Browse Source

控件自定义属性tab接口

master
vito 9 years ago
parent
commit
3d7e697de5
  1. 19
      designer_base/src/com/fr/design/ExtraDesignClassManager.java
  2. 18
      designer_base/src/com/fr/design/fun/WidgetCustomAttrProvider.java
  3. 21
      designer_base/src/com/fr/design/fun/impl/AbstractWidgetCustomAttrProvider.java
  4. 39
      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<WidgetCustomAttrProvider> widgetCustomAttrProviders;
public TableDataTreePaneProcessor getTableDataTreePaneProcessor() {
return tableDataTreePaneProcessor;
}
@ -736,6 +738,21 @@ public class ExtraDesignClassManager extends XMLFileManager implements ExtraDesi
elementUIProviders.add((ElementUIProvider) level);
}
public WidgetCustomAttrProvider[] getWidgetCustomAttrProviders() {
if (widgetCustomAttrProviders == null) {
return new WidgetCustomAttrProvider[0];
}
return widgetCustomAttrProviders.toArray(new WidgetCustomAttrProvider[widgetCustomAttrProviders.size()]);
}
public void addWidgetCustomAttrProvider(Level level, PluginSimplify simplify) throws Exception {
if (widgetCustomAttrProviders == null) {
widgetCustomAttrProviders = new HashSet<WidgetCustomAttrProvider>();
}
validAPILevel(level, WidgetCustomAttrProvider.CURRENT_LEVEL, simplify.getPluginName());
widgetCustomAttrProviders.add((WidgetCustomAttrProvider) 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(WidgetCustomAttrProvider.XML_TAG)) {
addWidgetCustomAttrProvider(impl, simplify);
}
} catch (PluginInvalidLevelException e) {
PluginMessage.remindUpdate(e.getMessage());

18
designer_base/src/com/fr/design/fun/WidgetCustomAttrProvider.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 WidgetCustomAttrProvider extends Level {
String XML_TAG = "WidgetCustomAttrProvider";
int CURRENT_LEVEL = 1;
AbstractPropertyTable createWidgetCustomAttrTable();
String setTableTitle();
}

21
designer_base/src/com/fr/design/fun/impl/AbstractWidgetCustomAttrProvider.java

@ -0,0 +1,21 @@
package com.fr.design.fun.impl;
import com.fr.design.fun.WidgetCustomAttrProvider;
import com.fr.stable.fun.impl.AbstractProvider;
/**
* Created by vito on 16/4/27.
*/
public abstract class AbstractWidgetCustomAttrProvider extends AbstractProvider implements WidgetCustomAttrProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return this.getClass().getName();
}
}

39
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.WidgetCustomAttrProvider;
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> customPropertyTables;
private FormDesigner designer;
public static WidgetPropertyPane getInstance() {
if (HOLDER.singleton == null) {
@ -59,12 +63,13 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
@Override
public void refreshDockingView() {
FormDesigner designer = this.getEditingFormDesigner();
designer = this.getEditingFormDesigner();
removeAll();
if(designer == null){
if (designer == null) {
clearDockingView();
return;
}
customPropertyTables = new ArrayList<AbstractPropertyTable>();
propertyTable = new WidgetPropertyTable(designer);
designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable));
propertyTable.setBorder(null);
@ -82,20 +87,38 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
tabbedPane.setTabPlacement(SwingConstants.BOTTOM);
tabbedPane.addTab(Inter.getLocText("Form-Properties"), psp);
tabbedPane.addTab(Inter.getLocText("Form-Events"), esp);
WidgetCustomAttrProvider[] customAttrProviders = ExtraDesignClassManager.getInstance().getWidgetCustomAttrProviders();
for (WidgetCustomAttrProvider customAttrProvider : customAttrProviders) {
AbstractPropertyTable propertyTable = customAttrProvider.createWidgetCustomAttrTable();
customPropertyTables.add(propertyTable);
designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable));
UIScrollPane uiScrollPane = new UIScrollPane(propertyTable);
uiScrollPane.setBorder(null);
tabbedPane.addTab(customAttrProvider.setTableTitle(), uiScrollPane);
}
add(tabbedPane, BorderLayout.CENTER);
propertyTable.initPropertyGroups(null);
eventTable.refresh();
if (customPropertyTables.size() > 0) {
for (AbstractPropertyTable propertyTable : customPropertyTables) {
propertyTable.initPropertyGroups(designer);
}
}
}
public void setEditingFormDesigner(BaseFormDesigner editor) {
FormDesigner fd = (FormDesigner)editor;
FormDesigner fd = (FormDesigner) editor;
super.setEditingFormDesigner(fd);
}
public void clearDockingView() {
propertyTable = null;
eventTable = null;
if (customPropertyTables != null) {
customPropertyTables.clear();
}
JScrollPane psp = new JScrollPane();
psp.setBorder(null);
this.add(psp, BorderLayout.CENTER);
@ -113,7 +136,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
propertyTable.initPropertyGroups(null);
propertyTable.initPropertyGroups(designer);
} else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) {
repaint();
}
@ -121,7 +144,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
@Override
public boolean equals(Object o) {
return o instanceof WidgetPropertyDesignerAdapter;
return o instanceof WidgetPropertyDesignerAdapter && ((WidgetPropertyDesignerAdapter) o).propertyTable == this.propertyTable;
}
}

Loading…
Cancel
Save