Skip to content

Commit

Permalink
Fix documentation and eclipse warnings (#1931)
Browse files Browse the repository at this point in the history
  • Loading branch information
speckyspooky authored Oct 6, 2024
1 parent 12e0b7c commit ee625c6
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@
import org.eclipse.birt.report.designer.internal.ui.views.attributes.section.SimpleComboSection;
import org.eclipse.birt.report.designer.internal.ui.views.attributes.section.TextSection;
import org.eclipse.birt.report.designer.ui.views.ElementAdapterManager;
import org.eclipse.birt.report.model.api.ReportItemHandle;
import org.eclipse.birt.report.model.api.StyleHandle;
import org.eclipse.birt.report.model.api.TextItemHandle;
import org.eclipse.birt.report.model.api.elements.ReportDesignConstants;
import org.eclipse.birt.report.model.elements.interfaces.IDesignElementModel;
import org.eclipse.birt.report.model.elements.interfaces.IInternalReportItemModel;
import org.eclipse.birt.report.model.elements.interfaces.IStyleModel;
import org.eclipse.birt.report.model.elements.interfaces.IStyledElementModel;
import org.eclipse.birt.report.model.elements.interfaces.ITextItemModel;
import org.eclipse.swt.SWT;

/**
Expand All @@ -51,29 +52,29 @@ public class TextPage extends GeneralPage {
protected void buildContent() {
// Defines providers.

IDescriptorProvider nameProvider = new TextPropertyDescriptorProvider(ReportItemHandle.NAME_PROP,
IDescriptorProvider nameProvider = new TextPropertyDescriptorProvider(IDesignElementModel.NAME_PROP,
ReportDesignConstants.TEXT_ITEM);

IDescriptorProvider contentTypeProvider = new ComboPropertyDescriptorProvider(TextItemHandle.CONTENT_TYPE_PROP,
IDescriptorProvider contentTypeProvider = new ComboPropertyDescriptorProvider(ITextItemModel.CONTENT_TYPE_PROP,
ReportDesignConstants.TEXT_ITEM);

IDescriptorProvider styleProvider = new SimpleComboPropertyDescriptorProvider(ReportItemHandle.STYLE_PROP,
IDescriptorProvider styleProvider = new SimpleComboPropertyDescriptorProvider(IStyledElementModel.STYLE_PROP,
ReportDesignConstants.REPORT_ITEM);

ComboPropertyDescriptorProvider fontFamilyProvider = new ComboPropertyDescriptorProvider(
StyleHandle.FONT_FAMILY_PROP, ReportDesignConstants.STYLE_ELEMENT);
IStyleModel.FONT_FAMILY_PROP, ReportDesignConstants.STYLE_ELEMENT);
fontFamilyProvider.enableReset(true);

FontSizePropertyDescriptorProvider fontSizeProvider = new FontSizePropertyDescriptorProvider(
StyleHandle.FONT_SIZE_PROP, ReportDesignConstants.STYLE_ELEMENT);
IStyleModel.FONT_SIZE_PROP, ReportDesignConstants.STYLE_ELEMENT);
fontSizeProvider.enableReset(true);

ColorPropertyDescriptorProvider colorProvider = new ColorPropertyDescriptorProvider(StyleHandle.COLOR_PROP,
ColorPropertyDescriptorProvider colorProvider = new ColorPropertyDescriptorProvider(IStyleModel.COLOR_PROP,
ReportDesignConstants.STYLE_ELEMENT);
colorProvider.enableReset(true);

ColorPropertyDescriptorProvider bgColorProvider = new ColorPropertyDescriptorProvider(
StyleHandle.BACKGROUND_COLOR_PROP, ReportDesignConstants.STYLE_ELEMENT);
IStyleModel.BACKGROUND_COLOR_PROP, ReportDesignConstants.STYLE_ELEMENT);
bgColorProvider.enableReset(true);

IDescriptorProvider[] fontStyleProviders = createFontStyleProviders();
Expand Down Expand Up @@ -153,7 +154,7 @@ protected void buildContent() {
addSection(PageSectionId.TEXT_ELEMENT_ID, elementIdSection);

ComboPropertyDescriptorProvider wordwrapProvider = new ComboPropertyDescriptorProvider(
StyleHandle.WHITE_SPACE_PROP, ReportDesignConstants.STYLE_ELEMENT);
IStyleModel.WHITE_SPACE_PROP, ReportDesignConstants.STYLE_ELEMENT);
wordwrapProvider.enableReset(true);
RadioGroupSection wordwrapSection = new RadioGroupSection(wordwrapProvider.getDisplayName(), container, true);
wordwrapSection.setProvider(wordwrapProvider);
Expand Down Expand Up @@ -193,29 +194,25 @@ protected void buildContent() {
*/
private IDescriptorProvider[] createFontStyleProviders() {
PropertyDescriptorProvider[] providers = {
// Creates providers with StyleHandle.FONT_WEIGHT_PROP,
// StyleHandle.FONT_STYLE_PROP, StyleHandle.TEXT_UNDERLINE_PROP,
// StyleHandle.TEXT_LINE_THROUGH_PROP and
// StyleHandle.TEXT_ALIGN_PROP.

new FontStylePropertyDescriptorProvider(StyleHandle.FONT_WEIGHT_PROP,
new FontStylePropertyDescriptorProvider(IStyleModel.FONT_WEIGHT_PROP,
ReportDesignConstants.STYLE_ELEMENT),

new FontStylePropertyDescriptorProvider(StyleHandle.FONT_STYLE_PROP,
new FontStylePropertyDescriptorProvider(IStyleModel.FONT_STYLE_PROP,
ReportDesignConstants.STYLE_ELEMENT),

new FontStylePropertyDescriptorProvider(StyleHandle.TEXT_UNDERLINE_PROP,
new FontStylePropertyDescriptorProvider(IStyleModel.TEXT_UNDERLINE_PROP,
ReportDesignConstants.STYLE_ELEMENT),

new FontStylePropertyDescriptorProvider(StyleHandle.TEXT_LINE_THROUGH_PROP,
new FontStylePropertyDescriptorProvider(IStyleModel.TEXT_LINE_THROUGH_PROP,
ReportDesignConstants.STYLE_ELEMENT),

new PropertyDescriptorProvider(StyleHandle.TEXT_ALIGN_PROP, ReportDesignConstants.STYLE_ELEMENT)
new PropertyDescriptorProvider(IStyleModel.TEXT_ALIGN_PROP, ReportDesignConstants.STYLE_ELEMENT)
// bidi_hcg
};

for (int i = 0; i < providers.length; i++) {
((PropertyDescriptorProvider) providers[i]).enableReset(true);
providers[i].enableReset(true);
}

return providers;
Expand All @@ -230,7 +227,7 @@ protected void applyCustomSections() {
if (helperProvider != null) {
ISectionHelper helper = helperProvider.createHelper(this, PageConstants.THEME_HELPER_KEY);
if (helper != null) {
Section section = helper.createSection(container, TextItemHandle.THEME_PROP,
Section section = helper.createSection(container, IInternalReportItemModel.THEME_PROP,
ReportDesignConstants.TEXT_ITEM, true);
if (section instanceof SimpleComboSection) {
((SimpleComboSection) section).setWidth(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ public void performDirectEdit() {
}

/**
* @return
* Get the label adapter
*
* @return the label adapter
*/
protected LabelHandleAdapter getLabelAdapter() {
return (LabelHandleAdapter) getModelAdapter();
Expand Down Expand Up @@ -155,7 +157,7 @@ public void refreshFigure() {
/**
* Returns if the model element has explicit text set.
*
* @return
* @return if the model element has explicit text set.
*/
protected boolean hasText() {
if (StringUtil.isBlank(((LabelHandle) getModel()).getDisplayText())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FigureUtilities;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.StackLayout;
import org.eclipse.draw2d.geometry.Dimension;
Expand All @@ -29,6 +30,7 @@
import org.eclipse.draw2d.text.FlowFigure;
import org.eclipse.draw2d.text.FlowPage;
import org.eclipse.draw2d.text.ParagraphTextLayout;
import org.eclipse.draw2d.text.TextFragmentBox;
import org.eclipse.swt.graphics.Font;

import com.ibm.icu.text.BreakIterator;
Expand Down Expand Up @@ -61,7 +63,9 @@ public LabelFigure() {
}

/**
* @return
* Get the display of the label figure
*
* @return the label figure
*/
public String getDisplay() {
return display;
Expand All @@ -82,15 +86,12 @@ public LabelFigure(int borderSize) {
public void postValidate() {
if (DesignChoiceConstants.DISPLAY_BLOCK.equals(display)
|| DesignChoiceConstants.DISPLAY_INLINE.equals(display)) {
List list = getFragments();
FlowBox box;
List<? extends TextFragmentBox> listBox = getFragments();

int left = Integer.MAX_VALUE, top = left;
int bottom = Integer.MIN_VALUE;

for (int i = 0; i < list.size(); i++) {
box = (FlowBox) list.get(i);

for (FlowBox box : listBox) {
left = Math.min(left, box.getX());
top = Math.min(top, box.getBaseline() - box.getAscent());
bottom = Math.max(bottom, box.getBaseline() + box.getDescent());
Expand All @@ -110,9 +111,9 @@ public void postValidate() {
child.setBounds(new Rectangle(rect.x, rect.y, width, rect.height));
}

list = getChildren();
for (int i = 0; i < list.size(); i++) {
((FlowFigure) list.get(i)).postValidate();
List<? extends IFigure> listFigure = getChildren();
for (IFigure flowFigure : listFigure) {
((FlowFigure) flowFigure).postValidate();
}
} else {
super.postValidate();
Expand Down Expand Up @@ -212,9 +213,8 @@ private Dimension getMinimumSize(int wHint, int hHint, boolean isFix, boolean fo
dim = super.getMinimumSize(tempHint <= 0 ? -1 : tempHint, hHint);

return new Dimension(Math.max(dim.width, rx), Math.max(dim.height, ry));
} else {
dim = super.getMinimumSize(rx == 0 ? -1 : rx, hHint);
}
dim = super.getMinimumSize(rx == 0 ? -1 : rx, hHint);

if (dim.width < wHint) {
return new Dimension(Math.max(dim.width, rx), Math.max(dim.height, ry));
Expand Down Expand Up @@ -336,7 +336,7 @@ public void setRecommendSize(Dimension recommendSize) {
/**
* Gets the recommended size.
*
* @return
* @return the recommended size.
*/
public Dimension getRecommendSize() {
return recommendSize;
Expand Down Expand Up @@ -538,10 +538,20 @@ public Dimension getFixMinimumSize(int w, int h) {
return new Dimension(width, height);
}

/**
* Is the fixed layout in use
*
* @return is fixed layout in use
*/
public boolean isFixLayout() {
return isFixLayout;
}

/**
* Set the fixed layout
*
* @param isFixLayout fixed layout is used
*/
public void setFixLayout(boolean isFixLayout) {
this.isFixLayout = isFixLayout;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ public void paintTo(Graphics g, Point translationPoint) {
/**
* Paints self to specified graphics with given X,Y offsets.
*
* @param g
* @param xoff
* @param yoff
* @param g graphic
* @param xoff x offset
* @param yoff y offset
*/
public void paintTo(Graphics g, int xoff, int yoff) {
List fragments = this.getFragments();
List<? extends TextFragmentBox> fragments = this.getFragments();
assert this.getFont().getFontData().length > 0;

/**
Expand All @@ -187,9 +187,16 @@ public void paintTo(Graphics g, int xoff, int yoff) {
}

// bidi_hcg: rename and leave an old method for now.
/**
* Paints self to specified graphics with given X,Y offsets.
*
* @param g graphic
* @param xoff x offset
* @param yoff y offset
*/
public void paintTo_old(Graphics g, int xoff, int yoff) {
TextFragmentBox frag;
List fragments = this.getFragments();
List<? extends TextFragmentBox> fragments = this.getFragments();
assert this.getFont().getFontData().length > 0;

/**
Expand All @@ -201,14 +208,11 @@ public void paintTo_old(Graphics g, int xoff, int yoff) {
*/
int totalHeight = 0;
for (int i = 0; i < fragments.size(); i++) {
// FlowBoxWrapper wrapper = new FlowBoxWrapper( (FlowBox) fragments
// .get( i ) );
totalHeight += ((TextFragmentBox) fragments.get(i)).getAscent()
+ ((TextFragmentBox) fragments.get(i)).getDescent();
totalHeight += fragments.get(i).getAscent() + fragments.get(i).getDescent();
}

for (int i = 0; i < fragments.size(); i++) {
frag = (TextFragmentBox) fragments.get(i);
frag = fragments.get(i);

// FlowBoxWrapper wrapper = new FlowBoxWrapper( frag );
String draw = null;
Expand Down Expand Up @@ -317,7 +321,7 @@ private void paintSpecial_old(Graphics g, String text, int x, int y, boolean fir
* @return Next fragment index or -1 if there is no more fragments to process
*/
private int paintLineTo(Graphics g, int xoff, int yoff, int lineWidth, int fragIndex, boolean isMirrored) {
List fragments = this.getFragments();
List<? extends TextFragmentBox> fragments = this.getFragments();
if (fragments == null) {
return -1;
}
Expand All @@ -331,7 +335,7 @@ private int paintLineTo(Graphics g, int xoff, int yoff, int lineWidth, int fragI
* Get the total fragments height first
*/
// bidi_hcg start
TextFragmentBox frag = (TextFragmentBox) fragments.get(fragIndex);
TextFragmentBox frag = fragments.get(fragIndex);
int totalHeight = frag.getAscent() + frag.getDescent();
int totalWidth = 0;
String[] draws = new String[nFragments - fragIndex];
Expand Down Expand Up @@ -381,7 +385,7 @@ private int paintLineTo(Graphics g, int xoff, int yoff, int lineWidth, int fragI
break;
}

frag = (TextFragmentBox) fragments.get(i);
frag = fragments.get(i);

prevLineRoot = lineRoot;

Expand All @@ -399,7 +403,7 @@ private int paintLineTo(Graphics g, int xoff, int yoff, int lineWidth, int fragI
// bidi_hcg end

for (i = fragIndex; i < retIndex; i++) {
frag = (TextFragmentBox) fragments.get(i);
frag = fragments.get(i);

int fragAscent = frag.getAscent();

Expand Down Expand Up @@ -546,7 +550,8 @@ protected void paintFigure(Graphics g) {
*
* @param compWidth Container width.
* @param textWidth Text width.
* @return
* @return the left coordinate by given container width, text width and
* horizontal alignment style.
*/
protected int calculateLeft(int compWidth, int textWidth) {
int rlt = 0;
Expand Down Expand Up @@ -596,7 +601,8 @@ private int calculateSpacing(int compWidth, int textWidth, boolean isMirrored) {
*
* @param compHeight Container height.
* @param textHeight text height.
* @return
* @return the top coordinate by given container height, text height and
* vertical alignment style.
*/
protected int calculateTop(int compHeight, int textHeight) {
int rlt = 0;
Expand Down Expand Up @@ -625,7 +631,7 @@ public void setTextAlign(String textAlign) {
/**
* Gets the horizontal text alignment style.
*
* @return
* @return the horizontal text alignment style.
*/
public String getTextAlign() {
return textAlign;
Expand Down
Loading

0 comments on commit ee625c6

Please sign in to comment.