1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
/*
* TabbedPane.java
*
* Created on March 22, 2001, 11:39 AM
*/
package com.c2kernel.gui.tabs;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.SwingConstants;
import com.c2kernel.entity.proxy.EntityProxyObserver;
import com.c2kernel.gui.EntityDetails;
import com.c2kernel.gui.MainFrame;
import com.c2kernel.gui.data.NodeEntity;
import com.c2kernel.gui.tabs.outcome.OutcomeHandler;
import com.c2kernel.gui.tabs.outcome.form.OutcomePanel;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Language;
import com.c2kernel.utils.Logger;
import com.c2kernel.utils.Resource;
/**
* Generic item details tabbed pane.
*
* @version $Revision: 1.31 $ $Date: 2005/06/08 16:47:44 $
* @author $Author: abranson $
*/
public class EntityTabPane extends JPanel implements Runnable {
protected NodeEntity sourceEntity;
protected String titleText = null;
protected ImageIcon titleIcon = null;
private final String tabName;
protected GridBagLayout gridbag = new GridBagLayout();
protected GridBagConstraints c = null;
public static Font titleFont = null;
public static Color headingColor = new Color(0, 0, 185);
protected EntityDetails parent;
protected static ImageIcon mReloadIcon = null;
protected Box titleBox;
static {
try {
mReloadIcon = Resource.findImage("reload.gif");
} catch (Exception e) {
Logger.warning("Couldn't load images: " + e);
}
}
public void focusLost(FocusEvent e)
{
}
public EntityTabPane(String tabName, String titleText) {
this.tabName = Language.translate(tabName);
this.titleText =
titleText == null ? null : Language.translate(titleText);
if (titleFont == null)
titleFont =
new Font("SansSerif", Font.BOLD, this.getFont().getSize() + 5);
Logger.msg(2, "ItemTabPane.<init> - viewing " + tabName);
setLayout(gridbag);
}
public void setParent(EntityDetails parent) {
this.parent = parent;
}
public String getTabName() {
return tabName;
}
protected GridBagConstraints getGridBagConstraints() {
if (c == null)
c = new GridBagConstraints();
return c;
}
protected void initPanel() {
getGridBagConstraints().gridx = 0;
getGridBagConstraints().gridy = 0;
getGridBagConstraints().anchor = GridBagConstraints.NORTHWEST;
getGridBagConstraints().fill = GridBagConstraints.HORIZONTAL;
getGridBagConstraints().ipadx = 5;
getGridBagConstraints().weightx = 1.0;
getGridBagConstraints().ipady = 5;
// Help panel
if (titleText == null)
titleText = tabName;
if (titleIcon == null)
titleIcon = Resource.findImage("info.png");
JLabel title = new JLabel(titleText, titleIcon, SwingConstants.LEFT);
title.setFont(titleFont);
title.setForeground(headingColor);
JButton refreshButton = new JButton(mReloadIcon);
refreshButton.setToolTipText(Language.translate("Refresh"));
refreshButton.setMargin(new Insets(0, 0, 0, 0));
refreshButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setCursor(new Cursor(Cursor.WAIT_CURSOR));
reload();
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
});
String defaultStartTab = MainFrame.getPref("DefaultStartTab", "Properties");
JToggleButton defaultStart =
new JToggleButton(Resource.findImage("graph/start.png"));
defaultStart.setMargin(new Insets(0, 0, 0, 0));
defaultStart.setToolTipText(
Language.translate("Select this tab to be the default one opened when you double click an item"));
defaultStart.setSelected(tabName.equals(defaultStartTab));
defaultStart.setActionCommand(tabName);
defaultStart.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (((JToggleButton)e.getSource()).isSelected())
MainFrame.setPref("DefaultStartTab", e.getActionCommand());
}
});
titleBox = Box.createHorizontalBox();
titleBox.add(title);
titleBox.add(Box.createHorizontalGlue());
titleBox.add(defaultStart);
titleBox.add(refreshButton);
gridbag.setConstraints(titleBox, c);
this.add(titleBox);
}
public void initForEntity(NodeEntity sourceEntity) {
this.sourceEntity = sourceEntity;
Thread loader = new Thread(this);
loader.start();
}
@Override
public void run() {
Thread.currentThread().setName("Default Entity Pane Builder");
getGridBagConstraints();
c.gridx = 0;
c.gridy = 1;
c.anchor = GridBagConstraints.NORTHWEST;
c.fill = GridBagConstraints.HORIZONTAL;
c.ipadx = 5;
c.weightx = 1.0;
c.weighty = 1.0;
c.ipady = 5;
JLabel error = new JLabel("In Development");
gridbag.setConstraints(error, c);
this.add(error);
}
public void reload() {
}
public void runCommand(String command) {
}
public void destroy() {
if (sourceEntity != null && this instanceof EntityProxyObserver<?>) {
sourceEntity.getEntity().unsubscribe((EntityProxyObserver<?>)this);
}
parent = null;
}
@Override
protected void finalize() throws Throwable {
Logger.msg(7, "Reaping "+getClass().getName());
}
static public OutcomeHandler getOutcomeHandler(String schema, int version) {
String ohClassName = Gateway.getProperty("OutcomeHandler."+schema+"."+version);
try {
if (ohClassName != null && ohClassName.length() > 0) {
Class<?> ohClass = Class.forName(ohClassName);
return (OutcomeHandler) ohClass.newInstance();
}
} catch (Exception ex) {
Logger.error("Error creating handler "+ohClassName+". using default outcome editor");
}
ohClassName = Gateway.getProperty("OutcomeHandler.*");
try {
if (ohClassName != null && ohClassName.length() > 0) {
Class<?> ohClass = Class.forName(ohClassName);
return (OutcomeHandler) ohClass.newInstance();
}
} catch (Exception ex) {
Logger.error("Error creating handler "+ohClassName+". using default outcome editor");
Logger.error(ex);
}
return new OutcomePanel();
}
}
|