Browse Source

Merge branch 'feature/10.0' of https://cloud.finedevelop.com/scm/design/design into feature/10.0

# Conflicts:
#	designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java
research/11.0
vito 5 years ago
parent
commit
c72bcbad55
  1. 2
      designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java
  2. 52
      designer-base/src/main/java/com/fr/design/beans/BasicBeanPane.java
  3. 6
      designer-base/src/main/java/com/fr/design/beans/FurtherBasicBeanPane.java
  4. 3
      designer-base/src/main/java/com/fr/design/condition/ConditionAttrSingleConditionPane.java
  5. 2
      designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java
  6. 6
      designer-base/src/main/java/com/fr/design/dialog/BasicDialog.java
  7. 17
      designer-base/src/main/java/com/fr/design/dialog/BasicPane.java
  8. 3
      designer-base/src/main/java/com/fr/design/dialog/DialogActionAdapter.java
  9. 7
      designer-base/src/main/java/com/fr/design/dialog/DialogActionListener.java
  10. 8
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  11. 31
      designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java
  12. 35
      designer-base/src/main/java/com/fr/design/gui/itable/AbstractPropertyTable.java
  13. 2
      designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java
  14. 3
      designer-base/src/main/java/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java
  15. 1
      designer-base/src/main/java/com/fr/design/gui/style/NumberDragBar.java
  16. 4
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxDocument.java
  17. 3806
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java
  18. 2563
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java
  19. 433
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java
  20. 100
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java
  21. 5
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java
  22. 8
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java
  23. 3
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextArea.java
  24. 2
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java
  25. 10
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/VolatileImageBackgroundPainterStrategy.java
  26. 6
      designer-base/src/main/java/com/fr/design/icon/LockIcon.java
  27. 1
      designer-base/src/main/java/com/fr/design/icon/WarningIcon.java
  28. 1
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  29. 23
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  30. 7
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java
  31. 5
      designer-base/src/main/java/com/fr/design/report/WatermarkPane.java
  32. 1
      designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java
  33. 1
      designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java
  34. 1
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  35. 1
      designer-base/src/main/java/com/fr/design/utils/DrawRoutines.java
  36. 1
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  37. 20
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java
  38. 6
      designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java
  39. 9
      designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java
  40. 5
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java
  41. 4
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java
  42. 10
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BarPlotPane.java
  43. 10
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ColumnPlotPane.java
  44. 10
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java
  45. 10
      designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaPlotPane.java
  46. 5
      designer-chart/src/main/java/com/fr/van/chart/bar/VanChartBarPlotPane.java
  47. 5
      designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java
  48. 5
      designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotPane.java
  49. 4
      designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java
  50. 5
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java
  51. 6
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java
  52. 5
      designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java

2
designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java

@ -5,6 +5,7 @@
package com.fr.design; package com.fr.design;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.common.annotations.Open;
import com.fr.design.data.datapane.TableDataNameObjectCreator; import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.fun.*; import com.fr.design.fun.*;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
@ -34,6 +35,7 @@ import java.util.Set;
* @since : 8.0 * @since : 8.0
* 用于设计器扩展的管理类 * 用于设计器扩展的管理类
*/ */
@Open
public class ExtraDesignClassManager extends AbstractExtraClassManager implements ExtraDesignClassManagerProvider { public class ExtraDesignClassManager extends AbstractExtraClassManager implements ExtraDesignClassManagerProvider {
private static ExtraDesignClassManager classManager = new ExtraDesignClassManager(); private static ExtraDesignClassManager classManager = new ExtraDesignClassManager();

52
designer-base/src/main/java/com/fr/design/beans/BasicBeanPane.java

@ -1,41 +1,35 @@
package com.fr.design.beans; package com.fr.design.beans;
import com.fr.common.annotations.Open;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
/** @Open
* Update Pane
*/
public abstract class BasicBeanPane<T> extends BasicPane { public abstract class BasicBeanPane<T> extends BasicPane {
/**
* 展示数据
* @param ob 待展示的对象
*/
public abstract void populateBean(T ob);
/**
* 保存数据
* @return 待保存的对象
*/
public abstract T updateBean();
/** /**
* Populate. * 保存数据
*/ * @param ob 待保存的对象
public abstract void populateBean(T ob); */
public void updateBean(T ob) {
/** }
* Update.
*/
public abstract T updateBean();
public void updateBean(T ob) { /**
* 更新权限工具栏面板
} */
public void populateAuthority() {
/**
* 更新权限工具栏面板
*/
public void populateAuthority() {
}
/**
* 仅用来处理图表设计器的地图面板
* @param mapType 地图类型
*/
public void dealWidthMap(String mapType){
}
}
} }

6
designer-base/src/main/java/com/fr/design/beans/FurtherBasicBeanPane.java

@ -1,11 +1,9 @@
package com.fr.design.beans; package com.fr.design.beans;
import com.fr.common.annotations.Open;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
/** @Open
* @author zhou
* @since 2012-5-30下午12:12:42
*/
public abstract class FurtherBasicBeanPane<T> extends BasicBeanPane<T> { public abstract class FurtherBasicBeanPane<T> extends BasicBeanPane<T> {
/** /**
* 是否是指定类型 * 是否是指定类型

3
designer-base/src/main/java/com/fr/design/condition/ConditionAttrSingleConditionPane.java

@ -1,10 +1,13 @@
package com.fr.design.condition; package com.fr.design.condition;
import com.fr.common.annotations.Open;
/** /**
* @author richie * @author richie
* @date 2015-03-26 * @date 2015-03-26
* @since 8.0 * @since 8.0
*/ */
@Open
public abstract class ConditionAttrSingleConditionPane<T> extends SingleConditionPane<T> { public abstract class ConditionAttrSingleConditionPane<T> extends SingleConditionPane<T> {
protected HighLightConditionAction hightLighAttrUpdateAction = null; protected HighLightConditionAction hightLighAttrUpdateAction = null;
private ConditionAttributesPane conditionAttributesPane; private ConditionAttributesPane conditionAttributesPane;

2
designer-base/src/main/java/com/fr/design/condition/ConditionAttributesPane.java

@ -1,6 +1,7 @@
package com.fr.design.condition; package com.fr.design.condition;
import com.fr.common.annotations.Open;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
@ -17,6 +18,7 @@ import java.awt.Dimension;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@Open
public abstract class ConditionAttributesPane<T> extends BasicBeanPane<T> { public abstract class ConditionAttributesPane<T> extends BasicBeanPane<T> {
private static final int MIN_HEIGHT = 60; private static final int MIN_HEIGHT = 60;
protected CellHighlightAddMenuDef menuDef; protected CellHighlightAddMenuDef menuDef;

6
designer-base/src/main/java/com/fr/design/dialog/BasicDialog.java

@ -1,10 +1,10 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
import java.awt.*; import java.awt.*;
/* @Open
* @author _denny
*/
public abstract class BasicDialog extends UIDialog { public abstract class BasicDialog extends UIDialog {
public static final Dimension SMALL = new Dimension(340, 180); public static final Dimension SMALL = new Dimension(340, 180);
public static final Dimension MEDIUM = new Dimension(600, 400); public static final Dimension MEDIUM = new Dimension(600, 400);

17
designer-base/src/main/java/com/fr/design/dialog/BasicPane.java

@ -1,24 +1,17 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.JPanel; import javax.swing.*;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Color;
import java.awt.Dialog; @Open
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Window;
/*
* _denny: 这里的BasicPane通常会有populate & update方法
* 记得populate 一定要在对应的dialog setVisible之前populate
*/
public abstract class BasicPane extends JPanel { public abstract class BasicPane extends JPanel {
/** /**

3
designer-base/src/main/java/com/fr/design/dialog/DialogActionAdapter.java

@ -1,5 +1,8 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
@Open
public abstract class DialogActionAdapter implements DialogActionListener { public abstract class DialogActionAdapter implements DialogActionListener {
@Override @Override
public void doOk() {} public void doOk() {}

7
designer-base/src/main/java/com/fr/design/dialog/DialogActionListener.java

@ -1,8 +1,11 @@
package com.fr.design.dialog; package com.fr.design.dialog;
import com.fr.common.annotations.Open;
@Open
public interface DialogActionListener { public interface DialogActionListener {
public void doOk(); void doOk();
public void doCancel(); void doCancel();
} }

8
designer-base/src/main/java/com/fr/design/dialog/UIDialog.java

@ -25,13 +25,7 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Created with IntelliJ IDEA.
* User: 小灰灰
* Date: 13-7-16
* Time: 下午2:17
* To change this template use File | Settings | File Templates.
*/
public abstract class UIDialog extends JDialog { public abstract class UIDialog extends JDialog {
public static final String OK_BUTTON = "basic_ok"; public static final String OK_BUTTON = "basic_ok";
public static final String CANCEL_BUTTON = "basic_cancel"; public static final String CANCEL_BUTTON = "basic_cancel";

31
designer-base/src/main/java/com/fr/design/gui/ispinner/UnsignedIntUISpinner.java

@ -0,0 +1,31 @@
package com.fr.design.gui.ispinner;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField;
/**
* Created by IntelliJ IDEA.
* Author : Hugh.C
* Date: 19-08-28
* Time: 下午2:19
*/
public class UnsignedIntUISpinner extends UISpinner {
public UnsignedIntUISpinner(double minValue, double maxValue, double dierta) {
super(minValue, maxValue, dierta);
}
public UnsignedIntUISpinner(double minValue, double maxValue, double dierta, double defaultValue) {
super(minValue, maxValue, dierta, defaultValue);
}
@Override
protected UINumberField initNumberField() {
return new UIIntNumberField() {
public boolean shouldResponseChangeListener() {
return false;
}
};
}
}

35
designer-base/src/main/java/com/fr/design/gui/itable/AbstractPropertyTable.java

@ -3,11 +3,15 @@
*/ */
package com.fr.design.gui.itable; package com.fr.design.gui.itable;
import java.awt.*; import com.fr.general.ComparatorUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.ListSelectionModel; import javax.swing.ListSelectionModel;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
@ -16,9 +20,6 @@ import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import com.fr.general.ComparatorUtils;
/** /**
* @author richer * @author richer
* @since 6.5.3 * @since 6.5.3
@ -109,8 +110,8 @@ public abstract class AbstractPropertyTable extends JTable {
@Override @Override
public TableCellEditor getCellEditor(int row, int column) { public TableCellEditor getCellEditor(int row, int column) {
if (groups != null) { Point pIndex = getGroupIndex(row);
Point pIndex = getGroupIndex(row); if (groups != null && pIndex != null) {
PropertyGroup group = groups.get(pIndex.x); PropertyGroup group = groups.get(pIndex.x);
if (pIndex.y == 0) { if (pIndex.y == 0) {
return super.getCellEditor(row, column); return super.getCellEditor(row, column);
@ -162,7 +163,7 @@ public abstract class AbstractPropertyTable extends JTable {
int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint()); int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint());
if (row != -1) { if (row != -1) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (pIndex.y == 0 && e.getClickCount() > 1) { if (pIndex != null && pIndex.y == 0 && e.getClickCount() > 1) {
toggleCollapse(pIndex.x); toggleCollapse(pIndex.x);
} }
} }
@ -180,7 +181,7 @@ public abstract class AbstractPropertyTable extends JTable {
int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint()); int row = AbstractPropertyTable.super.rowAtPoint(e.getPoint());
if (row != -1) { if (row != -1) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (pIndex.y == 0 && e.getClickCount() == 1 && e.getX() < PROPERTY_ICON_WIDTH) { if (pIndex != null && pIndex.y == 0 && e.getClickCount() == 1 && e.getX() < PROPERTY_ICON_WIDTH) {
toggleCollapse(pIndex.x); toggleCollapse(pIndex.x);
} }
} }
@ -263,6 +264,9 @@ public abstract class AbstractPropertyTable extends JTable {
@Override @Override
public void setValueAt(Object aValue, int row, int column) { public void setValueAt(Object aValue, int row, int column) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
if (pIndex == null) {
return;
}
PropertyGroup group = groups.get(pIndex.x); PropertyGroup group = groups.get(pIndex.x);
if (pIndex.y != 0) { if (pIndex.y != 0) {
Object old_value = getValueAt(row, column); Object old_value = getValueAt(row, column);
@ -276,16 +280,11 @@ public abstract class AbstractPropertyTable extends JTable {
@Override @Override
public boolean isCellEditable(int row, int column) { public boolean isCellEditable(int row, int column) {
Point pIndex = getGroupIndex(row); Point pIndex = getGroupIndex(row);
PropertyGroup group = groups.get(pIndex.x); if (pIndex == null) {
if (pIndex.y == 0) { return false;
if (column == 0) {
return false;
} else {
return false;
}
} else {
return column == 1 && group.getModel().isEditable(pIndex.y - 1);
} }
PropertyGroup group = groups.get(pIndex.x);
return pIndex.y != 0 && (column == 1 && group.getModel().isEditable(pIndex.y - 1));
} }
} }
} }

2
designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java

@ -244,7 +244,7 @@ public abstract class UITableModelAdapter<T extends Object> extends AbstractTabl
FineLoggerFactory.getLogger().error(ee.getMessage(), ee); FineLoggerFactory.getLogger().error(ee.getMessage(), ee);
} }
} }
if (getRowCount() < 1 || selectedRow.length < 0) { if (getRowCount() < 1) {
return; return;
} }

3
designer-base/src/main/java/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java

@ -153,6 +153,7 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
try { try {
Thread.sleep(3); Thread.sleep(3);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt();
} }
} }
if (currentPanel != panel) { if (currentPanel != panel) {
@ -202,7 +203,7 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent {
} }
@Override @Override
public int getSelectedIndex() { public synchronized int getSelectedIndex() {
return selectedIndex; return selectedIndex;
} }

1
designer-base/src/main/java/com/fr/design/gui/style/NumberDragBar.java

@ -127,6 +127,7 @@ public class NumberDragBar extends JComponent {
revalidate(); revalidate();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.toString()); FineLoggerFactory.getLogger().error(e.toString());
Thread.currentThread().interrupt();
} }
} }
}); });

4
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxDocument.java

@ -366,7 +366,9 @@ public class RSyntaxDocument extends RDocument implements Iterable<Token>,
*/ */
public boolean getShouldIndentNextLine(int line) { public boolean getShouldIndentNextLine(int line) {
Token t = getTokenListForLine(line); Token t = getTokenListForLine(line);
t = t.getLastNonCommentNonWhitespaceToken(); if (t != null) {
t = t.getLastNonCommentNonWhitespaceToken();
}
return tokenMaker.getShouldIndentNextLineAfter(t); return tokenMaker.getShouldIndentNextLineAfter(t);
} }

3806
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextAreaEditorKit.java

File diff suppressed because it is too large Load Diff

2563
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxUtilities.java

File diff suppressed because it is too large Load Diff

433
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/SyntaxView.java

@ -9,24 +9,37 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import java.awt.*;
import javax.swing.event.*;
import javax.swing.text.*;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import javax.swing.event.DocumentEvent;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import javax.swing.text.PlainDocument;
import javax.swing.text.Position;
import javax.swing.text.TabExpander;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
/** /**
* The <code>javax.swing.text.View</code> object used by {@link RSyntaxTextArea} * The <code>javax.swing.text.View</code> object used by {@link RSyntaxTextArea}
* when word wrap is disabled. It implements syntax highlighting for * when word wrap is disabled. It implements syntax highlighting for
* programming languages using the colors and font styles specified by the * programming languages using the colors and font styles specified by the
* <code>RSyntaxTextArea</code>.<p> * <code>RSyntaxTextArea</code>.<p>
* * <p>
* You don't really have to do anything to use this class, as * You don't really have to do anything to use this class, as
* {@link RSyntaxTextAreaUI} automatically sets the text area's view to be * {@link RSyntaxTextAreaUI} automatically sets the text area's view to be
* an instance of this class if word wrap is disabled.<p> * an instance of this class if word wrap is disabled.<p>
* * <p>
* The tokens that specify how to paint the syntax-highlighted text are gleaned * The tokens that specify how to paint the syntax-highlighted text are gleaned
* from the text area's {@link RSyntaxDocument}. * from the text area's {@link RSyntaxDocument}.
* *
@ -34,7 +47,7 @@ import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
* @version 0.3 * @version 0.3
*/ */
public class SyntaxView extends View implements TabExpander, public class SyntaxView extends View implements TabExpander,
TokenOrientedView, RSTAView { TokenOrientedView, RSTAView {
/** /**
* The default font used by the text area. If this changes we need to * The default font used by the text area. If this changes we need to
@ -105,7 +118,7 @@ public class SyntaxView extends View implements TabExpander,
tabSize = getTabSize() * metrics.charWidth(' '); tabSize = getTabSize() * metrics.charWidth(' ');
Element lines = getElement(); Element lines = getElement();
int n = lines.getElementCount(); int n = lines.getElementCount();
for (int i=0; i<n; i++) { for (int i = 0; i < n; i++) {
Element line = lines.getElement(i); Element line = lines.getElement(i);
float w = getLineWidth(i); float w = getLineWidth(i);
if (w > longLineWidth) { if (w > longLineWidth) {
@ -121,8 +134,8 @@ public class SyntaxView extends View implements TabExpander,
* in a location that this view is responsible for. * in a location that this view is responsible for.
* *
* @param changes the change information from the associated document * @param changes the change information from the associated document
* @param a the current allocation of the view * @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children * @param f the factory to use to rebuild if the view has children
* @see View#changedUpdate * @see View#changedUpdate
*/ */
@Override @Override
@ -135,22 +148,21 @@ public class SyntaxView extends View implements TabExpander,
* Repaint the given line range. * Repaint the given line range.
* *
* @param line0 The starting line number to repaint. This must * @param line0 The starting line number to repaint. This must
* be a valid line number in the model. * be a valid line number in the model.
* @param line1 The ending line number to repaint. This must * @param line1 The ending line number to repaint. This must
* be a valid line number in the model. * be a valid line number in the model.
* @param a The region allocated for the view to render into. * @param a The region allocated for the view to render into.
* @param host The component hosting the view (used to call repaint). * @param host The component hosting the view (used to call repaint).
*/ */
protected void damageLineRange(int line0, int line1, Shape a, protected void damageLineRange(int line0, int line1, Shape a,
Component host) { Component host) {
if (a != null) { if (a != null) {
Rectangle area0 = lineToRect(a, line0); Rectangle area0 = lineToRect(a, line0);
Rectangle area1 = lineToRect(a, line1); Rectangle area1 = lineToRect(a, line1);
if ((area0 != null) && (area1 != null)) { if ((area0 != null) && (area1 != null)) {
Rectangle dmg = area0.union(area1); // damage. Rectangle dmg = area0.union(area1); // damage.
host.repaint(dmg.x, dmg.y, dmg.width, dmg.height); host.repaint(dmg.x, dmg.y, dmg.width, dmg.height);
} } else
else
host.repaint(); host.repaint();
} }
} }
@ -163,19 +175,19 @@ public class SyntaxView extends View implements TabExpander,
* off. * off.
* *
* @param painter The painter to render the tokens. * @param painter The painter to render the tokens.
* @param token The list of tokens to draw. * @param token The list of tokens to draw.
* @param g The graphics context in which to draw. * @param g The graphics context in which to draw.
* @param x The x-coordinate at which to draw. * @param x The x-coordinate at which to draw.
* @param y The y-coordinate at which to draw. * @param y The y-coordinate at which to draw.
* @return The x-coordinate representing the end of the painted text. * @return The x-coordinate representing the end of the painted text.
*/ */
private float drawLine(TokenPainter painter, Token token, Graphics2D g, private float drawLine(TokenPainter painter, Token token, Graphics2D g,
float x, float y) { float x, float y) {
float nextX = x; // The x-value at the end of our text. float nextX = x; // The x-value at the end of our text.
while (token!=null && token.isPaintable() && nextX<clipEnd) { while (token != null && token.isPaintable() && nextX < clipEnd) {
nextX = painter.paint(token, g, nextX,y, host, this, clipStart); nextX = painter.paint(token, g, nextX, y, host, this, clipStart);
token = token.getNextToken(); token = token.getNextToken();
} }
@ -198,29 +210,29 @@ public class SyntaxView extends View implements TabExpander,
* language. Tokens are checked for being in a selected region, and are * language. Tokens are checked for being in a selected region, and are
* rendered appropriately if they are. * rendered appropriately if they are.
* *
* @param painter The painter to render the tokens. * @param painter The painter to render the tokens.
* @param token The list of tokens to draw. * @param token The list of tokens to draw.
* @param g The graphics context in which to draw. * @param g The graphics context in which to draw.
* @param x The x-coordinate at which to draw. * @param x The x-coordinate at which to draw.
* @param y The y-coordinate at which to draw. * @param y The y-coordinate at which to draw.
* @param selStart The start of the selection. * @param selStart The start of the selection.
* @param selEnd The end of the selection. * @param selEnd The end of the selection.
* @return The x-coordinate representing the end of the painted text. * @return The x-coordinate representing the end of the painted text.
*/ */
private float drawLineWithSelection(TokenPainter painter, Token token, private float drawLineWithSelection(TokenPainter painter, Token token,
Graphics2D g, float x, float y, int selStart, int selEnd) { Graphics2D g, float x, float y, int selStart, int selEnd) {
float nextX = x; // The x-value at the end of our text. float nextX = x; // The x-value at the end of our text.
while (token!=null && token.isPaintable() && nextX<clipEnd) { while (token != null && token.isPaintable() && nextX < clipEnd) {
// Selection starts in this token // Selection starts in this token
if (token.containsPosition(selStart)) { if (token.containsPosition(selStart)) {
if (selStart>token.getOffset()) { if (selStart > token.getOffset()) {
tempToken.copyFrom(token); tempToken.copyFrom(token);
tempToken.textCount = selStart - tempToken.getOffset(); tempToken.textCount = selStart - tempToken.getOffset();
nextX = painter.paint(tempToken,g,nextX,y,host, this, clipStart); nextX = painter.paint(tempToken, g, nextX, y, host, this, clipStart);
tempToken.textCount = token.length(); tempToken.textCount = token.length();
tempToken.makeStartAt(selStart); tempToken.makeStartAt(selStart);
// Clone required since token and tempToken must be // Clone required since token and tempToken must be
@ -229,21 +241,20 @@ public class SyntaxView extends View implements TabExpander,
} }
int tokenLen = token.length(); int tokenLen = token.length();
int selCount = Math.min(tokenLen, selEnd-token.getOffset()); int selCount = Math.min(tokenLen, selEnd - token.getOffset());
if (selCount==tokenLen) { if (selCount == tokenLen) {
nextX = painter.paintSelected(token, g, nextX,y, host, nextX = painter.paintSelected(token, g, nextX, y, host,
this, clipStart); this, clipStart);
} } else {
else {
tempToken.copyFrom(token); tempToken.copyFrom(token);
tempToken.textCount = selCount; tempToken.textCount = selCount;
nextX = painter.paintSelected(tempToken, g, nextX,y, host, nextX = painter.paintSelected(tempToken, g, nextX, y, host,
this, clipStart); this, clipStart);
tempToken.textCount = token.length(); tempToken.textCount = token.length();
tempToken.makeStartAt(token.getOffset() + selCount); tempToken.makeStartAt(token.getOffset() + selCount);
token = tempToken; token = tempToken;
nextX = painter.paint(token, g, nextX,y, host, this, nextX = painter.paint(token, g, nextX, y, host, this,
clipStart); clipStart);
} }
} }
@ -252,24 +263,24 @@ public class SyntaxView extends View implements TabExpander,
else if (token.containsPosition(selEnd)) { else if (token.containsPosition(selEnd)) {
tempToken.copyFrom(token); tempToken.copyFrom(token);
tempToken.textCount = selEnd - tempToken.getOffset(); tempToken.textCount = selEnd - tempToken.getOffset();
nextX = painter.paintSelected(tempToken, g, nextX,y, host, this, nextX = painter.paintSelected(tempToken, g, nextX, y, host, this,
clipStart); clipStart);
tempToken.textCount = token.length(); tempToken.textCount = token.length();
tempToken.makeStartAt(selEnd); tempToken.makeStartAt(selEnd);
token = tempToken; token = tempToken;
nextX = painter.paint(token, g, nextX,y, host, this, clipStart); nextX = painter.paint(token, g, nextX, y, host, this, clipStart);
} }
// This token is entirely selected // This token is entirely selected
else if (token.getOffset()>=selStart && else if (token.getOffset() >= selStart &&
token.getEndOffset()<=selEnd) { token.getEndOffset() <= selEnd) {
nextX = painter.paintSelected(token, g, nextX,y, host, this, nextX = painter.paintSelected(token, g, nextX, y, host, this,
clipStart); clipStart);
} }
// This token is entirely unselected // This token is entirely unselected
else { else {
nextX = painter.paint(token, g, nextX,y, host, this, clipStart); nextX = painter.paint(token, g, nextX, y, host, this, clipStart);
} }
token = token.getNextToken(); token = token.getNextToken();
@ -293,16 +304,16 @@ public class SyntaxView extends View implements TabExpander,
/** /**
* Calculates the width of the line represented by the given element. * Calculates the width of the line represented by the given element.
* *
* @param line The line for which to get the length. * @param line The line for which to get the length.
* @param lineNumber The line number of the specified line in the document. * @param lineNumber The line number of the specified line in the document.
* @return The width of the line. * @return The width of the line.
*/ */
private float getLineWidth(int lineNumber) { private float getLineWidth(int lineNumber) {
Token tokenList = ((RSyntaxDocument)getDocument()). Token tokenList = ((RSyntaxDocument) getDocument()).
getTokenListForLine(lineNumber); getTokenListForLine(lineNumber);
return RSyntaxUtilities.getTokenListWidth(tokenList, return RSyntaxUtilities.getTokenListWidth(tokenList,
(RSyntaxTextArea)getContainer(), (RSyntaxTextArea) getContainer(),
this); this);
} }
@ -312,23 +323,23 @@ public class SyntaxView extends View implements TabExpander,
* they might not be in the same order found in the model, or they just * they might not be in the same order found in the model, or they just
* might not allow access to some of the locations in the model. * might not allow access to some of the locations in the model.
* *
* @param pos the position to convert >= 0 * @param pos the position to convert >= 0
* @param a the allocated region to render into * @param a the allocated region to render into
* @param direction the direction from the current position that can * @param direction the direction from the current position that can
* be thought of as the arrow keys typically found on a keyboard. * be thought of as the arrow keys typically found on a keyboard.
* This may be SwingConstants.WEST, SwingConstants.EAST, * This may be SwingConstants.WEST, SwingConstants.EAST,
* SwingConstants.NORTH, or SwingConstants.SOUTH. * SwingConstants.NORTH, or SwingConstants.SOUTH.
* @return the location within the model that best represents the next * @return the location within the model that best represents the next
* location visual position. * location visual position.
* @exception BadLocationException * @throws BadLocationException
* @exception IllegalArgumentException for an invalid direction * @throws IllegalArgumentException for an invalid direction
*/ */
@Override @Override
public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, public int getNextVisualPositionFrom(int pos, Position.Bias b, Shape a,
int direction, Position.Bias[] biasRet) int direction, Position.Bias[] biasRet)
throws BadLocationException { throws BadLocationException {
return RSyntaxUtilities.getNextVisualPositionFrom(pos, b, a, return RSyntaxUtilities.getNextVisualPositionFrom(pos, b, a,
direction, biasRet, this); direction, biasRet, this);
} }
@ -337,11 +348,11 @@ public class SyntaxView extends View implements TabExpander,
* axis. * axis.
* *
* @param axis may be either View.X_AXIS or View.Y_AXIS * @param axis may be either View.X_AXIS or View.Y_AXIS
* @return the span the view would like to be rendered into >= 0. * @return the span the view would like to be rendered into >= 0.
* Typically the view is told to render into the span * Typically the view is told to render into the span
* that is returned, although there is no guarantee. * that is returned, although there is no guarantee.
* The parent may choose to resize or break the view. * The parent may choose to resize or break the view.
* @exception IllegalArgumentException for an invalid axis * @throws IllegalArgumentException for an invalid axis
*/ */
@Override @Override
public float getPreferredSpan(int axis) { public float getPreferredSpan(int axis) {
@ -357,13 +368,13 @@ public class SyntaxView extends View implements TabExpander,
// We update lineHeight here as when this method is first // We update lineHeight here as when this method is first
// called, lineHeight isn't initialized. If we don't do it // called, lineHeight isn't initialized. If we don't do it
// here, we get no vertical scrollbar (as lineHeight==0). // here, we get no vertical scrollbar (as lineHeight==0).
lineHeight = host!=null ? host.getLineHeight() : lineHeight; lineHeight = host != null ? host.getLineHeight() : lineHeight;
// return getElement().getElementCount() * lineHeight; // return getElement().getElementCount() * lineHeight;
int visibleLineCount = getElement().getElementCount(); int visibleLineCount = getElement().getElementCount();
if (host.isCodeFoldingEnabled()) { if (host.isCodeFoldingEnabled()) {
visibleLineCount -= host.getFoldManager().getHiddenLineCount(); visibleLineCount -= host.getFoldManager().getHiddenLineCount();
} }
return visibleLineCount * lineHeight; return visibleLineCount * lineHeight;
default: default:
throw new IllegalArgumentException("Invalid axis: " + axis); throw new IllegalArgumentException("Invalid axis: " + axis);
} }
@ -378,7 +389,7 @@ return visibleLineCount * lineHeight;
*/ */
private final int getRhsCorrection() { private final int getRhsCorrection() {
int rhsCorrection = 10; int rhsCorrection = 10;
if (host!=null) { if (host != null) {
rhsCorrection = host.getRightHandSideCorrection(); rhsCorrection = host.getRightHandSideCorrection();
} }
return rhsCorrection; return rhsCorrection;
@ -391,8 +402,8 @@ return visibleLineCount * lineHeight;
* @return The tab size. * @return The tab size.
*/ */
private int getTabSize() { private int getTabSize() {
Integer i = (Integer)getDocument().getProperty( Integer i = (Integer) getDocument().getProperty(
PlainDocument.tabSizeAttribute); PlainDocument.tabSizeAttribute);
int size = (i != null) ? i.intValue() : 5; int size = (i != null) ? i.intValue() : 5;
return size; return size;
} }
@ -407,26 +418,25 @@ return visibleLineCount * lineHeight;
* *
* @param offset The offset in question. * @param offset The offset in question.
* @return A token list for the physical (and in this view, logical) line * @return A token list for the physical (and in this view, logical) line
* before this one. If <code>offset</code> is in the first line in * before this one. If <code>offset</code> is in the first line in
* the document, <code>null</code> is returned. * the document, <code>null</code> is returned.
*/ */
public Token getTokenListForPhysicalLineAbove(int offset) { public Token getTokenListForPhysicalLineAbove(int offset) {
RSyntaxDocument document = (RSyntaxDocument)getDocument(); RSyntaxDocument document = (RSyntaxDocument) getDocument();
Element map = document.getDefaultRootElement(); Element map = document.getDefaultRootElement();
int line = map.getElementIndex(offset); int line = map.getElementIndex(offset);
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
if (fm==null) { if (fm == null) {
line--; line--;
if (line>=0) { if (line >= 0) {
return document.getTokenListForLine(line); return document.getTokenListForLine(line);
} }
} } else {
else { line = fm.getVisibleLineAbove(line);
line = fm.getVisibleLineAbove(line); if (line >= 0) {
if (line>=0) { return document.getTokenListForLine(line);
return document.getTokenListForLine(line); }
} }
}
// int line = map.getElementIndex(offset) - 1; // int line = map.getElementIndex(offset) - 1;
// if (line>=0) // if (line>=0)
// return document.getTokenListForLine(line); // return document.getTokenListForLine(line);
@ -443,26 +453,25 @@ else {
* *
* @param offset The offset in question. * @param offset The offset in question.
* @return A token list for the physical (and in this view, logical) line * @return A token list for the physical (and in this view, logical) line
* after this one. If <code>offset</code> is in the last physical * after this one. If <code>offset</code> is in the last physical
* line in the document, <code>null</code> is returned. * line in the document, <code>null</code> is returned.
*/ */
public Token getTokenListForPhysicalLineBelow(int offset) { public Token getTokenListForPhysicalLineBelow(int offset) {
RSyntaxDocument document = (RSyntaxDocument)getDocument(); RSyntaxDocument document = (RSyntaxDocument) getDocument();
Element map = document.getDefaultRootElement(); Element map = document.getDefaultRootElement();
int lineCount = map.getElementCount(); int lineCount = map.getElementCount();
int line = map.getElementIndex(offset); int line = map.getElementIndex(offset);
if (!host.isCodeFoldingEnabled()) { if (!host.isCodeFoldingEnabled()) {
if (line<lineCount-1) { if (line < lineCount - 1) {
return document.getTokenListForLine(line+1); return document.getTokenListForLine(line + 1);
} }
} } else {
else { FoldManager fm = host.getFoldManager();
FoldManager fm = host.getFoldManager(); line = fm.getVisibleLineBelow(line);
line = fm.getVisibleLineBelow(line); if (line >= 0 && line < lineCount) {
if (line>=0 && line<lineCount) { return document.getTokenListForLine(line);
return document.getTokenListForLine(line); }
} }
}
// int line = map.getElementIndex(offset); // int line = map.getElementIndex(offset);
// int lineCount = map.getElementCount(); // int lineCount = map.getElementCount();
// if (line<lineCount-1) // if (line<lineCount-1)
@ -476,8 +485,8 @@ else {
* in a location that this view is responsible for. * in a location that this view is responsible for.
* *
* @param changes The change information from the associated document. * @param changes The change information from the associated document.
* @param a The current allocation of the view. * @param a The current allocation of the view.
* @param f The factory to use to rebuild if the view has children. * @param f The factory to use to rebuild if the view has children.
*/ */
@Override @Override
public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f) { public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f) {
@ -488,9 +497,9 @@ else {
/** /**
* Determine the rectangle that represents the given line. * Determine the rectangle that represents the given line.
* *
* @param a The region allocated for the view to render into * @param a The region allocated for the view to render into
* @param line The line number to find the region of. This must * @param line The line number to find the region of. This must
* be a valid line number in the model. * be a valid line number in the model.
*/ */
protected Rectangle lineToRect(Shape a, int line) { protected Rectangle lineToRect(Shape a, int line) {
Rectangle r = null; Rectangle r = null;
@ -500,14 +509,14 @@ else {
// NOTE: lineHeight is not initially set here, leading to the // NOTE: lineHeight is not initially set here, leading to the
// current line not being highlighted when a document is first // current line not being highlighted when a document is first
// opened. So, we set it here just in case. // opened. So, we set it here just in case.
lineHeight = host!=null ? host.getLineHeight() : lineHeight; lineHeight = host != null ? host.getLineHeight() : lineHeight;
if (host.isCodeFoldingEnabled()) { if (host != null && host.isCodeFoldingEnabled()) {
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
int hiddenCount = fm.getHiddenLineCountAbove(line); int hiddenCount = fm.getHiddenLineCountAbove(line);
line -= hiddenCount; line -= hiddenCount;
} }
r = new Rectangle(alloc.x, alloc.y + line*lineHeight, r = new Rectangle(alloc.x, alloc.y + line * lineHeight,
alloc.width, lineHeight); alloc.width, lineHeight);
} }
return r; return r;
} }
@ -518,19 +527,19 @@ if (host.isCodeFoldingEnabled()) {
* to the coordinate space of the view mapped to it. * to the coordinate space of the view mapped to it.
* *
* @param pos the position to convert >= 0 * @param pos the position to convert >= 0
* @param a the allocated region to render into * @param a the allocated region to render into
* @return the bounding box of the given position * @return the bounding box of the given position
* @exception BadLocationException if the given position does not * @throws BadLocationException if the given position does not
* represent a valid location in the associated document * represent a valid location in the associated document
* @see View#modelToView * @see View#modelToView
*/ */
@Override @Override
public Shape modelToView(int pos, Shape a, Position.Bias b) public Shape modelToView(int pos, Shape a, Position.Bias b)
throws BadLocationException { throws BadLocationException {
// line coordinates // line coordinates
Element map = getElement(); Element map = getElement();
RSyntaxDocument doc = (RSyntaxDocument)getDocument(); RSyntaxDocument doc = (RSyntaxDocument) getDocument();
int lineIndex = map.getElementIndex(pos); int lineIndex = map.getElementIndex(pos);
Token tokenList = doc.getTokenListForLine(lineIndex); Token tokenList = doc.getTokenListForLine(lineIndex);
Rectangle lineArea = lineToRect(a, lineIndex); Rectangle lineArea = lineToRect(a, lineIndex);
@ -542,8 +551,8 @@ if (host.isCodeFoldingEnabled()) {
// We use this method instead as it returns the actual bounding box, // We use this method instead as it returns the actual bounding box,
// not just the x-coordinate. // not just the x-coordinate.
lineArea = tokenList.listOffsetToView( lineArea = tokenList.listOffsetToView(
(RSyntaxTextArea)getContainer(), this, pos, (RSyntaxTextArea) getContainer(), this, pos,
tabBase, lineArea); tabBase, lineArea);
return lineArea; return lineArea;
@ -554,7 +563,7 @@ if (host.isCodeFoldingEnabled()) {
* Provides a mapping, for a given region, from the document model * Provides a mapping, for a given region, from the document model
* coordinate space to the view coordinate space. The specified region is * coordinate space to the view coordinate space. The specified region is
* created as a union of the first and last character positions.<p> * created as a union of the first and last character positions.<p>
* * <p>
* This is implemented to subtract the width of the second character, as * This is implemented to subtract the width of the second character, as
* this view's <code>modelToView</code> actually returns the width of the * this view's <code>modelToView</code> actually returns the width of the
* character instead of "1" or "0" like the View implementations in * character instead of "1" or "0" like the View implementations in
@ -565,34 +574,34 @@ if (host.isCodeFoldingEnabled()) {
* *
* @param p0 the position of the first character (>=0) * @param p0 the position of the first character (>=0)
* @param b0 The bias of the first character position, toward the previous * @param b0 The bias of the first character position, toward the previous
* character or the next character represented by the offset, in * character or the next character represented by the offset, in
* case the position is a boundary of two views; <code>b0</code> * case the position is a boundary of two views; <code>b0</code>
* will have one of these values: * will have one of these values:
* <ul> * <ul>
* <li> <code>Position.Bias.Forward</code> * <li> <code>Position.Bias.Forward</code>
* <li> <code>Position.Bias.Backward</code> * <li> <code>Position.Bias.Backward</code>
* </ul> * </ul>
* @param p1 the position of the last character (>=0) * @param p1 the position of the last character (>=0)
* @param b1 the bias for the second character position, defined * @param b1 the bias for the second character position, defined
* one of the legal values shown above * one of the legal values shown above
* @param a the area of the view, which encompasses the requested region * @param a the area of the view, which encompasses the requested region
* @return the bounding box which is a union of the region specified * @return the bounding box which is a union of the region specified
* by the first and last character positions * by the first and last character positions
* @exception BadLocationException if the given position does * @throws BadLocationException if the given position does
* not represent a valid location in the associated document * not represent a valid location in the associated document
* @exception IllegalArgumentException if <code>b0</code> or * @throws IllegalArgumentException if <code>b0</code> or
* <code>b1</code> are not one of the * <code>b1</code> are not one of the
* legal <code>Position.Bias</code> values listed above * legal <code>Position.Bias</code> values listed above
* @see View#viewToModel * @see View#viewToModel
*/ */
@Override @Override
public Shape modelToView(int p0, Position.Bias b0, public Shape modelToView(int p0, Position.Bias b0,
int p1, Position.Bias b1, int p1, Position.Bias b1,
Shape a) throws BadLocationException { Shape a) throws BadLocationException {
Shape s0 = modelToView(p0, a, b0); Shape s0 = modelToView(p0, a, b0);
Shape s1; Shape s1;
if (p1 ==getEndOffset()) { if (p1 == getEndOffset()) {
try { try {
s1 = modelToView(p1, a, b1); s1 = modelToView(p1, a, b1);
} catch (BadLocationException ble) { } catch (BadLocationException ble) {
@ -600,21 +609,20 @@ if (host.isCodeFoldingEnabled()) {
} }
if (s1 == null) { if (s1 == null) {
// Assume extends left to right. // Assume extends left to right.
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a :
a.getBounds(); a.getBounds();
s1 = new Rectangle(alloc.x + alloc.width - 1, alloc.y, s1 = new Rectangle(alloc.x + alloc.width - 1, alloc.y,
1, alloc.height); 1, alloc.height);
} }
} } else {
else {
s1 = modelToView(p1, a, b1); s1 = modelToView(p1, a, b1);
} }
Rectangle r0 = s0 instanceof Rectangle ? (Rectangle)s0 : s0.getBounds(); Rectangle r0 = s0 instanceof Rectangle ? (Rectangle) s0 : s0.getBounds();
Rectangle r1 = s1 instanceof Rectangle ? (Rectangle)s1 : s1.getBounds(); Rectangle r1 = s1 instanceof Rectangle ? (Rectangle) s1 : s1.getBounds();
if (r0.y != r1.y) { if (r0.y != r1.y) {
// If it spans lines, force it to be the width of the view. // If it spans lines, force it to be the width of the view.
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : Rectangle alloc = (a instanceof Rectangle) ? (Rectangle) a :
a.getBounds(); a.getBounds();
r0.x = alloc.x; r0.x = alloc.x;
r0.width = alloc.width; r0.width = alloc.width;
} }
@ -627,7 +635,7 @@ if (host.isCodeFoldingEnabled()) {
// this, one character too many is highlighted thanks to our // this, one character too many is highlighted thanks to our
// modelToView() implementation returning the actual width of the // modelToView() implementation returning the actual width of the
// character requested! // character requested!
if (p1>p0) r0.width -= r1.width; if (p1 > p0) r0.width -= r1.width;
return r0; return r0;
@ -639,15 +647,15 @@ if (host.isCodeFoldingEnabled()) {
* This implementation does not support things like centering so it * This implementation does not support things like centering so it
* ignores the tabOffset argument. * ignores the tabOffset argument.
* *
* @param x the current position >= 0 * @param x the current position >= 0
* @param tabOffset the position within the text stream * @param tabOffset the position within the text stream
* that the tab occurred at >= 0. * that the tab occurred at >= 0.
* @return the tab stop, measured in points >= 0 * @return the tab stop, measured in points >= 0
*/ */
public float nextTabStop(float x, int tabOffset) { public float nextTabStop(float x, int tabOffset) {
if (tabSize == 0) if (tabSize == 0)
return x; return x;
int ntabs = (((int)x) - tabBase) / tabSize; int ntabs = (((int) x) - tabBase) / tabSize;
return tabBase + ((ntabs + 1) * tabSize); return tabBase + ((ntabs + 1) * tabSize);
} }
@ -662,12 +670,12 @@ if (host.isCodeFoldingEnabled()) {
@Override @Override
public void paint(Graphics g, Shape a) { public void paint(Graphics g, Shape a) {
RSyntaxDocument document = (RSyntaxDocument)getDocument(); RSyntaxDocument document = (RSyntaxDocument) getDocument();
Rectangle alloc = a.getBounds(); Rectangle alloc = a.getBounds();
tabBase = alloc.x; tabBase = alloc.x;
host = (RSyntaxTextArea)getContainer(); host = (RSyntaxTextArea) getContainer();
Rectangle clip = g.getClipBounds(); Rectangle clip = g.getClipBounds();
// An attempt to speed things up for files with long lines. Note that // An attempt to speed things up for files with long lines. Note that
@ -695,52 +703,51 @@ if (host.isCodeFoldingEnabled()) {
boolean useSelectedTextColor = host.getUseSelectedTextColor(); boolean useSelectedTextColor = host.getUseSelectedTextColor();
RSyntaxTextAreaHighlighter h = RSyntaxTextAreaHighlighter h =
(RSyntaxTextAreaHighlighter)host.getHighlighter(); (RSyntaxTextAreaHighlighter) host.getHighlighter();
Graphics2D g2d = (Graphics2D)g; Graphics2D g2d = (Graphics2D) g;
Token token; Token token;
//System.err.println("Painting lines: " + linesAbove + " to " + (endLine-1)); //System.err.println("Painting lines: " + linesAbove + " to " + (endLine-1));
TokenPainter painter = host.getTokenPainter(); TokenPainter painter = host.getTokenPainter();
int line = linesAbove; int line = linesAbove;
//int count = 0; //int count = 0;
while (y<clip.y+clip.height+ascent && line<lineCount) { while (y < clip.y + clip.height + ascent && line < lineCount) {
Fold fold = fm.getFoldForLine(line); Fold fold = fm.getFoldForLine(line);
Element lineElement = map.getElement(line); Element lineElement = map.getElement(line);
int startOffset = lineElement.getStartOffset(); int startOffset = lineElement.getStartOffset();
//int endOffset = (line==lineCount ? lineElement.getEndOffset()-1 : //int endOffset = (line==lineCount ? lineElement.getEndOffset()-1 :
// lineElement.getEndOffset()-1); // lineElement.getEndOffset()-1);
int endOffset = lineElement.getEndOffset()-1; // Why always "-1"? int endOffset = lineElement.getEndOffset() - 1; // Why always "-1"?
h.paintLayeredHighlights(g2d, startOffset, endOffset, h.paintLayeredHighlights(g2d, startOffset, endOffset,
a, host, this); a, host, this);
// Paint a line of text. // Paint a line of text.
token = document.getTokenListForLine(line); token = document.getTokenListForLine(line);
if (!useSelectedTextColor || selStart==selEnd || if (!useSelectedTextColor || selStart == selEnd ||
(startOffset>=selEnd || endOffset<selStart)) { (startOffset >= selEnd || endOffset < selStart)) {
drawLine(painter, token, g2d, x,y); drawLine(painter, token, g2d, x, y);
} } else {
else {
//System.out.println("Drawing line with selection: " + line); //System.out.println("Drawing line with selection: " + line);
drawLineWithSelection(painter,token,g2d, x,y, selStart, selEnd); drawLineWithSelection(painter, token, g2d, x, y, selStart, selEnd);
} }
if (fold!=null && fold.isCollapsed()) { if (fold != null && fold.isCollapsed()) {
// Visible indicator of collapsed lines // Visible indicator of collapsed lines
Color c = RSyntaxUtilities.getFoldedLineBottomColor(host); Color c = RSyntaxUtilities.getFoldedLineBottomColor(host);
if (c!=null) { if (c != null) {
g.setColor(c); g.setColor(c);
g.drawLine(x,y+lineHeight-ascent-1, g.drawLine(x, y + lineHeight - ascent - 1,
alloc.width,y+lineHeight-ascent-1); alloc.width, y + lineHeight - ascent - 1);
} }
// Skip to next line to paint, taking extra care for lines with // Skip to next line to paint, taking extra care for lines with
// block ends and begins together, e.g. "} else {" // block ends and begins together, e.g. "} else {"
do { do {
int hiddenLineCount = fold.getLineCount(); int hiddenLineCount = fold.getLineCount();
if (hiddenLineCount==0) { if (hiddenLineCount == 0) {
// Fold parser identified a zero-line fold region. // Fold parser identified a zero-line fold region.
// This is really a bug, but we'll be graceful here // This is really a bug, but we'll be graceful here
// and avoid an infinite loop. // and avoid an infinite loop.
@ -748,7 +755,7 @@ if (host.isCodeFoldingEnabled()) {
} }
line += hiddenLineCount; line += hiddenLineCount;
fold = fm.getFoldForLine(line); fold = fm.getFoldForLine(line);
} while (fold!=null && fold.isCollapsed()); } while (fold != null && fold.isCollapsed());
} }
@ -767,7 +774,7 @@ if (host.isCodeFoldingEnabled()) {
* If the passed-in line is longer than the current longest line, then * If the passed-in line is longer than the current longest line, then
* the longest line is updated. * the longest line is updated.
* *
* @param line The line to test against the current longest. * @param line The line to test against the current longest.
* @param lineNumber The line number of the passed-in line. * @param lineNumber The line number of the passed-in line.
* @return <code>true</code> iff the current longest line was updated. * @return <code>true</code> iff the current longest line was updated.
*/ */
@ -787,8 +794,8 @@ if (host.isCodeFoldingEnabled()) {
* in a location that this view is responsible for. * in a location that this view is responsible for.
* *
* @param changes the change information from the associated document * @param changes the change information from the associated document
* @param a the current allocation of the view * @param a the current allocation of the view
* @param f the factory to use to rebuild if the view has children * @param f the factory to use to rebuild if the view has children
*/ */
@Override @Override
public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f) { public void removeUpdate(DocumentEvent changes, Shape a, ViewFactory f) {
@ -819,12 +826,12 @@ if (host.isCodeFoldingEnabled()) {
Element[] added = (ec != null) ? ec.getChildrenAdded() : null; Element[] added = (ec != null) ? ec.getChildrenAdded() : null;
Element[] removed = (ec != null) ? ec.getChildrenRemoved() : null; Element[] removed = (ec != null) ? ec.getChildrenRemoved() : null;
if (((added != null) && (added.length > 0)) || if (((added != null) && (added.length > 0)) ||
((removed != null) && (removed.length > 0))) { ((removed != null) && (removed.length > 0))) {
// lines were added or removed... // lines were added or removed...
if (added != null) { if (added != null) {
int addedAt = ec.getIndex(); // FIXME: Is this correct????? int addedAt = ec.getIndex(); // FIXME: Is this correct?????
for (int i = 0; i < added.length; i++) for (int i = 0; i < added.length; i++)
possiblyUpdateLongLine(added[i], addedAt+i); possiblyUpdateLongLine(added[i], addedAt + i);
} }
if (removed != null) { if (removed != null) {
for (int i = 0; i < removed.length; i++) { for (int i = 0; i < removed.length; i++) {
@ -841,14 +848,12 @@ if (host.isCodeFoldingEnabled()) {
// This occurs when syntax highlighting only changes on lines // This occurs when syntax highlighting only changes on lines
// (i.e. beginning a multiline comment). // (i.e. beginning a multiline comment).
else if (changes.getType()==DocumentEvent.EventType.CHANGE) { else if (changes.getType() == DocumentEvent.EventType.CHANGE) {
//System.err.println("Updating the damage due to a CHANGE event..."); //System.err.println("Updating the damage due to a CHANGE event...");
int startLine = changes.getOffset(); int startLine = changes.getOffset();
int endLine = changes.getLength(); int endLine = changes.getLength();
damageLineRange(startLine,endLine, a, host); damageLineRange(startLine, endLine, a, host);
} } else {
else {
Element map = getElement(); Element map = getElement();
int line = map.getElementIndex(changes.getOffset()); int line = map.getElementIndex(changes.getOffset());
damageLineRange(line, line, a, host); damageLineRange(line, line, a, host);
@ -861,14 +866,12 @@ if (host.isCodeFoldingEnabled()) {
// because it has gotten longer. // because it has gotten longer.
longLineWidth = getLineWidth(line); longLineWidth = getLineWidth(line);
preferenceChanged(null, true, false); preferenceChanged(null, true, false);
} } else {
else {
// If long line gets updated, update the status bars too. // If long line gets updated, update the status bars too.
if (possiblyUpdateLongLine(e, line)) if (possiblyUpdateLongLine(e, line))
preferenceChanged(null, true, false); preferenceChanged(null, true, false);
} }
} } else if (changes.getType() == DocumentEvent.EventType.REMOVE) {
else if (changes.getType() == DocumentEvent.EventType.REMOVE) {
if (map.getElement(line) == longLine) { if (map.getElement(line) == longLine) {
// removed from longest line... recalc // removed from longest line... recalc
longLineWidth = -1; // Must do this! longLineWidth = -1; // Must do this!
@ -884,7 +887,7 @@ if (host.isCodeFoldingEnabled()) {
* Checks to see if the font metrics and longest line are up-to-date. * Checks to see if the font metrics and longest line are up-to-date.
*/ */
private void updateMetrics() { private void updateMetrics() {
host = (RSyntaxTextArea)getContainer(); host = (RSyntaxTextArea) getContainer();
Font f = host.getFont(); Font f = host.getFont();
if (font != f) { if (font != f) {
// The font changed, we need to recalculate the longest line! // The font changed, we need to recalculate the longest line!
@ -900,9 +903,9 @@ if (host.isCodeFoldingEnabled()) {
* *
* @param fx the X coordinate >= 0 * @param fx the X coordinate >= 0
* @param fy the Y coordinate >= 0 * @param fy the Y coordinate >= 0
* @param a the allocated region to render into * @param a the allocated region to render into
* @return the location within the model that best represents the * @return the location within the model that best represents the
* given point in the view >= 0 * given point in the view >= 0
*/ */
@Override @Override
public int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias) { public int viewToModel(float fx, float fy, Shape a, Position.Bias[] bias) {
@ -910,7 +913,7 @@ if (host.isCodeFoldingEnabled()) {
bias[0] = Position.Bias.Forward; bias[0] = Position.Bias.Forward;
Rectangle alloc = a.getBounds(); Rectangle alloc = a.getBounds();
RSyntaxDocument doc = (RSyntaxDocument)getDocument(); RSyntaxDocument doc = (RSyntaxDocument) getDocument();
int x = (int) fx; int x = (int) fx;
int y = (int) fy; int y = (int) fy;
@ -936,9 +939,9 @@ if (host.isCodeFoldingEnabled()) {
Element map = doc.getDefaultRootElement(); Element map = doc.getDefaultRootElement();
int lineIndex = Math.abs((y - alloc.y) / lineHeight);//metrics.getHeight() ); int lineIndex = Math.abs((y - alloc.y) / lineHeight);//metrics.getHeight() );
FoldManager fm = host.getFoldManager(); FoldManager fm = host.getFoldManager();
//System.out.print("--- " + lineIndex); //System.out.print("--- " + lineIndex);
lineIndex += fm.getHiddenLineCountAbove(lineIndex, true); lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
//System.out.println(" => " + lineIndex); //System.out.println(" => " + lineIndex);
if (lineIndex >= map.getElementCount()) { if (lineIndex >= map.getElementCount()) {
return host.getLastVisibleOffset(); return host.getLastVisibleOffset();
@ -950,7 +953,7 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
if (x < alloc.x) if (x < alloc.x)
return line.getStartOffset(); return line.getStartOffset();
// If the point is to the right of the line... // If the point is to the right of the line...
else if (x > alloc.x + alloc.width) else if (x > alloc.x + alloc.width)
return line.getEndOffset() - 1; return line.getEndOffset() - 1;
@ -960,9 +963,9 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
Token tokenList = doc.getTokenListForLine(lineIndex); Token tokenList = doc.getTokenListForLine(lineIndex);
tabBase = alloc.x; tabBase = alloc.x;
int offs = tokenList.getListOffset( int offs = tokenList.getListOffset(
(RSyntaxTextArea)getContainer(), (RSyntaxTextArea) getContainer(),
this, tabBase, x); this, tabBase, x);
return offs!=-1 ? offs : p0; return offs != -1 ? offs : p0;
} }
} // End of else. } // End of else.
@ -981,11 +984,13 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
// NOTE: lineHeight is not initially set here, leading to the // NOTE: lineHeight is not initially set here, leading to the
// current line not being highlighted when a document is first // current line not being highlighted when a document is first
// opened. So, we set it here just in case. // opened. So, we set it here just in case.
lineHeight = host!=null ? host.getLineHeight() : lineHeight; lineHeight = host != null ? host.getLineHeight() : lineHeight;
FoldManager fm = host.getFoldManager(); if (host != null) {
if (!fm.isLineHidden(line)) { FoldManager fm = host.getFoldManager();
line -= fm.getHiddenLineCountAbove(line); if (!fm.isLineHidden(line)) {
return alloc.y + line*lineHeight; line -= fm.getHiddenLineCountAbove(line);
return alloc.y + line * lineHeight;
}
} }
} }
@ -998,7 +1003,7 @@ lineIndex += fm.getHiddenLineCountAbove(lineIndex, true);
* {@inheritDoc} * {@inheritDoc}
*/ */
public int yForLineContaining(Rectangle alloc, int offs) public int yForLineContaining(Rectangle alloc, int offs)
throws BadLocationException { throws BadLocationException {
Element map = getElement(); Element map = getElement();
int line = map.getElementIndex(offs); int line = map.getElementIndex(offs);
return yForLine(alloc, line); return yForLine(alloc, line);

100
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/WrappedSyntaxView.java

@ -9,15 +9,33 @@
*/ */
package com.fr.design.gui.syntax.ui.rsyntaxtextarea; package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import java.awt.*;
import javax.swing.text.*;
import javax.swing.text.Position.Bias;
import javax.swing.event.*;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenUtils.TokenSubList;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.Fold;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.folding.FoldManager;
import com.fr.design.gui.syntax.ui.rtextarea.Gutter; import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
import com.fr.stable.CommonUtils;
import javax.swing.event.DocumentEvent;
import javax.swing.text.BadLocationException;
import javax.swing.text.BoxView;
import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.LayeredHighlighter;
import javax.swing.text.PlainDocument;
import javax.swing.text.Position;
import javax.swing.text.Position.Bias;
import javax.swing.text.Segment;
import javax.swing.text.TabExpander;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
/** /**
@ -27,7 +45,7 @@ import com.fr.design.gui.syntax.ui.rtextarea.Gutter;
* @version 0.2 * @version 0.2
*/ */
public class WrappedSyntaxView extends BoxView implements TabExpander, public class WrappedSyntaxView extends BoxView implements TabExpander,
RSTAView { RSTAView {
boolean widthChanging; boolean widthChanging;
int tabBase; int tabBase;
@ -93,7 +111,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander,
int p = p0; int p = p0;
RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer(); RSyntaxTextArea textArea = (RSyntaxTextArea)getContainer();
float currentWidth = getWidth(); float currentWidth = getWidth();
if (currentWidth==Integer.MAX_VALUE) if (CommonUtils.equals(currentWidth, Integer.MAX_VALUE))
currentWidth = getPreferredSpan(X_AXIS); currentWidth = getPreferredSpan(X_AXIS);
// Make sure width>0; this is a huge hack to fix a bug where // Make sure width>0; this is a huge hack to fix a bug where
// loading text into an RTextArea before it is visible if word wrap // loading text into an RTextArea before it is visible if word wrap
@ -128,7 +146,7 @@ public class WrappedSyntaxView extends BoxView implements TabExpander,
//System.err.println("------ ending calculateBreakPosition() --------"); //System.err.println("------ ending calculateBreakPosition() --------");
// return p; // return p;
return p + 1; return p + 1;
} }
//private int getBreakLocation(Token t, FontMetrics fm, int x0, int x, //private int getBreakLocation(Token t, FontMetrics fm, int x0, int x,
@ -271,8 +289,8 @@ return p + 1;
* @param selEnd The end of the selection. * @param selEnd The end of the selection.
*/ */
protected void drawViewWithSelection(TokenPainter painter, Graphics2D g, protected void drawViewWithSelection(TokenPainter painter, Graphics2D g,
Rectangle r, View view, int fontHeight, int y, int selStart, Rectangle r, View view, int fontHeight, int y, int selStart,
int selEnd) { int selEnd) {
float x = r.x; float x = r.x;
@ -371,7 +389,7 @@ return p + 1;
int tokenOffset = token.getOffset(); int tokenOffset = token.getOffset();
Token orig = token; Token orig = token;
token = new TokenImpl(drawSeg, tokenOffset-start, p-1-start, token = new TokenImpl(drawSeg, tokenOffset-start, p-1-start,
tokenOffset, token.getType()); tokenOffset, token.getType());
// Selection starts in this token // Selection starts in this token
if (token.containsPosition(selStart)) { if (token.containsPosition(selStart)) {
@ -605,7 +623,7 @@ return p + 1;
*/ */
protected int getTabSize() { protected int getTabSize() {
Integer i = (Integer) getDocument(). Integer i = (Integer) getDocument().
getProperty(PlainDocument.tabSizeAttribute); getProperty(PlainDocument.tabSizeAttribute);
int size = (i != null) ? i.intValue() : 5; int size = (i != null) ? i.intValue() : 5;
return size; return size;
} }
@ -656,7 +674,7 @@ return p + 1;
public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f) { public void insertUpdate(DocumentEvent changes, Shape a, ViewFactory f) {
updateChildren(changes, a); updateChildren(changes, a);
Rectangle alloc = ((a != null) && isAllocationValid()) ? Rectangle alloc = ((a != null) && isAllocationValid()) ?
getInsideAllocation(a) : null; getInsideAllocation(a) : null;
int pos = changes.getOffset(); int pos = changes.getOffset();
View v = getViewAtPosition(pos, alloc); View v = getViewAtPosition(pos, alloc);
if (v != null) if (v != null)
@ -765,8 +783,8 @@ return p + 1;
*/ */
@Override @Override
public Shape modelToView(int p0, Position.Bias b0, public Shape modelToView(int p0, Position.Bias b0,
int p1, Position.Bias b1, int p1, Position.Bias b1,
Shape a) throws BadLocationException { Shape a) throws BadLocationException {
Shape s0 = modelToView(p0, a, b0); Shape s0 = modelToView(p0, a, b0);
Shape s1; Shape s1;
@ -779,9 +797,9 @@ return p + 1;
if (s1 == null) { if (s1 == null) {
// Assume extends left to right. // Assume extends left to right.
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a :
a.getBounds(); a.getBounds();
s1 = new Rectangle(alloc.x + alloc.width - 1, alloc.y, s1 = new Rectangle(alloc.x + alloc.width - 1, alloc.y,
1, alloc.height); 1, alloc.height);
} }
} }
else { else {
@ -789,11 +807,11 @@ return p + 1;
} }
Rectangle r0 = s0.getBounds(); Rectangle r0 = s0.getBounds();
Rectangle r1 = (s1 instanceof Rectangle) ? (Rectangle) s1 : Rectangle r1 = (s1 instanceof Rectangle) ? (Rectangle) s1 :
s1.getBounds(); s1.getBounds();
if (r0.y != r1.y) { if (r0.y != r1.y) {
// If it spans lines, force it to be the width of the view. // If it spans lines, force it to be the width of the view.
Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a : Rectangle alloc = (a instanceof Rectangle) ? (Rectangle)a :
a.getBounds(); a.getBounds();
r0.x = alloc.x; r0.x = alloc.x;
r0.width = alloc.width; r0.width = alloc.width;
} }
@ -840,7 +858,7 @@ return p + 1;
public void paint(Graphics g, Shape a) { public void paint(Graphics g, Shape a) {
Rectangle alloc = (a instanceof Rectangle) ? Rectangle alloc = (a instanceof Rectangle) ?
(Rectangle)a : a.getBounds(); (Rectangle)a : a.getBounds();
tabBase = alloc.x; tabBase = alloc.x;
Graphics2D g2d = (Graphics2D)g; Graphics2D g2d = (Graphics2D)g;
@ -919,11 +937,11 @@ return p + 1;
updateChildren(changes, a); updateChildren(changes, a);
Rectangle alloc = ((a != null) && isAllocationValid()) ? Rectangle alloc = ((a != null) && isAllocationValid()) ?
getInsideAllocation(a) : null; getInsideAllocation(a) : null;
int pos = changes.getOffset(); int pos = changes.getOffset();
View v = getViewAtPosition(pos, alloc); View v = getViewAtPosition(pos, alloc);
if (v != null) if (v != null)
v.removeUpdate(changes, alloc, f); v.removeUpdate(changes, alloc, f);
} }
@ -1044,8 +1062,8 @@ return p + 1;
// Code folding may have hidden the last line. If so, return the last // Code folding may have hidden the last line. If so, return the last
// visible offset instead of the last offset. // visible offset instead of the last offset.
if (host.isCodeFoldingEnabled() && v==getView(getViewCount()-1) && if (v != null && host.isCodeFoldingEnabled() && v == getView(getViewCount() - 1) &&
offs==v.getEndOffset()-1) { offs == v.getEndOffset() - 1) {
offs = host.getLastVisibleOffset(); offs = host.getLastVisibleOffset();
} }
@ -1068,7 +1086,7 @@ return p + 1;
* {@inheritDoc} * {@inheritDoc}
*/ */
public int yForLineContaining(Rectangle alloc, int offs) public int yForLineContaining(Rectangle alloc, int offs)
throws BadLocationException { throws BadLocationException {
if (isAllocationValid()) { if (isAllocationValid()) {
// TODO: make cached Y_AXIS offsets valid even with folding enabled // TODO: make cached Y_AXIS offsets valid even with folding enabled
// to speed this back up! // to speed this back up!
@ -1136,10 +1154,10 @@ return p + 1;
//System.err.println("... ... ... break position p==" + p); //System.err.println("... ... ... break position p==" + p);
p0 = (p == p0) ? ++p : p; // this is the fix of #4410243 p0 = (p == p0) ? ++p : p; // this is the fix of #4410243
// we check on situation when // we check on situation when
// width is too small and // width is too small and
// break position is calculated // break position is calculated
// incorrectly. // incorrectly.
//System.err.println("... ... ... new p0==" + p0); //System.err.println("... ... ... new p0==" + p0);
} }
/* /*
@ -1170,7 +1188,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
switch (axis) { switch (axis) {
case View.X_AXIS: case View.X_AXIS:
float width = getWidth(); float width = getWidth();
if (width == Integer.MAX_VALUE) { if (CommonUtils.equals(width, Integer.MAX_VALUE)) {
// We have been initially set to MAX_VALUE, but we don't // We have been initially set to MAX_VALUE, but we don't
// want this as our preferred. // want this as our preferred.
return 100f; return 100f;
@ -1212,7 +1230,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
*/ */
@Override @Override
public Shape modelToView(int pos, Shape a, Position.Bias b) public Shape modelToView(int pos, Shape a, Position.Bias b)
throws BadLocationException { throws BadLocationException {
//System.err.println("--- begin modelToView ---"); //System.err.println("--- begin modelToView ---");
Rectangle alloc = a.getBounds(); Rectangle alloc = a.getBounds();
@ -1222,7 +1240,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
int p0 = getStartOffset(); int p0 = getStartOffset();
int p1 = getEndOffset(); int p1 = getEndOffset();
int testP = (b == Position.Bias.Forward) ? pos : int testP = (b == Position.Bias.Forward) ? pos :
Math.max(p0, pos - 1); Math.max(p0, pos - 1);
// Get the token list for this line so we don't have to keep // Get the token list for this line so we don't have to keep
// recomputing it if this logical line spans multiple physical // recomputing it if this logical line spans multiple physical
@ -1242,9 +1260,9 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
if ((pos >= p0) && (testP<p)) {//pos < p)) { if ((pos >= p0) && (testP<p)) {//pos < p)) {
// it's in this line // it's in this line
alloc = RSyntaxUtilities.getLineWidthUpTo( alloc = RSyntaxUtilities.getLineWidthUpTo(
textArea, s, p0, pos, textArea, s, p0, pos,
WrappedSyntaxView.this, WrappedSyntaxView.this,
alloc, alloc.x); alloc, alloc.x);
//System.err.println("--- end modelToView ---"); //System.err.println("--- end modelToView ---");
return alloc; return alloc;
} }
@ -1253,9 +1271,9 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
// Wants end. // Wants end.
if (pos > p0) { if (pos > p0) {
alloc = RSyntaxUtilities.getLineWidthUpTo( alloc = RSyntaxUtilities.getLineWidthUpTo(
textArea, s, p0, pos, textArea, s, p0, pos,
WrappedSyntaxView.this, WrappedSyntaxView.this,
alloc, alloc.x); alloc, alloc.x);
} }
//System.err.println("--- end modelToView ---"); //System.err.println("--- end modelToView ---");
return alloc; return alloc;
@ -1352,8 +1370,8 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
// Start at alloc.x since this chunk starts // Start at alloc.x since this chunk starts
// at the beginning of a physical line. // at the beginning of a physical line.
int n = tlist.getListOffset(textArea, int n = tlist.getListOffset(textArea,
WrappedSyntaxView.this, WrappedSyntaxView.this,
alloc.x, x); alloc.x, x);
// NOTE: We needed to add the max() with // NOTE: We needed to add the max() with
// p0 as getTokenListForLine returns -1 // p0 as getTokenListForLine returns -1
@ -1379,7 +1397,7 @@ System.err.println(">>> >>> calculated number of lines for this view (line " + l
} }
private void handleDocumentEvent(DocumentEvent e, Shape a, private void handleDocumentEvent(DocumentEvent e, Shape a,
ViewFactory f) { ViewFactory f) {
int n = calculateLineCount(); int n = calculateLineCount();
if (this.nlines != n) { if (this.nlines != n) {
this.nlines = n; this.nlines = n;

5
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/parser/TaskTagParser.java

@ -18,6 +18,7 @@ import com.fr.design.gui.syntax.ui.rsyntaxtextarea.ErrorStrip;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxDocument; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxDocument;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants;
import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Token; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Token;
import com.fr.stable.StringUtils;
/** /**
@ -60,6 +61,7 @@ public class TaskTagParser extends AbstractParser {
} }
@SuppressWarnings("squid:S2259")
public ParseResult parse(RSyntaxDocument doc, String style) { public ParseResult parse(RSyntaxDocument doc, String style) {
Element root = doc.getDefaultRootElement(); Element root = doc.getDefaultRootElement();
@ -101,6 +103,9 @@ public class TaskTagParser extends AbstractParser {
} }
if (start>-1) { if (start>-1) {
if (StringUtils.isEmpty(text)) {
continue;
}
text = text.substring(start); text = text.substring(start);
// TODO: Strip off end of MLC's if they're there. // TODO: Strip off end of MLC's if they're there.
int len = text.length(); int len = text.length();

8
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/LineNumberList.java

@ -349,6 +349,10 @@ public class LineNumberList extends AbstractGutterComponent
int width = metrics.stringWidth(number); int width = metrics.stringWidth(number);
g.drawString(number, rhs-width,y); g.drawString(number, rhs-width,y);
y += cellHeight; y += cellHeight;
if (fm == null) {
line++;
continue;
}
Fold fold = fm.getFoldForLine(line-1); Fold fold = fm.getFoldForLine(line-1);
// Skip to next line to paint, taking extra care for lines with // Skip to next line to paint, taking extra care for lines with
// block ends and begins together, e.g. "} else {" // block ends and begins together, e.g. "} else {"
@ -371,6 +375,10 @@ public class LineNumberList extends AbstractGutterComponent
String number = Integer.toString(line + getLineNumberingStartIndex() - 1); String number = Integer.toString(line + getLineNumberingStartIndex() - 1);
g.drawString(number, RHS_BORDER_WIDTH, y); g.drawString(number, RHS_BORDER_WIDTH, y);
y += cellHeight; y += cellHeight;
if (fm == null) {
line++;
continue;
}
Fold fold = fm.getFoldForLine(line-1); Fold fold = fm.getFoldForLine(line-1);
// Skip to next line to paint, taking extra care for lines with // Skip to next line to paint, taking extra care for lines with
// block ends and begins together, e.g. "} else {" // block ends and begins together, e.g. "} else {"

3
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextArea.java

@ -635,6 +635,9 @@ public class RTextArea extends RTextAreaBase implements Printable {
parent = parent.getParent(); parent = parent.getParent();
} }
KeyStroke backspace = KeyStroke.getKeyStroke("BACK_SPACE"); KeyStroke backspace = KeyStroke.getKeyStroke("BACK_SPACE");
if (inputMap == null) {
return;
}
inputMap.put(backspace, DefaultEditorKit.deletePrevCharAction); inputMap.put(backspace, DefaultEditorKit.deletePrevCharAction);
} }

2
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/RTextAreaEditorKit.java

@ -902,6 +902,8 @@ public class RTextAreaEditorKit extends DefaultEditorKit {
} }
} catch (BadLocationException bl) { } catch (BadLocationException bl) {
} }
}else if (textArea == null) {
throw new IllegalArgumentException("RTextArea can not be null!");
} }
if (beep) if (beep)

10
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/VolatileImageBackgroundPainterStrategy.java

@ -9,6 +9,8 @@
*/ */
package com.fr.design.gui.syntax.ui.rtextarea; package com.fr.design.gui.syntax.ui.rtextarea;
import com.fr.log.FineLoggerFactory;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Image; import java.awt.Image;
import java.awt.image.VolatileImage; import java.awt.image.VolatileImage;
@ -95,9 +97,9 @@ public class VolatileImageBackgroundPainterStrategy
try { try {
tracker.waitForID(1); tracker.waitForID(1);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); FineLoggerFactory.getLogger().error(e.getMessage(),e);
bgImage = null; bgImage = null;
return; Thread.currentThread().interrupt();
} finally { } finally {
tracker.removeImage(i, 1); tracker.removeImage(i, 1);
} }
@ -106,9 +108,9 @@ public class VolatileImageBackgroundPainterStrategy
try { try {
tracker.waitForID(0); tracker.waitForID(0);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); FineLoggerFactory.getLogger().error(e.getMessage(),e);
bgImage = null; bgImage = null;
return; Thread.currentThread().interrupt();
} finally { } finally {
tracker.removeImage(bgImage, 0); tracker.removeImage(bgImage, 0);
} }

6
designer-base/src/main/java/com/fr/design/icon/LockIcon.java

@ -34,6 +34,7 @@ public class LockIcon extends ImageIcon {
} }
} }
@Override
public void paintIcon(Component c, Graphics g, int x, int y) { public void paintIcon(Component c, Graphics g, int x, int y) {
if (mainImage != null) { if (mainImage != null) {
g.drawImage(mainImage, x, y, c); g.drawImage(mainImage, x, y, c);
@ -48,6 +49,7 @@ public class LockIcon extends ImageIcon {
* *
* @param image the image * @param image the image
*/ */
@Override
protected void loadImage(Image image) { protected void loadImage(Image image) {
synchronized (tracker) { synchronized (tracker) {
tracker.addImage(image, 0); tracker.addImage(image, 0);
@ -55,6 +57,7 @@ public class LockIcon extends ImageIcon {
tracker.waitForID(0, 0); tracker.waitForID(0, 0);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
loadStatus = tracker.statusID(0, false); loadStatus = tracker.statusID(0, false);
@ -70,6 +73,7 @@ public class LockIcon extends ImageIcon {
* *
* @return the <code>Image</code> object for this <code>ImageIcon</code> * @return the <code>Image</code> object for this <code>ImageIcon</code>
*/ */
@Override
public Image getImage() { public Image getImage() {
return mainImage; return mainImage;
} }
@ -85,6 +89,7 @@ public class LockIcon extends ImageIcon {
* *
* @return the width in pixels of this icon * @return the width in pixels of this icon
*/ */
@Override
public int getIconWidth() { public int getIconWidth() {
return width; return width;
} }
@ -94,6 +99,7 @@ public class LockIcon extends ImageIcon {
* *
* @return the height in pixels of this icon * @return the height in pixels of this icon
*/ */
@Override
public int getIconHeight() { public int getIconHeight() {
return height; return height;
} }

1
designer-base/src/main/java/com/fr/design/icon/WarningIcon.java

@ -59,6 +59,7 @@ public class WarningIcon extends ImageIcon {
tracker.waitForID(0, 0); tracker.waitForID(0, 0);
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
tracker.statusID(0, false); tracker.statusID(0, false);

1
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -1117,6 +1117,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
thread.join(); thread.join();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error("Map Thread Error"); FineLoggerFactory.getLogger().error("Map Thread Error");
Thread.currentThread().interrupt();
} }
DesignerEnvManager.getEnvManager().setLastOpenFile( DesignerEnvManager.getEnvManager().setLastOpenFile(

23
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.mobile.ui; package com.fr.design.mainframe.mobile.ui;
import com.fr.base.background.ColorBackground;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -23,6 +24,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private MobileStyleCustomDefinePane customBeanPane; private MobileStyleCustomDefinePane customBeanPane;
private Class<? extends MobileStyle> mobileStyleClazz; private Class<? extends MobileStyle> mobileStyleClazz;
private NewColorSelectBox colorSelectBox; private NewColorSelectBox colorSelectBox;
private Color titleColor = new Color(47, 142, 241);
MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass, MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass,
Class<? extends MobileStyle> mobileStyleClazz) { Class<? extends MobileStyle> mobileStyleClazz) {
@ -35,7 +37,9 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
@Override @Override
public void populateBean(MobileStyle ob) { public void populateBean(MobileStyle ob) {
this.customBeanPane.populateBean(ob); this.customBeanPane.populateBean(ob);
colorSelectBox.setSelectObject(ob.getBackground()); if(ob.getBackground() != null) {
colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor());
}
} }
@Override @Override
@ -43,7 +47,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get(); MobileStyle mobileStyle = Reflect.on(mobileStyleClazz).create().get();
this.widget.setMobileStyle(mobileStyle); this.widget.setMobileStyle(mobileStyle);
this.customBeanPane.updateBean(); this.customBeanPane.updateBean();
mobileStyle.setBackground(colorSelectBox.getSelectObject()); mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject()));
return mobileStyle; return mobileStyle;
} }
@ -67,8 +71,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
JPanel mobileStylePreviewPane = this.customBeanPane.createPreviewPane(); JPanel mobileStylePreviewPane = this.customBeanPane.createPreviewPane();
if(mobileStylePreviewPane != null) { if(mobileStylePreviewPane != null) {
JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Widget_Style_Preview"), null); TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Widget_Style_Preview"));
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, new Color(0x2f8ef100)));
previewPane.setBorder(titledBorder); previewPane.setBorder(titledBorder);
previewPane.setPreferredSize(new Dimension(500, 83)); previewPane.setPreferredSize(new Dimension(500, 83));
previewPane.add(mobileStylePreviewPane, BorderLayout.CENTER); previewPane.add(mobileStylePreviewPane, BorderLayout.CENTER);
@ -82,8 +85,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5)); backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5));
backgroundPane.setPreferredSize(new Dimension(500, 65)); backgroundPane.setPreferredSize(new Dimension(500, 65));
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"), null); TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute"));
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, Color.BLUE));
backgroundPane.setBorder(titledBorder); backgroundPane.setBorder(titledBorder);
UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT); UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT);
@ -104,12 +106,17 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private void createCustomPane() { private void createCustomPane() {
JPanel configPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel configPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"), null); TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set"));
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12, Color.BLUE));
configPane.setBorder(titledBorder); configPane.setBorder(titledBorder);
configPane.add(this.customBeanPane, BorderLayout.CENTER); configPane.add(this.customBeanPane, BorderLayout.CENTER);
this.add(configPane, BorderLayout.CENTER); this.add(configPane, BorderLayout.CENTER);
} }
private TitledBorder createTitledBorder(String title) {
TitledBorder titledBorder = GUICoreUtils.createTitledBorder(title, titleColor);
titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12));
return titledBorder;
}
} }

7
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java

@ -19,12 +19,11 @@ public class VcsLabel extends ActionLabel {
} }
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
if (ui != null) { if (ui != null && g != null) {
Graphics scratchGraphics = (g == null) ? null : g.create(); Graphics scratchGraphics = g.create();
try { try {
ui.update(scratchGraphics, this); ui.update(scratchGraphics, this);
} } finally {
finally {
scratchGraphics.dispose(); scratchGraphics.dispose();
} }
} }

5
designer-base/src/main/java/com/fr/design/report/WatermarkPane.java

@ -7,6 +7,7 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.ispinner.UnsignedIntUISpinner;
import com.fr.design.gui.style.FRFontPane; import com.fr.design.gui.style.FRFontPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -112,8 +113,8 @@ public class WatermarkPane extends BasicPane {
formulaPane = new TinyFormulaPane(); formulaPane = new TinyFormulaPane();
fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES);
fontSizeComboBox.setEditable(true); fontSizeComboBox.setEditable(true);
horizontalGapSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 200); horizontalGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, 200);
verticalGapSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 100); verticalGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, 100);
horizontalGapSpinner.setPreferredSize(SPINNER_DIMENSION); horizontalGapSpinner.setPreferredSize(SPINNER_DIMENSION);
verticalGapSpinner.setPreferredSize(SPINNER_DIMENSION); verticalGapSpinner.setPreferredSize(SPINNER_DIMENSION);
JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0)); JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0));

1
designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java

@ -74,6 +74,7 @@ public class ColorPicker extends JDialog implements ActionListener
Thread.sleep(100); // 等待弹窗关闭 Thread.sleep(100); // 等待弹窗关闭
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} }
colorPickerPanel.captureScreen(); colorPickerPanel.captureScreen();
} }

1
designer-base/src/main/java/com/fr/design/update/actions/FileDownloader.java

@ -65,6 +65,7 @@ public abstract class FileDownloader extends SwingWorker<Boolean, DownloadItem>
success = get(); success = get();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
} catch (ExecutionException e) { } catch (ExecutionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }

1
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -385,6 +385,7 @@ public class UpdateMainDialog extends UIDialog {
showDownLoadInfo(); showDownLoadInfo();
} catch (InterruptedException e) { } catch (InterruptedException e) {
stopLoading(); stopLoading();
Thread.currentThread().interrupt();
} catch (ExecutionException e) { } catch (ExecutionException e) {
stopLoading(); stopLoading();
} finally { } finally {

1
designer-base/src/main/java/com/fr/design/utils/DrawRoutines.java

@ -206,6 +206,7 @@ public class DrawRoutines {
grabber.grabPixels(); grabber.grabPixels();
} catch (InterruptedException e) { } catch (InterruptedException e) {
FineLoggerFactory.getLogger().error("PixelGrabber interrupted waiting for pixels"); FineLoggerFactory.getLogger().error("PixelGrabber interrupted waiting for pixels");
Thread.currentThread().interrupt();
} }
if ((grabber.getStatus() & ImageObserver.ABORT) != 0) { if ((grabber.getStatus() & ImageObserver.ABORT) != 0) {

1
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -548,6 +548,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
FineLoggerFactory.getLogger().error(e, e.getMessage()); FineLoggerFactory.getLogger().error(e, e.getMessage());
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed")); message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
Thread.currentThread().interrupt();
} }
dialogDownPane.remove(cancelButton); dialogDownPane.remove(cancelButton);
dialogDownPane.revalidate(); dialogDownPane.revalidate();

20
designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java

@ -79,15 +79,17 @@ public class FineEmbedServerMonitor {
scheduler.scheduleAtFixedRate(new Runnable() { scheduler.scheduleAtFixedRate(new Runnable() {
@Override @Override
public void run() { public void run() {
if (isComplete()) { while (!isComplete()) {
scheduler.shutdown(); if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) {
DesignerContext.getDesignerFrame().hideProgressDialog(); DesignerContext.getDesignerFrame().showProgressDialog();
return; DesignerContext.getDesignerFrame().getProgressDialog().updateLoadingText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server"));
} }
if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) { DesignerContext.getDesignerFrame().updateProgress(getProgress());
DesignerContext.getDesignerFrame().showProgressDialog(); try {
DesignerContext.getDesignerFrame().getProgressDialog() Thread.sleep(STEP_HEARTBEAT);
.updateLoadingText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server")); } catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
} }
DesignerContext.getDesignerFrame().updateProgress(getProgress()); DesignerContext.getDesignerFrame().updateProgress(getProgress());
} }

6
designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java

@ -245,7 +245,11 @@ public class MapImageEditPane extends BasicBeanPane<String> {
g2d.translate(moveLeft, moveTop); g2d.translate(moveLeft, moveTop);
g2d.setStroke(new BasicStroke(1)); g2d.setStroke(new BasicStroke(1));
if (resultAreaShape != null && !resultAreaShape.isEmpty()) {
if (resultAreaShape == null) {
throw new IllegalArgumentException("resultAreaShape can not be null!");
}
if (!resultAreaShape.isEmpty()) {
for (String key : resultAreaShape.keySet()) { for (String key : resultAreaShape.keySet()) {
GeneralPath selectShape = getSelectedNodePath(key); GeneralPath selectShape = getSelectedNodePath(key);

9
designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java

@ -96,15 +96,6 @@ public class MapEditPane extends BasicBeanPane<MapSvgAttr>{
} }
/**
* 再图片面板设置类型和名字
* @param mapType 地图类型
*/
public void dealWidthMap(String mapType){
areaPane.setTypeNameAndMapName(mapType,currentMapName);
// pointPane.setTypeNameAndMapName(mapType,currentMapName);
}
@Override @Override
public MapSvgAttr updateBean() { public MapSvgAttr updateBean() {
MapSvgAttr currentAttr = editingPane.updateCurrentAttr(); MapSvgAttr currentAttr = editingPane.updateCurrentAttr();

5
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java

@ -56,7 +56,10 @@ public class ChartDataPane extends AbstractChartAttrPane {
} }
this.setLayout(new BorderLayout(0, 0)); this.setLayout(new BorderLayout(0, 0));
if (collection != null && collection.getChartCount() <= 0) { if (collection == null) {
throw new IllegalArgumentException("ChartCollection can not be null!");
}
if (collection.getChartCount() <= 0) {
contentsPane = new NormalChartDataPane(listener, ChartDataPane.this); contentsPane = new NormalChartDataPane(listener, ChartDataPane.this);
} else if (collection.getSelectedChart().getPlot() instanceof MapPlot) { } else if (collection.getSelectedChart().getPlot() instanceof MapPlot) {
contentsPane = new MapDataPane(listener); contentsPane = new MapDataPane(listener);

4
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java

@ -114,7 +114,9 @@ public class AreaPlotPane extends AbstractDeprecatedChartTypePane {
((Area3DPlot)plot).setStacked(true); ((Area3DPlot)plot).setStacked(true);
((Area3DPlot)plot).getyAxis().setPercentage(true); ((Area3DPlot)plot).getyAxis().setPercentage(true);
} }
createAreaCondition(plot); if(plot != null) {
createAreaCondition(plot);
}
return plot; return plot;
} }

10
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BarPlotPane.java

@ -97,10 +97,12 @@ public class BarPlotPane extends AbstractBarPane{
} }
Plot cloned = null; Plot cloned = null;
try { if(newPlot != null) {
cloned = (Plot)newPlot.clone(); try {
} catch (CloneNotSupportedException e) { cloned = (Plot) newPlot.clone();
FineLoggerFactory.getLogger().error("Error In ColumnChart"); } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ColumnChart");
}
} }
return cloned; return cloned;
} }

10
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ColumnPlotPane.java

@ -94,10 +94,12 @@ public class ColumnPlotPane extends AbstractBarPane{
} }
Plot cloned = null; Plot cloned = null;
try { if(newPlot != null) {
cloned = (Plot)newPlot.clone(); try {
} catch (CloneNotSupportedException e) { cloned = (Plot) newPlot.clone();
FineLoggerFactory.getLogger().error("Error In ColumnChart"); } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ColumnChart");
}
} }
return cloned; return cloned;
} }

10
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java

@ -66,10 +66,12 @@ public class MeterPlotPane extends AbstractDeprecatedChartTypePane {
} }
Plot cloned = null; Plot cloned = null;
try { if(newPlot != null) {
cloned = (Plot)newPlot.clone(); try {
} catch (CloneNotSupportedException e) { cloned = (Plot) newPlot.clone();
FineLoggerFactory.getLogger().error("Error In ColumnChart"); } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ColumnChart");
}
} }
return cloned; return cloned;
} }

10
designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaPlotPane.java

@ -68,10 +68,12 @@ public class VanChartAreaPlotPane extends AbstractVanChartTypePane {
} }
} }
Plot cloned = null; Plot cloned = null;
try { if(newPlot != null) {
cloned = (Plot) newPlot.clone(); try {
} catch (CloneNotSupportedException e) { cloned = (Plot) newPlot.clone();
FineLoggerFactory.getLogger().error("Error In AreaChart"); } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In AreaChart");
}
} }
return cloned; return cloned;
} }

5
designer-chart/src/main/java/com/fr/van/chart/bar/VanChartBarPlotPane.java

@ -65,10 +65,11 @@ public class VanChartBarPlotPane extends AbstractVanChartTypePane {
newPlot = (VanChartColumnPlot)barChart[i].getPlot(); newPlot = (VanChartColumnPlot)barChart[i].getPlot();
} }
} }
Plot cloned = null; Plot cloned = null;
try { try {
cloned = (Plot)newPlot.clone(); if(newPlot != null) {
cloned = (Plot) newPlot.clone();
}
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ColumnChart"); FineLoggerFactory.getLogger().error("Error In ColumnChart");
} }

5
designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubblePlotPane.java

@ -77,10 +77,11 @@ public class VanChartBubblePlotPane extends AbstractVanChartTypePane {
newPlot = (VanChartBubblePlot)bubbleChart[i].getPlot(); newPlot = (VanChartBubblePlot)bubbleChart[i].getPlot();
} }
} }
Plot cloned = null; Plot cloned = null;
try { try {
cloned = (Plot)newPlot.clone(); if(newPlot != null) {
cloned = (Plot) newPlot.clone();
}
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In BubbleChart"); FineLoggerFactory.getLogger().error("Error In BubbleChart");
} }

5
designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotPane.java

@ -66,10 +66,11 @@ public class VanChartColumnPlotPane extends AbstractVanChartTypePane {
newPlot = (VanChartColumnPlot)columnChart[i].getPlot(); newPlot = (VanChartColumnPlot)columnChart[i].getPlot();
} }
} }
Plot cloned = null; Plot cloned = null;
try { try {
cloned = (Plot)newPlot.clone(); if(newPlot != null) {
cloned = (Plot) newPlot.clone();
}
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ColumnChart"); FineLoggerFactory.getLogger().error("Error In ColumnChart");
} }

4
designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java

@ -261,7 +261,9 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane {
} }
Plot cloned = null; Plot cloned = null;
try { try {
cloned = (Plot) newPlot.clone(); if(newPlot != null) {
cloned = (Plot) newPlot.clone();
}
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error("Error In ScatterChart"); FineLoggerFactory.getLogger().error("Error In ScatterChart");
} }

5
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java

@ -92,8 +92,9 @@ public class VanChartAxisButtonPane extends BasicBeanPane<VanChartAxisPlot> {
pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
buttonPane.add(pane); buttonPane.add(pane);
} }
if(pane != null) {
pane.add(indexList_Y.get(i)); pane.add(indexList_Y.get(i));
}
} }
if(popupMenu != null){ if(popupMenu != null){

6
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java

@ -160,7 +160,7 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane {
boolean allowFullScreen = chartEditor.getMobileAttr().isAllowFullScreen(); boolean allowFullScreen = chartEditor.getMobileAttr().isAllowFullScreen();
this.allowFullCheckBox.setSelected(allowFullScreen); this.allowFullCheckBox.setSelected(allowFullScreen);
boolean isFunctionalWhenUnactivated = chartEditor.getMobileAttr().isFunctionalWhenUnactivated(); boolean isFunctionalWhenUnactivated = chartEditor.getMobileAttr().isFunctionalWhenUnactivated();
this.functionalWhenUnactivatedCheckBox.setSelected(isFunctionalWhenUnactivated); this.functionalWhenUnactivatedCheckBox.setSelected(!isFunctionalWhenUnactivated);
this.bindListeners2Widgets(); this.bindListeners2Widgets();
this.addAttributeChangeListener(changeListener); this.addAttributeChangeListener(changeListener);
@ -195,10 +195,10 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane {
mobileAttr.setZoomInAttr(ChartMobileFitAttrState.PROPORTION); mobileAttr.setZoomInAttr(ChartMobileFitAttrState.PROPORTION);
mobileAttr.setZoomOutAttr((ChartMobileFitAttrState) ((Item) zoomOutComboBox.getSelectedItem()).getValue()); mobileAttr.setZoomOutAttr((ChartMobileFitAttrState) ((Item) zoomOutComboBox.getSelectedItem()).getValue());
mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected()); mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected());
mobileAttr.setFunctionalWhenUnactivated(functionalWhenUnactivatedCheckBox.isSelected()); mobileAttr.setFunctionalWhenUnactivated(!functionalWhenUnactivatedCheckBox.isSelected());
}else { }else {
mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected()); mobileAttr.setAllowFullScreen(allowFullCheckBox.isSelected());
mobileAttr.setFunctionalWhenUnactivated(functionalWhenUnactivatedCheckBox.isSelected()); mobileAttr.setFunctionalWhenUnactivated(!functionalWhenUnactivatedCheckBox.isSelected());
} }
DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来 DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来
} }

5
designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java

@ -143,7 +143,7 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane {
this.maxHeightSpinner.setVisible(elementCaseEditor.isHeightRestrict()); this.maxHeightSpinner.setVisible(elementCaseEditor.isHeightRestrict());
this.maxHeightSpinner.setValue(elementCaseEditor.getHeightPercent()); this.maxHeightSpinner.setValue(elementCaseEditor.getHeightPercent());
this.allowFullCheckBox.setSelected(elementCaseEditor.isAllowFullScreen()); this.allowFullCheckBox.setSelected(elementCaseEditor.isAllowFullScreen());
this.functionalWhenUnactivatedCheckBox.setSelected(elementCaseEditor.isFunctionalWhenUnactivated()); this.functionalWhenUnactivatedCheckBox.setSelected(!elementCaseEditor.isFunctionalWhenUnactivated());
} }
@Override @Override
@ -168,8 +168,9 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane {
break; break;
case "allowFullCheckBox": case "allowFullCheckBox":
((ElementCaseEditor) xCreator.toData()).setAllowFullScreen(allowFullCheckBox.isSelected()); ((ElementCaseEditor) xCreator.toData()).setAllowFullScreen(allowFullCheckBox.isSelected());
break;
case "functionalWhenUnactivatedCheckBox": case "functionalWhenUnactivatedCheckBox":
((ElementCaseEditor) xCreator.toData()).setFunctionalWhenUnactivated(functionalWhenUnactivatedCheckBox.isSelected()); ((ElementCaseEditor) xCreator.toData()).setFunctionalWhenUnactivated(!functionalWhenUnactivatedCheckBox.isSelected());
} }
} }

Loading…
Cancel
Save