Browse Source

控件属性传递插件接口

master
zack 9 years ago
parent
commit
c55a0f68c9
  1. 17
      designer/src/com/fr/design/widget/WidgetPane.java
  2. 12
      designer_base/src/com/fr/design/ExtraDesignClassManager.java
  3. 22
      designer_base/src/com/fr/design/fun/WidgetDesignHandler.java
  4. 16
      designer_base/src/com/fr/design/fun/impl/AbstractWidgetDesignHandler.java

17
designer/src/com/fr/design/widget/WidgetPane.java

@ -1,6 +1,7 @@
package com.fr.design.widget;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.WidgetDesignHandler;
import com.fr.design.gui.core.WidgetOption;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
@ -30,6 +31,7 @@ public class WidgetPane extends BasicPane implements ItemListener {
private CellWidgetCardPane cellEditorCardPane;
private boolean shouldFireSelectedEvent;
protected JPanel northPane;
private Widget oldWidget;//记录一下上次编辑的插件
public WidgetPane() {
this(null);
@ -42,6 +44,14 @@ public class WidgetPane extends BasicPane implements ItemListener {
this.initComponents(pane);
}
public Widget getOldWidget() {
return oldWidget;
}
public void setOldWidget(Widget oldWidget) {
this.oldWidget = oldWidget;
}
protected void initComponents(ElementCasePane pane) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
@ -66,11 +76,17 @@ public class WidgetPane extends BasicPane implements ItemListener {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
if (e.getItem() instanceof Item && ((Item) e.getItem()).getValue() instanceof WidgetConfig) {
Widget newWidget = editorTypeComboBox.getCellWidget();
populate(editorTypeComboBox.getCellWidget());
return;
}
if (shouldFireSelectedEvent) {
Widget selectedItem = editorTypeComboBox.getCellWidget();
WidgetDesignHandler handler = ExtraDesignClassManager.getInstance().getWidgetDesignHandler();
if (handler != null) {
selectedItem = handler.dealWithWidget(getOldWidget(), selectedItem);
}
populateWidgetConfig(selectedItem);
}
}
@ -82,6 +98,7 @@ public class WidgetPane extends BasicPane implements ItemListener {
}
public void populate(Widget widget) {
setOldWidget(widget);
if (widget == null) {
widget = new TextEditor();
}

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

@ -132,6 +132,16 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi
private Set<WidgetAttrProvider> widgetAttrProviders;
private WidgetDesignHandler widgetDesignHandler;
public WidgetDesignHandler getWidgetDesignHandler() {
return widgetDesignHandler;
}
public void setWidgetDesignHandler(Level level, PluginSimplify simplify) throws Exception {
widgetDesignHandler = (WidgetDesignHandler) level;
}
public TableDataTreePaneProcessor getTableDataTreePaneProcessor() {
return tableDataTreePaneProcessor;
}
@ -847,6 +857,8 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi
addElementUIProvider(impl, simplify);
} else if (tagName.equals(WidgetAttrProvider.XML_TAG)) {
addWidgetAttrProvider(impl, simplify);
} else if (tagName.equals(WidgetDesignHandler.XML_TAG)) {
setWidgetDesignHandler(impl, simplify);
}
} catch (PluginInvalidLevelException e) {
PluginMessage.remindUpdate(e.getMessage());

22
designer_base/src/com/fr/design/fun/WidgetDesignHandler.java

@ -0,0 +1,22 @@
package com.fr.design.fun;
import com.fr.form.ui.Widget;
import com.fr.stable.fun.Level;
/**
* Coder: zack
* Date: 2016/5/12
* Time: 10:37
*/
public interface WidgetDesignHandler extends Level {
String XML_TAG = "WidgetDesignHandler";
int CURRENT_LEVEL = 1;
/**
* 控件设置的时候对原控件和新控件的一些特殊处理比如属性的传递默认属性的设置等
*
* @param oldWidget 老控件
* @param newWidget 新控件
* @return 处理后的控件
*/
Widget dealWithWidget(Widget oldWidget, Widget newWidget);
}

16
designer_base/src/com/fr/design/fun/impl/AbstractWidgetDesignHandler.java

@ -0,0 +1,16 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.WidgetDesignHandler;
import com.fr.form.ui.Widget;
/**
* Coder: zack
* Date: 2016/5/12
* Time: 10:41
*/
public abstract class AbstractWidgetDesignHandler implements WidgetDesignHandler {
@Override
public Widget dealWithWidget(Widget oldWidget, Widget newWidget) {
return newWidget;
}
}
Loading…
Cancel
Save