diff options
Diffstat (limited to 'source/com/c2kernel/gui/tabs/EntityTabPane.java')
| -rwxr-xr-x | source/com/c2kernel/gui/tabs/EntityTabPane.java | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/source/com/c2kernel/gui/tabs/EntityTabPane.java b/source/com/c2kernel/gui/tabs/EntityTabPane.java new file mode 100755 index 0000000..f6fae14 --- /dev/null +++ b/source/com/c2kernel/gui/tabs/EntityTabPane.java @@ -0,0 +1,182 @@ +/*
+ * TabbedPane.java
+ *
+ * Created on March 22, 2001, 11:39 AM
+ */
+package com.c2kernel.gui.tabs;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+
+import javax.swing.*;
+
+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 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.getImageResource("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.getImageResource("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() {
+ 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.getImageResource("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() {
+ 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();
+ }
+ 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;
+ }
+
+ 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();
+ }
+}
|
