throws RemoteAccessException
{
if(initialized)
return;
RemoteResource rr;
AttributeDescription b[] = null;
String s[] = null;
int nbn = 0;
boolean authorized;
this.rrw = rrw;
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.getBrowser().popupDialog("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
Label l;
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
Panel p = new Panel(gbl);
p.setForeground(new Color(0,0,128));
pwidget = new ScrollPane();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 0;
gbc.weighty = 0;
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 Label(labelText, Label.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.getBrowser().popupDialog("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());
}
}
pwidget.add(p);
widget.add("Center", pwidget);
// Now add the reset/commit button bar
Panel toolpane= new Panel(new BorderLayout());
Button commitb = new Button(COMMIT_L);
Button resetb = new Button(RESET_L);
MouseButtonListener mbl = new MouseButtonListener();
commitb.addMouseListener(mbl);
resetb.addMouseListener(mbl);
ButtonBarListener bbl = new ButtonBarListener();
commitb.addActionListener(bbl);
resetb.addActionListener(bbl);
message = new Label("", Label.CENTER);
message.setForeground(Color.white);
message.setBackground(Color.gray);
BorderPanel pmsg = new BorderPanel(BorderPanel.IN, 2);
pmsg.setLayout(new BorderLayout());
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();
}