Browse Source

Merge pull request #58 in BA/design from ~VITO/design:dev to dev

* commit '3fd1072b476a281f460a712902d42039cecd537f':
  去掉多余的判断
  把set去掉
  命名更改
  控件自定义属性tab接口
master
richie 9 years ago
parent
commit
caea50c68e
  1. 19
      designer_base/src/com/fr/design/ExtraDesignClassManager.java
  2. 18
      designer_base/src/com/fr/design/fun/WidgetAttrProvider.java
  3. 21
      designer_base/src/com/fr/design/fun/impl/AbstractWidgetAttrProvider.java
  4. 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());

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

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

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