001: // AddFramePanel.java
002: // $Id: AddFramePanel.java,v 1.5 2000/08/16 21:37:29 ylafon Exp $
003: // (c) COPYRIGHT MIT, INRIA and Keio, 1999.
004: // Please first read the full copyright statement in file COPYRIGHT.html
005:
006: package org.w3c.jigadmin.editors;
007:
008: import javax.swing.JLabel;
009: import javax.swing.JButton;
010: import javax.swing.JPanel;
011: import javax.swing.BorderFactory;
012:
013: import java.awt.GridLayout;
014: import java.awt.GridBagLayout;
015: import java.awt.GridBagConstraints;
016: import java.awt.Insets;
017: import java.awt.event.ActionListener;
018: import java.awt.event.ActionEvent;
019:
020: import java.util.Hashtable;
021:
022: import org.w3c.jigadmin.RemoteResourceWrapper;
023: import org.w3c.jigadmin.PropertyManager;
024:
025: import org.w3c.jigsaw.admin.RemoteAccessException;
026:
027: /**
028: * A widget used to select a frame class.
029: * @version $Revision: 1.5 $
030: * @author Benoît Mahé (bmahe@w3.org)
031: */
032: public class AddFramePanel extends AddResourcePanel {
033:
034: /**
035: * Get a list of resources that we can add to the given
036: * RemoteResourceWrapper.
037: * @param rrw The RemoteResourceWrapper
038: * @return a Hashtable instance containing the list of resource that can
039: * be added to the given RemoteResource.
040: * @exception RemoteAccessException is some remote error occurs
041: */
042: protected Hashtable getResources(RemoteResourceWrapper rrw)
043: throws RemoteAccessException {
044: PropertyManager pm = PropertyManager.getPropertyManager();
045: return pm.getFrames();
046: }
047:
048: /**
049: * Build the interface.
050: * @param rrw The RemoteResourceWrapper of the resource where we are going
051: * to add a frame.
052: * @param title the title of the panel.
053: * @exception RemoteAccessException is some remote error occurs
054: */
055: protected void build(RemoteResourceWrapper rrw, String title)
056: throws RemoteAccessException {
057: /**
058: * Our internal ActionListener
059: */
060: ActionListener afpal = new ActionListener() {
061: public void actionPerformed(ActionEvent ae) {
062: if (ae.getActionCommand().equals("Ok")) {
063: if (!classSC.getText().equals("")) {
064: browser.setResourceToAdd(classSC.getText(),
065: null);
066: browser.disposeAddResourcePopup();
067: done();
068: } else {
069: classSC.requestFocus();
070: }
071: } else if (ae.getActionCommand().equals("Cancel")) {
072: browser.setResourceToAdd(null, null);
073: browser.disposeAddResourcePopup();
074: done();
075: }
076: }
077: };
078:
079: GridBagLayout gbl = new GridBagLayout();
080: GridBagConstraints gbc = new GridBagConstraints();
081: GridBagLayout mgbl = new GridBagLayout();
082: GridBagConstraints mgbc = new GridBagConstraints();
083: JLabel l;
084: JButton b;
085: JPanel p = new JPanel(gbl);
086:
087: initializeStringChoice(rrw);
088:
089: gbc.fill = GridBagConstraints.HORIZONTAL;
090: gbc.weightx = 0;
091: gbc.weighty = 0;
092: gbc.insets = new Insets(0, 0, 10, 0);
093: mgbc.fill = GridBagConstraints.NONE;
094: mgbc.weightx = 0;
095: mgbc.weighty = 0;
096: mgbc.insets = new Insets(0, 10, 16, 5);
097: setLayout(mgbl);
098:
099: l = new JLabel("Class name: ", JLabel.RIGHT);
100: gbc.gridwidth = 1;
101: gbl.setConstraints(l, gbc);
102: p.add(l);
103: gbc.gridwidth = GridBagConstraints.REMAINDER;
104: gbl.setConstraints(classSC, gbc);
105: p.add(classSC);
106:
107: mgbc.gridwidth = GridBagConstraints.REMAINDER;
108: mgbl.setConstraints(p, mgbc);
109: add(p);
110: // and now the usual button bar
111: p = new JPanel(new GridLayout(1, 2, 20, 20));
112: b = new JButton("Ok");
113: b.addActionListener(afpal);
114: p.add(b);
115: b = new JButton("Cancel");
116: b.addActionListener(afpal);
117: p.add(b);
118: mgbl.setConstraints(p, mgbc);
119: add(p);
120: setBorder(BorderFactory.createTitledBorder(title));
121: }
122:
123: /**
124: * Constructor.
125: * @param title The widget title
126: * @param rrw The RemoteResourceWrapper of the resource where we are going
127: * to add a frame.
128: * @param browser the ResourceTreeBrowser
129: * @exception RemoteAccessException is some remote error occurs
130: */
131: protected AddFramePanel(String title, RemoteResourceWrapper rrw,
132: ResourceTreeBrowser browser) throws RemoteAccessException {
133: super(title, rrw, browser);
134: }
135:
136: }
|