/** 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); }
/** * 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); } }
/** * 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(); }
protected SCAdapter getSelection() { return (SCAdapter) selectionHolder.getValue(); }
protected Component buildPage() { JPanel contentPanel = new JPanel(new GridBagLayout()); contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); GridBagConstraints constraints = new GridBagConstraints(); // Read subclasses check box readSubclassesOnQueryHolder = buildReadSubclassesOnQueryBooleanHolder(); JCheckBox readSubclassOnQueryCheckBox = buildCheckBox( "READ_SUBCLASSES_ON_QUERY", new CheckBoxModelAdapter(readSubclassesOnQueryHolder)); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.LINE_START; constraints.insets = new Insets(0, 5, 0, 0); contentPanel.add(readSubclassOnQueryCheckBox, constraints); addHelpTopicId(readSubclassOnQueryCheckBox, helpTopicId() + ".readSubclassesView"); Collection components = new ArrayList(); // Read subclasses check box sub panel JPanel readSubclassOnQueryPanel = new JPanel(new BorderLayout()); readSubclassOnQueryPanel.setEnabled(readSubclassesOnQueryHolder.getValue() == Boolean.TRUE); ListChooser viewChooser = buildViewChooser(); components.add(viewChooser); JLabel viewLabel = buildLabel("READ_SUBCLASSES_VIEW_OPTIONAL"); viewLabel.setDisplayedMnemonic( resourceRepository().getMnemonic("READ_SUBCLASSES_VIEW_OPTIONAL")); components.add(viewLabel); viewLabel.setLabelFor(viewChooser); readSubclassOnQueryPanel.add(viewChooser, BorderLayout.CENTER); readSubclassOnQueryPanel.add(viewLabel, BorderLayout.LINE_START); addHelpTopicId(readSubclassOnQueryPanel, helpTopicId() + ".readSubclassesView"); Insets borderInsets = BorderFactory.createTitledBorder("m").getBorderInsets(this); constraints.gridx = 0; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(0, SwingTools.checkBoxIconWidth() + 5, 0, borderInsets.right + 5); contentPanel.add(readSubclassOnQueryPanel, constraints); new ComponentEnabler(readSubclassesOnQueryHolder, components); // outer join all subclasses check box outerJoinAllSubclassesHolder = buildOuterJoinAllSubclassesBooleanHolder(); JCheckBox outerJoinAllSubclassCheckBox = buildCheckBox( "OUTER_JOIN_ALL_SUBCLASSES", new CheckBoxModelAdapter(outerJoinAllSubclassesHolder)); constraints.gridx = 0; constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.LINE_START; constraints.insets = new Insets(0, 5, 0, 0); contentPanel.add(outerJoinAllSubclassCheckBox, constraints); addHelpTopicId(outerJoinAllSubclassCheckBox, helpTopicId() + ".outerJoinAllSubclasses"); // Is Child widgets JRadioButton isChildRadioButton = buildRadioButton( "IS_CHILD_DESC", buildIsChildDescriptorRadioButtonModel(getIsRootHolder())); addHelpTopicId(isChildRadioButton, helpTopicId() + ".isChild"); JPanel isChildPanel = buildIsChildPanel(getIsRootHolder().getValue() == Boolean.FALSE); getIsRootHolder().addPropertyChangeListener(buildIsChildListener(isChildPanel)); addHelpTopicId(isChildPanel, helpTopicId() + ".isChild"); // Is Root widgets JRadioButton isRootRadioButton = buildRadioButton( "IS_ROOT_DESC", buildIsRootParentDescriptorRadioButtonModel(getIsRootHolder())); addHelpTopicId(isRootRadioButton, helpTopicId() + ".isRoot"); Collection isRootListeners = new Vector(); JPanel isRootPanel = buildIsRootPanel(isRootListeners); isRootListeners.add(classIndicatorPolicyPanel); // Add everything to the container GroupBox isRootGroupBox = new GroupBox( isChildRadioButton, isChildPanel, isRootRadioButton, isRootPanel); constraints.gridx = 0; constraints.gridy = 4; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.PAGE_START; constraints.insets = new Insets(5, 0, 0, 0); contentPanel.add(isRootGroupBox, constraints); addHelpTopicId(getClassIndicatorPolicyPanel(), helpTopicId() + ".isRoot"); addHelpTopicId(contentPanel, helpTopicId()); addAllRootListeners(isRootListeners); return contentPanel; }