|
|
@ -30,37 +30,37 @@ import java.awt.event.MouseListener; |
|
|
|
|
|
|
|
|
|
|
|
//TODO: august TemplatePane和TemplateTreePane最好合并成一个类
|
|
|
|
//TODO: august TemplatePane和TemplateTreePane最好合并成一个类
|
|
|
|
public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
|
|
|
|
|
|
|
|
private static final long NUM = 1L; |
|
|
|
private static final long NUM = 1L; |
|
|
|
|
|
|
|
|
|
|
|
private static int NUM200 = 200; |
|
|
|
private static int NUM200 = 200; |
|
|
|
|
|
|
|
|
|
|
|
public static TemplatePane getInstance() { |
|
|
|
public static TemplatePane getInstance() { |
|
|
|
|
|
|
|
|
|
|
|
return HOLDER.singleton; |
|
|
|
return HOLDER.singleton; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static class HOLDER { |
|
|
|
private static class HOLDER { |
|
|
|
|
|
|
|
|
|
|
|
private static TemplatePane singleton = new TemplatePane(); |
|
|
|
private static TemplatePane singleton = new TemplatePane(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 2108412478281713143L; |
|
|
|
private static final long serialVersionUID = 2108412478281713143L; |
|
|
|
|
|
|
|
|
|
|
|
public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量
|
|
|
|
public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量
|
|
|
|
|
|
|
|
|
|
|
|
private static javax.swing.Icon leftIcon = BaseUtils.readIcon("/com/fr/design/images/docking/left.png"); |
|
|
|
private static javax.swing.Icon leftIcon = BaseUtils.readIcon("/com/fr/design/images/docking/left.png"); |
|
|
|
|
|
|
|
|
|
|
|
private static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png"); |
|
|
|
private static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png"); |
|
|
|
|
|
|
|
|
|
|
|
private boolean isExpanded = false; |
|
|
|
private boolean isExpanded = false; |
|
|
|
|
|
|
|
|
|
|
|
private UIButton editButton; |
|
|
|
private UIButton editButton; |
|
|
|
|
|
|
|
|
|
|
|
private UILabel envLabel; |
|
|
|
private UILabel envLabel; |
|
|
|
|
|
|
|
|
|
|
|
private TemplatePane() { |
|
|
|
private TemplatePane() { |
|
|
|
|
|
|
|
|
|
|
|
super(); |
|
|
|
super(); |
|
|
|
this.initComponents(); |
|
|
|
this.initComponents(); |
|
|
|
this.setFocusable(true); |
|
|
|
this.setFocusable(true); |
|
|
@ -69,24 +69,24 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
TemplateTreePane.getInstance().setVisible(isExpanded); |
|
|
|
TemplateTreePane.getInstance().setVisible(isExpanded); |
|
|
|
TemplateTreePane.getInstance().setVisible(true); |
|
|
|
TemplateTreePane.getInstance().setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initComponents() { |
|
|
|
private void initComponents() { |
|
|
|
|
|
|
|
|
|
|
|
GeneralContext.addEnvChangedListener(new EnvChangedListener() { |
|
|
|
GeneralContext.addEnvChangedListener(new EnvChangedListener() { |
|
|
|
|
|
|
|
|
|
|
|
public void envChanged() { |
|
|
|
public void envChanged() { |
|
|
|
|
|
|
|
|
|
|
|
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); |
|
|
|
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.setLayout(new BorderLayout(25, 0)); |
|
|
|
this.setLayout(new BorderLayout(25, 0)); |
|
|
|
editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) { |
|
|
|
editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) { |
|
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = NUM; |
|
|
|
private static final long serialVersionUID = NUM; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Point getToolTipLocation(MouseEvent event) { |
|
|
|
public Point getToolTipLocation(MouseEvent event) { |
|
|
|
|
|
|
|
|
|
|
|
return new Point(25, 2); |
|
|
|
return new Point(25, 2); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -98,9 +98,9 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
this.add(new UILabel(" "), BorderLayout.WEST); |
|
|
|
this.add(new UILabel(" "), BorderLayout.WEST); |
|
|
|
this.add(editButton, BorderLayout.EAST); |
|
|
|
this.add(editButton, BorderLayout.EAST); |
|
|
|
editButton.addActionListener(new ActionListener() { |
|
|
|
editButton.addActionListener(new ActionListener() { |
|
|
|
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
|
|
|
|
|
|
|
|
editItems(); |
|
|
|
editItems(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -109,25 +109,25 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); |
|
|
|
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName()); |
|
|
|
this.add(envLabel, BorderLayout.CENTER); |
|
|
|
this.add(envLabel, BorderLayout.CENTER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 是否可扩展 |
|
|
|
* 是否可扩展 |
|
|
|
* |
|
|
|
* |
|
|
|
* @return 同上 |
|
|
|
* @return 同上 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean IsExpanded() { |
|
|
|
public boolean IsExpanded() { |
|
|
|
|
|
|
|
|
|
|
|
return this.isExpanded; |
|
|
|
return this.isExpanded; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setExpand(boolean b) { |
|
|
|
public void setExpand(boolean b) { |
|
|
|
|
|
|
|
|
|
|
|
this.isExpanded = b; |
|
|
|
this.isExpanded = b; |
|
|
|
this.repaint(); |
|
|
|
this.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean envListOkAction(EnvListPane envListPane) { |
|
|
|
private boolean envListOkAction(EnvListPane envListPane) { |
|
|
|
|
|
|
|
|
|
|
|
final String selectedName = envListPane.updateEnvManager(); |
|
|
|
final String selectedName = envListPane.updateEnvManager(); |
|
|
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
|
|
|
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); |
|
|
|
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName); |
|
|
|
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName); |
|
|
@ -141,7 +141,6 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
WorkContext.switchTo(workspace, new WorkContextCallback() { |
|
|
|
WorkContext.switchTo(workspace, new WorkContextCallback() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void done() { |
|
|
|
public void done() { |
|
|
|
DesignerEnvManager.getEnvManager().setCurEnvName(selectedName); |
|
|
|
DesignerEnvManager.getEnvManager().setCurEnvName(selectedName); |
|
|
@ -165,33 +164,33 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 编辑items |
|
|
|
* 编辑items |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void editItems() { |
|
|
|
public void editItems() { |
|
|
|
|
|
|
|
|
|
|
|
final EnvListPane envListPane = new EnvListPane(); |
|
|
|
final EnvListPane envListPane = new EnvListPane(); |
|
|
|
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); |
|
|
|
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); |
|
|
|
|
|
|
|
|
|
|
|
envListPane.populateEnvManager(envLabel.getText()); |
|
|
|
envListPane.populateEnvManager(envLabel.getText()); |
|
|
|
envListDialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
envListDialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
|
|
|
|
|
|
|
|
public void doOk() { |
|
|
|
public void doOk() { |
|
|
|
|
|
|
|
|
|
|
|
envListOkAction(envListPane); |
|
|
|
envListOkAction(envListPane); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void doCancel() { |
|
|
|
public void doCancel() { |
|
|
|
|
|
|
|
|
|
|
|
envListDialog.setVisible(false); |
|
|
|
envListDialog.setVisible(false); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
envListDialog.setVisible(true); |
|
|
|
envListDialog.setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setJLabel(String name) { |
|
|
|
private void setJLabel(String name) { |
|
|
|
|
|
|
|
|
|
|
|
DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name); |
|
|
|
DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name); |
|
|
|
if (config != null) { |
|
|
|
if (config != null) { |
|
|
|
switch (config.getType()) { |
|
|
|
switch (config.getType()) { |
|
|
@ -205,26 +204,26 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
envLabel.setText(name); |
|
|
|
envLabel.setText(name); |
|
|
|
envLabel.repaint(); |
|
|
|
envLabel.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
|
|
|
|
|
|
|
|
return new Dimension(250, HEIGHT); |
|
|
|
return new Dimension(250, HEIGHT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
|
|
|
|
|
|
|
|
super.paintComponent(g); |
|
|
|
super.paintComponent(g); |
|
|
|
paintBackgroundIcon(g); |
|
|
|
paintBackgroundIcon(g); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void paintBackgroundIcon(Graphics g) { |
|
|
|
private void paintBackgroundIcon(Graphics g) { |
|
|
|
|
|
|
|
|
|
|
|
int w = this.getWidth(); |
|
|
|
int w = this.getWidth(); |
|
|
|
int h = this.getHeight(); |
|
|
|
int h = this.getHeight(); |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
@ -239,9 +238,9 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
g2d.drawLine(w - 1, 2, w - 1, h - 1); |
|
|
|
g2d.drawLine(w - 1, 2, w - 1, h - 1); |
|
|
|
Icon icon = !isExpanded ? leftIcon : rightIcon; |
|
|
|
Icon icon = !isExpanded ? leftIcon : rightIcon; |
|
|
|
icon.paintIcon(this, g2d, 4, 4); |
|
|
|
icon.paintIcon(this, g2d, 4, 4); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 鼠标点击 |
|
|
|
* 鼠标点击 |
|
|
|
* |
|
|
|
* |
|
|
@ -249,9 +248,9 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 鼠标按下 |
|
|
|
* 鼠标按下 |
|
|
|
* |
|
|
|
* |
|
|
@ -259,7 +258,7 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
|
|
if (e.getX() < NUM200) { |
|
|
|
if (e.getX() < NUM200) { |
|
|
|
isExpanded = !isExpanded; |
|
|
|
isExpanded = !isExpanded; |
|
|
|
TemplateTreePane.getInstance().setVisible(isExpanded); |
|
|
|
TemplateTreePane.getInstance().setVisible(isExpanded); |
|
|
@ -267,7 +266,7 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
DesignerEnvManager.getEnvManager().setTemplateTreePaneExpanded(isExpanded); |
|
|
|
DesignerEnvManager.getEnvManager().setTemplateTreePaneExpanded(isExpanded); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 鼠标放开 |
|
|
|
* 鼠标放开 |
|
|
|
* |
|
|
|
* |
|
|
@ -275,9 +274,9 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 鼠标进入 |
|
|
|
* 鼠标进入 |
|
|
|
* |
|
|
|
* |
|
|
@ -285,9 +284,9 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseEntered(MouseEvent e) { |
|
|
|
public void mouseEntered(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 鼠标离开 |
|
|
|
* 鼠标离开 |
|
|
|
* |
|
|
|
* |
|
|
@ -295,33 +294,33 @@ public class TemplatePane extends JPanel implements MouseListener { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
public void mouseExited(MouseEvent e) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 处理异常 |
|
|
|
* 处理异常 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void dealEvnExceptionWhenStartDesigner() { |
|
|
|
public void dealEvnExceptionWhenStartDesigner() { |
|
|
|
|
|
|
|
|
|
|
|
final EnvListPane envListPane = new EnvListPane(); |
|
|
|
final EnvListPane envListPane = new EnvListPane(); |
|
|
|
envListPane.populateEnvManager(envLabel.getText()); |
|
|
|
envListPane.populateEnvManager(envLabel.getText()); |
|
|
|
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); |
|
|
|
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); |
|
|
|
envListDialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
envListDialog.addDialogActionListener(new DialogActionAdapter() { |
|
|
|
|
|
|
|
|
|
|
|
public void doOk() { |
|
|
|
public void doOk() { |
|
|
|
|
|
|
|
|
|
|
|
if (!envListOkAction(envListPane)) { |
|
|
|
if (!envListOkAction(envListPane)) { |
|
|
|
System.exit(0); |
|
|
|
System.exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void doCancel() { |
|
|
|
public void doCancel() { |
|
|
|
|
|
|
|
|
|
|
|
System.exit(0); |
|
|
|
System.exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
envListDialog.setVisible(true); |
|
|
|
envListDialog.setVisible(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|