/** * Nullified everything that was initialized. * * @throws Exception */ protected void tearDown() throws Exception { selectionHolder.setValue(null); nodeHolder.setValue(null); nodeHolder = null; selectionHolder = null; windowX = windowW = windowH = 0; super.tearDown(); }
/** * 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); } }