|
|
|
@ -17,7 +17,6 @@ import com.fr.plugin.event.manager.ui.tree.MyComponentTree;
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.JSplitPane; |
|
|
|
|
import javax.swing.ScrollPaneConstants; |
|
|
|
|
import javax.swing.SwingConstants; |
|
|
|
|
import javax.swing.event.TreeSelectionEvent; |
|
|
|
|
import javax.swing.event.TreeSelectionListener; |
|
|
|
@ -25,16 +24,22 @@ import java.awt.BorderLayout;
|
|
|
|
|
import java.awt.Component; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 事件配置面板,左边为组件树,右边为无/事件编辑面板 |
|
|
|
|
* 事件配置面板,左边为组件树,右边为空提示/事件编辑面板 |
|
|
|
|
* @author Joe |
|
|
|
|
* Created by Joe on 12/11/2020 |
|
|
|
|
*/ |
|
|
|
|
public class EventConfigPane extends BasicPane implements TreeSelectionListener { |
|
|
|
|
private MyTree tree; |
|
|
|
|
|
|
|
|
|
// lastNode用来保存最新一个操作过的树节点
|
|
|
|
|
private MyTree lastNode; |
|
|
|
|
private boolean rootVisible; |
|
|
|
|
|
|
|
|
|
//事件属性容器
|
|
|
|
|
private MyComponentTree componentTree; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 事件编辑容器 |
|
|
|
|
*/ |
|
|
|
|
private JPanel rightPane; |
|
|
|
|
private WidgetEventPane eventPane; |
|
|
|
|
private UILabel emptyLabel; |
|
|
|
@ -65,29 +70,47 @@ public class EventConfigPane extends BasicPane implements TreeSelectionListener
|
|
|
|
|
this.rootVisible = rootVisible; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 初始化面板 |
|
|
|
|
*/ |
|
|
|
|
private void initComponentPane() { |
|
|
|
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
this.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8)); |
|
|
|
|
setLayout(FRGUIPaneFactory.createBorderLayout()); |
|
|
|
|
setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8)); |
|
|
|
|
initRightPane(); |
|
|
|
|
// SplitPane
|
|
|
|
|
// 增加边框
|
|
|
|
|
JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), rightPane); |
|
|
|
|
mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor())); |
|
|
|
|
mainSplitPane.setOneTouchExpandable(true); |
|
|
|
|
|
|
|
|
|
this.add(mainSplitPane, BorderLayout.CENTER); |
|
|
|
|
add(mainSplitPane, BorderLayout.CENTER); |
|
|
|
|
mainSplitPane.setDividerLocation(180); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 当切换sheet/tab时触发,更新组件树,右边为默认的空提示 |
|
|
|
|
*/ |
|
|
|
|
public void refreshUI() { |
|
|
|
|
componentTree.refreshTree(); |
|
|
|
|
refreshRightPane(emptyLabel); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 初始化右边的面板,默认是一个空提示 |
|
|
|
|
*/ |
|
|
|
|
private void initRightPane() { |
|
|
|
|
rightPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
eventPane = new WidgetEventPaneNoPop(null); |
|
|
|
|
eventPane.setBorder(BorderFactory.createEmptyBorder()); |
|
|
|
|
emptyLabel = new UILabel("当前组件没有设置过事件"); |
|
|
|
|
emptyLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Plugin_Event_Manager_Config_Right_Tip")); |
|
|
|
|
emptyLabel.setHorizontalAlignment(SwingConstants.CENTER); |
|
|
|
|
rightPane.add(emptyLabel, BorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 刷新右边的面板,可能生成一个空提示,也可能生成一个事件编辑面板 |
|
|
|
|
* |
|
|
|
|
* @param component |
|
|
|
|
*/ |
|
|
|
|
private void refreshRightPane(Component component) { |
|
|
|
|
rightPane.removeAll(); |
|
|
|
|
rightPane.repaint(); |
|
|
|
@ -95,42 +118,50 @@ public class EventConfigPane extends BasicPane implements TreeSelectionListener
|
|
|
|
|
rightPane.revalidate(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建左边的面板,里面放组件树 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private JPanel getLeftPane() { |
|
|
|
|
JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
// 存放组件树
|
|
|
|
|
JPanel leftContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
initLeftContentPane(leftContentPane); |
|
|
|
|
leftPane.add(leftContentPane, BorderLayout.CENTER); |
|
|
|
|
// 左上方 items with event
|
|
|
|
|
// 左上方文字
|
|
|
|
|
JPanel leftTopPane = getLeftTopPane(); |
|
|
|
|
leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0)); |
|
|
|
|
leftPane.add(leftTopPane, BorderLayout.NORTH); |
|
|
|
|
return leftPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 初始化组件树父面板 |
|
|
|
|
* @param leftContentPane |
|
|
|
|
*/ |
|
|
|
|
private void initLeftContentPane(JPanel leftContentPane) { |
|
|
|
|
MyComponentTree componentTree = new MyComponentTree(tree, EventConfigPane.this, rootVisible); |
|
|
|
|
componentTree = new MyComponentTree(this, rootVisible); |
|
|
|
|
UIScrollPane scrollPane = new UIScrollPane(componentTree); |
|
|
|
|
// 把树添加到滚动框中
|
|
|
|
|
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
|
|
|
|
leftContentPane.add(scrollPane, BorderLayout.CENTER); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 创建左上方的文字提示 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private JPanel getLeftTopPane() { |
|
|
|
|
JPanel leftTopPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
|
|
|
|
leftTopPane.add(FRWidgetFactory.createLineWrapLabel("Items with Event"), BorderLayout.CENTER); |
|
|
|
|
leftTopPane.add(FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Plugin_Event_Manager_Config_Left_Title")), BorderLayout.CENTER); |
|
|
|
|
return leftTopPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return "event config"; |
|
|
|
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Plugin_Event_Manager_Config_Title"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 树节点的点击响应事件 |
|
|
|
|
* |
|
|
|
|
* @param e |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
@ -139,37 +170,22 @@ public class EventConfigPane extends BasicPane implements TreeSelectionListener
|
|
|
|
|
update(); |
|
|
|
|
MyComponentTree componentTree = (MyComponentTree) e.getSource(); |
|
|
|
|
MyTree tree = (MyTree) componentTree.getLastSelectedPathComponent(); |
|
|
|
|
// 记录当前节点
|
|
|
|
|
lastNode = tree; |
|
|
|
|
if (hasEvent(tree)) { |
|
|
|
|
// 如果点击的节点有(过)事件,则右侧为事件编辑面板
|
|
|
|
|
Widget widget = ((MyWidget) tree.getData()).getWidget(); |
|
|
|
|
refreshRightPane(eventPane); |
|
|
|
|
populate(widget); |
|
|
|
|
eventPane.populate(widget); |
|
|
|
|
} else { |
|
|
|
|
// 否则右侧为空提示
|
|
|
|
|
refreshRightPane(emptyLabel); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断节点是否是一个含有事件的控件 |
|
|
|
|
* |
|
|
|
|
* @param tree |
|
|
|
|
* @return |
|
|
|
|
* 更新事件的方法,基本上需要更新的地方都最终会到这个方法来 |
|
|
|
|
*/ |
|
|
|
|
private boolean hasEvent(MyTree tree) { |
|
|
|
|
if (tree != null && tree.getData() instanceof MyWidget) { |
|
|
|
|
MyWidget myWidget = (MyWidget) tree.getData(); |
|
|
|
|
if (myWidget != null) { |
|
|
|
|
Widget widget = myWidget.getWidget(); |
|
|
|
|
return widget != null && widget.getListenerSize() > 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void populate(Widget widget) { |
|
|
|
|
eventPane.populate(widget); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void update() { |
|
|
|
|
if (hasEvent(lastNode)) { |
|
|
|
|
Widget lastNodeWidget = ((MyWidget) lastNode.getData()).getWidget(); |
|
|
|
@ -183,4 +199,17 @@ public class EventConfigPane extends BasicPane implements TreeSelectionListener
|
|
|
|
|
lastNode = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断树节点是否有事件 |
|
|
|
|
* |
|
|
|
|
* @param myTree |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private boolean hasEvent(MyTree myTree) { |
|
|
|
|
if (myTree != null && myTree.getData() instanceof MyWidget) { |
|
|
|
|
return ((MyWidget) myTree.getData()).isHasEvent(); |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|