/** * Prompts the user for a type from the specified class repository. Set the value of the specified * selection holder to the type selected by the user. This method will not "clear" the selection; * i.e. it will not set the value of the selectionHolder to null. The assumption is that once you * get here, you require a type to be selected. * * @param context The context ... * @param classRepository The repository used to retrieve the list of classes * @param selectionHolder The holder of the selected item if set, otherwise the value will remain * <code>null</code> */ public static void promptForType( WorkbenchContext context, ClassDescriptionRepository repository, PropertyValueModel selectionHolder) { try { context.getCurrentWindow().setCursor(CursorConstants.WAIT_CURSOR); // If the selection holder is not a SimplePropertyValueModel but a // PropertyAspectAdapter, we make sure it has a listener to it so that // the subject has been engaged and setValueFromSubject() is called PropertyChangeListener fakeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) {} }; selectionHolder.addPropertyChangeListener(PropertyValueModel.VALUE, fakeListener); ClassChooserDialog dialog = ClassChooserDialog.createDialog(repository, context); dialog.setVisible(true); if (dialog.wasConfirmed()) { selectionHolder.setValue(dialog.selection()); } selectionHolder.removePropertyChangeListener(PropertyValueModel.VALUE, fakeListener); } finally { context.getCurrentWindow().setCursor(CursorConstants.DEFAULT_CURSOR); } }
/** Initializes the layout of this pane. */ protected void initializeLayout() { GridBagConstraints constraints = new GridBagConstraints(); // Titled border TitledBorder border = new TitledBorder(""); PropertyValueModel displayStringAdapter = buildDisplayStringHolder(); displayStringAdapter.addPropertyChangeListener( PropertyValueModel.VALUE, buildDisplayStringListener(border)); border.setTitle( resourceRepository().getString("PROJECT_SESSIONS_LIST", displayStringAdapter.getValue())); setBorder( BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(0, 5, 5, 5))); // Sessions list AddRemoveListPanel interfacesListPanel = buildSessionListPane(); interfacesListPanel.setCellRenderer(buidlAddRemoveListCellRenderer()); constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(0, 0, 0, 0); add(interfacesListPanel, constraints); addPaneForAlignment(interfacesListPanel); }