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