/** * @param commandTypes * @param partFactory * @param parent * @return true if start command area was created. False otherwise. */ protected boolean createStartCommandArea( List<StartCommandType> commandTypes, StartCommandPartFactory partFactory, Composite parent) { if (commandTypes.isEmpty()) { return false; } int columnNumber = commandTypes.size(); Composite buttonSelectionArea = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(columnNumber).applyTo(buttonSelectionArea); GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonSelectionArea); StartCommandType defaultStartCommandType = startCommand.getDefaultStartCommandType(); // Create radio buttons for each start command type, which // allows users to // toggle between the different start command for (StartCommandType commandType : commandTypes) { // If no default start command type was specified, make // the first one encountered // the default start command type if (defaultStartCommandType == null) { defaultStartCommandType = commandType; } final Button radio = new Button(buttonSelectionArea, SWT.RADIO); radio.setText(commandType.name()); radio.setToolTipText(commandType.getDescription()); radio.setData(commandType); boolean isSelected = commandType.equals(defaultStartCommandType); radio.setSelection(isSelected); radio.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (radio.getSelection()) { StartCommandType type = (StartCommandType) radio.getData(); makeStartCommandControlsVisible(type); StartCommandPart part = startCommandAreas.get(type); if (part != null) { part.updateStartCommand(); } } } }); } // Create the start command type UI whose visibility is // controlled by the radio button Composite startCompositeArea = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().numColumns(1).spacing(0, 0).applyTo(startCompositeArea); GridDataFactory.fillDefaults().grab(true, false).applyTo(startCompositeArea); for (StartCommandType commandType : commandTypes) { StartCommandPart commandPart = partFactory.createStartCommandTypePart(commandType, startCompositeArea); if (commandPart != null) { // Since the standalone part is a container of multiple // subparts, with only one subpart // ever visible at any given time, make sure the listener of any // part changes // (e.g, a wizard page) only receives ONE event originating from // the // container part, not from the individual // subparts. This is to avoid the listener from keeping track of // errors from non-visible subparts, as errors from non-visible // parts should // not prevent the completion of an operation, like deploying an // application. commandPart.addPartChangeListener(this); startCommandAreas.put(commandType, commandPart); } } // At this stage, at least one UI control has been created makeStartCommandControlsVisible(defaultStartCommandType); return true; }