diff --git a/designer-base/src/com/fr/design/DesignerEnvManager.java b/designer-base/src/com/fr/design/DesignerEnvManager.java index 209de7c6e0..634240489b 100644 --- a/designer-base/src/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/com/fr/design/DesignerEnvManager.java @@ -61,6 +61,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private static final int MAX_SHOW_NUM = 10; private static final String VERSION_80 = "80"; + private static final int CACHINGTEMPLATE_LIMIT = 5; private static DesignerEnvManager designerEnvManager; // gui. private String activationKey = null; @@ -99,6 +100,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private int language; //2014-8-26默认显示全部, 因为以前的版本, 虽然是false, 实际上是显示所有表, 因此这边要兼容 private boolean useOracleSystemSpace = true; + private int cachingTemplateLimit = CACHINGTEMPLATE_LIMIT; private boolean autoBackUp = true; private int undoLimit = 5; private short pageLengthUnit = Constants.UNIT_MM; @@ -244,7 +246,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { // 写文件的LogLocation String logLocation = DesignerEnvManager.getEnvManager().getLogLocation(); - if (logLocation != null) { + //Mac下8.0,9.0 选项-日志设置为空时在根目录下检测文件存在会抛无权限,这里应该设个默认值比较好吧 + if (StringUtils.isNotEmpty(logLocation)) { try { Calendar calender = GregorianCalendar.getInstance(); calender.setTimeInMillis(System.currentTimeMillis()); @@ -629,6 +632,21 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.useOracleSystemSpace = displayOracleSystem; } + /** + * 配置最大缓存模板个数 + */ + public void setCachingTemplateLimit(int cachingTemplateLimit) { + this.cachingTemplateLimit = cachingTemplateLimit; + } + + + /** + * 获取最大缓存模板个数 + */ + public int getCachingTemplateLimit() { + return this.cachingTemplateLimit; + } + /** * 是否加入产品改良 * @@ -740,7 +758,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { /** * 返回Jetty服务器的端口号 */ - public int getJettyServerPort() { + public int getEmbedServerPort() { return this.jettyServerPort; } @@ -1392,6 +1410,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.setMaxNumberOrPreviewRow(reader.getAttrAsInt("maxNumberOrPreviewRow", 200)); this.setOracleSystemSpace(reader.getAttrAsBoolean("useOracleSystemSpace", true)); + this.setCachingTemplateLimit(reader.getAttrAsInt("cachingTemplateLimit", CACHINGTEMPLATE_LIMIT)); this.setJoinProductImprove(reader.getAttrAsBoolean("joinProductImprove", true)); this.setAutoBackUp(reader.getAttrAsBoolean("autoBackUp", true)); this.setTemplateTreePaneExpanded(reader.getAttrAsBoolean("templateTreePaneExpanded", false)); @@ -1612,6 +1631,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (!this.isOracleSystemSpace()) { writer.attr("useOracleSystemSpace", this.isOracleSystemSpace()); } + if (this.getCachingTemplateLimit() >= 0) { + writer.attr("cachingTemplateLimit", this.getCachingTemplateLimit()); + } if (!this.isJoinProductImprove()) { writer.attr("joinProductImprove", this.isJoinProductImprove()); } diff --git a/designer-base/src/com/fr/design/actions/UpdateAction.java b/designer-base/src/com/fr/design/actions/UpdateAction.java index e6845745d8..d8b9f5385f 100644 --- a/designer-base/src/com/fr/design/actions/UpdateAction.java +++ b/designer-base/src/com/fr/design/actions/UpdateAction.java @@ -293,13 +293,20 @@ public abstract class UpdateAction extends ShortCut implements Action { button.setEnabled(this.isEnabled()); //peter:产生tooltip - button.setToolTipText(ActionFactory.createButtonToolTipText(this)); + button.setToolTipText(getToolTipText()); object = button; } return (JComponent) object; } + /** + * 重写此方法,可以自定义 action 的提示文字 + */ + protected String getToolTipText() { + return ActionFactory.createButtonToolTipText(this); + } + /** * Equals */ diff --git a/designer-base/src/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/com/fr/design/actions/file/PreferencePane.java index fd90242931..c4e26db6c3 100644 --- a/designer-base/src/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/com/fr/design/actions/file/PreferencePane.java @@ -14,6 +14,7 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; @@ -55,6 +56,9 @@ public class PreferencePane extends BasicPane { private static final int MAX_UNDO_LIMIT_50 = 50; private static final int SELECTED_INDEX_4 = 4; private static final int SELECTED_INDEX_5 = 5; + private static final int CACHING_MAX = 10; + private static final int CACHING_DEFAULT = 5; + private static final int CACHING_GAP = 5; private static final String TYPE = "pressed"; private static final String DISPLAY_TYPE = "+"; @@ -113,6 +117,7 @@ public class PreferencePane extends BasicPane { private IntegerEditor portEditor; private UITextField jdkHomeTextField; private UICheckBox oracleSpace; + private UISpinner cachingTemplateSpinner; private UICheckBox joinProductImprove; public PreferencePane() { @@ -173,6 +178,7 @@ public class PreferencePane extends BasicPane { JPanel spaceUpPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); spaceUpPane.add(oraclePane, BorderLayout.NORTH); + spaceUpPane.add(createMemoryPane(), BorderLayout.CENTER); spaceUpPane.add(improvePane, BorderLayout.SOUTH); advancePane.add(spaceUpPane); } @@ -497,6 +503,20 @@ public class PreferencePane extends BasicPane { serverPortPane.add(choosePortPane, BorderLayout.CENTER); } + private JPanel createMemoryPane() { + JPanel memoryPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Preference_CachingTemplate")); + UILabel memoryLabel = new UILabel(Inter.getLocText("FR-Designer_Preference_MaxCachingTemplate")); + UILabel memoryTipLabel = new UILabel(Inter.getLocText("FR-Designer_Preference_CachingTemplateTip")); + memoryTipLabel.setBorder(BorderFactory.createEmptyBorder( 0, CACHING_GAP, 0, 0)); + cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT); + JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); + memorySpace.add(memoryLabel); + memorySpace.add(cachingTemplateSpinner); + memorySpace.add(memoryTipLabel); + memoryPane.add(memorySpace); + return memoryPane; + } + @Override protected String title4PopupWindow() { return Inter.getLocText("M_Window-Preference"); @@ -550,11 +570,12 @@ public class PreferencePane extends BasicPane { this.pageLengthComboBox.setSelectedIndex(designerEnvManager.getPageLengthUnit()); this.reportLengthComboBox.setSelectedIndex(designerEnvManager.getReportLengthUnit()); - this.portEditor.setValue(new Integer(designerEnvManager.getJettyServerPort())); + this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort())); this.jdkHomeTextField.setText(designerEnvManager.getJdkHome()); this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace()); + this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit()); this.joinProductImprove.setSelected(designerEnvManager.isJoinProductImprove()); } @@ -615,6 +636,7 @@ public class PreferencePane extends BasicPane { designerEnvManager.setJdkHome(jdkHomeTextField.getText()); designerEnvManager.setOracleSystemSpace(this.oracleSpace.isSelected()); + designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue()); designerEnvManager.setJoinProductImprove(this.joinProductImprove.isSelected()); // designerEnvManager.setAutoBackUp(this.autoBackUp.isSelected()); diff --git a/designer-base/src/com/fr/design/actions/help/WebDemoAction.java b/designer-base/src/com/fr/design/actions/help/WebDemoAction.java index bf3f65229e..2532d0b0d3 100644 --- a/designer-base/src/com/fr/design/actions/help/WebDemoAction.java +++ b/designer-base/src/com/fr/design/actions/help/WebDemoAction.java @@ -4,7 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; import com.fr.design.menu.MenuKeySet; import com.fr.general.Inter; -import com.fr.start.StartServer; +import com.fr.start.ServerStarter; import javax.swing.*; import java.awt.event.ActionEvent; @@ -23,7 +23,7 @@ public class WebDemoAction extends UpdateAction { * @param evt 事件 */ public void actionPerformed(ActionEvent evt) { - StartServer.browserDemoURL(); + ServerStarter.browserDemoURL(); } public static final MenuKeySet PRODUCT_DEMO = new MenuKeySet() { diff --git a/designer-base/src/com/fr/design/constants/UIConstants.java b/designer-base/src/com/fr/design/constants/UIConstants.java index 1b8debbb5d..1959f6fc04 100644 --- a/designer-base/src/com/fr/design/constants/UIConstants.java +++ b/designer-base/src/com/fr/design/constants/UIConstants.java @@ -108,6 +108,7 @@ public interface UIConstants { public static final Color AUTHORITY_SHEET_UNSELECTED = new Color(146, 192, 225); public static final Color ATTRIBUTE_PRESS = new Color(0x419BF9); public static final Color NORMAL_BLUE = new Color(0x419BF9); + public static final Color DISABLED_ICON_COLOR = new Color(170, 170, 171); public static final Color ATTRIBUTE_NORMAL = Color.WHITE; public static final Color ATTRIBUTE_HOVER = new Color(0xF5F5F7); public static final Color UI_TOOLBAR_COLOR = new Color(0xF5F5F7); diff --git a/designer-base/src/com/fr/design/event/DesignerOpenedListener.java b/designer-base/src/com/fr/design/event/DesignerOpenedListener.java new file mode 100644 index 0000000000..77c6bcf8f1 --- /dev/null +++ b/designer-base/src/com/fr/design/event/DesignerOpenedListener.java @@ -0,0 +1,13 @@ +package com.fr.design.event; + +import java.util.EventListener; + +/** + * Created by plough on 2018/1/19. + */ +public interface DesignerOpenedListener extends EventListener { + /** + * Invoked when the target of the listener has changed the rpt content. + */ + public void designerOpened(); +} \ No newline at end of file diff --git a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java index b9ffee91a5..92a27b7605 100644 --- a/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer-base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -35,7 +35,7 @@ import java.util.List; public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent { //最大保存内存中面板数,为0时关闭优化内存 - private static final int DEAD_LINE = 5; + private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit();; private static final int LIST_BORDER = 4; private List> historyList; private JTemplate editingTemplate; diff --git a/designer-base/src/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/com/fr/design/file/MutilTempalteTabPane.java index e2c0264651..b152e1fe80 100644 --- a/designer-base/src/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/com/fr/design/file/MutilTempalteTabPane.java @@ -16,6 +16,7 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; +import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.project.ProjectConstants; @@ -709,7 +710,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M filename = ((FileNodeFILE) openedTemplate.get(selectedIndex).getEditingFILE()).getEnvPath() + File.separator + filename; } - filename = filename.replaceAll("/", "\\\\"); + filename = OperatingSystem.isWindows() ? filename.replaceAll("/", "\\\\") : filename.replaceAll("\\\\", "/"); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); diff --git a/designer-base/src/com/fr/design/gui/controlpane/UIListControlPane.java b/designer-base/src/com/fr/design/gui/controlpane/UIListControlPane.java index d6c1a34324..bb6d7dbab1 100644 --- a/designer-base/src/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer-base/src/com/fr/design/gui/controlpane/UIListControlPane.java @@ -219,8 +219,9 @@ public abstract class UIListControlPane extends UIControlPane { return; } - for (Nameable aNameableArray : nameableArray) { - listModel.addElement(new ListModelElement(aNameableArray)); + listModel.setSize(nameableArray.length); + for (int i = 0; i < nameableArray.length; i++) { + listModel.set(i, new ListModelElement(nameableArray[i])); } if (listModel.size() > 0 || this.nameableList.getSelectedIndex() != 0) { diff --git a/designer-base/src/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java b/designer-base/src/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java index 8f5fa9804d..1366b46b3c 100644 --- a/designer-base/src/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java +++ b/designer-base/src/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java @@ -5,6 +5,7 @@ import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; +import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.*; @@ -40,7 +41,7 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { * 后台初始化所有事件. */ public void initAllListeners() { - initListener(AbstractAttrNoScrollPane.this); + initListener(AbstractAttrNoScrollPane.this); } protected void initContentPane() { @@ -73,14 +74,14 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { } if (tmpComp instanceof GlobalNameObserver) { ((GlobalNameObserver) tmpComp).registerNameListener(new GlobalNameListener() { - public void setGlobalName(String name) { - globalName = name; - } - - public String getGlobalName() { - return globalName; - } - }); + public void setGlobalName(String name) { + globalName = name; + } + + public String getGlobalName() { + return globalName; + } + }); } if (tmpComp instanceof UIObserver) { ((UIObserver) tmpComp).registerChangeListener(new UIObserverListener() { @@ -93,10 +94,10 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { } } - /** - * 是否有改变监听 - * @return 是则返回true - */ + /** + * 是否有改变监听 + * @return 是则返回true + */ public static boolean isHasChangeListener() { return hasChangeListener; } @@ -109,10 +110,10 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { } - /** - * 返回绑定的属性事件. - * @param listener 增加监听 - */ + /** + * 返回绑定的属性事件. + * @param listener 增加监听 + */ public void addAttributeChangeListener(AttributeChangeListener listener) { this.listener = listener; hasChangeListener = true; @@ -132,13 +133,19 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { /** * 返回图标的路径 */ - public abstract String getIconPath(); + public String getIconPath() { + // 默认为空,子类有需要再重写 + return StringUtils.EMPTY; + } - /** - * 界面标题 - * @return 标题 - */ - public abstract String title4PopupWindow(); + /** + * 界面标题 + * @return 标题 + */ + public String title4PopupWindow() { + // 默认为空,子类有需要再重写 + return StringUtils.EMPTY; + } /** * 设置选中的ID, 用于双击展示界面. @@ -151,12 +158,12 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { return globalName; } - /** - * 主要用于图表设计器 - * @return 是 - */ - public boolean isNeedPresentPaneWhenFilterData(){ - return true; - } + /** + * 主要用于图表设计器 + * @return 是 + */ + public boolean isNeedPresentPaneWhenFilterData(){ + return true; + } } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/gui/ibutton/UIRadioButton.java b/designer-base/src/com/fr/design/gui/ibutton/UIRadioButton.java index d8e36296fd..0752eef4d2 100644 --- a/designer-base/src/com/fr/design/gui/ibutton/UIRadioButton.java +++ b/designer-base/src/com/fr/design/gui/ibutton/UIRadioButton.java @@ -1,6 +1,14 @@ package com.fr.design.gui.ibutton; +import com.fr.design.event.GlobalNameListener; +import com.fr.design.event.GlobalNameObserver; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.stable.StringUtils; + import javax.swing.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; /** * Created by IntelliJ IDEA. @@ -9,38 +17,110 @@ import javax.swing.*; * Date: 13-3-27 * Time: 下午5:04 */ -public class UIRadioButton extends JRadioButton { +public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNameObserver { + private UIObserverListener uiObserverListener; + private GlobalNameListener globalNameListener = null; + private String radioButtonName = StringUtils.EMPTY; public UIRadioButton() { super(); + initListener(); } public UIRadioButton(Icon icon) { super(icon); + initListener(); } public UIRadioButton(Action a) { super(a); + initListener(); } public UIRadioButton(Icon icon, boolean selected) { super(icon, selected); + initListener(); } public UIRadioButton(String text) { super(text); + initListener(); } public UIRadioButton(String text, boolean selected) { super(text, selected); + initListener(); } public UIRadioButton(String text, Icon icon) { super(text, icon); + initListener(); } public UIRadioButton(String text, Icon icon, boolean selected) { super(text, icon, selected); + initListener(); + } + + private void initListener() { + if (shouldResponseChangeListener()) { + this.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + if (uiObserverListener == null || e.getStateChange() != ItemEvent.SELECTED) { + return; + } + if (globalNameListener != null && shouldResponseNameListener()) { + globalNameListener.setGlobalName(radioButtonName); + } + uiObserverListener.doChange(); + } + }); + } + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + + public void setGlobalName(String name) { + radioButtonName = name; + } + + public String getGlobalName() { + return radioButtonName; + } + + /** + * 组件是否需要响应添加的观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + public boolean shouldResponseChangeListener() { + return true; + } + + /** + * 注册观察者监听事件 + * @param listener 观察者监听事件 + */ + public void registerNameListener(GlobalNameListener listener) { + globalNameListener = listener; + } + + /** + * 组件是否需要响应观察者事件 + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + public boolean shouldResponseNameListener() { + return true; } } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/gui/icheckbox/UICheckBox.java b/designer-base/src/com/fr/design/gui/icheckbox/UICheckBox.java index 6e2c93f520..9d49bd06ec 100644 --- a/designer-base/src/com/fr/design/gui/icheckbox/UICheckBox.java +++ b/designer-base/src/com/fr/design/gui/icheckbox/UICheckBox.java @@ -137,10 +137,12 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser g.setColor(b.getBackground()); g.fillRect(0, 0, size.width, size.height); } + Graphics2D g2d = (Graphics2D) g; g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if ( model.isSelected()) { - GUIPaintUtils.fillPaint(g2d, iconRect.x, iconRect.y, iconRect.width, iconRect.height,false, Constants.NULL,UIConstants.CHECKBOX_HOVER_SELECTED, 0); + GUIPaintUtils.fillPaint(g2d, iconRect.x, iconRect.y, iconRect.width, iconRect.height,false, Constants.NULL, + model.isEnabled() ? UIConstants.CHECKBOX_HOVER_SELECTED : UIConstants.DISABLED_ICON_COLOR, 0); } else if (model.isRollover() && ! model.isSelected()) { g.setColor(UIConstants.CHECKBOX_HOVER_SELECTED); g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); diff --git a/designer-base/src/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/com/fr/design/gui/ispinner/UISpinner.java index c9c3988293..24d0b1c1c4 100644 --- a/designer-base/src/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/com/fr/design/gui/ispinner/UISpinner.java @@ -12,14 +12,28 @@ import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.stable.Constants; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.ButtonModel; +import javax.swing.Icon; +import javax.swing.JComponent; +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.ButtonUI; -import java.awt.*; -import java.awt.event.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver { diff --git a/designer-base/src/com/fr/design/gui/style/FRFontPane.java b/designer-base/src/com/fr/design/gui/style/FRFontPane.java index ef378ea32f..261a51764c 100644 --- a/designer-base/src/com/fr/design/gui/style/FRFontPane.java +++ b/designer-base/src/com/fr/design/gui/style/FRFontPane.java @@ -49,7 +49,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse private JPanel isSuperOrSubPane; private UIComboBox fontNameComboBox; private UIComboBox fontSizeStyleComboBox; - private UIComboBox fontSizeComboBox; + protected UIComboBox fontSizeComboBox; private UIToggleButton bold; private UIToggleButton italic; private UIToggleButton underline; @@ -327,7 +327,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); } - private JPanel createRightPane() { + protected JPanel createRightPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = {f}; diff --git a/designer-base/src/com/fr/design/icon/IconPathConstants.java b/designer-base/src/com/fr/design/icon/IconPathConstants.java index ec5fcded3f..9a670fa4c6 100644 --- a/designer-base/src/com/fr/design/icon/IconPathConstants.java +++ b/designer-base/src/com/fr/design/icon/IconPathConstants.java @@ -1 +1,36 @@ -package com.fr.design.icon; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 6.5.6 * Date: 12-12-18 * Time: 上午9:42 * 用于保存所有图标路径的类 */ public class IconPathConstants { private IconPathConstants() { } public static final String ADD_POPMENU_ICON_PATH = "/com/fr/design/images/control/addPopup.png"; public static final String DS_ICON_PATH = "/com/fr/design/images/data/datasource.png"; public static final String CLASS_TD_ICON_PATH = "/com/fr/design/images/data/source/classTableData.png"; public static final String EMB_TD_ICON_PATH = "/com/fr/design/images/data/dataTable.png"; public static final String DS_RELATION_TD_ICON_PATH = "/com/fr/design/images/data/multi.png"; public static final String FILE_TD_ICON_PATH = "/com/fr/design/images/data/file.png"; public static final String DS_TREE_TD_ICON_PATH = "/com/fr/design/images/data/tree.png"; public static final String DS_QUERY_ICON_PATH = "/com/fr/design/images/data/database.png"; public static final String PREVIEW_ICON_PATH = "/com/fr/design/images/m_file/preview.png"; public static final String TD_EDIT_ICON_PATH = "/com/fr/design/images/control/edit.png"; public static final String TD_EL_SHARE_HELP_ICON_PATH = "/com/fr/design/images/control/help_open.png"; public static final String TD_EL_SHARE_CLOSE_ICON_PATH = "/com/fr/design/images/control/help_close.png"; public static final String TD_REMOVE_ICON_PATH = "/com/fr/design/images/control/tab/remove.png"; public static final String TD_CONNECTION_ICON_PATH = "/com/fr/design/images/m_web/connection.png"; public static final String SP_SHOW_ICON_PATH = "/com/fr/design/images/data/store_procedure.png"; public static final String STD_SHOW_ICON_PATH = "/com/fr/design/images/data/dock/serverdatabase.png"; public static final String XMLA_ICON_PATH = "/com/fr/design/images/data/cube.png"; public static final String FORBID_ICON_PATH = "/com/fr/web/images/form/forbid.png"; } \ No newline at end of file +package com.fr.design.icon; + +/** + * Created by IntelliJ IDEA. + * Author : Richer + * Version: 6.5.6 + * Date: 12-12-18 + * Time: 上午9:42 + * 用于保存所有图标路径的类 + */ +public class IconPathConstants { + private IconPathConstants() { + + } + + public static final String ADD_POPMENU_ICON_PATH = "/com/fr/design/images/control/addPopup.png"; + + public static final String DS_ICON_PATH = "/com/fr/design/images/data/datasource.png"; + public static final String CLASS_TD_ICON_PATH = "/com/fr/design/images/data/source/classTableData.png"; + public static final String EMB_TD_ICON_PATH = "/com/fr/design/images/data/dataTable.png"; + public static final String DS_RELATION_TD_ICON_PATH = "/com/fr/design/images/data/multi.png"; + public static final String FILE_TD_ICON_PATH = "/com/fr/design/images/data/file.png"; + public static final String DS_TREE_TD_ICON_PATH = "/com/fr/design/images/data/tree.png"; + public static final String DS_QUERY_ICON_PATH = "/com/fr/design/images/data/database.png"; + public static final String PREVIEW_ICON_PATH = "/com/fr/design/images/m_file/preview.png"; + public static final String TD_EDIT_ICON_PATH = "/com/fr/design/images/control/edit.png"; + public static final String TD_EL_SHARE_HELP_ICON_PATH = "/com/fr/design/images/control/help_open.png"; + public static final String TD_EL_SHARE_CLOSE_ICON_PATH = "/com/fr/design/images/control/help_close.png"; + public static final String TD_REMOVE_ICON_PATH = "/com/fr/design/images/control/tab/remove.png"; + public static final String TD_CONNECTION_ICON_PATH = "/com/fr/design/images/m_web/connection.png"; + public static final String SP_SHOW_ICON_PATH = "/com/fr/design/images/data/store_procedure.png"; + public static final String STD_SHOW_ICON_PATH = "/com/fr/design/images/data/dock/serverdatabase.png"; + public static final String XMLA_ICON_PATH = "/com/fr/design/images/data/cube.png"; + public static final String FORBID_ICON_PATH = "/com/fr/web/images/form/forbid.png"; + public static final String EDIT_ICON_PATH = "/com/fr/design/images/control/newEdit.png"; +} diff --git a/designer-base/src/com/fr/design/images/control/newEdit.png b/designer-base/src/com/fr/design/images/control/newEdit.png new file mode 100644 index 0000000000..a54ad7419c Binary files /dev/null and b/designer-base/src/com/fr/design/images/control/newEdit.png differ diff --git a/designer-base/src/com/fr/design/javascript/JavaScriptActionPane.java b/designer-base/src/com/fr/design/javascript/JavaScriptActionPane.java index 469c72555c..3226213e6c 100644 --- a/designer-base/src/com/fr/design/javascript/JavaScriptActionPane.java +++ b/designer-base/src/com/fr/design/javascript/JavaScriptActionPane.java @@ -2,21 +2,20 @@ package com.fr.design.javascript; import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.fun.JavaScriptActionProvider; import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.write.submit.DBManipulationPane; -import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.editor.ValueEditorPaneFactory; -import com.fr.design.editor.editor.Editor; import com.fr.form.ui.WebContentUtils; import com.fr.general.Inter; import com.fr.js.JavaScript; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -105,7 +104,7 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane { callPane.populateBean(getCall()); - BasicDialog dialog = callPane.showWindow(DesignerContext.getDesignerFrame()); + BasicDialog dialog = callPane.showWindow(SwingUtilities.getWindowAncestor(JavaScriptActionPane.this)); dialog.addDialogActionListener(new DialogActionAdapter() { @Override diff --git a/designer-base/src/com/fr/design/layout/FRGUIPaneFactory.java b/designer-base/src/com/fr/design/layout/FRGUIPaneFactory.java index e21f1c1944..db48cf9950 100644 --- a/designer-base/src/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/com/fr/design/layout/FRGUIPaneFactory.java @@ -416,6 +416,37 @@ public class FRGUIPaneFactory { return jp; } + /** + * 创建垂直流布局面板 + * + * @param isAlignLeft 是否左对齐 + * @return JPanel对象 + */ + public static JPanel createVerticalFlowLayout_S_Pane(boolean isAlignLeft) { + JPanel jp = new JPanel(); + VerticalFlowLayout layout = new VerticalFlowLayout(); + layout.setAlignLeft(isAlignLeft); + jp.setLayout(layout); + return jp; + } + + /** + * 创建垂直流布局面板 + * + * @param isAlignLeft 是否左对齐 + * @param align the alignment value + * @param hgap the horizontal gap between components + * @param vgap the vertical gap between components + * @return JPanel对象 + */ + public static JPanel createVerticalFlowLayout_Pane(boolean isAlignLeft, int align, int hgap, int vgap) { + JPanel jp = new JPanel(); + VerticalFlowLayout layout = new VerticalFlowLayout(align, hgap, vgap); + layout.setAlignLeft(isAlignLeft); + jp.setLayout(layout); + return jp; + } + /** * 创建边框面板L * diff --git a/designer-base/src/com/fr/design/layout/VerticalFlowLayout.java b/designer-base/src/com/fr/design/layout/VerticalFlowLayout.java index 7e386c9da5..5d5131ff40 100644 --- a/designer-base/src/com/fr/design/layout/VerticalFlowLayout.java +++ b/designer-base/src/com/fr/design/layout/VerticalFlowLayout.java @@ -71,6 +71,9 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { */ int newAlign; // This is the one we actually use + // 当列宽不一致时,是否需要左对齐(默认居中对齐) + boolean isAlignLeft = false; + /** * The flow layout manager allows a seperation of * components with gaps. The horizontal gap will @@ -261,9 +264,9 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { return dim; } } - + protected boolean dialWithDim4PreferredLayoutSize(Dimension dim, Dimension d, boolean firstVisibleComponent) { - dim.width = Math.max(dim.width, d.width); + dim.width = Math.max(dim.width, d.width); if (firstVisibleComponent) { firstVisibleComponent = false; } else { @@ -271,7 +274,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { } dim.height += d.height; - + return firstVisibleComponent; } @@ -291,7 +294,7 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { Dimension dim = new Dimension(0, 0); int nmembers = target.getComponentCount(); boolean firstVisibleComponent = true; - + for (int i = 0; i < nmembers; i++) { Component m = target.getComponent(i); if (m.isVisible()) { @@ -306,14 +309,14 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { return dim; } } - + protected boolean dialWithDim4MinimumLayoutSize(Dimension dim, Dimension d, int i, boolean firstVisibleComponent) { - dim.width = Math.max(dim.width, d.width); + dim.width = Math.max(dim.width, d.width); if (i > 0) { dim.height += vgap; } dim.height += d.height; - + return firstVisibleComponent; } @@ -345,10 +348,11 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { for (int i = rowStart; i < rowEnd; i++) { Component m = target.getComponent(i); if (m.isVisible()) { + int newX = x + (width - m.getWidth()) / 2; if (ltr) { - m.setLocation(x + (width - m.getWidth()) / 2, y); + m.setLocation(isAlignLeft ? x : newX, y); } else { - m.setLocation(x + (width - m.getWidth()) / 2, target.getHeight() - y - m.getHeight()); + m.setLocation(isAlignLeft ? x : newX, target.getHeight() - y - m.getHeight()); } y += m.getHeight() + vgap; } @@ -395,17 +399,17 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { dealWithMC4LayoutContainer(target, insets, x, y, roww, start, maxlen, nmembers, ltr); } } - + protected Dimension getPreferredSize(Container target, Component m) { - return m.getPreferredSize(); + return m.getPreferredSize(); } - + protected void dealWithMC4LayoutContainer(Container target, Insets insets, int x, int y, int roww, int start, int maxlen, int nmembers, boolean ltr) { - moveComponents(target, x, insets.top + vgap, roww, maxlen - y, start, nmembers, ltr); + moveComponents(target, x, insets.top + vgap, roww, maxlen - y, start, nmembers, ltr); } - + protected int[] dealWithDim4LayoutContainer(Container target, Insets insets, Dimension d, int x, int y, int roww, int start, int maxlen, int i, boolean ltr) { - if ((y == 0) || ((y + d.height) <= maxlen)) { + if ((y == 0) || ((y + d.height) <= maxlen)) { if (y > 0) y += vgap; y += d.height; roww = Math.max(roww, d.width); @@ -416,19 +420,26 @@ public class VerticalFlowLayout implements LayoutManager, java.io.Serializable { roww = d.width; start = i; } - return new int[]{x, y, roww, start}; + return new int[]{x, y, roww, start}; } - + protected int getMaxLen4LayoutContainer(Container target, Insets insets) { - return target.getHeight() - (insets.top + insets.bottom + vgap * 2); + return target.getHeight() - (insets.top + insets.bottom + vgap * 2); } - + protected int getX4LayoutContainer(Insets insets) { - return insets.left + hgap; + return insets.left + hgap; } - + protected int getY4LayoutContainer(Insets insets) { - return 0; + return 0; + } + + /** + * 当列宽不一致时,通过此方法设置是否需要左对齐 + */ + public void setAlignLeft(boolean isAlignLeft) { + this.isAlignLeft = true; } diff --git a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java index 828c6623b2..628bf85710 100644 --- a/designer-base/src/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/com/fr/design/mainframe/DesignerFrame.java @@ -7,6 +7,7 @@ import com.fr.base.BaseUtils; import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.core.env.EnvConfig; +import com.fr.core.env.EnvContext; import com.fr.core.env.resource.EnvConfigUtils; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; @@ -16,6 +17,7 @@ import com.fr.design.actions.core.ActionFactory; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.design.event.DesignerOpenedListener; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; @@ -95,6 +97,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private static final Integer TOP_LAYER = new Integer((200)); private static java.util.List> appList = new java.util.ArrayList>(); + private List designerOpenedListenerList = new ArrayList<>(); + private ToolBarMenuDock ad; private DesktopCardPane centerTemplateCardPane; @@ -287,6 +291,22 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } } + /** + * 注册"设计器初始化完成"的监听 + */ + public void addDesignerOpenedListener(DesignerOpenedListener listener) { + designerOpenedListenerList.add(listener); + } + + /** + * 触发"设计器初始化完成"事件 + */ + public void fireDesignerOpened() { + for (DesignerOpenedListener listener : designerOpenedListenerList) { + listener.designerOpened(); + } + } + protected DesktopCardPane getCenterTemplateCardPane() { return centerTemplateCardPane; } @@ -317,7 +337,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void on(PluginEvent event) { refreshNorthEastPane(northEastPane, ad); - DesignUtils.refreshDesignerFrame(FRContext.getCurrentEnv()); + DesignUtils.refreshDesignerFrame(); } }, new PluginFilter() { @@ -682,10 +702,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta /** * 报表运行环境改变时,需要刷新某些面板 - * - * @param env 环境 */ - public void refreshEnv(Env env) { + public void refreshEnv() { this.setTitle(); DesignerFrameFileDealerPane.getInstance().refreshDockingView(); @@ -929,8 +947,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } else { this.addAndActivateJTemplate(jt); } - //REPORT-5084:激活后刷新一下右側面板 - jt.refreshEastPropertiesPane(); } /** @@ -965,14 +981,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta DesignerEnvManager.getEnvManager().saveXMLFile(); - Env currentEnv = FRContext.getCurrentEnv(); - try { - EventDispatcher.fire(BEFORE_SIGN_OUT); - currentEnv.signOut(); - EventDispatcher.fire(AFTER_SIGN_OUT); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } + EnvContext.signOut(); + this.setVisible(false); this.dispose(); diff --git a/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java index d2bffafc55..ef8729ddc3 100644 --- a/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/com/fr/design/mainframe/EastRegionContainerPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; @@ -81,7 +82,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { * * @return */ - public static final EastRegionContainerPane getInstance() { + public static EastRegionContainerPane getInstance() { if (THIS == null) { THIS = new EastRegionContainerPane(); THIS.setLastContainerWidth(DesignerEnvManager.getEnvManager().getLastEastRegionContainerWidth()); @@ -230,6 +231,13 @@ public class EastRegionContainerPane extends UIEastResizableContainer { updateAllPropertyPane(); } + /** + * 可通过此方法,判断当前的编辑模式 + * */ + public PropertyMode getCurrentMode() { + return currentMode; + } + public void updateAllPropertyPane() { updatePropertyItemMap(); initContentPane(); @@ -357,10 +365,6 @@ public class EastRegionContainerPane extends UIEastResizableContainer { propertyItemMap.get(KEY_WIDGET_SETTINGS).replaceHeaderPane(paraPane); } - public void setParameterHeight(int height) { - // stub - } - public static void main(String[] args){ JFrame jf = new JFrame("test"); // jf = new JFrame("test"); @@ -436,7 +440,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // 无可用 tab 时,显示提示文字 if (!hasAvailableTab) { resetPropertyIcons(); - if (!hasEnabledTab && BaseUtils.isAuthorityEditing()) { + if (!hasEnabledTab && DesignerMode.isAuthorityEditing()) { propertyCard.show(rightPane, DEFAULT_AUTHORITY_PANE); } else { propertyCard.show(rightPane, DEFAULT_PANE); diff --git a/designer-base/src/com/fr/design/mainframe/JSliderPane.java b/designer-base/src/com/fr/design/mainframe/JSliderPane.java index 83edb560ae..19673fc34e 100644 --- a/designer-base/src/com/fr/design/mainframe/JSliderPane.java +++ b/designer-base/src/com/fr/design/mainframe/JSliderPane.java @@ -6,6 +6,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.ibutton.UISliderButton; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.islider.UISlider; import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.ispinner.UISpinnerUI; @@ -21,7 +22,6 @@ import javax.swing.JButton; import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JPanel; -import javax.swing.JPopupMenu; import javax.swing.JRadioButton; import javax.swing.JSeparator; import javax.swing.JSpinner; @@ -41,6 +41,7 @@ import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; +import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.ActionEvent; @@ -59,22 +60,15 @@ public class JSliderPane extends JPanel { private static final double ONEPOINTEIGHT = 1.8; private static final int SIX = 6; private static final int TEN = 10; - private static final int ONE_EIGHT = 18; private static final int FONT_SIZE = 12; private static final int SPINNER_WIDTH = 45; private static final int SPINNER_HEIGHT = 20; private static final int HALF_HUNDRED = 50; private static final int HUNDRED = 100; private static final int TWO_HUNDRED = 200; - private static final int THREE_HUNDRED = 300; private static final int FOUR_HUNDRED = 400; - private static final int DIALOG_WIDTH = 157; - private static final int DIALOG_HEIGHT = 192; - private static final int SLIDER_WIDTH = 220; - private static final int SLIDER_HEIGHT = 20; private static final int SHOWVALBUTTON_WIDTH = 40; private static final int SHOWVALBUTTON_HEIGHTH = 20; - private static final int SLIDER_GAP = 5; private static final int TOOLTIP_Y = 30; private static final Color BACK_COLOR = new Color(245, 245, 247); @@ -427,14 +421,14 @@ public class JSliderPane extends JPanel { dialog = new PopupPane(upButton, dialogContentPanel); if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); } } else { if (upButtonX == 0) { upButtonX = btnCoords.x; - GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); } else { - GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT); + GUICoreUtils.showPopupMenu(dialog, upButton, -dialog.getPreferredSize().width + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -dialog.getPreferredSize().height); } } } @@ -503,9 +497,12 @@ class JSliderPaneUI extends BasicSliderUI { } -class PopupPane extends JPopupMenu { +class PopupPane extends UIPopupMenu { + private static final float REC = 8f; + private static final int INSERT_TOPBOTTOM = 10; + private static final int INSERT_LEFTRIGHT = 2; private static final int DIALOG_WIDTH = 157; - private static final int DIALOG_HEIGHT = 192; + private static final int DIALOG_HEIGHT = 205; PopupPane(JButton b, JPanel dialogContentPanel) { this.add(dialogContentPanel, BorderLayout.CENTER); @@ -513,5 +510,7 @@ class PopupPane extends JPopupMenu { this.setBackground(new Color(245, 245, 247)); } - + public Insets getInsets() { + return new Insets(INSERT_TOPBOTTOM, INSERT_LEFTRIGHT, INSERT_TOPBOTTOM, INSERT_LEFTRIGHT); + } } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/mainframe/JTemplate.java b/designer-base/src/com/fr/design/mainframe/JTemplate.java index bec2dcf2e6..df970d1b3e 100644 --- a/designer-base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/com/fr/design/mainframe/JTemplate.java @@ -557,15 +557,25 @@ public abstract class JTemplate> operation == FILEChooserPane.OK_OPTION; } - private boolean saveAsTemplate(boolean isShowLoc) { + public boolean saveAsTemplate(boolean isShowLoc) { FILE editingFILE = this.getEditingFILE(); if (editingFILE == null) { return false; } + return saveAsTemplate(isShowLoc, editingFILE.getName()); + } + + /** + * 保存 + * @param isShowLoc 是否显示“报表运行环境”外的路径(C盘D盘等) + * @param fileName 保存文件名 + * @return + */ + public boolean saveAsTemplate(boolean isShowLoc, String fileName) { String oldName = this.getFullPathName(); // alex:如果是SaveAs的话需要让用户来选择路径了 FILEChooserPane fileChooser = getFILEChooserPane(isShowLoc); - fileChooser.setFileNameTextField(editingFILE.getName(), this.suffix()); + fileChooser.setFileNameTextField(fileName, this.suffix()); int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix()); if (isCancelOperation(chooseResult)) { @@ -574,7 +584,7 @@ public abstract class JTemplate> } if (isOkOperation(chooseResult)) { - if (!FRContext.getCurrentEnv().hasFileFolderAllow(fileChooser.getSelectedFILE().getPath())) { + if (!FRContext.getCurrentEnv().hasFileFolderAllow(fileChooser.getSelectedFILE().getPath()) ) { JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_No-Privilege") + "!", Inter.getLocText("FR-Designer_Message"), JOptionPane.WARNING_MESSAGE); return false; } @@ -1000,10 +1010,24 @@ public abstract class JTemplate> return UIConstants.RUN_BIG_ICON; } + /** + * 获取所有参数 + * + * @return + */ public Parameter[] getParameters() { return new Parameter[0]; } + /** + * 获取模板参数 + * + * @return + */ + public Parameter[] getJTemplateParameters() { + return new Parameter[0]; + } + /** * 请求表单焦点 */ diff --git a/designer-base/src/com/fr/design/mainframe/JVirtualTemplate.java b/designer-base/src/com/fr/design/mainframe/JVirtualTemplate.java index 4652a6b8b8..25570ee941 100644 --- a/designer-base/src/com/fr/design/mainframe/JVirtualTemplate.java +++ b/designer-base/src/com/fr/design/mainframe/JVirtualTemplate.java @@ -12,6 +12,7 @@ import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; +import com.fr.stable.OperatingSystem; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; @@ -41,7 +42,8 @@ public class JVirtualTemplate extends JTemplate { if (editingFileName.startsWith(ProjectConstants.REPORTLETS_NAME)) { editingFileName = ((FileNodeFILE) getEditingFILE()).getEnvPath() + File.separator + editingFileName; } - return editingFileName.replaceAll("/", "\\\\"); + editingFileName = OperatingSystem.isWindows() ? editingFileName.replaceAll("/", "\\\\") : editingFileName.replaceAll("\\\\", "/"); + return editingFileName; } /** diff --git a/designer-base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java b/designer-base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java index de9628e501..405e1fc187 100644 --- a/designer-base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java +++ b/designer-base/src/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java @@ -47,7 +47,7 @@ public class ImageBackgroundQuickPane extends BackgroundQuickPane { public ImageBackgroundQuickPane(boolean hasImageLayout) { this.setLayout(new BorderLayout(0, 4)); - String[] nameArray = {Inter.getLocText("FR-Background_Image_Default"), Inter.getLocText("FR-Background_Image_Titled"), Inter.getLocText("FR-Background_Image_Adjust"), Inter.getLocText("FR-Background_Image_Extend")}; + String[] nameArray = {Inter.getLocText("FR-Background_Image_Default"), Inter.getLocText("FR-Background_Image_Titled"), Inter.getLocText("FR-Background_Image_Extend"), Inter.getLocText("FR-Background_Image_Adjust")}; Byte[] valueArray = {Constants.IMAGE_CENTER, Constants.IMAGE_TILED, Constants.IMAGE_EXTEND, Constants.IMAGE_ADJUST}; imageLayoutPane = new UIButtonGroup(nameArray, valueArray); imageLayoutPane.setSelectedIndex(0); diff --git a/designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 846583538b..ef53252154 100644 --- a/designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -1,7 +1,6 @@ package com.fr.design.mainframe.loghandler; import com.fr.base.BaseUtils; -import com.fr.base.ServerConfig; import com.fr.base.FRContext; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.imenu.UIMenuItem; @@ -38,9 +37,9 @@ import java.util.logging.LogRecord; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; public class DesignerLogHandler { - protected static final int INFO_INT = com.fr.third.apache.log4j.Level.INFO.toInt(); - protected static final int ERROR_INT = com.fr.third.apache.log4j.Level.ERROR.toInt(); - protected static final int WARN_INT = com.fr.third.apache.log4j.Level.WARN.toInt(); + protected static final int INFO_INT = Level.INFO.intValue(); + protected static final int ERROR_INT = Level.SEVERE.intValue(); + protected static final int WARN_INT = Level.WARNING.intValue(); private static final int GAP_X = -150; private static final int INFO_GAP_Y = -60; private static final int ERRO_GAP_Y = -40; diff --git a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java index 23393dcb29..ac5a2ab018 100644 --- a/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java +++ b/designer-base/src/com/fr/design/mainframe/loghandler/socketio/DesignerSocketIO.java @@ -10,7 +10,6 @@ import com.fr.design.mainframe.loghandler.DesignerLogHandler; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; -import com.fr.event.Null; import com.fr.general.LogRecordTime; import com.fr.general.LogUtils; import com.fr.log.FineLoggerFactory; @@ -43,18 +42,18 @@ public class DesignerSocketIO { }; static { - EventDispatcher.listen(EnvEvent.AFTER_SIGN_OUT, new Listener() { + EventDispatcher.listen(EnvEvent.AFTER_SIGN_OUT, new Listener() { @Override - public void on(Event event, Null param) { + public void on(Event event, EnvConfig param) { if (socketIO.isPresent()) { socketIO.get().close(); socketIO = Optional.absent(); } } }); - EventDispatcher.listen(EnvEvent.AFTER_SIGN_IN, new Listener() { + EventDispatcher.listen(EnvEvent.AFTER_SIGN_IN, new Listener() { @Override - public void on(Event event, Null param) { + public void on(Event event, EnvConfig param) { updateSocket(); } }); diff --git a/designer-base/src/com/fr/design/mainframe/widget/BasicPropertyPane.java b/designer-base/src/com/fr/design/mainframe/widget/BasicPropertyPane.java index 12b83b3e7d..d69f4c282d 100644 --- a/designer-base/src/com/fr/design/mainframe/widget/BasicPropertyPane.java +++ b/designer-base/src/com/fr/design/mainframe/widget/BasicPropertyPane.java @@ -13,6 +13,10 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; /** * Created by plough on 2017/8/7. @@ -27,7 +31,31 @@ public class BasicPropertyPane extends BasicPane { protected void initContentPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - widgetName = new UITextField(); + widgetName = new UITextField() { + protected void initListener() { + if (shouldResponseChangeListener()) { + addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + + } + + @Override + public void focusLost(FocusEvent e) { + attributeChange(); + } + }); + addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + attributeChange(); + } + } + }); + } + } + }; widgetName.setGlobalName(Inter.getLocText("FR-Designer_Basic")); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; diff --git a/designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java b/designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java index 931793aab2..02a675e7fa 100644 --- a/designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java +++ b/designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleImgBackgroundEditor.java @@ -1,14 +1,15 @@ package com.fr.design.mainframe.widget.accessibles; -import java.awt.Dimension; -import javax.swing.SwingUtilities; import com.fr.base.background.ColorBackground; -import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper; import com.fr.design.style.background.BackgroundButtonPane; import com.fr.general.Background; +import javax.swing.SwingUtilities; +import java.awt.Dimension; + public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor { private BackgroundButtonPane choosePane; @@ -18,7 +19,7 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor { @Override protected void showEditorPane() { - choosePane = new BackgroundButtonPane(); + choosePane = initBackgroundPane(); choosePane.setPreferredSize(new Dimension(600, 400)); BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); dlg.addDialogActionListener(new DialogActionAdapter() { @@ -32,4 +33,9 @@ public class AccessibleImgBackgroundEditor extends UneditableAccessibleEditor { choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); dlg.setVisible(true); } + + protected BackgroundButtonPane initBackgroundPane(){ + return new BackgroundButtonPane(); + } + } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java b/designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java new file mode 100644 index 0000000000..8f7c18cb1e --- /dev/null +++ b/designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabBackgroundEditor.java @@ -0,0 +1,18 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.design.style.background.BackgroundButtonPane; +import com.fr.design.style.background.BackgroundCardSwitchButtonPane; + +/** + * @author kerry + * @date 2018/1/29 + */ +public class AccessibleTabBackgroundEditor extends AccessibleImgBackgroundEditor { + public AccessibleTabBackgroundEditor() { + super(); + } + @Override + protected BackgroundButtonPane initBackgroundPane(){ + return new BackgroundCardSwitchButtonPane(); + } +} diff --git a/designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java b/designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java new file mode 100644 index 0000000000..ee0d7634f7 --- /dev/null +++ b/designer-base/src/com/fr/design/mainframe/widget/accessibles/AccessibleTabPaneBackgroundEditor.java @@ -0,0 +1,40 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.base.background.ColorBackground; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.widget.wrappers.BackgroundWrapper; +import com.fr.design.style.background.BackgroundTabPane; +import com.fr.general.Background; + +import javax.swing.SwingUtilities; +import java.awt.Dimension; + +/** + * @author kerry + * @date 2018/1/17 + */ +public class AccessibleTabPaneBackgroundEditor extends UneditableAccessibleEditor { + private BackgroundTabPane choosePane; + + public AccessibleTabPaneBackgroundEditor() { + super(new BackgroundWrapper()); + } + + @Override + protected void showEditorPane() { + choosePane = new BackgroundTabPane(); + choosePane.setPreferredSize(new Dimension(600, 400)); + BasicDialog dlg = choosePane.showWindow(SwingUtilities.getWindowAncestor(this)); + dlg.addDialogActionListener(new DialogActionAdapter() { + + @Override + public void doOk() { + setValue(choosePane.update()); + fireStateChanged(); + } + }); + choosePane.populate(getValue() instanceof Background ? (Background) getValue() : new ColorBackground()); + dlg.setVisible(true); + } +} \ No newline at end of file diff --git a/designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java b/designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java index 890e5dc5cf..7a0e1bb064 100644 --- a/designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java +++ b/designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePane.java @@ -1,17 +1,17 @@ package com.fr.design.mainframe.widget.accessibles; +import com.fr.design.dialog.BasicPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; import com.fr.general.cardtag.BannerTemplateStyle; import com.fr.general.cardtag.BookMarkTemplateStyle; import com.fr.general.cardtag.CardTemplateStyle; import com.fr.general.cardtag.DefaultTemplateStyle; import com.fr.general.cardtag.MenuTemplateStyle; import com.fr.general.cardtag.PentagonTemplateStyle; -import com.fr.general.cardtag.TrapezoidTemplateStyle; -import com.fr.design.dialog.BasicPane; import com.fr.general.cardtag.TemplateStyle; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.Inter; +import com.fr.general.cardtag.TrapezoidTemplateStyle; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; @@ -41,11 +41,11 @@ public class TemplateStylePane extends BasicPane { listModel = new DefaultListModel(); listModel.addElement(new DefaultTemplateStyle()); listModel.addElement(new CardTemplateStyle()); + listModel.addElement(new BannerTemplateStyle()); listModel.addElement(new BookMarkTemplateStyle()); - listModel.addElement(new PentagonTemplateStyle()); listModel.addElement(new MenuTemplateStyle()); + listModel.addElement(new PentagonTemplateStyle()); listModel.addElement(new TrapezoidTemplateStyle()); - listModel.addElement(new BannerTemplateStyle()); styleList = new JList(listModel); styleList.setCellRenderer(render); diff --git a/designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java b/designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java index 4871bfd1d4..0f684006ae 100644 --- a/designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java +++ b/designer-base/src/com/fr/design/mainframe/widget/accessibles/TemplateStylePreviewPane.java @@ -14,7 +14,8 @@ import java.awt.Image; public class TemplateStylePreviewPane extends JPanel { private static final int WIDTH = 540; - private static final int HEIGHT = 500; + private static final int HEIGHT = 400; + private static final int OFFSETY = 50; private TemplateStyle templateStyle; @@ -32,6 +33,6 @@ public class TemplateStylePreviewPane extends JPanel { super.paint(g); Graphics2D g2d = (Graphics2D) g.create(); Image image = BaseUtils.readImage(templateStyle.getPreview()); - g2d.drawImage(image, 0, 0, WIDTH, HEIGHT, null); + g2d.drawImage(image, 0, OFFSETY, WIDTH, HEIGHT, null); } } diff --git a/designer-base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java b/designer-base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java new file mode 100644 index 0000000000..b5a2aeffad --- /dev/null +++ b/designer-base/src/com/fr/design/style/background/BackgroundCardSwitchButtonPane.java @@ -0,0 +1,95 @@ +package com.fr.design.style.background; + +import com.fr.base.background.ColorBackground; +import com.fr.base.background.GradientBackground; +import com.fr.base.background.ImageBackground; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.gradient.GradientBackgroundPane; +import com.fr.design.style.background.impl.ColorBackgroundPane; +import com.fr.design.style.background.impl.ImageBackgroundPane; +import com.fr.design.style.background.impl.NullBackgroundPane; +import com.fr.general.Background; +import com.fr.general.Inter; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author kerry + * @date 2018/1/29 + */ +public class BackgroundCardSwitchButtonPane extends BackgroundButtonPane { + + private static Map, BackgroundUIWrapper> cardSwitchButton = new LinkedHashMap<>(); + + static { + registerCardSwitchBtnBackground(cardSwitchButton); + } + + + private static void registerCardSwitchBtnBackground(Map, BackgroundUIWrapper> map) { + map.put(ColorBackground.class, BackgroundUIWrapper.create() + .setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color"))); + map.put(ImageBackground.class, BackgroundUIWrapper.create() + .setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image"))); + map.put(GradientBackground.class, BackgroundUIWrapper.create() + .setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Gradient_Color"))); + + } + + public BackgroundCardSwitchButtonPane() { + super(); + } + + @Override + protected void initTabPane() { + int index = 0; + for (Class key : cardSwitchButton.keySet()) { + BackgroundUIWrapper wrapper = cardSwitchButton.get(key); + wrapper.setIndex(index++); + tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + } + } + + @Override + protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) { + return cardSwitchButton.get(background == null ? null : background.getClass()); + } + + + @Override + protected BackgroundDetailPane getTabItemPane(Background background, int index) { + BackgroundDetailPane quickPane = cacheMap.get(index); + if (quickPane == null) { + BackgroundUIWrapper uiWrapper = getBackgroundUIWrapper(background); + quickPane = BackgroundFactory.createByWrapper(uiWrapper); + quickPane.addChangeListener(backgroundChangeListener); + cacheMap.put(index, quickPane); + } + tabbedPane.setComponentAt(index, quickPane); + tabbedPane.setSelectedIndex(index); + return quickPane; + } + + @Override + protected BackgroundDetailPane getTabItemPaneByIndex(int index) { + BackgroundDetailPane quickPane = cacheMap.get(index); + if (quickPane == null) { + quickPane = createDetailPaneByIndex(index); + tabbedPane.setComponentAt(index, quickPane); + cacheMap.put(index, quickPane); + quickPane.addChangeListener(backgroundChangeListener); + } + return quickPane; + } + + public BackgroundDetailPane createDetailPaneByIndex(int index) { + for (BackgroundUIWrapper wrapper : cardSwitchButton.values()) { + if (wrapper.getIndex() == index) { + return BackgroundFactory.createByWrapper(wrapper); + } + } + return new NullBackgroundPane(); + } + +} diff --git a/designer-base/src/com/fr/design/style/background/BackgroundFactory.java b/designer-base/src/com/fr/design/style/background/BackgroundFactory.java index b965e4aeab..8489f7d889 100644 --- a/designer-base/src/com/fr/design/style/background/BackgroundFactory.java +++ b/designer-base/src/com/fr/design/style/background/BackgroundFactory.java @@ -1,13 +1,29 @@ package com.fr.design.style.background; -import com.fr.base.background.*; +import com.fr.base.background.ColorBackground; +import com.fr.base.background.GradientBackground; +import com.fr.base.background.ImageBackground; +import com.fr.base.background.PatternBackground; +import com.fr.base.background.TextureBackground; import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.BackgroundUIProvider; import com.fr.design.style.background.gradient.GradientBackgroundPane; -import com.fr.design.style.background.impl.*; +import com.fr.design.style.background.impl.ColorBackgroundPane; +import com.fr.design.style.background.impl.ImageBackgroundPane; +import com.fr.design.style.background.impl.ImageBackgroundPane4Browser; +import com.fr.design.style.background.impl.ImageButtonBackgroundPane; +import com.fr.design.style.background.impl.NullBackgroundPane; +import com.fr.design.style.background.impl.PatternBackgroundPane; +import com.fr.design.style.background.impl.TextureBackgroundPane; import com.fr.general.Background; +import com.fr.general.GeneralContext; import com.fr.general.Inter; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import com.fr.plugin.observer.PluginEventType; import java.util.LinkedHashMap; import java.util.Map; @@ -29,9 +45,51 @@ public class BackgroundFactory { registerBrowserImageBackground(browser); registerExtra(map); registerExtra(browser); + listenPlugin(); registerButtonBackground(button); } - + + private static void listenPlugin() { + + PluginFilter filter = new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(BackgroundUIProvider.MARK_STRING); + } + }; + GeneralContext.listenPlugin(PluginEventType.BeforeStop, new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + Set set = event.getContext().getRuntime().get(BackgroundUIProvider.MARK_STRING); + for (BackgroundUIProvider provider : set) { + map.remove(provider.targetClass()); + browser.remove(provider.targetClass()); + } + } + }, filter); + GeneralContext.listenPlugin(PluginEventType.AfterRun, new PluginEventListener() { + + @Override + public void on(PluginEvent event) { + + Set set = event.getContext().getRuntime().get(BackgroundUIProvider.MARK_STRING); + Class clazz; + BackgroundUIWrapper wrapper; + for (BackgroundUIProvider provider : set) { + clazz = provider.targetClass(); + wrapper = BackgroundUIWrapper.create().setType(provider.targetUIClass()).setTitle(provider.targetTitle()); + map.put(clazz, wrapper); + browser.put(clazz, wrapper); + } + } + }); + + } + private static void registerUniversal(Map, BackgroundUIWrapper> map) { map.put(null, BackgroundUIWrapper.create() .setType(NullBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Null"))); @@ -46,19 +104,19 @@ public class BackgroundFactory { } private static void registerImageBackground(Map, BackgroundUIWrapper> map) { - map.put(ImageFileBackground.class, BackgroundUIWrapper.create() + map.put(ImageBackground.class, BackgroundUIWrapper.create() .setType(ImageBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image"))); } private static void registerBrowserImageBackground(Map, BackgroundUIWrapper> map) { - map.put(ImageFileBackground.class, BackgroundUIWrapper.create() + map.put(ImageBackground.class, BackgroundUIWrapper.create() .setType(ImageBackgroundPane4Browser.class).setTitle(Inter.getLocText("FR-Designer_Background_Image"))); } - private static void registerButtonBackground(Map, BackgroundUIWrapper> map) { + private static void registerButtonBackground(Map, BackgroundUIWrapper> map){ map.put(ColorBackground.class, BackgroundUIWrapper.create() .setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color"))); - map.put(ImageFileBackground.class, BackgroundUIWrapper.create() + map.put(ImageBackground.class, BackgroundUIWrapper.create() .setType(ImageButtonBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Image"))); } @@ -139,7 +197,7 @@ public class BackgroundFactory { return new NullBackgroundPane(); } - private static BackgroundDetailPane createByWrapper(BackgroundUIWrapper wrapper) { + public static BackgroundDetailPane createByWrapper(BackgroundUIWrapper wrapper) { Class clazz = wrapper.getType(); if (clazz == null) { clazz = NullBackgroundPane.class; diff --git a/designer-base/src/com/fr/design/style/background/BackgroundTabPane.java b/designer-base/src/com/fr/design/style/background/BackgroundTabPane.java new file mode 100644 index 0000000000..6cc71a074e --- /dev/null +++ b/designer-base/src/com/fr/design/style/background/BackgroundTabPane.java @@ -0,0 +1,88 @@ +package com.fr.design.style.background; + +import com.fr.base.background.ColorBackground; +import com.fr.base.background.GradientBackground; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.gradient.GradientBackgroundPane; +import com.fr.design.style.background.impl.ColorBackgroundPane; +import com.fr.design.style.background.impl.NullBackgroundPane; +import com.fr.general.Background; +import com.fr.general.Inter; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * @author kerry + * @date 2018/1/17 + */ +public class BackgroundTabPane extends BackgroundPane { + + private static Map, BackgroundUIWrapper> tabpane = new LinkedHashMap<>(); + + static { + registerTabpaneBackground(tabpane); + } + + + private static void registerTabpaneBackground(Map, BackgroundUIWrapper> map) { + map.put(null, BackgroundUIWrapper.create() + .setType(NullBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Null"))); + map.put(ColorBackground.class, BackgroundUIWrapper.create() + .setType(ColorBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Color"))); + map.put(GradientBackground.class, BackgroundUIWrapper.create() + .setType(GradientBackgroundPane.class).setTitle(Inter.getLocText("FR-Designer_Background_Gradient_Color"))); + + } + + public BackgroundTabPane() { + super(); + } + + protected void initTabPane() { + int index = 0; + for (Class key : tabpane.keySet()) { + BackgroundUIWrapper wrapper = tabpane.get(key); + wrapper.setIndex(index++); + tabbedPane.addTab(Inter.getLocText(wrapper.getTitle()), FRGUIPaneFactory.createY_AXISBoxInnerContainer_L_Pane()); + } + } + + protected BackgroundUIWrapper getBackgroundUIWrapper(Background background) { + return tabpane.get(background == null ? null : background.getClass()); + } + + protected BackgroundDetailPane getTabItemPane(Background background, int index) { + BackgroundDetailPane quickPane = cacheMap.get(index); + if (quickPane == null) { + BackgroundUIWrapper uiWrapper = getBackgroundUIWrapper(background); + quickPane = BackgroundFactory.createByWrapper(uiWrapper); + quickPane.addChangeListener(backgroundChangeListener); + cacheMap.put(index, quickPane); + } + tabbedPane.setComponentAt(index, quickPane); + tabbedPane.setSelectedIndex(index); + return quickPane; + } + + protected BackgroundDetailPane getTabItemPaneByIndex(int index) { + BackgroundDetailPane quickPane = cacheMap.get(index); + if (quickPane == null) { + quickPane = createDetailPaneByIndex(index); + tabbedPane.setComponentAt(index, quickPane); + cacheMap.put(index, quickPane); + quickPane.addChangeListener(backgroundChangeListener); + } + return quickPane; + } + + public BackgroundDetailPane createDetailPaneByIndex(int index) { + for (BackgroundUIWrapper wrapper : tabpane.values()) { + if (wrapper.getIndex() == index) { + return BackgroundFactory.createByWrapper(wrapper); + } + } + return new NullBackgroundPane(); + } + +} diff --git a/designer-base/src/com/fr/design/utils/DesignUtils.java b/designer-base/src/com/fr/design/utils/DesignUtils.java index 1148d64f48..22cf51abab 100644 --- a/designer-base/src/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/com/fr/design/utils/DesignUtils.java @@ -1,15 +1,15 @@ package com.fr.design.utils; import com.fr.base.BaseUtils; -import com.fr.base.Env; import com.fr.base.EnvException; import com.fr.base.FRContext; import com.fr.base.FeedBackInfo; import com.fr.base.ServerConfig; import com.fr.base.Utils; import com.fr.base.remote.RemoteDeziConstants; +import com.fr.core.env.EnvConfig; +import com.fr.core.env.EnvContext; import com.fr.dav.DavXMLUtils; -import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.DesignerEnvProcessor; @@ -29,10 +29,13 @@ import com.fr.stable.CodeUtils; import com.fr.stable.EncodeConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import com.fr.start.StartServer; +import com.fr.start.ServerStarter; -import javax.swing.*; -import java.awt.*; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import java.awt.Desktop; +import java.awt.Font; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; @@ -142,7 +145,7 @@ public class DesignUtils { String line = null; while ((line = reader.readLine()) != null) { if (line.startsWith("demo")) { - StartServer.browserDemoURL(); + ServerStarter.browserDemoURL(); } else if (StringUtils.isNotEmpty(line)) { File f = new File(line); String path = f.getAbsolutePath(); @@ -184,20 +187,16 @@ public class DesignUtils { }); } - /** * 当前的报表运行环境切换到env * * @param env 需要切换去的环境 */ - public static void switchToEnv(Env env) { + public static void switchToEnv(EnvConfig env) { if (env == null) { return; } - Env oldEnv = FRContext.getCurrentEnv(); - String oldEnvPath = oldEnv == null ? null : oldEnv.getPath(); - // 看一下这个env在DesignerEnvManager里面有没有对应的,有的话就setCurrentEnvName DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); java.util.Iterator nameIt = envManager.getEnvNameIterator(); @@ -208,20 +207,11 @@ public class DesignUtils { break; } } - - // 更新CurrentEnv于FRContext & DesignerEnvManager - FRContext.setCurrentEnv(env); - - refreshDesignerFrame(env); - // 当换了运行环境,重置服务器,让它下次预览时重启 - if (env instanceof LocalEnv && !ComparatorUtils.equals(env.getPath(), oldEnvPath)) { - StartServer.currentEnvChanged(); - } + EnvContext.signIn(env); + refreshDesignerFrame(); } - public static void refreshDesignerFrame(Env env) { - - final Env run_env = env; + public static void refreshDesignerFrame() { // 刷新DesignerFrame里面的面板 SwingUtilities.invokeLater(new Runnable() { @@ -230,7 +220,7 @@ public class DesignUtils { if (DesignerContext.getDesignerFrame() == null) { return; } - DesignerContext.getDesignerFrame().refreshEnv(run_env); + DesignerContext.getDesignerFrame().refreshEnv(); DesignerContext.getDesignerFrame().repaint();// kunsnat: 切换环境后 刷新下 报表. 比如图表某些风格改变. } }); @@ -358,10 +348,10 @@ public class DesignUtils { } else { try { String web = GeneralContext.getCurrentAppNameOfEnv(); - String url = "http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + String url = "http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + web + "/" + ServerConfig.getInstance().getServletName() + baseRoute + postfixOfUri; - StartServer.browserURLWithLocalEnv(url); + ServerStarter.browserURLWithLocalEnv(url); } catch (Throwable e) { // } @@ -524,4 +514,4 @@ public class DesignUtils { } -} \ No newline at end of file +} diff --git a/designer-base/src/com/fr/design/utils/gui/GUICoreUtils.java b/designer-base/src/com/fr/design/utils/gui/GUICoreUtils.java index 0aa153544e..69c1e63e90 100644 --- a/designer-base/src/com/fr/design/utils/gui/GUICoreUtils.java +++ b/designer-base/src/com/fr/design/utils/gui/GUICoreUtils.java @@ -12,6 +12,7 @@ import com.fr.design.actions.core.ActionFactory; import com.fr.design.border.UITitledBorder; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.EditTextField; @@ -37,6 +38,7 @@ import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; @@ -844,4 +846,49 @@ public abstract class GUICoreUtils{ && oneRect.getWidth() == otherRect.getWidth() && oneRect.getHeight() == otherRect.getHeight(); } + + /** + * 生成提示标签 + * @param tipText 提示文字 + * @return UILabel 标签对象 + */ + public static UILabel createTipLabel(String tipText) { + UILabel tipLabel = new UILabel("" + tipText + ""); + tipLabel.setForeground(Color.gray); + return tipLabel; + } + + /** + * 生成没有边框的 UICheckBox + * @param text 说明文字 + * @return UICheckBox + */ + public static UICheckBox createNoBorderCheckBox(String text) { + UICheckBox checkBox = new UICheckBox(text); + checkBox.setBorder(BorderFactory.createEmptyBorder()); + return checkBox; + } + + /** + * 创建包含选择框和一个动态面板的联动面板。根据选择框的状态,动态面板会动态地显示或隐藏 + * @param checkBox 选择框 + * @param dynamicPane 包含任意内容的动态面板 + * @param hideOnSelected 选中时隐藏动态面板(若为false,则在"去掉勾选"时隐藏动态面板) + * @return 联动面板 + */ + public static JPanel createCheckboxAndDynamicPane(UICheckBox checkBox, final JPanel dynamicPane, final boolean hideOnSelected) { + checkBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + int visibleState = hideOnSelected ? ItemEvent.DESELECTED : ItemEvent.SELECTED; + dynamicPane.setVisible(e.getStateChange() == visibleState); + } + }); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.add(checkBox, BorderLayout.NORTH); + JPanel dynamicPaneWrapper = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + dynamicPaneWrapper.add(dynamicPane); + panel.add(dynamicPaneWrapper, BorderLayout.CENTER); + return panel; + } } \ No newline at end of file diff --git a/designer-base/src/com/fr/design/widget/component/BackgroundCompPane.java b/designer-base/src/com/fr/design/widget/component/BackgroundCompPane.java index 098d96b742..77c42ceadc 100644 --- a/designer-base/src/com/fr/design/widget/component/BackgroundCompPane.java +++ b/designer-base/src/com/fr/design/widget/component/BackgroundCompPane.java @@ -11,8 +11,10 @@ import com.fr.design.mainframe.widget.accessibles.AccessibleImgBackgroundEditor; import com.fr.form.ui.Widget; import com.fr.general.Inter; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; /** * Created by ibm on 2017/8/6. @@ -31,9 +33,7 @@ public abstract class BackgroundCompPane extends BasicPane { public void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); UILabel headLabel = createUILable(); - initialBackgroundEditor = new AccessibleImgBackgroundEditor(); - overBackgroundEditor = new AccessibleImgBackgroundEditor(); - clickBackgroundEditor = new AccessibleImgBackgroundEditor(); + initBackgroundEditor(); String [] titles = new String[]{Inter.getLocText("FR-Designer_DEFAULT"), Inter.getLocText("FR-Designer_Custom")}; double f = TableLayout.FILL; @@ -44,9 +44,9 @@ public abstract class BackgroundCompPane extends BasicPane { Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Initial")), initialBackgroundEditor}, new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Over")), overBackgroundEditor}, - new Component[]{new UILabel(Inter.getLocText("FR-Designer_Background-Click")), clickBackgroundEditor}, + new Component[]{getClickLabel(), clickBackgroundEditor}, }; - panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W0, IntervalConstants.INTERVAL_L1); + panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); panel.setBorder(BorderFactory.createEmptyBorder(IntervalConstants.INTERVAL_L6, IntervalConstants.INTERVAL_L5, 0, 0)); backgroundHead = new UIButtonGroup(titles); JPanel headPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ @@ -57,6 +57,16 @@ public abstract class BackgroundCompPane extends BasicPane { } + protected void initBackgroundEditor(){ + initialBackgroundEditor = new AccessibleImgBackgroundEditor(); + overBackgroundEditor = new AccessibleImgBackgroundEditor(); + clickBackgroundEditor = new AccessibleImgBackgroundEditor(); + } + + protected UILabel getClickLabel(){ + return new UILabel(Inter.getLocText("FR-Designer_Background-Click")); + } + protected UILabel createUILable(){ return new UILabel(Inter.getLocText("FR-Designer_Background")); } diff --git a/designer-base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java b/designer-base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java index e9f1d1d2b3..0c5101cf40 100644 --- a/designer-base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java +++ b/designer-base/src/com/fr/design/widget/component/UIComboBoxNoArrow.java @@ -9,9 +9,10 @@ import com.fr.stable.StringUtils; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.basic.BasicComboBoxUI; -import java.awt.*; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; +import java.awt.Dimension; +import java.awt.Insets; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; /** * Created by kerry on 2017/9/14. @@ -66,14 +67,29 @@ public class UIComboBoxNoArrow extends UIComboBox { super(); this.comboBox = comboBox; textField.getDocument().addDocumentListener(this); - textField.addFocusListener(new FocusListener() { + textField.addMouseListener(new MouseListener() { @Override - public void focusGained(FocusEvent e) { + public void mouseClicked(MouseEvent e) { changeHandler(); } @Override - public void focusLost(FocusEvent e) { + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { } }); diff --git a/designer-base/src/com/fr/env/RemoteEnv.java b/designer-base/src/com/fr/env/RemoteEnv.java index 8e17a4e22b..3bbb181048 100644 --- a/designer-base/src/com/fr/env/RemoteEnv.java +++ b/designer-base/src/com/fr/env/RemoteEnv.java @@ -2,7 +2,10 @@ package com.fr.env; import com.fr.base.EnvException; import com.fr.base.TableData; +import com.fr.base.operator.file.FileOperator; import com.fr.base.remote.RemoteDeziConstants; +import com.fr.common.rpc.netty.MessageSendExecutor; +import com.fr.common.rpc.serialize.RpcSerializeProtocol; import com.fr.core.env.EnvConstants; import com.fr.core.env.EnvContext; import com.fr.core.env.resource.RemoteEnvConfig; @@ -41,6 +44,7 @@ import com.fr.stable.SvgProvider; import com.fr.stable.file.XMLFileManagerProvider; import com.fr.stable.project.ProjectConstants; import com.fr.stable.xml.XMLTools; +import com.fr.third.guava.base.Strings; import com.fr.third.guava.collect.ImmutableMap; import com.fr.web.ResourceConstants; @@ -75,6 +79,7 @@ import static com.fr.third.guava.base.Preconditions.checkArgument; * @author null */ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurable { + private static final String CERT_KEY = "javax.net.ssl.trustStore"; private static final String PWD_KEY = "javax.net.ssl.trustStorePassword"; private static final String HTTPS_PREFIX = "https:"; @@ -87,6 +92,23 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl env = new RemoteEnvConfig(path, userName, password); } + @Override + public void connect() { + // FIXME:richie ip地址属于测试的,带实际修改为RemoteEnv配置的地址 + MessageSendExecutor.getInstance().setRpcServerLoader("127.0.0.1:" + 33999, RpcSerializeProtocol.KRYOSERIALIZE); + } + + @Override + public boolean disconnect() { + MessageSendExecutor.getInstance().stop(); + return true; + } + + @Override + public FileOperator getFileOperator() throws Exception { + return MessageSendExecutor.getInstance().execute(FileOperator.class); + } + @Override public String getPath() { return env.getPath(); @@ -138,7 +160,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl } - /** * nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的 * @@ -214,7 +235,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl EnvConstants.USERNAME, getUser(), EnvConstants.PWD, getPassword()); String res = HttpToolbox.post(url, params, headers); - if (res == null) { + if (Strings.isNullOrEmpty(res)) { if (needMessage) { JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed")); } @@ -237,7 +258,7 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl return false; } else { if (needMessage) { - JOptionPane.showMessageDialog(component, Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); + JOptionPane.showMessageDialog(component, Inter.getLocText("Datasource-Connection_failed")); } else { FineLoggerFactory.getLogger().info(Inter.getLocText(new String[]{"Datasource-Connection_failed", "Version-does-not-support"}, new String[]{",", "!"})); } @@ -818,7 +839,6 @@ public class RemoteEnv extends AbstractEnv implements DesignAuthorityConfigurabl } - /** * 获取当前env的build文件路径 */ diff --git a/designer-base/src/com/fr/env/SignIn.java b/designer-base/src/com/fr/env/SignIn.java index 1e31677945..902acdaf19 100644 --- a/designer-base/src/com/fr/env/SignIn.java +++ b/designer-base/src/com/fr/env/SignIn.java @@ -1,13 +1,10 @@ package com.fr.env; -import com.fr.base.FRContext; import com.fr.core.env.EnvConfig; import com.fr.core.env.EnvContext; import com.fr.core.env.EnvEvent; -import com.fr.core.env.resource.EnvConfigUtils; -import com.fr.core.env.resource.RemoteEnvConfig; -import com.fr.dav.LocalEnv; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.DesignUtils; import com.fr.event.Event; import com.fr.event.EventDispatcher; @@ -16,8 +13,7 @@ import com.fr.event.Null; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; -import javax.swing.JOptionPane; -import javax.swing.UIManager; +import javax.swing.*; public class SignIn { @@ -26,36 +22,22 @@ public class SignIn { EventDispatcher.listen(EnvEvent.CONNECTION_ERROR, new Listener() { @Override public void on(Event event, Null param) { - if (JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Remote_Connect2Server_Again"), UIManager.getString("OptionPane.titleText"), JOptionPane.YES_NO_OPTION) - == JOptionPane.OK_OPTION) { - try { - EnvContext.signIn(EnvContext.currentEnv()); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage()); - } - } + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Datasource-Connection_failed")); } }); } /** * 注册入环境 + * * @param selectedEnv 选择的环境 * @throws Exception 异常 */ public static void signIn(EnvConfig selectedEnv) throws Exception { + if (EnvContext.currentEnv() != null && !ComparatorUtils.equals(EnvContext.currentEnv(), selectedEnv)) { EnvContext.signOut(); } - EnvContext.signIn(selectedEnv); - DesignUtils.switchToEnv(trans(selectedEnv)); - } - - private static com.fr.base.Env trans(EnvConfig env) { - if (env instanceof RemoteEnvConfig) { - return new RemoteEnv(env.getPath(), EnvConfigUtils.getUsername(env), EnvConfigUtils.getPassword(env)); - } else { - return new LocalEnv(); - } + DesignUtils.switchToEnv(selectedEnv); } } \ No newline at end of file diff --git a/designer-base/src/com/fr/start/BBSGuestPaneProvider.java b/designer-base/src/com/fr/start/BBSGuestPaneProvider.java index eb094ca710..cc664b1cab 100644 --- a/designer-base/src/com/fr/start/BBSGuestPaneProvider.java +++ b/designer-base/src/com/fr/start/BBSGuestPaneProvider.java @@ -10,6 +10,6 @@ package com.fr.start; */ public interface BBSGuestPaneProvider { - public static final String XML_TAG = "BBSGuestPane"; + String XML_TAG = "BBSGuestPane"; } \ No newline at end of file diff --git a/designer-base/src/com/fr/start/BaseDesigner.java b/designer-base/src/com/fr/start/BaseDesigner.java index 5d723f5793..2a5f0af50a 100644 --- a/designer-base/src/com/fr/start/BaseDesigner.java +++ b/designer-base/src/com/fr/start/BaseDesigner.java @@ -13,11 +13,14 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.utils.DesignUtils; +import com.fr.event.EventDispatcher; import com.fr.file.FILE; import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; +import com.fr.module.ModuleEvent; import com.fr.stable.OperatingSystem; import java.awt.*; @@ -39,7 +42,8 @@ public abstract class BaseDesigner extends ToolBarMenuDock { } private void init(String[] args) { - + //初始化 + EventDispatcher.fire(ModuleEvent.MajorModuleStarting, InterProviderFactory.getProvider().getLocText("FR-Designer_Initializing")); // 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到 DesignUtils.initLookAndFeel(); @@ -93,6 +97,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { + DesignerEnvManager.getEnvManager().getLastOpenFile()); } isException = openFile(df, isException, file); + df.fireDesignerOpened(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); if (!isException) { diff --git a/designer-base/src/com/fr/start/StartServer.java b/designer-base/src/com/fr/start/ServerStarter.java similarity index 59% rename from designer-base/src/com/fr/start/StartServer.java rename to designer-base/src/com/fr/start/ServerStarter.java index 7ab65e5490..880a33774c 100644 --- a/designer-base/src/com/fr/start/StartServer.java +++ b/designer-base/src/com/fr/start/ServerStarter.java @@ -16,57 +16,43 @@ import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; import com.fr.log.FineLoggerFactory; -import com.fr.stable.EnvChangedListener; import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import com.fr.start.server.TomcatHost; +import com.fr.start.server.FineEmbedServer; -import javax.swing.BorderFactory; -import javax.swing.JOptionPane; -import java.awt.BorderLayout; -import java.awt.Desktop; -import java.awt.Font; +import javax.swing.*; +import java.awt.*; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -public class StartServer { - public static boolean NEED_LOAD_ENV = true; - // 原先的tomcatHost放在类TomcatHost里面,很不方便操作,而且因为存在多个进程的原因, - // 原先的getInstance()方法无多大意义 - private static TomcatHost tomcatHost = null; - private static Object lock = new Object(); - - static { - GeneralContext.addEnvChangedListener(new EnvChangedListener() { - public void envChanged() { - currentEnvChanged(); - } - }); - } - +public class ServerStarter { + /** * 预览Demo * 找默认工作目录,不应该按照名字去找,而应该按照安装路径,因为默认工作目录的名字可能会改变。 */ public static void browserDemoURL() { + if (FRContext.getCurrentEnv() instanceof RemoteEnv) { browser(FRContext.getCurrentEnv().getPath()); return; } if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 String web = GeneralContext.getCurrentAppNameOfEnv(); - browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ServerConfig.getInstance().getServletName()); + browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + web + "/" + ServerConfig.getInstance().getServletName()); return; } DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); if (!envManager.isCurrentEnvDefault()) { InformationPane inf = new InformationPane(envManager.getDefaultEnvName()); inf.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override public void doOk() { + try { SignIn.signIn(DesignerEnvManager.getEnvManager().getDefaultEnv()); TemplateTreePane.getInstance().refreshDockingView(); @@ -76,99 +62,43 @@ public class StartServer { } initDemoServerAndBrowser(); } - + }).setVisible(true); } else { initDemoServerAndBrowser(); } } - + private static void initDemoServerAndBrowser() { - synchronized (lock) { - if (tomcatHost != null) { - if (!tomcatHost.isDemoAppLoaded()) { - tomcatHost.exit(); - tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); - tomcatHost.addAndStartInstallHomeWebApp(); - } - } else { - tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); - tomcatHost.addAndStartInstallHomeWebApp(); - } - } + try { - if (!tomcatHost.isStarted()) { - tomcatHost.start(); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FineEmbedServer.getInstance().start(); } finally { //先访问Demo, 后访问报表, 不需要重置服务器. - NEED_LOAD_ENV = false; - browser("http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + GeneralContext.getCurrentAppNameOfEnv() + "/" + ServerConfig.getInstance().getServletName()); - } - } - - public static void start() { - try { - synchronized (lock) { - if (tomcatHost != null) { - if (NEED_LOAD_ENV) { - tomcatHost.exit(); - tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); - tomcatHost.addAndStartLocalEnvHomeWebApp(); - - } - } else { - tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); - tomcatHost.addAndStartLocalEnvHomeWebApp(); - - } - if (!tomcatHost.isStarted()) { - tomcatHost.start(); - } - } - } catch (InterruptedException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } finally { - NEED_LOAD_ENV = false; + browser("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + GeneralContext.getCurrentAppNameOfEnv() + "/" + ServerConfig.getInstance().getServletName()); } } - + /** * 本地环境浏览url * * @param url 指定路径 */ public static void browserURLWithLocalEnv(String url) { - start(); + + FineEmbedServer.getInstance().start(); browser(url); } - - public static TomcatHost getInstance() { - // august: 正确的逻辑能保证jettyHost不为null,不然就有bug,不允许这儿加是否等于null判断 - return tomcatHost; - } - - /** - * 运行环境改变事件 - */ - public static void currentEnvChanged() { - if (!NEED_LOAD_ENV) { - NEED_LOAD_ENV = true; - } - } - + private static void browser(String uri) { + if (StringUtils.isEmpty(uri)) { FRContext.getLogger().info("The URL is empty!"); return; } try { Desktop.getDesktop().browse(new URI(uri)); - + } catch (IOException e) { startBrowserFromCommand(uri, e); } catch (URISyntaxException e) { @@ -178,8 +108,9 @@ public class StartServer { FineLoggerFactory.getLogger().error("Can not open the browser for URL: " + uri); } } - + private static void startBrowserFromCommand(String uri, IOException e) { + if (OperatingSystem.isWindows()) { try { // win10 内存用到到80%左右的时候, Desktop.browser经常提示"存储空间不足, 无法处理改命令", 用rundll32可以打开. @@ -192,30 +123,40 @@ public class StartServer { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } - + + public static boolean isStarted() { + + return FineEmbedServer.getInstance().isRunning(); + } + private static class InformationPane extends BasicPane { + private static final long serialVersionUID = 1L; + private static final int FREE_STYLE_TOP = 15; + private static final int FREE_STYLE_OTHER = 5; - - public InformationPane(String message) { + + InformationPane(String message) { + init(message); } - + private void init(String message) { + this.setLayout(new BorderLayout(10, 10)); this.setBorder(BorderFactory.createEmptyBorder(FREE_STYLE_TOP, FREE_STYLE_OTHER, FREE_STYLE_OTHER, FREE_STYLE_OTHER)); String text; if (!ComparatorUtils.equals(message, Inter.getLocText(new String[]{"Default", "Utils-Report_Runtime_Env"}))) { - text = new StringBuffer(Inter.getLocText("FR-Designer_Open")) - .append(ProductConstants.APP_NAME) - .append(Inter.getLocText("FR-Designer_Utils-OpenDemoEnv")) - .append(message).append(Inter.getLocText("FR-Designer_Utils-switch")).toString(); + text = Inter.getLocText("FR-Designer_Open") + + ProductConstants.APP_NAME + + Inter.getLocText("FR-Designer_Utils-OpenDemoEnv") + + message + Inter.getLocText("FR-Designer_Utils-switch"); } else { - text = new StringBuffer(Inter.getLocText("FR-Designer_Open")) - .append(ProductConstants.APP_NAME) - .append(Inter.getLocText("FR-Designer_Utils-NewDemoEnv")) - .append(message).append(Inter.getLocText("FR-Designer_Utils-switch")).toString(); + text = Inter.getLocText("FR-Designer_Open") + + ProductConstants.APP_NAME + + Inter.getLocText("FR-Designer_Utils-NewDemoEnv") + + message + Inter.getLocText("FR-Designer_Utils-switch"); } UITextArea a = new UITextArea(text); a.setFont(new Font("Dialog", Font.PLAIN, 12)); @@ -224,12 +165,13 @@ public class StartServer { a.setLineWrap(true); this.add(a); } - + @Override protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Tooltips"); } - + } - + } \ No newline at end of file diff --git a/designer-base/src/com/fr/start/SplashStrategy.java b/designer-base/src/com/fr/start/SplashStrategy.java new file mode 100644 index 0000000000..8f7673d5c9 --- /dev/null +++ b/designer-base/src/com/fr/start/SplashStrategy.java @@ -0,0 +1,34 @@ +package com.fr.start; + +/** + * 启动动画策略接口 + * + * @author vito + * @date 2018/6/1 + */ +public interface SplashStrategy { + + /** + * 显示启动动画窗口 + */ + void show(); + + /** + * 隐藏启动动画窗口 + */ + void hide(); + + /** + * 设置模块加载信息 + * + * @param text 更新的文字 + */ + void updateModuleLog(String text); + + /** + * 设置感谢文字 + * + * @param text 更新的文字 + */ + void updateThanksLog(String text); +} diff --git a/designer-base/src/com/fr/start/TomcatFRHost.java b/designer-base/src/com/fr/start/TomcatFRHost.java deleted file mode 100644 index 585564b902..0000000000 --- a/designer-base/src/com/fr/start/TomcatFRHost.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.fr.start; - -import java.io.File; -import javax.servlet.ServletException; -import org.apache.catalina.Context; -import org.apache.catalina.LifecycleException; -import org.apache.catalina.core.AprLifecycleListener; -import org.apache.catalina.core.StandardServer; -import org.apache.catalina.startup.Tomcat; - -public class TomcatFRHost { - private static Tomcat tomcat; - - public static Tomcat getTomcat() { - return tomcat; - } - - private static StandardServer server; - - private static AprLifecycleListener listener; - - public static void main(String[] args) throws Exception { - tomcat = new Tomcat(); - // 主机名,或ip -// tomcat.setHostname("localhost"); - // 设置端口,80为默认端口 - tomcat.setPort(8071); - // tomcat用于存储自身的信息,可以随意指定,最好包含在项目目录下 - tomcat.setBaseDir("."); - // 建立server参照tomcat文件结构 - server = (StandardServer) tomcat.getServer(); - listener = new AprLifecycleListener(); - server.addLifecycleListener(listener); - // 将appBase设为本项目所在目录 - //tomcat.getHost().setAppBase("."); - tomcat.getHost().setAppBase( - System.getProperty("user.dir") + File.separator + "."); - - // 第二个参数对应docBase为web应用路径,目录下应有WEB-INF,WEB-INF下要有web.xml - // 启动tomcat - try { - tomcat.start(); - Context ct1 = tomcat.addWebapp("/WebReport", "/Users/momeak/Documents/Working/develop/others/tomcatsrc/WebReport"); - } catch (LifecycleException e) { - e.printStackTrace(); - } catch (ServletException e) { - e.printStackTrace(); - } -// Context ct1 = tomcat.addWebapp("/examples", "/Users/momeak/Documents/Working/develop/others/tomcatsrc/examples"); - -// Context ct = tomcat.addWebapp("", "/Users/momeak/Documents/Working/develop/others/tomcatsrc/webapps/ROOT"); - -// tomcat.getServer().await(); - System.out.println("启动成功"); - } -} diff --git a/designer-base/src/com/fr/start/server/EmbedServerEvent.java b/designer-base/src/com/fr/start/server/EmbedServerEvent.java new file mode 100644 index 0000000000..ced7432179 --- /dev/null +++ b/designer-base/src/com/fr/start/server/EmbedServerEvent.java @@ -0,0 +1,15 @@ +package com.fr.start.server; + +import com.fr.event.Event; +import com.fr.event.Null; + +/** + * Created by juhaoyu on 2018/6/5. + * 内置服务器事件 + */ +public enum EmbedServerEvent implements Event { + BeforeStart, + AfterStart, + BeforeStop, + AfterStop +} diff --git a/designer-base/src/com/fr/start/server/FRTomcat.java b/designer-base/src/com/fr/start/server/FRTomcat.java deleted file mode 100644 index 46c5296977..0000000000 --- a/designer-base/src/com/fr/start/server/FRTomcat.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.fr.start.server; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.servlet.ServletException; -import org.apache.catalina.Context; -import org.apache.catalina.Host; -import org.apache.catalina.core.ContainerBase; -import org.apache.catalina.core.StandardContext; -import org.apache.catalina.core.StandardHost; -import org.apache.catalina.startup.ContextConfig; -import org.apache.catalina.startup.Tomcat; - -public class FRTomcat extends Tomcat{ - - private final Map frpinnedLoggers = new HashMap(); - private boolean frsilent = false; - - - public Context addWebapp(String contextPath, String docBase) throws ServletException { - silence(host, contextPath); - - Context ctx = createContext(host, contextPath); - if (ctx instanceof StandardContext) { - ((StandardContext)ctx).setDelegate(true); - } - ctx.setPath(contextPath); - ctx.setDocBase(docBase); - - ctx.addLifecycleListener(new DefaultWebXmlListener()); - ctx.setConfigFile(getWebappConfigFile(docBase, contextPath)); - - ContextConfig ctxCfg = new ContextConfig(); - ctx.addLifecycleListener(ctxCfg); - - ctxCfg.setDefaultWebXml(noDefaultWebXmlPath()); - - if (host == null) { - getHost().addChild(ctx); - } else { - host.addChild(ctx); - } - - return ctx; - } - - private void silence(Host host, String contextPath) { - String loggerName = getLoggerName(host, contextPath); - Logger logger = Logger.getLogger(loggerName); - frpinnedLoggers.put(loggerName, logger); - if (frsilent) { - logger.setLevel(Level.WARNING); - } else { - logger.setLevel(Level.INFO); - } - } - - private String getLoggerName(Host host, String contextName) { - if (host == null) { - host = getHost(); - } - StringBuilder loggerName = new StringBuilder(); - loggerName.append(ContainerBase.class.getName()); - loggerName.append(".["); - // Engine name - loggerName.append(host.getParent().getName()); - loggerName.append("].["); - // Host name - loggerName.append(host.getName()); - loggerName.append("].["); - // Context name - if (contextName == null || contextName.equals("")) { - loggerName.append("/"); - } else if (contextName.startsWith("##")) { - loggerName.append("/"); - loggerName.append(contextName); - } - loggerName.append(']'); - - return loggerName.toString(); - } - - private Context createContext(Host host, String url) { - String contextClass = StandardContext.class.getName(); - if (host == null) { - host = this.getHost(); - } - if (host instanceof StandardHost) { - contextClass = ((StandardHost) host).getContextClass(); - } - try { - return (Context) Class.forName(contextClass).getConstructor() - .newInstance(); - } catch (InstantiationException e) { - throw new IllegalArgumentException( - "Can't instantiate context-class " + contextClass - + " for host " + host + " and url " - + url, e); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException( - "Can't instantiate context-class " + contextClass - + " for host " + host + " and url " - + url, e); - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException( - "Can't instantiate context-class " + contextClass - + " for host " + host + " and url " - + url, e); - } catch (InvocationTargetException e) { - throw new IllegalArgumentException( - "Can't instantiate context-class " + contextClass - + " for host " + host + " and url " - + url, e); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException( - "Can't instantiate context-class " + contextClass - + " for host " + host + " and url " - + url, e); - } catch (SecurityException e) { - throw new IllegalArgumentException( - "Can't instantiate context-class " + contextClass - + " for host " + host + " and url " - + url, e); - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException( - "Can't instantiate context-class " + contextClass - + " for host " + host + " and url " - + url, e); - } - } -} diff --git a/designer-base/src/com/fr/start/server/FineEmbedServer.java b/designer-base/src/com/fr/start/server/FineEmbedServer.java new file mode 100644 index 0000000000..96e07f166b --- /dev/null +++ b/designer-base/src/com/fr/start/server/FineEmbedServer.java @@ -0,0 +1,134 @@ +package com.fr.start.server; + +import com.fr.base.FRContext; +import com.fr.design.DesignerEnvManager; +import com.fr.event.EventDispatcher; +import com.fr.log.FineLoggerFactory; +import com.fr.module.ModuleRole; +import com.fr.startup.FineWebApplicationInitializer; +import com.fr.third.springframework.web.SpringServletContainerInitializer; +import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.apache.catalina.Context; +import org.apache.catalina.LifecycleException; +import org.apache.catalina.loader.VirtualWebappLoader; +import org.apache.catalina.startup.Tomcat; + +import java.io.File; +import java.util.HashSet; +import java.util.Set; + +/** + * Created by juhaoyu on 2018/6/5. + */ +public class FineEmbedServer { + + private static final FineEmbedServer INSTANCE = new FineEmbedServer(); + + private Tomcat tomcat; + + private volatile boolean isRunning = false; + + public static FineEmbedServer getInstance() { + + return INSTANCE; + } + + private FineEmbedServer() {} + + + public synchronized void start() { + + if (isRunning) { + return; + } + EventDispatcher.fire(EmbedServerEvent.BeforeStart); + try { + //初始化tomcat + initTomcat(); + tomcat.start(); + } catch (LifecycleException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + isRunning = true; + EventDispatcher.fire(EmbedServerEvent.AfterStart); + } + + public synchronized void stop() { + + if (!isRunning) { + return; + } + EventDispatcher.fire(EmbedServerEvent.BeforeStop); + try { + stopSpring(); + stopServerActivator(); + stopTomcat(); + } catch (LifecycleException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + isRunning = false; + EventDispatcher.fire(EmbedServerEvent.AfterStop); + } + + public boolean isRunning() { + + return isRunning; + } + + + private void initTomcat() { + + tomcat = new Tomcat(); + + tomcat.setPort(DesignerEnvManager.getEnvManager().getEmbedServerPort()); + String docBase = new File(FRContext.getCurrentEnv().getPath()).getParent(); + String appName = "/" + FRContext.getCurrentEnv().getAppName(); + Context context = tomcat.addContext(appName, docBase); + tomcat.addServlet(appName, "default", "org.apache.catalina.servlets.DefaultServlet"); + //覆盖tomcat的WebAppClassLoader + context.setLoader(new FRTomcatLoader()); + + //直接指定initializer,tomcat就不用再扫描一遍了 + SpringServletContainerInitializer initializer = new SpringServletContainerInitializer(); + Set> classes = new HashSet>(); + classes.add(FineWebApplicationInitializer.class); + context.addServletContainerInitializer(initializer, classes); + } + + + private void stopServerActivator() { + + ModuleRole.ServerRoot.stop(); + } + + private void stopSpring() { + + AnnotationConfigWebApplicationContext context = ModuleRole.ServerRoot.getSingleton(AnnotationConfigWebApplicationContext.class); + if (context != null) { + context.stop(); + context.destroy(); + } + } + + private void stopTomcat() throws LifecycleException { + + tomcat.stop(); + tomcat.destroy(); + } + + + /** + * Created by juhaoyu on 2018/6/5. + * 自定义的tomcat loader,主要用于防止内置服务器再加载一遍class + */ + private static class FRTomcatLoader extends VirtualWebappLoader { + + @Override + public ClassLoader getClassLoader() { + + return this.getClass().getClassLoader(); + } + + } + +} diff --git a/designer-base/src/com/fr/start/server/MultiOutputStream.java b/designer-base/src/com/fr/start/server/MultiOutputStream.java deleted file mode 100644 index 08580f2ef9..0000000000 --- a/designer-base/src/com/fr/start/server/MultiOutputStream.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.fr.start.server; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; - -/** - * p: 这是为了将一个OutputStream输出多个OutputStream - */ -public class MultiOutputStream extends OutputStream { - private List outList = new ArrayList(); - - public MultiOutputStream() { - } - - public void addOutputStream(OutputStream output) { - this.outList.add(output); - } - - public void removeOutputStream(OutputStream output) { - this.outList.remove(output); - } - - public int getOutputStreamCount() { - return this.outList.size(); - } - - public OutputStream getOutputStream(int index) { - return (OutputStream) this.outList.get(index); - } - - public void write(int b) throws IOException { - for(int i = 0; i < outList.size(); i++) { - ((OutputStream)outList.get(i)).write(b); - } - } - - public void write(byte buff[]) throws IOException { - for(int i = 0; i < outList.size(); i++) { - ((OutputStream)outList.get(i)).write(buff); - } - } - - public void write(byte buff[], int off, int len) throws IOException { - for(int i = 0; i < outList.size(); i++) { - ((OutputStream)outList.get(i)).write(buff, off, len); - } - } - - public void flush() throws IOException { - for(int i = 0; i < outList.size(); i++) { - ((OutputStream)outList.get(i)).flush(); - } - } - - public void close() throws IOException { - for(int i = 0; i < outList.size(); i++) { - ((OutputStream)outList.get(i)).close(); - } - } -} \ No newline at end of file diff --git a/designer-base/src/com/fr/start/server/ServerManageFrame.java b/designer-base/src/com/fr/start/server/ServerManageFrame.java index 02d60b5f47..4f05cdeaff 100644 --- a/designer-base/src/com/fr/start/server/ServerManageFrame.java +++ b/designer-base/src/com/fr/start/server/ServerManageFrame.java @@ -1,27 +1,20 @@ package com.fr.start.server; -import java.awt.BorderLayout; -import java.awt.Desktop; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JFrame; - -import com.fr.base.FRContext; -import com.fr.design.gui.ilable.UILabel; -import javax.swing.JPanel; -import javax.swing.SwingConstants; - import com.fr.base.BaseUtils; +import com.fr.base.FRContext; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.Inter; -import com.fr.start.StartServer; import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.start.ServerStarter; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * 内置Tomcat服务器管理界面 @@ -29,11 +22,11 @@ import com.fr.design.utils.gui.GUICoreUtils; public class ServerManageFrame extends JFrame { // 由于实际情况,只需要一个当前对象的Instance. private static ServerManageFrame serverManageFrame = null; - private TomcatHost hostTomcatServer; - public static ServerManageFrame getServerManageFrame(TomcatHost hostTomcatServer) { - if(serverManageFrame == null) { - serverManageFrame = new ServerManageFrame(hostTomcatServer); + static ServerManageFrame getServerManageFrame() { + + if (serverManageFrame == null) { + serverManageFrame = new ServerManageFrame(); } //p:每次启动之前都需要检查按钮的Enabled属性. @@ -49,8 +42,7 @@ public class ServerManageFrame extends JFrame { private JPanel startPane; private JPanel stopPane; - private ServerManageFrame(TomcatHost hostTomcatServer) { - this.hostTomcatServer = hostTomcatServer; + private ServerManageFrame() { DesignUtils.initLookAndFeel(); this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/trayStarted.png")); @@ -82,12 +74,8 @@ public class ServerManageFrame extends JFrame { startPane.add(new UILabel(Inter.getLocText("Server-Start"))); startButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - TomcatHost tomcatServer = StartServer.getInstance(); try { - if(!tomcatServer.isStarted()) { - tomcatServer.start(); - tomcatServer.addAndStartLocalEnvHomeWebApp(); - } + FineEmbedServer.getInstance().start(); checkButtonEnabled(); } catch(Exception exp) { FRContext.getLogger().error(exp.getMessage()); @@ -103,11 +91,8 @@ public class ServerManageFrame extends JFrame { stopPane.add(new UILabel(Inter.getLocText("Server-Stop"))); stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - TomcatHost tomcatServer = StartServer.getInstance(); try { - if(tomcatServer.isStarted()) { - tomcatServer.stop(); - } + FineEmbedServer.getInstance().stop(); checkButtonEnabled(); } catch(Exception exp) { FRContext.getLogger().error(exp.getMessage()); @@ -125,24 +110,21 @@ public class ServerManageFrame extends JFrame { infoPane.add(logPathTextField, BorderLayout.CENTER); logPathTextField.setEditable(false); - // logfile - logPathTextField.setText(hostTomcatServer.getOutLogFile().getPath()); - UIButton openButton = new UIButton(); infoPane.add(openButton, BorderLayout.EAST); openButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/server/view.png")); openButton.setToolTipText(Inter.getLocText("Open")); - openButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - - Desktop desktop = Desktop.getDesktop(); - try { - desktop.open(ServerManageFrame.this.hostTomcatServer.getOutLogFile()); - } catch(Exception exp) { - FRContext.getLogger().error(exp.getMessage()); - } - } - }); +// openButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent evt) { +// +// Desktop desktop = Desktop.getDesktop(); +// try { +// desktop.open(); +// } catch(Exception exp) { +// FRContext.getLogger().error(exp.getMessage()); +// } +// } +// }); this.setSize(420, 160); this.setTitle(Inter.getLocText("Server-Embedded_Server")); @@ -154,8 +136,8 @@ public class ServerManageFrame extends JFrame { * @throws Exception 异常 */ public void checkButtonEnabled() throws Exception { - TomcatHost tomcatServer = StartServer.getInstance(); - if(tomcatServer.isStarted()) { + + if (ServerStarter.isStarted()) { GUICoreUtils.setEnabled(startPane, false); GUICoreUtils.setEnabled(stopPane, true); } else { diff --git a/designer-base/src/com/fr/start/server/ServerTray.java b/designer-base/src/com/fr/start/server/ServerTray.java index c1f4bb5aed..4598be3e0e 100644 --- a/designer-base/src/com/fr/start/server/ServerTray.java +++ b/designer-base/src/com/fr/start/server/ServerTray.java @@ -1,82 +1,76 @@ package com.fr.start.server; -import java.awt.AWTException; -import java.awt.Image; -import java.awt.MenuItem; -import java.awt.PopupMenu; -import java.awt.SystemTray; -import java.awt.TrayIcon; +import com.fr.base.BaseUtils; +import com.fr.base.FRContext; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.ListenerAdaptor; +import com.fr.general.Inter; + +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import com.fr.base.BaseUtils; -import com.fr.base.FRContext; -import com.fr.general.Inter; -import com.fr.start.StartServer; - /** * Create server tray. */ public class ServerTray { - public static boolean JVM_EXIT_ON_TRAY_EXIT = false; - - private MenuItem manangeMenu, startMenu, stopMenu, exitMenu; - private Image trayStartedImage = BaseUtils.readImage( - "/com/fr/base/images/oem/trayStarted.png"); - private Image trayStoppedImage = BaseUtils.readImage( - "/com/fr/base/images/oem/trayStopped.png"); + + private static ServerTray INSTANCE; + + private MenuItem startMenu; + + private MenuItem stopMenu; + + private Image trayStartedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStarted.png"); + + private Image trayStoppedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStopped.png"); private ServerManageFrame serverManageFrame; private TrayIcon trayIcon; - - private TomcatHost hostTomcatServer; - - - public ServerTray(TomcatHost hostTomcatServer) { - - this.hostTomcatServer = hostTomcatServer; - - //p:首先构建右键菜单 - PopupMenu popup = new PopupMenu(); - manangeMenu = new MenuItem(Inter.getLocText("Server-Open_Service_Manager")); + + + private ServerTray() { + + listen(); + //p:首先构建右键菜单 + PopupMenu popup = new PopupMenu(); + MenuItem manangeMenu = new MenuItem(Inter.getLocText("Server-Open_Service_Manager")); manangeMenu.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { - serverManageFrame = ServerManageFrame.getServerManageFrame(ServerTray.this.hostTomcatServer); - if(!serverManageFrame.isVisible()) { - serverManageFrame.setVisible(true); - } - serverManageFrame.toFront();//p:到第一个. + + serverManageFrame = ServerManageFrame.getServerManageFrame(); + if (!serverManageFrame.isVisible()) { + serverManageFrame.setVisible(true); + } + serverManageFrame.toFront();//p:到第一个. } }); startMenu = new MenuItem(Inter.getLocText("FR-Server_Embedded_Server_Start")); stopMenu = new MenuItem(Inter.getLocText("FR-Server_Embedded_Server_Stop")); - exitMenu = new MenuItem(Inter.getLocText("Exit")); + MenuItem exitMenu = new MenuItem(Inter.getLocText("Exit")); //创建打开监听器 ActionListener startListener = new ActionListener() { + public void actionPerformed(ActionEvent e) { - TomcatHost tomcatServer = StartServer.getInstance(); + try { - if(!tomcatServer.isStarted()) { - tomcatServer.start(); - tomcatServer.addAndStartLocalEnvHomeWebApp();//暂停后再打开Tomcat,需要addApp - } - } catch(Exception exp) { - FRContext.getLogger().error(exp.getMessage(), exp); + FineEmbedServer.getInstance().start(); + } catch (Exception exp) { + FRContext.getLogger().error(exp.getMessage(), exp); } } }; ActionListener stopListener = new ActionListener() { public void actionPerformed(ActionEvent e) { - TomcatHost tomcatServer = StartServer.getInstance(); try { - if(tomcatServer.isStarted()) { - tomcatServer.stop(); - } - } catch(Exception exp) { - FRContext.getLogger().error(exp.getMessage(), exp); + FineEmbedServer.getInstance().stop(); + } catch (Throwable exp) { + FRContext.getLogger().error(exp.getMessage(), exp); } } }; @@ -105,18 +99,18 @@ public class ServerTray { if(e.getClickCount() < 2) { return; } - - ServerManageFrame serverManageFrame = ServerManageFrame.getServerManageFrame(ServerTray.this.hostTomcatServer); - if(!serverManageFrame.isVisible()) { - serverManageFrame.setVisible(true); - } - serverManageFrame.toFront();//p:到第一个. - } + + ServerManageFrame serverManageFrame = ServerManageFrame.getServerManageFrame(); + if (!serverManageFrame.isVisible()) { + serverManageFrame.setVisible(true); + } + serverManageFrame.toFront();//p:到第一个. + } }); - - TrayIcon[] ti = SystemTray.getSystemTray().getTrayIcons(); - for(int i = 0;i webAppsMap = new HashMap(); - private List listenerList = new ArrayList(); - private boolean isDemoAppLoaded = false; - - public TomcatHost(int port) { - this.currentPort = port; - initServer(); - - initLogFileAndOutputStream(); - - // TODO: 将HostTomcatServer放到ServerTray中去 - tryStartServerTray(); - } - - public static FRTomcat getTomcat() { - return tomcat; - } - - private void initServer() { - try { - //直接用自定义的,不用server.xml - this.tomcat = new FRTomcat(); - this.tomcat.setPort(this.currentPort); - this.tomcat.setBaseDir(StableUtils.getInstallHome()); - this.server = (StandardServer) tomcat.getServer(); - this.listener = new AprLifecycleListener(); - this.server.addLifecycleListener(listener); - this.tomcat.getHost().setAppBase(StableUtils.getInstallHome() + File.separator + "."); - this.tomcat.getConnector().setURIEncoding("UTF-8"); - } catch (Exception e) { - //todo 最好加一个用server.xml - FRContext.getLogger().error(e.getMessage(), e); - } - } - - private void initLogFileAndOutputStream() { - // log文件放置的位置 - File logDir = null; - String installHome = StableUtils.getInstallHome(); - if (installHome == null) {// 没有installHome的时候,就放到user.home下面喽 - logDir = new File(ProductConstants.getEnvHome() + File.separator + ProjectConstants.LOGS_NAME); - } else { - // james:logs放在安装目录下面 - logDir = new File(installHome + File.separator + ProjectConstants.LOGS_NAME + File.separator + "tomcat"); - } - StableUtils.mkdirs(logDir); - DateFormat fateFormat = new SimpleDateFormat("yyyy-MM-dd"); - Calendar curCalendar = Calendar.getInstance(); - outLogFile = new File(logDir, "tomcat_" + fateFormat.format(curCalendar.getTime()) + ".log"); - - try { - multiOutputStream = new MultiOutputStream(); - multiOutputStream.addOutputStream(new FileOutputStream(outLogFile, true)); - multiOutputStream.addOutputStream(System.out); - System.setErr(new PrintStream(multiOutputStream)); - System.setOut(new PrintStream(multiOutputStream)); - } catch (IOException ioe) { - FRContext.getLogger().error(ioe.getMessage(), ioe); - } - } - - private synchronized void addWebApplication(String context, String webappsPath) { - FRContext.getLogger().info("The new Application Path is: \n" + webappsPath + ", it will be added."); - if (webAppsMap.get(context) != null) { - Context webapp = webAppsMap.remove(context); - } - try { - if (!isStarted()) { - start(); - } - Context webapp = tomcat.addWebapp(context, webappsPath); - webAppsMap.put(context, webapp); - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - } - - private void addAndStartWebApplication(String context, String webAppPath) { - addWebApplication(context, webAppPath); - } - - /** - * Get MultiOutputStream. - */ - public MultiOutputStream getMultiOutputStream() { - return this.multiOutputStream; - } - - /** - * Get out log file - */ - public File getOutLogFile() { - return this.outLogFile; - } - - private Server getServer() { - if (server == null) { - initServer(); - } - - return server; - } - - /** - * Start - * - * @throws Exception - */ - public void start() throws Exception { - tomcat.start(); - for (int i = 0; i < listenerList.size(); i++) { - TomcatServerListener listener = TomcatHost.this.getLinstener(i); - listener.started(this); - } - } - - /** - * Stop - * - * @throws Exception - */ - public void stop() throws Exception { - - tomcat.stop(); - - for (int i = 0; i < listenerList.size(); i++) { - TomcatServerListener listener = this.getLinstener(i); - listener.stopped(this); - } - - StartServer.currentEnvChanged(); - server = null;//重置server - } - - /** - * Is started - * - * @throws Exception - */ - public boolean isStarted() throws Exception { - return getServer().getState().isAvailable(); - } - - public void addListener(TomcatServerListener listener) { - this.listenerList.add(listener); - } - - public int getLinstenerCount() { - return this.listenerList.size(); - } - - public TomcatServerListener getLinstener(int index) { - if (index < 0 || index >= this.getLinstenerCount()) { - return null; - } - - return this.listenerList.get(index); - } - - public void clearLinsteners() { - this.listenerList.clear(); - } - - /** - * 尝试启动系统托盘 - */ - private void tryStartServerTray() { - if (SystemTray.isSupported()) { - new ServerTray(this); - } else { - FRContext.getLogger().error("Do not support the SystemTray!"); - } - } - - public void exit() { - try { - getServer().stop(); - } catch (LifecycleException e) { - FRContext.getLogger().error(e.getMessage(), e); - } - - for (int i = 0; i < listenerList.size(); i++) { - TomcatServerListener listener = this.getLinstener(i); - listener.exited(this); - } - - try { - getServer().destroy(); - } catch (LifecycleException e) { - FRContext.getLogger().error(e.getMessage(), e); - } - StartServer.currentEnvChanged(); - - } - - public int getCurrentPort() { - return currentPort; - } - - /** - * 安装目录下的默认的WebReport,这个只执行一次,除了预览demo,其他的不要调用这个方法 - */ - public void addAndStartInstallHomeWebApp() { - if (!isDemoAppLoaded) { - String installHome = StableUtils.getInstallHome(); - String webApplication = StableUtils.pathJoin(new String[]{installHome, ProjectConstants.WEBAPP_NAME}); - - if (new File(webApplication).isDirectory()) { - addAndStartWebApplication("/" + ProjectConstants.WEBAPP_NAME, webApplication); - } - } - isDemoAppLoaded = true; - } - - /** - * 加载Env下的报表运行环境 - */ - public void addAndStartLocalEnvHomeWebApp() { - String name = DesignerEnvManager.getEnvManager().getCurEnvName(); - if (name.equals(Inter.getLocText("Default"))) { - isDemoAppLoaded = true; - } - Env env = FRContext.getCurrentEnv(); - if (env instanceof LocalEnv) { - String webApplication = new File(env.getPath()).getParent(); - FRContext.getLogger().info(Inter.getLocText("INFO-Reset_Webapp") + ":" + webApplication); - addAndStartWebApplication("/" + GeneralContext.getCurrentAppNameOfEnv(), webApplication); - } - } - - public boolean isDemoAppLoaded() { - return isDemoAppLoaded; - } - -} \ No newline at end of file diff --git a/designer-base/src/com/fr/start/server/TomcatServerListener.java b/designer-base/src/com/fr/start/server/TomcatServerListener.java deleted file mode 100644 index 30702d3404..0000000000 --- a/designer-base/src/com/fr/start/server/TomcatServerListener.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.fr.start.server; - -public interface TomcatServerListener { - /** - * Started - */ - public void started(TomcatHost tomcatServer); - - /** - * Stopped - */ - public void stopped(TomcatHost tomcatServer); - /** - * Exited - */ - public void exited(TomcatHost tomcatServer); - -} \ No newline at end of file diff --git a/designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java b/designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java index 9c8096cde0..fb0ef83728 100644 --- a/designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java +++ b/designer-chart/src/com/fr/van/chart/map/server/ChartMapEditorAction.java @@ -8,7 +8,7 @@ import com.fr.design.actions.UpdateAction; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.general.Inter; -import com.fr.start.StartServer; +import com.fr.start.ServerStarter; import java.awt.event.ActionEvent; @@ -23,11 +23,11 @@ public class ChartMapEditorAction extends UpdateAction { } public void actionPerformed(ActionEvent evt) { - int port = DesignerEnvManager.getEnvManager().getJettyServerPort(); + int port = DesignerEnvManager.getEnvManager().getEmbedServerPort(); String web = GeneralContext.getCurrentAppNameOfEnv(); String serverlet = ServerConfig.getInstance().getReportServletName(); Env env = FRContext.getCurrentEnv(); - StartServer.browserURLWithLocalEnv(env.isLocalEnv() ? String.format("http://localhost:%d/%s/%s?op=map", port, web, serverlet) : env.getPath() + "?op=map"); + ServerStarter.browserURLWithLocalEnv(env.isLocalEnv() ? String.format("http://localhost:%d/%s/%s?op=map", port, web, serverlet) : env.getPath() + "?op=map"); } } diff --git a/designer-form/src/com/fr/design/designer/beans/actions/CopyAction.java b/designer-form/src/com/fr/design/designer/beans/actions/CopyAction.java index a93da2a60d..96d3970425 100644 --- a/designer-form/src/com/fr/design/designer/beans/actions/CopyAction.java +++ b/designer-form/src/com/fr/design/designer/beans/actions/CopyAction.java @@ -1,6 +1,7 @@ package com.fr.design.designer.beans.actions; import com.fr.base.BaseUtils; +import com.fr.design.designer.beans.actions.behavior.ComponentEnable; import com.fr.design.mainframe.FormDesigner; import com.fr.general.Inter; @@ -18,6 +19,7 @@ public class CopyAction extends FormWidgetEditAction { this.setMnemonic('C'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)); + setUpdateBehavior(new ComponentEnable()); } @Override @@ -28,5 +30,4 @@ public class CopyAction extends FormWidgetEditAction { } return false; } - } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/beans/actions/CutAction.java b/designer-form/src/com/fr/design/designer/beans/actions/CutAction.java index e47a2c2893..b1a5ec428d 100644 --- a/designer-form/src/com/fr/design/designer/beans/actions/CutAction.java +++ b/designer-form/src/com/fr/design/designer/beans/actions/CutAction.java @@ -6,6 +6,7 @@ import java.awt.event.KeyEvent; import javax.swing.KeyStroke; import com.fr.base.BaseUtils; +import com.fr.design.designer.beans.actions.behavior.ComponentEnable; import com.fr.general.Inter; import com.fr.design.mainframe.FormDesigner; @@ -19,6 +20,7 @@ public class CutAction extends FormWidgetEditAction { this.setMnemonic('T'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png")); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); + this.setUpdateBehavior(new ComponentEnable()); } @Override @@ -29,5 +31,4 @@ public class CutAction extends FormWidgetEditAction { } return editPane.cut(); } - } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java b/designer-form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java index d799fed63b..2e9912f1e6 100644 --- a/designer-form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java +++ b/designer-form/src/com/fr/design/designer/beans/actions/FormDeleteAction.java @@ -8,6 +8,7 @@ import java.awt.event.KeyEvent; import javax.swing.*; import com.fr.base.BaseUtils; +import com.fr.design.designer.beans.actions.behavior.ComponentEnable; import com.fr.general.Inter; import com.fr.design.designer.creator.XCreator; import com.fr.design.mainframe.FormDesigner; @@ -27,6 +28,13 @@ public class FormDeleteAction extends FormWidgetEditAction { // Richie:删除菜单图标 this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/delete.png")); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)); + this.setUpdateBehavior(new ComponentEnable()); + } + + @Override + protected String getToolTipText() { + String originText = super.getToolTipText(); + return originText.replace(KeyEvent.getKeyText(KeyEvent.VK_BACK_SPACE), KeyEvent.getKeyText(KeyEvent.VK_DELETE)); } @Override @@ -48,11 +56,8 @@ public class FormDeleteAction extends FormWidgetEditAction { if (designer == null) { return false; } - FormSelection selection = designer.getSelectionModel().getSelection(); - XCreator creator = selection.getSelectedCreator(); designer.getSelectionModel().deleteSelection(); - creator.deleteRelatedComponent(creator, designer); return false; } } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/beans/actions/FormWidgetEditAction.java b/designer-form/src/com/fr/design/designer/beans/actions/FormWidgetEditAction.java index 8fbaec430f..b22ac5f76d 100644 --- a/designer-form/src/com/fr/design/designer/beans/actions/FormWidgetEditAction.java +++ b/designer-form/src/com/fr/design/designer/beans/actions/FormWidgetEditAction.java @@ -1,23 +1,32 @@ package com.fr.design.designer.beans.actions; import com.fr.design.actions.TemplateComponentAction; +import com.fr.design.designer.beans.actions.behavior.UpdateBehavior; import com.fr.design.mainframe.FormDesigner; +import com.fr.general.Inter; import com.fr.plugin.ExtraClassManager; import com.fr.stable.ReportFunctionProcessor; import com.fr.stable.fun.FunctionProcessor; -import javax.swing.JButton; +import javax.swing.*; import java.awt.event.ActionEvent; public abstract class FormWidgetEditAction extends TemplateComponentAction { + private UpdateBehavior updateBehavior = new UpdateBehavior() { + @Override + public void doUpdate(FormWidgetEditAction action) { + action.setEnabled(true); + } + }; + protected FormWidgetEditAction(FormDesigner t) { super(t); } @Override public void update() { - this.setEnabled(true); + updateBehavior.doUpdate(this); } @Override @@ -36,4 +45,8 @@ public abstract class FormWidgetEditAction extends TemplateComponentAction { + @Override + public void doUpdate(FormWidgetEditAction action) { + FormDesigner designer = action.getEditingComponent(); + if (designer == null) { + action.setEnabled(false); + return; + } + action.setEnabled(!designer.isRootSelected()); + } +} diff --git a/designer-form/src/com/fr/design/designer/beans/actions/behavior/MovableDownEnable.java b/designer-form/src/com/fr/design/designer/beans/actions/behavior/MovableDownEnable.java new file mode 100644 index 0000000000..ad73be1b1c --- /dev/null +++ b/designer-form/src/com/fr/design/designer/beans/actions/behavior/MovableDownEnable.java @@ -0,0 +1,19 @@ +package com.fr.design.designer.beans.actions.behavior; + +import com.fr.design.designer.beans.actions.FormWidgetEditAction; +import com.fr.design.mainframe.FormDesigner; + +/** + * Created by plough on 2018/1/19. + */ +public class MovableDownEnable implements UpdateBehavior { + @Override + public void doUpdate(FormWidgetEditAction action) { + FormDesigner designer = action.getEditingComponent(); + if (designer == null) { + action.setEnabled(false); + return; + } + action.setEnabled(designer.isCurrentComponentMovableDown()); + } +} diff --git a/designer-form/src/com/fr/design/designer/beans/actions/behavior/MovableUpEnable.java b/designer-form/src/com/fr/design/designer/beans/actions/behavior/MovableUpEnable.java new file mode 100644 index 0000000000..85c12039ae --- /dev/null +++ b/designer-form/src/com/fr/design/designer/beans/actions/behavior/MovableUpEnable.java @@ -0,0 +1,19 @@ +package com.fr.design.designer.beans.actions.behavior; + +import com.fr.design.designer.beans.actions.FormWidgetEditAction; +import com.fr.design.mainframe.FormDesigner; + +/** + * Created by plough on 2018/1/19. + */ +public class MovableUpEnable implements UpdateBehavior { + @Override + public void doUpdate(FormWidgetEditAction action) { + FormDesigner designer = action.getEditingComponent(); + if (designer == null) { + action.setEnabled(false); + return; + } + action.setEnabled(designer.isCurrentComponentMovableUp()); + } +} diff --git a/designer-form/src/com/fr/design/designer/beans/actions/behavior/UpdateBehavior.java b/designer-form/src/com/fr/design/designer/beans/actions/behavior/UpdateBehavior.java new file mode 100644 index 0000000000..fa56bca018 --- /dev/null +++ b/designer-form/src/com/fr/design/designer/beans/actions/behavior/UpdateBehavior.java @@ -0,0 +1,8 @@ +package com.fr.design.designer.beans.actions.behavior; + +/** + * Created by plough on 2018/1/19. + */ +public interface UpdateBehavior { + public void doUpdate(T t); +} diff --git a/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java b/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java index 001e9fe615..d010bad9a3 100644 --- a/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java +++ b/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBorderLayoutAdapter.java @@ -1,11 +1,5 @@ package com.fr.design.designer.beans.adapters.layout; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; - -import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; -import com.fr.general.ComparatorUtils; import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.painters.FRBorderLayoutPainter; @@ -14,8 +8,13 @@ import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.properties.FRBorderLayoutConstraints; import com.fr.design.form.layout.FRBorderLayout; -import com.fr.form.ui.container.WBorderLayout; import com.fr.design.utils.gui.LayoutUtils; +import com.fr.form.ui.container.WBorderLayout; +import com.fr.general.ComparatorUtils; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; public class FRBorderLayoutAdapter extends AbstractLayoutAdapter { @@ -36,9 +35,6 @@ public class FRBorderLayoutAdapter extends AbstractLayoutAdapter { * @param creator 组件 */ public void fix(XCreator creator) { - if(creator.acceptType(XWCardTagLayout.class)){ - creator = (XCreator) creator.getParent(); - } FRBorderLayout layout = (FRBorderLayout)container.getFRLayout(); Object constraints = layout.getConstraints(creator); if (ComparatorUtils.equals(constraints, BorderLayout.NORTH)) { diff --git a/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java b/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java new file mode 100644 index 0000000000..4b17ffaedb --- /dev/null +++ b/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java @@ -0,0 +1,62 @@ +package com.fr.design.designer.beans.adapters.layout; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; +import com.fr.design.form.layout.FRBorderLayout; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; + +import javax.swing.JOptionPane; +import java.awt.BorderLayout; +import java.awt.Rectangle; + +/** + * cardMainBorderLayout适配器 + * + * @author kerry + * @date 2019/1/4 + */ +public class FRCardMainBorderLayoutAdapter extends FRBorderLayoutAdapter { + + public FRCardMainBorderLayoutAdapter(XLayoutContainer container) { + super(container); + } + + /** + * CardMainBorderLayout的title部分不能超出layout边界 + * + * @param creator 组件 + */ + @Override + public void fix(XCreator creator) { + if (creator.acceptType(XWCardTagLayout.class)) { + creator = (XCreator) creator.getParent(); + } + boolean beyondBounds = calculateBeyondBounds(creator); + if (!beyondBounds) { + super.fix(creator); + } + } + + private boolean calculateBeyondBounds(XCreator creator) { + FRBorderLayout layout = (FRBorderLayout) container.getFRLayout(); + Object constraints = layout.getConstraints(creator); + Rectangle rectangle = creator.getBounds(); + //不能超出控件边界 + if (ComparatorUtils.equals(constraints, BorderLayout.NORTH) || ComparatorUtils.equals(constraints, BorderLayout.SOUTH)) { + int containerHeight = container.getHeight(); + if (rectangle.height > containerHeight) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Beyond_Tablayout_Bounds")); + return true; + } + } else if (ComparatorUtils.equals(constraints, BorderLayout.EAST) || ComparatorUtils.equals(constraints, BorderLayout.WEST)) { + int containerWidth = container.getWidth(); + if (rectangle.width > containerWidth) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer-Beyond_Tablayout_Bounds")); + return true; + } + } + return false; + } +} diff --git a/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index f05e60212b..9aa9e5ab9c 100644 --- a/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -811,7 +811,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { if (ry != y) { calculateNoRelatedWhileRightTop(rec, rightComp); } else { - calculateNoRelatedWhileRightBott(rec, rightComp); + calculateNoRelatedWhileRightBott(rec); } } @@ -856,8 +856,11 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { recalculateChildrenSize(bound.x, bound.y, bound.width, bound.height, true); } - private void calculateNoRelatedWhileRightBott(Rectangle bound, Component rcomp) { - rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width); + private void calculateNoRelatedWhileRightBott(Rectangle bound) { + Component rcomp = container.getBottomRightComp(bound.x, bound.y, bound.height, bound.width); + if(rcomp == null){ + return; + } int ry = rcomp.getY(); int rh = rcomp.getHeight(); int rw = rcomp.getWidth(); diff --git a/designer-form/src/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/com/fr/design/designer/beans/models/SelectionModel.java index 850b737a36..fe94edc3b2 100644 --- a/designer-form/src/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/com/fr/design/designer/beans/models/SelectionModel.java @@ -234,7 +234,6 @@ public class SelectionModel { */ public void deleteSelection() { XCreator[] roots = selection.getSelectedCreators(); - if (roots.length > 0) { boolean isInPara = true; // 在参数面板内删除控件 for (XCreator creator : roots) { @@ -245,10 +244,12 @@ public class SelectionModel { designer.removeParaComponent(); } removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight()); + creator.deleteRelatedComponent(creator, designer); creator.removeAll(); // 清除被选中的组件 selection.reset(); } + setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent()); // 触发事件 designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); diff --git a/designer-form/src/com/fr/design/designer/beans/models/StateModel.java b/designer-form/src/com/fr/design/designer/beans/models/StateModel.java index d089e282f6..5eee1aca8d 100644 --- a/designer-form/src/com/fr/design/designer/beans/models/StateModel.java +++ b/designer-form/src/com/fr/design/designer/beans/models/StateModel.java @@ -434,6 +434,9 @@ public class StateModel { // 拖拽时画依附线用到的painter private void setDependLinePainter(MouseEvent e) { XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); + if (comp == null) { + return; + } XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); XCreator creator = selectionModel.getSelection().getSelectedCreator(); HoverPainter painter = AdapterBus.getContainerPainter(designer, container); diff --git a/designer-form/src/com/fr/design/designer/creator/DedicateLayoutContainer.java b/designer-form/src/com/fr/design/designer/creator/DedicateLayoutContainer.java index 8c3cd743de..d7f073b451 100644 --- a/designer-form/src/com/fr/design/designer/creator/DedicateLayoutContainer.java +++ b/designer-form/src/com/fr/design/designer/creator/DedicateLayoutContainer.java @@ -5,9 +5,10 @@ package com.fr.design.designer.creator; import com.fr.form.ui.container.WLayout; -import java.awt.*; +import java.awt.Component; +import java.awt.Dimension; import java.beans.IntrospectionException; -import java.util.ArrayList; +import java.util.List; /** * 一些控件专属的容器,如标题容器,sclae容器 @@ -27,6 +28,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer { * @return 属性名 * @throws IntrospectionException */ + @Override public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { return new CRPropertyDescriptor[0]; } @@ -50,7 +52,8 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer { * * @param path 控件树list */ - public void notShowInComponentTree(ArrayList path) { + @Override + public void notShowInComponentTree(List path) { path.remove(path.size() - 1); } @@ -59,6 +62,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer { * * @param name 名称 */ + @Override public void resetCreatorName(String name) { super.resetCreatorName(name); XCreator child = getXCreator(XWScaleLayout.INDEX); @@ -70,6 +74,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer { * 重置组件的可见性 * @param visible 可见性 */ + @Override public void resetVisible(boolean visible){ super.resetVisible(visible); XCreator child = getXCreator(XWScaleLayout.INDEX); @@ -80,6 +85,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer { * * @return 组件 */ + @Override public XCreator getPropertyDescriptorCreator() { return getXCreator(XWScaleLayout.INDEX); } @@ -89,6 +95,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer { * * @return 是则返回true */ + @Override public boolean isComponentTreeLeaf() { return true; } @@ -98,6 +105,7 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer { * * @return 是则返回true */ + @Override public boolean isDedicateContainer() { return true; } diff --git a/designer-form/src/com/fr/design/designer/creator/XButton.java b/designer-form/src/com/fr/design/designer/creator/XButton.java index d534f6d632..2b5a17dc51 100644 --- a/designer-form/src/com/fr/design/designer/creator/XButton.java +++ b/designer-form/src/com/fr/design/designer/creator/XButton.java @@ -3,20 +3,6 @@ */ package com.fr.design.designer.creator; -import java.awt.AlphaComposite; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.geom.Rectangle2D; -import java.beans.IntrospectionException; - -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.SwingConstants; - import com.fr.base.ScreenResolution; import com.fr.base.background.GradientBackground; import com.fr.design.form.util.XCreatorConstants; @@ -36,13 +22,26 @@ import com.fr.general.Inter; import com.fr.stable.ArrayUtils; import com.fr.stable.core.PropertyChangeAdapter; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.SwingConstants; +import java.awt.AlphaComposite; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.beans.IntrospectionException; + /** * @author richer * @since 6.5.3 */ public class XButton extends XWidgetCreator { - public final static Background DEFAULTBG = new GradientBackground(new Color(247,247,247),new Color(210,210,210),GradientBackground.TOP2BOTTOM); + public final static Background DEFAULTBG = new GradientBackground(new Color(247,247,247),new Color(210,210,210), GradientBackground.TOP2BOTTOM); public final static Font DEFAULTFT = new Font("Song_TypeFace",0,12); public final static Color DEFAULTFOREGROUNDCOLOR = Color.BLACK; private Background bg; @@ -198,10 +197,14 @@ public class XButton extends XWidgetCreator { protected JComponent initEditor() { if (editor == null) { editor = new UILabel(); - contentLabel = new UILabel(); + contentLabel = initContentLabel(); } return editor; } + + protected UILabel initContentLabel() { + return new UILabel(); + } @Override public void paintComponent(Graphics g) { diff --git a/designer-form/src/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/com/fr/design/designer/creator/XChartEditor.java index 4a53a01d69..a53aae956d 100644 --- a/designer-form/src/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/com/fr/design/designer/creator/XChartEditor.java @@ -6,6 +6,7 @@ import java.beans.IntrospectionException; import javax.swing.*; +import com.fr.base.GraphHelper; import com.fr.base.chart.BaseChartCollection; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; @@ -21,6 +22,7 @@ import com.fr.form.ui.BaseChartEditor; import com.fr.form.ui.Widget; import com.fr.design.form.util.XCreatorConstants; import com.fr.general.Inter; +import com.fr.stable.Constants; import com.fr.stable.core.PropertyChangeAdapter; /** @@ -32,13 +34,18 @@ import com.fr.stable.core.PropertyChangeAdapter; */ public class XChartEditor extends XBorderStyleWidgetCreator { private static final long serialVersionUID = -7009439442104836657L; + private static final int BORDER_WIDTH = 2; + //具体来说是DesignerEditor private DesignerEditor designerEditor; // private DesignerEditor designerEditor; //marro:无奈的属性,暂时想不出好办法 private boolean isRefreshing = false; + private boolean isHovering = false; private boolean isEditing = false; + private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30); + private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249); private JPanel coverPanel; public XChartEditor(BaseChartEditor editor) { @@ -180,12 +187,32 @@ public class XChartEditor extends XBorderStyleWidgetCreator { return bcc; } + + /** + * 编辑状态的时候需要重新绘制下边框 + * + */ + @Override + public void paintBorder(Graphics g, Rectangle bounds){ + if(isEditing){ + g.setColor(OUTER_BORDER_COLOR); + GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 1, bounds.height + BORDER_WIDTH + 1), Constants.LINE_LARGE); + }else if(!isHovering){ + super.paintBorder(g, bounds); + } + } + + /** * 渲染Painter */ public void paint(Graphics g) { designerEditor.paintEditor(g, this.getSize()); super.paint(g); + if(isEditing){ + g.setColor(INNER_BORDER_COLOR); + GraphHelper.draw(g, new Rectangle(0, 0, getWidth(), getHeight()), Constants.LINE_MEDIUM); + } } /** @@ -270,6 +297,14 @@ public class XChartEditor extends XBorderStyleWidgetCreator { return coverPanel; } + /** + * 是否支持设置可用 + * return boolean + */ + public boolean supportSetEnable(){ + return false; + } + /** * data属性改变触发其他操作 * diff --git a/designer-form/src/com/fr/design/designer/creator/XCreator.java b/designer-form/src/com/fr/design/designer/creator/XCreator.java index 31aceeb910..8aa2f215e3 100644 --- a/designer-form/src/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/com/fr/design/designer/creator/XCreator.java @@ -3,7 +3,8 @@ */ package com.fr.design.designer.creator; -import com.fr.base.BaseUtils; +import com.fr.base.GraphHelper; +import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.UpdateAction; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; @@ -14,6 +15,7 @@ import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.AuthorityPropertyPane; import com.fr.design.mainframe.BaseJForm; +import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.NoSupportAuthorityEdit; @@ -21,6 +23,7 @@ import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WTitleLayout; +import com.fr.stable.Constants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -32,6 +35,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.Graphics; import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.beans.IntrospectionException; @@ -55,14 +59,15 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo protected Widget data; protected JComponent editor; + protected CoverReportPane coverPanel; // XCreator加入到某些XLayoutContainer中时,能调整宽度或者高度 private int[] directions; private Rectangle backupBound; private String shareId = StringUtils.EMPTY;//如果组件是共享的会有这个属性 private boolean isHelpBtnOnFocus = false;//焦点是否在帮助按钮上 - private static final int SHORTS_SEPARATOR_POS = 4; // 弹出菜单分割的位置 + private static final int SHORTS_SEPARATOR_POS = 4; // 弹出菜单分割的位置 - public XCreator(Widget ob, Dimension initSize) { + public XCreator(Widget ob, Dimension initSize) { this.data = ob; this.initEditor(); @@ -72,12 +77,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo add(editor, BorderLayout.CENTER); } - if (initSize.width == 0) { - initSize.width = this.initEditorSize().width; - } - if (initSize.height == 0) { - initSize.height = this.initEditorSize().height; - } + setInitSize(initSize); this.setPreferredSize(initSize); this.setSize(initSize); this.setMaximumSize(initSize); @@ -101,6 +101,18 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } } + /** + * 初始化组件大小 + */ + public void setInitSize(Dimension initSize) { + if (initSize.width == 0) { + initSize.width = this.initEditorSize().width; + } + if (initSize.height == 0) { + initSize.height = this.initEditorSize().height; + } + } + /** * 备份当前大小 */ @@ -241,8 +253,8 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } protected String getIconName() { - return StringUtils.EMPTY; - } + return StringUtils.EMPTY; + } public String getIconPath() { return "/com/fr/web/images/form/resources/" + getIconName(); @@ -282,8 +294,9 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo *@param formEditor 设计界面组件 *@return 工具界面 */ + @Override public JComponent createToolPane(BaseJForm jform, FormDesigner formEditor) { - if (!BaseUtils.isAuthorityEditing()) { + if (!DesignerMode.isAuthorityEditing()) { if (isDedicateContainer()) { // 图表块和报表块由于控件树处不显示,但对应的属性表要显示,此处处理下 XCreator child = ((XLayoutContainer) this).getXCreator(0); @@ -317,21 +330,21 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo return false; } - /** - * 该组件是否可以拖入参数面板 - * @return 是则返回true - */ - public boolean canEnterIntoParaPane(){ - return true; - } + /** + * 该组件是否可以拖入参数面板 + * @return 是则返回true + */ + public boolean canEnterIntoParaPane(){ + return true; + } - /** - * 该组件是否可以拖入表单主体 - * @return 是则返回true - */ - public boolean canEnterIntoAdaptPane(){ - return true; - } + /** + * 该组件是否可以拖入表单主体 + * @return 是则返回true + */ + public boolean canEnterIntoAdaptPane(){ + return true; + } /** * 该组件是否可以拖入绝对布局 @@ -341,27 +354,27 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo return true; } - /** - * 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽) - * @return 是则返回true - */ - public boolean isSupportDrag(){ - return true; - } + /** + * 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽) + * @return 是则返回true + */ + public boolean isSupportDrag(){ + return true; + } - public List getAllXCreatorNameList(XCreator xCreator, List namelist){ - namelist.add(xCreator.toData().getWidgetName()); - return namelist; - } + public List getAllXCreatorNameList(XCreator xCreator, List namelist){ + namelist.add(xCreator.toData().getWidgetName()); + return namelist; + } - /** - * 是否有查询按钮 - * @param xCreator 控件或容器 - * @return 有无查询按钮 - */ - public boolean SearchQueryCreators(XCreator xCreator) { - return false; - } + /** + * 是否有查询按钮 + * @param xCreator 控件或容器 + * @return 有无查询按钮 + */ + public boolean SearchQueryCreators(XCreator xCreator) { + return false; + } /** * @return the backupBound @@ -381,14 +394,25 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * 控件树不显示此组件 * @param path 控件树list */ - public void notShowInComponentTree(ArrayList path) { + @Override + public void notShowInComponentTree(List path) { return; } + /** + * 获取其在控件树上可见父层 + * @return 组件 + */ + @Override + public Component getParentShow(){ + return this.getParent(); + } + /** * 重置组件的名称 * @param name 名称 */ + @Override public void resetCreatorName(String name) { toData().setWidgetName(name); } @@ -405,6 +429,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * 返回编辑的子组件,scale为其内部组件 * @return 组件 */ + @Override public XCreator getEditingChildCreator() { return this; } @@ -413,6 +438,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * 返回对应属性表的组件,scale和title返回其子组件 * @return 组件 */ + @Override public XCreator getPropertyDescriptorCreator() { return this; } @@ -421,6 +447,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * 更新子组件的Bound; 没有不处理 * @param minHeight 最小高度 */ + @Override public void updateChildBound(int minHeight) { return; } @@ -429,6 +456,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * 是否作为控件树的叶子节点 * @return 是则返回true */ + @Override public boolean isComponentTreeLeaf() { return true; } @@ -437,23 +465,24 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * 是否为sclae和title专属容器 * @return 是则返回true */ + @Override public boolean isDedicateContainer() { return false; } /** - * 是否接收这种类型 - * @param acceptTypes 接收的类型 - * @return 接收指定的类型则返回true,否则返回false - */ - public boolean acceptType(Class... acceptTypes) { - for (Class type : acceptTypes) { - if (StableUtils.objectInstanceOf(this, type)) { - return true; - } - } - return false; - } + * 是否接收这种类型 + * @param acceptTypes 接收的类型 + * @return 接收指定的类型则返回true,否则返回false + */ + public boolean acceptType(Class... acceptTypes) { + for (Class type : acceptTypes) { + if (StableUtils.objectInstanceOf(this, type)) { + return true; + } + } + return false; + } /** * 是否组件要缩放(自适应里部分组件需要, 如数字、文本、下拉框、下拉复选框、密码、下拉树、下拉复选树、日期) @@ -580,7 +609,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo /** * 组件是否是共享组件 * @return 是否是共享组件 - */ + */ public boolean isShared() { return StringUtils.isNotEmpty(shareId); } @@ -596,7 +625,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo /** * 焦点是否在帮助按钮上 * @return 焦点是否在帮助按钮上 - */ + */ public boolean isHelpBtnOnFocus() { return isHelpBtnOnFocus; } @@ -608,18 +637,41 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo /** * 设置描述信息 * @param msg 帮助信息 - */ - public void setXDescrption(String msg){} + */ + public void setXDescrption(String msg){ + if (coverPanel != null) { + coverPanel.setHelpMsg(msg); + } + } + + public JComponent getCoverPane(){ + return coverPanel; + } + + /** + * 销毁帮助提示框 + */ + public void destroyHelpDialog(){ + if (coverPanel != null) { + coverPanel.destroyHelpDialog(); + } + } + + /** + * 是否展现覆盖的pane + * @param display 是否 + */ + public void displayCoverPane(boolean display){ + } /** * 根据widget设置Xcreator描述信息 * @param widget - */ + */ public void setXDescrption(Widget widget){ if (widget != null) { setXDescrption(widget.getDescription()); } - } /** @@ -667,39 +719,55 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo * */ public void firePropertyChange(){ - // do nothing + // do nothing + } + + /** + * 有的控件是有编辑状态的,给一个退出编辑的接口 + * + */ + public void stopEditing() { + // do nothing } - /** - * 有的控件是有编辑状态的,给一个退出编辑的接口 - * - */ - public void stopEditing() { - // do nothing - } + /** + * 编辑状态的时候需要重新绘制下边框 + * + */ + public void paintBorder(Graphics g, Rectangle bounds){ + GraphHelper.draw(g, bounds, Constants.LINE_MEDIUM); + } /** * 创建右击弹出菜单 * */ public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { - UpdateAction[] actions = formDesigner.getActions(); + UpdateAction[] actions = formDesigner.getActions(); UIPopupMenu popup = new UIPopupMenu(); - for (int i = 0; i < actions.length; i++) { - if (i == SHORTS_SEPARATOR_POS) { - popup.addSeparator(); - } - popup.add(actions[i].createMenuItem()); - } + for (int i = 0; i < actions.length; i++) { + if (i == SHORTS_SEPARATOR_POS) { + popup.addSeparator(); + } + popup.add(actions[i].createMenuItem()); + } return popup; } - /** - * 是否支持上移一层、下移一层等操作 - * - */ - public boolean isMovable() { - return true; - } + /** + * 是否支持上移一层、下移一层等操作 + * + */ + public boolean isMovable() { + return true; + } + + /** + * 是否支持共享-现只支持报表块、图表、tab块、绝对布局 + * @return + */ + public boolean isSupportShared() { + return false; + } } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/creator/XCreatorTools.java b/designer-form/src/com/fr/design/designer/creator/XCreatorTools.java index 8a23daa78b..38df157d34 100644 --- a/designer-form/src/com/fr/design/designer/creator/XCreatorTools.java +++ b/designer-form/src/com/fr/design/designer/creator/XCreatorTools.java @@ -1,15 +1,15 @@ /** - * + * */ package com.fr.design.designer.creator; import java.awt.Component; -import java.util.ArrayList; +import java.util.List; /** * @author jim * @date 2014-11-7 - * + * */ public interface XCreatorTools { @@ -17,42 +17,46 @@ public interface XCreatorTools { * 控件树不显示此组件 * @param path 控件树list */ - void notShowInComponentTree(ArrayList path); - + void notShowInComponentTree(List path); /** * 重置组件的名称 * @param name 名称 */ void resetCreatorName(String name); - + /** * 返回编辑的子组件,scale为其内部组件 * @return 组件 */ XCreator getEditingChildCreator(); - + /** * 返回对应属性表的组件,scale和title返回其子组件 * @return 组件 */ XCreator getPropertyDescriptorCreator(); - + /** * 更新子组件的Bound; 没有不处理 * @param minHeight 最小高度 */ void updateChildBound(int minHeight); - + /** * 是否作为控件树的叶子节点 * @return 是则返回true */ boolean isComponentTreeLeaf(); - + /** * 是否为sclae和title专属容器 * @return 是则返回true */ boolean isDedicateContainer(); - + + /** + * 获取其在控件树上可见父层 + * @return 组件 + */ + Component getParentShow(); } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/creator/XElementCase.java b/designer-form/src/com/fr/design/designer/creator/XElementCase.java index d95a7f9fa4..0ca67aabf6 100644 --- a/designer-form/src/com/fr/design/designer/creator/XElementCase.java +++ b/designer-form/src/com/fr/design/designer/creator/XElementCase.java @@ -38,6 +38,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme private CoverReportPane coverPanel; private FormDesigner designer; private static BufferedImage DEFAULT_BACKGROUND; + private boolean isHovering = false; static{ try{ @@ -122,7 +123,11 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme if (editor.getFitStateInPC() == 0) { editor.setReportFitAttr(null); } - ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : editor.getReportFitAttr(); + ReportFitAttrProvider reportFit = editor.getReportFitAttr(); + if(fitAttr != null){ + reportFit = fitAttr.fitInBrowser() ? editor.getReportFitAttr() : fitAttr; + } + ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : reportFit; PropertyDescriptor[] extraEditor = processor.createPropertyDescriptor(this.data.getClass(), reportFitAttr); if (editor.getReportFitAttr() == null) { editor.setReportFitInPc(processor.getFitStateInPC(fitAttr)); @@ -211,6 +216,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme * @param display 是否 */ public void displayCoverPane(boolean display){ + isHovering = display; coverPanel.setVisible(display); coverPanel.setBounds(1, 1, (int) editor.getBounds().getWidth(), (int) editor.getBounds().getHeight()); editor.repaint(); @@ -227,6 +233,14 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme return coverPanel; } + @Override + public void paintBorder(Graphics g, Rectangle bounds){ + if (!isHovering) { + super.paintBorder(g, bounds); + } + } + + /** * 初始化大小 * @return 尺寸 diff --git a/designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java b/designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java index 3b4067aac5..4f0476388d 100644 --- a/designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java +++ b/designer-form/src/com/fr/design/designer/creator/XLayoutContainer.java @@ -241,6 +241,10 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme } } + public int getShowXCreatorCount() { + return getXCreatorCount(); + } + public int getXCreatorCount() { return getComponentCount(); } diff --git a/designer-form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer-form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index 1c389230b6..d0ab8cbdf7 100644 --- a/designer-form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -89,6 +89,21 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { }; } + /** + * 获取其在控件树上可见父层 + * @return 组件 + */ + @Override + public Component getParentShow(){ + //绝对布局作为body的时候不显示自适应布局父层 + if ((this.getParent() != null)) { + return ((XCreator) this.getParent()).getParentShow(); + } + return super.getParentShow(); + } + + + @Override public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { return new WidgetPropertyUIProvider[]{ new BodyMobilePropertyUI(this)}; diff --git a/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java index 69277fc6f8..5afe30d384 100644 --- a/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -3,6 +3,9 @@ */ package com.fr.design.designer.creator; +import com.fr.base.GraphHelper; +import com.fr.base.iofileattr.SharableAttrMark; +import com.fr.design.constants.UIConstants; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.LayoutAdapter; @@ -11,10 +14,14 @@ import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.form.layout.FRAbsoluteLayout; +import com.fr.design.form.util.XCreatorConstants; import com.fr.design.icon.IconPathConstants; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetHelpDialog; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.form.ui.Connector; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; @@ -23,8 +30,20 @@ import com.fr.form.ui.container.WLayout; import com.fr.general.FRScreen; import com.fr.general.IOUtils; import com.fr.general.Inter; - -import java.awt.*; +import com.fr.share.ShareConstants; +import com.fr.stable.Constants; + +import javax.swing.Icon; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.Toolkit; import java.awt.event.ContainerEvent; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; @@ -38,14 +57,20 @@ import java.util.HashMap; */ public class XWAbsoluteLayout extends XLayoutContainer { - private static final int EDIT_BTN_WIDTH = 60; - private static final int EDIT_BTN_HEIGHT = 24; + private static final int EDIT_BTN_WIDTH = 75; + private static final int EDIT_BTN_HEIGHT = 20; private int minWidth = WLayout.MIN_WIDTH; private int minHeight = WLayout.MIN_HEIGHT; + private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30); + private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249); + private static final int BORDER_WIDTH = 1; + private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH); //由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算 protected double containerPercent = 1.0; + private boolean isHovering = false; + private HashMap xConnectorMap; public XWAbsoluteLayout() { @@ -437,15 +462,18 @@ public class XWAbsoluteLayout extends XLayoutContainer { Graphics2D g2d = (Graphics2D) g; Composite oldComposite = g2d.getComposite(); //画白色的编辑层 - g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F)); - g2d.setColor(Color.WHITE); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F)); + g2d.setColor(XCreatorConstants.COVER_COLOR); g2d.fillRect(x, y, w, h); //画编辑按钮所在框 + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR ? 0.9f : 0.7f); + g2d.setColor(XCreatorConstants.EDIT_COLOR); + g2d.setComposite(alphaComposite); + g2d.fillRoundRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT, 4, 4); g2d.setComposite(oldComposite); - g2d.setColor(new Color(176, 196, 222)); - g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT); //画编辑按钮图标 - BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH); + BufferedImage image = IOUtils.readImage(IconPathConstants.EDIT_ICON_PATH); g2d.drawImage( image, (x + w / 2 - 23), @@ -455,12 +483,37 @@ public class XWAbsoluteLayout extends XLayoutContainer { null, this ); - g2d.setColor(Color.BLACK); + g2d.setColor(Color.WHITE); //画编辑文字 + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5); + g.setColor(XCreatorConstants.FORM_BORDER_COLOR); + GraphHelper.draw(g, new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - BORDER_WIDTH * 2, getHeight() - BORDER_WIDTH * 2), Constants.LINE_MEDIUM); + paintExtro(g); } } + public void paintExtro(Graphics g) { + if (this.toData().getWidgetAttrMark(SharableAttrMark.XML_TAG) != null) { + int width = getWidth() - ShareConstants.SHARE_EL_CONTROL_BUTTON_HW; + g.setColor(UIConstants.NORMAL_BACKGROUND); + g.fillArc(width, 0, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW, ShareConstants.SHARE_EL_CONTROL_BUTTON_HW, + 0, 360); + controlMode.paintIcon(this, g, width, 0); + } + } + + @Override + public void paintBorder(Graphics g, Rectangle bounds){ + if(editable){ + g.setColor(OUTER_BORDER_COLOR); + GraphHelper.draw(g, new Rectangle(bounds.x - 3, bounds.y - 3, bounds.width + 5, bounds.height + 5), Constants.LINE_LARGE); + g.setColor(INNER_BORDER_COLOR); + GraphHelper.draw(g, new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height), Constants.LINE_MEDIUM); + }else if(!isMouseEnter){ + super.paintBorder(g, bounds); + } + } /** * 响应点击事件 * @@ -468,6 +521,11 @@ public class XWAbsoluteLayout extends XLayoutContainer { * @param e 鼠标点击事件 */ public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) { + //帮助弹窗 + if (this.isHelpBtnOnFocus()) { + new WidgetHelpDialog(DesignerContext.getDesignerFrame(), this.toData().getDescription()).showWindow(e); + return; + } FormDesigner designer = editingMouseListener.getDesigner(); SelectionModel selectionModel = editingMouseListener.getSelectionModel(); boolean isEditing = isEditable() || @@ -523,4 +581,12 @@ public class XWAbsoluteLayout extends XLayoutContainer { public boolean supportInnerOrderChangeActions() { return true; } + + /** + * 是否支持共享-现只支持报表块、图表、tab块、绝对布局 + * @return + */ + public boolean isSupportShared() { + return true; + } } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/com/fr/design/designer/creator/XWFitLayout.java index 614259bf30..722e866766 100644 --- a/designer-form/src/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/XWFitLayout.java @@ -28,14 +28,17 @@ import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; +import javax.swing.JOptionPane; + + /** * @author jim * @date 2014-6-23 */ public class XWFitLayout extends XLayoutContainer { - + private static final long serialVersionUID = 8112908607102660176L; - + //由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算 protected double containerPercent = 1.0; // 布局缩小的时候,考虑最小宽高,若挨着右侧或底侧边框的控件缩小后达到最小宽或高,此时容器大小微调下 @@ -50,7 +53,7 @@ public class XWFitLayout extends XLayoutContainer { public XWFitLayout(){ this(new WFitLayout(), new Dimension()); } - + public XWFitLayout(WFitLayout widget, Dimension initSize) { super(widget, initSize); @@ -58,17 +61,17 @@ public class XWFitLayout extends XLayoutContainer { widget.setResolutionScaling(containerPercent); } - + //根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90% private void initPercent(){ - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Dimension scrnsize = toolkit.getScreenSize(); - double screenValue = FRScreen.getByDimension(scrnsize).getValue(); - if(screenValue != FormArea.DEFAULT_SLIDER){ - this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); - } - } - + Toolkit toolkit = Toolkit.getDefaultToolkit(); + Dimension scrnsize = toolkit.getScreenSize(); + double screenValue = FRScreen.getByDimension(scrnsize).getValue(); + if(screenValue != FormArea.DEFAULT_SLIDER){ + this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); + } + } + @Override public LayoutAdapter getLayoutAdapter() { return new FRFitLayoutAdapter(this); @@ -79,15 +82,15 @@ public class XWFitLayout extends XLayoutContainer { this.setLayout(new FRFitLayout()); } - @Override + @Override protected String getIconName() { return "layout_absolute.png"; } - - /** - * 返回最右侧控件的微调宽度 - * @return 微调宽度 - */ + + /** + * 返回最右侧控件的微调宽度 + * @return 微调宽度 + */ public int getNeedAddWidth() { return needAddWidth; } @@ -96,10 +99,10 @@ public class XWFitLayout extends XLayoutContainer { this.needAddWidth = needAddWidth; } - /** - * 返回最右侧控件的微调高度 - * @return 微调宽度 - */ + /** + * 返回最右侧控件的微调高度 + * @return 微调宽度 + */ public int getNeedAddHeight() { return needAddHeight; } @@ -107,7 +110,7 @@ public class XWFitLayout extends XLayoutContainer { public void setNeedAddHeight(int needAddHeight) { this.needAddHeight = needAddHeight; } - + /** * 更新组件的backupBound * 拖动滑块改变容器大小,改变的是界面显示大小,更新bound,再次拖入或拉伸边框用到 @@ -119,7 +122,7 @@ public class XWFitLayout extends XLayoutContainer { creator.setBackupBound(comp.getBounds()); } } - + /** * 直接拖动滑条改变整体像素大小时,不用考虑控件的最小高度宽度,内部组件全部一起缩小放大 * 只是界面显示大小改变,不改变对应的BoundsWidget大小 @@ -172,7 +175,7 @@ public class XWFitLayout extends XLayoutContainer { } LayoutUtils.layoutContainer(this); } - + /** * 调整控件的point和size,避免拖动滑块出现空隙 */ @@ -216,20 +219,20 @@ public class XWFitLayout extends XLayoutContainer { * 获取内部组件横坐标的值 * @return int[] 横坐标数组 */ - + public int[] getHors(){ return getHors(false); } - + /** * 获取内部组件纵坐标值 * @return int[] 纵坐标数组 - * + * */ public int[] getVeris(){ return getVeris(false); } - + /** * 获取内部组件横坐标的值 * @param isActualSize 实际大小 @@ -254,12 +257,12 @@ public class XWFitLayout extends XLayoutContainer { Collections.sort(posX); return ArrayUtils.toPrimitive(posX.toArray(new Integer[]{posX.size()})); } - + /** * 获取内部组件纵坐标值 * @param isActualSize 实际大小 * @return int[] 纵坐标数组 - * + * */ public int[] getVeris(boolean isActualSize) { double perc = isActualSize ? containerPercent : 1.0; @@ -280,7 +283,7 @@ public class XWFitLayout extends XLayoutContainer { Collections.sort(posY); return ArrayUtils.toPrimitive(posY.toArray(new Integer[]{posY.size()})); } - + /** * 是否能缩小 * @param percent 百分比 @@ -294,10 +297,10 @@ public class XWFitLayout extends XLayoutContainer { } return canReduceSize; } - + /** * 按照百分比缩放内部组件宽度 - * + * * @param percent 宽度变化的百分比 */ public void adjustCreatorsWidth(double percent) { @@ -311,7 +314,7 @@ public class XWFitLayout extends XLayoutContainer { if (gap >0 && hasCalGap) { moveCompInterval(getAcualInterval()); } - layoutWidthResize(percent); + layoutWidthResize(percent); if (percent < 0 && needAddWidth > 0) { this.setSize(this.getWidth()+needAddWidth, this.getHeight()); modifyEdgemostCreator(true); @@ -321,7 +324,7 @@ public class XWFitLayout extends XLayoutContainer { updateWidgetBackupBounds(); LayoutUtils.layoutContainer(this); } - + // 手动修改宽高时,全部用的实际大小计算,所以最小值不用百分比计算后的 protected void layoutWidthResize(double percent) { int[] hroValues= toData().getHorComps(); @@ -336,11 +339,11 @@ public class XWFitLayout extends XLayoutContainer { //自适应布局里,控件的最小宽度为36 if (nextX-x < MIN_WIDTH-dw) { dw = MIN_WIDTH +x - nextX; - } + } caculateWidth(x, dw); } } - + /** * x位置的组件宽度按dw进行调整 */ @@ -365,7 +368,7 @@ public class XWFitLayout extends XLayoutContainer { calculateCreatorWidth(creator, rec, dw, x); } } - + private void calculateCreatorWidth(XCreator creator, Rectangle rec, int dw, int x) { if (x == 0) { int width = notHasRightCreator(rec) ? this.getWidth() : rec.width+dw; @@ -388,7 +391,7 @@ public class XWFitLayout extends XLayoutContainer { creator.adjustCompWidth((double) creator.getBounds().width / rec.width); toData().setBounds(creator.toData(), creator.getBounds()); } - + /** * 是否在布局最右侧 */ @@ -398,7 +401,7 @@ public class XWFitLayout extends XLayoutContainer { } return false; } - + /** * 是否在布局最下侧 */ @@ -408,7 +411,7 @@ public class XWFitLayout extends XLayoutContainer { } return false; } - + /** * 布局最右侧或下侧有控件在缩小时达到最小宽高,则微调下 */ @@ -424,7 +427,7 @@ public class XWFitLayout extends XLayoutContainer { } } } - + /** * 布局容器高度手动修改时, * 同时调整容器内的组件们,缩小时需要考虑有的组件高度不满足缩小高度 @@ -451,7 +454,7 @@ public class XWFitLayout extends XLayoutContainer { updateWidgetBackupBounds(); LayoutUtils.layoutContainer(this); } - + protected void layoutHeightResize(double percent) { int[] vertiValues= toData().getVertiComps(); int num=vertiValues.length; @@ -464,12 +467,12 @@ public class XWFitLayout extends XLayoutContainer { dh = (int) ((nextY-y)*percent); if (nextY-y < MIN_HEIGHT-dh) { dh = MIN_HEIGHT + y - nextY; - } + } calculateHeight(y, dh); } } - + /** * y位置的组件按dh进行调整 */ @@ -490,11 +493,11 @@ public class XWFitLayout extends XLayoutContainer { creator.setSize(rec.width, rec.height+dh); toData().setBounds(creator.toData(), creator.getBounds()); continue; - } + } calculateCreatorHeight(creator, rec, dh, y); } } - + private void calculateCreatorHeight(XCreator creator, Rectangle rec, int dh, int y) { if (y==0) { int height = notHasBottomCreator(rec) ? this.getHeight() : rec.height+dh; @@ -512,7 +515,7 @@ public class XWFitLayout extends XLayoutContainer { creator.adjustCompHeight((double) creator.getBounds().height / rec.height); toData().setBounds(creator.toData(), creator.getBounds()); } - + private List getCompsAtX(int x) { List comps = new ArrayList(); int size = toData().getWidgetCount(); @@ -529,7 +532,7 @@ public class XWFitLayout extends XLayoutContainer { } return comps; } - + private List getCompsAtY(int y) { List comps = new ArrayList(); for (int i=0,size=this.getComponentCount(); i comps) { //容器高度拉伸时,计算内部组件的最小高度 if (comps.isEmpty()) { - return 0; - } - int minH =this.getWidth(); - for (int i=0, size=comps.size(); icomps.get(i).getHeight() ? comps.get(i).getHeight() : minH; - } - return minH; - } - + return 0; + } + int minH =this.getWidth(); + for (int i=0, size=comps.size(); icomps.get(i).getHeight() ? comps.get(i).getHeight() : minH; + } + return minH; + } + /** * 初始化组件大小 * @return 默认大小 @@ -622,7 +625,7 @@ public class XWFitLayout extends XLayoutContainer { public Dimension initEditorSize() { return new Dimension(0, 0); } - + /** * f返回默认组件name * @return 容器名 @@ -630,16 +633,16 @@ public class XWFitLayout extends XLayoutContainer { public String createDefaultName() { return "fit"; } - + /** * 返回容器对应的wlayout * @return 同上 */ @Override - public WFitLayout toData() { - return (WFitLayout) data; - } - + public WFitLayout toData() { + return (WFitLayout) data; + } + /** * 当前组件zorder位置替换新的控件 * @param widget 控件 @@ -657,118 +660,136 @@ public class XWFitLayout extends XLayoutContainer { } return null; } - + @Override public Dimension getMinimumSize() { return toData().getMinDesignSize(); } - + + /** + * 将WLayout转换为XLayoutContainer + */ + public void convert() { + isRefreshing = true; + WFitLayout layout = this.toData(); + this.removeAll(); + for (int i=0, num=layout.getWidgetCount(); i childrenList = creator.getTargetChildrenList(); - if(!childrenList.isEmpty()){ - for(int i=0; i childrenList = creator.getTargetChildrenList(); + if(!childrenList.isEmpty()){ + for(int i=0; i 0) { for (int i=1, len=hors.length; i directions = new ArrayList(); - // 只要组件边框没有和container贴着的,都可以拉伸 - if (x > margin.getLeft()) { - directions.add(Direction.LEFT); - } - if (x+w < containerWidth - margin.getRight()) { - directions.add(Direction.RIGHT); - } - if (y > margin.getTop()) { - directions.add(Direction.TOP); - } - if (y+h < containerHeight - margin.getBottom()) { - directions.add(Direction.BOTTOM); - } - if (directions.isEmpty()) { - creator.setDirections(null); - }else { - creator.setDirections(ArrayUtils.toPrimitive(directions.toArray(new Integer[directions.size()]))); - } - } - - } - - - /** - * 间隔大于0时,界面处加上间隔 - * 界面的间隔是针对显示,实际保存的大小不受间隔影响 - * ps:改变布局大小或者拖入、删除、拉伸都要重新考虑间隔 - * @param gap 间隔 - */ - public void addCompInterval(int gap) { - if (gap == 0) { - return; - } - int val = gap/2; - for (int i=0, len=this.getComponentCount(); i 0) { - bound.x += val; - bound.width -= val; - } - if (rec.width+rec.x < this.getWidth()) { - bound.width -= val; - } - if (rec.y > 0) { - bound.y += val; - bound.height -= val; - } - if (rec.height+rec.y < this.getHeight()) { - bound.height -= val; - } - comp.setBounds(bound); - } - this.hasCalGap = true; - } - - /** - * 去除原有的间隔 - * @param gap 间隔 - */ - public void moveCompInterval(int gap) { - if (gap == 0) { - return; - } - int val = gap/2; - for (int i=0, len=this.getComponentCount(); i 0) { - bound.x -= val; - bound.width += val; - } - if (rec.width+rec.x < this.getWidth()) { - bound.width += val; - } - if (rec.y > 0) { - bound.y -= val; - bound.height += val; - } - if (rec.height+rec.y < this.getHeight()) { - bound.height += val; - } - comp.setBounds(bound); - } - this.hasCalGap = false; - } - - /** - * 是否可以加入当前间隔 - * @param interval 间隔 - * @return 默认返回true - */ - public boolean canAddInterval(int interval) { - int val = interval/2; - for (int i=0, len=this.getComponentCount(); i 0) { + } + + /** + * 在添加的时候需要把可拉伸的方向确定,所以重写了add方法 + * @param comp 组件 + * @param constraints 属性 + */ + public void add(Component comp, Object constraints) { + if (comp == null) { + return; + } + super.add(comp, constraints); + XCreator creator = (XCreator) comp; + dealDirections(creator, false); + } + + private void add(Component comp, Object constraints, boolean isInit) { + super.add(comp, constraints); + XCreator creator = (XCreator) comp; + dealDirections(creator, isInit); + } + + /** + * 处理自适应布局的directions + * @param xcreator 组件 + */ + public void dealDirections(XCreator xcreator, boolean isInit) { + if (xcreator == null) { + return; + } + // 重新打开模版时,容器还没初始化,大小都还为0 + int containerWidth = isInit ? toData().getContainerWidth() : this.getWidth(); + int containerHeight = isInit ? toData().getContainerHeight() : this.getHeight(); + PaddingMargin margin = isInit ? new PaddingMargin(0,0,0,0) : toData().getMargin(); + // 再次打开时和初始设计时的区别是没计算过内边距和没按屏幕分辨率调整大小 + for (int i=0; i directions = new ArrayList(); + // 只要组件边框没有和container贴着的,都可以拉伸 + if (x > margin.getLeft()) { + directions.add(Direction.LEFT); + } + if (x+w < containerWidth - margin.getRight()) { + directions.add(Direction.RIGHT); + } + if (y > margin.getTop()) { + directions.add(Direction.TOP); + } + if (y+h < containerHeight - margin.getBottom()) { + directions.add(Direction.BOTTOM); + } + if (directions.isEmpty()) { + creator.setDirections(null); + }else { + creator.setDirections(ArrayUtils.toPrimitive(directions.toArray(new Integer[directions.size()]))); + } + } + + } + + + /** + * 间隔大于0时,界面处加上间隔 + * 界面的间隔是针对显示,实际保存的大小不受间隔影响 + * ps:改变布局大小或者拖入、删除、拉伸都要重新考虑间隔 + * @param gap 间隔 + */ + public void addCompInterval(int gap) { + if (gap == 0) { + return; + } + int val = gap/2; + for (int i=0, len=this.getComponentCount(); i 0) { + bound.x += val; + bound.width -= val; + } + if (rec.width+rec.x < this.getWidth()) { + bound.width -= val; + } + if (rec.y > 0) { + bound.y += val; + bound.height -= val; + } + if (rec.height+rec.y < this.getHeight()) { + bound.height -= val; + } + comp.setBounds(bound); + } + this.hasCalGap = true; + } + + /** + * 去除原有的间隔 + * @param gap 间隔 + */ + public void moveCompInterval(int gap) { + if (gap == 0) { + return; + } + int val = gap/2; + for (int i=0, len=this.getComponentCount(); i 0) { + bound.x -= val; + bound.width += val; + } + if (rec.width+rec.x < this.getWidth()) { + bound.width += val; + } + if (rec.y > 0) { + bound.y -= val; + bound.height += val; + } + if (rec.height+rec.y < this.getHeight()) { + bound.height += val; + } + comp.setBounds(bound); + } + this.hasCalGap = false; + } + + /** + * 是否可以加入当前间隔 + * @param interval 间隔 + * @return 默认返回true + */ + public boolean canAddInterval(int interval) { + int val = interval/2; + for (int i=0, len=this.getComponentCount(); i 0) { bound.width -= val; } if (rec.width+rec.x < d.width) { @@ -984,106 +1007,106 @@ public class XWFitLayout extends XLayoutContainer { bound.height -= val; } return new Rectangle(bound); - } - - /** - * 缩小宽度或者高度时 存在间隔的话是否支持缩小 - */ - private boolean canReduceSize(double percent) { - int val = toData().getCompInterval()/2; - for (int i=0, len=this.getComponentCount(); i position.getY()); } //将当前switchButton改为选中状态 - private void changeButtonState(int index){ - for(int i=0;i"); - for(int i = 0; i < titleText.length(); i++){ - titleString.append(titleText.charAt(i)).append("
"); - } - titleString.append(""); - titleText = titleString.toString(); - } - } - this.setButtonText(titleText); - if (this.cardLayout == null) { - initRelateLayout(this); - } - - LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle(); - - // 标题部分 - WidgetTitle title = style.getTitle(); - FRFont font = title.getFrFont(); - FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST); + FRFont font = widgetTitle.getFrFont(); + FRFont newFont = FRFont.getInstance(font.getName(),font.getStyle(),font.getSize() + FONT_SIZE_ADJUST); UILabel label = this.getContentLabel(); label.setFont(newFont); label.setForeground(font.getForeground()); - Background background = title.getBackground(); - if (background != null) { - if(button.isShowButton() && selectBackground != null){ - this.setContentBackground(selectBackground); - }else if (button.isShowButton() && selectBackground == null){ - background = ColorBackground.getInstance(CHOOSED_GRAL); - this.setContentBackground(background); - } else { - this.setContentBackground(background); - } + + } + + private WidgetTitle getWidgetTitle() { + if (this.cardLayout == null) { + initRelateLayout(); } + LayoutBorderStyle style = this.cardLayout.toData().getBorderStyle(); + return style.getTitle(); } //删除tab布局 - private void deleteTabLayout(SelectionModel selectionModel,FormDesigner designer){ + private void deleteTabLayout(SelectionModel selectionModel, FormDesigner designer){ String titleName = this.getContentLabel().getText(); int value = JOptionPane.showConfirmDialog(null, Inter.getLocText("FR-Designer_ConfirmDialog_Content") + "“" + titleName + "”", Inter.getLocText("FR-Designer_ConfirmDialog_Title"),JOptionPane.YES_NO_OPTION); @@ -427,6 +399,10 @@ public class XCardSwitchButton extends XButton { public XCreator getXCreator() { //根据index获取对应的tabFitLayout int index = ((CardSwitchButton) this.toData()).getIndex(); + //关闭重新打开,相关的layout未存到xml中,初始化 + if(cardLayout == null){ + initRelateLayout(); + } return (XCreator) cardLayout.getComponent(index); } @@ -437,9 +413,89 @@ public class XCardSwitchButton extends XButton { label = this.getContentLabel(); } + @Override public void firePropertyChange() { super.firePropertyChange(); tagLayout.setTabsAndAdjust(); repaint(); } + + @Override + protected UILabel initContentLabel() { + return new CardSwitchBtnLabel(); + } + + public class CardSwitchBtnLabel extends UILabel { + + public CardSwitchBtnLabel() { + updateUI(); + } + + @Override + public void updateUI() { + setUI(new CardSwitchBtnLabelUI()); + } + } + + + public class CardSwitchBtnLabelUI extends BasicLabelUI { + private static final int DOT_COUNT = 3; + private static final String DOT = "."; + private static final int DOTS_LINESPACE = 6; + private static final int DOTS_HEIGHT = 10; + + @Override + public void paint(Graphics g, JComponent c) { + WCardTagLayout wCardTagLayout = (WCardTagLayout) tagLayout.toData(); + if (ComparatorUtils.equals(wCardTagLayout.getTextDirection(), WTabTextDirection.TEXT_VER_DIRECTION)) { + //绘制文本竖排展示 + paintVerticalText(g); + } else { + super.paint(g, c); + } + } + + private void paintVerticalText(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + int width = XCardSwitchButton.this.getWidth(); + int height = XCardSwitchButton.this.getHeight(); + CardSwitchButton button = (CardSwitchButton) XCardSwitchButton.this.toData(); + String titleText = button.getText(); + java.util.List verticalTextList = new ArrayList(); + StringBuilder titleStringBuf = new StringBuilder(); + WidgetTitle title = getWidgetTitle(); + FRFont font = title.getFrFont(); + FRFont newFont = FRFont.getInstance(font.getName(), font.getStyle(), font.getSize() + FONT_SIZE_ADJUST); + FontMetrics fm = GraphHelper.getFontMetrics(newFont); + for (int i = 0; i < titleText.length(); i++) { + titleStringBuf.append(titleText.charAt(i)); + verticalTextList.add(titleStringBuf.substring(0, titleStringBuf.length())); + titleStringBuf.delete(0, titleStringBuf.length()); + } + int textAscent = fm.getAscent(); + int textHeight = fm.getHeight(); + int textY = 0; + textY += textAscent; + for (int i = 0; i < verticalTextList.size(); i++) { + String paint_str = (String) verticalTextList.get(i); + + GraphHelper.drawString(g2d, paint_str, (width - fm.stringWidth(paint_str)) / 2, textY); + textY += textHeight; + textY += PT.pt2pix(0, RESLUTION); + if (textY > height - textHeight && i < verticalTextList.size() - 1) { + textY -= DOTS_HEIGHT; + paintDots(g2d, textY, (width - fm.stringWidth(paint_str)) / 2); + break; + } + } + } + + public void paintDots(Graphics2D g2d, int startY, int startX) { + for (int i = 0; i < DOT_COUNT; i++) { + GraphHelper.drawString(g2d, DOT, startX, startY); + startY += DOTS_LINESPACE; + startY += PT.pt2pix(0, RESLUTION); + } + } + } } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java index 6beadc2920..adc2031294 100644 --- a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java @@ -31,8 +31,11 @@ import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout; +import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import com.fr.general.cardtag.DefaultTemplateStyle; +import com.fr.general.cardtag.TemplateStyle; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; import com.fr.stable.core.PropertyChangeAdapter; @@ -40,9 +43,11 @@ import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.border.Border; import java.awt.CardLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Dimension; import java.awt.event.ContainerEvent; import java.beans.IntrospectionException; +import java.util.List; /** * @author richer @@ -55,6 +60,11 @@ public class XWCardLayout extends XLayoutContainer { private static final int NORTH = 0; private FormDesigner designer; + private static final int LAYOUT_INDEX = 0; + + public static final String DEFAULT_NAME = "cardlayout"; + + //默认蓝色标题背景 private static final Color TITLE_COLOR = new Color(51, 132, 240); @@ -76,8 +86,9 @@ public class XWCardLayout extends XLayoutContainer { * @date 2014-11-25-下午6:22:40 * */ + @Override public String createDefaultName() { - return "cardlayout"; + return DEFAULT_NAME; } /** @@ -89,7 +100,8 @@ public class XWCardLayout extends XLayoutContainer { * @date 2014-11-25-下午6:22:17 * */ - public WCardLayout toData() { + @Override + public WCardLayout toData() { return (WCardLayout) data; } @@ -97,6 +109,7 @@ public class XWCardLayout extends XLayoutContainer { * 初始化时默认的组件大小 * @return 默认Dimension */ + @Override public Dimension initEditorSize() { return new Dimension(500, 300); } @@ -150,6 +163,7 @@ public class XWCardLayout extends XLayoutContainer { * @date 2014-11-25-下午4:47:23 * */ + @Override protected XLayoutContainer getCreatorWrapper(String widgetName) { initStyle(); Dimension dimension = new Dimension(); @@ -201,6 +215,7 @@ public class XWCardLayout extends XLayoutContainer { Dimension dimension = new Dimension(); //放置标题的tab流式布局 WCardTagLayout tagLayout = new WCardTagLayout("tabpane" + widgetName.replaceAll(createDefaultName(), "")); + tagLayout.setNewTab(true); XWCardTagLayout xTag = new XWCardTagLayout(tagLayout, dimension, this); xTag.setBackupParent(xTitle); @@ -214,25 +229,33 @@ public class XWCardLayout extends XLayoutContainer { private XCardSwitchButton initFirstButton(String widgetName, XWCardTagLayout xTag){ CardSwitchButton firstBtn = new CardSwitchButton(widgetName); firstBtn.setText(Inter.getLocText("FR-Designer_Title") + 0); - firstBtn.setInitialBackground(ColorBackground.getInstance(Color.WHITE)); - firstBtn.setCustomStyle(true); xTag.setCurrentCard(firstBtn); XCardSwitchButton xFirstBtn = new XCardSwitchButton(firstBtn, new Dimension(CardSwitchButton.DEF_WIDTH, -1), this, xTag); xFirstBtn.setBackupParent(xTag); - return xFirstBtn; } - + + /** + * 控件树不显示此组件 + * @param path 控件树list + */ + @Override + public void notShowInComponentTree(List path) { + path.remove(LAYOUT_INDEX); + } + + /** * 设置父容器的名字 - * + * * @param parentPanel 当前父容器 * @param widgetName 当前控件名 - * + * * * @date 2014-11-27-上午9:47:00 - * + * */ + @Override protected void setWrapperName(XLayoutContainer parentPanel, String widgetName) { parentPanel.toData().setWidgetName("tablayout" + widgetName.replaceAll(createDefaultName(),"")); } @@ -246,7 +269,8 @@ public class XWCardLayout extends XLayoutContainer { * @date 2014-11-25-下午4:57:55 * */ - protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){ + @Override + protected void addToWrapper(XLayoutContainer parentPanel, int width, int minHeight){ parentPanel.add(this, WBorderLayout.CENTER); } @@ -259,7 +283,8 @@ public class XWCardLayout extends XLayoutContainer { * @date 2014-11-25-下午6:20:10 * */ - public void componentAdded(ContainerEvent e) { + @Override + public void componentAdded(ContainerEvent e) { if (isRefreshing) { return; } @@ -284,6 +309,7 @@ public class XWCardLayout extends XLayoutContainer { * 是否支持标题样式 * @return 默认false */ + @Override public boolean hasTitleStyle() { return true; } @@ -293,6 +319,7 @@ public class XWCardLayout extends XLayoutContainer { * @return 属性名 * @throws IntrospectionException */ + @Override public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { //嵌套的tab组件,内层的不支持轮播属性,屏蔽属性表 if(!isNested()) { @@ -379,7 +406,8 @@ public class XWCardLayout extends XLayoutContainer { } //初始化样式 - protected void initStyle() { + @Override + protected void initStyle() { LayoutBorderStyle style = toData().getBorderStyle(); initBorderTitleStyle(style); initBorderStyle(); @@ -432,12 +460,14 @@ public class XWCardLayout extends XLayoutContainer { * @param designer 表单设计器 * */ - public void deleteRelatedComponent(XCreator creator,FormDesigner designer){ + @Override + public void deleteRelatedComponent(XCreator creator, FormDesigner designer){ XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) creator.getBackupParent(); SelectionModel selectionModel = designer.getSelectionModel(); selectionModel.setSelectedCreator(mainLayout); selectionModel.deleteSelection(); } + @Override public void setBorder(Border border) { super.setBorder(border); @@ -461,8 +491,22 @@ public class XWCardLayout extends XLayoutContainer { * data属性改变触发其他操作 * */ + @Override public void firePropertyChange(){ initStyle(); } + public void resetTabBackground(TemplateStyle templateStyle){ + for (int i = 0; i < this.getXCreatorCount(); i++) { + XWTabFitLayout xCreator = (XWTabFitLayout)this.getXCreator(i); + WTabFitLayout wTabFitLayout = (WTabFitLayout)xCreator.toData(); + boolean defaultStyle = ComparatorUtils.equals(templateStyle.getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE); + wTabFitLayout.setInitialBackground(defaultStyle ? null : templateStyle.getTabDefaultBackground()); + wTabFitLayout.setOverBackground(null); + wTabFitLayout.setClickBackground(null); + wTabFitLayout.setCustomStyle(!defaultStyle); + xCreator.checkButonType(); + } + } + } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 42a940d062..a8f6d2d5e3 100644 --- a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -3,22 +3,38 @@ */ package com.fr.design.designer.creator.cardlayout; +import com.fr.base.GraphHelper; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; +import com.fr.design.designer.beans.LayoutAdapter; +import com.fr.design.designer.beans.adapters.layout.FRCardMainBorderLayoutAdapter; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWBorderLayout; +import com.fr.design.designer.creator.XWidgetCreator; +import com.fr.design.form.util.XCreatorConstants; import com.fr.design.icon.IconPathConstants; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.form.event.Listener; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; import com.fr.form.ui.container.WBorderLayout; +import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WTabDisplayPosition; +import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; +import com.fr.form.ui.container.cardlayout.WCardTitleLayout; +import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.general.Inter; +import com.fr.stable.Constants; + import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Component; @@ -27,9 +43,11 @@ import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Rectangle; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; import java.util.ArrayList; +import java.util.List; /** * card布局主体框架 @@ -38,17 +56,17 @@ import java.util.ArrayList; * * @date: 2014-12-9-下午9:59:31 */ -public class XWCardMainBorderLayout extends XWBorderLayout{ +public class XWCardMainBorderLayout extends XWBorderLayout { private static final int CENTER = 1; private static final int NORTH = 0; - public static final Color DEFAULT_BORDER_COLOR = new Color(210,210,210); - private static final int LAYOUT_INDEX = 0; private static final int TITLE_STYLE = 2; - private static final int NORMAL_STYLE = 1; - private static final int EDIT_BTN_WIDTH = 60; - private static final int EDIT_BTN_HEIGHT = 24; + private static final int EDIT_BTN_WIDTH = 75; + private static final int EDIT_BTN_HEIGHT = 20; + private static final int BORDER_WIDTH = 1; + + private final int CARDMAINLAYOUT_CHILD_COUNT = 1; /** * 构造函数 @@ -66,6 +84,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ * @date 2014-12-10-下午1:46:33 * */ + @Override public WCardMainBorderLayout toData() { return (WCardMainBorderLayout) super.toData(); } @@ -84,15 +103,86 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ this.add(title, position); } + public int getTitleWidth(){ + String position = toData().getTabPosition(); + if(ComparatorUtils.equals(WBorderLayout.NORTH, position) || ComparatorUtils.equals(WBorderLayout.SOUTH, position)){ + return getTitlePart().getHeight(); + } + return getTitlePart().getWidth(); + } + public void add(Component comp, String position) { super.add(comp, position); } + + /** + * 将WLayout转换为XLayoutContainer + */ + @Override + public void convert() { + isRefreshing = true; + WBorderLayout wb = this.toData(); + this.removeAll(); + String[] arrs = {WBorderLayout.NORTH, WBorderLayout.SOUTH, WBorderLayout.EAST, WBorderLayout.WEST, WBorderLayout.CENTER}; + for (int i = 0; i < arrs.length; i++) { + Widget wgt = wb.getLayoutWidget(arrs[i]); + //用来兼容之前titlePart设置不可见 + if (wgt != null && ComparatorUtils.equals(arrs[i], WBorderLayout.NORTH) && !wgt.isVisible()) { + wgt.setVisible(true); + this.toData().setNorthSize(0); + } + if (wgt != null) { + XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(wgt, calculatePreferredSize(wgt)); + this.add(comp, arrs[i]); + comp.setBackupParent(this); + } + } + dealCompatibility(wb); + + isRefreshing = false; + } + + private void dealCompatibility(WBorderLayout wb){ + WCardMainBorderLayout ob = (WCardMainBorderLayout)wb; + WCardLayout cardLayout = ob.getCardPart(); + //tab结构改变需要兼容以前的tab,重新命名tabpane + WCardTitleLayout wCardTitleLayout = ob.getTitlePart(); + if(cardLayout == null || wCardTitleLayout == null){ + return; + } + WCardTagLayout wCardTagLayout = wCardTitleLayout.getTagPart(); + String tabpaneName = cardLayout.getWidgetName(); + if (!wCardTagLayout.isNewTab()) { + wCardTagLayout.setWidgetName(tabpaneName); + LayoutBorderStyle borderStyle = cardLayout.getBorderStyle(); + if(borderStyle != null){ + //新tab默认都有标题 + borderStyle.setType(LayoutBorderStyle.TITLE); + } + cardLayout.setWidgetName(XWCardLayout.DEFAULT_NAME + tabpaneName.replaceAll(XWCardTagLayout.DEFAULT_NAME, "")); + wCardTitleLayout.setCardName(cardLayout.getWidgetName()); + wCardTagLayout.setNewTab(true); + //这边需要设置成默认值兼容之前的title高度(不知道为啥之前的title的高度会改变) + if(this.toData().getNorthSize() != 0){ + ob.setNorthSize(WTitleLayout.TITLE_HEIGHT); + } + for(int i = 0 ;i < cardLayout.getListenerSize(); i ++){ + Listener listener = cardLayout.getListener(i); + if(listener != null){ + wCardTagLayout.addListener(listener); + } + } + cardLayout.clearListeners(); + } + } + /** * 切换到非添加状态 * * @return designer 表单设计器 */ + @Override public void stopAddingState(FormDesigner designer){ designer.stopAddingState(); return; @@ -119,7 +209,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ public XWCardTitleLayout getTitlePart(){ Component[] components = this.getComponents(); for(Component component : components){ - if(component instanceof XWCardTitleLayout){ + if(component instanceof XWCardTitleLayout){ return (XWCardTitleLayout)component; } } @@ -141,8 +231,14 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ * 控件树不显示此组件 * @param path 控件树list */ - public void notShowInComponentTree(ArrayList path) { - path.remove(LAYOUT_INDEX); + @Override + public void notShowInComponentTree(List path) { + return; + } + + @Override + public int getShowXCreatorCount() { + return CARDMAINLAYOUT_CHILD_COUNT; } @Override @@ -160,7 +256,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ * 重新调整子组件的宽度 * @param width 宽度 */ - public void recalculateChildWidth(int width){ + @Override + public void recalculateChildWidth(int width){ ArrayList childrenList = this.getTargetChildrenList(); int size = childrenList.size(); if (size > 0) { @@ -191,7 +288,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ * 重新调整子组件的高度 * @param height 高度 */ - public void recalculateChildHeight(int height){ + @Override + public void recalculateChildHeight(int height){ ArrayList childrenList = this.getTargetChildrenList(); int size = childrenList.size(); if (size > 0) { @@ -223,6 +321,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ } + @Override public void paint(Graphics g) { super.paint(g); //如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层 @@ -235,15 +334,19 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ Graphics2D g2d = (Graphics2D) g; Composite oldComposite = g2d.getComposite(); //画白色的编辑层 - g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F)); - g2d.setColor(Color.WHITE); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 50 / 100.0F)); + g2d.setColor(XCreatorConstants.COVER_COLOR); g2d.fillRect(x, y, w, h); //画编辑按钮所在框 + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR ? 0.9f : 0.7f); + g2d.setColor(XCreatorConstants.EDIT_COLOR); + g2d.setComposite(alphaComposite); + g2d.fillRoundRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT, 4, 4); g2d.setComposite(oldComposite); - g2d.setColor(new Color(176, 196, 222)); - g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT); + //画编辑按钮图标 - BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH); + BufferedImage image = IOUtils.readImage(IconPathConstants.EDIT_ICON_PATH); g2d.drawImage( image, (x + w / 2 - 23), @@ -253,9 +356,18 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ null, this ); - g2d.setColor(Color.BLACK); + g2d.setColor(Color.WHITE); //画编辑文字 g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5); + g.setColor(XCreatorConstants.FORM_BORDER_COLOR); + GraphHelper.draw(g, new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - BORDER_WIDTH * 2, getHeight() - BORDER_WIDTH * 2), Constants.LINE_MEDIUM); + } + } + + @Override + public void paintBorder(Graphics g, Rectangle bounds){ + if (!isMouseEnter) { + super.paintBorder(g, bounds); } } @@ -265,7 +377,8 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ * @param editingMouseListener 鼠标点击,位置处理器 * @param e 鼠标点击事件 */ - public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ + @Override + public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e){ FormDesigner designer = editingMouseListener.getDesigner(); SelectionModel selectionModel = editingMouseListener.getSelectionModel(); boolean isEditing = e.getButton() == MouseEvent.BUTTON1 && @@ -289,43 +402,57 @@ public class XWCardMainBorderLayout extends XWBorderLayout{ */ @Override public XLayoutContainer getTopLayout() { - XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout(); - if (xTopLayout != null && !xTopLayout.isEditable()){ - return xTopLayout; - } - else{ return this; - } + } + + @Override + public int getIndexOfChild(Object child) { + XWCardTitleLayout titlePart = this.getTitlePart(); + return titlePart.getIndexOfChild(child); } /** * data属性改变触发其他操作 * */ + @Override public void firePropertyChange(){ - getCardPart().initStyle(); + return; } public void resetTabDisplayPosition(WTabDisplayPosition wTabDisplayPosition){ XWCardTitleLayout xwCardTitleLayout = getTitlePart(); + int titleSize = getTitleWidth(); xwCardTitleLayout.resetNewBtnPosition(wTabDisplayPosition); + Rectangle parentBounds = new Rectangle(xwCardTitleLayout.getBounds()); switch (wTabDisplayPosition){ case TOP_POSITION: - this.addTitlePart(getTitlePart(),WBorderLayout.NORTH); + this.addTitlePart(xwCardTitleLayout, WBorderLayout.NORTH); + parentBounds.height = titleSize; break; case LEFT_POSITION: - this.addTitlePart(getTitlePart(),WBorderLayout.WEST); + this.addTitlePart(xwCardTitleLayout, WBorderLayout.WEST); + parentBounds.width = titleSize; break; case BOTTOM_POSITION: - this.addTitlePart(getTitlePart(),WBorderLayout.SOUTH); + this.addTitlePart(xwCardTitleLayout, WBorderLayout.SOUTH); + parentBounds.height = titleSize; break; case RIGHT_POSITION: - this.addTitlePart(getTitlePart(),WBorderLayout.EAST); + this.addTitlePart(xwCardTitleLayout, WBorderLayout.EAST); + parentBounds.width = titleSize; break; default: break; } + xwCardTitleLayout.setBounds(parentBounds); this.addCardPart((XWCardLayout)this.getComponent(0)); } + + @Override + public LayoutAdapter getLayoutAdapter() { + return new FRCardMainBorderLayoutAdapter(this); + } + } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java index 10c1f3a253..f0d155f7af 100644 --- a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java @@ -25,23 +25,23 @@ import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.Widget; +import com.fr.form.ui.WidgetTitle; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; +import com.fr.general.cardtag.DefaultTemplateStyle; import javax.swing.border.Border; -import java.awt.Component; import java.awt.Dimension; -import java.awt.Font; import java.awt.FontMetrics; import java.awt.Rectangle; import java.awt.event.ContainerEvent; import java.awt.event.MouseEvent; -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -64,7 +64,9 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { private static final int HEIGHT_SIDE_OFFSET = 20; - private static final int DEFAULT_BUTTON_HEIGHT = 40; + private static final int DEFAULT_VERTICAL_SPACING = 3; + + public static final String DEFAULT_NAME = "tabpane"; public CardSwitchButton getCurrentCard() { return currentCard; @@ -119,6 +121,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { * @param e 事件 * @date 2014-11-25-下午6:20:10 */ + @Override public void componentAdded(ContainerEvent e) { super.componentAdded(e); @@ -136,7 +139,14 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard); fitLayout.setTabNameIndex(getTabNameIndex()); XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension()); + WCardTagLayout layout = (WCardTagLayout) this.toData(); + + if(!ComparatorUtils.equals(layout.getTemplateStyle().getStyle(), DefaultTemplateStyle.DEFAULT_TEMPLATE_STYLE)){ + fitLayout.setInitialBackground(layout.getTemplateStyle().getTabDefaultBackground()); + fitLayout.setCustomStyle(true); + } tabFitLayout.setxCardSwitchButton((XCardSwitchButton)this.getComponent(0)); + tabFitLayout.checkButonType(); tabFitLayout.setBackupParent(cardLayout); cardLayout.add(tabFitLayout, widgetName); this.cardLayout.toData().setShowIndex(index); @@ -144,6 +154,11 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { } + @Override + protected String getIconName() { + return "tabpane.png"; + } + private void initCardLayout() { XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.getBackupParent(); XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout) titleLayout.getBackupParent(); @@ -153,6 +168,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { /** * 将WLayout转换为XLayoutContainer */ + @Override public void convert() { isRefreshing = true; WCardTagLayout layout = (WCardTagLayout) this.toData(); @@ -169,8 +185,9 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { isRefreshing = false; } + @Override public String createDefaultName() { - return "tabpane"; + return DEFAULT_NAME; } /** @@ -178,6 +195,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { * * @return designer 表单设计器 */ + @Override public void stopAddingState(FormDesigner designer) { designer.stopAddingState(); } @@ -212,6 +230,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { * * @param */ + @Override public void setBorder(Border border) { } @@ -244,10 +263,12 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { return UIPopupMenu.EMPTY; // 不要菜单 } + @Override public int[] getDirections() { return ((XCreator)getParent()).getDirections(); } + @Override public Rectangle getBounds() { return this.getParent().getBounds(); } @@ -257,13 +278,21 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { return this.getBackupParent().getTopLayout(); } - public void notShowInComponentTree(ArrayList path) { - path.remove(0); + + @Override + public int getIndexOfChild(Object child) { + XLayoutContainer cardPart = ((XWCardMainBorderLayout)this.getTopLayout()).getCardPart(); + return cardPart.getIndexOfChild(child); } + @Override + public boolean isSupportDrag(){ + return false; + } @Override public void doLayout() { + setTabsAndAdjust(); //设置布局 super.doLayout(); } @@ -304,6 +333,7 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { * data属性改变触发其他操作 * */ + @Override public void firePropertyChange() { WCardTagLayout wCardTagLayout = (WCardTagLayout) this.toData(); ((XWCardMainBorderLayout) getTopLayout()).resetTabDisplayPosition(wCardTagLayout.getDisplayPosition()); @@ -313,77 +343,68 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { repaint(); } - public void setTabsAndAdjust() { - WCardTagLayout wCardTagLayout = (WCardTagLayout)this.toData(); + WCardTagLayout wCardTagLayout = (WCardTagLayout) this.toData(); int tabLength = this.getComponentCount(); - Map cardWidth = new HashMap<>(); - Map cardHeight = new HashMap<>(); + Map cardWidth = new HashMap(); + Map cardHeight = new HashMap(); + XLayoutContainer parent = this.getBackupParent(); + for (int i = 0; i < tabLength; i++) { XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); CardSwitchButton tempCard = (CardSwitchButton) temp.toData(); String tempText = tempCard.getText(); - Font f = tempCard.getFont(); + if (this.cardLayout == null) { + initCardLayout(); + } + LayoutBorderStyle borderStyle = this.cardLayout.toData().getBorderStyle(); + WidgetTitle title = borderStyle.getTitle(); + FRFont f = title.getFrFont(); FontMetrics fm = GraphHelper.getFontMetrics(f); - switch (wCardTagLayout.getTextDirection()){ + switch (wCardTagLayout.getTextDirection()) { case TEXT_HORI_DERECTION: - cardWidth.put(i,fm.stringWidth(tempText)); - cardHeight.put(i,fm.getHeight()); + cardWidth.put(i, fm.stringWidth(tempText)); + cardHeight.put(i, fm.getHeight()); break; case TEXT_VER_DIRECTION: int perHeight = fm.getHeight(); int wordCount = tempText.length(); - if(tempText.length() !=0 ){ - cardWidth.put(i,fm.stringWidth(tempText)/tempText.length()); - }else { + if (tempText.length() != 0) { + cardWidth.put(i, fm.stringWidth(tempText) / tempText.length()); + } else { cardWidth.put(i, 0); } - cardHeight.put(i,(perHeight+3)*wordCount); + cardHeight.put(i, (perHeight + DEFAULT_VERTICAL_SPACING) * wordCount); break; default: break; } } - if(isHori()){ - adjustTabsH(tabLength, cardWidth, cardHeight); - }else { - adjustTabsV(tabLength, cardWidth, cardHeight); + if (isHori()) { + adjustTabsH(parent, tabLength, cardWidth, cardHeight); + } else { + adjustTabsV(parent, tabLength, cardWidth, cardHeight); } + fixTitleLayout(parent); } - public void adjustTabsH(int tabLength, Map width, Map height) { + public void adjustTabsH(XLayoutContainer parent, int tabLength, Map width, Map height) { if (width == null) { return; } + int tabPaneSize = parent.getHeight(); //调整XWCardTagLayout的高度 int tempX = 0; - int maxHeight = DEFAULT_BUTTON_HEIGHT; for (int i = 0; i < tabLength; i++) { - Rectangle rectangle = this.getComponent(i).getBounds(); Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET; - Integer cardHeight = height.get(i)+ HEIGHT_SIDE_OFFSET ; - if(cardHeight < DEFAULT_BUTTON_HEIGHT){ - cardHeight = DEFAULT_BUTTON_HEIGHT; - } - maxHeight = maxHeight > cardHeight ? maxHeight : cardHeight ; + Integer cardHeight = tabPaneSize; rectangle.setBounds(tempX, 0, cardWidth, cardHeight); tempX += cardWidth; XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); setTabBtnSize(cardWidth, cardHeight, temp); } - - FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - XLayoutContainer parent = this.getBackupParent(); - Rectangle parentBounds = new Rectangle(parent.getBounds()); - parentBounds.height = maxHeight; - parent.setBounds(parentBounds); - LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent); - if (layoutAdapter != null) { - parent.setBackupBound(parent.getBounds()); - layoutAdapter.fix(parent); - } } public void setTabBtnSize(int cardWidth, int cardHeight, XCardSwitchButton temp){ @@ -401,36 +422,27 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { } - public void adjustTabsV(int tabLength, Map width, Map height) { + public void adjustTabsV(XLayoutContainer parent, int tabLength, Map width, Map height) { if (width == null) { return; } + int tabPaneSize = parent.getWidth(); int tempY = 0; - int maxWidth = DEFAULT_BUTTON_HEIGHT; for (int i = 0; i < tabLength; i++) { Rectangle rectangle = this.getComponent(i).getBounds(); - Integer cardWidth = width.get(i) + WIDTH_SIDE_OFFSET; - maxWidth = maxWidth > cardWidth ? maxWidth : cardWidth; + Integer cardWidth = tabPaneSize; //先用这边的固定高度 Integer cardHeight = height.get(i) + HEIGHT_SIDE_OFFSET; - - if(cardWidth < DEFAULT_BUTTON_HEIGHT){ - cardWidth = DEFAULT_BUTTON_HEIGHT; - } - if(cardHeight < DEFAULT_BUTTON_HEIGHT){ - cardHeight = DEFAULT_BUTTON_HEIGHT; - } rectangle.setBounds(0, tempY, cardWidth, cardHeight); tempY += cardHeight; XCardSwitchButton temp = (XCardSwitchButton) this.getComponent(i); setTabBtnSize(cardWidth, cardHeight, temp); } + } + + private void fixTitleLayout(XLayoutContainer parent){ FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - XLayoutContainer parent = this.getBackupParent(); - Rectangle parentBounds = new Rectangle(parent.getBounds()); - parentBounds.width = maxWidth; - parent.setBounds(parentBounds); LayoutAdapter layoutAdapter = AdapterBus.searchLayoutAdapter(formDesigner, parent); if (layoutAdapter != null) { parent.setBackupBound(parent.getBounds()); diff --git a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java index f2b3902f8c..babc54b316 100644 --- a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardTitleLayout.java @@ -3,11 +3,6 @@ */ package com.fr.design.designer.creator.cardlayout; -import java.awt.Dimension; -import java.awt.event.MouseEvent; - -import javax.swing.border.Border; - import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.ComponentAdapter; import com.fr.design.designer.beans.models.SelectionModel; @@ -24,6 +19,12 @@ import com.fr.form.ui.container.WTabDisplayPosition; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout; +import javax.swing.border.Border; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.MouseEvent; +import java.util.List; + /** * * @@ -33,6 +34,11 @@ public class XWCardTitleLayout extends XWBorderLayout { private static final int CENTER = 1; + private static final int LAYOUT_INDEX = 0; + + private static final int POSISIONT_OFFSET = 1; + + /** * 构造函数 */ @@ -47,19 +53,48 @@ public class XWCardTitleLayout extends XWBorderLayout { super(widget, initSize); } + /** + * 初始化组件大小,titlePart的宽高可能为0 + */ + @Override + public void setInitSize(Dimension initSize){ + return; + } + public WTabDisplayPosition getDisplayPosition(){ return ((WCardTagLayout)this.getTagPart().toData()).getDisplayPosition(); } + + /** + * 控件树不显示此组件 + * @param path 控件树list + */ + @Override + public void notShowInComponentTree(List path) { + path.remove(LAYOUT_INDEX); + } + + @Override + public int getIndexOfChild(Object child) { + int count = getComponentCount(); + for (int i = 0; i < count; i++) { + Component comp = getComponent(i); + if (comp == child) { + return i - POSISIONT_OFFSET; + } + } + return -1; + } /** * 将WLayout转换为XLayoutContainer */ + @Override public void convert(){ isRefreshing = true; WCardTitleLayout titleLayout = (WCardTitleLayout)this.toData(); - this.setVisible(titleLayout.isVisible()); - this.removeAll(); + this.removeAll(); String[] arrs = {WBorderLayout.NORTH, WBorderLayout.SOUTH, WBorderLayout.EAST, WBorderLayout.WEST, WBorderLayout.CENTER}; for (int i = 0; i < arrs.length; i++) { Widget wgt = titleLayout.getLayoutWidget(arrs[i]); @@ -139,7 +174,8 @@ public class XWCardTitleLayout extends XWBorderLayout { * * @return designer 表单设计器 */ - public void stopAddingState(FormDesigner designer){ + @Override + public void stopAddingState(FormDesigner designer){ designer.stopAddingState(); return; } @@ -182,6 +218,7 @@ public class XWCardTitleLayout extends XWBorderLayout { return this.getBackupParent().getTopLayout(); } + @Override public String createDefaultName() { return "tabpane"; } @@ -191,5 +228,5 @@ public class XWCardTitleLayout extends XWBorderLayout { public XCreator getXCreator() { return (XCreator)this.getComponent(1); } - + } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java index b93451488c..0e500bc849 100644 --- a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java @@ -1,7 +1,6 @@ package com.fr.design.designer.creator.cardlayout; import com.fr.base.GraphHelper; -import com.fr.base.background.ColorBackground; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter; import com.fr.design.designer.beans.models.SelectionModel; @@ -23,7 +22,6 @@ import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.general.Background; import com.fr.general.Inter; -import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.core.PropertyChangeAdapter; @@ -43,7 +41,7 @@ import java.beans.IntrospectionException; */ public class XWTabFitLayout extends XWFitLayout { - private static final int MIN_SIZE = 1; + private static final int MIN_SIZE = 0; private static final int WIDTH_SIDE_OFFSET = 57; @@ -104,16 +102,27 @@ public class XWTabFitLayout extends XWFitLayout { super(widget, initSize); } + public WTabFitLayout getWTabFitLayout(){ + return (WTabFitLayout)data; + } + @Override public UIPopupMenu createPopupMenu(FormDesigner formDesigner) { return UIPopupMenu.EMPTY; // 不要菜单 } + @Override + protected String getIconName() { + return "tab_fit_layout.png"; + } + + /** * 得到属性名 * @return 属性名 * @throws IntrospectionException */ + @Override public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { checkButonType(); CRPropertyDescriptor[] crp = ((WTabFitLayout) data).isCustomStyle() ? getisCustomStyle() : getisnotCustomStyle(); @@ -205,41 +214,32 @@ public class XWTabFitLayout extends XWFitLayout { return crPropertyDescriptors; } - private void checkButonType() { - if (this.xCardSwitchButton == null) { - //假如为空,默认获取第一个tab的cardBtn属性 - try { - xCardSwitchButton = (XCardSwitchButton) ((XWCardMainBorderLayout) this.getTopLayout()).getTitlePart().getTagPart().getComponent(0); - }catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage()); - } - return; + public void checkButonType() { + WTabFitLayout wTabFitLayout = ((WTabFitLayout) data); + XCardSwitchButton xCardSwitchButton = this.getxCardSwitchButton(); + if(xCardSwitchButton == null){ + initRelateSwitchButton(); } - boolean isStyle = ((WTabFitLayout) data).isCustomStyle(); - Background bg; - bg = ColorBackground.getInstance(NORMAL_GRAL); CardSwitchButton cardSwitchButton = (CardSwitchButton) this.xCardSwitchButton.toData(); + boolean isStyle = wTabFitLayout.isCustomStyle(); + Background initialBackground = wTabFitLayout.getInitialBackground(); + Background overBackground = wTabFitLayout.getOverBackground(); + Background clickBackground = wTabFitLayout.getClickBackground(); if (!isStyle) { - this.xCardSwitchButton.setCustomStyle(false); - this.xCardSwitchButton.setSelectBackground(bg); + cardSwitchButton.setCustomStyle(false); cardSwitchButton.setInitialBackground(null); cardSwitchButton.setClickBackground(null); cardSwitchButton.setOverBackground(null); } else { - Background initialBackground = cardSwitchButton.getInitialBackground(); - bg = initialBackground == null ? bg : initialBackground; - this.xCardSwitchButton.setSelectBackground(bg); - this.xCardSwitchButton.setCustomStyle(true); cardSwitchButton.setCustomStyle(true); - if (this.initialBackground != null){ - this.xCardSwitchButton.setSelectBackground(this.initialBackground); - cardSwitchButton.setInitialBackground(this.initialBackground); + if (initialBackground != null){ + cardSwitchButton.setInitialBackground(initialBackground); } - if (this.overBackground != null){ - cardSwitchButton.setOverBackground(this.overBackground); + if (overBackground != null){ + cardSwitchButton.setOverBackground(overBackground); } - if (this.clickBackground != null) { - cardSwitchButton.setClickBackground(this.clickBackground); + if (clickBackground != null) { + cardSwitchButton.setClickBackground(clickBackground); } } } @@ -256,7 +256,8 @@ public class XWTabFitLayout extends XWFitLayout { * @param designer 表单设计器 * */ - public void deleteRelatedComponent(XCreator creator,FormDesigner designer){ + @Override + public void deleteRelatedComponent(XCreator creator, FormDesigner designer){ //逐层回溯找出相关的layout和对应的tab按钮 XWTabFitLayout fitLayout = (XWTabFitLayout)creator; WTabFitLayout fit = (WTabFitLayout) fitLayout.toData(); @@ -269,21 +270,22 @@ public class XWTabFitLayout extends XWFitLayout { //放置tab按钮的tagLayout XWCardTagLayout tagLayout = titleLayout.getTagPart(); WCardTagLayout tag = (WCardTagLayout) tagLayout.toData(); - + + //先删除对应的tab按钮 + for(int i=0;i index){ - button.setIndex(--buttonIndex); - } - if(currentFitIndex > index){ - tempFitLayout.setIndex(--currentFitIndex); - } - } + + private void refreshIndex(WCardTagLayout tag, XWCardLayout cardLayout, int index) { + for (int i = 0; i < tag.getWidgetCount(); i++) { + CardSwitchButton button = tag.getSwitchButton(i); + XWTabFitLayout tempFit = (XWTabFitLayout) cardLayout.getComponent(i); + WTabFitLayout tempFitLayout = (WTabFitLayout) tempFit.toData(); + int currentFitIndex = tempFitLayout.getIndex(); + int buttonIndex = button.getIndex(); + if (buttonIndex > index) { + button.setIndex(--buttonIndex); + } + if (currentFitIndex > index) { + tempFitLayout.setIndex(--currentFitIndex); + } + } } /** @@ -323,7 +325,8 @@ public class XWTabFitLayout extends XWFitLayout { * @param comp 当前组件 * void */ - public void seleteRelatedComponent(XCreator comp){ + @Override + public void seleteRelatedComponent(XCreator comp){ XWTabFitLayout fitLayout = (XWTabFitLayout)comp; WTabFitLayout fit = (WTabFitLayout) fitLayout.toData(); int index = fit.getIndex(); @@ -348,7 +351,8 @@ public class XWTabFitLayout extends XWFitLayout { * @date 2014-12-30-下午3:15:28 * */ - public XLayoutContainer findNearestFit(){ + @Override + public XLayoutContainer findNearestFit(){ XLayoutContainer parent = this.getBackupParent(); return parent == null ? null : parent.findNearestFit(); } @@ -357,6 +361,7 @@ public class XWTabFitLayout extends XWFitLayout { * 非顶层自适应布局的缩放 * @param percent 百分比 */ + @Override public void adjustCompSize(double percent) { this.adjustCreatorsWhileSlide(percent); } @@ -375,6 +380,7 @@ public class XWTabFitLayout extends XWFitLayout { * * @param percent 宽度变化的百分比 */ + @Override public void adjustCreatorsWidth(double percent) { if (this.getComponentCount()==0) { // 初始化没有拖入控件时,实际宽度依然调整 @@ -407,6 +413,7 @@ public class XWTabFitLayout extends XWFitLayout { * 同时调整容器内的组件们,缩小时需要考虑有的组件高度不满足缩小高度 * @param percent 高度变化的百分比 */ + @Override public void adjustCreatorsHeight(double percent) { if (this.getComponentCount()==0) { //调整高度后,wlayout那边记录下 @@ -431,6 +438,7 @@ public class XWTabFitLayout extends XWFitLayout { LayoutUtils.layoutContainer(this); } + @Override public XLayoutContainer getOuterLayout(){ XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent(); return cardLayout.getBackupParent(); @@ -445,12 +453,43 @@ public class XWTabFitLayout extends XWFitLayout { wgt.setBackupBounds(this.getComponent(m).getBounds()); } } + + /** + * 获取其在控件树上可见父层 + * @return 组件 + */ + @Override + public Component getParentShow(){ + XCardSwitchButton cardSwitchButton = this.getxCardSwitchButton(); + if(cardSwitchButton == null){ + initRelateSwitchButton(); + } + //控件树上显示其taglayout层 + if ((cardSwitchButton != null)) { + return cardSwitchButton.getBackupParent(); + } + return super.getParentShow(); + } + + public void initRelateSwitchButton(){ + //先确定此tabFitLayout所处位置 + XLayoutContainer parentContainer = this.getBackupParent(); + int index = parentContainer.getIndexOfChild(this); + XWCardMainBorderLayout cardMainBorderLayout = (XWCardMainBorderLayout) this.getTopLayout(); + XWCardTitleLayout titleLayout = cardMainBorderLayout.getTitlePart(); + XWCardTagLayout tagLayout = titleLayout.getTagPart(); + XCreator xCreator = tagLayout.getXCreator(index); + if(xCreator != null){ + this.setxCardSwitchButton((XCardSwitchButton)xCreator); + } + } /** * 去除原有的间隔 * @param gap 间隔 */ - public void moveCompInterval(int gap) { + @Override + public void moveCompInterval(int gap) { if (gap == 0) { return; } @@ -507,7 +546,8 @@ public class XWTabFitLayout extends XWFitLayout { * ps:改变布局大小或者拖入、删除、拉伸都要重新考虑间隔 * @param gap 间隔 */ - public void addCompInterval(int gap) { + @Override + public void addCompInterval(int gap) { if (gap == 0) { return; } @@ -552,6 +592,7 @@ public class XWTabFitLayout extends XWFitLayout { return new WidgetPropertyUIProvider[0]; } + @Override public void firePropertyChange(){ checkButonType(); //根据字体长度设置tab宽度 @@ -559,24 +600,9 @@ public class XWTabFitLayout extends XWFitLayout { XWCardLayout cardLayout = (XWCardLayout) this.getBackupParent(); XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) cardLayout.getBackupParent(); XWCardTitleLayout titleLayout = mainLayout.getTitlePart(); -// //放置tab按钮的tagLayout + //放置tab按钮的tagLayout XWCardTagLayout tagLayout = titleLayout.getTagPart(); tagLayout.setTabsAndAdjust(); - - initialBackground = ((WTabFitLayout) data).getInitialBackground(); - overBackground = ((WTabFitLayout) data).getOverBackground(); - clickBackground = ((WTabFitLayout)data).getClickBackground(); - CardSwitchButton cardSwitchButton = (CardSwitchButton) xCardSwitchButton.toData(); - if(initialBackground != null){ - xCardSwitchButton.setSelectBackground(initialBackground); - cardSwitchButton.setInitialBackground(initialBackground); - } - if(overBackground != null){ - cardSwitchButton.setOverBackground(overBackground); - } - if(clickBackground != null){ - cardSwitchButton.setClickBackground(clickBackground); - } } public void setCardSwitchBtnSize(){ @@ -587,5 +613,26 @@ public class XWTabFitLayout extends XWFitLayout { xCardSwitchButton.setPreferredSize(new Dimension(width, xCardSwitchButton.getHeight())); } + private void checkVisible(){ + WTabFitLayout wTabFitLayout = (WTabFitLayout)this.data; + CardSwitchButton cardSwitchButton = wTabFitLayout.getCurrentCard(); + cardSwitchButton.setVisible(wTabFitLayout.isVisible()); + } + + + /** + * 是否支持设置可见 + * return boolean + */ + @Override + public boolean supportSetVisible(){ + return true; + } + + + @Override + public void resetVisible(boolean visible){ + checkVisible(); + } } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/properties/EventPropertyTable.java b/designer-form/src/com/fr/design/designer/properties/EventPropertyTable.java index 435f42cfe6..d36c974d0b 100644 --- a/designer-form/src/com/fr/design/designer/properties/EventPropertyTable.java +++ b/designer-form/src/com/fr/design/designer/properties/EventPropertyTable.java @@ -30,10 +30,10 @@ public class EventPropertyTable extends UIListControlPane { this.designer = designer; } - @Override - public String getAddItemText() { - return Inter.getLocText("FR-Designer_Add_Event"); - } + @Override + public String getAddItemText() { + return Inter.getLocText("FR-Designer_Add_Event"); + } public static class WidgetEventListenerUpdatePane extends ListenerUpdatePane { @@ -70,9 +70,9 @@ public class EventPropertyTable extends UIListControlPane { return false; } } - + private String switchLang(String eventName) { - return Inter.getLocText("Event-" + eventName); + return Inter.getLocText("FR-Engine_Event_" + eventName); } /** @@ -93,31 +93,31 @@ public class EventPropertyTable extends UIListControlPane { refreshNameableCreator(EventCreator.createEventCreator(widget.supportedEvents(), WidgetEventListenerUpdatePane.class)); - ArrayList nameObjectList = new ArrayList<>(); + ArrayList nameObjectList = new ArrayList<>(); for (int i = 0, size = widget.getListenerSize(); i < size; i++) { Listener listener = widget.getListener(i); if (!listener.isDefault()) { - nameObjectList.add(i, new NameObject(switchLang(listener.getEventName()) + (i + 1), listener)); - } + nameObjectList.add(i, new NameObject(switchLang(listener.getEventName()) + (i + 1), listener)); + } } - populate(nameObjectList.toArray(new NameObject[widget.getListenerSize()])); + populate(nameObjectList.toArray(new NameObject[widget.getListenerSize()])); checkButtonEnabled(); this.repaint(); - } + } /** * 更新控件事件 * @param creator 控件 */ public void updateWidgetListener(XCreator creator) { - (creator.toData()).clearListeners(); - Nameable[] res = this.update(); - for (int i = 0; i < res.length; i++) { - NameObject nameObject = (NameObject)res[i]; - (creator.toData()).addListener((Listener) nameObject.getObject()); - } - - designer.fireTargetModified(); + (creator.toData()).clearListeners(); + Nameable[] res = this.update(); + for (int i = 0; i < res.length; i++) { + NameObject nameObject = (NameObject)res[i]; + (creator.toData()).addListener((Listener) nameObject.getObject()); + } + + designer.fireTargetModified(); checkButtonEnabled(); } @@ -135,9 +135,9 @@ public class EventPropertyTable extends UIListControlPane { @Override public void saveSettings() { - if (isPopulating) { - return; - } - updateWidgetListener(creator); - } + if (isPopulating) { + return; + } + updateWidgetListener(creator); + } } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java b/designer-form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java index 3a32d77092..16ec4405df 100644 --- a/designer-form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java +++ b/designer-form/src/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java @@ -1,18 +1,15 @@ package com.fr.design.designer.treeview; -import java.awt.Component; -import java.awt.Dimension; - -import javax.swing.Icon; - import com.fr.design.constants.UIConstants; -import com.fr.design.designer.creator.cardlayout.XWCardLayout; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.gui.ilable.UILabel; + +import javax.swing.Icon; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; - -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; +import java.awt.Component; +import java.awt.Dimension; public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer { @@ -25,12 +22,6 @@ public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer { super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); if (value instanceof XCreator) { String name = ((XCreator) value).toData().getWidgetName(); - //树节点上不显示此控件 - if(value instanceof XWCardLayout){ - this.setSize(new Dimension(0, 0)); - this.setPreferredSize(new Dimension(0, 0)); - return this; - } setText(name); Icon icon = XCreatorUtils.getCreatorIcon((XCreator) value); if (icon != null) { diff --git a/designer-form/src/com/fr/design/designer/treeview/ComponentTreeModel.java b/designer-form/src/com/fr/design/designer/treeview/ComponentTreeModel.java index 6fe4f762c4..c626fea8ce 100644 --- a/designer-form/src/com/fr/design/designer/treeview/ComponentTreeModel.java +++ b/designer-form/src/com/fr/design/designer/treeview/ComponentTreeModel.java @@ -1,19 +1,22 @@ package com.fr.design.designer.treeview; -import java.awt.Component; -import java.lang.reflect.Method; -import java.util.ArrayList; +import com.fr.base.FRContext; +import com.fr.design.designer.beans.events.DesignerEvent; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWAbsoluteBodyLayout; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWidgetCreator; +import com.fr.design.mainframe.FormDesigner; +import com.fr.form.ui.Widget; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; - -import com.fr.base.FRContext; -import com.fr.design.designer.creator.*; -import com.fr.design.mainframe.FormDesigner; -import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.form.ui.Widget; +import java.awt.Component; +import java.lang.reflect.Method; +import java.util.ArrayList; public class ComponentTreeModel implements TreeModel { @@ -23,6 +26,7 @@ public class ComponentTreeModel implements TreeModel { private final int ABSOLUTE_AS_BODY_NOT_FOUND = -1; + public ComponentTreeModel(FormDesigner designer, Component root) { this.designer = designer; this.root = root; @@ -60,8 +64,9 @@ public class ComponentTreeModel implements TreeModel { public int getChildCount(Object parent) { if (parent != null && parent instanceof XLayoutContainer) { XLayoutContainer xlayout = (XLayoutContainer) parent; - return xlayout.getXCreatorCount(); + return xlayout.getShowXCreatorCount(); } + return 0; } diff --git a/designer-form/src/com/fr/design/form/images/joption_failure.png b/designer-form/src/com/fr/design/form/images/joption_failure.png new file mode 100755 index 0000000000..bea459040d Binary files /dev/null and b/designer-form/src/com/fr/design/form/images/joption_failure.png differ diff --git a/designer-form/src/com/fr/design/form/images/joption_success.png b/designer-form/src/com/fr/design/form/images/joption_success.png new file mode 100755 index 0000000000..4bafb56d9c Binary files /dev/null and b/designer-form/src/com/fr/design/form/images/joption_success.png differ diff --git a/designer-form/src/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/com/fr/design/form/parameter/FormParaDesigner.java index 0b39f987d2..5c48f2c70b 100644 --- a/designer-form/src/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/com/fr/design/form/parameter/FormParaDesigner.java @@ -13,7 +13,6 @@ import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; -import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; @@ -21,6 +20,7 @@ import javax.swing.JPanel; import com.fr.base.BaseUtils; import com.fr.base.Parameter; import com.fr.base.parameter.ParameterUI; +import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.actions.UpdateAction; import com.fr.design.designer.beans.actions.CopyAction; @@ -107,11 +107,10 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA); EastRegionContainerPane.getInstance().replaceWidgetLibPane( FormWidgetDetailPane.getInstance(this)); - if (!BaseUtils.isAuthorityEditing()) { - ParameterPropertyPane parameterPropertyPane = ParameterPropertyPane.getInstance(this); + if (!DesignerMode.isAuthorityEditing()) { + ParameterPropertyPane parameterPropertyPane = ParameterPropertyPane.getInstance(this); // 传入this的同时会更新参数面板高度 parameterPropertyPane.refreshState(); EastRegionContainerPane.getInstance().addParameterPane(parameterPropertyPane); - EastRegionContainerPane.getInstance().setParameterHeight(parameterPropertyPane.getPreferredSize().height); EastRegionContainerPane.getInstance().replaceWidgetSettingsPane( WidgetPropertyPane.getInstance(this)); } else { diff --git a/designer-form/src/com/fr/design/form/util/XCreatorConstants.java b/designer-form/src/com/fr/design/form/util/XCreatorConstants.java index 91cd2007ed..c504ed7ff6 100644 --- a/designer-form/src/com/fr/design/form/util/XCreatorConstants.java +++ b/designer-form/src/com/fr/design/form/util/XCreatorConstants.java @@ -31,7 +31,7 @@ public class XCreatorConstants { public static final Color RESIZE_BOX_BORDER_COLOR = new Color(143, 171, 196); // 当前选取的组件的边框线着色 public static final Color SELECTION_COLOR = new Color(179, 209, 236); - public static final Color FORM_BORDER_COLOR = new Color(200, 201, 205); + public static final Color FORM_BORDER_COLOR = new Color(141, 194, 249); // 设计器区域外边框的颜色和粗细 public static final Border AREA_BORDER = BorderFactory.createLineBorder(new Color(224, 224, 255), 0); // 布局拖拽时的颜色 @@ -43,10 +43,14 @@ public class XCreatorConstants { public static final Color FIT_LAYOUT_POINT_COLOR = new Color(106, 168, 222); // 格子布局的分割线 public static final Color LAYOUT_SEP_COLOR = new Color(210, 210, 210); - + // 组件覆盖层颜色 + public static final Color COVER_COLOR = new Color(216, 242, 253); + //组件编辑按钮颜色 + public static final Color EDIT_COLOR = new Color(51, 51, 52); + // 伸缩表单操作条的颜色 public static final Color OP_COLOR = new Color(157,228,245); - + // 不同粗细的线 public static final BasicStroke STROKE = new BasicStroke(2); } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java b/designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java index 6dc296a7a3..da3d79404a 100644 --- a/designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java +++ b/designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPane.java @@ -3,11 +3,6 @@ */ package com.fr.design.gui.xpane; -import java.awt.BorderLayout; - -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JPanel; import com.fr.base.Utils; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; @@ -21,6 +16,11 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.ui.LayoutBorderStyle; import com.fr.general.Inter; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; + /** * CardTagLayoutBorderPane Pane. */ @@ -32,7 +32,7 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane { protected UIScrollPane initRightBottomPane(){ this.setFontSizeComboBox(new UIComboBox(FRFontPane.FONT_SIZES)); - this.setFontNameComboBox(new UIComboBox(Utils.getAvailableFontFamilyNames4Report())); + this.setFontNameComboBox(new UIComboBox(Utils.getAvailableFontFamilyNames4Report())); JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0)); fontSizeTypePane.add(this.getFontSizeComboBox(), BorderLayout.CENTER); fontSizeTypePane.add(this.getFontNameComboBox(), BorderLayout.EAST); @@ -72,7 +72,7 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane { centerPane.add(borderPane, BorderLayout.CENTER); borderPane.setBorder(BorderFactory.createEmptyBorder(10, 4, 10, 4)); - this.setLayoutBorderPreviewPane(new CardTagLayoutBorderPreviewPane(this.getBorderStyle())); + this.setLayoutBorderPreviewPane(new CardTagLayoutBorderPreviewPane(this.getBorderStyle())); borderPane.add(this.getLayoutBorderPreviewPane(), BorderLayout.CENTER); @@ -92,15 +92,18 @@ public class CardTagLayoutBorderPane extends LayoutBorderPane { return; } - public LayoutBorderStyle update() { - LayoutBorderStyle style = new LayoutBorderStyle(); - style.setBorderStyle(this.getBorderStyleCombo().getSelectedIndex()); - style.setBorder(this.getCurrentLineCombo().getSelectedLineStyle()); - style.setColor(this.getCurrentLineColorPane().getColor()); - style.setBackground(this.getBackgroundPane().update()); - style.setAlpha((float)(this.getNumberDragPane().updateBean()/this.getMaxNumber())); - return style; + public LayoutBorderStyle update() { + LayoutBorderStyle style = new LayoutBorderStyle(); + if (this.getBorderStyle() != null) { + style.setStyle(this.getBorderStyle()); } + style.setBorderStyle(this.getBorderStyleCombo().getSelectedIndex()); + style.setBorder(this.getCurrentLineCombo().getSelectedLineStyle()); + style.setColor(this.getCurrentLineColorPane().getColor()); + style.setBackground(this.getBackgroundPane().update()); + style.setAlpha((float) (this.getNumberDragPane().updateBean() / this.getMaxNumber())); + return style; + } protected void populateBorderType(){ return; diff --git a/designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPreviewPane.java b/designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPreviewPane.java index 6ae33aad1e..593b1db40b 100644 --- a/designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPreviewPane.java +++ b/designer-form/src/com/fr/design/gui/xpane/CardTagLayoutBorderPreviewPane.java @@ -3,7 +3,7 @@ package com.fr.design.gui.xpane; import com.fr.form.ui.LayoutBorderStyle; /** - * + * * @author focus * */ @@ -11,4 +11,9 @@ public class CardTagLayoutBorderPreviewPane extends LayoutBorderPreviewPane{ public CardTagLayoutBorderPreviewPane(LayoutBorderStyle borderStyle) { super(borderStyle,true); } + + @Override + protected void showTitlePreviewPane(){ + + } } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java b/designer-form/src/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java index a1260687a8..0716e8e247 100644 --- a/designer-form/src/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java +++ b/designer-form/src/com/fr/design/gui/xpane/LayoutBorderPreviewPane.java @@ -13,10 +13,13 @@ import com.fr.general.FRFont; import com.fr.general.Inter; import com.fr.stable.Constants; -import javax.swing.*; - -import java.awt.*; -import java.awt.geom.Rectangle2D; +import javax.swing.JPanel; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Shape; import java.awt.geom.Rectangle2D.Double; import java.awt.geom.RoundRectangle2D; @@ -54,7 +57,7 @@ public class LayoutBorderPreviewPane extends JPanel{ add(jp); } - public LayoutBorderPreviewPane(LayoutBorderStyle borderStyle,boolean isTabLayout) { + public LayoutBorderPreviewPane(LayoutBorderStyle borderStyle, boolean isTabLayout) { this(borderStyle); this.isTabLayout = true; } @@ -74,7 +77,7 @@ public class LayoutBorderPreviewPane extends JPanel{ Background background = borderStyle.getBackground(); if (background != null) { - Shape shape = new Rectangle2D.Double(smallGAP, smallGAP, this.getWidth() - GAP, this.getHeight() - GAP); + Shape shape = new Double(smallGAP, smallGAP, this.getWidth() - GAP, this.getHeight() - GAP); background.paint(g, shape); } else { g.setColor(Color.WHITE); @@ -90,13 +93,16 @@ public class LayoutBorderPreviewPane extends JPanel{ int height = borderStyle.getTitle().getFrFont().getSize() + GAP; jp.setPreferredSize(new Dimension(getWidth() - GAP, height)); jp.setBounds(smallGAP,smallGAP, getWidth() - GAP, height); - borderStyle.paint(g, new Rectangle2D.Double(smallGAP, smallGAP, getWidth() - GAP, getHeight() - GAP)); + borderStyle.paint(g, new Double(smallGAP, smallGAP, getWidth() - GAP, getHeight() - GAP)); jp.setFontObject(borderStyle.getTitle().getFrFont()); - jp.setVisible(borderStyle.getType() == LayoutBorderStyle.TITLE); - + showTitlePreviewPane(); } } + protected void showTitlePreviewPane(){ + jp.setVisible(borderStyle.getType() == LayoutBorderStyle.TITLE); + } + private class titlePreviewPane extends UITextArea { private FRFont frFont = null; @@ -134,7 +140,7 @@ public class LayoutBorderPreviewPane extends JPanel{ } Background background = title.getBackground(); if (background != null) { - Shape shape = new Rectangle2D.Double(0, 0, this.getWidth(), this.getHeight()); + Shape shape = new Double(0, 0, this.getWidth(), this.getHeight()); background.paint(g, shape); } GraphHelper.drawString(g2d, paintText, startX1, startY); @@ -145,25 +151,25 @@ public class LayoutBorderPreviewPane extends JPanel{ } g.setColor(borderStyle.getColor()); int line = GraphHelper.getLineStyleSize(borderStyle.getBorder()); - Double double1 = new Rectangle2D.Double(0, getHeight()-1, getWidth(), getHeight()); + Double double1 = new Double(0, getHeight()-1, getWidth(), getHeight()); double x = double1.getX() + (line == 1 ? 1 : 2) - line - 1; double y = double1.getY() + (line == 1 ? 1 : 2) - line ; RoundRectangle2D.Double double2 = new RoundRectangle2D.Double(x, y, double1.getWidth() + line, double1.getHeight() + line, 0, 0); GraphHelper.draw(g,double2, borderStyle.getBorder()); } - - private void drawTabBack(Graphics2D g2d,Graphics g,WidgetTitle title,FontMetrics fm,int startX1,int startY){ + + private void drawTabBack(Graphics2D g2d, Graphics g, WidgetTitle title, FontMetrics fm, int startX1, int startY){ Dimension d = getSize(); String paintText = Inter.getLocText("FR-Designer_Title")+TAB_ZERO; - + Background rightBack = ColorBackground.getInstance(XCardSwitchButton.CHOOSED_GRAL); - Shape right = new Rectangle2D.Double(this.getWidth()/2, 0, this.getWidth()/2, this.getHeight()); + Shape right = new Double(this.getWidth()/2, 0, this.getWidth()/2, this.getHeight()); rightBack.paint(g, right); String rightLabel = Inter.getLocText("FR-Designer_Title")+TAB_ONE; GraphHelper.drawString(g2d, rightLabel, (d.width/2 - fm.stringWidth(paintText)) / 2+d.width/2, startY); Background background = title.getBackground(); if (background != null) { - Shape shape = new Rectangle2D.Double(0, 0, this.getWidth()/2, this.getHeight()); + Shape shape = new Double(0, 0, this.getWidth()/2, this.getHeight()); background.paint(g, shape); } GraphHelper.drawString(g2d, paintText, startX1, startY); diff --git a/designer-form/src/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/com/fr/design/mainframe/ComponentTree.java index e99b448140..02abef0105 100644 --- a/designer-form/src/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/com/fr/design/mainframe/ComponentTree.java @@ -121,6 +121,11 @@ public class ComponentTree extends JTree { scrollPathToVisible(treepath[0]); } + @Override + public void paint(Graphics g) { + super.paint(g); + designer.getSelectionModel(); // 否则参数一个一个加会导致参数面板和body结构出问题 + } /** * 刷新 @@ -222,21 +227,13 @@ public class ComponentTree extends JTree { if (creator != comp) { creator.notShowInComponentTree(path); } - //绝对布局作为body的时候不显示自适应布局父层 - if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class)) { - if ((parent.getParent() != null) - && ((XCreator) parent.getParent()).acceptType(XWFitLayout.class)) { - parent = parent.getParent().getParent(); - continue; - } - } - - parent = parent.getParent(); + parent = creator.getParentShow(); } Object[] components = path.toArray(); return new TreePath(components); } + private void popupPreviewPane(int popupPosYOnScreen, XCreator comp) { if (previewPane == null) { previewPane = new PopupPreviewPane(); @@ -245,7 +242,7 @@ public class ComponentTree extends JTree { previewPane.setVisible(false); } - if (!previewPane.isVisible()) { + if (!previewPane.isVisible() && comp.getWidth() != 0 && comp.getHeight() != 0) { previewPane.setComp(comp); int popupPosY = popupPosYOnScreen - FormHierarchyTreePane.getInstance().getLocationOnScreen().y; GUICoreUtils.showPopupMenu(previewPane, FormHierarchyTreePane.getInstance(), -previewPane.getPreferredSize().width, popupPosY); diff --git a/designer-form/src/com/fr/design/mainframe/CoverPane.java b/designer-form/src/com/fr/design/mainframe/CoverPane.java index 9fed1ab7c3..5b359b06c6 100644 --- a/designer-form/src/com/fr/design/mainframe/CoverPane.java +++ b/designer-form/src/com/fr/design/mainframe/CoverPane.java @@ -1,12 +1,26 @@ package com.fr.design.mainframe; +import com.fr.base.GraphHelper; +import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; import com.fr.general.IOUtils; import com.fr.general.Inter; +import com.fr.stable.Constants; + +import javax.swing.JPanel; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Component; +import java.awt.Composite; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.LayoutManager; +import java.awt.Rectangle; -import javax.swing.*; -import java.awt.*; /** * Created with IntelliJ IDEA. @@ -17,14 +31,18 @@ import java.awt.*; public class CoverPane extends JPanel { private UIButton editButton; - private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F); + private AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f); + private static final int BORDER_WIDTH = 2; + private static final Color COVER_COLOR = new Color(216, 242, 253); + private static final int EDIT_BTN_WIDTH = 75; + private static final int EDIT_BTN_HEIGHT = 20; public CoverPane() { setLayout(getCoverLayout()); setBackground(null); setOpaque(false); - editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon(IconPathConstants.TD_EDIT_ICON_PATH)) { + editButton = new UIButton(Inter.getLocText("Edit"), IOUtils.readIcon(IconPathConstants.EDIT_ICON_PATH)) { @Override public Dimension getPreferredSize() { return new Dimension(60, 24); @@ -32,7 +50,7 @@ public class CoverPane extends JPanel { }; editButton.setBorderPainted(false); editButton.setExtraPainted(false); - editButton.setBackground(new Color(176, 196, 222)); + editButton.setForeground(Color.WHITE); add(editButton); } @@ -86,12 +104,30 @@ public class CoverPane extends JPanel { public void paint(Graphics g) { + int x = 0; + int y = 0; + int w = getWidth(); + int h = getHeight(); Graphics2D g2d = (Graphics2D) g; Composite oldComposite = g2d.getComposite(); g2d.setComposite(composite); - g2d.setColor(Color.WHITE); + g2d.setColor(COVER_COLOR); g2d.fillRect(0, 0, getWidth(), getHeight()); + FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + g2d.setColor(XCreatorConstants.EDIT_COLOR); + boolean editHover = formDesigner.getCursor().getType() != Cursor.DEFAULT_CURSOR; + AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, editHover ? 0.9f : 0.7f); + g2d.setComposite(alphaComposite); + g2d.fillRoundRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT, 4, 4); g2d.setComposite(oldComposite); + g.setColor(XCreatorConstants.FORM_BORDER_COLOR); + GraphHelper.draw(g, getPaintBorderBounds(), Constants.LINE_MEDIUM); + + super.paint(g); } + + protected Rectangle getPaintBorderBounds(){ + return new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - BORDER_WIDTH * 2 , getHeight() - BORDER_WIDTH * 2); + } } \ No newline at end of file diff --git a/designer-form/src/com/fr/design/mainframe/CoverReportPane.java b/designer-form/src/com/fr/design/mainframe/CoverReportPane.java index a0cb43b433..a47403f0f3 100644 --- a/designer-form/src/com/fr/design/mainframe/CoverReportPane.java +++ b/designer-form/src/com/fr/design/mainframe/CoverReportPane.java @@ -21,6 +21,7 @@ import java.awt.event.WindowEvent; * Time: 11:32 */ public class CoverReportPane extends CoverPane implements HelpDialogHandler{ + private static final int BORDER_WIDTH = 1; private Icon controlMode = IOUtils.readIcon(IconPathConstants.TD_EL_SHARE_HELP_ICON_PATH); private JComponent controlButton = new JComponent() { protected void paintComponent(Graphics g) { @@ -126,6 +127,11 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{ } } + @Override + protected Rectangle getPaintBorderBounds(){ + return new Rectangle(BORDER_WIDTH, BORDER_WIDTH, getWidth() - 3 * BORDER_WIDTH , getHeight() - 3 * BORDER_WIDTH); + } + @Override public void setVisible(boolean aFlag) { super.setVisible(aFlag); diff --git a/designer-form/src/com/fr/design/mainframe/FormArea.java b/designer-form/src/com/fr/design/mainframe/FormArea.java index 971ca9ce6a..c716d0239d 100644 --- a/designer-form/src/com/fr/design/mainframe/FormArea.java +++ b/designer-form/src/com/fr/design/mainframe/FormArea.java @@ -507,7 +507,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { public void scrollPathToVisible(XCreator creator) { creator.seleteRelatedComponent(creator); - if (!ComponentUtils.isComponentVisible(creator) && !designer.isRoot(creator) && (creator.toData()).isVisible()) { + if (!ComponentUtils.isComponentVisible(creator) && !designer.isRoot(creator)) { designer.makeVisible(creator); } diff --git a/designer-form/src/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/com/fr/design/mainframe/FormCreatorDropTarget.java index 24cc147d9b..29a06060c9 100644 --- a/designer-form/src/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -8,31 +8,20 @@ import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.Painter; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.models.AddingModel; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteLayout; -import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.designer.creator.*; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; import com.fr.design.utils.ComponentUtils; import com.fr.form.share.SharableEditorProvider; import com.fr.form.share.ShareLoader; -import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.SharableWidgetBindInfo; import com.fr.form.ui.Widget; import com.fr.general.Inter; import com.fr.stable.Constants; -import javax.swing.BorderFactory; -import javax.swing.JWindow; -import java.awt.Color; -import java.awt.Component; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Toolkit; +import javax.swing.*; +import java.awt.*; import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; @@ -100,8 +89,9 @@ public class FormCreatorDropTarget extends DropTarget { Map tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource()); //合并数据集之后,可能会有数据集名称变化,做一下联动 //共享的组件拿的时候都是克隆的,这边改拖拽中克隆的对象而非新克隆对象,上面这个新克隆的对象只是为了拿数据集 - ElementCaseEditor elementCaseEditor = (ElementCaseEditor) widget; - elementCaseEditor.batchRenameTdName(tdNameMap); + for (Map.Entry entry : tdNameMap.entrySet()) { + designer.getTarget().renameTableData(widget, entry.getKey(), entry.getValue()); + } } } designer.getSelectionModel().setSelectedCreators( diff --git a/designer-form/src/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/com/fr/design/mainframe/FormDesigner.java index be8f050a71..d986a3a889 100644 --- a/designer-form/src/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/com/fr/design/mainframe/FormDesigner.java @@ -1,8 +1,8 @@ package com.fr.design.mainframe; -import com.fr.base.BaseUtils; import com.fr.base.Parameter; import com.fr.base.ScreenResolution; +import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; import com.fr.design.actions.UpdateAction; import com.fr.design.designer.TargetComponent; @@ -21,6 +21,7 @@ import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.beans.models.StateModel; import com.fr.design.designer.creator.*; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; +import com.fr.design.event.DesignerOpenedListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; @@ -43,10 +44,9 @@ import com.fr.form.ui.WidgetValue; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; +import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; -import com.fr.stable.CoreGraphHelper; import com.fr.stable.bridge.StableFactory; import javax.swing.*; @@ -202,8 +202,7 @@ public class FormDesigner extends TargetComponent
implements TreeSelection } ParameterPropertyPane.getInstance().getParameterToolbarPane().populateBean( getParameterArray() == null ? new Parameter[0] : getParameterArray()); - ParameterPropertyPane.getInstance().repaintContainer(); - EastRegionContainerPane.getInstance().setParameterHeight(ParameterPropertyPane.getInstance(this).getPreferredSize().height); + ParameterPropertyPane.getInstance(this).repaintContainer(); // 传入this的同时会更新参数面板高度 } private void removeSame(Parameter[] parameters, List namelist) { @@ -350,11 +349,11 @@ public class FormDesigner extends TargetComponent implements TreeSelection } parameterArray = null; - refreshParameter(); + //parameter多的时候,不刷新会出现控件边界交叉 refreshRoot(); - //不知道为什么添加完参数后控件树只有一个label,这儿刷新一下控件树好了 - EastRegionContainerPane.getInstance().refreshDownPane(); + // 最后刷新"添加参数面板"和控件树 + refreshParameter(); } private void addParaPaneTooltips() { @@ -475,7 +474,6 @@ public class FormDesigner extends TargetComponent implements TreeSelection paraHeight = 0; paraComponent = null; formLayoutContainer.setSize(rootComponent.getWidth(), rootComponent.getHeight()); - EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(this.getEastDownPane()); //atat //EastRegionContainerPane.getInstance().addTitlePane(ParameterPropertyPane.getInstance(FormDesigner.this)); //删除后重绘下 @@ -679,6 +677,13 @@ public class FormDesigner extends TargetComponent implements TreeSelection } }); + + DesignerContext.getDesignerFrame().addDesignerOpenedListener(new DesignerOpenedListener() { + @Override + public void designerOpened() { + setToolbarButtons(); + } + }); } /** @@ -1028,7 +1033,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection selected.add((XCreator) path.getLastPathComponent()); } - if (!BaseUtils.isAuthorityEditing()) { + if (!DesignerMode.isAuthorityEditing()) { selectionModel.setSelectedCreators(selected); if (formArea != null) { @@ -1040,8 +1045,21 @@ public class FormDesigner extends TargetComponent implements TreeSelection showAuthorityEditPane(); } //先选中再检查 - setToolbarButtons(paths.length == 1 && tree.getSelectionPath().getParentPath() == null); + setToolbarButtons(); + } + } + + /** + * 是否选中了自适应布局或底层form + */ + public boolean isRootSelected() { + ComponentTree tree = FormHierarchyTreePane.getInstance().getComponentTree(); + TreePath[] paths = tree.getSelectionPaths(); + if (paths == null) { + return true; } + boolean isForm = paths.length == 1 && tree.getSelectionPath().getParentPath() == null; + return isForm || isRoot(getSelectionModel().getSelection().getSelectedCreator()); } /** @@ -1074,9 +1092,9 @@ public class FormDesigner extends TargetComponent implements TreeSelection } - protected void setToolbarButtons(boolean flag) { + protected void setToolbarButtons() { //自适应布局和底层都不能删除 - DesignerContext.getDesignerFrame().checkCombineUp(!(isRoot(getSelectionModel().getSelection().getSelectedCreator()) || flag), NAME_ARRAY_LIST); + DesignerContext.getDesignerFrame().checkCombineUp(!isRootSelected(), NAME_ARRAY_LIST); } private void invalidateLayout() { @@ -1298,7 +1316,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection try { Thread.sleep(1500); } catch (InterruptedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + FRLogger.getLogger().error(e.getMessage(), e); } pane.setLayout(new BorderLayout()); @@ -1413,7 +1431,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection @Override public void fireCreatorModified(DesignerEvent evt) { - if (!BaseUtils.isAuthorityEditing()) { + if (!DesignerMode.isAuthorityEditing()) { return; } if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED @@ -1425,7 +1443,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection if (paths == null) { return; } - if (BaseUtils.isAuthorityEditing()) { + if (DesignerMode.isAuthorityEditing()) { showAuthorityEditPane(); } diff --git a/designer-form/src/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/com/fr/design/mainframe/FormDesignerUI.java index 04820a73c2..636152b697 100644 --- a/designer-form/src/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/com/fr/design/mainframe/FormDesignerUI.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import java.awt.AlphaComposite; +import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; @@ -266,6 +267,7 @@ public class FormDesignerUI extends ComponentUI { bounds.y -= designer.getArea().getVerticalValue(); drawResizingThumbs(g, selectionModel.getSelection().getDirections(), bounds.x, bounds.y, bounds.width, bounds.height); + //选中时边框颜色 g.setColor(XCreatorConstants.FORM_BORDER_COLOR); for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { @@ -277,7 +279,7 @@ public class FormDesignerUI extends ComponentUI { } else if (designer.getRootComponent().acceptType(XWFitLayout.class)) { resetCreatorBounds(creatorBounds); } - GraphHelper.draw(g, creatorBounds, Constants.LINE_MEDIUM); + creator.paintBorder(g, creatorBounds); } } diff --git a/designer-form/src/com/fr/design/mainframe/JForm.java b/designer-form/src/com/fr/design/mainframe/JForm.java index 4f1e45053b..23aeaa3550 100644 --- a/designer-form/src/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/com/fr/design/mainframe/JForm.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.PaperSize; +import com.fr.base.Parameter; import com.fr.design.DesignState; import com.fr.design.actions.core.WorkBookSupportable; import com.fr.design.actions.file.WebPreviewUtils; @@ -258,9 +259,6 @@ public class JForm extends JTemplate implements BaseJForm { private XComponent lastAffectedCreator; @Override public void fireCreatorModified(DesignerEvent evt) { - if (formDesign.getArea() == null || !formDesign.getArea().isValid()) { - return; - } if (evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED) { setPropertyPaneChange(formDesign.getRootComponent()); } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED) { @@ -682,6 +680,11 @@ public class JForm extends JTemplate implements BaseJForm { return UIConstants.RUN_BIG_ICON; } + @Override + public Parameter[] getJTemplateParameters() { + return this.getTarget().getTemplateParameters(); + } + @Override /** * 创建菜单项Preview @@ -740,9 +743,8 @@ public class JForm extends JTemplate implements BaseJForm { EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.FORM); EastRegionContainerPane.getInstance().replaceWidgetSettingsPane(WidgetPropertyPane.getInstance(formDesign)); ParameterPropertyPane parameterPropertyPane = ParameterPropertyPane.getInstance(formDesign); - parameterPropertyPane.setAddParaPaneVisible(false, this); + parameterPropertyPane.refreshState(this); EastRegionContainerPane.getInstance().addParameterPane(parameterPropertyPane); - EastRegionContainerPane.getInstance().setParameterHeight(parameterPropertyPane.getPreferredSize().height); refreshWidgetLibPane(); } diff --git a/designer-form/src/com/fr/design/mainframe/WidgetHelpDialog.java b/designer-form/src/com/fr/design/mainframe/WidgetHelpDialog.java new file mode 100644 index 0000000000..d45c7c321b --- /dev/null +++ b/designer-form/src/com/fr/design/mainframe/WidgetHelpDialog.java @@ -0,0 +1,93 @@ +package com.fr.design.mainframe; + +import com.fr.design.dialog.UIDialog; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.itextarea.UITextArea; +import com.fr.general.Inter; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Point; +import java.awt.event.MouseEvent; + +/** + * @author zack + * @date 2016-10-14 + * @since 8.0 + */ +public class WidgetHelpDialog extends UIDialog { + + private static final int OUTER_WIDTH = 190; + private static final int OUTER_HEIGHT = 280; + private static final int DIALOG_X = 227; + private static final int DIALOG_Y = 165; + + + private String helpMsg; + private UIScrollPane helpArea; + + + public WidgetHelpDialog(Frame parent, String helpMsg) { + super(parent); + this.helpMsg = helpMsg; + initHelpArea(); + JPanel panel = (JPanel) getContentPane(); + initComponents(panel); + setSize(new Dimension(OUTER_WIDTH, OUTER_HEIGHT)); + } + + private void initHelpArea() { + UITextArea textArea = new UITextArea(helpMsg); + textArea.setEditable(false); + textArea.setBorder(null); + helpArea = new UIScrollPane(textArea); + helpArea.setBounds(0, 0, OUTER_WIDTH, OUTER_HEIGHT); + helpArea.setBorder(null); + } + + private void initComponents(JPanel contentPane) { + contentPane.setLayout(new BorderLayout()); + add(helpArea, BorderLayout.CENTER); + this.applyClosingAction(); + this.setTitle(Inter.getLocText("FR-Designer_Help")); + } + + /** + * 打开帮助框 + */ + public void showWindow() { + this.setResizable(false); + setVisible(true); + } + + /** + * 打开帮助框-e + */ + public void showWindow(MouseEvent e) { + int rX = WestRegionContainerPane.getInstance().getWidth() + e.getX() - DIALOG_X;//弹出框宽度190加上图标的宽度27加上10的偏移 + int rY = DIALOG_Y + e.getY();//165是设计器最上面几个面板的高度 + this.setLocationRelativeTo(DesignerContext.getDesignerFrame(), rX, rY); + this.setResizable(false); + setVisible(true); + } + + /** + * 略 + */ + @Override + public void checkValid() throws Exception { + + } + + public void setLocationRelativeTo(JFrame c, int x, int y) { + int dx = 0, dy = 0; + Point compLocation = c.getLocationOnScreen();//获取设计器Jframe坐标作为相对位置原点 + setLocation(dx + x, dy + y); + dx = compLocation.x; + dy = compLocation.y + c.getRootPane().getY();//加上底层容器的y坐标(其实就是设计器最上方图标栏的高度) + setLocation(dx + x, dy + y); + } +} \ No newline at end of file diff --git a/designer-form/src/com/fr/design/mainframe/WidgetPropertyPane.java b/designer-form/src/com/fr/design/mainframe/WidgetPropertyPane.java index 75a1bed357..c0baf9151a 100644 --- a/designer-form/src/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer-form/src/com/fr/design/mainframe/WidgetPropertyPane.java @@ -7,21 +7,18 @@ import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.*; import com.fr.design.designer.properties.EventPropertyTable; -import com.fr.design.dialog.BasicPane; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itable.AbstractPropertyTable; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.widget.ui.FormWidgetCardPane; import com.fr.design.widget.ui.designer.mobile.MobileWidgetDefinePane; -import com.fr.form.ui.Widget; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; import javax.swing.*; -import javax.swing.border.LineBorder; -import javax.swing.table.JTableHeader; import java.awt.*; import java.util.ArrayList; import java.util.List; @@ -33,22 +30,15 @@ import java.util.Set; */ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane { - private static final String PARA = "para"; - private static final String BODY = "body"; + private static final int PADDING = 10; + private static final int PADDING_M = 12; private FormWidgetCardPane formWidgetCardPane; // 控件的属性表 private EventPropertyTable eventTable; // 控件的事件表 private List widgetPropertyTables; // 这个变量应该是保存控件拓展的属性tab private List mobileExtraPropertyPanes; // 保存9.0设计器下移动端拓展的属性tab,舍弃JTable private FormDesigner designer; // 当前designer private UIScrollPane psp; // 用来装载属性表table的容器 - private UIScrollPane esp; //用来装载事件table的容器 private JPanel wsp; // 装载移动端tab的容器,包括移动端属性表和控件拓展的移动端属性表 - private MobileParaWidgetTable mobileParaWidgetTable; // 参数面板的移动端属性tab(和body的移动端属性tab区别是没有标签名column) - private MobileWidgetTable mobileWidgetTable; // body的移动端属性tab - private UIScrollPane downPanel; // 这个滚动容器是用于装载centerPane的 - private JPanel centerPane; // 此centerPane采用的是cardLayout布局,装载着mobileWidgetTable和mobileBodyWidgetTable - private CardLayout cardLayout; // 卡片布局,选中参数面板时显示mobileWidgetTable,选中body时显示mobileBodyWidgetTable - private JTableHeader header;//把表头单独get出来作为一个组件 private UIHeadGroup tabsHeaderIconPane; private XComponent lastAffectedCreator; @@ -122,6 +112,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope if (mobileExtraPropertyPanes != null) { for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { extraPane.initPropertyGroups(designer); + extraPane.populate(designer); } } if (widgetPropertyTables != null) { @@ -156,33 +147,10 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope //加上表头后,这里不再使用borderLayout布局,而采用BoxLayout布局 wsp = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); wsp.setBorder(null); - mobileParaWidgetTable = new MobileParaWidgetTable(designer); - mobileWidgetTable = new MobileWidgetTable(designer); designer.addDesignerEditListener(new MobileWidgetDesignerAdapter()); - centerPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - cardLayout = (CardLayout) centerPane.getLayout(); - centerPane.add(mobileParaWidgetTable, PARA); - // 采用卡片布局的容器必须指定卡片名字,如果没有卡片名字 - // 就会出现:Exception in thread "main" java.lang.IllegalArgumentException: - // cannot add to layout: constraint must be a string - // 第二个参数代表卡片的名字。后来show方法调用时通过名字找到要显示的卡片 - centerPane.add(mobileWidgetTable, BODY); //这两句代码,是把JTable放到一个JPanel中去了,表头不会显示, - //只有放到JScrollPanel中去表头才能正常显示,这就是MobileWidgetTable中定义了表头却没有显示的原因! - //解决方案:MobileWidgetTable实在无法直接放到JScrollPanel中去的时候,应该把表头get出来单独作为一个组件显示 - - if (hasSelectParaPane(designer)) { - cardLayout.show(centerPane, PARA); - header = mobileParaWidgetTable.getTableHeader(); - } else { - cardLayout.show(centerPane, BODY); - header = mobileWidgetTable.getTableHeader(); - } - downPanel = new UIScrollPane(centerPane); - downPanel.setBorder(new LineBorder(Color.GRAY)); //获取拓展移动端属性tab WidgetPropertyUIProvider[] widgetAttrProviders = getExtraPropertyUIProviders(); - addWidgetAttr(widgetAttrProviders); } @@ -217,13 +185,13 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope * @param widgetAttrProviders 拓展的tab */ private void addWidgetAttr(WidgetPropertyUIProvider[] widgetAttrProviders) { - if (widgetAttrProviders.length == 0) { // 判断有没有拓展的tab,没有就使用原来的 - wsp.add(header); - wsp.add(downPanel); + if (widgetAttrProviders.length == 0) { // 判断有没有拓展的tab,提示"无可用配置项" + wsp.add(getUnavailablePane()); } else { for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) { MobileWidgetDefinePane extraPane = (MobileWidgetDefinePane) widgetAttrProvider.createWidgetAttrPane(); if (extraPane != null) { + extraPane.setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, PADDING, PADDING_M)); mobileExtraPropertyPanes.add(extraPane); wsp.add(extraPane); } @@ -232,29 +200,20 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope widgetPropertyTables.add(propertyTable); designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(formWidgetCardPane)); - UIScrollPane uiScrollPane = new UIScrollPane(getExtraBodyTable(propertyTable)); + UIScrollPane uiScrollPane = new UIScrollPane(propertyTable); wsp.add(uiScrollPane); } } } } - /** - * 如果是body的拓展属性表,那么要额外加上一张控件顺序表 - * - * @return - */ - private Component getExtraBodyTable(AbstractPropertyTable abstractPropertyTable) { - Widget selection = designer.getSelectionModel().getSelection().getSelectedCreator().toData(); - if ("body".equals(selection.getWidgetName())) { - JPanel jPanel = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); - jPanel.add(abstractPropertyTable); - MobileWidgetTable mobileWidgetTable = new MobileWidgetTable(designer); - jPanel.add(mobileWidgetTable.getTableHeader()); - jPanel.add(mobileWidgetTable); - return jPanel; - } - return abstractPropertyTable; + // "无可用配置项"面板 + private JPanel getUnavailablePane() { + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + UILabel label = new UILabel(Inter.getLocText("FR-Designer_No_Settings_Available")); + label.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(label); + return panel; } private void initTabPane() { @@ -406,7 +365,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetPrope if (!isValid) { return; } - //fanglei:下面的注释不要删,只是暂时屏蔽 + //fanglei:下面的注释不要删,只是暂时屏蔽 // int value = downPanel.getVerticalScrollBar().getValue(); // if (hasSelectParaPane(getEditingFormDesigner())) { // cardLayout.show(centerPane, PARA); diff --git a/designer-form/src/com/fr/design/mainframe/actions/FormMobileAttrAction.java b/designer-form/src/com/fr/design/mainframe/actions/FormMobileAttrAction.java index 171bc09aad..4d7394620d 100644 --- a/designer-form/src/com/fr/design/mainframe/actions/FormMobileAttrAction.java +++ b/designer-form/src/com/fr/design/mainframe/actions/FormMobileAttrAction.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.actions; import com.fr.base.BaseUtils; +import com.fr.base.iofileattr.MobileOnlyTemplateAttrMark; import com.fr.design.actions.JTemplateAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -8,7 +9,9 @@ import com.fr.design.form.mobile.FormMobileAttrPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.JForm; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.menu.MenuKeySet; +import com.fr.file.FILE; import com.fr.form.main.Form; import com.fr.form.main.mobile.FormMobileAttr; import com.fr.general.Inter; @@ -52,15 +55,27 @@ public class FormMobileAttrAction extends JTemplateAction { @Override public void doOk() { FormMobileAttr formMobileAttr = mobileAttrPane.updateBean(); - formTpl.setFormMobileAttr(formMobileAttr); - ((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified(); - jf.fireTargetModified(); - if (formMobileAttr.isMobileOnly()) { - FunctionProcessor processor = ExtraClassManager.getInstance().getFunctionProcessor(); - if (processor != null) { - processor.recordFunction(ReportFunctionProcessor.MOBILE_TEMPLATE_FRM); + if (formMobileAttr.isMobileOnly() && jf.getTarget().getAttrMark(MobileOnlyTemplateAttrMark.XML_TAG) == null) { + // 如果是老模板,选择手机专属之后需要另存为 + FILE editingFILE = jf.getEditingFILE(); + if (editingFILE != null && editingFILE.exists()) { + String fileName = editingFILE.getName().substring(0, editingFILE.getName().length() - jf.suffix().length()) + "_mobile"; + if (!jf.saveAsTemplate(true, fileName)) { + return; + } } + // 放到后面。如果提前 return 了,则仍然处于未设置状态,不要添加 + jf.getTarget().addAttrMark(new MobileOnlyTemplateAttrMark()); + } + // 记录功能点 + FunctionProcessor processor = ExtraClassManager.getInstance().getFunctionProcessor(); + if (processor != null) { + processor.recordFunction(ReportFunctionProcessor.MOBILE_TEMPLATE_FRM); } + // 设置移动端属性并刷新界面 + formTpl.setFormMobileAttr(formMobileAttr); // 会调整 body 的自适应布局,放到最后 + ((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified(); + WidgetPropertyPane.getInstance().refreshDockingView(); } }); dialog.setVisible(true); diff --git a/designer-form/src/com/fr/design/mainframe/actions/NewFormAction.java b/designer-form/src/com/fr/design/mainframe/actions/NewFormAction.java index b5efec1fe3..275d02f4ea 100644 --- a/designer-form/src/com/fr/design/mainframe/actions/NewFormAction.java +++ b/designer-form/src/com/fr/design/mainframe/actions/NewFormAction.java @@ -9,9 +9,8 @@ import com.fr.design.menu.MenuKeySet; import com.fr.general.Inter; import com.fr.stable.bridge.StableFactory; -import javax.swing.*; +import javax.swing.KeyStroke; import java.awt.event.ActionEvent; -import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; diff --git a/designer-form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer-form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index 841e9c2908..538f26099d 100644 --- a/designer-form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer-form/src/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.widget.ui; +import com.fr.base.BaseUtils; import com.fr.design.data.DataCreatorUI; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; @@ -16,7 +17,9 @@ import com.fr.design.dialog.BasicScrollPane; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.FormDesigner; import com.fr.design.widget.DataModify; import com.fr.design.widget.FormWidgetDefinePaneFactoryBase; @@ -34,6 +37,7 @@ import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JComponent; +import javax.swing.JOptionPane; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -208,6 +212,12 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { currentEditorDefinePane.setGlobalName(getGlobalName()); Widget widget = currentEditorDefinePane.updateBean(); if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Basic")) && widgetPropertyPane != null) { + UITextField widgetNameField = widgetPropertyPane.getWidgetNameField(); + if (designer.getTarget().isNameExist(widgetNameField.getText()) && !ComparatorUtils.equals(widgetNameField.getText(), widget.getWidgetName())) { + widgetNameField.setText(widget.getWidgetName()); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Form_Widget_Rename_Failure"), Inter.getLocText("FR-Designer_Joption_News"), JOptionPane.ERROR_MESSAGE, BaseUtils.readIcon("com/fr/design/form/images/joption_failure.png")); + return; + } widgetPropertyPane.update(widget); xCreator.resetCreatorName(widget.getWidgetName()); xCreator.resetVisible(widget.isVisible()); diff --git a/designer-form/src/com/fr/design/parameter/ParameterPropertyPane.java b/designer-form/src/com/fr/design/parameter/ParameterPropertyPane.java index cf393be8db..b8bfe4e0b0 100644 --- a/designer-form/src/com/fr/design/parameter/ParameterPropertyPane.java +++ b/designer-form/src/com/fr/design/parameter/ParameterPropertyPane.java @@ -1,6 +1,7 @@ package com.fr.design.parameter; import com.fr.design.constants.UIConstants; +import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.dialog.BasicScrollPane; import com.fr.design.gui.ibutton.UIButton; @@ -79,7 +80,7 @@ public class ParameterPropertyPane extends JPanel{ } }; JPanel scrollPaneWrapperInner = new JPanel(new BorderLayout()); - scrollPaneWrapperInner.setBorder(BorderFactory.createEmptyBorder(0, PADDING_MIDDLE, PADDING_MIDDLE, PADDING_SMALL)); + scrollPaneWrapperInner.setBorder(BorderFactory.createEmptyBorder(PADDING_MIDDLE, PADDING_MIDDLE, PADDING_MIDDLE, PADDING_SMALL)); scrollPaneWrapperInner.add(basicScrollPane, BorderLayout.CENTER); addParaPane = new JPanel(new BorderLayout()); addParaPane.add(scrollPaneWrapperInner, BorderLayout.CENTER); @@ -87,8 +88,8 @@ public class ParameterPropertyPane extends JPanel{ initParameterListener(); this.setLayout(new BorderLayout(0, 6)); - this.setBorder(BorderFactory.createEmptyBorder(PADDING_MIDDLE, 0, PADDING_MIDDLE, 0)); - this.add(addParaPane, BorderLayout.CENTER); + this.setBorder(BorderFactory.createEmptyBorder(0, 0, PADDING_MIDDLE, 0)); + this.add(addParaPane, BorderLayout.NORTH); } // 显示或隐藏添加参数面板 @@ -113,14 +114,15 @@ public class ParameterPropertyPane extends JPanel{ } public void setAddParaPaneVisible(boolean isVisible, JTemplate jt) { - if (isVisible == addParaPane.isVisible() || formHierarchyTreePaneWrapper == null) { + if (formHierarchyTreePaneWrapper == null) { return; } // 表单中,只有添加并选中参数面板时,才显示 boolean hideInJForm; try { + XCreator creator = (XCreator) FormHierarchyTreePane.getInstance().getComponentTree().getSelectionPath().getLastPathComponent(); hideInJForm = jt instanceof JForm && - !(FormHierarchyTreePane.getInstance().getComponentTree().getSelectionPath().getLastPathComponent() instanceof XWParameterLayout); + !(creator instanceof XWParameterLayout || creator.getParent() instanceof XWParameterLayout); } catch (NullPointerException ex) { hideInJForm = true; } @@ -129,7 +131,9 @@ public class ParameterPropertyPane extends JPanel{ this.setPreferredSize(null); } else { addParaPane.setVisible(false); - this.setPreferredSize(new Dimension(getWidth(), formHierarchyTreePaneWrapper.getPreferredSize().height + UIConstants.GAP_NORMAL)); + if (formHierarchyTreePaneWrapper.getPreferredSize().height > 0) { + this.setPreferredSize(new Dimension(getWidth(), formHierarchyTreePaneWrapper.getPreferredSize().height + UIConstants.GAP_NORMAL)); + } } } @@ -137,7 +141,7 @@ public class ParameterPropertyPane extends JPanel{ if (formHierarchyTreePaneWrapper == null) { formHierarchyTreePaneWrapper = new JPanel(new BorderLayout()); formHierarchyTreePaneWrapper.setBorder(BorderFactory.createEmptyBorder(0, PADDING_MIDDLE, 0, 0)); - this.add(formHierarchyTreePaneWrapper, BorderLayout.SOUTH); + this.add(formHierarchyTreePaneWrapper, BorderLayout.CENTER); } formHierarchyTreePaneWrapper.remove(FormHierarchyTreePane.getInstance()); formHierarchyTreePaneWrapper.add(FormHierarchyTreePane.getInstance(editor), BorderLayout.CENTER); diff --git a/designer-form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java b/designer-form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java index 8eef29192a..dd21b4d849 100644 --- a/designer-form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java +++ b/designer-form/src/com/fr/design/widget/ui/designer/component/TabFitLayoutBackgroundPane.java @@ -1,6 +1,7 @@ package com.fr.design.widget.ui.designer.component; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.widget.accessibles.AccessibleTabBackgroundEditor; import com.fr.design.widget.component.BackgroundCompPane; import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.general.Background; @@ -15,33 +16,47 @@ public class TabFitLayoutBackgroundPane extends BackgroundCompPane { private UISpinner componentIntervel; private PaddingBoundPane paddingBound; private AccessibleWLayoutBorderStyleEditor stylePane; - private AccessibleBodyWatermarkEditor watermarkEditor; public FRFitLayoutDefinePane(XCreator xCreator) { super(xCreator); @@ -76,13 +72,9 @@ public class FRFitLayoutDefinePane extends AbstractDataModify { public JPanel createAdvancePane() { JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); stylePane = new AccessibleWLayoutBorderStyleEditor(); - watermarkEditor = new AccessibleBodyWatermarkEditor(); paddingBound = new PaddingBoundPane(); - JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane( - new Component[][]{ - new Component[]{new UILabel(Inter.getLocText("FR-Designer-Widget_Style")), stylePane}, - new Component[]{new UILabel(Inter.getLocText("FR-Designer_WaterMark")), watermarkEditor} - }, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); + JPanel jp2 = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ + new Component[]{new UILabel(Inter.getLocText("FR-Designer-Widget_Style")), stylePane}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W3, IntervalConstants.INTERVAL_L1); jp2.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); jPanel.add(paddingBound, BorderLayout.CENTER); jPanel.add(jp2, BorderLayout.NORTH); @@ -143,7 +135,6 @@ public class FRFitLayoutDefinePane extends AbstractDataModify { adaptComboBox.setSelectedIndex(ob.getCompState()); componentIntervel.setValue(ob.getCompInterval()); stylePane.setValue(ob.getBorderStyle()); - watermarkEditor.setValue(ReportUtils.getWatermarkFromAttrMarkFile(getCurrentIOFile())); } private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) { @@ -158,12 +149,13 @@ public class FRFitLayoutDefinePane extends AbstractDataModify { @Override public WFitLayout updateBean() { WFitLayout layout = (WFitLayout) creator.toData(); - paddingBound.update(layout); + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Layout-Padding"))) { + paddingBound.update(layout); + } LayoutBorderStyle borderStyle = (LayoutBorderStyle) stylePane.getValue(); if(borderStyle != null){ layout.setBorderStyle(borderStyle); } - updateWatermark(); Item item = (Item) layoutComboBox.getSelectedItem(); Object value = item.getValue(); int state = 0; @@ -195,7 +187,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify { FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); } } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); + FRLogger.getLogger().error(e.getMessage()); } //todo 验证下 @@ -211,18 +203,6 @@ public class FRFitLayoutDefinePane extends AbstractDataModify { return layout; } - private void updateWatermark() { - WatermarkAttr watermark = (WatermarkAttr) watermarkEditor.getValue(); - if (watermark != null) { - IOFile ioFile = getCurrentIOFile(); - ioFile.addAttrMark(watermark); - } - } - - private IOFile getCurrentIOFile() { - return WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); - } - private void setLayoutGap(int value) { int interval = wFitLayout.getCompInterval(); if (value != interval) { diff --git a/designer-form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java b/designer-form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java index ff2b139c2a..f07a66d12e 100644 --- a/designer-form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java +++ b/designer-form/src/com/fr/design/widget/ui/designer/layout/WCardMainLayoutDefinePane.java @@ -25,7 +25,7 @@ import java.awt.event.ActionListener; /** * Created by ibm on 2017/8/2. */ -public class WCardMainLayoutDefinePane extends AbstractDataModify { +public class WCardMainLayoutDefinePane extends AbstractDataModify { private AccessibleCardTagWLayoutBorderStyleEditor accessibleCardTagWLayoutBorderStyleEditor; private UICheckBox setCarousel; private UISpinner carouselInterval; @@ -38,7 +38,7 @@ public class WCardMainLayoutDefinePane extends AbstractDataModify { - private AccessibleImgBackgroundEditor backgroundEditor; + private AccessibleTabPaneBackgroundEditor backgroundEditor; private FRFontPane frFontPane; private UIButtonGroup displayPositionGroup; private UIButtonGroup textDirectionGroup; @@ -47,7 +50,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify public void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - backgroundEditor = new AccessibleImgBackgroundEditor(); + backgroundEditor = new AccessibleTabPaneBackgroundEditor(); templateStyleEditor = new AccessibleTemplateStyleEditor(); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; @@ -57,8 +60,27 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify UILabel fontLabel = new UILabel(Inter.getLocText("FR-Designer_Font")); fontLabel.setVerticalAlignment(SwingConstants.TOP); - frFontPane = new FRFontPane(); - displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray()); + frFontPane = new FRFontPane() { + protected JPanel createRightPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f}; + double[] rowSize = {p}; + int[][] rowCount = {{1, 1}}; + Component[][] components = new Component[][]{ + new Component[]{fontSizeComboBox}, + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); + } + + }; + displayPositionGroup = new UIButtonGroup(WTabDisplayPosition.getStringArray()) { + @Override + public boolean shouldResponseNameListener() { + return true; + } + }; + displayPositionGroup.setGlobalName(Inter.getLocText("FR-Designer_Tab_Style_Template")); textDirectionGroup = new UIButtonGroup(WTabTextDirection.getStringArray()); Component[][] components = new Component[][]{ new Component[]{new UILabel(Inter.getLocText("FR-Designer_Tab_Style_Template")), templateStyleEditor}, @@ -84,7 +106,7 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify public void populateBean(WCardTagLayout ob) { //标题背景和字体属性设置在WCardLayout上做兼容 XLayoutContainer topLayout = creator.getTopLayout(); - LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle(); + LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout) topLayout).getCardPart().toData().getBorderStyle(); displayPositionGroup.setSelectedIndex(ob.getDisplayPosition().getType()); textDirectionGroup.setSelectedIndex(ob.getTextDirection().getType()); @@ -100,14 +122,29 @@ public class WCardTagLayoutDefinePane extends AbstractDataModify public WCardTagLayout updateBean() { //标题背景和字体属性设置在WCardLayout上做兼容 XLayoutContainer topLayout = creator.getTopLayout(); - LayoutBorderStyle layoutBorderStyle = ((XWCardMainBorderLayout)topLayout).getCardPart().toData().getBorderStyle(); + XWCardLayout xCardLayout = ((XWCardMainBorderLayout) topLayout).getCardPart(); + LayoutBorderStyle layoutBorderStyle = xCardLayout.toData().getBorderStyle(); FRFont frFont = layoutBorderStyle.getTitle().getFrFont() == null ? FRFont.getInstance() : layoutBorderStyle.getTitle().getFrFont(); - layoutBorderStyle.getTitle().setBackground((Background) backgroundEditor.getValue()); layoutBorderStyle.getTitle().setFrFont(frFontPane.update(frFont)); WCardTagLayout layout = (WCardTagLayout) creator.toData(); - layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex())); + boolean isHori = displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.TOP_POSITION.getType() || displayPositionGroup.getSelectedIndex() == WTabDisplayPosition.BOTTOM_POSITION.getType(); + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Tab_Style_Template"))) { + layout.setDisplayPosition(WTabDisplayPosition.parse(displayPositionGroup.getSelectedIndex())); + textDirectionGroup.setSelectedIndex(isHori ? WTabTextDirection.TEXT_HORI_DERECTION.getType() : WTabTextDirection.TEXT_VER_DIRECTION.getType()); + layout.setHgap(isHori ? WCardTagLayout.DESIGNER_DEFAULT_GAP : 0); + layout.setVgap(isHori ? 0 : WCardTagLayout.DESIGNER_DEFAULT_GAP); + } layout.setTextDirection(WTabTextDirection.parse(textDirectionGroup.getSelectedIndex())); - layout.setTemplateStyle((TemplateStyle) templateStyleEditor.getValue()); + TemplateStyle templateStyle = (TemplateStyle) templateStyleEditor.getValue(); + if (!ComparatorUtils.equals(layout.getTemplateStyle(), templateStyle)) { + backgroundEditor.setValue(templateStyle.getDefaultBackground()); + layoutBorderStyle.getTitle().setBackground(templateStyle.getDefaultBackground()); + //重置内部tab的默认背景 + xCardLayout.resetTabBackground(templateStyle); + layout.setTemplateStyle(templateStyle); + } else { + layoutBorderStyle.getTitle().setBackground((Background) backgroundEditor.getValue()); + } return layout; } diff --git a/designer-form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java b/designer-form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java index 85ca8ee977..46906925f0 100644 --- a/designer-form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java +++ b/designer-form/src/com/fr/design/widget/ui/designer/layout/WTabFitLayoutDefinePane.java @@ -19,6 +19,7 @@ import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import javax.swing.BorderFactory; @@ -77,12 +78,12 @@ public class WTabFitLayoutDefinePane extends AbstractDataModify { @Override public void populateBean(WTabFitLayout ob) { - borderStyle.populate(ob); paddingBoundPane.populate(ob); componentInterval.setValue(ob.getCompInterval()); if(ob.getCurrentCard() == null){ ob.setCurrentCard(getRelateSwitchButton(ob)); } + borderStyle.populate(ob); titleField.setText(ob.getCurrentCard().getText()); } @@ -118,7 +119,9 @@ public class WTabFitLayoutDefinePane extends AbstractDataModify { public WTabFitLayout updateBean() { WTabFitLayout layout = (WTabFitLayout) creator.toData(); borderStyle.update(layout); - paddingBoundPane.update(layout); + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Layout-Padding"))) { + paddingBoundPane.update(layout); + } int gap = (int)componentInterval.getValue(); setLayoutGap(gap, layout, (XWTabFitLayout)creator); layout.getCurrentCard().setText(titleField.getText()); diff --git a/designer-form/src/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java b/designer-form/src/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java index 70c3b94f63..cbfbfb68cb 100644 --- a/designer-form/src/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java +++ b/designer-form/src/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java @@ -18,9 +18,14 @@ import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.form.ui.ElementCaseEditor; import com.fr.general.Inter; +import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; /** * 报表块-移动端属性面板 @@ -28,6 +33,7 @@ import java.awt.*; * Created by fanglei on 2017/8/8. */ public class ElementCaseDefinePane extends MobileWidgetDefinePane{ + private static final double MAX_HEIGHT_LIMIT = 0.8; private static final Item[] ITEMS = { new Item(MobileFitAttrState.HORIZONTAL.description(), MobileFitAttrState.HORIZONTAL), new Item(MobileFitAttrState.VERTICAL.description(), MobileFitAttrState.VERTICAL), @@ -48,25 +54,6 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane{ this.xCreator = xCreator; } - @Override - protected void initContentPane() {} - - @Override - protected JPanel createContentPane() { - return null; - } - - @Override - public String getIconPath() { - return ""; - } - - @Override - public String title4PopupWindow() { - return "ElementCase"; - } - - @Override public void initPropertyGroups(Object source) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -75,7 +62,25 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane{ this.vComboBox = new UIComboBox(ITEMS); this.heightRestrictCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Mobile-Height-Limit")); this.maxHeightLabel = new UILabel(Inter.getLocText("FR-Designer_Mobile-Height-Percent"), SwingConstants.LEFT); - this.maxHeightSpinner = new UISpinner(0, 1, 0.01, 0.75); + this.maxHeightSpinner = new UISpinner(0, MAX_HEIGHT_LIMIT, 0.01, 0.75) { + public void setValue(double value) { + String warningText = StringUtils.EMPTY; + if (value > MAX_HEIGHT_LIMIT) { + warningText = Inter.getLocText("FR-Designer_Mobile-Warning"); + } else if (value < 0) { + // 弹窗提示 + warningText = Inter.getLocText("FR-Designer_Max_Height_Cannot_Be_Negative"); + } + if (StringUtils.isNotEmpty(warningText)) { + // 弹窗提示 + JOptionPane.showMessageDialog(null, + warningText, + Inter.getLocText("FR-Designer_Tooltips"), + JOptionPane.PLAIN_MESSAGE); + } + super.setValue(value); + } + }; maxHeightSpinner.setVisible(false); maxHeightLabel.setVisible(false); diff --git a/designer-form/src/com/fr/design/widget/ui/designer/mobile/MobileWidgetDefinePane.java b/designer-form/src/com/fr/design/widget/ui/designer/mobile/MobileWidgetDefinePane.java index 49d0b59a52..ac4de096a6 100644 --- a/designer-form/src/com/fr/design/widget/ui/designer/mobile/MobileWidgetDefinePane.java +++ b/designer-form/src/com/fr/design/widget/ui/designer/mobile/MobileWidgetDefinePane.java @@ -3,6 +3,8 @@ package com.fr.design.widget.ui.designer.mobile; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.mainframe.FormDesigner; +import javax.swing.*; + /** * 所有移动端需要拓展的属性面板均继承此类 * @@ -23,4 +25,14 @@ public abstract class MobileWidgetDefinePane extends AbstractAttrNoScrollPane{ * 从属性面板把数据传到后台 */ public abstract void update(); + + // 暂不需要此方法 + @Override + protected void initContentPane() {} + + // 暂不需要此方法 + @Override + protected JPanel createContentPane() { + return new JPanel(); + } } diff --git a/designer-realize/src/com/fr/design/actions/edit/EditFloatElementNameAction.java b/designer-realize/src/com/fr/design/actions/edit/EditFloatElementNameAction.java index e5a6354606..2923c271ce 100644 --- a/designer-realize/src/com/fr/design/actions/edit/EditFloatElementNameAction.java +++ b/designer-realize/src/com/fr/design/actions/edit/EditFloatElementNameAction.java @@ -39,7 +39,7 @@ public class EditFloatElementNameAction extends FloatSelectionAction { if (report.getFloatElement(name) == null) { selectedFloatElement.setName(name); } - reportPane.setSelection(new FloatSelection(name)); + ((FloatSelection) reportPane.getSelection()).setFloatName(name); } }); nameDialog.setVisible(true); diff --git a/designer-realize/src/com/fr/design/actions/report/ReportPrintSettingAction.java b/designer-realize/src/com/fr/design/actions/report/ReportPrintSettingAction.java new file mode 100644 index 0000000000..ee07807ea5 --- /dev/null +++ b/designer-realize/src/com/fr/design/actions/report/ReportPrintSettingAction.java @@ -0,0 +1,75 @@ +package com.fr.design.actions.report; + +import com.fr.base.IconManager; +import com.fr.base.print.PrintSettingsAttrMark; +import com.fr.design.actions.JWorkBookAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JWorkBook; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.webattr.printsettings.ReportPrintSettingPane; +import com.fr.general.IOUtils; +import com.fr.general.Inter; +import com.fr.main.TemplateWorkBook; +import com.fr.main.impl.WorkBook; +import com.fr.report.core.ReportUtils; + +import javax.swing.KeyStroke; +import java.awt.event.ActionEvent; + +/** + * Created by plough on 2018/3/5. + */ +public class ReportPrintSettingAction extends JWorkBookAction { + + public ReportPrintSettingAction(JWorkBook jwb) { + super(jwb); + this.setMenuKeySet(REPORT_APP_ATTR); + this.setName(getMenuKeySet().getMenuKeySetName() + "..."); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(IOUtils.readIcon(IconManager.PRINT.getPath())); + this.setSearchText(new ReportPrintSettingPane()); + } + + /** + * 执行动作 + * + * @return 是否执行成功 + */ + public void actionPerformed(ActionEvent evt) { + final JWorkBook jwb = getEditingComponent(); + if (jwb == null) { + return; + } + final WorkBook wbTpl = jwb.getTarget(); + PrintSettingsAttrMark printSettings = ReportUtils.getPrintSettingsFromWorkbook(wbTpl); + + final ReportPrintSettingPane reportPrintSettingPane = new ReportPrintSettingPane(); + reportPrintSettingPane.populate(printSettings); + BasicDialog dialog = reportPrintSettingPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + PrintSettingsAttrMark newPrintSettings = reportPrintSettingPane.updateBean(); + wbTpl.addAttrMark(newPrintSettings); + jwb.fireTargetModified(); + } + }); + dialog.setVisible(true); + } + + private static final MenuKeySet REPORT_APP_ATTR = new MenuKeySet() { + @Override + public char getMnemonic() { return 'P'; } + + @Override + public String getMenuName() { + return Inter.getLocText("FR-Designer_Print_Setting"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; +} diff --git a/designer-realize/src/com/fr/design/images/splash_10.gif b/designer-realize/src/com/fr/design/images/splash_10.gif new file mode 100644 index 0000000000..0f099397e5 Binary files /dev/null and b/designer-realize/src/com/fr/design/images/splash_10.gif differ diff --git a/designer-realize/src/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer-realize/src/com/fr/design/mainframe/ElementCasePaneDelegate.java index 38a13c2c06..b3dc014109 100644 --- a/designer-realize/src/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer-realize/src/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -79,9 +79,7 @@ public class ElementCasePaneDelegate extends ElementCasePane { EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(RolesAlreadyEditedPane.getInstance()); return; } - if (DesignerContext.getDesignerFrame().getSelectedJTemplate() != null) { - CellWidgetPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); - } + CellWidgetPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); CellElementPropertyPane.getInstance().populate(ElementCasePaneDelegate.this); QuickEditorRegion.getInstance().populate(getCurrentEditor()); JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); diff --git a/designer-realize/src/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/com/fr/design/mainframe/JWorkBook.java index 472231b7ee..bb75eda532 100644 --- a/designer-realize/src/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/com/fr/design/mainframe/JWorkBook.java @@ -22,6 +22,7 @@ import com.fr.design.actions.file.export.WordExportAction; import com.fr.design.actions.report.ReportExportAttrAction; import com.fr.design.actions.report.ReportMobileAttrAction; import com.fr.design.actions.report.ReportParameterAction; +import com.fr.design.actions.report.ReportPrintSettingAction; import com.fr.design.actions.report.ReportWatermarkAction; import com.fr.design.actions.report.ReportWebAttrAction; import com.fr.design.cell.bar.DynamicScrollBar; @@ -695,6 +696,7 @@ public class JWorkBook extends JTemplate { new ReportExportAttrAction(this), new ReportParameterAction(this), new ReportMobileAttrAction(this), + new ReportPrintSettingAction(this), new ReportWatermarkAction(this), new NameSeparator(Inter.getLocText("Utils-Current_Sheet")), }, this.reportComposite.getEditingReportComponent().shortcut4TemplateMenu()); @@ -1027,6 +1029,11 @@ public class JWorkBook extends JTemplate { return ps; } + @Override + public Parameter[] getJTemplateParameters() { + return this.parameterPane.getAllParameters(); + } + /** * 请求单元格区域的焦点 */ diff --git a/designer-realize/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer-realize/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index fcbdd58ff9..3d97fd92ba 100644 --- a/designer-realize/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer-realize/src/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -7,13 +7,14 @@ import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.layout.*; +import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; @@ -63,8 +64,14 @@ public class CellOtherSetPane extends AbstractCellAttrPane { private UICheckBox canBreakOnPaginateCheckBox; private UICheckBox repeatCheckBox; - private UICheckBox autoHeightCheckBox; - private UICheckBox autoWidthCheckBox; + + // 自动调整 + private UIRadioButton autoHeightRadioButton; // 自动调整行高 + private UIRadioButton autoWidthRadioButton; // 自动调整列宽 + private UIRadioButton noAutoRadioButton; // 不自动调整 + private UIRadioButton defaultAutoRadioButton; // 跟随页面设置(默认) + private UIRadioButton[] adjustRadioButtons; + // 插入行策略 private UIButtonGroup insertRowPolicy; private ValueEditorPane valueEditor; @@ -80,7 +87,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { */ public JPanel createContentPane() { JPanel downPane = new JPanel(new BorderLayout()); - downPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Advanced"), HEAD_WDITH, HEAD_HEIGTH, seniorPane()), BorderLayout.NORTH); + downPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Auto_Adjust_Size"), HEAD_WDITH, HEAD_HEIGTH, seniorPane()), BorderLayout.NORTH); downPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Pagination"), HEAD_WDITH, HEAD_HEIGTH, pagePane()), BorderLayout.CENTER); JPanel contentPane = new JPanel(new BorderLayout(0, 0)); contentPane.add(new UIExpandablePane(Inter.getLocText("FR-Designer_Basic"), HEAD_WDITH, HEAD_HEIGTH, basicPane()), BorderLayout.NORTH); @@ -89,24 +96,36 @@ public class CellOtherSetPane extends AbstractCellAttrPane { return contentPane; } - private JPanel basicPane() { - autoHeightCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Auto_Adjust_Height")); - autoWidthCheckBox = new UICheckBox(Inter.getLocText("FR-Designer_Auto_Adjust_Wdith")); - autoHeightCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); - autoWidthCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p}; - double[] columnSize = {p}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; - Component[][] components = new Component[][]{ - new Component[]{null}, - new Component[]{autoHeightCheckBox}, - new Component[]{autoWidthCheckBox}, - new Component[]{null}, + defaultAutoRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Follow_Paper_Settings")); + noAutoRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_No_Auto_Adjust")); + autoHeightRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Auto_Adjust_Height")); + autoWidthRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Auto_Adjust_Width")); + adjustRadioButtons = new UIRadioButton[]{ + defaultAutoRadioButton, noAutoRadioButton, autoHeightRadioButton, autoWidthRadioButton }; - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_LARGE); + // 指定分组 + ButtonGroup autoBG = new ButtonGroup(); + for (UIRadioButton radioButton : adjustRadioButtons) { + autoBG.add(radioButton); + } + + JPanel basicPane = new JPanel() { + @Override + public Insets getInsets() { + return new Insets(LayoutConstants.VGAP_MEDIUM, 0, LayoutConstants.VGAP_MEDIUM, 0); + } + }; + VerticalFlowLayout verticalFlowLayout = new VerticalFlowLayout(VerticalFlowLayout.CENTER, 0, 0); + verticalFlowLayout.setAlignLeft(true); + basicPane.setLayout(verticalFlowLayout); + basicPane.add(defaultAutoRadioButton); + basicPane.add(noAutoRadioButton); + basicPane.add(autoHeightRadioButton); + basicPane.add(autoWidthRadioButton); + + return basicPane; } private JPanel seniorPane() { @@ -268,12 +287,13 @@ public class CellOtherSetPane extends AbstractCellAttrPane { private void initAllNames() { -// autoshrik.setGlobalName(Inter.getLocText("FR-Designer_Auto_Adjust_Size")); - autoHeightCheckBox.setGlobalName(Inter.getLocText("FR-Designer_Auto_Adjust_Height")); - autoWidthCheckBox.setGlobalName(Inter.getLocText("FR-Designer_Auto_Adjust_Wdith")); + defaultAutoRadioButton.setGlobalName(Inter.getLocText("FR-Designer_Follow_Paper_Settings")); + noAutoRadioButton.setGlobalName(Inter.getLocText("FR-Designer_No_Auto_Adjust")); + autoHeightRadioButton.setGlobalName(Inter.getLocText("FR-Designer_Auto_Adjust_Height")); + autoWidthRadioButton.setGlobalName(Inter.getLocText("FR-Designer_Auto_Adjust_Width")); previewCellContent.setGlobalName(Inter.getLocText("FR-Designer_Preview")); - printAndExportContent.setGlobalName(Inter.getLocText("CellWrite-Preview_Cell_Content")); - printAndExportBackground.setGlobalName(Inter.getLocText("CellWrite-Print_Background")); + printAndExportContent.setGlobalName(Inter.getLocText("FR-Designer_CellWrite_Print_Content")); + printAndExportBackground.setGlobalName(Inter.getLocText("FR-Designer_CellWrite_Print_Background")); showContent.setGlobalName(Inter.getLocText("FR-Designer_Show_Content")); fileNameTextField.setGlobalName(Inter.getLocText("FR-Designer_Show_Content")); tooltipTextField.setGlobalName(Inter.getLocText("FR-Designer_CellWrite_ToolTip")); @@ -300,27 +320,32 @@ public class CellOtherSetPane extends AbstractCellAttrPane { if (cellGUIAttr == null) { cellGUIAttr = CellGUIAttr.DEFAULT_CELLGUIATTR; } -// autoshrik.setSelectedIndex(cellGUIAttr.getAdjustMode()); + + // 是否在编辑表单中的报表块 + boolean isInForm = EastRegionContainerPane.getInstance().getCurrentMode().equals(EastRegionContainerPane.PropertyMode.FORM_REPORT); + + defaultAutoRadioButton.setVisible(!isInForm); switch (cellGUIAttr.getAdjustMode()) { - case 0: - autoHeightCheckBox.setSelected(false); - autoWidthCheckBox.setSelected(false); + case CellGUIAttr.ADJUST_MODE_NO_AUTO: + noAutoRadioButton.setSelected(true); break; - case 1: - autoHeightCheckBox.setSelected(true); - autoWidthCheckBox.setSelected(false); + case CellGUIAttr.ADJUST_MODE_AUTO_HEIGHT: + autoHeightRadioButton.setSelected(true); break; - case 2: - autoHeightCheckBox.setSelected(false); - autoWidthCheckBox.setSelected(true); + case CellGUIAttr.ADJUST_MODE_AUTO_WIDTH: + autoWidthRadioButton.setSelected(true); break; - case 3: - autoHeightCheckBox.setSelected(true); - autoWidthCheckBox.setSelected(true); + case CellGUIAttr.ADJUST_MODE_DEFAULT: + if (isInForm) { + autoHeightRadioButton.setSelected(true); + } else { + defaultAutoRadioButton.setSelected(true); + } break; default: break; } + previewCellContent.setSelected(cellGUIAttr.isPreviewContent()); printAndExportContent.setSelected(cellGUIAttr.isPrintContent()); printAndExportBackground.setSelected(cellGUIAttr.isPrintBackground()); @@ -384,32 +409,29 @@ public class CellOtherSetPane extends AbstractCellAttrPane { cellGUIAttr = new CellGUIAttr(); } -// if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Auto_Adjust_Size"))) { -// cellGUIAttr.setAdjustMode(autoshrik.getSelectedIndex()); -// } - - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Auto_Adjust_Height")) || ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Auto_Adjust_Wdith"))) { - int flag; - if (autoHeightCheckBox.isSelected()) { - if (autoWidthCheckBox.isSelected()) { - flag = 3; + for (UIRadioButton radioButton : adjustRadioButtons) { + if (ComparatorUtils.equals(getGlobalName(), radioButton.getGlobalName())) { + // 自动调整 + int flag; + if (defaultAutoRadioButton.isSelected()) { + flag = CellGUIAttr.ADJUST_MODE_DEFAULT; + } else if (autoWidthRadioButton.isSelected()) { + flag = CellGUIAttr.ADJUST_MODE_AUTO_WIDTH; + } else if (autoHeightRadioButton.isSelected()) { + flag = CellGUIAttr.ADJUST_MODE_AUTO_HEIGHT; } else { - flag = 1; + flag = CellGUIAttr.ADJUST_MODE_NO_AUTO; } - } else if (autoWidthCheckBox.isSelected()) { - flag = 2; - } else { - flag = 0; + cellGUIAttr.setAdjustMode(flag); + break; } - cellGUIAttr.setAdjustMode(flag); } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_Preview"))) { cellGUIAttr.setPreviewContent(previewCellContent.isSelected()); } - if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_CellWrite_Preview_Cell_Content"))) { + if (ComparatorUtils.equals(getGlobalName(), Inter.getLocText("FR-Designer_CellWrite_Print_Content"))) { cellGUIAttr.setPrintContent(printAndExportContent.isSelected()); } diff --git a/designer-realize/src/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java b/designer-realize/src/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java index 3e47457b51..d2740d681a 100644 --- a/designer-realize/src/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java +++ b/designer-realize/src/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java @@ -21,6 +21,7 @@ import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.present.ConditionAttributesGroupPane; import com.fr.form.main.Form; +import com.fr.grid.Grid; import com.fr.js.NameJavaScriptGroup; import com.fr.page.ReportSettingsProvider; import com.fr.report.elementcase.TemplateElementCase; @@ -32,9 +33,13 @@ import com.fr.design.selection.SelectionListener; */ public class FormElementCasePaneDelegate extends ElementCasePane{ - public FormElementCasePaneDelegate(FormElementCase sheet, Form form) { + public FormElementCasePaneDelegate(FormElementCase sheet, Form form) { super(sheet); - this.getGrid().setShowPaginateLine(form.getFormMobileAttr().isMobileOnly()); + + this.getGrid().setPaginateLineShowType(form.getFormMobileAttr().isMobileOnly() + ? Grid.SINGLE_HORIZONTAL_PAGINATE_LINE + : Grid.NO_PAGINATE_LINE); + this.addSelectionChangeListener(new SelectionListener() { @Override public void selectionChanged(SelectionEvent e) { @@ -138,9 +143,9 @@ public class FormElementCasePaneDelegate extends ElementCasePane allPrinterName = new HashSet(); + + for (int i = 0, len = printServices.length; i < len; i++) { + allPrinterName.add(printServices[i].getName()); + } + + return allPrinterName.toArray(new String[allPrinterName.size()]); + } + + private JPanel getPaperSettingPane() { + predefinedPaperSizeComboBox = new UIComboBox(); + for (int i = 0; i < ReportConstants.PaperSizeNameSizeArray.length; i++) { + Object[] tmpPaperSizeNameArray = ReportConstants.PaperSizeNameSizeArray[i]; + predefinedPaperSizeComboBox.addItem(tmpPaperSizeNameArray[1]); + } + predefinedPaperSizeComboBox.setRenderer(new UIComboBoxRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + if (value instanceof PaperSize) { + PaperSize paperSize = (PaperSize) value; + for (int i = 0; i < ReportConstants.PaperSizeNameSizeArray.length; i++) { + Object[] tmpPaperSizeNameArray = ReportConstants.PaperSizeNameSizeArray[i]; + + if (ComparatorUtils.equals(paperSize, tmpPaperSizeNameArray[1])) { + String sbuf = tmpPaperSizeNameArray[0].toString() + " [" + + Utils.convertNumberStringToString(paperSize.getWidth().toMMValue4Scale2()) + + 'x' + + Utils.convertNumberStringToString(paperSize.getHeight().toMMValue4Scale2()) + + ' ' + + Inter.getLocText("PageSetup-mm") + + ']'; + this.setText(sbuf); + break; + } + } + } + + return this; + } + }); + + JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + panel.add(predefinedPaperSizeComboBox); + panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0)); + return panel; + } + + private JPanel getLayoutSettingPane() { + JPanel layoutSettingPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + layoutSettingPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); + portraitRadioButton = new UIRadioButton(Inter.getLocText("PageSetup-Portrait")); + portraitRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); + landscapeRadioButton = new UIRadioButton(Inter.getLocText("PageSetup-Landscape")); + layoutSettingPane.add(portraitRadioButton); + layoutSettingPane.add(landscapeRadioButton); + + ButtonGroup layoutButtonGroup = new ButtonGroup(); + layoutButtonGroup.add(portraitRadioButton); + layoutButtonGroup.add(landscapeRadioButton); + + portraitRadioButton.setSelected(true); + return layoutSettingPane; + } + + // 页码范围 + private JPanel getPrintAreaPane() { + allPageRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_All_Pages")); + currentPageRadioButton = new UIRadioButton(Inter.getLocText("FR-Designer_Current_Page")); + customPageRadioButton = new UIRadioButton(Inter.getLocText("FR-Engine_HJS-Specified_Pages")); + ButtonGroup group = new ButtonGroup(); + group.add(allPageRadioButton); + group.add(currentPageRadioButton); + group.add(customPageRadioButton); + allPageRadioButton.setSelected(true); + + specifiedAreaField = new UITextField(20) { + @Override + public void setEnabled(boolean enabled) { + // 如果未选中"指定页",此输入框始终不可用 + if (enabled && !customPageRadioButton.isSelected()) { + return; + } + super.setEnabled(enabled); + } + }; + UILabel areaFieldTip = GUICoreUtils.createTipLabel(Inter.getLocText("FR-Designer_Print_Area_Tip")); + + // TableLayout + double p = TableLayout.PREFERRED; + double[] rowSize = {p, p, p}; + double[] columnSize = {p, p, p}; + Component[][] components = { + {allPageRadioButton, null, null}, + {currentPageRadioButton, null, null}, + {customPageRadioButton, specifiedAreaField, areaFieldTip} + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 0); + } + + // 返回包含一个标签的 panel,标签始终位于 panel 顶部 + private JPanel getTopAlignLabelPane(String labelText) { + JPanel labelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + labelPane.add(new UILabel(labelText), BorderLayout.NORTH); + return labelPane; + } + + public void populate(NativePrintAttr nativePrintAttr) { + isShowDialogCheck.setSelected(nativePrintAttr.isShowDialog()); + printerComboBox.setSelectedItem(nativePrintAttr.getPrinterName()); + copySpinner.setValue(nativePrintAttr.getCopy()); + + if (nativePrintAttr.getPageType().equals(NativePrintAttr.PageType.ALL_PAGES)) { + allPageRadioButton.setSelected(true); + } else if (nativePrintAttr.getPageType().equals(NativePrintAttr.PageType.CURRENT_PAGE)) { + currentPageRadioButton.setSelected(true); + } else { + customPageRadioButton.setSelected(true); + specifiedAreaField.setText(nativePrintAttr.getArea()); + } + specifiedAreaField.setEnabled(customPageRadioButton.isSelected()); + + inheritPagePaperSettingCheck.setSelected(nativePrintAttr.isInheritPagePaperSetting()); + predefinedPaperSizeComboBox.setSelectedItem(nativePrintAttr.getPaperSize()); + inheritPageLayoutSettingCheck.setSelected(nativePrintAttr.isInheritPageLayoutSetting()); + if (nativePrintAttr.getOrientation() == ReportConstants.PORTRAIT) { + portraitRadioButton.setSelected(true); + } else { + landscapeRadioButton.setSelected(true); + } + inheritPageMarginSettingCheck.setSelected(nativePrintAttr.isInheritPageMarginSetting()); + pageMarginSettingPane.populate(nativePrintAttr.getMargin()); + fitPaperSizeCheck.setSelected(nativePrintAttr.isFitPaperSize()); + } + + public void update(NativePrintAttr nativePrintAttr) { + nativePrintAttr.setShowDialog(isShowDialogCheck.isSelected()); + if (printerComboBox.getSelectedItem() != null) { + nativePrintAttr.setPrinterName(printerComboBox.getSelectedItem().toString()); + } + nativePrintAttr.setCopy((int)copySpinner.getValue()); + + // 页码 + if (allPageRadioButton.isSelected()) { + nativePrintAttr.setPageType(NativePrintAttr.PageType.ALL_PAGES); + } else if (currentPageRadioButton.isSelected()) { + nativePrintAttr.setPageType(NativePrintAttr.PageType.CURRENT_PAGE); + } else { + nativePrintAttr.setPageType(NativePrintAttr.PageType.SPECIFIED_PAGES); + nativePrintAttr.setArea(specifiedAreaField.getText()); + } + + nativePrintAttr.setInheritPagePaperSetting(inheritPagePaperSettingCheck.isSelected()); + nativePrintAttr.setPaperSize((PaperSize) predefinedPaperSizeComboBox.getSelectedItem()); + nativePrintAttr.setInheritPageLayoutSetting(inheritPageLayoutSettingCheck.isSelected()); + nativePrintAttr.setOrientation(portraitRadioButton.isSelected() ? + ReportConstants.PORTRAIT : ReportConstants.LANDSCAPE); + nativePrintAttr.setInheritPageMarginSetting(inheritPageMarginSettingCheck.isSelected()); + nativePrintAttr.setMargin(pageMarginSettingPane.updateBean()); + nativePrintAttr.setFitPaperSize(fitPaperSizeCheck.isSelected()); + } + + // 刷新面板可用状态 + public void checkEnabled() { + GUICoreUtils.setEnabled(centerPane, !isShowDialogCheck.isSelected()); + } +} diff --git a/designer-realize/src/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java b/designer-realize/src/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java new file mode 100644 index 0000000000..14ebc7c4a6 --- /dev/null +++ b/designer-realize/src/com/fr/design/webattr/printsettings/NoClientPrintSettingPane.java @@ -0,0 +1,103 @@ +package com.fr.design.webattr.printsettings; + +import com.fr.base.print.NoClientPrintAttr; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/** + * 零客户端打印设置面板 + * Created by plough on 2018/3/5. + */ +public class NoClientPrintSettingPane extends JPanel { + private UICheckBox setMarginWhenPrintCheck; + private UICheckBox inheritPageMarginSettingCheck; // 继承页面边距设置 + private PageMarginSettingPane pageMarginSettingPane; + private JPanel centerPane; + + public NoClientPrintSettingPane() { + initComponents(); + initListeners(); + } + + private void initComponents() { + JPanel printPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + + setMarginWhenPrintCheck = new UICheckBox(Inter.getLocText("FR-Engine_Set_Margin_When_Printing")); + setMarginWhenPrintCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); + UILabel tipLabel = GUICoreUtils.createTipLabel(Inter.getLocText("FR-Designer_Tip_Use_Default_Print_Margin")); + JPanel northPane = GUICoreUtils.createFlowPane(new Component[] { + setMarginWhenPrintCheck, tipLabel}, FlowLayout.LEFT); + northPane.setBorder(BorderFactory.createEmptyBorder(8, 10, 10, 0)); + + printPane.add(northPane, BorderLayout.NORTH); + + centerPane = FRGUIPaneFactory.createTitledBorderPane(Inter.getLocText("FR-Designer_Default_Settings")); + + inheritPageMarginSettingCheck = GUICoreUtils.createNoBorderCheckBox(Inter.getLocText("FR-Designer_Inherit_Page_Margin_Setting")); + pageMarginSettingPane = new PageMarginSettingPane(); + pageMarginSettingPane.setBorder(BorderFactory.createEmptyBorder(10, -10, 0, 0)); + JPanel pageMarginCheckPane = GUICoreUtils.createCheckboxAndDynamicPane(inheritPageMarginSettingCheck, pageMarginSettingPane, true); + + // TableLayout + double p = TableLayout.PREFERRED; + double[] rowSize = {p}; + double[] columnSize = {60, p}; + Component[][] components = { + {getTopAlignLabelPane(Inter.getLocText("FR-Designer_Margin") + ":"), pageMarginCheckPane} + }; + JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 15); + + centerPane.add(panel); + + printPane.add(centerPane, BorderLayout.CENTER); + + this.setLayout(new BorderLayout()); + this.add(printPane, BorderLayout.CENTER); + } + + private void initListeners() { + setMarginWhenPrintCheck.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + checkEnabled(); + } + }); + } + + // 返回包含一个标签的 panel,标签始终位于 panel 顶部 + private JPanel getTopAlignLabelPane(String labelText) { + JPanel labelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + labelPane.add(new UILabel(labelText), BorderLayout.NORTH); + return labelPane; + } + + public void populate(NoClientPrintAttr noClientPrintAttr) { + setMarginWhenPrintCheck.setSelected(noClientPrintAttr.isSetMarginOnPrint()); + inheritPageMarginSettingCheck.setSelected(noClientPrintAttr.isInheritPageMarginSetting()); + pageMarginSettingPane.populate(noClientPrintAttr.getMargin()); + } + + public void update(NoClientPrintAttr noClientPrintAttr) { + noClientPrintAttr.setSetMarginOnPrint(setMarginWhenPrintCheck.isSelected()); + noClientPrintAttr.setInheritPageMarginSetting(inheritPageMarginSettingCheck.isSelected()); + noClientPrintAttr.setMargin(pageMarginSettingPane.updateBean()); + } + + // 刷新面板可用状态 + public void checkEnabled() { + GUICoreUtils.setEnabled(centerPane, !setMarginWhenPrintCheck.isSelected()); + } +} diff --git a/designer-realize/src/com/fr/design/webattr/printsettings/PageMarginSettingPane.java b/designer-realize/src/com/fr/design/webattr/printsettings/PageMarginSettingPane.java new file mode 100644 index 0000000000..8c63fa5207 --- /dev/null +++ b/designer-realize/src/com/fr/design/webattr/printsettings/PageMarginSettingPane.java @@ -0,0 +1,79 @@ +package com.fr.design.webattr.printsettings; + +import com.fr.base.Margin; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.report.UnitFieldPane; +import com.fr.general.Inter; +import com.fr.stable.Constants; + +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * Created by plough on 2018/3/5. + */ +public class PageMarginSettingPane extends JPanel { + private UnitFieldPane marginTopUnitFieldPane; + private UnitFieldPane marginBottomUnitFieldPane; + private UnitFieldPane marginLeftUnitFieldPane; + private UnitFieldPane marginRightUnitFieldPane; + + public PageMarginSettingPane() { + initComponents(); + } + private void initComponents() { + // 页边距设置面板 + JPanel marginPane = FRGUIPaneFactory.createX_AXISBoxInnerContainer_M_Pane(); + // left + JPanel marginLeftPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); + marginPane.add(marginLeftPane); + + JPanel marginLeftTextPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + marginLeftPane.add(marginLeftTextPane); + marginLeftTextPane.add(new UILabel(Inter.getLocText("Top") + ":")); + marginTopUnitFieldPane = new UnitFieldPane(Constants.UNIT_MM); + marginLeftTextPane.add(marginTopUnitFieldPane); + JPanel marginLeftUnitPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + marginLeftPane.add(marginLeftUnitPane); + marginLeftUnitPane.add(new UILabel(Inter.getLocText("Bottom") + ":")); + marginBottomUnitFieldPane = new UnitFieldPane(Constants.UNIT_MM); + marginLeftUnitPane.add(marginBottomUnitFieldPane); + + // right + JPanel marginRightPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); + marginPane.add(marginRightPane); + + // peter:这个一个垂直的上下的字符panel. + JPanel marginRightTextPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + marginRightPane.add(marginRightTextPane); + marginRightTextPane.add(new UILabel(Inter.getLocText("Left") + ":")); + marginLeftUnitFieldPane = new UnitFieldPane(Constants.UNIT_MM); + marginRightTextPane.add(marginLeftUnitFieldPane); + + JPanel marginRightUnitPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + marginRightPane.add(marginRightUnitPane); + marginRightUnitPane.add(new UILabel(Inter.getLocText("Right") + ":")); + marginRightUnitFieldPane = new UnitFieldPane(Constants.UNIT_MM); + marginRightUnitPane.add(marginRightUnitFieldPane); + + this.setLayout(new BorderLayout()); + this.add(marginPane, BorderLayout.CENTER); + } + + public void populate(Margin margin) { + marginTopUnitFieldPane.setUnitValue(margin.getTop()); + marginLeftUnitFieldPane.setUnitValue(margin.getLeft()); + marginBottomUnitFieldPane.setUnitValue(margin.getBottom()); + marginRightUnitFieldPane.setUnitValue(margin.getRight()); + } + + public Margin updateBean() { + Margin margin = new Margin(); + margin.setTop(marginTopUnitFieldPane.getUnitValue()); + margin.setLeft(marginLeftUnitFieldPane.getUnitValue()); + margin.setBottom(marginBottomUnitFieldPane.getUnitValue()); + margin.setRight(marginRightUnitFieldPane.getUnitValue()); + return margin; + } +} diff --git a/designer-realize/src/com/fr/design/webattr/printsettings/PrintSettingPane.java b/designer-realize/src/com/fr/design/webattr/printsettings/PrintSettingPane.java new file mode 100644 index 0000000000..bed697c3c7 --- /dev/null +++ b/designer-realize/src/com/fr/design/webattr/printsettings/PrintSettingPane.java @@ -0,0 +1,112 @@ +package com.fr.design.webattr.printsettings; + +import com.fr.base.print.PrintSettingsAttrMark; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/** + * Created by plough on 2018/3/1. + */ +public class PrintSettingPane extends BasicPane { + private UIRadioButton noClientPrintRadioButton = new UIRadioButton(Inter.getLocText("FR-Engine_No_Client_Print")); + private UIRadioButton nativePrintRadioButton = new UIRadioButton(Inter.getLocText("FR-Engine_Native_Print")); + + private NoClientPrintSettingPane noClientPrintSettingPane; + private NativePrintSettingPane nativePrintSettingPane; + private CardLayout printCard; + private JPanel printPane; + + public PrintSettingPane() { + initComponents(); + initListener(); + } + + private void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel allPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + this.add(allPanel, BorderLayout.CENTER); + JPanel north = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + allPanel.add(north, BorderLayout.NORTH); + ButtonGroup buttonGroup = new ButtonGroup(); + noClientPrintRadioButton.setSelected(true); + buttonGroup.add(noClientPrintRadioButton); + buttonGroup.add(nativePrintRadioButton); + noClientPrintRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 50)); + JPanel radioGroupPane = GUICoreUtils.createFlowPane(new Component[] { + noClientPrintRadioButton, nativePrintRadioButton}, FlowLayout.LEFT, 0, 0); + north.add(radioGroupPane); + + noClientPrintSettingPane = new NoClientPrintSettingPane(); + nativePrintSettingPane = new NativePrintSettingPane(); + printCard = new CardLayout(); + printPane = new JPanel(); + printPane.setLayout(printCard); + printPane.add(noClientPrintRadioButton.getText(), noClientPrintSettingPane); + printPane.add(nativePrintRadioButton.getText(), nativePrintSettingPane); + + north.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + allPanel.add(printPane, BorderLayout.CENTER); + } + + private void initListener() { + noClientPrintRadioButton.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + printCard.show(printPane, noClientPrintRadioButton.getText()); + } + } + }); + nativePrintRadioButton.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + printCard.show(printPane, nativePrintRadioButton.getText()); + } + } + }); + } + + // 刷新面板可用状态 + public void checkEnabled() { + noClientPrintSettingPane.checkEnabled(); + nativePrintSettingPane.checkEnabled(); + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Print_Setting"); + } + + public void populate(PrintSettingsAttrMark printSettings) { + if (printSettings.getPrintType() == PrintSettingsAttrMark.NO_CLIENT_PRINT) { + noClientPrintRadioButton.setSelected(true); + } else { + nativePrintRadioButton.setSelected(true); + } + noClientPrintSettingPane.populate(printSettings.getNoClientPrintAttr()); + nativePrintSettingPane.populate(printSettings.getNativePrintAttr()); + } + + public PrintSettingsAttrMark updateBean() { + PrintSettingsAttrMark printSettings = new PrintSettingsAttrMark(); + printSettings.setPrintType(noClientPrintRadioButton.isSelected() ? + PrintSettingsAttrMark.NO_CLIENT_PRINT : PrintSettingsAttrMark.NATIVE_PRINT); + noClientPrintSettingPane.update(printSettings.getNoClientPrintAttr()); + nativePrintSettingPane.update(printSettings.getNativePrintAttr()); + return printSettings; + } +} diff --git a/designer-realize/src/com/fr/design/webattr/printsettings/ReportPrintSettingPane.java b/designer-realize/src/com/fr/design/webattr/printsettings/ReportPrintSettingPane.java new file mode 100644 index 0000000000..be2401f988 --- /dev/null +++ b/designer-realize/src/com/fr/design/webattr/printsettings/ReportPrintSettingPane.java @@ -0,0 +1,101 @@ +package com.fr.design.webattr.printsettings; + +import com.fr.base.print.PrintSettingsAttrMark; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.Inter; +import com.fr.report.core.ReportUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/** + * 模版->打印设置 + * Created by plough on 2018/3/6. + */ +public class ReportPrintSettingPane extends BasicPane { + private static final String[] CHOOSEITEM = new String[] { + Inter.getLocText("FR-Designer_I_Want_To_Set_Single"), + Inter.getLocText("FR-Designer_Using_Server_Report_View_Settings") + }; + private static final int SINGLE_SET = 0; + private static final int SERVER_SET = 1; + + private UIComboBox chooseComboBox; + private PrintSettingPane printSettingPane; + + public ReportPrintSettingPane() { + initComponents(); + } + + private void initComponents() { + chooseComboBox = new UIComboBox(CHOOSEITEM); + chooseComboBox.addItemListener(itemListener); + UILabel belowSetLabel = new UILabel(Inter.getLocText("FR-Designer_Blow_set") + ":"); + JPanel buttonPane = GUICoreUtils.createFlowPane(new Component[] { + belowSetLabel, chooseComboBox}, FlowLayout.LEFT, 0, 0); + buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 0)); + + printSettingPane = new PrintSettingPane(); + this.setLayout(new BorderLayout()); + this.add(buttonPane, BorderLayout.NORTH); + this.add(printSettingPane, BorderLayout.CENTER); + } + + private ItemListener itemListener = new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getStateChange() == ItemEvent.SELECTED) { + if (chooseComboBox.getSelectedIndex() == 0) { + setSettingPaneEnabled(true); + } else { + populateServerSettings(); + setSettingPaneEnabled(false); + } + } + } + }; + + private void setSettingPaneEnabled(boolean enabled) { + // GUICoreUtils.setEnabled 会遍历所有 Component。所以要先设置外层,如果是生效的,再设置内层 + GUICoreUtils.setEnabled(printSettingPane, enabled); + if (enabled) { + printSettingPane.checkEnabled(); + } + } + + private void populateServerSettings() { + PrintSettingsAttrMark printSettings = ReportUtils.getPrintSettingsFromServerConfig(); + printSettingPane.populate(printSettings); + } + + public void populate(PrintSettingsAttrMark printSettings) { + if (!printSettings.isValid()) { // 采用服务器配置 + chooseComboBox.setSelectedIndex(SERVER_SET); + populateServerSettings(); + return; + } + chooseComboBox.setSelectedIndex(SINGLE_SET); + printSettingPane.populate(printSettings); + } + + public PrintSettingsAttrMark updateBean() { + PrintSettingsAttrMark printSettings = printSettingPane.updateBean(); + if (chooseComboBox.getSelectedIndex() == SERVER_SET) { + printSettings.setValid(false); + } + return printSettings; + } + + @Override + protected String title4PopupWindow() { + return Inter.getLocText("FR-Designer_Print_Setting"); + } +} diff --git a/designer-realize/src/com/fr/design/widget/WidgetEventPane.java b/designer-realize/src/com/fr/design/widget/WidgetEventPane.java index 34b42baf98..b840876d94 100644 --- a/designer-realize/src/com/fr/design/widget/WidgetEventPane.java +++ b/designer-realize/src/com/fr/design/widget/WidgetEventPane.java @@ -91,7 +91,7 @@ public class WidgetEventPane extends ObjectUIControlPane { @Override protected DBManipulationPane createDBManipulationPane() { - if(epane == null) { + if(epane == null && DesignerContext.getDesignerFrame().getSelectedJTemplate() != null) { return autoCreateDBManipulationInWidgetEventPane(); } diff --git a/designer-realize/src/com/fr/design/write/submit/SmartInsertDBManipulationPane.java b/designer-realize/src/com/fr/design/write/submit/SmartInsertDBManipulationPane.java index 9b43da390a..bde8cdfcbf 100644 --- a/designer-realize/src/com/fr/design/write/submit/SmartInsertDBManipulationPane.java +++ b/designer-realize/src/com/fr/design/write/submit/SmartInsertDBManipulationPane.java @@ -11,6 +11,7 @@ import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableCellRenderer; import javax.swing.table.TableColumn; @@ -248,10 +249,17 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { } while (dialog.getParent() != null) { dialog = dialog.getParent(); - if (dialog instanceof SmartInsertSubmitJobListPane) { - ((SmartInsertSubmitJobListPane)dialog).showParentDialog(); - } else if (dialog instanceof Dialog) { - dialog.setVisible(true); + if (dialog instanceof Dialog) { + //这边需要另起一个线程设置可见,防止阻塞 + final Container finalDialog = dialog; + SwingWorker worker = new SwingWorker() { + @Override + protected Object doInBackground() throws Exception { + finalDialog.setVisible(true); + return null; + } + }; + worker.execute(); } } } @@ -263,15 +271,14 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane { } while (dialog.getParent() != null) { dialog = dialog.getParent(); - if (dialog instanceof SmartInsertSubmitJobListPane) { - ((SmartInsertSubmitJobListPane)dialog).hideParentDialog(); - } else if (dialog instanceof Dialog) { + if (dialog instanceof Dialog) { // 条件属性中添加的控件的话有两层dialog,需要都隐藏 dialog.setVisible(false); } } } + /** * 检测是否合法 * @throws Exception diff --git a/designer-realize/src/com/fr/grid/Grid.java b/designer-realize/src/com/fr/grid/Grid.java index 45bcf38845..16b8924731 100644 --- a/designer-realize/src/com/fr/grid/Grid.java +++ b/designer-realize/src/com/fr/grid/Grid.java @@ -61,6 +61,9 @@ public class Grid extends BaseGridComponent { /** * If editing, the Component that is handling the editing. */ + public static final int NO_PAGINATE_LINE = 0; // 不显示分页线 + public static final int MULTIPLE_PAGINATE_LINE = 1; // 绘制多条分页线 + public static final int SINGLE_HORIZONTAL_PAGINATE_LINE = 2; // 仅绘制一条水平分页线 private static final int VERTICAL_EXTENT_INITIAL_VALUE = 50; private static final int HORIZONTAL_EXTENT_INITIAL_VALUE = 40; transient protected Component editorComponent; @@ -70,7 +73,7 @@ public class Grid extends BaseGridComponent { private boolean showGridLine = true; private Color gridLineColor = UIConstants.RULER_LINE_COLOR; // line color. - private boolean isShowPaginateLine = true; + private int paginateLineShowType = MULTIPLE_PAGINATE_LINE; // 分页线类型 private Color paginationLineColor = Color.RED; // line color of paper private boolean isShowVerticalFrozenLine = true; @@ -216,25 +219,6 @@ public class Grid extends BaseGridComponent { this.getElementCasePane().repaint(); } - /** - * 是否显示分页线 - * - * @return 是否显示分页线 - * @date 2014-12-21-下午6:31:45 - */ - public boolean isShowPaginateLine() { - return isShowPaginateLine; - } - - /** - * Sets to show pagination line. - */ - public void setShowPaginateLine(boolean showPaginateLine) { - this.isShowPaginateLine = showPaginateLine; - - this.getElementCasePane().repaint(); - } - /** * Gets pagination line color. */ @@ -1456,8 +1440,12 @@ public class Grid extends BaseGridComponent { this.tooltipLocation.setLocation(x, y); } -// @Override -// public void requestFocus() { -// super.requestFocus(); -// } + public int getPaginateLineShowType() { + return paginateLineShowType; + } + + public void setPaginateLineShowType(int paginateLineShowType) { + this.paginateLineShowType = paginateLineShowType; + this.getElementCasePane().repaint(); + } } \ No newline at end of file diff --git a/designer-realize/src/com/fr/grid/GridUI.java b/designer-realize/src/com/fr/grid/GridUI.java index 0f9438306b..7320b955ce 100644 --- a/designer-realize/src/com/fr/grid/GridUI.java +++ b/designer-realize/src/com/fr/grid/GridUI.java @@ -127,7 +127,7 @@ public class GridUI extends ComponentUI { // richer;聚合报表设计中,最初的ElementCase还没有加到Report中,所以elementCase.getReport()可能为空 ReportSettingsProvider reportSettings = getReportSettings(elementCase); PaperSettingProvider psetting = reportSettings.getPaperSetting(); - if (grid.isShowPaginateLine()) {// paint paper margin line. + if (grid.getPaginateLineShowType() != Grid.NO_PAGINATE_LINE) {// paint paper margin line. PaperSize paperSize = psetting.getPaperSize(); Margin margin = psetting.getMargin(); @@ -173,7 +173,7 @@ public class GridUI extends ComponentUI { private void paintScrollBackground(Graphics2D g2d, Grid grid, Background background, PaperSettingProvider psetting, ReportSettingsProvider reportSettings) { boolean isCanDrawImage = grid.isEditable() || isAuthority; if (isCanDrawImage && (background instanceof ImageFileBackground)) { - if (!grid.isShowPaginateLine()) { + if (grid.getPaginateLineShowType() == Grid.NO_PAGINATE_LINE) { calculatePaper(psetting, reportSettings); } @@ -239,12 +239,15 @@ public class GridUI extends ComponentUI { // 分页线 paginateLineList.clear(); + boolean isShowVerticalPaginateLine = grid.getPaginateLineShowType() == Grid.MULTIPLE_PAGINATE_LINE; + boolean isShowHorizontalPaginateLine = grid.getPaginateLineShowType() != Grid.NO_PAGINATE_LINE; + new DrawVerticalLineHelper(grid.getVerticalBeginValue(), verticalEndValue, - grid.isShowGridLine(), grid.isShowPaginateLine(), rowHeightList, paperPaintHeight, + grid.isShowGridLine(), isShowVerticalPaginateLine, rowHeightList, paperPaintHeight, paginateLineList, realWidth, resolution).iterateStart2End(g2d); new DrawHorizontalLineHelper(grid.getHorizontalBeginValue(), horizontalEndValue, - grid.isShowGridLine(), grid.isShowPaginateLine(), columnWidthList, paperPaintWidth, + grid.isShowGridLine(), isShowHorizontalPaginateLine, columnWidthList, paperPaintWidth, paginateLineList, realHeight, resolution).iterateStart2End(g2d); } @@ -609,8 +612,12 @@ public class GridUI extends ComponentUI { //g2d.setXORMode(Utils.getXORColor(grid.getPaginationLineColor())); GraphHelper.setStroke(g2d, GraphHelper.getStroke(Constants.LINE_DASH_DOT)); - for (int i = 0, len = paginateLineList.size(); i < len; i++) { - g2d.draw((Shape) paginateLineList.get(i)); + if (grid.getPaginateLineShowType() == Grid.SINGLE_HORIZONTAL_PAGINATE_LINE) { + g2d.draw((Shape) paginateLineList.get(0)); + } else { + for (int i = 0, len = paginateLineList.size(); i < len; i++) { + g2d.draw((Shape) paginateLineList.get(i)); + } } g2d.setPaintMode(); diff --git a/designer-realize/src/com/fr/start/Designer.java b/designer-realize/src/com/fr/start/Designer.java index ae382d2fa3..74a8758c56 100644 --- a/designer-realize/src/com/fr/start/Designer.java +++ b/designer-realize/src/com/fr/start/Designer.java @@ -39,23 +39,28 @@ import com.fr.design.module.DesignModuleFactory; import com.fr.design.module.DesignerModule; import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.event.EventDispatcher; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import com.fr.locale.InterProviderFactory; import com.fr.module.Module; import com.fr.module.ModuleContext; +import com.fr.module.ModuleEvent; +import com.fr.stable.BuildContext; +import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLTools; +import com.fr.start.fx.SplashFx; +import com.fr.start.jni.SplashMac; import com.fr.start.module.StartupArgs; +import com.fr.start.server.FineEmbedServer; +import com.fr.start.server.ServerTray; -import javax.swing.JComponent; -import javax.swing.JPanel; +import javax.swing.*; import javax.swing.border.MatteBorder; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Insets; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; @@ -85,15 +90,30 @@ public class Designer extends BaseDesigner { * @param args 参数 */ public static void main(String[] args) { - + + BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); + SplashContext.getInstance().registerSplash(createSplash()); + SplashContext.getInstance().show(); Module designerRoot = ModuleContext.parseRoot("designer-startup.xml"); //传递启动参数 designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args)); designerRoot.start(); if (FRContext.getCurrentEnv() instanceof LocalEnv) { // 预启动一下 - StartServer.start(); + FineEmbedServer.getInstance().start(); + ServerTray.init(); + } + + } + + private static SplashStrategy createSplash() { + // 这里可以开接口加载自定义启动画面 + if (OperatingSystem.isWindows()) { + return new SplashFx(); + } else if (OperatingSystem.isMacOS()) { + return new SplashMac(); } + return new SplashFx(); } public Designer(String[] args) { diff --git a/designer-realize/src/com/fr/start/ReportSplashPane.java b/designer-realize/src/com/fr/start/ReportSplashPane.java deleted file mode 100644 index 840d611106..0000000000 --- a/designer-realize/src/com/fr/start/ReportSplashPane.java +++ /dev/null @@ -1,189 +0,0 @@ -package com.fr.start; - -import com.bulenkov.iconloader.IconLoader; -import com.bulenkov.iconloader.util.JBUI; -import com.fr.base.BaseUtils; -import com.fr.base.FRContext; -import com.fr.base.GraphHelper; -import com.fr.design.mainframe.bbs.BBSConstants; -import com.fr.general.GeneralContext; -import com.fr.general.Inter; -import com.fr.general.ModuleContext; -import com.fr.stable.OperatingSystem; -import com.fr.stable.StableUtils; -import com.fr.stable.StringUtils; -import com.fr.stable.module.ModuleAdapter; -import com.fr.stable.module.ModuleListener; - -import javax.swing.*; -import java.awt.*; -import java.util.Locale; -import java.util.Random; -import java.util.TimerTask; - -/** - * @author neil - * @date: 2015-3-13-上午9:47:58 - */ -public class ReportSplashPane extends SplashPane { - - private static final String OEM_PATH = "/com/fr/base/images/oem"; - private static final String SPLASH_MAC_CN = "splash_chinese_mac.png"; - private static final String SPLASH_MAC_EN = "splash_english_mac.png"; - - private static float JBUI_INIT_SCALE = JBUI.scale(1f); - - private static final Color MODULE_COLOR = new Color(255, 255, 255); - private static final int MODULE_INFO_X = uiScale(54); - private static final int MODULE_INFO_Y = uiScale(340); - - private static final Color THANK_COLOR = new Color(255, 255, 255, (int) (0.6 * 255 + 0.5)); - private static final int THANK_INFO_Y = uiScale(382); - - private static final String ARIAL_FONT_NAME = "Arial"; - private static final String YAHEI_FONT_NAME = "Microsoft YaHei"; - - private static final String GUEST = getRandomUser(); - - private String showText = ""; - - private String moduleID = ""; - private int loadingIndex = 0; - private String[] loading = new String[]{"..", "....", "......"}; - private java.util.Timer timer = new java.util.Timer(); - - private ModuleListener listener; - - private static float uiScale(float f) { - return f * JBUI_INIT_SCALE; - } - - private static int uiScale(int i) { - return (int) (i * JBUI_INIT_SCALE); - } - - public ReportSplashPane() { - init(); - } - - private void init() { - this.setBackground(null); - - timer.schedule(new TimerTask() { - public void run() { - loadingIndex++; - ReportSplashPane.this.setShowText(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); - ReportSplashPane.this.repaint(); - } - }, 0, 300); - - listener = new ModuleAdapter() { - @Override - public void onStartBefore(String moduleName, String moduleI18nName) { - moduleID = moduleI18nName; - loadingIndex++; - ReportSplashPane.this.setShowText(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); - ReportSplashPane.this.repaint(); - } - }; - } - - public ModuleListener getModuleListener() { - - return listener; - } - - protected void paintComponent(Graphics g) { - Icon icon = IconLoader.getIcon(StableUtils.pathJoin(OEM_PATH, getImageName())); - icon.paintIcon(null, g, 0, 0); - paintShowText((Graphics2D) g); - g.dispose(); - } - - public void setShowText(String text) { - this.showText = text; - } - - public Image getSplashImage() { - Icon icon = IconLoader.getIcon(StableUtils.pathJoin(OEM_PATH, getImageName())); - return ((ImageIcon) IconLoader.getIconSnapshot(icon)).getImage(); - } - - private void paintShowText(Graphics2D splashG2d) { - GraphHelper.applyRenderingHints(splashG2d); - - splashG2d.setPaint(MODULE_COLOR); - - Font font = null; - if (OperatingSystem.isWindows()) { - font = new Font(YAHEI_FONT_NAME, Font.PLAIN, uiScale(12)); - } - - if (font == null || isDialogFont(font)) { - font = createFont(ARIAL_FONT_NAME); - } - splashG2d.setFont(font); - - //加载模块信息 - GraphHelper.drawString(splashG2d, showText, MODULE_INFO_X, MODULE_INFO_Y); - - //每次随机感谢一位论坛用户 - if (shouldShowThanks()) { - splashG2d.setPaint(THANK_COLOR); - String content = Inter.getLocText("FR-Designer_Thanks-To") + GUEST; - GraphHelper.drawString(splashG2d, content, MODULE_INFO_X, THANK_INFO_Y); - } - } - - private boolean isDialogFont(Font font) { - return Font.DIALOG.equals(font.getFamily(Locale.US)); - } - - private Font createFont(String fontName) { - return new Font(fontName, Font.PLAIN, uiScale(12)); - } - - // 是否显示鸣谢文字 - private boolean shouldShowThanks() { - Locale[] hideLocales = {Locale.US, Locale.KOREA, Locale.JAPAN}; - for (Locale loc : hideLocales) { - if (FRContext.getLocale().equals(loc)) { - return false; - } - } - return true; - } - - private static String getRandomUser() { - String[] allGuest = BBSConstants.getAllGuest(); - if (allGuest.length == 0) { - return StringUtils.EMPTY; - } - int num = new Random().nextInt(allGuest.length); - return StringUtils.BLANK + allGuest[num]; - } - - /** - * 窗口关闭后取消定时获取模块信息的timer - */ - public void releaseTimer() { - timer.cancel(); - } - - /** - * 创建启动画面的背景图片 - * - * @return 背景图片 - */ - public Image createSplashBackground() { - String fileName = getImageName(); - return BaseUtils.readImage(StableUtils.pathJoin(OEM_PATH, fileName)); - } - - //获取图片文件名 - private String getImageName() { - boolean isChina = GeneralContext.isChineseEnv(); - //jdk1.8下透明有bug, 设置了setWindowTransparent后, JFrame直接最小化了, 先用mac下的加载图片 - return isChina ? SPLASH_MAC_CN : SPLASH_MAC_EN; - } -} diff --git a/designer-realize/src/com/fr/start/SplashContext.java b/designer-realize/src/com/fr/start/SplashContext.java new file mode 100644 index 0000000000..e5021b2b3d --- /dev/null +++ b/designer-realize/src/com/fr/start/SplashContext.java @@ -0,0 +1,143 @@ +package com.fr.start; + +import com.fr.base.FRContext; +import com.fr.design.mainframe.bbs.BBSConstants; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.general.Inter; +import com.fr.module.ModuleEvent; +import com.fr.stable.StringUtils; + +import java.util.Locale; +import java.util.Random; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * 启动动画策略 + * + * @author vito + * @date 2018/6/5 + */ +public class SplashContext { + + private static final SplashContext SPLASH_CONTEXT = new SplashContext(); + + private SplashStrategy splashStrategy; + + private String moduleID = ""; + private int loadingIndex = 0; + private String[] loading = new String[]{"..", "....", "......"}; + + private static final String GUEST = getRandomUser(); + + private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + + private Listener listener; + + + public static SplashContext getInstance() { + return SPLASH_CONTEXT; + } + + private SplashContext() { + + } + + /** + * 注册具体的启动动画 + */ + public void registerSplash(SplashStrategy splashStrategy) { + this.splashStrategy = splashStrategy; + } + + /** + * 展示启动动画 + */ + public void show() { + //监听 + initListener(); + splashStrategy.show(); + } + + /** + * 隐藏启动动画 + */ + public void hide() { + //取消监听 + EventDispatcher.stopListen(listener); + splashStrategy.hide(); + // 窗口关闭后取消定时获取模块信息的timer + scheduler.shutdown(); + // 一次性 + splashStrategy = null; + } + + private void initListener() { + scheduler.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + loadingIndex++; + updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); + } + }, 0, 300, TimeUnit.MILLISECONDS); + + listener = new Listener() { + + @Override + public void on(Event event, String i18n) { + + moduleID = i18n; + loadingIndex++; + updateModuleLog(moduleID.isEmpty() ? StringUtils.EMPTY : moduleID + loading[loadingIndex % 3]); + } + }; + EventDispatcher.listen(ModuleEvent.MajorModuleStarting, listener); + showThanks(); + } + + private void updateModuleLog(String text) { + splashStrategy.updateModuleLog(text); + } + + private void updateThanksLog(String text) { + splashStrategy.updateThanksLog(text); + } + + /** + * 获取随机感谢人员 + */ + private static String getRandomUser() { + String[] allGuest = BBSConstants.getAllGuest(); + if (allGuest.length == 0) { + return StringUtils.EMPTY; + } + int num = new Random().nextInt(allGuest.length); + return StringUtils.BLANK + allGuest[num]; + } + + /** + * 展示感谢信息 + */ + private void showThanks() { + if (shouldShowThanks()) { + updateThanksLog(Inter.getLocText("FR-Designer_Thanks-To") + GUEST); + } + } + + /** + * 是否显示鸣谢面板 + */ + private boolean shouldShowThanks() { + Locale[] hideLocales = {Locale.CHINA, Locale.TAIWAN}; + for (Locale loc : hideLocales) { + if (FRContext.getLocale().equals(loc)) { + return true; + } + } + return false; + } + +} diff --git a/designer-realize/src/com/fr/start/fx/FastGifImage.java b/designer-realize/src/com/fr/start/fx/FastGifImage.java new file mode 100644 index 0000000000..9049850c36 --- /dev/null +++ b/designer-realize/src/com/fr/start/fx/FastGifImage.java @@ -0,0 +1,210 @@ +package com.fr.start.fx; + +import com.sun.imageio.plugins.gif.GIFImageReader; +import com.sun.imageio.plugins.gif.GIFImageReaderSpi; +import com.sun.javafx.tk.ImageLoader; +import com.sun.javafx.tk.PlatformImage; +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.event.Event; +import javafx.event.EventHandler; +import javafx.scene.image.WritableImage; +import javafx.util.Duration; + +import javax.imageio.stream.FileImageInputStream; +import java.io.File; +import java.lang.ref.WeakReference; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.util.regex.Pattern; + +/** + * 边加载边播放的gif加载器 + * + * @author daniel + */ +public class FastGifImage extends WritableImage { + private String url; + private int gifCount; + + public FastGifImage(String url, int w, int h) { + super(w, h); + this.url = validateUrl(url); + seekCount(); + initialize(); + } + + /** + * 给出gif帧数,加快加载速度 + * + * @param url gif url + * @param gifCount gif帧数 + * @param w 宽 + * @param h 高 + */ + public FastGifImage(String url, int gifCount, int w, int h) { + super(w, h); + this.url = validateUrl(url); + this.gifCount = gifCount; + initialize(); + } + + private void seekCount() { + try { + GIFImageReaderSpi spi = new GIFImageReaderSpi(); + GIFImageReader gifReader = (GIFImageReader) spi.createReaderInstance(); + gifReader.setInput(new FileImageInputStream(new File(new URI(url)))); + gifCount = gifReader.getNumImages(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static final Pattern URL_QUICKMATCH = Pattern.compile("^\\p{Alpha}[\\p{Alnum}+.-]*:.*$"); + + private static String validateUrl(final String url) { + if (url == null) { + throw new NullPointerException("URL must not be null"); + } + + if (url.trim().isEmpty()) { + throw new IllegalArgumentException("URL must not be empty"); + } + + try { + if (!URL_QUICKMATCH.matcher(url).matches()) { + final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + URL resource; + if (url.charAt(0) == '/') { + resource = contextClassLoader.getResource(url.substring(1)); + } else { + resource = contextClassLoader.getResource(url); + } + if (resource == null) { + throw new IllegalArgumentException("Invalid URL or resource not found"); + } + return resource.toString(); + } + // Use URL constructor for validation + return new URL(url).toString(); + } catch (final IllegalArgumentException e) { + throw new IllegalArgumentException("Invalid URL" + e.getMessage()); + } catch (final MalformedURLException e) { + throw new IllegalArgumentException("Invalid URL" + e.getMessage()); + } + } + + + private void finishImage(Exception e) { + e.printStackTrace(); + } + + private void finishImage(ImageLoader loader) { + final Exception loadingException = loader.getException(); + if (loadingException != null) { + finishImage(loadingException); + return; + } + initializeAnimatedImage(loader); + } + + // Generates the animation Timeline for multiframe images. + private void initializeAnimatedImage(ImageLoader loader) { + + animation = new Animation(this, loader); + animation.start(); + } + + // Support for animated images. + private Animation animation; + + private static final class Animation { + final WeakReference imageRef; + final Timeline timeline; + final ImageLoader loader; + + public Animation(final FastGifImage image, final ImageLoader loader) { + this.loader = loader; + imageRef = new WeakReference(image); + timeline = new Timeline(); + timeline.setCycleCount(Timeline.INDEFINITE); + + final int frameCount = loader.getFrameCount(); + int duration = 0; + + for (int i = 0; i < frameCount; ++i) { + addKeyFrame(i, duration); + duration = duration + loader.getFrameDelay(i); + } + + // Note: we need one extra frame in the timeline to define how long + // the last frame is shown, the wrap around is "instantaneous" + addKeyFrame(0, duration); + } + + public void start() { + timeline.play(); + } + + public void stop() { + timeline.stop(); + } + + private void updateImage(final int frameIndex) { + final FastGifImage image = imageRef.get(); + if (image != null) { + image.setPlatformImagePropertyImpl( + loader.getFrame(frameIndex)); + } else { + timeline.stop(); + } + } + + private void addKeyFrame(final int index, final double duration) { + timeline.getKeyFrames().add( + new KeyFrame(Duration.millis(duration), + new EventHandler() { + @Override + public void handle(Event event) { + updateImage(index); + } + } + )); + } + } + + private static Method method; + + static { + try { + method = FastGifImage.class.getSuperclass().getSuperclass().getDeclaredMethod("platformImagePropertyImpl"); + method.setAccessible(true); + } catch (Exception e) { + + } + } + + private void setPlatformImagePropertyImpl(PlatformImage image) { + try { + Object o = method.invoke(this); + Method method = o.getClass().getDeclaredMethod("set", Object.class); + method.setAccessible(true); + method.invoke(o, image); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + } + + + private void initialize() { + finishImage(new PrismImageLoader2(url, gifCount, (int) getRequestedWidth(), (int) getRequestedHeight(), isPreserveRatio(), isSmooth())); + } + +} diff --git a/designer-realize/src/com/fr/start/fx/PrismImageLoader2.java b/designer-realize/src/com/fr/start/fx/PrismImageLoader2.java new file mode 100644 index 0000000000..e943df011c --- /dev/null +++ b/designer-realize/src/com/fr/start/fx/PrismImageLoader2.java @@ -0,0 +1,211 @@ +package com.fr.start.fx; + +import com.sun.javafx.iio.ImageFrame; +import com.sun.javafx.iio.ImageLoadListener; +import com.sun.javafx.iio.ImageLoader; +import com.sun.javafx.iio.ImageMetadata; +import com.sun.javafx.iio.ImageStorageException; +import com.sun.javafx.iio.common.ImageTools; +import com.sun.javafx.iio.gif.GIFImageLoaderFactory; +import com.sun.javafx.tk.PlatformImage; +import com.sun.prism.Image; +import com.sun.prism.impl.PrismSettings; +import sun.util.logging.PlatformLogger; + +import java.io.IOException; +import java.io.InputStream; + +/** + * 边加载边播放的gif加载器 + * + * @author daniel + */ +class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader { + + private static PlatformLogger imageioLogger = null; + + private Image[] images; + private int[] delayTimes; + private int width; + private int height; + private int gifCount = 1; + private Exception exception; + + public PrismImageLoader2(final String url, int gifCount, final int width, final int height, + final boolean preserveRatio, final boolean smooth) { + this.gifCount = gifCount; + images = new Image[gifCount]; + delayTimes = new int[gifCount]; + this.width = width; + this.height = height; + new Thread() { + @Override + public void run() { + InputStream inputStream = null; + try { + inputStream = ImageTools.createInputStream(url); + loadAll(inputStream, width, height, preserveRatio, smooth); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + }.start(); + + } + + @Override + public int getWidth() { + return width; + } + + @Override + public int getHeight() { + return height; + } + + @Override + public int getFrameCount() { + return gifCount; + } + + @Override + public PlatformImage getFrame(int index) { + while (images[index] == null) { + synchronized (this) { + if (images[index] == null) { + try { + this.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + return images[index]; + } + + + @Override + public int getFrameDelay(int index) { +// while (images[0] == null) { +// synchronized (this) { +// if(images[0] == null) { +// try { +// this.wait(); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// } +// return 0; +// } +// return delayTimes[0]; + // 直接使用第一帧的时间 + return 40; + } + + @Override + public int getLoopCount() { + return 0; + } + + @Override + public Exception getException() { + return exception; + } + + + private void loadAll(InputStream stream, int w, int h, + boolean preserveRatio, boolean smooth) { + ImageLoadListener listener = new PrismLoadListener(); + + try { + ImageLoader loader = null; + loader = GIFImageLoaderFactory.getInstance().createImageLoader(stream); + loader.addListener(listener); + + for (int i = 0; i < gifCount; i++) { + ImageFrame imageFrame = loader.load(i, w, h, preserveRatio, smooth); + images[i] = convert(imageFrame); + synchronized (this) { + this.notify(); + } + } + } catch (ImageStorageException e) { + handleException(e); + } catch (Exception e) { + handleException(e); + } + } + + private void handleException(final ImageStorageException isException) { + // unwrap ImageStorageException if possible + final Throwable exceptionCause = isException.getCause(); + if (exceptionCause instanceof Exception) { + handleException((Exception) exceptionCause); + } else { + handleException((Exception) isException); + } + } + + private void handleException(final Exception exception) { + if (PrismSettings.verbose) { + exception.printStackTrace(System.err); + } + this.exception = exception; + } + + private Image convert(ImageFrame imgFrames) { + ImageFrame frame = imgFrames; + Image image = Image.convertImageFrame(frame); + ImageMetadata metadata = frame.getMetadata(); + if (metadata != null) { + Integer delay = metadata.delayTime; + if (delay != null) { + delayTimes[0] = delay.intValue(); + } + } + return image; + } + + /** + * Returns the PlatformLogger for logging imageio-related activities. + */ + private static synchronized PlatformLogger getImageioLogger() { + if (imageioLogger == null) { + imageioLogger = PlatformLogger.getLogger("imageio"); + } + + return imageioLogger; + } + + private class PrismLoadListener implements ImageLoadListener { + @Override + public void imageLoadWarning(ImageLoader loader, String message) { + getImageioLogger().warning(message); + } + + @Override + public void imageLoadProgress(ImageLoader loader, + float percentageComplete) { + // progress only matters when backgroundLoading=true, but + // currently we are relying on AbstractRemoteResource for tracking + // progress of the InputStream, so there's no need to implement + // this for now; eventually though we might want to consider + // moving away from AbstractRemoteResource and instead use + // the built-in support for progress in the javafx-iio library... + } + + @Override + public void imageLoadMetaData(ImageLoader loader, ImageMetadata metadata) { + // We currently have no need to listen for ImageMetadata ready. + } + } + +} diff --git a/designer-realize/src/com/fr/start/fx/SplashFx.java b/designer-realize/src/com/fr/start/fx/SplashFx.java new file mode 100644 index 0000000000..b69de89468 --- /dev/null +++ b/designer-realize/src/com/fr/start/fx/SplashFx.java @@ -0,0 +1,60 @@ +package com.fr.start.fx; + +import com.fr.start.SplashStrategy; +import javafx.application.Application; +import javafx.application.Platform; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * JavaFx方式启动启动动画。这种方式在mac下与 + * swing一起启动会会出现线程死锁,jvm等问题, + * 所以这个方式仅用于windows上。 + * + * @author vito + * @date 2018/6/4 + * @see com.fr.start.jni.SplashMac + */ +public class SplashFx implements SplashStrategy { + + private SplashFxWindow test; + private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(); + + @Override + public void show() { + SERVICE.execute(new Runnable() { + @Override + public void run() { + Application.launch(SplashFxWindow.class); + } + }); + test = SplashFxWindow.waitForStartUpTest(); + } + + @Override + public void hide() { + Platform.exit(); + } + + @Override + public void updateModuleLog(final String text) { + Platform.runLater(new Runnable() { + @Override + public void run() { + test.updateModuleInfo(text); + } + }); + + } + + @Override + public void updateThanksLog(final String text) { + Platform.runLater(new Runnable() { + @Override + public void run() { + test.updateThanks(text); + } + }); + } +} diff --git a/designer-realize/src/com/fr/start/fx/SplashFxWindow.java b/designer-realize/src/com/fr/start/fx/SplashFxWindow.java new file mode 100644 index 0000000000..f048cebd50 --- /dev/null +++ b/designer-realize/src/com/fr/start/fx/SplashFxWindow.java @@ -0,0 +1,134 @@ +package com.fr.start.fx; + +import com.bulenkov.iconloader.util.JBUI; +import com.fr.base.FRContext; +import com.fr.stable.OperatingSystem; +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.AnchorPane; +import javafx.scene.paint.Color; +import javafx.scene.text.Font; +import javafx.scene.text.Text; +import javafx.stage.Stage; +import javafx.stage.StageStyle; + +import java.util.concurrent.CountDownLatch; + + +/** + * JavaFx启动动画窗口 + * + * @author vito + */ +public class SplashFxWindow extends Application { + + private static float JBUI_INIT_SCALE = JBUI.scale(1f); + + private static final String ARIAL_FONT_NAME = "Arial"; + private static final String PF_FONT_NAME = "PingFang"; + private static final String YAHEI_FONT_NAME = "Microsoft YaHei"; + private static final int MODULE_INFO_LEFT_MARGIN = 36; + private static final int MODULE_INFO_BOTTOM_MARGIN = 28; + private static final int THINKS_BOTTOM_RIGHT = 35; + private static final int THINKS_BOTTOM_MARGIN = 27; + private static final int WINDOW_WIDTH = 640; + private static final int WINDOW_HEIGHT = 360; + private static final int FONT = 12; + private static final int FRAME_COUNT = 254; + private static final String THINKS_COLOR = "#82b1ce"; + private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif"; + + private static final CountDownLatch LATCH = new CountDownLatch(1); + private static SplashFxWindow app = null; + + private Text moduleInfo; + private Text thanks; + + private static int uiScale(int i) { + return (int) (i * JBUI_INIT_SCALE); + } + + /** + * 获取当前运行实例。黑科技 + * + * @return 运行实例 + */ + public static SplashFxWindow waitForStartUpTest() { + try { + LATCH.await(); + } catch (InterruptedException e) { + FRContext.getLogger().error(e.getMessage(), e); + } + return app; + } + + private static void setApp(SplashFxWindow window) { + app = window; + LATCH.countDown(); + } + + public SplashFxWindow() { + setApp(this); + } + + @Override + public void start(Stage primaryStage) { + AnchorPane root = new AnchorPane(); + primaryStage.initStyle(StageStyle.TRANSPARENT); + Image image = new FastGifImage(SPLASH_PATH, FRAME_COUNT, WINDOW_WIDTH, WINDOW_HEIGHT); + + ImageView gif = new ImageView(image); + + AnchorPane.setBottomAnchor(gif, 0d); + AnchorPane.setTopAnchor(gif, 0d); + AnchorPane.setLeftAnchor(gif, 0d); + AnchorPane.setRightAnchor(gif, 0d); + Font font; + if (OperatingSystem.isWindows()) { + font = new Font(YAHEI_FONT_NAME, uiScale(FONT)); + } else if (OperatingSystem.isMacOS()) { + font = new Font(PF_FONT_NAME, uiScale(FONT)); + } else { + font = new Font(ARIAL_FONT_NAME, uiScale(FONT)); + } + + moduleInfo = new Text(); + moduleInfo.setFont(font); + moduleInfo.setFill(Color.WHITE); + AnchorPane.setLeftAnchor(moduleInfo, (double) uiScale(MODULE_INFO_LEFT_MARGIN)); + AnchorPane.setBottomAnchor(moduleInfo, (double) uiScale(MODULE_INFO_BOTTOM_MARGIN)); + thanks = new Text(); + thanks.setFont(font); + thanks.setFill(Color.valueOf(THINKS_COLOR)); + AnchorPane.setRightAnchor(thanks, (double) uiScale(THINKS_BOTTOM_RIGHT)); + AnchorPane.setBottomAnchor(thanks, (double) uiScale(THINKS_BOTTOM_MARGIN)); + + root.getChildren().add(gif); + root.getChildren().add(moduleInfo); + root.getChildren().add(thanks); + + Scene scene = new Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT, null); + primaryStage.setScene(scene); + primaryStage.show(); + } + + /** + * 更新模块信息 + * + * @param s 文字 + */ + public void updateModuleInfo(String s) { + moduleInfo.setText(s); + } + + /** + * 更新欢迎信息 + * + * @param s 文字 + */ + public void updateThanks(String s) { + thanks.setText(s); + } +} diff --git a/designer-realize/src/com/fr/start/jni/SplashJNI.java b/designer-realize/src/com/fr/start/jni/SplashJNI.java new file mode 100644 index 0000000000..e71a44ca21 --- /dev/null +++ b/designer-realize/src/com/fr/start/jni/SplashJNI.java @@ -0,0 +1,69 @@ +package com.fr.start.jni; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; + +/** + * Splash JNI调用。jni类改名或者移包之后 + * 必须重新编译动态库 + * + * @author vito + * @date 2018/6/4 + */ +public class SplashJNI { + + static { + try { + System.setProperty("java.library.path", "."); + System.loadLibrary("splash"); + } catch (UnsatisfiedLinkError e) { + loadLibraryFromJar("/com/fr/start/jni/splash.dylib"); + } + } + + /** + * 显示启动动画窗口 + */ + public native void show(String path); + + /** + * 隐藏启动动画窗口 + */ + public native void hide(); + + /** + * 设置模块加载信息 + */ + public native void updateModuleLog(String text); + + /** + * 设置感谢文字 + */ + public native void updateThanksLog(String text); + + /** + * 从jar中加载动态库 + * + * @param path 路径,如/com/a/b + * @throws UnsatisfiedLinkError 没有找到合适的动态库 + */ + private static void loadLibraryFromJar(String path) throws UnsatisfiedLinkError { + try (InputStream inputStream = SplashJNI.class.getResourceAsStream(path)) { + File tempLib = File.createTempFile(path, ""); + + byte[] buffer = new byte[1024]; + int read = -1; + + try (FileOutputStream fileOutputStream = new FileOutputStream(tempLib)) { + while ((read = inputStream.read(buffer)) != -1) { + fileOutputStream.write(buffer, 0, read); + } + } + + System.load(tempLib.getAbsolutePath()); + } catch (Exception e) { + throw new UnsatisfiedLinkError("Unable to open " + path + " from jar file."); + } + } +} diff --git a/designer-realize/src/com/fr/start/jni/SplashMac.java b/designer-realize/src/com/fr/start/jni/SplashMac.java new file mode 100644 index 0000000000..c5c8ee63e5 --- /dev/null +++ b/designer-realize/src/com/fr/start/jni/SplashMac.java @@ -0,0 +1,95 @@ +package com.fr.start.jni; + +import com.fr.base.FRContext; +import com.fr.stable.ProductConstants; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; +import com.fr.start.SplashContext; +import com.fr.start.SplashStrategy; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * mac上使用jni方式绘制gif。不使用javafx有两个原因: + * 1.mac上javafx和swing同时启动会导致卡死; + * 2.platform.exit会导致设计器崩溃 + * + * @author vito + * @see com.fr.start.fx.SplashFx + */ +public class SplashMac implements SplashStrategy { + + private static final String SPLASH_CACHE_NAME = "splash_10.gif"; + private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif"; + + private SplashJNI jni; + + public SplashMac() { + jni = new SplashJNI(); + } + + /** + * 将jar中的资源拷贝到缓存文件夹 + * + * @return 路径 + */ + private static String loadResFromJar() { + File tempLib = null; + try (InputStream inputStream = SplashContext.class.getResourceAsStream(SplashMac.SPLASH_PATH)) { + if (inputStream == null) { + FRContext.getLogger().error("Unable to copy " + SplashMac.SPLASH_PATH + " from jar file."); + return StringUtils.EMPTY; + } + tempLib = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), SPLASH_CACHE_NAME)); + byte[] buffer = new byte[1024]; + int read = -1; + try (FileOutputStream fileOutputStream = new FileOutputStream(tempLib)) { + while ((read = inputStream.read(buffer)) != -1) { + fileOutputStream.write(buffer, 0, read); + } + } + return tempLib.getAbsolutePath(); + } catch (IOException e) { + if (tempLib != null) { + tempLib.deleteOnExit(); + } + // 直接抛异常 + throw new RuntimeException("Unable to copy " + SplashMac.SPLASH_PATH + " from jar file."); + } + } + + @Override + public void show() { + if (jni != null) { + File splash = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), SPLASH_CACHE_NAME)); + String path = splash.exists() ? splash.getAbsolutePath() : loadResFromJar(); + jni.show(path); + } + } + + @Override + public void hide() { + if (jni != null) { + jni.hide(); + jni = null; + } + } + + @Override + public void updateModuleLog(String text) { + if (jni != null) { + jni.updateModuleLog(text); + } + + } + + @Override + public void updateThanksLog(String text) { + if (jni != null) { + jni.updateThanksLog(text); + } + } +} diff --git a/designer-realize/src/com/fr/start/jni/splash.dylib b/designer-realize/src/com/fr/start/jni/splash.dylib new file mode 100755 index 0000000000..3e19cd20e5 Binary files /dev/null and b/designer-realize/src/com/fr/start/jni/splash.dylib differ diff --git a/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java b/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java index 68e7a4c9a1..f15b0a42b6 100644 --- a/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java +++ b/designer-realize/src/com/fr/start/module/DesignerEnvProvider.java @@ -1,25 +1,34 @@ package com.fr.start.module; +import com.fr.base.FRContext; import com.fr.base.ModifiedTable; import com.fr.base.Parameter; import com.fr.base.StoreProcedureParameter; import com.fr.base.TableData; import com.fr.base.env.serializer.OldSerializerAdapter; import com.fr.base.env.serializer.ProcedureDataModelSerializer; -import com.fr.base.env.user.RemoteUserCenter; -import com.fr.core.env.operator.user.UserCenter; +import com.fr.core.env.EnvConfig; +import com.fr.core.env.EnvEvent; import com.fr.core.env.proxy.EnvProxy; +import com.fr.core.env.resource.EnvConfigUtils; +import com.fr.core.env.resource.LocalEnvConfig; +import com.fr.core.env.resource.RemoteEnvConfig; import com.fr.data.core.db.TableProcedure; import com.fr.data.impl.Connection; import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.dav.DavXMLUtils; +import com.fr.dav.LocalEnv; import com.fr.design.DesignerEnvManager; +import com.fr.env.RemoteEnv; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.module.Activator; import com.fr.start.EnvSwitcher; -import com.fr.start.StartServer; +import com.fr.start.ServerStarter; import java.io.InputStream; import java.io.OutputStream; @@ -38,187 +47,196 @@ public class DesignerEnvProvider extends Activator { for (String arg : args) { if (ComparatorUtils.equals(arg, "demo")) { DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); - StartServer.browserDemoURL(); + ServerStarter.browserDemoURL(); break; } } } initDesignerEnv(); - + getRoot().setSingleton(EnvSwitcher.class, new EnvSwitcher()); //设置好环境即可,具体跟环境有关的模块会自动调用 getRoot().getSingleton(EnvSwitcher.class).switch2LastEnv(); } - + private void initDesignerEnv() { - addSerializers(); - EnvProxy.addRemoteService(UserCenter.class, new RemoteUserCenter()); + EventDispatcher.listen(EnvEvent.BEFORE_SIGN_IN, new Listener() { + @Override + public void on(Event event, EnvConfig envConfig) { + if (envConfig instanceof RemoteEnvConfig) { + RemoteEnv remoteEnv = new RemoteEnv(envConfig.getPath(), EnvConfigUtils.getUsername(envConfig), EnvConfigUtils.getPassword(envConfig)); + FRContext.setCurrentEnv(remoteEnv); + } else if (envConfig instanceof LocalEnvConfig) { + FRContext.setCurrentEnv(new LocalEnv()); + } + } + }); } - - + + private void addSerializers() { - + EnvProxy.addSerializer(ProcedureDataModel[].class, new ProcedureDataModelSerializer()); - + EnvProxy.addSerializer(ModifiedTable.class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(ModifiedTable obj, OutputStream out) throws Exception { - - DavXMLUtils.writeXMLModifiedTables(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public ModifiedTable deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLModifiedTables(in); + new OldSerializerAdapter.OldSerializer() { + + @Override + public void serializer(ModifiedTable obj, OutputStream out) throws Exception { + + DavXMLUtils.writeXMLModifiedTables(obj, out); + } + }, + new OldSerializerAdapter.OldDeserializer() { + + @Override + public ModifiedTable deserializer(InputStream in) throws Exception { + + return DavXMLUtils.readXMLModifiedTables(in); + } } - } )); - + EnvProxy.addSerializer(com.fr.data.impl.Connection.class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(Connection obj, OutputStream out) { - - DavXMLUtils.writeXMLFileDatabaseConnection(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public Connection deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLDatabaseConnection(in); + new OldSerializerAdapter.OldSerializer() { + + @Override + public void serializer(Connection obj, OutputStream out) { + + DavXMLUtils.writeXMLFileDatabaseConnection(obj, out); + } + }, + new OldSerializerAdapter.OldDeserializer() { + + @Override + public Connection deserializer(InputStream in) throws Exception { + + return DavXMLUtils.readXMLDatabaseConnection(in); + } } - } )); - + EnvProxy.addSerializer(FileNode[].class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(FileNode[] obj, OutputStream out) { - - DavXMLUtils.writeXMLFileNodes(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public FileNode[] deserializer(InputStream in) { - - return DavXMLUtils.readXMLFileNodes(in); + new OldSerializerAdapter.OldSerializer() { + + @Override + public void serializer(FileNode[] obj, OutputStream out) { + + DavXMLUtils.writeXMLFileNodes(obj, out); + } + }, + new OldSerializerAdapter.OldDeserializer() { + + @Override + public FileNode[] deserializer(InputStream in) { + + return DavXMLUtils.readXMLFileNodes(in); + } } - } )); - + EnvProxy.addSerializer(TableProcedure[].class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(TableProcedure[] obj, OutputStream out) { - - DavXMLUtils.writeXMLFileSQLTable(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public TableProcedure[] deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLSQLTables(in); + new OldSerializerAdapter.OldSerializer() { + + @Override + public void serializer(TableProcedure[] obj, OutputStream out) { + + DavXMLUtils.writeXMLFileSQLTable(obj, out); + } + }, + new OldSerializerAdapter.OldDeserializer() { + + @Override + public TableProcedure[] deserializer(InputStream in) throws Exception { + + return DavXMLUtils.readXMLSQLTables(in); + } } - } )); - + EnvProxy.addSerializer(TableData.class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(TableData obj, OutputStream out) { - - DavXMLUtils.writeXMLFileTableData(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public TableData deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLTableData(in); + new OldSerializerAdapter.OldSerializer() { + + @Override + public void serializer(TableData obj, OutputStream out) { + + DavXMLUtils.writeXMLFileTableData(obj, out); + } + }, + new OldSerializerAdapter.OldDeserializer() { + + @Override + public TableData deserializer(InputStream in) throws Exception { + + return DavXMLUtils.readXMLTableData(in); + } } - } )); - + EnvProxy.addSerializer(Parameter[].class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(Parameter[] obj, OutputStream out) { - - DavXMLUtils.writeXMLFileParameters(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public Parameter[] deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLParameters(in); + new OldSerializerAdapter.OldSerializer() { + + @Override + public void serializer(Parameter[] obj, OutputStream out) { + + DavXMLUtils.writeXMLFileParameters(obj, out); + } + }, + new OldSerializerAdapter.OldDeserializer() { + + @Override + public Parameter[] deserializer(InputStream in) throws Exception { + + return DavXMLUtils.readXMLParameters(in); + } } - } )); - + EnvProxy.addSerializer(StoreProcedure.class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(StoreProcedure obj, OutputStream out) { - - DavXMLUtils.writeXMLFileStoreProcedure(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public StoreProcedure deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLStoreProcedure(in); + new OldSerializerAdapter.OldSerializer() { + + @Override + public void serializer(StoreProcedure obj, OutputStream out) { + + DavXMLUtils.writeXMLFileStoreProcedure(obj, out); + } + }, + new OldSerializerAdapter.OldDeserializer() { + + @Override + public StoreProcedure deserializer(InputStream in) throws Exception { + + return DavXMLUtils.readXMLStoreProcedure(in); + } } - } )); - + EnvProxy.addSerializer(StoreProcedureParameter[].class, new OldSerializerAdapter( - new OldSerializerAdapter.OldSerializer() { - - @Override - public void serializer(StoreProcedureParameter[] obj, OutputStream out) { - - DavXMLUtils.writeXMLFileParameters(obj, out); - } - }, - new OldSerializerAdapter.OldDeserializer() { - - @Override - public StoreProcedureParameter[] deserializer(InputStream in) throws Exception { - - return DavXMLUtils.readXMLStoreProcedureParameters(in); + new OldSerializerAdapter.OldSerializer() { + + @Override + public void serializer(StoreProcedureParameter[] obj, OutputStream out) { + + DavXMLUtils.writeXMLFileParameters(obj, out); + } + }, + new OldSerializerAdapter.OldDeserializer() { + + @Override + public StoreProcedureParameter[] deserializer(InputStream in) throws Exception { + + return DavXMLUtils.readXMLStoreProcedureParameters(in); + } } - } )); } - + @Override public void stop() { //清空模块 getRoot().removeSingleton(EnvSwitcher.class); } - - + + } diff --git a/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java b/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java index b6abbdf85c..fc488fb7e5 100644 --- a/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java +++ b/designer-realize/src/com/fr/start/module/DesignerModuleActivator.java @@ -6,7 +6,6 @@ import com.fr.general.ModuleContext; import com.fr.locale.InterMutableKey; import com.fr.module.Activator; import com.fr.module.extension.Prepare; -import com.fr.stable.module.ModuleListener; /** * Created by juhaoyu on 2018/1/31. @@ -14,25 +13,22 @@ import com.fr.stable.module.ModuleListener; * 之后慢慢将DesignerModule拆成Activator */ public class DesignerModuleActivator extends Activator implements Prepare { - + @Override public void start() { - ModuleContext.registerModuleListener(getModule().upFindSingleton(ModuleListener.class)); ModuleContext.startModule(DesignerModule.class.getName()); - ModuleContext.clearModuleListener(); - DesignerSocketIO.init(); } - + @Override public void stop() { - + } - + @Override public void prepare() { - + addMutable(InterMutableKey.Path, "com/fr/design/i18n/main", "com/fr/design/i18n/chart"); } } diff --git a/designer-realize/src/com/fr/start/module/DesignerStartup.java b/designer-realize/src/com/fr/start/module/DesignerStartup.java index dd2b09c538..54e8c1d9fa 100644 --- a/designer-realize/src/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/com/fr/start/module/DesignerStartup.java @@ -2,11 +2,9 @@ package com.fr.start.module; import com.fr.module.Activator; import com.fr.stable.CoreActivator; -import com.fr.stable.module.ModuleListener; import com.fr.start.Designer; import com.fr.start.EnvSwitcher; -import com.fr.start.ReportSplashPane; -import com.fr.start.SplashWindow; +import com.fr.start.SplashContext; import com.fr.startup.activators.BasicActivator; /** @@ -16,12 +14,9 @@ public class DesignerStartup extends Activator { @Override public void start() { - startSub(PreStartActivator.class); //启动基础部分 startSub(BasicActivator.class); - //启动画面 - SplashWindow splashWindow = createSplashWindow(); String[] args = getModule().upFindSingleton(StartupArgs.class).get(); Designer designer = new Designer(args); //启动env @@ -33,18 +28,10 @@ public class DesignerStartup extends Activator { //启动设计器界面 designer.show(args); //启动画面结束 - splashWindow.setVisible(false); - splashWindow.dispose(); + SplashContext.getInstance().hide(); startSub(StartFinishActivator.class); } - - private SplashWindow createSplashWindow() { - - ReportSplashPane reportSplashPane = new ReportSplashPane(); - SplashWindow splashWindow = new SplashWindow(reportSplashPane); - getModule().setSingleton(ModuleListener.class, reportSplashPane.getModuleListener()); - return splashWindow; - } + @Override public void stop() { diff --git a/designer-realize/src/com/fr/start/module/PreStartActivator.java b/designer-realize/src/com/fr/start/module/PreStartActivator.java index eba3996b16..e013a35519 100644 --- a/designer-realize/src/com/fr/start/module/PreStartActivator.java +++ b/designer-realize/src/com/fr/start/module/PreStartActivator.java @@ -25,7 +25,6 @@ public class PreStartActivator extends Activator { public void start() { RestartHelper.deleteRecordFilesWhenStart(); - BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); SiteCenter.getInstance(); if (checkMultiStart()) { return; diff --git a/designer-realize/src/com/fr/start/module/StartFinishActivator.java b/designer-realize/src/com/fr/start/module/StartFinishActivator.java index f66459729b..b9e165b264 100644 --- a/designer-realize/src/com/fr/start/module/StartFinishActivator.java +++ b/designer-realize/src/com/fr/start/module/StartFinishActivator.java @@ -2,7 +2,6 @@ package com.fr.start.module; import com.fr.design.fun.impl.GlobalListenerProviderManager; import com.fr.design.utils.DesignUtils; -import com.fr.general.ModuleContext; import com.fr.module.Activator; /** @@ -16,7 +15,6 @@ public class StartFinishActivator extends Activator { public void start() { DesignUtils.creatListeningServer(getStartPort(), startFileSuffix()); - ModuleContext.clearModuleListener(); GlobalListenerProviderManager.getInstance().init(); }