Browse Source

Merge pull request #61 in BA/design from ~VITO/design:store_bug to release

* commit '83a9bdf8dd3688ee3fce8096cf17f6ccb28bc162':
  去掉多余的import
  1、减小插件商店窗体高度 2、提醒插件升级的时候使用的框体改为新版插件商店的框体
  修复提示消息在页面背部的问题
  去掉多余的判断
  把set去掉
  命名更改
  控件自定义属性tab接口
  格式化
  menuhandler的equals方法会使带参数的shortcut不进行比较,改用AbstractProvider
master
richie 9 years ago
parent
commit
b5f0bf3efc
  1. 19
      designer_base/src/com/fr/design/ExtraDesignClassManager.java
  2. 36
      designer_base/src/com/fr/design/extra/PluginManagerPane.java
  3. 2
      designer_base/src/com/fr/design/extra/PluginShopDialog.java
  4. 16
      designer_base/src/com/fr/design/fun/MenuHandler.java
  5. 18
      designer_base/src/com/fr/design/fun/WidgetAttrProvider.java
  6. 34
      designer_base/src/com/fr/design/fun/impl/AbstractMenuHandler.java
  7. 21
      designer_base/src/com/fr/design/fun/impl/AbstractWidgetAttrProvider.java
  8. 7
      designer_base/src/com/fr/start/BaseDesigner.java
  9. 163
      designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

19
designer_base/src/com/fr/design/ExtraDesignClassManager.java

@ -130,6 +130,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi
private Set<ElementUIProvider> elementUIProviders;
private Set<WidgetAttrProvider> 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<WidgetAttrProvider>();
}
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());

36
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,

2
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);

16
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);
}

18
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();
}

34
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;
}
}

21
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();
}
}

7
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);
}
}

163
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<AbstractPropertyTable> 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<AbstractPropertyTable>();
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;
}
}
Loading…
Cancel
Save