throws RemoteAccessException
{
if(initialized)
return;
RemoteResource rr;
AttributeDescription b[] = null;
String s[] = null;
int nbn = 0;
boolean authorized;
this.rrw = (RemoteResourceWrapper)r;
rr = rrw.getResource();
authorized = false;
while(!authorized) {
try {
authorized = true;
b = rr.getAttributes();
} catch (RemoteAccessException ex) {
if(ex.getMessage().equals("Unauthorized")) {
authorized = false;
} else {
throw ex;
}
} finally {
if(!authorized) {
rrw.getServerBrowser().popupPasswdDialog("admin");
}
}
}
// we select only the editable Attributes.
for(int i=0; i<b.length; i++)
if(b[i] == null)
nbn++;
else
if(!b[i].getAttribute().checkFlag(Attribute.EDITABLE))
nbn++;
a = new AttributeDescription[b.length-nbn];
ae = new AttributeEditor[a.length];
int j = 0;
for(int i=0; i<b.length; i++) {
if(b[i] != null &&
b[i].getAttribute().checkFlag(Attribute.EDITABLE)) {
a[j++] = b[i];
}
}
// add all the attribute editors
JLabel l;
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
JPanel p = new JPanel(gbl);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.insets = Utilities.insets4;
for(int i = 0 ; i < a.length ; i++) {
if(a[i] != null) {
PropertyManager pm = PropertyManager.getPropertyManager();
Properties attrProps =
pm.getAttributeProperties(rrw, a[i].getAttribute());
String labelText = (String) attrProps.get("label");
if ( labelText == null )
labelText = a[i].getName();
l = new JLabel(labelText, JLabel.RIGHT);
ae[i] = AttributeEditorFactory.getEditor(rrw,
a[i].getAttribute());
authorized = false;
while(!authorized) {
try {
authorized = true;
ae[i].initialize(rrw, a[i].getAttribute(),
a[i].getValue(), attrProps);
} catch (RemoteAccessException ex) {
if(ex.getMessage().equals("Unauthorized")) {
authorized = false;
} else {
throw ex;
}
} finally {
if(!authorized) {
rrw.getServerBrowser().popupPasswdDialog("admin");
}
}
}
gbc.gridwidth = 1;
gbl.setConstraints(l, gbc);
p.add(l);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbl.setConstraints(ae[i].getComponent(), gbc);
p.add(ae[i].getComponent());
}
}
JScrollPane pwidget = new JScrollPane(p);
//pwidget.add(p);
widget.add("Center", pwidget);
// Now add the reset/commit button bar
JPanel toolpane= new JPanel(new BorderLayout());
JButton commitb = new JButton(COMMIT_L);
JButton resetb = new JButton(RESET_L);
commitb.addMouseListener(ma);
resetb.addMouseListener(ma);
commitb.addActionListener(al);
resetb.addActionListener(al);
message = new JLabel("", JLabel.CENTER);
message.setForeground(Color.white);
message.setBackground(Color.gray);
JPanel pmsg = new JPanel(new BorderLayout());
pmsg.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
pmsg.add("Center", message);
toolpane.add("West", commitb);
toolpane.add("Center", pmsg);
toolpane.add("East", resetb);
widget.add("South", toolpane);
// add information about the class of the resource edited
String classes[] = {""};
try {
classes = rr.getClassHierarchy();
} catch (RemoteAccessException ex) {
// big trouble but it may be temporary and this information
// is not vital, so just warn
ex.printStackTrace();
}