diff options
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug')
5 files changed, 304 insertions, 284 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java index cab7c4ff8..1e92b1fc7 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTUtil.java @@ -23,8 +23,12 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; /** * Utility class to simplify access to some SWT resources. @@ -105,6 +109,64 @@ public class SWTUtil { } /** + * Creates a new label widget + * @param parent the parent composite to add this label widget to + * @param text the text for the label + * @param hspan the horizontal span to take up in the parent composite + * @return the new label + * @since 3.2 + * + */ + public static Label createLabel(Composite parent, String text, int hspan) { + Label l = new Label(parent, SWT.NONE); + l.setFont(parent.getFont()); + l.setText(text); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = hspan; + l.setLayoutData(gd); + return l; + } + + /** + * Creates a new text widget + * @param parent the parent composite to add this text widget to + * @param hspan the horizontal span to take up on the parent composite + * @return the new text widget + * @since 3.2 + * + */ + public static Text createSingleText(Composite parent, int hspan) { + Text t = new Text(parent, SWT.SINGLE | SWT.BORDER); + t.setFont(parent.getFont()); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = hspan; + t.setLayoutData(gd); + return t; + } + + /** + * Creates a Group widget + * @param parent the parent composite to add this group to + * @param text the text for the heading of the group + * @param columns the number of columns within the group + * @param hspan the horizontal span the group should take up on the parent + * @param fill the style for how this composite should fill into its parent + * @return the new group + * @since 3.2 + * + */ + public static Group createGroup(Composite parent, String text, int columns, int hspan, int fill) { + Group g = new Group(parent, SWT.NONE); + g.setLayout(new GridLayout(columns, false)); + g.setText(text); + g.setFont(parent.getFont()); + GridData gd = new GridData(fill); + gd.horizontalSpan = hspan; + g.setLayoutData(gd); + return g; + } + + /** * This method allows us to open the preference dialog on the specific page, in this case the perspective page * @param id the id of pref page to show * @param page the actual page to show diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java index 40ccc96a0..08a9d2efc 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java @@ -70,6 +70,7 @@ import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.ViewForm; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties index feb530d01..b815bb8c2 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties @@ -37,7 +37,7 @@ CommonTab_9=Variable&s... CompileErrorPromptStatusHandler_0=Errors in Project CompileErrorPromptStatusHandler_1=Errors exist in a required project. Continue launch? CompileErrorPromptStatusHandler_2=Errors exist in required project(s): {0}.\nContinue launch? -CompileErrorProjectPromptStatusHandler_0=Always +CompileErrorProjectPromptStatusHandler_0=&Always EnvironmentTab_22=New Environment Variable diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java index 55b80e941..7ac47ca0b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java @@ -33,6 +33,8 @@ import org.eclipse.swt.widgets.Shell; * </p> * @see ILaunchConfigurationTab * @since 2.0 + * + * @TODO Add in accessor methods for createGroup, createLabel and createSingleText from SWTUtil post 3.2 API freeze */ public abstract class AbstractLaunchConfigurationTab implements ILaunchConfigurationTab { diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java index abb3a00ce..9302e49aa 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,8 +17,10 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; + import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; @@ -32,11 +34,11 @@ import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.internal.ui.DebugUIPlugin; import org.eclipse.debug.internal.ui.IDebugHelpContextIds; import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.SWTUtil; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsMessages; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchGroupExtension; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.CheckStateChangedEvent; @@ -61,7 +63,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.WorkbenchEncoding; @@ -82,16 +83,25 @@ import org.eclipse.ui.views.navigator.ResourceSorter; * @since 2.0 */ public class CommonTab extends AbstractLaunchConfigurationTab { - + + private static final String EMPTY_STRING = ""; //$NON-NLS-1$ + // Local/shared UI widgets private Button fLocalRadioButton; private Button fSharedRadioButton; - - // Shared location UI widgets private Text fSharedLocationText; private Button fSharedLocationButton; - - protected Button fLaunchInBackgroundButton; + private Button fLaunchInBackgroundButton; + private Button fDefaultEncodingButton; + private Button fAltEncodingButton; + private Combo fEncodingCombo; + private Button fConsoleOutput; + private Button fFileOutput; + private Button fFileBrowse; + private Text fFileText; + private Button fVariables; + private Button fAppend; + private Button fWorkspaceBrowse; /** * Check box list for specifying favorites @@ -102,25 +112,11 @@ public class CommonTab extends AbstractLaunchConfigurationTab { * Modify listener that simply updates the owning launch configuration dialog. */ private ModifyListener fBasicModifyListener = new ModifyListener() { - public void modifyText(ModifyEvent evt) { - updateLaunchConfigurationDialog(); - } + public void modifyText(ModifyEvent evt) { + updateLaunchConfigurationDialog(); + } }; - - // Console Encoding widgets - private Button fDefaultEncodingButton; - private Button fAltEncodingButton; - private Combo fEncodingCombo; - // Console Output widgets - private Button fConsoleOutput; - private Button fFileOutput; - private Button fFileBrowse; - private Text fFileText; - private Button fVariables; - private Button fAppend; - private Button fWorkspaceBrowse; - /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) */ @@ -128,99 +124,78 @@ public class CommonTab extends AbstractLaunchConfigurationTab { Composite comp = new Composite(parent, SWT.NONE); setControl(comp); PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_COMMON_TAB); - GridLayout topLayout = new GridLayout(2, true); - topLayout.horizontalSpacing = 10; - comp.setLayout(topLayout); + comp.setLayout(new GridLayout(2, true)); comp.setFont(parent.getFont()); - Group group = new Group(comp, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.numColumns = 3; - group.setLayout(layout); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - group.setLayoutData(gd); - group.setText(LaunchConfigurationsMessages.CommonTab_0); - group.setFont(comp.getFont()); - - setLocalRadioButton(new Button(group, SWT.RADIO)); - getLocalRadioButton().setText(LaunchConfigurationsMessages.CommonTab_L_ocal_3); - gd = new GridData(); + createSharedConfigComponent(comp); + createFavoritesComponent(comp); + createEncodingComponent(comp); + createOutputCaptureComponent(comp); + createLaunchInBackgroundComponent(comp); + } + + /** + * Creates the favorites control + * @param parent the parent composite to add this one to + * @since 3.2 + */ + private void createFavoritesComponent(Composite parent) { + Group favComp = SWTUtil.createGroup(parent, LaunchConfigurationsMessages.CommonTab_Display_in_favorites_menu__10, 1, 1, GridData.FILL_BOTH); + fFavoritesTable = CheckboxTableViewer.newCheckList(favComp, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); + Control table = fFavoritesTable.getControl(); + GridData gd = new GridData(GridData.FILL_BOTH); + table.setLayoutData(gd); + table.setFont(parent.getFont()); + fFavoritesTable.setContentProvider(new FavoritesContentProvider()); + fFavoritesTable.setLabelProvider(new FavoritesLabelProvider()); + fFavoritesTable.addCheckStateListener(new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + updateLaunchConfigurationDialog(); + } + }); + } + + /** + * Creates the shared config component + * @param parent the parent composite to add this component to + * @since 3.2 + */ + private void createSharedConfigComponent(Composite parent) { + Group group = SWTUtil.createGroup(parent, LaunchConfigurationsMessages.CommonTab_0, 3, 2, GridData.FILL_HORIZONTAL); + fLocalRadioButton = createRadioButton(group, LaunchConfigurationsMessages.CommonTab_L_ocal_3); + GridData gd = new GridData(); gd.horizontalSpan = 3; - getLocalRadioButton().setLayoutData(gd); - setSharedRadioButton(new Button(group, SWT.RADIO)); - getSharedRadioButton().setText(LaunchConfigurationsMessages.CommonTab_S_hared_4); - getSharedRadioButton().addSelectionListener(new SelectionAdapter() { + fLocalRadioButton.setLayoutData(gd); + fSharedRadioButton = createRadioButton(group, LaunchConfigurationsMessages.CommonTab_S_hared_4); + fSharedRadioButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { handleSharedRadioButtonSelected(); } }); - gd = new GridData(); - getSharedRadioButton().setLayoutData(gd); - - setSharedLocationText(new Text(group, SWT.SINGLE | SWT.BORDER)); - gd = new GridData(GridData.FILL_HORIZONTAL); - getSharedLocationText().setLayoutData(gd); - getSharedLocationText().addModifyListener(fBasicModifyListener); - - setSharedLocationButton(createPushButton(group, LaunchConfigurationsMessages.CommonTab__Browse_6, null)); - getSharedLocationButton().addSelectionListener(new SelectionAdapter() { + fSharedLocationText = SWTUtil.createSingleText(group, 1); + fSharedLocationText.addModifyListener(fBasicModifyListener); + fSharedLocationButton = createPushButton(group, LaunchConfigurationsMessages.CommonTab__Browse_6, null); + fSharedLocationButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { handleSharedLocationButtonSelected(); } }); - getLocalRadioButton().setSelection(true); - setSharedEnabled(false); - - Group favComp = new Group(comp, SWT.NONE); - gd = new GridData(GridData.FILL_BOTH); - favComp.setLayoutData(gd); - GridLayout favLayout = new GridLayout(); - favComp.setLayout(favLayout); - - favComp.setText(LaunchConfigurationsMessages.CommonTab_Display_in_favorites_menu__10); - favComp.setFont(parent.getFont()); - - fFavoritesTable = CheckboxTableViewer.newCheckList(favComp, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); - Control table = fFavoritesTable.getControl(); - gd = new GridData(GridData.FILL_BOTH); - table.setLayoutData(gd); - - fFavoritesTable.setContentProvider(new FavoritesContentProvider()); - fFavoritesTable.setLabelProvider(new FavoritesLabelProvider()); - fFavoritesTable.addCheckStateListener( - new ICheckStateListener() { - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) - */ - public void checkStateChanged(CheckStateChangedEvent event) { - updateLaunchConfigurationDialog(); - } - }); - - createEncodingComponent(comp); - createOutputCaptureComponent(comp); - createLaunchInBackgroundComponent(comp); - - Dialog.applyDialogFont(parent); + fLocalRadioButton.setSelection(true); + setSharedEnabled(false); } + /** + * Creates the component set for the capture output composite + * @param parent the parent to add this component to + */ private void createOutputCaptureComponent(Composite parent) { - Group group = new Group(parent, SWT.NONE); - group.setText(LaunchConfigurationsMessages.CommonTab_4); - GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false); - gd.horizontalSpan = 2; - group.setLayoutData(gd); - GridLayout layout = new GridLayout(5, false); - group.setLayout(layout); - group.setFont(parent.getFont()); + Group group = SWTUtil.createGroup(parent, LaunchConfigurationsMessages.CommonTab_4, 5, 2, GridData.FILL_HORIZONTAL); fConsoleOutput = createCheckButton(group, LaunchConfigurationsMessages.CommonTab_5); - gd = new GridData(SWT.BEGINNING, SWT.NORMAL, true, false); + GridData gd = new GridData(SWT.BEGINNING, SWT.NORMAL, true, false); gd.horizontalSpan = 5; fConsoleOutput.setLayoutData(gd); - fConsoleOutput.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateLaunchConfigurationDialog(); @@ -229,45 +204,18 @@ public class CommonTab extends AbstractLaunchConfigurationTab { fFileOutput = createCheckButton(group, LaunchConfigurationsMessages.CommonTab_6); fFileOutput.setLayoutData(new GridData(SWT.BEGINNING, SWT.NORMAL, false, false)); - - fFileText = new Text(group, SWT.SINGLE | SWT.BORDER); - gd = new GridData(SWT.FILL, SWT.NORMAL, true, false); - gd.horizontalSpan = 4; - fFileText.setLayoutData(gd); - - Label spacer = new Label(group,SWT.NONE); - gd = new GridData(SWT.FILL, SWT.NORMAL, true, false); - gd.horizontalSpan=2; - spacer.setLayoutData(gd); - fWorkspaceBrowse = createPushButton(group, LaunchConfigurationsMessages.CommonTab_12, null); - fFileBrowse = createPushButton(group, LaunchConfigurationsMessages.CommonTab_7, null); - fVariables = createPushButton(group, LaunchConfigurationsMessages.CommonTab_9, null); - - spacer = new Label(group,SWT.NONE); - spacer.setLayoutData(new GridData(SWT.FILL, SWT.NORMAL, false, false)); - fAppend = createCheckButton(group, LaunchConfigurationsMessages.CommonTab_11); - gd = new GridData(SWT.LEFT, SWT.TOP, true, false); - gd.horizontalSpan = 4; - fAppend.setLayoutData(gd); - fFileOutput.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - boolean enabled = fFileOutput.getSelection(); - fFileText.setEnabled(enabled); - fFileBrowse.setEnabled(enabled); - fWorkspaceBrowse.setEnabled(enabled); - fVariables.setEnabled(enabled); - fAppend.setEnabled(enabled); + enableOuputCaptureWidgets(fFileOutput.getSelection()); updateLaunchConfigurationDialog(); } }); + fFileText = SWTUtil.createSingleText(group, 4); + fFileText.addModifyListener(fBasicModifyListener); - fAppend.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - updateLaunchConfigurationDialog(); - } - }); + SWTUtil.createLabel(group, EMPTY_STRING, 2); + fWorkspaceBrowse = createPushButton(group, LaunchConfigurationsMessages.CommonTab_12, null); fWorkspaceBrowse.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); @@ -275,8 +223,7 @@ public class CommonTab extends AbstractLaunchConfigurationTab { dialog.setMessage(LaunchConfigurationsMessages.CommonTab_14); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); dialog.setSorter(new ResourceSorter(ResourceSorter.NAME)); - int buttonId = dialog.open(); - if (buttonId == IDialogConstants.OK_ID) { + if (dialog.open() == IDialogConstants.OK_ID) { IResource resource = (IResource) dialog.getFirstResult(); String arg = resource.getFullPath().toString(); String fileLoc = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ @@ -284,25 +231,18 @@ public class CommonTab extends AbstractLaunchConfigurationTab { } } }); - + fFileBrowse = createPushButton(group, LaunchConfigurationsMessages.CommonTab_7, null); fFileBrowse.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { String filePath = fFileText.getText(); FileDialog dialog = new FileDialog(getShell(), SWT.SAVE); - filePath = dialog.open(); if (filePath != null) { fFileText.setText(filePath); } } }); - - fFileText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateLaunchConfigurationDialog(); - } - }); - + fVariables = createPushButton(group, LaunchConfigurationsMessages.CommonTab_9, null); fVariables.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); @@ -312,25 +252,43 @@ public class CommonTab extends AbstractLaunchConfigurationTab { fFileText.insert(variable); } } - public void widgetDefaultSelected(SelectionEvent e) { - } + public void widgetDefaultSelected(SelectionEvent e) {} }); + fAppend = createCheckButton(group, LaunchConfigurationsMessages.CommonTab_11); + gd = new GridData(SWT.LEFT, SWT.TOP, true, false); + gd.horizontalSpan = 4; + fAppend.setLayoutData(gd); + fAppend.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateLaunchConfigurationDialog(); + } + }); } + /** + * Eanbles or disables the ouptput capture widgets based on the the specified enablement + * @param enable if the output capture widgets should be enabled or not + * @since 3.2 + */ + private void enableOuputCaptureWidgets(boolean enable) { + fFileText.setEnabled(enable); + fFileBrowse.setEnabled(enable); + fWorkspaceBrowse.setEnabled(enable); + fVariables.setEnabled(enable); + fAppend.setEnabled(enable); + } + + /** + * Creates the encoding component + * @param parent the parent to add this composite to + */ private void createEncodingComponent(Composite parent) { List allEncodings = IDEEncoding.getIDEEncodings(); String defaultEncoding = WorkbenchEncoding.getWorkbenchDefaultEncoding(); - - Group group = new Group(parent, SWT.NONE); - group.setText(LaunchConfigurationsMessages.CommonTab_1); - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false); - group.setLayoutData(gd); - GridLayout layout = new GridLayout(2, false); - group.setLayout(layout); - group.setFont(parent.getFont()); + Group group = SWTUtil.createGroup(parent, LaunchConfigurationsMessages.CommonTab_1, 2, 1, GridData.FILL_BOTH); fDefaultEncodingButton = createRadioButton(group, MessageFormat.format(LaunchConfigurationsMessages.CommonTab_2, new String[]{defaultEncoding})); - gd = new GridData(SWT.BEGINNING, SWT.NORMAL, true, false); + GridData gd = new GridData(SWT.BEGINNING, SWT.NORMAL, true, false); gd.horizontalSpan = 2; fDefaultEncodingButton.setLayoutData(gd); @@ -339,12 +297,12 @@ public class CommonTab extends AbstractLaunchConfigurationTab { fEncodingCombo = new Combo(group, SWT.READ_ONLY); fEncodingCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + fEncodingCombo.setFont(parent.getFont()); String[] encodingArray = (String[]) allEncodings.toArray(new String[0]); fEncodingCombo.setItems(encodingArray); if (encodingArray.length > 0) { fEncodingCombo.select(0); } - SelectionListener listener = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateLaunchConfigurationDialog(); @@ -375,60 +333,59 @@ public class CommonTab extends AbstractLaunchConfigurationTab { }); } - - private void setSharedLocationButton(Button sharedLocationButton) { - this.fSharedLocationButton = sharedLocationButton; - } - - private Button getSharedLocationButton() { - return fSharedLocationButton; - } - - private void setSharedLocationText(Text sharedLocationText) { - this.fSharedLocationText = sharedLocationText; - } - - private Text getSharedLocationText() { - return fSharedLocationText; - } - - private void setLocalRadioButton(Button button) { - fLocalRadioButton = button; - } - - private Button getLocalRadioButton() { - return fLocalRadioButton; - } - - private void setSharedRadioButton(Button button) { - fSharedRadioButton = button; - } - - private Button getSharedRadioButton() { - return fSharedRadioButton; - } - + /** + * handles the shared radio button being selected + */ private void handleSharedRadioButtonSelected() { setSharedEnabled(isShared()); updateLaunchConfigurationDialog(); } + /** + * Sets the widgets for specifying that a launch configuraiton is to be shared to the enable value + * @param enable the enabled value for + */ private void setSharedEnabled(boolean enable) { - getSharedLocationText().setEnabled(enable); - getSharedLocationButton().setEnabled(enable); + fSharedLocationText.setEnabled(enable); + fSharedLocationButton.setEnabled(enable); } + private String getDefaultSharedConfigLocation(ILaunchConfiguration config) { + String path = EMPTY_STRING; + try { + IResource[] res = config.getMappedResources(); + if(res != null) { + IProject proj; + for (int i = 0; i < res.length; i++) { + proj = res[i].getProject(); + if(proj.isAccessible()) { + return proj.getFullPath().toOSString(); + } + } + } + } + catch (CoreException e) {DebugUIPlugin.log(e);} + return path; + } + + /** + * if the shared radio button is selected, indicating that the launch configuration is to be shared + * @return true if the radio button is selected, false otherwise + */ private boolean isShared() { - return getSharedRadioButton().getSelection(); + return fSharedRadioButton.getSelection(); } + /** + * Handles the shared location button being selected + */ private void handleSharedLocationButtonSelected() { ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), getWorkspaceRoot(), false, LaunchConfigurationsMessages.CommonTab_Select_a_location_for_the_launch_configuration_13); - String currentContainerString = getSharedLocationText().getText(); + String currentContainerString = fSharedLocationText.getText(); IContainer currentContainer = getContainer(currentContainerString); if (currentContainer != null) { IPath path = currentContainer.getFullPath(); @@ -441,10 +398,15 @@ public class CommonTab extends AbstractLaunchConfigurationTab { if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) { IPath path = (IPath)results[0]; String containerName = path.toOSString(); - getSharedLocationText().setText(containerName); + fSharedLocationText.setText(containerName); } } + /** + * gets the container form the specified path + * @param path the path to get the container from + * @return the container for the specified path or null if one cannot be determined + */ private IContainer getContainer(String path) { Path containerPath = new Path(path); return (IContainer) getWorkspaceRoot().findMember(containerPath); @@ -453,15 +415,33 @@ public class CommonTab extends AbstractLaunchConfigurationTab { /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ - public void initializeFrom(ILaunchConfiguration configuration) { - updateLocalSharedFromConfig(configuration); - updateSharedLocationFromConfig(configuration); + public void initializeFrom(ILaunchConfiguration configuration) { + boolean isShared = !configuration.isLocal(); + fSharedRadioButton.setSelection(isShared); + fLocalRadioButton.setSelection(!isShared); + setSharedEnabled(isShared); + fSharedLocationText.setText(getDefaultSharedConfigLocation(configuration)); + if(isShared) { + String containerName = EMPTY_STRING; + IFile file = configuration.getFile(); + if (file != null) { + IContainer parent = file.getParent(); + if (parent != null) { + containerName = parent.getFullPath().toOSString(); + } + } + fSharedLocationText.setText(containerName); + } updateFavoritesFromConfig(configuration); updateLaunchInBackground(configuration); updateEncoding(configuration); updateConsoleOutput(configuration); } + /** + * Updates the console output form the local configuration + * @param configuration the local configuration + */ private void updateConsoleOutput(ILaunchConfiguration configuration) { boolean outputToConsole = true; String outputFile = null; @@ -481,17 +461,21 @@ public class CommonTab extends AbstractLaunchConfigurationTab { fFileText.setText(outputFile); } fFileOutput.setSelection(haveOutputFile); - fFileText.setEnabled(haveOutputFile); - fFileBrowse.setEnabled(haveOutputFile); - fWorkspaceBrowse.setEnabled(haveOutputFile); - fVariables.setEnabled(haveOutputFile); - fAppend.setEnabled(haveOutputFile); + enableOuputCaptureWidgets(haveOutputFile); } + /** + * Updates the launch on background check button + * @param configuration the local launch configuration + */ protected void updateLaunchInBackground(ILaunchConfiguration configuration) { fLaunchInBackgroundButton.setSelection(isLaunchInBackground(configuration)); } + /** + * Updates the encoding + * @param configuration the local configuration + */ private void updateEncoding(ILaunchConfiguration configuration) { String encoding = null; try { @@ -526,26 +510,11 @@ public class CommonTab extends AbstractLaunchConfigurationTab { } return launchInBackground; } - - private void updateLocalSharedFromConfig(ILaunchConfiguration config) { - boolean isShared = !config.isLocal(); - getSharedRadioButton().setSelection(isShared); - getLocalRadioButton().setSelection(!isShared); - setSharedEnabled(isShared); - } - - private void updateSharedLocationFromConfig(ILaunchConfiguration config) { - getSharedLocationText().setText(""); //$NON-NLS-1$ - IFile file = config.getFile(); - if (file != null) { - IContainer parent = file.getParent(); - if (parent != null) { - String containerName = parent.getFullPath().toOSString(); - getSharedLocationText().setText(containerName); - } - } - } - + + /** + * Updates the favorites selections from the local configuration + * @param config the local configuration + */ private void updateFavoritesFromConfig(ILaunchConfiguration config) { fFavoritesTable.setInput(config); fFavoritesTable.setCheckedElements(new Object[]{}); @@ -575,16 +544,27 @@ public class CommonTab extends AbstractLaunchConfigurationTab { } } + /** + * Updates the configuration form the local shared config working copy + * @param config the local sharded config working copy + */ private void updateConfigFromLocalShared(ILaunchConfigurationWorkingCopy config) { if (isShared()) { - String containerPathString = getSharedLocationText().getText(); + String containerPathString = fSharedLocationText.getText(); IContainer container = getContainer(containerPathString); config.setContainer(container); } else { config.setContainer(null); } } - + + /** + * Convenience accessor + */ + protected LaunchConfigurationManager getLaunchConfigurationManager() { + return DebugUIPlugin.getDefault().getLaunchConfigurationManager(); + } + /** * Update the favorite settings. * @@ -623,10 +603,8 @@ public class CommonTab extends AbstractLaunchConfigurationTab { } } } - // erase old attributes (if any) config.setAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, (String)null); config.setAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, (String)null); - // new attribute List groups = null; for (int i = 0; i < checked.length; i++) { LaunchGroupExtension group = (LaunchGroupExtension)checked[i]; @@ -658,6 +636,10 @@ public class CommonTab extends AbstractLaunchConfigurationTab { return validateLocalShared() && validateRedirectFile() && validateEncoding(); } + /** + * validates the encoding selection + * @return true if the validate encoding is allowable, false otherwise + */ private boolean validateEncoding() { if (fAltEncodingButton.getSelection()) { if (fEncodingCombo.getSelectionIndex() == -1) { @@ -668,6 +650,10 @@ public class CommonTab extends AbstractLaunchConfigurationTab { return true; } + /** + * Valdates if the redirect file is valid + * @return true if the filename is not zero, false otherwise + */ private boolean validateRedirectFile() { if(fFileOutput.getSelection()) { int len = fFileText.getText().trim().length(); @@ -679,6 +665,10 @@ public class CommonTab extends AbstractLaunchConfigurationTab { return true; } + /** + * validates the local shared config file location + * @return true if the local sharded file exists, false otherwsie + */ private boolean validateLocalShared() { if (isShared()) { String path = fSharedLocationText.getText().trim(); @@ -762,11 +752,22 @@ public class CommonTab extends AbstractLaunchConfigurationTab { public Image getImage() { return DebugUITools.getImage(IInternalDebugUIConstants.IMG_OBJS_COMMON_TAB); } + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void activated(ILaunchConfigurationWorkingCopy workingCopy) {} + + /* (non-Javadoc) + * @see org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {} + /** + * Content provider for the favorites table + */ class FavoritesContentProvider implements IStructuredContentProvider { - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ + public Object[] getElements(Object inputElement) { ILaunchGroup[] groups = DebugUITools.getLaunchGroups(); List possibleGroups = new ArrayList(); @@ -781,27 +782,20 @@ public class CommonTab extends AbstractLaunchConfigurationTab { return possibleGroups.toArray(); } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() { - } + public void dispose() {} - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} } + /** + * Provides the labels for the favorites table + * + */ class FavoritesLabelProvider implements ITableLabelProvider { private Map fImages = new HashMap(); - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) - */ + public Image getColumnImage(Object element, int columnIndex) { Image image = (Image)fImages.get(element); if (image == null) { @@ -814,23 +808,13 @@ public class CommonTab extends AbstractLaunchConfigurationTab { return image; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) - */ public String getColumnText(Object element, int columnIndex) { String label = ((LaunchGroupExtension)element).getLabel(); return DebugUIPlugin.removeAccelerators(label); } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void addListener(ILabelProviderListener listener) { - } + public void addListener(ILabelProviderListener listener) {} - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ public void dispose() { Iterator images = fImages.values().iterator(); while (images.hasNext()) { @@ -839,38 +823,9 @@ public class CommonTab extends AbstractLaunchConfigurationTab { } } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) - */ - public boolean isLabelProperty(Object element, String property) { - return false; - } + public boolean isLabelProperty(Object element, String property) {return false;} - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) - */ - public void removeListener(ILabelProviderListener listener) { - } - - } - - /** - * Convenience accessor - */ - protected LaunchConfigurationManager getLaunchConfigurationManager() { - return DebugUIPlugin.getDefault().getLaunchConfigurationManager(); - } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - public void activated(ILaunchConfigurationWorkingCopy workingCopy) { - // do nothing when activated + public void removeListener(ILabelProviderListener listener) {} } - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) { - // do nothing when deactivated - } } |