Browse Source

Merge pull request #387 in BA/design from ~XIAOXIA/design:dev to dev

* commit 'a24081dc3113edc444795b372dabdc5dd7cea269':
  rt
  rt
  rt
  rt
  rt
  rt
  rt
  rt
  rt
  rt
  控件树放到下拉框
  修改设计器布局
  rt
  rt
  修改一下控件
master
superman 8 years ago
parent
commit
f3c89103df
  1. BIN
      designer_form/src/com/fr/design/form/images/download.png
  2. 36
      designer_form/src/com/fr/design/mainframe/ComponentTree.java
  3. 316
      designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java
  4. 175
      designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java
  5. 14
      designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java
  6. 11
      designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java
  7. 145
      designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java
  8. 9
      designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java
  9. 4
      designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java

BIN
designer_form/src/com/fr/design/form/images/download.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 B

36
designer_form/src/com/fr/design/mainframe/ComponentTree.java

@ -36,11 +36,8 @@ public class ComponentTree extends JTree {
this.setDropMode(DropMode.ON_OR_INSERT);
this.setTransferHandler(new TreeTransferHandler());
this.refreshTreeRoot();
TreePath[] paths = getSelectedTreePath();
addTreeSelectionListener(designer);
setSelectionPaths(paths);
designer.addDesignerEditListener(new TreeDesignerEditAdapter());
this.addMouseListener(new MouseAdapter() {
@Override
@ -159,40 +156,7 @@ public class ComponentTree extends JTree {
return paths;
}
private class TreeDesignerEditAdapter implements DesignerEditListener {
@Override
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) {
TreePath[] paths = getSelectedTreePath();
if (paths.length == 1) {
setAndScrollSelectionPath(paths[0]);
} else {
setSelectionPaths(paths);
}
} else if(evt.getCreatorEventID() == DesignerEvent.CREATOR_PASTED) {
ComponentTree.this.refreshUI();
TreePath[] paths = getSelectedTreePath();
if (paths.length == 1) {
setAndScrollSelectionPath(paths[0]);
} else {
setSelectionPaths(paths);
}
ComponentTree.this.repaint();
} else {
ComponentTree.this.refreshUI();
ComponentTree.this.repaint();
}
}
@Override
public boolean equals(Object o) {
return o.getClass() == this.getClass();
}
}
/**

316
designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java

@ -1,12 +1,14 @@
package com.fr.design.mainframe;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.*;
import java.awt.event.ActionEvent;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import com.fr.design.actions.community.NeedAction;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.widget.UITreeComboBox;
import com.fr.design.parameter.HierarchyTreePane;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWParameterLayout;
@ -43,11 +45,13 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
public static final int NODE_LENGTH = 2;
public static final int PARA = 0;
public static final int BODY = 1;
private ComponentTree componentTree;
private UITreeComboBox treeComboBox;
private JPanel widgetPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
// richer:搜寻树节点的的文本框
private UITextField searchTextField;
private SearchResultPane searchResult;
// private UITextField searchTextField;
// private SearchResultPane searchResult;
public static FormHierarchyTreePane getInstance() {
return HOLDER.singleton;
@ -64,7 +68,7 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
}
private FormHierarchyTreePane() {
setLayout(new BorderLayout(0, 6));
setLayout(new BorderLayout(0, 0));
}
@Override
@ -86,8 +90,8 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
*/
public void clearDockingView() {
this.componentTree = null;
this.searchTextField = null;
this.searchResult = null;
// this.searchTextField = null;
// this.searchResult = null;
add(new JScrollPane(), BorderLayout.CENTER);
}
@ -103,53 +107,65 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
return;
}
componentTree = new ComponentTree(formDesigner);
ComponentTreeModel treeModel = (ComponentTreeModel) componentTree.getModel();
XCreator root = (XCreator)treeModel.getRoot();
int childCount = treeModel.getChildCount(root);
//按照节点添加para在下的,但这里需要para节点在上,调整一下位置
if(childCount == NODE_LENGTH){
adjustPosition(treeModel,formDesigner);
adjustPosition(treeModel, formDesigner);
}
widgetPane.setBorder(BorderFactory.createEmptyBorder(3, 2, 3, 0));
add(widgetPane, BorderLayout.NORTH);
if(treeComboBox == null) {
widgetPane.add(new UILabel(Inter.getLocText("FR-Designer-Selected_Widget") + " ",
SwingConstants.HORIZONTAL), BorderLayout.WEST);
treeComboBox = new UITreeComboBox(componentTree);
widgetPane.add(treeComboBox, BorderLayout.CENTER);
add(widgetPane, BorderLayout.CENTER);
}
UIScrollPane scrollPane = new UIScrollPane(componentTree);
scrollPane.setBorder(null);
add(scrollPane, BorderLayout.CENTER);
JPanel searchPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
add(searchPane, BorderLayout.NORTH);
searchPane.add(new UILabel(Inter.getLocText("FR-Designer_Search") + ":",
SwingConstants.HORIZONTAL), BorderLayout.WEST);
searchTextField = new UITextField();
searchPane.add(searchTextField, BorderLayout.CENTER);
searchTextField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
search();
}
@Override
public void removeUpdate(DocumentEvent e) {
search();
}
@Override
public void changedUpdate(DocumentEvent e) {
search();
}
private void search() {
String text = searchTextField.getText();
if (StringUtils.isEmpty(text)) {
removeSearchResult();
} else {
populate(componentTree.search(text));
}
}
});
// UIScrollPane scrollPane = new UIScrollPane(componentTree);
// scrollPane.setBorder(null);
// add(scrollPane, BorderLayout.CENTER);
// JPanel searchPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
// add(searchPane, BorderLayout.NORTH);
// searchPane.add(new UILabel(Inter.getLocText("FR-Designer_Search") + ":",
// SwingConstants.HORIZONTAL), BorderLayout.WEST);
// searchTextField = new UITextField();
// searchPane.add(searchTextField, BorderLayout.CENTER);
// searchTextField.getDocument().addDocumentListener(new DocumentListener() {
// @Override
// public void insertUpdate(DocumentEvent e) {
// search();
// }
//
// @Override
// public void removeUpdate(DocumentEvent e) {
// search();
// }
//
// @Override
// public void changedUpdate(DocumentEvent e) {
// search();
// }
//
// private void search() {
// String text = searchTextField.getText();
// if (StringUtils.isEmpty(text)) {
// removeSearchResult();
// } else {
// populate(componentTree.search(text));
// }
// }
// });
}
/**
* 调整结构树para和body的位置
*
*
* @param treeModel
* @param formDesigner
*/
@ -176,114 +192,114 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree
/**
* 删除搜索结果
*/
public void removeSearchResult() {
componentTree.setSelectionPath(null);
if (searchResult != null) {
this.remove(searchResult);
}
}
public void populate(TreePath[] treepath) {
if (this.searchResult == null) {
searchResult = new SearchResultPane();
}
if (((BorderLayout) getLayout()).getLayoutComponent(BorderLayout.SOUTH) == null) {
add(searchResult, BorderLayout.SOUTH);
}
searchResult.populate(treepath);
}
private class SearchResultPane extends JPanel {
private UILabel resultLabel = new UILabel();
private BackAction backAction = new BackAction();
private ForWardAction forwardAction = new ForWardAction();
private TreePath[] tree;
private int number = 0;
SearchResultPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel actionJPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane();
addButtonToJPanel(actionJPanel, backAction.createToolBarComponent());
addButtonToJPanel(actionJPanel, forwardAction.createToolBarComponent());
this.add(actionJPanel, BorderLayout.EAST);
this.add(resultLabel, BorderLayout.WEST);
}
private void addButtonToJPanel(JPanel actionLabel,
JComponent toolBarComponent) {
actionLabel.add(toolBarComponent);
if (toolBarComponent instanceof UIButton) {
toolBarComponent.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}
}
public void populate(TreePath[] search) {
tree = search;
resultLabel.setText(Inter.getLocText("FR-Designer_Total") + ":" + tree.length);
number = 0;
check();
}
public void next() {
if (number < tree.length - 1) {
componentTree.setAndScrollSelectionPath(tree[++number]);
}
check();
}
public void last() {
if (number > 0) {
componentTree.setAndScrollSelectionPath(tree[--number]);
}
check();
}
public void check() {
if (tree.length < 1) {
backAction.setEnabled(false);
forwardAction.setEnabled(false);
} else {
backAction.setEnabled(number > 0);
forwardAction.setEnabled(number < tree.length - 1);
}
}
}
private class BackAction extends UpdateAction {
public BackAction() {
this.setName(Inter.getLocText("Form-Hierarchy_Tree_Last"));
this.setSmallIcon(BaseUtils
.readIcon("com/fr/design/images/m_help/back.png"));
this.setEnabled(false);
}
public void actionPerformed(ActionEvent e) {
searchResult.last();
}
}
private class ForWardAction extends UpdateAction {
public ForWardAction() {
this.setName(Inter.getLocText("Form-Hierarchy_Tree_Next"));
this.setSmallIcon(BaseUtils
.readIcon("com/fr/design/images/m_help/forward.png"));
this.setEnabled(false);
}
public void actionPerformed(ActionEvent e) {
searchResult.next();
}
}
// public void removeSearchResult() {
// componentTree.setSelectionPath(null);
// if (searchResult != null) {
// this.remove(searchResult);
// }
// }
//
// public void populate(TreePath[] treepath) {
// if (this.searchResult == null) {
// searchResult = new SearchResultPane();
// }
// if (((BorderLayout) getLayout()).getLayoutComponent(BorderLayout.SOUTH) == null) {
// add(searchResult, BorderLayout.SOUTH);
// }
// searchResult.populate(treepath);
// }
// private class SearchResultPane extends JPanel {
// private UILabel resultLabel = new UILabel();
// private BackAction backAction = new BackAction();
// private ForWardAction forwardAction = new ForWardAction();
// private TreePath[] tree;
// private int number = 0;
//
// SearchResultPane() {
// this.setLayout(FRGUIPaneFactory.createBorderLayout());
// JPanel actionJPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane();
// addButtonToJPanel(actionJPanel, backAction.createToolBarComponent());
// addButtonToJPanel(actionJPanel, forwardAction.createToolBarComponent());
//
// this.add(actionJPanel, BorderLayout.EAST);
// this.add(resultLabel, BorderLayout.WEST);
// }
//
// private void addButtonToJPanel(JPanel actionLabel,
// JComponent toolBarComponent) {
// actionLabel.add(toolBarComponent);
// if (toolBarComponent instanceof UIButton) {
// toolBarComponent.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
// }
// }
//
// public void populate(TreePath[] search) {
// tree = search;
// resultLabel.setText(Inter.getLocText("FR-Designer_Total") + ":" + tree.length);
// number = 0;
// check();
// }
//
// public void next() {
// if (number < tree.length - 1) {
// componentTree.setAndScrollSelectionPath(tree[++number]);
// }
// check();
// }
//
// public void last() {
// if (number > 0) {
// componentTree.setAndScrollSelectionPath(tree[--number]);
// }
// check();
// }
//
// public void check() {
// if (tree.length < 1) {
// backAction.setEnabled(false);
// forwardAction.setEnabled(false);
// } else {
// backAction.setEnabled(number > 0);
// forwardAction.setEnabled(number < tree.length - 1);
// }
//
// }
//}
// private class BackAction extends UpdateAction {
//
// public BackAction() {
// this.setName(Inter.getLocText("Form-Hierarchy_Tree_Last"));
// this.setSmallIcon(BaseUtils
// .readIcon("com/fr/design/images/m_help/back.png"));
// this.setEnabled(false);
// }
//
// public void actionPerformed(ActionEvent e) {
// searchResult.last();
// }
// }
//
// private class ForWardAction extends UpdateAction {
//
// public ForWardAction() {
// this.setName(Inter.getLocText("Form-Hierarchy_Tree_Next"));
// this.setSmallIcon(BaseUtils
// .readIcon("com/fr/design/images/m_help/forward.png"));
// this.setEnabled(false);
// }
//
// public void actionPerformed(ActionEvent e) {
// searchResult.next();
// }
// }
@Override
/**
* 位置
*
*
* @return 位置
*/
public Location preferredLocation() {

175
designer_form/src/com/fr/design/mainframe/FormWidgetDetailPane.java

@ -1,28 +1,24 @@
package com.fr.design.mainframe;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.*;
import java.util.List;
import javax.swing.*;
import javax.swing.border.LineBorder;
import com.fr.base.BaseUtils;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.parameter.ParameterPropertyPane;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.form.share.ShareConstants;
import com.fr.form.share.ShareLoader;
import com.fr.form.ui.ElCaseBindInfo;
import com.fr.general.Inter;
/**
@ -32,16 +28,12 @@ import com.fr.general.Inter;
* Time: 下午8:18
*/
public class FormWidgetDetailPane extends FormDockView{
public static final String PARA = "para";
public static final String BODY = "body";
private UITabbedPane tabbedPane;
private ParameterPropertyPane parameterPropertyPane;
private MobileWidgetTable mobileWidgetTable;
private MobileBodyWidgetTable mobileBodyWidgetTable;
private UIScrollPane downPanel;
private JPanel centerPane;
private CardLayout cardLayout;
private JScrollPane downPanel;
private JPanel reuWidgetPanel;
private UIComboBox comboBox;
private ElCaseBindInfo[] elCaseBindInfoList;
public static FormWidgetDetailPane getInstance() {
if (HOLDER.singleton == null) {
@ -84,100 +76,101 @@ public class FormWidgetDetailPane extends FormDockView{
clearDockingView();
return;
}
parameterPropertyPane = ParameterPropertyPane.getInstance(designer);
parameterPropertyPane.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
JPanel esp = FRGUIPaneFactory.createBorderLayout_S_Pane();
esp.setBorder(null);
mobileWidgetTable = new MobileWidgetTable(designer);
mobileBodyWidgetTable = new MobileBodyWidgetTable(designer);
designer.addDesignerEditListener(new mobileWidgetDesignerAdapter());
centerPane = FRGUIPaneFactory.createCardLayout_S_Pane();
cardLayout = (CardLayout) centerPane.getLayout();
centerPane.add(mobileWidgetTable,PARA);
centerPane.add(mobileBodyWidgetTable,BODY);
if(hasSelectParaPane(designer)){
cardLayout.show(centerPane,PARA);
} else {
cardLayout.show(centerPane,BODY);
if (elCaseBindInfoList == null) {
elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList();
}
downPanel = new UIScrollPane(centerPane);
downPanel.setBorder(new LineBorder(Color.gray));
esp.add(downPanel,BorderLayout.CENTER);
UILabel upLabel = new UILabel(Inter.getLocText("FR-Widget_Mobile_Table"),SwingConstants.CENTER);
upLabel.setBorder(BorderFactory.createEmptyBorder(6,0,6,0));
esp.add(upLabel,BorderLayout.NORTH);
initReuWidgetPanel();
esp.add(reuWidgetPanel, BorderLayout.CENTER);
UIButton button = new UIButton();
button.setIcon(BaseUtils.readIcon("/com/fr/design/form/images/download.png"));
button.set4ToolbarButton();
JPanel widgetPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
widgetPane.setBorder(BorderFactory.createEmptyBorder(3, 10, 3, 3));
widgetPane.add(new UILabel(Inter.getLocText("FR-Designer_LocalWidget"),
SwingConstants.HORIZONTAL), BorderLayout.WEST);
widgetPane.add(button, BorderLayout.EAST);
esp.add(widgetPane,BorderLayout.NORTH);
tabbedPane = new UITabbedPane();
tabbedPane.setOpaque(true);
tabbedPane.setBorder(null);
tabbedPane.setTabPlacement(SwingConstants.BOTTOM);
tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Tree"), parameterPropertyPane);
tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Terminal"), esp);
tabbedPane.addTab(Inter.getLocText("FR-Engine_Report"), esp);
tabbedPane.addTab(Inter.getLocText("FR-Designer-Form-ToolBar_Chart"), new JPanel());
add(tabbedPane, BorderLayout.CENTER);
}
/**
* 初始化组件共享和复用面板
*/
private void initReuWidgetPanel() {
int rowCount = (elCaseBindInfoList.length + 1)/2;
downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList));
downPanel.setPreferredSize(new Dimension(236, rowCount * 82));
reuWidgetPanel = FRGUIPaneFactory.createCenterFlowInnerContainer_S_Pane();
comboBox = new UIComboBox(getCategories());
comboBox.setPreferredSize(new Dimension(236, 30));
initComboBoxSelectedListener();
reuWidgetPanel.add(comboBox, BorderLayout.NORTH);
reuWidgetPanel.add(downPanel, BorderLayout.CENTER);
reuWidgetPanel.setBorder(new LineBorder(Color.gray));
}
private void initComboBoxSelectedListener() {
comboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
int filterIndex = comboBox.getSelectedIndex();
if (filterIndex == 0) {
elCaseBindInfoList = ShareLoader.getLoader().getAllBindInfoList();
} else {
String filterName = (String) e.getItem();
elCaseBindInfoList = ShareLoader.getLoader().getFilterBindInfoList(filterName);
}
refreshDownPanel();
}
});
}
public String[] getCategories() {
return ShareConstants.WIDGET_CATEGORIES;
}
public void refreshDownPanel() {
reuWidgetPanel.remove(downPanel);
downPanel = new UIScrollPane(new ShareWidgetPane(elCaseBindInfoList));
//todo:这个地方有问题
reuWidgetPanel.add(downPanel);
repaintContainer();
}
public void repaintContainer() {
validate();
repaint();
revalidate();
}
public void setSelectedIndex(int index){
tabbedPane.setSelectedIndex(index);
}
/**
* 选中的组件是否在参数面板里
* @param designer 设计器
* @return 是则返回true
*/
public boolean hasSelectParaPane(FormDesigner designer){
XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if(xCreator == null){
xCreator = designer.getRootComponent();
}
XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator);
return xCreator.acceptType(XWParameterLayout.class) || container.acceptType(XWParameterLayout.class);
}
/**
* 清除数据
*/
public void clearDockingView() {
parameterPropertyPane = null;
mobileWidgetTable = null;
JScrollPane psp = new JScrollPane();
psp.setBorder(null);
this.add(psp, BorderLayout.CENTER);
}
public class mobileWidgetDesignerAdapter implements DesignerEditListener {
public mobileWidgetDesignerAdapter() {
}
/**
* 响应界面改变事件
* @param evt 事件
*/
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_ADDED) {
int value = downPanel.getVerticalScrollBar().getValue();
if(hasSelectParaPane(getEditingFormDesigner())){
cardLayout.show(centerPane,PARA);
mobileWidgetTable.refresh();
} else {
cardLayout.show(centerPane,BODY);
mobileBodyWidgetTable.refresh();
}
//出现滚动条
downPanel.doLayout();
//控件列表选中某组件,触发表单中选中控件,选中事件又触发列表刷新,滚动条回到0
//此处设置滚动条值为刷新前
downPanel.getVerticalScrollBar().setValue(value);
}
}
}
/**
* 定位

14
designer_form/src/com/fr/design/mainframe/ShareWidgetButton.java

@ -46,16 +46,16 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot
private void initUI() {
this.setBackground(Color.WHITE);
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
setPreferredSize(new Dimension(110, 70));
setPreferredSize(new Dimension(108, 72));
setLayout(FRGUIPaneFactory.createBorderLayout());
ImagePanel imagePanel = new ImagePanel((BufferedImage) bindInfo.getCover());
imagePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
this.add(imagePanel, BorderLayout.NORTH);
JPanel panel = new JPanel();
UILabel label = new UILabel(bindInfo.getName(), SwingConstants.HORIZONTAL);
panel.setBackground(new Color(184, 220, 242));
panel.add(label);
this.add(panel, BorderLayout.SOUTH);
label.setOpaque(true);
label.setBackground(new Color(184, 220, 242));
this.add(label, BorderLayout.SOUTH);
}
private class ImagePanel extends JPanel {
@ -64,12 +64,12 @@ public class ShareWidgetButton extends JPanel implements MouseListener, MouseMot
public ImagePanel(BufferedImage image) {
this.image = image;
this.setPreferredSize(new Dimension(110, 50));
this.setPreferredSize(new Dimension(108, 52));
}
@Override
public void paintComponent(Graphics g) {
g.drawImage(image, 0, 0, 110, 70, null);
g.drawImage(image, 0, 0, null);
}
}

11
designer_form/src/com/fr/design/mainframe/ShareWidgetPane.java

@ -6,24 +6,27 @@ import com.fr.form.ui.ElCaseBindInfo;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.*;
import java.util.List;
/**
* Created by xiaxiang on 2016/10/10.
*/
public class ShareWidgetPane extends JPanel {
public ShareWidgetPane(ArrayList<ElCaseBindInfo> elCaseBindInfoList) {
public ShareWidgetPane(ElCaseBindInfo[] elCaseBindInfoList) {
this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));// 设置面板的边框 ,距离上、左、下、右 的距离
int rowCount = (elCaseBindInfoList.size() + 1)/2;
int rowCount = (elCaseBindInfoList.length + 1)/2;
this.setLayout(new GridLayout(rowCount, 2, 10, 10));
for (ElCaseBindInfo rbModuleInfo : elCaseBindInfoList) {
ShareWidgetButton widgetButton = new ShareWidgetButton(rbModuleInfo);
this.add(widgetButton);
}
if (elCaseBindInfoList.size() == 1) {
if (elCaseBindInfoList.length == 1) {
this.add(new JPanel());
}
}
}

145
designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

@ -4,17 +4,26 @@ import com.fr.base.BaseUtils;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.designer.beans.events.DesignerEditListener;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.designer.properties.EventPropertyTable;
import com.fr.design.designer.properties.WidgetPropertyTable;
import com.fr.design.designer.treeview.ComponentTreeModel;
import com.fr.design.fun.WidgetPropertyUIProvider;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.AbstractPropertyTable;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.parameter.ParameterPropertyPane;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import javax.swing.*;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
@ -29,6 +38,18 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
private EventPropertyTable eventTable;
private List<AbstractPropertyTable> widgetPropertyTables;
private FormDesigner designer;
private ComponentTree componentTree;
private JPanel wsp;
private ParameterPropertyPane parameterPropertyPane;
private MobileWidgetTable mobileWidgetTable;
private MobileBodyWidgetTable mobileBodyWidgetTable;
private UIScrollPane downPanel;
private JPanel centerPane;
private CardLayout cardLayout;
public static final String PARA = "para";
public static final String BODY = "body";
public static final int NODE_LENGTH = 2;
public boolean isrefresh = true;
public static WidgetPropertyPane getInstance() {
if (HOLDER.singleton == null) {
@ -52,6 +73,37 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
setLayout(FRGUIPaneFactory.createBorderLayout());
}
public class mobileWidgetDesignerAdapter implements DesignerEditListener {
public mobileWidgetDesignerAdapter() {
}
/**
* 响应界面改变事件
* @param evt 事件
*/
public void fireCreatorModified(DesignerEvent evt) {
if (evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED
|| evt.getCreatorEventID() == DesignerEvent.CREATOR_ADDED) {
int value = downPanel.getVerticalScrollBar().getValue();
if(hasSelectParaPane(getEditingFormDesigner())){
cardLayout.show(centerPane,PARA);
mobileWidgetTable.refresh();
} else {
cardLayout.show(centerPane,BODY);
mobileBodyWidgetTable.refresh();
}
//出现滚动条
downPanel.doLayout();
//控件列表选中某组件,触发表单中选中控件,选中事件又触发列表刷新,滚动条回到0
//此处设置滚动条值为刷新前
downPanel.getVerticalScrollBar().setValue(value);
}
}
}
@Override
public String getViewTitle() {
return Inter.getLocText("Form-Widget_Property_Table");
@ -64,12 +116,24 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
@Override
public void refreshDockingView() {
designer = this.getEditingFormDesigner();
removeAll();
if (designer == null) {
clearDockingView();
return;
}
componentTree = new ComponentTree(designer);
ComponentTreeModel treeModel = (ComponentTreeModel) componentTree.getModel();
XCreator root = (XCreator)treeModel.getRoot();
int childCount = treeModel.getChildCount(root);
//按照节点添加para在下的,但这里需要para节点在上,调整一下位置
if(childCount == NODE_LENGTH){
adjustPosition(treeModel, designer);
}
widgetPropertyTables = new ArrayList<AbstractPropertyTable>();
propertyTable = new WidgetPropertyTable(designer);
designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable));
@ -81,30 +145,93 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
eventTable.setBorder(null);
UIScrollPane esp = new UIScrollPane(eventTable);
esp.setBorder(null);
// JTabbedPane tabbedPane = new JTabbedPane();
wsp = FRGUIPaneFactory.createBorderLayout_S_Pane();
wsp.setBorder(null);
mobileWidgetTable = new MobileWidgetTable(designer);
mobileBodyWidgetTable = new MobileBodyWidgetTable(designer);
designer.addDesignerEditListener(new mobileWidgetDesignerAdapter());
centerPane = FRGUIPaneFactory.createCardLayout_S_Pane();
cardLayout = (CardLayout) centerPane.getLayout();
centerPane.add(mobileWidgetTable,PARA);
centerPane.add(mobileBodyWidgetTable,BODY);
if(hasSelectParaPane(designer)){
cardLayout.show(centerPane,PARA);
} else {
cardLayout.show(centerPane,BODY);
}
downPanel = new UIScrollPane(centerPane);
downPanel.setBorder(new LineBorder(Color.gray));
wsp.add(downPanel,BorderLayout.CENTER);
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);
tabbedPane.addTab(Inter.getLocText("FR-Widget_Mobile_Terminal"), wsp);
WidgetPropertyUIProvider[] widgetAttrProviders = getExtraPropertyUIProviders();
for (WidgetPropertyUIProvider 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);
if (widgetAttrProviders.length == 0) {
UILabel upLabel = new UILabel(Inter.getLocText("FR-Widget_Mobile_Table"),SwingConstants.CENTER);
upLabel.setBorder(BorderFactory.createEmptyBorder(6,0,6,0));
wsp.add(upLabel,BorderLayout.NORTH);
} else {
for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) {
AbstractPropertyTable propertyTable = widgetAttrProvider.createWidgetAttrTable();
widgetPropertyTables.add(propertyTable);
designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(propertyTable));
UIScrollPane uiScrollPane = new UIScrollPane(propertyTable);
uiScrollPane.setBorder(null);
wsp.add(uiScrollPane);
}
}
add(tabbedPane, BorderLayout.CENTER);
parameterPropertyPane = ParameterPropertyPane.getInstance(designer);
parameterPropertyPane.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 4));
add(parameterPropertyPane, BorderLayout.NORTH);
add(tabbedPane, BorderLayout.CENTER);
propertyTable.initPropertyGroups(null);
eventTable.refresh();
for (AbstractPropertyTable propertyTable : widgetPropertyTables) {
propertyTable.initPropertyGroups(designer);
}
isrefresh = false;
}
/**
* 调整结构树para和body的位置
*
* @param treeModel
* @param formDesigner
*/
private void adjustPosition(ComponentTreeModel treeModel,FormDesigner formDesigner){
XCreator root = (XCreator)treeModel.getRoot();
if(treeModel.getChild(root,0) instanceof XWParameterLayout){
return;
}
root.add((Component)(treeModel.getChild(root,0)),1);
treeModel.setRoot(root);
componentTree = new ComponentTree(formDesigner,treeModel);
}
//
/**
* 选中的组件是否在参数面板里
* @param designer 设计器
* @return 是则返回true
*/
public boolean hasSelectParaPane(FormDesigner designer){
XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
if(xCreator == null){
xCreator = designer.getRootComponent();
}
XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator);
return xCreator.acceptType(XWParameterLayout.class) || container.acceptType(XWParameterLayout.class);
}
/**

9
designer_form/src/com/fr/design/mainframe/widget/UITreeComboBox.java

@ -107,14 +107,16 @@ public class UITreeComboBox extends JComboBox{
class UITreeComboBoxRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus){
if(value != null){
TreePath path = (TreePath)value;
if(tree != null ){
TreePath path = tree.getSelectedTreePath()[0];
tree.setAndScrollSelectionPath(path);
Object node = path.getLastPathComponent();
value = node;
TreeCellRenderer r = tree.getCellRenderer();
JLabel lb = (JLabel)r.getTreeCellRendererComponent(
tree, value, isSelected, false, false, index,
cellHasFocus);
return lb;
}
return super.getListCellRendererComponent(list, value, index,
@ -138,7 +140,8 @@ public class UITreeComboBox extends JComboBox{
setSelectedItem(paths[0]);
MenuSelectionManager.defaultManager().clearSelectedPath();
} else {
return;
tree.refreshUI();
repaint();
}
}

4
designer_form/src/com/fr/design/parameter/ParameterPropertyPane.java

@ -48,12 +48,12 @@ public class ParameterPropertyPane extends JPanel{
this.setLayout(new BorderLayout(0, 6));
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
this.add(toolbarPane, BorderLayout.NORTH);
this.add(toolbarPane, BorderLayout.CENTER);
}
private void setEditor(FormDesigner editor) {
this.remove(FormHierarchyTreePane.getInstance());
this.add(FormHierarchyTreePane.getInstance(editor), BorderLayout.CENTER);
this.add(FormHierarchyTreePane.getInstance(editor), BorderLayout.NORTH);
}
private void initParameterListener() {

Loading…
Cancel
Save