setInitialSelection()
selected.
*/
public static final int LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION = 3;
/**
* Constant specifying that a new launch configuration dialog was not opened. Instead
* an existing launch configuration dialog was used.
*/
public static final int LAUNCH_CONFIGURATION_DIALOG_REUSE_OPEN = 4;
/**
* defines the delimiter used in the persistence of the expanded state
* @since 3.2
*/
private static final String DELIMITER = ", "; //$NON-NLS-1$
/**
* Specifies how this dialog behaves when opened. Value is one of the
* 'LAUNCH_CONFIGURATION_DIALOG' constants defined in this class.
*/
private int fOpenMode = LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_LAST_LAUNCHED;
private boolean fIsShift = false;
/**
* dialog settings
*/
private static final String DIALOG_SASH_WEIGHTS_1 = IDebugUIConstants.PLUGIN_ID + ".DIALOG_SASH_WEIGHTS_1"; //$NON-NLS-1$
private static final String DIALOG_SASH_WEIGHTS_2 = IDebugUIConstants.PLUGIN_ID + ".DIALOG_SASH_WEIGHTS_2"; //$NON-NLS-1$
private static final String DIALOG_EXPANDED_NODES = IDebugUIConstants.PLUGIN_ID + ".EXPANDED_NODES"; //$NON-NLS-1$
/**
* Returns the currently visible dialog
* @return the currently visible launch dialog
*/
public static ILaunchConfigurationDialog getCurrentlyVisibleLaunchConfigurationDialog() {
return fgCurrentlyVisibleLaunchConfigurationDialog;
}
/**
* Sets which launch dialog is currently the visible one
* @param dialog the dialog to set as the visible one
*/
public static void setCurrentlyVisibleLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) {
fgCurrentlyVisibleLaunchConfigurationDialog = dialog;
}
/**
* widgets
*/
private Control fLastControl;
private Composite fButtonComp;
private SashForm fSashForm;
private LaunchConfigurationView fLaunchConfigurationView;
private LaunchConfigurationTabGroupViewer fTabViewer;
private ProgressMonitorPart fProgressMonitorPart;
private LaunchGroupExtension fGroup;
private Image fBannerImage;
/**
* When this dialog is opened in LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_SELECTION
* mode, this specifies the selection that is initially shown in the dialog.
*/
private IStructuredSelection fInitialSelection;
/**
* The status to open the dialog on, or null
if none.
*/
private IStatus fInitialStatus;
/**
* The number of 'long-running' operations currently taking place in this dialog
*/
private long fActiveRunningOperations = 0;
/**
* Double-click action
*/
private IAction fDoubleClickAction;
/**
* Filters for the LCD
* @since 3.2
*/
private ClosedProjectFilter fClosedProjectFilter;
private DeletedProjectFilter fDeletedProjectFilter;
private LaunchConfigurationTypeFilter fLCTFilter;
private WorkingSetsFilter fWorkingSetsFilter;
/**
* set of reserved names that should not be considered when generating a new name for a launch configuration
*/
protected SetDialog
*
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
*/
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == ID_LAUNCH_BUTTON) {
handleLaunchPressed();
}
else if (buttonId == ID_CLOSE_BUTTON) {
handleClosePressed();
}
else {
super.buttonPressed(buttonId);
}
}
/**
* Return whether the current configuration should be saved or discarded. This involves determining
* if it is dirty, and if it is, asking the user what to do.
*
* @return if we can discard the current config or not
*/
protected int shouldSaveCurrentConfig() {
if (fTabViewer.isDirty()) {
if (fTabViewer.canSave()) {
return showSaveChangesDialog();
}
return showUnsavedChangesDialog();
}
return IDialogConstants.NO_ID;
}
@Override
public boolean close() {
if (!isSafeToClose()) {
return false;
}
persistSashWeights();
persistExpansion();
setCurrentlyVisibleLaunchConfigurationDialog(null);
fTabViewer.dispose();
if (fLaunchConfigurationView != null) {
fLaunchConfigurationView.dispose();
}
DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
boolean result = super.close();
getBannerImage().dispose();
return result;
}
/**
* Sets the title for the dialog, and establishes the help context.
*
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell);
*/
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText(getShellTitle());
}
@Override
public void create() {
super.create();
if (fTabViewer.getInput() == null) {
fTabViewer.inputChanged(null);
}
}
@Override
protected Control createButtonBar(Composite parent) {
Font font = parent.getFont();
Composite composite = new Composite(parent, SWT.NULL);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight= 0;
layout.marginWidth= 0;
layout.marginLeft = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
composite.setFont(font);
// create help control if needed
if (isHelpAvailable()) {
createHelpControl(composite);
}
Composite monitorComposite = new Composite(composite, SWT.NULL);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 2;
monitorComposite.setLayout(layout);
monitorComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridLayout pmLayout = new GridLayout();
fProgressMonitorPart= new ProgressMonitorPart(monitorComposite, pmLayout, true);
fProgressMonitorPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fProgressMonitorPart.setFont(font);
monitorComposite.setVisible(false);
/*
* Create the rest of the button bar, but tell it not to
* create a help button (we've already created it).
*/
boolean helpAvailable = isHelpAvailable();
setHelpAvailable(false);
fButtonComp = (Composite) super.createButtonBar(composite);
setHelpAvailable(helpAvailable);
return composite;
}
/**
*
* @param buttonId
*/
protected void launchButtonPressed(int buttonId) {
if (buttonId == ID_LAUNCH_BUTTON) {
handleLaunchPressed();
} else if (buttonId == ID_CLOSE_BUTTON) {
handleClosePressed();
} else {
super.buttonPressed(buttonId);
}
}
/**
* A launch configuration dialog overrides this method
* to create a custom set of buttons in the button bar.
* This dialog has 'Launch' and 'Cancel'
* buttons.
*
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createButtonsForButtonBar(Composite parent) {
Button button = createButton(parent, ID_LAUNCH_BUTTON, getLaunchButtonText(), true);
button.setEnabled(false);
Listener[] listeners = button.getListeners(SWT.Selection);
for (Listener listener : listeners) {
button.removeListener(SWT.Selection, listener);
}
listeners = button.getListeners(SWT.DefaultSelection);
for (Listener listener : listeners) {
button.removeListener(SWT.DefaultSelection, listener);
}
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
setShift(((event.stateMask & SWT.SHIFT) > 0) ? true : false);
handleLaunchPressed();
}
});
createButton(parent, ID_CLOSE_BUTTON, LaunchConfigurationsMessages.LaunchConfigurationDialog_Close_1, false);
}
@Override
protected Control createContents(Composite parent) {
Control contents = super.createContents(parent);
initializeContent();
PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), getHelpContextId());
return contents;
}
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogComp = (Composite)super.createDialogArea(parent);
addContent(dialogComp);
if(fLaunchConfigurationView != null) {
fLaunchConfigurationView.updateFilterLabel();
}
return dialogComp;
}
/**
* Creates the launch configuration edit area of the dialog.
* This area displays the name of the launch configuration
* currently being edited, as well as a tab folder of tabs
* that are applicable to the launch configuration.
*
* @return the composite used for launch configuration editing
*/
protected Composite createLaunchConfigurationEditArea(Composite parent) {
setTabViewer(new LaunchConfigurationTabGroupViewer(parent, this));
return (Composite)fTabViewer.getControl();
}
/**
* Creates all of the actions for the toolbar
* @param toolbar
* @since 3.2
*/
protected void createToolbarActions(ToolBarManager tmanager) {
tmanager.add(getNewAction());
tmanager.add(getNewPrototypeAction());
tmanager.add(getExportAction());
tmanager.add(getDuplicateAction());
tmanager.add(getDeleteAction());
tmanager.add(new Separator());
tmanager.add(getCollapseAllAction());
tmanager.add(getFilterAction());
tmanager.update(true);
DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
}
protected void setShift(boolean isShift) {
fIsShift = isShift;
}
/**
* Creates the launch configuration selection area of the dialog.
* This area displays a tree of launch configurations that the user
* may select, and allows users to create new configurations, and
* delete and duplicate existing configurations.
*
* @return the composite used for launch configuration selection area
*/
protected Control createLaunchConfigurationSelectionArea(Composite parent) {
Composite comp = new Composite(parent, SWT.FLAT);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
comp.setLayout(gridLayout);
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
ViewForm viewForm = new ViewForm(comp, SWT.FLAT | SWT.BORDER);
ToolBarManager toolBarManager= new ToolBarManager(SWT.FLAT);
ToolBar toolBar = toolBarManager.createControl(viewForm);
toolBar.setBackground(parent.getBackground());
viewForm.setTopLeft(toolBar);
viewForm.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite viewFormContents = new Composite(viewForm, SWT.FLAT);
gridLayout = new GridLayout();
gridLayout.marginHeight = 5;
gridLayout.marginWidth = 5;
viewFormContents.setLayout(gridLayout);
viewFormContents.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
fLaunchConfigurationView = new LaunchConfigurationView(getLaunchGroup(), createViewerFilters());
fLaunchConfigurationView.createLaunchDialogControl(viewFormContents);
Text filterText = fLaunchConfigurationView.getFilteringTextControl();
if (filterText != null){
filterText.setFocus();
}
//create toolbar actions, we reuse the actions from the view so we wait until after
//the view is created to add them to the toolbar
createToolbarActions(toolBarManager);
fDoubleClickAction = new Action() {
@Override
public void run() {
runInternal(false);
}
@Override
public void runWithEvent(Event event) {
runInternal(((event.stateMask & SWT.SHIFT) > 0) ? true : false);
}
void runInternal(boolean isShift) {
IStructuredSelection selection = (IStructuredSelection)fLaunchConfigurationView.getViewer().getSelection();
Object target = selection.getFirstElement();
if (target instanceof ILaunchConfiguration) {
if (fTabViewer.canLaunch() & fTabViewer.canLaunchWithModes() & !fTabViewer.hasDuplicateDelegates()) {
setShift(isShift);
handleLaunchPressed();
}
} else {
getNewAction().run();
}
}
};
fLaunchConfigurationView.setAction(IDebugView.DOUBLE_CLICK_ACTION, fDoubleClickAction);
Viewer viewer = fLaunchConfigurationView.getViewer();
Control control = viewer.getControl();
GridData gd = new GridData(GridData.FILL_BOTH);
control.setLayoutData(gd);
viewForm.setContent(viewFormContents);
AbstractLaunchConfigurationAction.IConfirmationRequestor requestor = new AbstractLaunchConfigurationAction.IConfirmationRequestor() {
@Override
public boolean getConfirmation() {
int status = shouldSaveCurrentConfig();
if(status == IDialogConstants.YES_ID) {
fTabViewer.handleApplyPressed();
return true;
}
else if(status == IDialogConstants.NO_ID) {
fTabViewer.handleRevertPressed();
return true;
}
return false;
}
};
getDuplicateAction().setConfirmationRequestor(requestor);
getExportAction().setConfirmationRequestor(requestor);
getNewAction().setConfirmationRequestor(requestor);
getNewPrototypeAction().setConfirmationRequestor(requestor);
getLinkPrototypeAction().setConfirmationRequestor(requestor);
getUnlinkPrototypeAction().setConfirmationRequestor(requestor);
getResetWithPrototypeValuesAction().setConfirmationRequestor(requestor);
((StructuredViewer) viewer).addPostSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
handleLaunchConfigurationSelectionChanged(event);
getNewAction().setEnabled(getNewAction().isEnabled());
getNewPrototypeAction().setEnabled(getNewPrototypeAction().isEnabled());
getDeleteAction().setEnabled(getDeleteAction().isEnabled());
getExportAction().setEnabled(getExportAction().isEnabled());
getDuplicateAction().setEnabled(getDuplicateAction().isEnabled());
getLinkPrototypeAction().setEnabled(getLinkPrototypeAction().isEnabled());
getUnlinkPrototypeAction().setEnabled(getUnlinkPrototypeAction().isEnabled());
getResetWithPrototypeValuesAction().setEnabled(getResetWithPrototypeValuesAction().isEnabled());
}
});
return comp;
}
/**
* Create the filters to be initially applied to the viewer.
* The initial filters are based on the persisted preferences
* @return the array of initial filters
* @since 3.2
*/
private ViewerFilter[] createViewerFilters() {
ArrayListgetDialogSettingsSectionName()
.
*
* @return IDialogSettings
*/
protected IDialogSettings getDialogSettings() {
IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings();
IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
if (section == null) {
section = settings.addNewSection(getDialogSettingsSectionName());
}
return section;
}
/**
* Returns the name of the section that this dialog stores its settings in
*
* @return String
*/
protected String getDialogSettingsSectionName() {
return IDebugUIConstants.PLUGIN_ID + ".LAUNCH_CONFIGURATIONS_DIALOG_SECTION"; //$NON-NLS-1$
}
/**
* Gets the current display
*
* @return the display
*/
protected Display getDisplay() {
Shell shell = getShell();
if (shell != null) {
return shell.getDisplay();
}
return DebugUIPlugin.getStandardDisplay();
}
/**
* Gets the duplicate menu action
*
* @return the duplicate menu action
*/
protected AbstractLaunchConfigurationAction getDuplicateAction() {
return (AbstractLaunchConfigurationAction)fLaunchConfigurationView.getAction(DuplicateLaunchConfigurationAction.ID_DUPLICATE_ACTION);
}
/**
* Gets the export menu action
*
* @return the export menu action
*/
protected AbstractLaunchConfigurationAction getExportAction() {
return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(ExportLaunchConfigurationAction.ID_EXPORT_ACTION);
}
/**
* Gets the help context id
*
* @return the help context id
*/
protected String getHelpContextId() {
return IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG;
}
/**
* Returns the status the dialog was opened on or null
if none.
*
* @return IStatus
*/
protected IStatus getInitialStatus() {
return fInitialStatus;
}
/**
* Return the last launched configuration in the workspace.
*
* @return the last launched configuration
*/
protected ILaunchConfiguration getLastLaunchedWorkbenchConfiguration() {
return DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLastLaunch(getLaunchGroup().getIdentifier());
}
/**
* Returns the appropriate text for the launch button - run or debug.
*
* @return the launch button text
*/
protected String getLaunchButtonText() {
return DebugPlugin.getDefault().getLaunchManager().getLaunchMode(getMode()).getLabel();
}
/**
* Returns the launch group being displayed.
*
* @return launch group
*/
public LaunchGroupExtension getLaunchGroup() {
return fGroup;
}
@Override
public String getMode() {
return getLaunchGroup().getMode();
}
/**
* Gets the new menu action
*
* @return the new menu action
*/
protected AbstractLaunchConfigurationAction getNewAction() {
return (AbstractLaunchConfigurationAction)fLaunchConfigurationView.getAction(CreateLaunchConfigurationAction.ID_CREATE_ACTION);
}
/**
* Gets the new prototype menu action
*
* @return the new prototype menu action
*
* @since 3.13
*/
protected AbstractLaunchConfigurationAction getNewPrototypeAction() {
return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(CreateLaunchConfigurationPrototypeAction.ID_CREATE_PROTOTYPE_ACTION);
}
/**
* Gets the link prototype menu action
*
* @return the link prototype menu action
*
* @since 3.13
*/
protected AbstractLaunchConfigurationAction getLinkPrototypeAction() {
return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(LinkPrototypeAction.ID_LINK_PROTOTYPE_ACTION);
}
/**
* Gets the unlink prototype menu action
*
* @return the unlink prototype menu action
*
* @since 3.13
*/
protected AbstractLaunchConfigurationAction getUnlinkPrototypeAction() {
return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(UnlinkPrototypeAction.ID_UNLINK_PROTOTYPE_ACTION);
}
/**
* Gets the reset with prototype values menu action
*
* @return the reset with prototype values menu action
*
* @since 3.13
*/
protected AbstractLaunchConfigurationAction getResetWithPrototypeValuesAction() {
return (AbstractLaunchConfigurationAction) fLaunchConfigurationView.getAction(ResetWithPrototypeValuesAction.ID_RESET_WITH_PROTOTYPE_VALUES_ACTION);
}
/**
* Returns the reserved name set (if there is one), null
otherwise
* @return the reserved name set or null
* @since 3.3
*
*/
public Setnull
if none
*/
public ILaunchConfigurationTabGroup getTabGroup() {
if (fTabViewer != null) {
return fTabViewer.getTabGroup();
}
return null;
}
@Override
public ILaunchConfigurationTab[] getTabs() {
if (getTabGroup() == null) {
return null;
}
return getTabGroup().getTabs();
}
/**
* Returns the viewer used to display the tabs for a launch configuration.
*
* @return LaunchConfigurationTabGroupViewer
*/
public LaunchConfigurationTabGroupViewer getTabViewer() {
return fTabViewer;
}
/**
* Notification the 'Close' button has been pressed.
*/
protected void handleClosePressed() {
if(fTabViewer.canSave()) {
int status = shouldSaveCurrentConfig();
if(status != IDialogConstants.CANCEL_ID) {
if(status != ID_DISCARD_BUTTON) {
if(status == IDialogConstants.YES_ID) {
fTabViewer.handleApplyPressed();
}
cancelPressed();
}
}
}
else {
cancelPressed();
}
}
/**
* Notification that selection has changed in the launch configuration tree.
* * If the currently displayed configuration is not saved, * prompt for saving before moving on to the new selection. *
* * @param event selection changed event */ protected void handleLaunchConfigurationSelectionChanged(SelectionChangedEvent event) { Object input = fTabViewer.getInput(); Object newInput = null; IStructuredSelection selection = event.getStructuredSelection(); if (selection.size() == 1) { newInput = selection.getFirstElement(); } if (!isEqual(input, newInput)) { ILaunchConfiguration original = fTabViewer.getOriginal(); if (original != null && newInput == null && getLaunchManager().getMovedTo(original) != null) { return; } boolean deleted = false; if (original != null) { deleted = !original.exists(); } boolean renamed = false; if (newInput instanceof ILaunchConfiguration) { renamed = getLaunchManager().getMovedFrom((ILaunchConfiguration)newInput) != null; } try { fSettingInput = true; if (fTabViewer.canSave() && fTabViewer.isDirty() && !deleted && !renamed) { if(fLaunchConfigurationView != null) { fLaunchConfigurationView.setAutoSelect(false); } int ret = showUnsavedChangesDialog(); if(ret == IDialogConstants.YES_ID) { fTabViewer.handleApplyPressed(); ILaunchConfigurationTab[] tabs = getTabs(); if (tabs != null) { for (ILaunchConfigurationTab tab : tabs) { tab.postApply(); } } fTabViewer.setInput(newInput); } else if(ret == IDialogConstants.NO_ID) { fTabViewer.handleRevertPressed(); fTabViewer.setInput(newInput); } else { fLaunchConfigurationView.getViewer().setSelection(new StructuredSelection(input)); } fLaunchConfigurationView.setAutoSelect(true); } else { fTabViewer.setInput(newInput); if(fTabViewer.isDirty()) { fTabViewer.handleApplyPressed(); } } } finally { fSettingInput = false; updateButtons(); updateMessage(); } if(getShell() != null && getShell().isVisible()) { resize(); } } } /** * Notification the 'launch' button has been pressed. Save and launch. * */ protected void handleLaunchPressed() { ILaunchConfiguration config = fTabViewer.getOriginal(); if (fTabViewer.isDirty() && fTabViewer.canSave()) { config = fTabViewer.handleApplyPressed(); } if(config != null) { close(); DebugUITools.launch(config, getMode(), fIsShift); } setShift(false); } /** * Consult a status handler for the given status, if any. The status handler * is passed this launch config dialog as an argument. * * @param status the status to be handled */ public void handleStatus(IStatus status) { IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status); if (handler != null) { try { handler.handleStatus(status, this); return; } catch (CoreException e) {status = e.getStatus();} } // if no handler, or handler failed, display error/warning dialog String title = null; switch (status.getSeverity()) { case IStatus.ERROR: title = LaunchConfigurationsMessages.LaunchConfigurationsDialog_Error_1; break; case IStatus.WARNING: title = LaunchConfigurationsMessages.LaunchConfigurationsDialog_Warning_2; break; default: title = LaunchConfigurationsMessages.LaunchConfigurationsDialog_Information_3; break; } ErrorDialog.openError(getShell(), title, null, status); } @Override protected void initializeBounds() { IDialogSettings settings = getDialogSettings(); if (fSashForm != null) { int w1, w2; try { w1 = settings.getInt(DIALOG_SASH_WEIGHTS_1); if(w1 < 10) { w1 = DEFAULT_SASH_WEIGHTS[0]; } w2 = settings.getInt(DIALOG_SASH_WEIGHTS_2); if(w2 < 10) { w2 = DEFAULT_SASH_WEIGHTS[1]; } } catch(NumberFormatException nfe) { w1 = DEFAULT_SASH_WEIGHTS[0]; w2 = DEFAULT_SASH_WEIGHTS[1]; } fSashForm.setWeights(new int[] {w1, w2}); } super.initializeBounds(); } @Override protected Point getInitialSize() { try { getDialogSettings().getInt("DIALOG_HEIGHT"); //$NON-NLS-1$ return super.getInitialSize(); } catch(NumberFormatException nfe) { return DEFAULT_INITIAL_DIALOG_SIZE; } } /** * Sets the default values for the given {@link LaunchConfigurationWorkingCopy} * @param wc * @since 3.6 */ protected void doSetDefaults(ILaunchConfigurationWorkingCopy wc) { try { ILaunchConfigurationTabGroup tabGroup = LaunchConfigurationPresentationManager.getDefault().getTabGroup(wc, getMode()); // this only works because this action is only present when the dialog is open ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog(); tabGroup.createTabs(dialog, dialog.getMode()); ILaunchConfigurationTab[] tabs = tabGroup.getTabs(); for (int i = 0; i < tabs.length; i++) { tabs[i].setLaunchConfigurationDialog(dialog); } tabGroup.setDefaults(wc); tabGroup.dispose(); } catch (CoreException e) { DebugUIPlugin.log(e.getStatus()); } } /** * Performs initialization of the content by setting the initial tree selection */ protected void initializeContent() { if(fSetDefaultOnOpen) { try { Object o = fInitialSelection.getFirstElement(); if(o instanceof ILaunchConfigurationWorkingCopy) { ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) o; doSetDefaults(wc); setInitialSelection(new StructuredSelection(wc.doSave())); } } catch (CoreException e) { DebugUIPlugin.log(e); } } doInitialTreeSelection(); IStatus status = getInitialStatus(); if (status != null) { handleStatus(status); } restoreExpansion(); } /** * Compares two objects to determine their equality * * @param o1 the first object * @param o2 the object to compare to object one * @return true if they are equal, false if object 1 is null, the result of o1.equals(o2) otherwise */ protected boolean isEqual(Object o1, Object o2) { if (o1 == o2) { return true; } else if (o1 == null) { return false; } else { return o1.equals(o2); } } /** * Returns whether the dialog can be closed * * @return whether the dialog can be closed */ protected boolean isSafeToClose() { return fActiveRunningOperations == 0; } /** * Determine the initial configuration for this dialog. * Open the dialog in the mode set using #setOpenMode(int) and return one of *Window. OK
or Window.CANCEL
.
*
* @see org.eclipse.jface.window.Window#open()
* @return the int status of opening the dialog
*/
@Override
public int open() {
int mode = getOpenMode();
setCurrentlyVisibleLaunchConfigurationDialog(this);
if (mode == LAUNCH_CONFIGURATION_DIALOG_OPEN_ON_LAST_LAUNCHED) {
ILaunchConfiguration lastLaunchedConfig = getLastLaunchedWorkbenchConfiguration();
if (lastLaunchedConfig != null) {
setInitialSelection(new StructuredSelection(lastLaunchedConfig));
}
}
return super.open();
}
/**
* saves which of the nodes are expanded at the time the dialog is closed
* @since 3.2
*/
protected void persistExpansion() {
if(fLaunchConfigurationView != null) {
IDialogSettings settings = getDialogSettings();
TreeItem[] items = fLaunchConfigurationView.getTreeViewer().getTree().getItems();
String value = settings.get(DIALOG_EXPANDED_NODES);
if(value == null) {
value = IInternalDebugCoreConstants.EMPTY_STRING;
}
ArrayList