Browse Source

Merge pull request #1196 in DESIGN/design from ~BRYANT/design:feature/10.0 to feature/10.0

* commit '31dfa564d15d534dfea62b5bd10e08cfd0f2ebf9':
  无jira任务 sonar问题修改
research/11.0
Bryant 5 years ago
parent
commit
c24499f09f
  1. 14
      designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java
  2. 32
      designer-base/src/main/java/com/fr/design/gui/syntax/print/RPrintUtilities.java

14
designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java

@ -102,7 +102,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal_white.png")}, {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal_white.png")},
{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment_white.png")}}; {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment_white.png")}};
Integer[] hAlignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT, Integer.valueOf(Constants.DISTRIBUTED), Constants.NULL}; Integer[] hAlignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT, Integer.valueOf(Constants.DISTRIBUTED), Constants.NULL};
hAlignmentPane = new UIButtonGroup<Integer>(hAlignmentIconArray, hAlignment); hAlignmentPane = new UIButtonGroup<>(hAlignmentIconArray, hAlignment);
hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Right"), hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Right"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Distributed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_DEFAULT")}); com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Distributed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_DEFAULT")});
hPaneContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); hPaneContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
@ -112,7 +112,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal_white.png")}, {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal_white.png")},
{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal_white.png")}}; {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal_white.png")}};
Integer[] vAlignment = new Integer[]{Constants.TOP, Constants.CENTER, Constants.BOTTOM}; Integer[] vAlignment = new Integer[]{Constants.TOP, Constants.CENTER, Constants.BOTTOM};
vAlignmentPane = new UIButtonGroup<Integer>(vAlignmentIconArray, vAlignment); vAlignmentPane = new UIButtonGroup<>(vAlignmentIconArray, vAlignment);
vAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Top"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Bottom")}); vAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Top"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Bottom")});
initOtherComponent(); initOtherComponent();
initAllNames(); initAllNames();
@ -174,7 +174,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
} }
private void initTextRotationCombox() { private void initTextRotationCombox() {
ArrayList<String> selectOption = new ArrayList<String>(); ArrayList<String> selectOption = new ArrayList<>();
selectOption.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Angle")); selectOption.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Angle"));
VerticalTextProcessor processor = ExtraClassManager.getInstance().getSingle(VerticalTextProcessor.XML_TAG, DefaultVerticalTextProcessor.class); VerticalTextProcessor processor = ExtraClassManager.getInstance().getSingle(VerticalTextProcessor.XML_TAG, DefaultVerticalTextProcessor.class);
selectOption.addAll(Arrays.asList(processor.getComboxOption())); selectOption.addAll(Arrays.asList(processor.getComboxOption()));
@ -343,8 +343,8 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
int rightPadding = indentationUnitProcessor.paddingUnitProcessor(style.getPaddingRight()); int rightPadding = indentationUnitProcessor.paddingUnitProcessor(style.getPaddingRight());
// alex:indent // alex:indent
this.leftIndentSpinner.setValue(new Integer(leftPadding)); this.leftIndentSpinner.setValue(leftPadding);
this.rightIndentSpinner.setValue(new Integer(rightPadding)); this.rightIndentSpinner.setValue(rightPadding);
this.spaceBeforeSpinner.setValue(style.getSpacingBefore()); this.spaceBeforeSpinner.setValue(style.getSpacingBefore());
this.spaceAfterSpinner.setValue(style.getSpacingAfter()); this.spaceAfterSpinner.setValue(style.getSpacingAfter());
@ -360,7 +360,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
public Style update(Style style) { public Style update(Style style) {
// peter:需要判断传递进来的值是否为null. // peter:需要判断传递进来的值是否为null.
if (style == null) { if (style == null) {
return style; return null;
} }
if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Pane_Horizontal"))) { if (ComparatorUtils.equals(globalNameListener.getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Pane_Horizontal"))) {
@ -463,7 +463,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO
} }
/** /**
* @param name * @param name 全局名
*/ */
public void setGlobalName(String name) { public void setGlobalName(String name) {
} }

32
designer-base/src/main/java/com/fr/design/gui/syntax/print/RPrintUtilities.java

@ -9,6 +9,8 @@
*/ */
package com.fr.design.gui.syntax.print; package com.fr.design.gui.syntax.print;
import com.fr.log.FineLoggerFactory;
import javax.swing.text.BadLocationException; import javax.swing.text.BadLocationException;
import javax.swing.text.Document; import javax.swing.text.Document;
import javax.swing.text.Element; import javax.swing.text.Element;
@ -62,8 +64,8 @@ public abstract class RPrintUtilities {
private static int getLineBreakPoint(String line, final int maxCharsPerLine) { private static int getLineBreakPoint(String line, final int maxCharsPerLine) {
int breakPoint = -1; int breakPoint = -1;
for (int i=0; i<breakChars.length; i++) { for (char breakChar : breakChars) {
int breakCharPos = line.lastIndexOf(breakChars[i], maxCharsPerLine-1); int breakCharPos = line.lastIndexOf(breakChar, maxCharsPerLine - 1);
if (breakCharPos > breakPoint) if (breakCharPos > breakPoint)
breakPoint = breakCharPos; breakPoint = breakCharPos;
} }
@ -147,11 +149,11 @@ public abstract class RPrintUtilities {
int tabIndex = curLineString.indexOf('\t'); int tabIndex = curLineString.indexOf('\t');
while (tabIndex > -1) { while (tabIndex > -1) {
int spacesNeeded = tabSizeInSpaces - (tabIndex % tabSizeInSpaces); int spacesNeeded = tabSizeInSpaces - (tabIndex % tabSizeInSpaces);
String replacementString = ""; StringBuilder replacementString = new StringBuilder();
for (int i=0; i<spacesNeeded; i++) for (int i=0; i<spacesNeeded; i++)
replacementString += ' '; replacementString.append(' ');
// Note that "\t" is actually a regex for this method. // Note that "\t" is actually a regex for this method.
curLineString = curLineString.replaceFirst("\t", replacementString); curLineString = curLineString.replaceFirst("\t", replacementString.toString());
tabIndex = curLineString.indexOf('\t'); tabIndex = curLineString.indexOf('\t');
} }
} }
@ -385,7 +387,7 @@ public abstract class RPrintUtilities {
doc.getText(currentLineStart+startingOffset, currentLineEnd-(currentLineStart+startingOffset), doc.getText(currentLineStart+startingOffset, currentLineEnd-(currentLineStart+startingOffset),
currentLineSeg); currentLineSeg);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
System.err.println("BadLocationException in print (where there shouldn't be one!): " + ble); FineLoggerFactory.getLogger().error("BadLocationException in print (where there shouldn't be one!): " + ble.getMessage());
return Printable.NO_SUCH_PAGE; return Printable.NO_SUCH_PAGE;
} }
@ -417,9 +419,9 @@ public abstract class RPrintUtilities {
// currentPos will be the last position in the current text of a "line break character." // currentPos will be the last position in the current text of a "line break character."
currentPos = -1; currentPos = -1;
String currentLineString = currentLineSeg.toString(); String currentLineString = currentLineSeg.toString();
for (int i=0; i<breakChars.length; i++) { for (char breakChar : breakChars) {
// "+1" below so we include the character on the line. // "+1" below so we include the character on the line.
int pos = currentLineString.lastIndexOf(breakChars[i]) + 1; int pos = currentLineString.lastIndexOf(breakChar) + 1;
//if (pos>-1 && pos>currentPos) //if (pos>-1 && pos>currentPos)
// currentPos = pos; // currentPos = pos;
if (pos > 0 && pos > currentPos & pos != currentLineString.length()) if (pos > 0 && pos > currentPos & pos != currentLineString.length())
@ -440,7 +442,7 @@ public abstract class RPrintUtilities {
try { try {
doc.getText(currentLineStart+startingOffset, currentPos, currentLineSeg); doc.getText(currentLineStart+startingOffset, currentPos, currentLineSeg);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
System.err.println(ble); FineLoggerFactory.getLogger().error(ble.getMessage());
return Printable.NO_SUCH_PAGE; return Printable.NO_SUCH_PAGE;
} }
currentLineLengthInPixels = Utilities. currentLineLengthInPixels = Utilities.
@ -453,12 +455,11 @@ public abstract class RPrintUtilities {
try { try {
doc.getText((currentLineStart+startingOffset), currentPos, currentLineSeg); doc.getText((currentLineStart+startingOffset), currentPos, currentLineSeg);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
System.err.println("BadLocationException in print (a):"); FineLoggerFactory.getLogger().error("BadLocationException in print (a):" + "==> currentLineStart: " + currentLineStart +
System.err.println("==> currentLineStart: " + currentLineStart + "; startingOffset: " + startingOffset + "; currentPos: " + currentPos +
"; startingOffset: " + startingOffset + "; currentPos: " + currentPos); "==> Range: " + (currentLineStart+startingOffset) + " - " +
System.err.println("==> Range: " + (currentLineStart+startingOffset) + " - " +
(currentLineStart+startingOffset+currentPos)); (currentLineStart+startingOffset+currentPos));
ble.printStackTrace(); FineLoggerFactory.getLogger().error(ble.getMessage());
return Printable.NO_SUCH_PAGE; return Printable.NO_SUCH_PAGE;
} }
@ -521,7 +522,8 @@ public abstract class RPrintUtilities {
return x; return x;
int tabSizeInPixels = tabSizeInSpaces * fm.charWidth(' '); int tabSizeInPixels = tabSizeInSpaces * fm.charWidth(' ');
int ntabs = (((int) x) - xOffset) / tabSizeInPixels; int ntabs = (((int) x) - xOffset) / tabSizeInPixels;
return xOffset + ((ntabs + 1) * tabSizeInPixels); float reFloat = xOffset + ((ntabs + 1) * tabSizeInPixels);
return reFloat;
} }
} }

Loading…
Cancel
Save