List of usage examples for com.jgoodies.binding PresentationModel PresentationModel
public PresentationModel(ValueModel beanChannel)
From source file:org.openthinclient.console.nodes.views.ClientEditor.java
License:Open Source License
public ClientEditor(final Client client, Realm realm) { final PresentationModel model = new PresentationModel(new ValueHolder(client, true)); final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"), //$NON-NLS-1$ Messages.getBundle(), this); dfb.getPanel().setName(Messages.getString("Settings_title")); //$NON-NLS-1$ dfb.appendI15d("Client.ipHostNumber", //$NON-NLS-1$ BasicComponentFactory.createTextField(model.getModel("ipHostNumber"), //$NON-NLS-1$ true));/*ww w . j av a 2 s.c om*/ dfb.nextLine(); if (UnrecognizedClientEditor.isUnrecognize()) { // Disable editing of unrecognized client MAC addresses final JTextField macAdressTextField = BasicComponentFactory .createTextField(model.getModel("macAddress")); macAdressTextField.setEditable(false); dfb.appendI15d("Client.macAddress", //$NON-NLS-1$ macAdressTextField, //$NON-NLS-1$ false); } else dfb.appendI15d("Client.macAddress", //$NON-NLS-1$ BasicComponentFactory.createTextField(model.getModel("macAddress"), //$NON-NLS-1$ false)); dfb.nextLine(); // FIXME: den richtigen Realm benutzen! Set<Location> locations; try { locations = realm.getDirectory().list(Location.class); } catch (final DirectoryException e) { ErrorManager.getDefault().notify(e); locations = new HashSet<Location>(); } final JComboBox locationBox = BasicComponentFactory .createComboBox(new SelectionInList(new ArrayList(locations), model.getModel("location"))); dfb.appendI15d("Client.location", locationBox); if (locations.size() == 1 && locationBox.getSelectedIndex() < 0) locationBox.setSelectedIndex(0); dfb.nextLine(); Set<HardwareType> hwtypes; try { hwtypes = realm.getDirectory().list(HardwareType.class); } catch (final DirectoryException e) { ErrorManager.getDefault().notify(e); hwtypes = new HashSet<HardwareType>(); } final JComboBox hwtBox = BasicComponentFactory .createComboBox(new SelectionInList(new ArrayList(hwtypes), model.getModel("hardwareType"))); dfb.appendI15d("Client.hardwareType", hwtBox); if (hwtypes.size() == 1 && hwtBox.getSelectedIndex() < 0) hwtBox.setSelectedIndex(0); dfb.nextLine(); putClientProperty(DirObjectEditor.KEY_VALIDATOR, new ClientValidator(model, client)); }
From source file:org.openthinclient.console.nodes.views.DirObjectEditor.java
License:Open Source License
@Override public JComponent getHeaderComponent() { boolean isMutabel = true; boolean isRealm = false; final String name = dirObject.getClass().getSimpleName(); // check if is mutable if (!LDAPDirectory.isMutable(dirObject.getClass())) isMutabel = false;//from w w w . j a v a 2 s .c o m if (name.equals("Realm")) isRealm = true; final JPanel panel = new JPanel(); final PresentationModel model = new PresentationModel(new ValueHolder(dirObject, true)); final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("p, 10dlu, r:p, 3dlu, f:p:g"), //$NON-NLS-1$ Messages.getBundle(), panel); dfb.setLeadingColumnOffset(2); dfb.setColumn(3); if (isMutabel == false) { dfb.appendI15d("DirObjectEditor.name", BasicComponentFactory.createLabel(model.getModel("name"))); dfb.appendI15d("DirObjectEditor.description", BasicComponentFactory.createLabel(model.getModel("description"))); } else if (isRealm == true) { // FIXME: make it easier String dn = realm.getConnectionDescriptor().getBaseDN(); dn = dn.replace("\\,", "#%COMMA%#"); final String[] s = dn.split(","); String nameRealm = ""; if (s.length > 0) { nameRealm = s[0].replace("ou=", "").trim(); nameRealm = nameRealm.replace("#%COMMA%#", "\\,").trim(); } final JTextField field = new javax.swing.JTextField(); field.setText(nameRealm); dfb.appendI15d("DirObjectEditor.name", field); //$NON-NLS-1$ dfb.appendI15d("DirObjectEditor.description", BasicComponentFactory.createTextField( //$NON-NLS-1$ model.getModel("description"), true)); //$NON-NLS-1$ } else { dfb.appendI15d("DirObjectEditor.name", BasicComponentFactory.createTextField( //$NON-NLS-1$ model.getModel("name"), false)); //$NON-NLS-1$ dfb.appendI15d("DirObjectEditor.description", BasicComponentFactory.createTextField( //$NON-NLS-1$ model.getModel("description"), true)); //$NON-NLS-1$ } panel.add( new JLabel(IconManager.getInstance(DetailViewProvider.class, "icons") //$NON-NLS-1$ .getIcon("tree." + dirObject.getClass().getSimpleName())), //$NON-NLS-1$ new CellConstraints(1, 1, 1, dfb.getRowCount(), CellConstraints.CENTER, CellConstraints.TOP)); panel.putClientProperty(DirObjectEditor.KEY_VALIDATOR, this); return panel; }
From source file:org.openthinclient.console.nodes.views.DirObjectEditor.java
License:Open Source License
public void init(Node[] selection, TopComponent tc) { dirObject = realm = null;/*from w w w. j a v a 2s. c o m*/ for (final Node node : selection) if (node instanceof DirObjectNode) { realm = (Realm) node.getLookup().lookup(Realm.class); dirObject = (DirectoryObject) node.getLookup().lookup(DirectoryObject.class); } else if (node instanceof RealmNode) dirObject = realm = (Realm) node.getLookup().lookup(Realm.class); if (null == dirObject) throw new IllegalStateException("Could not lookup a DirectoryObject instance"); //$NON-NLS-1$ if (null == realm) throw new IllegalStateException("Could not lookup a Realm instance"); //$NON-NLS-1$ model = new PresentationModel(new ValueHolder(dirObject, true)); }
From source file:org.openthinclient.console.nodes.views.RealmEditor.java
License:Open Source License
public RealmEditor(final Realm realm) { // final PresentationModel realmModel = new PresentationModel(new // ValueHolder( // realm, true)); final PresentationModel roPrincipalModel = new PresentationModel( new ValueHolder(realm.getReadOnlyPrincipal(), true)); final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"), //$NON-NLS-1$ Messages.getBundle(), this); dfb.getPanel().setName(Messages.getString("Settings_title")); //$NON-NLS-1$ dfb.appendI15d("User.changePassword", BasicComponentFactory //$NON-NLS-1$ .createPasswordField(roPrincipalModel.getModel("newPassword"), //$NON-NLS-1$ false));/*from w w w .ja va2 s .c o m*/ dfb.nextLine(); dfb.appendI15d("User.verifyPassword", BasicComponentFactory //$NON-NLS-1$ .createPasswordField(roPrincipalModel.getModel("verifyPassword"), //$NON-NLS-1$ false)); dfb.nextLine(); // HACK: forward property changes from the roPrincipal user to the realm, // in order to make the validation trigger. realm.getReadOnlyPrincipal().addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { realm.fakePropertyChange(); } }); putClientProperty(DirObjectEditor.KEY_VALIDATOR, new UserValidator(roPrincipalModel, realm.getReadOnlyPrincipal())); }
From source file:org.openthinclient.console.nodes.views.UserEditor.java
License:Open Source License
public UserEditor(final User user, Realm realm) { if (!LDAPDirectory.isMutable(User.class)) { final PresentationModel model = new PresentationModel(new ValueHolder(user, true)); final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"), Messages.getBundle(), this); dfb.getPanel().setName(Messages.getString("Settings_title")); dfb.appendI15d("User.givenName", BasicComponentFactory.createLabel(model.getModel("givenName"))); dfb.nextLine();/*from w w w .ja v a2 s . co m*/ dfb.appendI15d("User.surname", BasicComponentFactory.createLabel(model.getModel("sn"))); dfb.nextLine(); // dfb.appendI15d("User.stringLocation", // BasicComponentFactory.createLabel( // model.getModel("stringLocation"))); // dfb.nextLine(); dfb.appendUnrelatedComponentsGapRow(); dfb.nextLine(); dfb.appendI15d("User.changePassword", BasicComponentFactory.createLabel(model.getModel("newPassword"))); dfb.nextLine(); dfb.appendI15d("User.verifyPassword", BasicComponentFactory.createLabel(model.getModel("verifyPassword"))); dfb.nextLine(); putClientProperty(DirObjectEditor.KEY_VALIDATOR, new UserValidator(model, user)); } else { final PresentationModel model = new PresentationModel(new ValueHolder(user, true)); final DetailViewFormBuilder dfb = new DetailViewFormBuilder(new FormLayout("r:p, 3dlu, f:p:g"), //$NON-NLS-1$ Messages.getBundle(), this); dfb.getPanel().setName(Messages.getString("Settings_title")); //$NON-NLS-1$ dfb.appendI15d("User.givenName", BasicComponentFactory.createTextField( //$NON-NLS-1$ model.getModel("givenName"), //$NON-NLS-1$ true)); dfb.nextLine(); dfb.appendI15d("User.surname", BasicComponentFactory.createTextField(model //$NON-NLS-1$ .getModel("sn"), //$NON-NLS-1$ false)); dfb.nextLine(); // Set<Location> locations; // try { // locations = // realm.getDirectory(user.getClass().getName()).list(Location.class); // } catch (DirectoryException e) { // ErrorManager.getDefault().notify(e); // locations = new HashSet<Location>(); // } // dfb.appendI15d("User.location", //$NON-NLS-1$ // BasicComponentFactory.createComboBox(new SelectionInList(new ArrayList( // locations), model.getModel("location")))); //$NON-NLS-1$ // dfb.nextLine(); dfb.appendUnrelatedComponentsGapRow(); dfb.nextLine(); dfb.appendI15d("User.changePassword", BasicComponentFactory //$NON-NLS-1$ .createPasswordField(model.getModel("newPassword"), //$NON-NLS-1$ false)); dfb.nextLine(); dfb.appendI15d("User.verifyPassword", BasicComponentFactory //$NON-NLS-1$ .createPasswordField(model.getModel("verifyPassword"), //$NON-NLS-1$ false)); dfb.nextLine(); putClientProperty(DirObjectEditor.KEY_VALIDATOR, new UserValidator(model, user)); } }
From source file:repast.simphony.ui.RunOptionsPanel.java
public void init(RunOptionsModel optionsModel) { PresentationModel pModel = new PresentationModel(optionsModel); ValueModel model = pModel.getModel("pauseAt"); Bindings.bind(pauseAtFld, model); model = pModel.getModel("stopAt"); Bindings.bind(stopAtFld, model); model = pModel.getModel("sparklineLength"); Bindings.bind(sparklineLengthFld, model); sparklineLengthFld.setText("" + RunEnvironment.DEFAULT_SPARKLINE_LENGTH); model = pModel.getModel("sparklineType"); Bindings.bind(sparklineTypeFld, model); sparklineTypeFld.setSelected(RunEnvironment.DEFAULT_SPARKLINE_TYPE); pauseAtFld.addFocusListener(tempFocusCommitter); stopAtFld.addFocusListener(tempFocusCommitter); sparklineLengthFld.addFocusListener(tempFocusCommitter); model = pModel.getModel("scheduleTickDelay"); Bindings.addComponentPropertyHandler(slider1, model); slider1.setModel(new BoundedRangeAdapter(model, 0, 0, 100)); }