--- /dev/null
+// RealmsHelper.java\r
+// $Id: RealmsHelper.java,v 1.1 2010/06/15 12:22:42 smhuang Exp $\r
+// (c) COPYRIGHT MIT and INRIA, 1997.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.jigadm.editors ;\r
+\r
+import java.awt.BorderLayout;\r
+import java.awt.Button;\r
+import java.awt.Component;\r
+import java.awt.Container;\r
+import java.awt.GridBagConstraints;\r
+import java.awt.GridBagLayout;\r
+import java.awt.Label;\r
+import java.awt.Panel;\r
+import java.awt.TextComponent;\r
+import java.awt.TextField;\r
+\r
+import java.awt.event.ActionEvent;\r
+import java.awt.event.ActionListener;\r
+\r
+import java.util.Properties;\r
+\r
+import org.w3c.jigadm.RemoteResourceWrapper;\r
+\r
+import org.w3c.jigsaw.admin.RemoteAccessException;\r
+import org.w3c.jigsaw.admin.RemoteResource;\r
+\r
+import org.w3c.tools.resources.Attribute;\r
+\r
+public class RealmsHelper extends ResourceHelper {\r
+\r
+ class AddRealmListener implements ActionListener {\r
+\r
+ public void actionPerformed(ActionEvent ae) {\r
+ addRealm();\r
+ }\r
+ }\r
+\r
+ RemoteResourceWrapper rrw = null;\r
+ RemoteResource rr = null;\r
+ private boolean initialized = false;\r
+ TextField tf;\r
+ Panel widget;\r
+\r
+ protected void addRealm() {\r
+ if(tf.getText().length() > 0) {\r
+ RemoteResource nrr;\r
+ try {\r
+ nrr = rrw.getResource().\r
+ registerResource(tf.getText(),\r
+ "org.w3c.jigsaw.auth.AuthRealm");\r
+ } catch (RemoteAccessException ex) {\r
+ errorPopup("RemoteAccessException",ex);\r
+ return;\r
+ }\r
+ RemoteResourceWrapper nrrw;\r
+ nrrw = new RemoteResourceWrapper(rrw, nrr, rrw.getBrowser());\r
+ rrw.getBrowser().insertNode(rrw, nrrw, tf.getText());\r
+ }\r
+ }\r
+\r
+ protected RemoteResourceWrapper getWrapper() {\r
+ return rrw;\r
+ }\r
+\r
+ public Component getComponent() {\r
+ return widget;\r
+ }\r
+\r
+ public void commitChanges() {\r
+ }\r
+\r
+ public boolean hasChanged() { \r
+ return false;\r
+ }\r
+\r
+ public void resetChanges() {\r
+ }\r
+\r
+ public void clearChanged() {\r
+ }\r
+\r
+ public final String getTitle () {\r
+ return "Realms";\r
+ }\r
+\r
+ public RealmsHelper() {\r
+ widget = new Panel();\r
+ }\r
+\r
+ protected void initAddPanel() {\r
+ GridBagLayout gbl = new GridBagLayout();\r
+ GridBagConstraints gbc = new GridBagConstraints();\r
+ AddRealmListener arl = new AddRealmListener();\r
+ Panel p = new Panel(gbl);\r
+ Label l;\r
+ gbc.fill = GridBagConstraints.HORIZONTAL;\r
+ gbc.weightx = 0;\r
+ gbc.weighty = 0; \r
+ tf = new TextField(15);\r
+ tf.addActionListener(arl);\r
+ l = new Label("Realm name", Label.RIGHT);\r
+ gbc.gridwidth = 1;\r
+ gbl.setConstraints(l, gbc);\r
+ p.add(l);\r
+ gbc.gridwidth = GridBagConstraints.REMAINDER;\r
+ gbl.setConstraints(tf, gbc);\r
+ p.add(tf);\r
+ widget.add("Center", p);\r
+ Button newb = new Button("Add Realm");\r
+ newb.addActionListener(arl);\r
+ widget.add("South", newb);\r
+ }\r
+\r
+ /**\r
+ * initialize this helper\r
+ * @param rrw The RemoteResourceWrapper\r
+ * @param pr The properties\r
+ * @exception RemoteAccessException if a remote access error occurs.\r
+ */\r
+ public void initialize(RemoteResourceWrapper rrw, Properties pr)\r
+ throws RemoteAccessException\r
+ {\r
+ if(!initialized)\r
+ initialized = true;\r
+ else\r
+ return; \r
+ \r
+ this.rrw = rrw;\r
+ rr = rrw.getResource();\r
+\r
+ if(rr.isContainer()) {\r
+ widget.setLayout(new BorderLayout());\r
+ initAddPanel();\r
+ }\r
+ }\r
+}\r