From c9cf6f76590ab553651efe89799de3d56efc7403 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Tue, 15 Nov 2016 19:09:01 +0800 Subject: [PATCH 01/16] rt --- .../mainframe/widget/UITreeComboBox.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java index 38b62a99a..c315bca3b 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java +++ b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java @@ -15,6 +15,7 @@ import com.fr.design.designer.beans.*; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.mainframe.ComponentTree; import com.sun.java.swing.plaf.motif.*; import com.sun.java.swing.plaf.windows.*; @@ -116,7 +117,6 @@ public class UITreeComboBox extends JComboBox{ JLabel lb = (JLabel)r.getTreeCellRendererComponent( tree, value, isSelected, false, false, index, cellHasFocus); - return lb; } return super.getListCellRendererComponent(list, value, index, @@ -129,7 +129,7 @@ public class UITreeComboBox extends JComboBox{ @Override public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED || evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) { + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { TreePath[] paths = tree.getSelectedTreePath(); if (tree != null && paths.length > 0) { tree.setAndScrollSelectionPath(paths[0]); @@ -137,9 +137,18 @@ public class UITreeComboBox extends JComboBox{ MenuSelectionManager.defaultManager().clearSelectedPath(); } - } else { + } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) { + tree.refreshUI(); + TreePath[] paths = tree.getSelectedTreePath(); + if (tree != null && paths.length > 0) { + tree.setAndScrollSelectionPath(paths[0]); + setSelectedItem(paths[0]); + MenuSelectionManager.defaultManager().clearSelectedPath(); + } + } else { tree.refreshUI(); - repaint(); + setSelectedItem(null); + MenuSelectionManager.defaultManager().clearSelectedPath(); } } @@ -192,13 +201,12 @@ class TreePopup extends JPopupMenu implements ComboPopup{ public TreePopup(JComboBox comboBox){ this.comboBox = (UITreeComboBox)comboBox; - setBorder(BorderFactory.createLineBorder(Color.black)); setLayout(new BorderLayout()); setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled()); JTree tree = this.comboBox.getTree(); if(tree != null){ - scrollPane = new JScrollPane(tree); - scrollPane.setBorder(null); + scrollPane = new UIScrollPane(tree); + scrollPane.setBorder(BorderFactory.createEmptyBorder(0,4,0,0)); add(scrollPane, BorderLayout.CENTER); } } From 275fe159b03545ac76976bf0b03c23db8075d198 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 00:08:07 +0800 Subject: [PATCH 02/16] rt --- .../src/com/fr/design/mainframe/widget/UITreeComboBox.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java index c315bca3b..ea44f01c3 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java +++ b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java @@ -145,10 +145,13 @@ public class UITreeComboBox extends JComboBox{ setSelectedItem(paths[0]); MenuSelectionManager.defaultManager().clearSelectedPath(); } - } else { + } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED) { tree.refreshUI(); setSelectedItem(null); MenuSelectionManager.defaultManager().clearSelectedPath(); + } else { + tree.refreshUI(); + tree.repaint(); } } From c3ba1c7e3a8ca3e9ff1455209eb18cf4bc312c58 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 09:27:34 +0800 Subject: [PATCH 03/16] rt --- .../fr/design/mainframe/ComponentTree.java | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/ComponentTree.java b/designer_form/src/com/fr/design/mainframe/ComponentTree.java index ca84e44c0..a3452f602 100644 --- a/designer_form/src/com/fr/design/mainframe/ComponentTree.java +++ b/designer_form/src/com/fr/design/mainframe/ComponentTree.java @@ -38,29 +38,29 @@ public class ComponentTree extends JTree { this.refreshTreeRoot(); addTreeSelectionListener(designer); - this.addMouseListener(new MouseAdapter() { - - @Override - public void mouseClicked(MouseEvent e) { - if (e.isPopupTrigger()) { - popupMenu(e); - } - } - - @Override - public void mousePressed(MouseEvent e) { - if (e.isPopupTrigger()) { - popupMenu(e); - } - } - - @Override - public void mouseReleased(MouseEvent e) { - if (e.isPopupTrigger()) { - popupMenu(e); - } - } - }); +// this.addMouseListener(new MouseAdapter() { +// +// @Override +// public void mouseClicked(MouseEvent e) { +// if (e.isPopupTrigger()) { +// popupMenu(e); +// } +// } +// +// @Override +// public void mousePressed(MouseEvent e) { +// if (e.isPopupTrigger()) { +// popupMenu(e); +// } +// } +// +// @Override +// public void mouseReleased(MouseEvent e) { +// if (e.isPopupTrigger()) { +// popupMenu(e); +// } +// } +// }); setEditable(true); } @@ -121,19 +121,19 @@ public class ComponentTree extends JTree { scrollPathToVisible(treepath); } - private void popupMenu(MouseEvent e) { - TreePath path = this.getSelectionPath(); - if (path == null) { - return; - } - Component component = (Component) path.getLastPathComponent(); - if (!(component instanceof XCreator)) { - return; - } - ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, (XCreator) component); - JPopupMenu menu = adapter.getContextPopupMenu(e); - menu.show(this, e.getX(), e.getY()); - } +// private void popupMenu(MouseEvent e) { +// TreePath path = this.getSelectionPath(); +// if (path == null) { +// return; +// } +// Component component = (Component) path.getLastPathComponent(); +// if (!(component instanceof XCreator)) { +// return; +// } +// ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, (XCreator) component); +// JPopupMenu menu = adapter.getContextPopupMenu(e); +// menu.show(this, e.getX(), e.getY()); +// } /** * 刷新 From e533606177aae6a2ec8baab34afbaf36d41504db Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 15:50:11 +0800 Subject: [PATCH 04/16] rt --- .../mainframe/FormWidgetDetailPane.java | 112 +++++++++++++----- 1 file changed, 84 insertions(+), 28 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index 5beea605c..e74f9db1e 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -21,6 +21,7 @@ import com.fr.form.share.ShareLoader; import com.fr.form.ui.ElCaseBindInfo; import com.fr.general.Inter; import com.fr.general.SiteCenter; +import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import javax.swing.*; @@ -44,13 +45,17 @@ import java.net.URISyntaxException; public class FormWidgetDetailPane extends FormDockView{ private UITabbedPane tabbedPane; - private UIScrollPane downPanel; + private UIScrollPane downPane; private JPanel reuWidgetPanel; private UIComboBox comboBox; private ElCaseBindInfo[] elCaseBindInfoList; private UIButton downloadButton; private UIButton refreshButton; private UIButton deleteButton; + private UIButton resetButton; + private JPanel editPanel; + private JPanel resetPanel; + private JPanel menutPanel; private static final int OFFSET_X = 140; private static final int OFFSET_Y = 26; private SwingWorker sw; @@ -114,8 +119,6 @@ public class FormWidgetDetailPane extends FormDockView{ sw.execute(); } initReuWidgetPanel(); - createRefreshButton(); - createDownloadButton(); initMenuPanel(); tabbedPane = new UITabbedPane(); tabbedPane.setOpaque(true); @@ -131,34 +134,68 @@ public class FormWidgetDetailPane extends FormDockView{ * 初始化组件共享和复用面板 */ private void initReuWidgetPanel() { - downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList, false)); - reuWidgetPanel.add(downPanel); + downPane = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList, false)); + reuWidgetPanel.add(downPane); } /** * 初始化菜单栏面板 */ private void initMenuPanel() { - JPanel menutPane = new JPanel(); - menutPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - menutPane.setBorder(BorderFactory.createEmptyBorder(3, 8, 3, 3)); - menutPane.setPreferredSize(new Dimension(240, 48)); - menutPane.add(new UILabel(Inter.getLocText("FR-Designer_LocalWidget"), + menutPanel = new JPanel(); + menutPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); + menutPanel.setBorder(BorderFactory.createEmptyBorder(3, 8, 3, 3)); + menutPanel.setPreferredSize(new Dimension(240, 48)); + menutPanel.add(new UILabel(Inter.getLocText("FR-Designer_LocalWidget"), SwingConstants.HORIZONTAL), BorderLayout.WEST); - JPanel buttonPanel = new JPanel(); - buttonPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); - buttonPanel.add(refreshButton, BorderLayout.WEST); - buttonPanel.add(downloadButton, BorderLayout.EAST); - menutPane.add(buttonPanel, BorderLayout.EAST); - menutPane.add(new JPanel(), BorderLayout.CENTER); + + menutPanel.add(initButtonPane(), BorderLayout.EAST); + menutPanel.add(new JPanel(), BorderLayout.CENTER); comboBox = new UIComboBox(getFormCategories()); comboBox.setPreferredSize(new Dimension(240, 30)); initComboBoxSelectedListener(); - menutPane.add(comboBox, BorderLayout.SOUTH); - reuWidgetPanel.add(menutPane, BorderLayout.NORTH); + menutPanel.add(comboBox, BorderLayout.SOUTH); + reuWidgetPanel.add(menutPanel, BorderLayout.NORTH); + + } + + /** + * 创建菜单栏按钮面板 + */ + private JPanel initButtonPane() { + editPanel = new JPanel(); + editPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); + editPanel.add(createRefreshButton(), BorderLayout.WEST); + editPanel.add(createDownloadButton(), BorderLayout.EAST); + return editPanel; + } + + /** + * 创建取消删除面板 + */ + private JPanel initResetButtonPane() { + resetPanel = new JPanel(); + resetButton = new UIButton(Inter.getLocText("FR-Designer_Reset")); + resetPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + resetButton.set4ToolbarButton(); + resetButton.setOpaque(true); + resetButton.setBackground(new Color(184, 220, 242)); + resetButton.setForeground(Color.WHITE); + resetButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + refreshDownPanel(false); + replaceButtonPanel(false); + reuWidgetPanel.remove(deleteButton); + } + }); + resetPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); + resetPanel.add(resetButton, BorderLayout.CENTER); + return resetPanel; } + private void initComboBoxSelectedListener() { comboBox.addItemListener(new ItemListener() { @Override @@ -176,7 +213,10 @@ public class FormWidgetDetailPane extends FormDockView{ }); } - private void createRefreshButton() { + /** + * 创建刷新按钮 + */ + private UIButton createRefreshButton() { refreshButton = new UIButton(); refreshButton.setIcon(BaseUtils.readIcon("/com/fr/design/form/images/refresh.png")); refreshButton.setToolTipText(Inter.getLocText("FR-Designer_Refresh")); @@ -192,6 +232,7 @@ public class FormWidgetDetailPane extends FormDockView{ protected Object doInBackground() throws Exception { ShareLoader.getLoader().refreshModule(); elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); + comboBox.setSelectedIndex(0); refreshDownPanel(false); return null; } @@ -199,13 +240,14 @@ public class FormWidgetDetailPane extends FormDockView{ sw.execute(); } }); + return refreshButton; } /** * 创建下载模板的按钮 */ - private void createDownloadButton() { + private UIButton createDownloadButton() { downloadButton = new UIButton(); downloadButton.setIcon(BaseUtils.readIcon("/com/fr/design/form/images/showmenu.png")); downloadButton.set4ToolbarButton(); @@ -263,6 +305,7 @@ public class FormWidgetDetailPane extends FormDockView{ deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + replaceButtonPanel(true); deleteFromDiskZipFile(); } }); @@ -271,27 +314,28 @@ public class FormWidgetDetailPane extends FormDockView{ } }); + return downloadButton; } private void deleteFromDiskZipFile() { deleteButton = new UIButton(Inter.getLocText("FR-Designer-CommitTab_Remove")); - deleteButton.setOpaque(true); + deleteButton.setBackground(Color.red); + deleteButton.repaint(); deleteButton.setPreferredSize(new Dimension(240, 40)); reuWidgetPanel.add(deleteButton, BorderLayout.SOUTH); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if(ShareLoader.getLoader().removeModulesFromList()) { + if (ShareLoader.getLoader().removeModulesFromList()) { refreshShareMoudule(); reuWidgetPanel.remove(deleteButton); elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList(); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Share_Module_Removed_Successful")); refreshDownPanel(false); + replaceButtonPanel(false); } else { - reuWidgetPanel.remove(deleteButton); JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Share_Module_Removed_Failed")); - refreshDownPanel(false); } } @@ -300,6 +344,18 @@ public class FormWidgetDetailPane extends FormDockView{ } + private void replaceButtonPanel(boolean isEdit) { + if (isEdit) { + menutPanel.remove(editPanel); + menutPanel.add(initResetButtonPane(), BorderLayout.EAST); + } else { + menutPanel.remove(resetPanel); + menutPanel.add(initButtonPane(), BorderLayout.EAST); + } + + + } + private void installFromDiskZipFile(File chosenFile) { try { ShareLoader.getLoader().installModuleFromDiskZipFile(chosenFile); @@ -326,15 +382,15 @@ public class FormWidgetDetailPane extends FormDockView{ * 获取报表块组件分类 */ public String[] getFormCategories() { - return ShareConstants.WIDGET_CATEGORIES; + return ArrayUtils.addAll(new String[] {Inter.getLocText("FR-Designer_AllCategories")}, ShareLoader.getLoader().getModuleCategory()); } public void refreshDownPanel(boolean isEdit) { - reuWidgetPanel.remove(downPanel); - downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList, isEdit)); - reuWidgetPanel.add(downPanel); + reuWidgetPanel.remove(downPane); + downPane = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList, isEdit)); + reuWidgetPanel.add(downPane); repaintContainer(); } From b1fa14a43912857e20d94fd3a77126a574837a9d Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 15:51:00 +0800 Subject: [PATCH 05/16] rt --- .../src/com/fr/design/mainframe/widget/UITreeComboBox.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java index ea44f01c3..cf68a7ea7 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java +++ b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java @@ -151,7 +151,7 @@ public class UITreeComboBox extends JComboBox{ MenuSelectionManager.defaultManager().clearSelectedPath(); } else { tree.refreshUI(); - tree.repaint(); + repaint(); } } From 5a77fe8ee6c1ade8cc1e0a4e44b2bd02fe3d4214 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 15:58:43 +0800 Subject: [PATCH 06/16] rt --- .../fr/design/mainframe/ComponentTree.java | 450 ++++++++++-------- 1 file changed, 249 insertions(+), 201 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/ComponentTree.java b/designer_form/src/com/fr/design/mainframe/ComponentTree.java index a3452f602..ab1f2a980 100644 --- a/designer_form/src/com/fr/design/mainframe/ComponentTree.java +++ b/designer_form/src/com/fr/design/mainframe/ComponentTree.java @@ -1,255 +1,303 @@ -package com.fr.design.mainframe; - -import java.awt.Component; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; - -import javax.swing.DropMode; -import javax.swing.JPopupMenu; -import javax.swing.JTree; -import javax.swing.tree.TreePath; -import javax.swing.tree.TreeSelectionModel; - -import com.fr.design.constants.UIConstants; -import com.fr.design.designer.beans.AdapterBus; -import com.fr.design.designer.beans.ComponentAdapter; +package com.fr.design.mainframe.widget; + +/** + * Created by xiaxiang on 2016/9/30. + */ +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.plaf.*; +import javax.swing.plaf.basic.*; +import javax.swing.plaf.metal.*; +import javax.swing.tree.*; + +import com.fr.design.designer.beans.*; 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.treeview.ComponentTreeCellRenderer; -import com.fr.design.designer.treeview.ComponentTreeModel; -import com.fr.stable.StringUtils; - -public class ComponentTree extends JTree { - - private FormDesigner designer; - private ComponentTreeModel model; - - public ComponentTree(FormDesigner designer) { - this.designer = designer; - this.setBackground(UIConstants.NORMAL_BACKGROUND); - setRootVisible(true); - setCellRenderer(new ComponentTreeCellRenderer()); - getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); - this.setDragEnabled(false); - this.setDropMode(DropMode.ON_OR_INSERT); - this.setTransferHandler(new TreeTransferHandler()); - this.refreshTreeRoot(); - addTreeSelectionListener(designer); - -// this.addMouseListener(new MouseAdapter() { -// -// @Override -// public void mouseClicked(MouseEvent e) { -// if (e.isPopupTrigger()) { -// popupMenu(e); -// } -// } -// -// @Override -// public void mousePressed(MouseEvent e) { -// if (e.isPopupTrigger()) { -// popupMenu(e); -// } -// } -// -// @Override -// public void mouseReleased(MouseEvent e) { -// if (e.isPopupTrigger()) { -// popupMenu(e); -// } -// } -// }); - setEditable(true); - } - - public FormDesigner getDesigner() { - return designer; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.mainframe.ComponentTree; +import com.sun.java.swing.plaf.motif.*; +import com.sun.java.swing.plaf.windows.*; + +/** + * 控件树下拉列表框 + */ +public class UITreeComboBox extends JComboBox{ + /** + * 显示用的树 + */ + private ComponentTree tree; + + public UITreeComboBox(ComponentTree componentTree){ + this.setTree(componentTree); + tree.getDesigner().addDesignerEditListener(new TreeComboBoxDesignerEditAdapter()); +// for(int i=0; iTitle: UITreeComboBoxRenderer

+ *

Description: 树形结构而来的DefaultListCellRenderer

+ */ + class UITreeComboBoxRenderer extends DefaultListCellRenderer { + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus){ + if(tree != null && tree.getSelectedTreePath().length > 0){ + TreePath path = tree.getSelectedTreePath()[0]; + tree.setAndScrollSelectionPath(path); + Object node = path.getLastPathComponent(); + value = node; + TreeCellRenderer r = tree.getCellRenderer(); + JLabel lb = (JLabel)r.getTreeCellRendererComponent( + tree, value, isSelected, false, false, index, + cellHasFocus); + return lb; + } + return super.getListCellRendererComponent(list, value, index, + isSelected, cellHasFocus); + } + } + private class TreeComboBoxDesignerEditAdapter implements DesignerEditListener { + + @Override + public void fireCreatorModified(DesignerEvent evt) { + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { + TreePath[] paths = tree.getSelectedTreePath(); + if (tree != null && paths.length > 0) { + tree.setAndScrollSelectionPath(paths[0]); + setSelectedItem(paths[0]); + MenuSelectionManager.defaultManager().clearSelectedPath(); + } + + } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) { + tree.refreshUI(); + TreePath[] paths = tree.getSelectedTreePath(); + if (tree != null && paths.length > 0) { + tree.setAndScrollSelectionPath(paths[0]); + setSelectedItem(paths[0]); + MenuSelectionManager.defaultManager().clearSelectedPath(); + } + } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED) { + tree.refreshUI(); + setSelectedItem(null); + MenuSelectionManager.defaultManager().clearSelectedPath(); + } else { + tree.refreshUI(); + repaint(); + } - public TreePath[] getSelectedTreePath() { - XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators(); - TreePath[] paths = new TreePath[creators.length]; + } - for (int i = 0; i < paths.length; i++) { - paths[i] = buildTreePath(creators[i]); + @Override + public boolean equals(Object o) { + return o.getClass() == this.getClass(); } - return paths; } + /** + * 测试 + */ +// public static void main(String args[]){ +// JFrame frame = new JFrame("UITreeComboBox"); +// final UITreeComboBox box = new UITreeComboBox(new ComponentTree(new FormDesigner())); +// box.setPreferredSize(new Dimension(300, 28)); +// frame.getContentPane().add(box); +// frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); +// frame.pack(); +// frame.setVisible(true); +// } +} +/** + *

Title: UITreeComboBox

+ *

Description: TreePopup

+ */ +class TreePopup extends JPopupMenu implements ComboPopup{ + protected UITreeComboBox comboBox; + protected JScrollPane scrollPane; + protected MouseMotionListener mouseMotionListener; + protected MouseListener mouseListener; - /** - *搜索指定名称的路径 - * - * @param text 名称 - * @return 树路径 - */ - public TreePath[] search(String text) { - if (StringUtils.isNotEmpty(text)) { - text = text.toLowerCase(); - } - ArrayList searchList = new ArrayList(); - XLayoutContainer root = designer.getRootComponent(); - searchFormRoot(root, searchList, text); - TreePath[] paths = new TreePath[searchList.size()]; - for (int i = 0; i < paths.length; i++) { - paths[i] = buildTreePath(searchList.get(i)); + public void popupMenu(MouseEvent e) { + TreePath path = comboBox.getTree().getSelectionPath(); + if (path == null) { + return; } - if(paths.length > 0) { - setAndScrollSelectionPath(paths[0]); - } else { - setSelectionPath(); + Component component = (Component) path.getLastPathComponent(); + if (!(component instanceof XCreator)) { + return; + } + com.fr.design.designer.beans.ComponentAdapter adapter = AdapterBus.getComponentAdapter(comboBox.getTree().getDesigner(), (XCreator) component); + JPopupMenu menu = adapter.getContextPopupMenu(e); + menu.show(comboBox, e.getX(), e.getY()); + } + + public TreePopup(JComboBox comboBox){ + this.comboBox = (UITreeComboBox)comboBox; + setLayout(new BorderLayout()); + setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled()); + JTree tree = this.comboBox.getTree(); + if(tree != null){ + scrollPane = new UIScrollPane(tree); + scrollPane.setBorder(BorderFactory.createEmptyBorder(0,2,0,0)); + add(scrollPane, BorderLayout.CENTER); } - return paths; } + public void show() { + updatePopup(); + show(comboBox, 0, comboBox.getHeight()); + comboBox.getTree().requestFocus(); + } - private void setSelectionPath(){ + public void hide(){ + setVisible(false); + comboBox.firePropertyChange("popupVisible", true, false); + } - /** - * 不让传null参数,所以只有自己定义 - */ - super.setSelectionPath(null); - clearSelection(); + protected JList list = new JList(); + public JList getList(){ + return list; } - private void searchFormRoot(XLayoutContainer container, ArrayList searchList, String text) { - if (StringUtils.isEmpty(text)) { - return; - } - for (int i = 0, size = container.getXCreatorCount(); i < size; i++) { - XCreator creator = container.getXCreator(i); - String xName = creator.toData().getWidgetName(); - if (xName.toLowerCase().contains(text)) { - searchList.add(creator); - } - if (creator instanceof XLayoutContainer) { - searchFormRoot((XLayoutContainer) creator, searchList, text); - } + public MouseMotionListener getMouseMotionListener(){ + if(mouseMotionListener == null){ + mouseMotionListener = new MouseMotionAdapter(){}; } + return mouseMotionListener; } - /** - * 触发 - */ - public void fireTreeChanged() { - designer.refreshDesignerUI(); + public KeyListener getKeyListener(){ + return null; } + public void uninstallingUI(){} + /** - * 刷新 + * Implementation of ComboPopup.getMouseListener(). + * + * @return a MouseListener or null + * @see ComboPopup#getMouseListener */ - public void refreshTreeRoot() { - model = new ComponentTreeModel(designer, designer.getTopContainer()); - setModel(model); - setDragEnabled(false); - setDropMode(DropMode.ON_OR_INSERT); - setTransferHandler(new TreeTransferHandler()); - repaint(); - } - - private TreePath buildTreePath(Component comp) { - ArrayList path = new ArrayList(); - Component parent = comp; - - while (parent != null) { - XCreator creator = (XCreator) parent; - path.add(0, parent); - if (creator != comp ) { - creator.notShowInComponentTree(path); + public MouseListener getMouseListener(){ + if(mouseListener == null){ + mouseListener = new InvocationMouseHandler(); + } + return mouseListener; + } + + protected void togglePopup(){ + if(isVisible()){ + hide(); + } else{ + show(); + } + } + protected void updatePopup(){ + setPreferredSize(new Dimension(comboBox.getSize().width, 200)); + Object selectedObj = comboBox.getSelectedItem(); + if(selectedObj != null){ + TreePath tp = (TreePath)selectedObj; + ((UITreeComboBox)comboBox).getTree().setSelectionPath(tp); + } + } + + protected class InvocationMouseHandler extends MouseAdapter{ + public void mousePressed(MouseEvent e){ + if(!SwingUtilities.isLeftMouseButton(e) || !comboBox.isEnabled()){ + return; } - //绝对布局作为body的时候不显示自适应布局父层 - if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class) - && (parent.getParent() != null) - && ((XCreator)parent.getParent()).acceptType(XWFitLayout.class)){ - parent = parent.getParent().getParent(); - continue; + if(comboBox.isEditable()){ + Component comp = comboBox.getEditor().getEditorComponent(); + if((!(comp instanceof JComponent)) || + ((JComponent)comp).isRequestFocusEnabled()){ + comp.requestFocus(); + } + } else if(comboBox.isRequestFocusEnabled()){ + comboBox.requestFocus(); + } + togglePopup(); + } + + public void mouseClicked (MouseEvent e){ + if (e.isMetaDown()) { + popupMenu(e); + } else { + return; } - parent = parent.getParent(); } - Object[] components = path.toArray(); - return new TreePath(components); } -} \ No newline at end of file + + + +} From 693e858233401513c6e602e55c539dc4bb947c2e Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 16:00:12 +0800 Subject: [PATCH 07/16] rt --- .../src/com/fr/design/mainframe/widget/UITreeComboBox.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java index cf68a7ea7..c3e1d7303 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java +++ b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java @@ -209,7 +209,7 @@ class TreePopup extends JPopupMenu implements ComboPopup{ JTree tree = this.comboBox.getTree(); if(tree != null){ scrollPane = new UIScrollPane(tree); - scrollPane.setBorder(BorderFactory.createEmptyBorder(0,4,0,0)); + scrollPane.setBorder(BorderFactory.createEmptyBorder(0,2,0,0)); add(scrollPane, BorderLayout.CENTER); } } From a5e30ec9739cb850c6db45dabf785ab47ff49bda Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 16:00:29 +0800 Subject: [PATCH 08/16] rt --- .../fr/design/mainframe/ComponentTree.java | 450 ++++++++---------- 1 file changed, 201 insertions(+), 249 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/ComponentTree.java b/designer_form/src/com/fr/design/mainframe/ComponentTree.java index ab1f2a980..a3452f602 100644 --- a/designer_form/src/com/fr/design/mainframe/ComponentTree.java +++ b/designer_form/src/com/fr/design/mainframe/ComponentTree.java @@ -1,303 +1,255 @@ -package com.fr.design.mainframe.widget; - -/** - * Created by xiaxiang on 2016/9/30. - */ -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.plaf.*; -import javax.swing.plaf.basic.*; -import javax.swing.plaf.metal.*; -import javax.swing.tree.*; - -import com.fr.design.designer.beans.*; +package com.fr.design.mainframe; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; + +import javax.swing.DropMode; +import javax.swing.JPopupMenu; +import javax.swing.JTree; +import javax.swing.tree.TreePath; +import javax.swing.tree.TreeSelectionModel; + +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.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.mainframe.ComponentTree; -import com.sun.java.swing.plaf.motif.*; -import com.sun.java.swing.plaf.windows.*; - -/** - * 控件树下拉列表框 - */ -public class UITreeComboBox extends JComboBox{ - /** - * 显示用的树 - */ - private ComponentTree tree; - - public UITreeComboBox(ComponentTree componentTree){ - this.setTree(componentTree); - tree.getDesigner().addDesignerEditListener(new TreeComboBoxDesignerEditAdapter()); -// for(int i=0; iTitle: UITreeComboBoxRenderer

- *

Description: 树形结构而来的DefaultListCellRenderer

+ * 刷新 */ - class UITreeComboBoxRenderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus){ - if(tree != null && tree.getSelectedTreePath().length > 0){ - TreePath path = tree.getSelectedTreePath()[0]; - tree.setAndScrollSelectionPath(path); - Object node = path.getLastPathComponent(); - value = node; - TreeCellRenderer r = tree.getCellRenderer(); - JLabel lb = (JLabel)r.getTreeCellRendererComponent( - tree, value, isSelected, false, false, index, - cellHasFocus); - return lb; - } - return super.getListCellRendererComponent(list, value, index, - isSelected, cellHasFocus); - } + public void refreshUI() { + updateUI(); } - private class TreeComboBoxDesignerEditAdapter implements DesignerEditListener { - - @Override - public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { - TreePath[] paths = tree.getSelectedTreePath(); - if (tree != null && paths.length > 0) { - tree.setAndScrollSelectionPath(paths[0]); - setSelectedItem(paths[0]); - MenuSelectionManager.defaultManager().clearSelectedPath(); - } - - } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) { - tree.refreshUI(); - TreePath[] paths = tree.getSelectedTreePath(); - if (tree != null && paths.length > 0) { - tree.setAndScrollSelectionPath(paths[0]); - setSelectedItem(paths[0]); - MenuSelectionManager.defaultManager().clearSelectedPath(); - } - } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_CUTED) { - tree.refreshUI(); - setSelectedItem(null); - MenuSelectionManager.defaultManager().clearSelectedPath(); - } else { - tree.refreshUI(); - repaint(); - } - } - @Override - public boolean equals(Object o) { - return o.getClass() == this.getClass(); + + public TreePath[] getSelectedTreePath() { + XCreator[] creators = designer.getSelectionModel().getSelection().getSelectedCreators(); + TreePath[] paths = new TreePath[creators.length]; + + for (int i = 0; i < paths.length; i++) { + paths[i] = buildTreePath(creators[i]); } + return paths; } - /** - * 测试 - */ -// public static void main(String args[]){ -// JFrame frame = new JFrame("UITreeComboBox"); -// final UITreeComboBox box = new UITreeComboBox(new ComponentTree(new FormDesigner())); -// box.setPreferredSize(new Dimension(300, 28)); -// frame.getContentPane().add(box); -// frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); -// frame.pack(); -// frame.setVisible(true); -// } -} - -/** - *

Title: UITreeComboBox

- *

Description: TreePopup

- */ -class TreePopup extends JPopupMenu implements ComboPopup{ - protected UITreeComboBox comboBox; - protected JScrollPane scrollPane; - protected MouseMotionListener mouseMotionListener; - protected MouseListener mouseListener; - public void popupMenu(MouseEvent e) { - TreePath path = comboBox.getTree().getSelectionPath(); - if (path == null) { - return; - } - Component component = (Component) path.getLastPathComponent(); - if (!(component instanceof XCreator)) { - return; + /** + *搜索指定名称的路径 + * + * @param text 名称 + * @return 树路径 + */ + public TreePath[] search(String text) { + if (StringUtils.isNotEmpty(text)) { + text = text.toLowerCase(); } - com.fr.design.designer.beans.ComponentAdapter adapter = AdapterBus.getComponentAdapter(comboBox.getTree().getDesigner(), (XCreator) component); - JPopupMenu menu = adapter.getContextPopupMenu(e); - menu.show(comboBox, e.getX(), e.getY()); - } + ArrayList searchList = new ArrayList(); + XLayoutContainer root = designer.getRootComponent(); + searchFormRoot(root, searchList, text); + TreePath[] paths = new TreePath[searchList.size()]; - public TreePopup(JComboBox comboBox){ - this.comboBox = (UITreeComboBox)comboBox; - setLayout(new BorderLayout()); - setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled()); - JTree tree = this.comboBox.getTree(); - if(tree != null){ - scrollPane = new UIScrollPane(tree); - scrollPane.setBorder(BorderFactory.createEmptyBorder(0,2,0,0)); - add(scrollPane, BorderLayout.CENTER); + for (int i = 0; i < paths.length; i++) { + paths[i] = buildTreePath(searchList.get(i)); + } + if(paths.length > 0) { + setAndScrollSelectionPath(paths[0]); + } else { + setSelectionPath(); } + return paths; } - public void show() { - updatePopup(); - show(comboBox, 0, comboBox.getHeight()); - comboBox.getTree().requestFocus(); - } - public void hide(){ - setVisible(false); - comboBox.firePropertyChange("popupVisible", true, false); - } + private void setSelectionPath(){ - protected JList list = new JList(); - public JList getList(){ - return list; + /** + * 不让传null参数,所以只有自己定义 + */ + super.setSelectionPath(null); + clearSelection(); } - public MouseMotionListener getMouseMotionListener(){ - if(mouseMotionListener == null){ - mouseMotionListener = new MouseMotionAdapter(){}; + private void searchFormRoot(XLayoutContainer container, ArrayList searchList, String text) { + if (StringUtils.isEmpty(text)) { + return; + } + for (int i = 0, size = container.getXCreatorCount(); i < size; i++) { + XCreator creator = container.getXCreator(i); + String xName = creator.toData().getWidgetName(); + if (xName.toLowerCase().contains(text)) { + searchList.add(creator); + } + if (creator instanceof XLayoutContainer) { + searchFormRoot((XLayoutContainer) creator, searchList, text); + } } - return mouseMotionListener; - } - - public KeyListener getKeyListener(){ - return null; } - public void uninstallingUI(){} - /** - * Implementation of ComboPopup.getMouseListener(). - * - * @return a MouseListener or null - * @see ComboPopup#getMouseListener + * 触发 */ - public MouseListener getMouseListener(){ - if(mouseListener == null){ - mouseListener = new InvocationMouseHandler(); - } - return mouseListener; - } - - protected void togglePopup(){ - if(isVisible()){ - hide(); - } else{ - show(); - } - } - protected void updatePopup(){ - setPreferredSize(new Dimension(comboBox.getSize().width, 200)); - Object selectedObj = comboBox.getSelectedItem(); - if(selectedObj != null){ - TreePath tp = (TreePath)selectedObj; - ((UITreeComboBox)comboBox).getTree().setSelectionPath(tp); - } + public void fireTreeChanged() { + designer.refreshDesignerUI(); } - protected class InvocationMouseHandler extends MouseAdapter{ - public void mousePressed(MouseEvent e){ - if(!SwingUtilities.isLeftMouseButton(e) || !comboBox.isEnabled()){ - return; - } - if(comboBox.isEditable()){ - Component comp = comboBox.getEditor().getEditorComponent(); - if((!(comp instanceof JComponent)) || - ((JComponent)comp).isRequestFocusEnabled()){ - comp.requestFocus(); - } - } else if(comboBox.isRequestFocusEnabled()){ - comboBox.requestFocus(); + /** + * 刷新 + */ + public void refreshTreeRoot() { + model = new ComponentTreeModel(designer, designer.getTopContainer()); + setModel(model); + setDragEnabled(false); + setDropMode(DropMode.ON_OR_INSERT); + setTransferHandler(new TreeTransferHandler()); + repaint(); + } + + private TreePath buildTreePath(Component comp) { + ArrayList path = new ArrayList(); + Component parent = comp; + + while (parent != null) { + XCreator creator = (XCreator) parent; + path.add(0, parent); + if (creator != comp ) { + creator.notShowInComponentTree(path); } - togglePopup(); - } - - public void mouseClicked (MouseEvent e){ - if (e.isMetaDown()) { - popupMenu(e); - } else { - return; + //绝对布局作为body的时候不显示自适应布局父层 + if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class) + && (parent.getParent() != null) + && ((XCreator)parent.getParent()).acceptType(XWFitLayout.class)){ + parent = parent.getParent().getParent(); + continue; } + parent = parent.getParent(); } + Object[] components = path.toArray(); + return new TreePath(components); } - - - -} +} \ No newline at end of file From b75e8f0422fa1e6ac2b36284d8760b6940291154 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 16:15:26 +0800 Subject: [PATCH 09/16] rt --- .../fr/design/mainframe/FormWidgetDetailPane.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index e74f9db1e..2a490726f 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -49,8 +49,6 @@ public class FormWidgetDetailPane extends FormDockView{ private JPanel reuWidgetPanel; private UIComboBox comboBox; private ElCaseBindInfo[] elCaseBindInfoList; - private UIButton downloadButton; - private UIButton refreshButton; private UIButton deleteButton; private UIButton resetButton; private JPanel editPanel; @@ -149,7 +147,7 @@ public class FormWidgetDetailPane extends FormDockView{ menutPanel.add(new UILabel(Inter.getLocText("FR-Designer_LocalWidget"), SwingConstants.HORIZONTAL), BorderLayout.WEST); - menutPanel.add(initButtonPane(), BorderLayout.EAST); + menutPanel.add(initEditButtonPane(), BorderLayout.EAST); menutPanel.add(new JPanel(), BorderLayout.CENTER); comboBox = new UIComboBox(getFormCategories()); comboBox.setPreferredSize(new Dimension(240, 30)); @@ -162,7 +160,7 @@ public class FormWidgetDetailPane extends FormDockView{ /** * 创建菜单栏按钮面板 */ - private JPanel initButtonPane() { + private JPanel initEditButtonPane() { editPanel = new JPanel(); editPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); editPanel.add(createRefreshButton(), BorderLayout.WEST); @@ -217,7 +215,7 @@ public class FormWidgetDetailPane extends FormDockView{ * 创建刷新按钮 */ private UIButton createRefreshButton() { - refreshButton = new UIButton(); + UIButton refreshButton = new UIButton(); refreshButton.setIcon(BaseUtils.readIcon("/com/fr/design/form/images/refresh.png")); refreshButton.setToolTipText(Inter.getLocText("FR-Designer_Refresh")); refreshButton.set4ToolbarButton(); @@ -248,7 +246,7 @@ public class FormWidgetDetailPane extends FormDockView{ * 创建下载模板的按钮 */ private UIButton createDownloadButton() { - downloadButton = new UIButton(); + UIButton downloadButton = new UIButton(); downloadButton.setIcon(BaseUtils.readIcon("/com/fr/design/form/images/showmenu.png")); downloadButton.set4ToolbarButton(); downloadButton.setToolTipText(Inter.getLocText("FR-Designer_Download_Template")); @@ -350,7 +348,8 @@ public class FormWidgetDetailPane extends FormDockView{ menutPanel.add(initResetButtonPane(), BorderLayout.EAST); } else { menutPanel.remove(resetPanel); - menutPanel.add(initButtonPane(), BorderLayout.EAST); + menutPanel.add(initEditButtonPane(), BorderLayout.EAST); + ShareLoader.getLoader().resetRemovedModuleList(); } From 18ab59513070bab3deeb79fa5f468991d4f08c60 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 16:17:47 +0800 Subject: [PATCH 10/16] rt --- .../src/com/fr/design/mainframe/widget/UITreeComboBox.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java index c3e1d7303..0d7b224f6 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java +++ b/designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java @@ -209,7 +209,7 @@ class TreePopup extends JPopupMenu implements ComboPopup{ JTree tree = this.comboBox.getTree(); if(tree != null){ scrollPane = new UIScrollPane(tree); - scrollPane.setBorder(BorderFactory.createEmptyBorder(0,2,0,0)); + scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); add(scrollPane, BorderLayout.CENTER); } } From e1ea2ec04904dac22880d46dcba85aa34d91a1ce Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 16:31:49 +0800 Subject: [PATCH 11/16] rt --- .../src/com/fr/design/mainframe/FormWidgetDetailPane.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index 2a490726f..cde028801 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -19,6 +19,7 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.share.ShareConstants; import com.fr.form.share.ShareLoader; import com.fr.form.ui.ElCaseBindInfo; +import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.general.SiteCenter; import com.fr.stable.ArrayUtils; @@ -257,11 +258,9 @@ public class FormWidgetDetailPane extends FormDockView{ UIMenuItem downloadItem = new UIMenuItem(Inter.getLocText("FR-Designer_Download_Template"), BaseUtils.readIcon("/com/fr/design/form/images/download icon.png")); UIMenuItem installItem = new UIMenuItem(Inter.getLocText("FR-Designer_Install_Template"), BaseUtils.readIcon("/com/fr/design/form/images/install icon.png")); UIMenuItem deleteItem = new UIMenuItem(Inter.getLocText("FR-Designer_Delete_Template"), BaseUtils.readIcon("/com/fr/design/form/images/delete icon.png")); - menu.add(downloadItem); menu.add(installItem); menu.add(deleteItem); - downloadItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -291,7 +290,7 @@ public class FormWidgetDetailPane extends FormDockView{ JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setFileFilter(new FileNameExtensionFilter(".reu", "reu")); - int returnValue = fileChooser.showDialog(new JLabel(), Inter.getLocText("FR-Designer_Select")); + int returnValue = fileChooser.showDialog(new UILabel(), Inter.getLocText("FR-Designer_Select")); if (returnValue == JFileChooser.APPROVE_OPTION) { final File chosenFile = fileChooser.getSelectedFile(); installFromDiskZipFile(chosenFile); @@ -364,7 +363,7 @@ public class FormWidgetDetailPane extends FormDockView{ JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Share_Module_OK")); } catch (IOException e) { JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Share_Module_Error")); - e.printStackTrace(); + FRLogger.getLogger().error(e.getMessage(), e); } } From 8c911275b7e3a8df09716c5e7251ff951bd8b35c Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 16:33:41 +0800 Subject: [PATCH 12/16] rt --- .../src/com/fr/design/mainframe/FormWidgetDetailPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index cde028801..e94974b61 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -372,7 +372,7 @@ public class FormWidgetDetailPane extends FormDockView{ try { ShareLoader.getLoader().refreshModule(); } catch (Exception e) { - e.printStackTrace(); + FRLogger.getLogger().error(e.getMessage(), e); } } From e3b98e7ec1f6cb400cc37c6ffc761c6f7659a992 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 16:50:55 +0800 Subject: [PATCH 13/16] rt --- .../src/com/fr/design/mainframe/FormWidgetDetailPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index e94974b61..c8f17031e 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -272,7 +272,7 @@ public class FormWidgetDetailPane extends FormDockView{ try { Desktop.getDesktop().browse(new URI(url)); } catch (IOException exp) { - JOptionPane.showMessageDialog(null, Inter.getLocText("Set_default_browser")); + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer_Set_default_browser")); FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); } catch (URISyntaxException exp) { FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); From 10d591ada7f22b58b7588da6643fb1a747d554cd Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 16:59:08 +0800 Subject: [PATCH 14/16] rt --- .../src/com/fr/design/mainframe/ComponentTree.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/ComponentTree.java b/designer_form/src/com/fr/design/mainframe/ComponentTree.java index a3452f602..d439629d5 100644 --- a/designer_form/src/com/fr/design/mainframe/ComponentTree.java +++ b/designer_form/src/com/fr/design/mainframe/ComponentTree.java @@ -241,12 +241,14 @@ public class ComponentTree extends JTree { creator.notShowInComponentTree(path); } //绝对布局作为body的时候不显示自适应布局父层 - if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class) - && (parent.getParent() != null) - && ((XCreator)parent.getParent()).acceptType(XWFitLayout.class)){ - parent = parent.getParent().getParent(); - continue; + if (((XCreator) parent).acceptType(XWAbsoluteBodyLayout.class)) { + if ((parent.getParent() != null) + && ((XCreator)parent.getParent()).acceptType(XWFitLayout.class)){ + parent = parent.getParent().getParent(); + continue; + } } + parent = parent.getParent(); } Object[] components = path.toArray(); From 0aa3db1c0f10260690a4fa89454d170151395f72 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 17:17:29 +0800 Subject: [PATCH 15/16] rt --- .../mainframe/FormWidgetDetailPane.java | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java index c8f17031e..a9f4b6bf7 100644 --- a/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -254,69 +254,69 @@ public class FormWidgetDetailPane extends FormDockView{ downloadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - UIPopupMenu menu = new UIPopupMenu(); - UIMenuItem downloadItem = new UIMenuItem(Inter.getLocText("FR-Designer_Download_Template"), BaseUtils.readIcon("/com/fr/design/form/images/download icon.png")); - UIMenuItem installItem = new UIMenuItem(Inter.getLocText("FR-Designer_Install_Template"), BaseUtils.readIcon("/com/fr/design/form/images/install icon.png")); - UIMenuItem deleteItem = new UIMenuItem(Inter.getLocText("FR-Designer_Delete_Template"), BaseUtils.readIcon("/com/fr/design/form/images/delete icon.png")); - menu.add(downloadItem); - menu.add(installItem); - menu.add(deleteItem); - downloadItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - String url = SiteCenter.getInstance().acquireUrlByKind("reuse.url"); - if (StringUtils.isEmpty(url)) { - FRContext.getLogger().info("The URL is empty!"); - return; - } - try { - Desktop.getDesktop().browse(new URI(url)); - } catch (IOException exp) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer_Set_default_browser")); - FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); - } catch (URISyntaxException exp) { - FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); - } catch (Exception exp) { - FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); - FRContext.getLogger().error("Can not open the browser for URL: " + url); - } - - } - }); - - installItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - fileChooser.setFileFilter(new FileNameExtensionFilter(".reu", "reu")); - int returnValue = fileChooser.showDialog(new UILabel(), Inter.getLocText("FR-Designer_Select")); - if (returnValue == JFileChooser.APPROVE_OPTION) { - final File chosenFile = fileChooser.getSelectedFile(); - installFromDiskZipFile(chosenFile); - - } - } - }); - - deleteItem.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - replaceButtonPanel(true); - deleteFromDiskZipFile(); - } - }); - - GUICoreUtils.showPopupMenu(menu, tabbedPane, tabbedPane.getX() + OFFSET_X, OFFSET_Y); - + initPopMenu(); } }); return downloadButton; } + /** + * 初始化下拉面板 + */ + private void initPopMenu() { + UIPopupMenu menu = new UIPopupMenu(); + UIMenuItem downloadItem = new UIMenuItem(Inter.getLocText("FR-Designer_Download_Template"), BaseUtils.readIcon("/com/fr/design/form/images/download icon.png")); + UIMenuItem installItem = new UIMenuItem(Inter.getLocText("FR-Designer_Install_Template"), BaseUtils.readIcon("/com/fr/design/form/images/install icon.png")); + UIMenuItem deleteItem = new UIMenuItem(Inter.getLocText("FR-Designer_Delete_Template"), BaseUtils.readIcon("/com/fr/design/form/images/delete icon.png")); + menu.add(downloadItem); + menu.add(installItem); + menu.add(deleteItem); + downloadItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String url = SiteCenter.getInstance().acquireUrlByKind("reuse.url"); + if (StringUtils.isEmpty(url)) { + FRContext.getLogger().info("The URL is empty!"); + return; + } + try { + Desktop.getDesktop().browse(new URI(url)); + } catch (IOException exp) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer_Set_default_browser")); + FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); + } catch (URISyntaxException exp) { + FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); + } catch (Exception exp) { + FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); + FRContext.getLogger().error("Can not open the browser for URL: " + url); + } + } + }); + installItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); + fileChooser.setFileFilter(new FileNameExtensionFilter(".reu", "reu")); + int returnValue = fileChooser.showDialog(new UILabel(), Inter.getLocText("FR-Designer_Select")); + if (returnValue == JFileChooser.APPROVE_OPTION) { + final File chosenFile = fileChooser.getSelectedFile(); + installFromDiskZipFile(chosenFile); + } + } + }); + deleteItem.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + replaceButtonPanel(true); + deleteFromDiskZipFile(); + } + }); + GUICoreUtils.showPopupMenu(menu, tabbedPane, tabbedPane.getX() + OFFSET_X, OFFSET_Y); + } + private void deleteFromDiskZipFile() { deleteButton = new UIButton(Inter.getLocText("FR-Designer-CommitTab_Remove")); - deleteButton.setBackground(Color.red); deleteButton.repaint(); deleteButton.setPreferredSize(new Dimension(240, 40)); From 8eaf712d94e32bcf2efc292fcdaf2fbb1f8d2631 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 16 Nov 2016 17:38:43 +0800 Subject: [PATCH 16/16] rt --- .../fr/design/mainframe/ComponentTree.java | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/ComponentTree.java b/designer_form/src/com/fr/design/mainframe/ComponentTree.java index d439629d5..4d58c4887 100644 --- a/designer_form/src/com/fr/design/mainframe/ComponentTree.java +++ b/designer_form/src/com/fr/design/mainframe/ComponentTree.java @@ -37,30 +37,6 @@ public class ComponentTree extends JTree { this.setTransferHandler(new TreeTransferHandler()); this.refreshTreeRoot(); addTreeSelectionListener(designer); - -// this.addMouseListener(new MouseAdapter() { -// -// @Override -// public void mouseClicked(MouseEvent e) { -// if (e.isPopupTrigger()) { -// popupMenu(e); -// } -// } -// -// @Override -// public void mousePressed(MouseEvent e) { -// if (e.isPopupTrigger()) { -// popupMenu(e); -// } -// } -// -// @Override -// public void mouseReleased(MouseEvent e) { -// if (e.isPopupTrigger()) { -// popupMenu(e); -// } -// } -// }); setEditable(true); } @@ -121,19 +97,6 @@ public class ComponentTree extends JTree { scrollPathToVisible(treepath); } -// private void popupMenu(MouseEvent e) { -// TreePath path = this.getSelectionPath(); -// if (path == null) { -// return; -// } -// Component component = (Component) path.getLastPathComponent(); -// if (!(component instanceof XCreator)) { -// return; -// } -// ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, (XCreator) component); -// JPopupMenu menu = adapter.getContextPopupMenu(e); -// menu.show(this, e.getX(), e.getY()); -// } /** * 刷新