diff --git a/designer_base/src/com/fr/design/ExtraDesignClassManager.java b/designer_base/src/com/fr/design/ExtraDesignClassManager.java index 771dbec7a..a861772c9 100644 --- a/designer_base/src/com/fr/design/ExtraDesignClassManager.java +++ b/designer_base/src/com/fr/design/ExtraDesignClassManager.java @@ -130,6 +130,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi private Set elementUIProviders; + private Set widgetAttrProviders; + public TableDataTreePaneProcessor getTableDataTreePaneProcessor() { return tableDataTreePaneProcessor; } @@ -736,6 +738,21 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi elementUIProviders.add((ElementUIProvider) level); } + public WidgetAttrProvider[] getWidgetAttrProviders() { + if (widgetAttrProviders == null) { + return new WidgetAttrProvider[0]; + } + return widgetAttrProviders.toArray(new WidgetAttrProvider[widgetAttrProviders.size()]); + } + + public void addWidgetAttrProvider(Level level, PluginSimplify simplify) throws Exception { + if (widgetAttrProviders == null) { + widgetAttrProviders = new HashSet(); + } + validAPILevel(level, WidgetAttrProvider.CURRENT_LEVEL, simplify.getPluginName()); + widgetAttrProviders.add((WidgetAttrProvider) level); + } + /** * 文件名 * @@ -828,6 +845,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi setTableDataSourceOPProcessor(impl, simplify); } else if (tagName.equals(ElementUIProvider.MARK_STRING)) { addElementUIProvider(impl, simplify); + } else if (tagName.equals(WidgetAttrProvider.XML_TAG)) { + addWidgetAttrProvider(impl, simplify); } } catch (PluginInvalidLevelException e) { PluginMessage.remindUpdate(e.getMessage()); diff --git a/designer_base/src/com/fr/design/extra/PluginManagerPane.java b/designer_base/src/com/fr/design/extra/PluginManagerPane.java index 0704977f6..ae64f58a6 100644 --- a/designer_base/src/com/fr/design/extra/PluginManagerPane.java +++ b/designer_base/src/com/fr/design/extra/PluginManagerPane.java @@ -43,22 +43,22 @@ public class PluginManagerPane extends BasicPane { URL url = ClassLoader.getSystemResource(""); installHome = url.getPath(); } else { - installHome = StableUtils.getInstallHome(); - File file = new File(StableUtils.pathJoin(installHome, "scripts")); - if (!file.exists()) { - int rv = JOptionPane.showConfirmDialog( - null, - Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), - Inter.getLocText("FR-Designer-Plugin_Warning"), - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE - ); - if (rv == JOptionPane.OK_OPTION) { - downloadShopScripts(); + installHome = StableUtils.getInstallHome(); + File file = new File(StableUtils.pathJoin(installHome, "scripts")); + if (!file.exists()) { + int rv = JOptionPane.showConfirmDialog( + this, + Inter.getLocText("FR-Designer-Plugin_Shop_Need_Install"), + Inter.getLocText("FR-Designer-Plugin_Warning"), + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.INFORMATION_MESSAGE + ); + if (rv == JOptionPane.OK_OPTION) { + downloadShopScripts(); + } + } else { + updateShopScripts(); } - } else { - updateShopScripts(); - } } PluginWebPane webPane = new PluginWebPane(new File(installHome).getAbsolutePath()); add(webPane, BorderLayout.CENTER); @@ -90,7 +90,7 @@ public class PluginManagerPane extends BasicPane { } }); } catch (PluginVerifyException e) { - JOptionPane.showMessageDialog(null, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(PluginManagerPane.this, e.getMessage(), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.ERROR_MESSAGE); return false; } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); @@ -106,7 +106,7 @@ public class PluginManagerPane extends BasicPane { if (get()) { IOUtils.unzip(new File(StableUtils.pathJoin(PluginHelper.DOWNLOAD_PATH, PluginHelper.TEMP_FILE)), StableUtils.getInstallHome()); int rv = JOptionPane.showOptionDialog( - null, + PluginManagerPane.this, Inter.getLocText("FR-Designer-Plugin_Shop_Installed"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.YES_NO_OPTION, @@ -135,7 +135,7 @@ public class PluginManagerPane extends BasicPane { if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { if (!ComparatorUtils.equals(httpClient.getResponseText(), LATEST)) { int rv = JOptionPane.showConfirmDialog( - null, + PluginManagerPane.this, Inter.getLocText("FR-Designer-Plugin_Shop_Need_Update"), Inter.getLocText("FR-Designer-Plugin_Warning"), JOptionPane.OK_CANCEL_OPTION, diff --git a/designer_base/src/com/fr/design/extra/PluginShopDialog.java b/designer_base/src/com/fr/design/extra/PluginShopDialog.java index cc75e46e8..05b192b95 100644 --- a/designer_base/src/com/fr/design/extra/PluginShopDialog.java +++ b/designer_base/src/com/fr/design/extra/PluginShopDialog.java @@ -10,7 +10,7 @@ import java.awt.*; * Created by vito on 16/4/18. */ public class PluginShopDialog extends UIDialog { - private static final Dimension DEFAULT_SHOP = new Dimension(900, 700); + private static final Dimension DEFAULT_SHOP = new Dimension(900, 690); public PluginShopDialog(Frame frame, BasicPane pane) { super(frame, pane, false); diff --git a/designer_base/src/com/fr/design/fun/MenuHandler.java b/designer_base/src/com/fr/design/fun/MenuHandler.java index 53958f856..5b9dd179d 100644 --- a/designer_base/src/com/fr/design/fun/MenuHandler.java +++ b/designer_base/src/com/fr/design/fun/MenuHandler.java @@ -10,7 +10,7 @@ import com.fr.stable.fun.Level; * @since 8.0 * 设计器菜单栏插件接口 */ -public interface MenuHandler extends Level{ +public interface MenuHandler extends Level { String MARK_STRING = "MenuHandler"; @@ -30,47 +30,43 @@ public interface MenuHandler extends Level{ * 插入菜单的位置 * * @param total 插入的位置 - * * @return 插入位置,如果想放到最后,则返回-1 */ int insertPosition(int total); /** * 是否在插入的菜单前插入一个分割符 + * * @return 是否插入分隔符 */ boolean insertSeparatorBefore(); /** * 是否在插入的菜单后插入一个分割符 + * * @return 是否插入分隔符 */ boolean insertSeparatorAfter(); /** * 所属的分类菜单 + * * @return 分类菜单名 */ String category(); /** * 具体的菜单项内容 + * * @return 菜单项内容 */ ShortCut shortcut(); /** * 具体的菜单项内容 - * @param plus 当前模板 * + * @param plus 当前模板 * @return 菜单项内容 */ ShortCut shortcut(ToolBarMenuDockPlus plus); - - /** - * 两个菜单项相等等情况 - * @param obj 比较对象 - * @return 相等则返回true,否则返回false - */ - boolean equals(Object obj); } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/fun/WidgetAttrProvider.java b/designer_base/src/com/fr/design/fun/WidgetAttrProvider.java new file mode 100644 index 000000000..4d2c2e624 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/WidgetAttrProvider.java @@ -0,0 +1,18 @@ +package com.fr.design.fun; + +import com.fr.design.gui.itable.AbstractPropertyTable; +import com.fr.stable.fun.Level; + + +/** + * Created by vito on 16/4/27. + */ +public interface WidgetAttrProvider extends Level { + String XML_TAG = "WidgetAttrProvider"; + + int CURRENT_LEVEL = 1; + + AbstractPropertyTable createWidgetAttrTable(); + + String tableTitle(); +} diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractMenuHandler.java b/designer_base/src/com/fr/design/fun/impl/AbstractMenuHandler.java index db911f501..d62769a2d 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractMenuHandler.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractMenuHandler.java @@ -3,39 +3,22 @@ package com.fr.design.fun.impl; import com.fr.design.fun.MenuHandler; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.menu.ShortCut; -import com.fr.general.ComparatorUtils; +import com.fr.stable.fun.impl.AbstractProvider; /** * @author richie * @date 2015-05-13 * @since 8.0 */ -public abstract class AbstractMenuHandler implements MenuHandler { +public abstract class AbstractMenuHandler extends AbstractProvider implements MenuHandler { public int currentAPILevel() { return CURRENT_LEVEL; } - - public boolean equals(Object obj) { - return obj instanceof AbstractMenuHandler - && ComparatorUtils.equals(category(), ((AbstractMenuHandler) obj).category()) - && shortCutEquals(this, (AbstractMenuHandler)obj); - } - - private boolean shortCutEquals(AbstractMenuHandler target, AbstractMenuHandler self){ - ShortCut targetShortCut = target.shortcut(); - ShortCut selfShortCut = self.shortcut(); - - if (targetShortCut == null && selfShortCut == null){ - return true; - } - - if (targetShortCut != null && selfShortCut != null){ - return ComparatorUtils.equals(targetShortCut.getClass(), selfShortCut.getClass()); - } - - return false; + @Override + public String mark4Provider() { + return this.getClass().getName(); } /** @@ -43,9 +26,8 @@ public abstract class AbstractMenuHandler implements MenuHandler { * 不需要选中对象, (文件, 服务器, 关于) * * @return 菜单Action - * */ - public ShortCut shortcut(){ + public ShortCut shortcut() { return null; } @@ -53,11 +35,9 @@ public abstract class AbstractMenuHandler implements MenuHandler { * 获取当前菜单对应的Action * * @param plus 当前选中的对象(模板) - * * @return 菜单Action - * */ - public ShortCut shortcut(ToolBarMenuDockPlus plus){ + public ShortCut shortcut(ToolBarMenuDockPlus plus) { return null; } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractWidgetAttrProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractWidgetAttrProvider.java new file mode 100644 index 000000000..8471115e8 --- /dev/null +++ b/designer_base/src/com/fr/design/fun/impl/AbstractWidgetAttrProvider.java @@ -0,0 +1,21 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.WidgetAttrProvider; +import com.fr.stable.fun.impl.AbstractProvider; + + +/** + * Created by vito on 16/4/27. + */ +public abstract class AbstractWidgetAttrProvider extends AbstractProvider implements WidgetAttrProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return this.getClass().getName(); + } +} diff --git a/designer_base/src/com/fr/start/BaseDesigner.java b/designer_base/src/com/fr/start/BaseDesigner.java index df341bc41..6d92b1067 100644 --- a/designer_base/src/com/fr/start/BaseDesigner.java +++ b/designer_base/src/com/fr/start/BaseDesigner.java @@ -7,8 +7,10 @@ import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.RestartHelper; -import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.UIDialog; import com.fr.design.extra.PluginManagerPane; +import com.fr.design.extra.PluginShopDialog; +import com.fr.design.extra.PluginWebBridge; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.TemplateTreePane; @@ -130,7 +132,8 @@ public abstract class BaseDesigner extends ToolBarMenuDock { int r = JOptionPane.showConfirmDialog(null, text, Inter.getLocText("FR-Designer_Plugin_Should_Update_Title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); if (r == JOptionPane.OK_OPTION) { final PluginManagerPane managerPane = new PluginManagerPane(); - BasicDialog dlg = managerPane.showLargeWindow(DesignerContext.getDesignerFrame(),null); + UIDialog dlg = new PluginShopDialog(DesignerContext.getDesignerFrame(),managerPane); + PluginWebBridge.getHelper().setDialogHandle(dlg); dlg.setVisible(true); } } diff --git a/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java b/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java index 8fb8a904d..68bb08701 100644 --- a/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java @@ -1,12 +1,14 @@ package com.fr.design.mainframe; import java.awt.BorderLayout; +import java.util.ArrayList; +import java.util.List; -import javax.swing.Icon; -import javax.swing.JScrollPane; -import javax.swing.SwingConstants; +import javax.swing.*; import com.fr.base.BaseUtils; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.WidgetAttrProvider; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.general.Inter; import com.fr.design.gui.icontainer.UIScrollPane; @@ -24,6 +26,8 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper private WidgetPropertyTable propertyTable; private EventPropertyTable eventTable; + private List widgetPropertyTables; + private FormDesigner designer; public static WidgetPropertyPane getInstance() { if (HOLDER.singleton == null) { @@ -33,14 +37,14 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper } public static WidgetPropertyPane getInstance(FormDesigner formEditor) { - HOLDER.singleton.setEditingFormDesigner(formEditor); - HOLDER.singleton.refreshDockingView(); - return HOLDER.singleton; - } + HOLDER.singleton.setEditingFormDesigner(formEditor); + HOLDER.singleton.refreshDockingView(); + return HOLDER.singleton; + } + - private static class HOLDER { - private static WidgetPropertyPane singleton = new WidgetPropertyPane(); + private static WidgetPropertyPane singleton = new WidgetPropertyPane(); } private WidgetPropertyPane() { @@ -58,13 +62,14 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper } @Override - public void refreshDockingView() { - FormDesigner designer = this.getEditingFormDesigner(); - removeAll(); - if(designer == null){ - clearDockingView(); - return; - } + public void refreshDockingView() { + designer = this.getEditingFormDesigner(); + removeAll(); + if (designer == null) { + clearDockingView(); + return; + } + widgetPropertyTables = new ArrayList(); propertyTable = new WidgetPropertyTable(designer); designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable)); propertyTable.setBorder(null); @@ -76,79 +81,95 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper UIScrollPane esp = new UIScrollPane(eventTable); esp.setBorder(null); // JTabbedPane tabbedPane = new JTabbedPane(); - UITabbedPane tabbedPane = new UITabbedPane(); + UITabbedPane tabbedPane = new UITabbedPane(); tabbedPane.setOpaque(true); tabbedPane.setBorder(null); tabbedPane.setTabPlacement(SwingConstants.BOTTOM); tabbedPane.addTab(Inter.getLocText("Form-Properties"), psp); tabbedPane.addTab(Inter.getLocText("Form-Events"), esp); + + WidgetAttrProvider[] widgetAttrProviders = ExtraDesignClassManager.getInstance().getWidgetAttrProviders(); + for (WidgetAttrProvider widgetAttrProvider : widgetAttrProviders) { + AbstractPropertyTable propertyTable = widgetAttrProvider.createWidgetAttrTable(); + widgetPropertyTables.add(propertyTable); + designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable)); + UIScrollPane uiScrollPane = new UIScrollPane(propertyTable); + uiScrollPane.setBorder(null); + tabbedPane.addTab(widgetAttrProvider.tableTitle(), uiScrollPane); + } add(tabbedPane, BorderLayout.CENTER); - - propertyTable.initPropertyGroups(null); - eventTable.refresh(); + + propertyTable.initPropertyGroups(null); + eventTable.refresh(); + for (AbstractPropertyTable propertyTable : widgetPropertyTables) { + propertyTable.initPropertyGroups(designer); + } } - public void setEditingFormDesigner(BaseFormDesigner editor) { - FormDesigner fd = (FormDesigner)editor; - super.setEditingFormDesigner(fd); - } + public void setEditingFormDesigner(BaseFormDesigner editor) { + FormDesigner fd = (FormDesigner) editor; + super.setEditingFormDesigner(fd); + } public void clearDockingView() { propertyTable = null; eventTable = null; + if (widgetPropertyTables != null) { + widgetPropertyTables.clear(); + } JScrollPane psp = new JScrollPane(); psp.setBorder(null); this.add(psp, BorderLayout.CENTER); } - public class WidgetPropertyDesignerAdapter implements DesignerEditListener { - AbstractPropertyTable propertyTable; - - public WidgetPropertyDesignerAdapter(AbstractPropertyTable propertyTable) { - this.propertyTable = propertyTable; - } - - @Override - public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { - propertyTable.initPropertyGroups(null); - } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) { - repaint(); - } - } - - @Override - public boolean equals(Object o) { - return o instanceof WidgetPropertyDesignerAdapter; - } - } - - public class EventPropertyDesignerAdapter implements DesignerEditListener { - EventPropertyTable propertyTable; - - public EventPropertyDesignerAdapter(EventPropertyTable eventTable) { - this.propertyTable = eventTable; - } - - @Override - public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { - propertyTable.refresh(); - } - } - - @Override - public boolean equals(Object o) { - return o instanceof EventPropertyDesignerAdapter; - } - } - + public class WidgetPropertyDesignerAdapter implements DesignerEditListener { + AbstractPropertyTable propertyTable; + + public WidgetPropertyDesignerAdapter(AbstractPropertyTable propertyTable) { + this.propertyTable = propertyTable; + } + + @Override + public void fireCreatorModified(DesignerEvent evt) { + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED + || evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED + || evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { + propertyTable.initPropertyGroups(designer); + } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) { + repaint(); + } + } + + @Override + public boolean equals(Object o) { + return o instanceof WidgetPropertyDesignerAdapter && ((WidgetPropertyDesignerAdapter) o).propertyTable == this.propertyTable; + } + } + + public class EventPropertyDesignerAdapter implements DesignerEditListener { + EventPropertyTable propertyTable; + + public EventPropertyDesignerAdapter(EventPropertyTable eventTable) { + this.propertyTable = eventTable; + } + + @Override + public void fireCreatorModified(DesignerEvent evt) { + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED + || evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED + || evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { + propertyTable.refresh(); + } + } + + @Override + public boolean equals(Object o) { + return o instanceof EventPropertyDesignerAdapter; + } + } + @Override public Location preferredLocation() { - return Location.WEST_BELOW; + return Location.WEST_BELOW; } } \ No newline at end of file