Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Rennie2006-11-16 17:09:24 +0000
committerMichael Rennie2006-11-16 17:09:24 +0000
commita6d8573a4ac98c999b1029a5e2206f2d1145b95f (patch)
tree21fe64c548814d5f745edd120cc858a9c7b8cb52 /org.eclipse.debug.ui/ui
parentc130146e210d0c6b4c0330c63f9629144c06f4ad (diff)
downloadeclipse.platform.debug-a6d8573a4ac98c999b1029a5e2206f2d1145b95f.tar.gz
eclipse.platform.debug-a6d8573a4ac98c999b1029a5e2206f2d1145b95f.tar.xz
eclipse.platform.debug-a6d8573a4ac98c999b1029a5e2206f2d1145b95f.zip
Bug 164682
NPE SourceLookupPanel add external archive
Diffstat (limited to 'org.eclipse.debug.ui/ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupPanel.java51
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java8
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractLaunchConfigurationTab.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java29
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java17
6 files changed, 72 insertions, 41 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupPanel.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupPanel.java
index 01e102277..277bb84de 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupPanel.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupPanel.java
@@ -212,16 +212,6 @@ public class SourceLookupPanel extends AbstractLaunchConfigurationTab implements
}
/**
- * Create some empty space
- */
- protected void createVerticalSpacer(Composite comp, int colSpan) {
- Label label = new Label(comp, SWT.NONE);
- GridData gd = new GridData();
- gd.horizontalSpan = colSpan;
- label.setLayoutData(gd);
- }
-
- /**
* Adds the given action to the action collection in this tab
*/
protected void addAction(SourceContainerAction action) {
@@ -258,7 +248,7 @@ public class SourceLookupPanel extends AbstractLaunchConfigurationTab implements
if (type == null) {
type = configuration.getType().getSourceLocatorId();
}
- }catch(CoreException e){
+ } catch(CoreException e){
setErrorMessage(e.getMessage());
return;
}
@@ -296,7 +286,6 @@ public class SourceLookupPanel extends AbstractLaunchConfigurationTab implements
setErrorMessage(e.getMessage());
return;
}
-
initializeFrom(fLocator);
if (migration && configuration.isWorkingCopy()) {
// ensure perform apply actual updates the config
@@ -310,8 +299,9 @@ public class SourceLookupPanel extends AbstractLaunchConfigurationTab implements
* AbstractSourceLookupDirector
*/
public void initializeFrom(ISourceLookupDirector locator) {
- if(fConfig == null)
+ if(fConfig == null) {
fConfig = locator.getLaunchConfiguration();
+ }
fPathViewer.setEntries(locator.getSourceContainers());
fDuplicatesButton.setSelection(locator.isFindDuplicates());
fLocator = locator;
@@ -338,19 +328,22 @@ public class SourceLookupPanel extends AbstractLaunchConfigurationTab implements
configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);
return;
}
- ILaunchConfigurationWorkingCopy workingCopy = null;
+ ILaunchConfigurationWorkingCopy workingCopy = configuration;
if(configuration == null) {
- try{
- workingCopy = fLocator.getLaunchConfiguration().getWorkingCopy();
- }catch(CoreException e){
+ try {
+ ILaunchConfiguration config = fLocator.getLaunchConfiguration();
+ if(config != null) {
+ workingCopy = config.getWorkingCopy();
+ }
+ }
+ catch(CoreException e) {
DebugUIPlugin.log(e);
setErrorMessage(SourceLookupUIMessages.sourceLookupPanel_1);
return;
}
}
- else workingCopy = configuration;
if(workingCopy == null) {
- DebugUIPlugin.logErrorMessage("Error occurred - unable to apply source lookup path changes."); //$NON-NLS-1$
+ DebugUIPlugin.logErrorMessage("Error occurred - a working copy could not be acquired, therefore source lookup path changes will not be applied."); //$NON-NLS-1$
return;
}
//set new values in director so memento returned is correct
@@ -358,7 +351,7 @@ public class SourceLookupPanel extends AbstractLaunchConfigurationTab implements
fLocator.setFindDuplicates(fDuplicatesButton.getSelection());
//writing to the file will cause a change event and the listeners will be updated
- try{
+ try {
if (isDefault(workingCopy)) {
workingCopy.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
workingCopy.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null);
@@ -366,10 +359,12 @@ public class SourceLookupPanel extends AbstractLaunchConfigurationTab implements
workingCopy.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, fLocator.getMemento());
workingCopy.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, fLocator.getId());
}
- if(configuration == null)
+ if(configuration == null) {
workingCopy.doSave();
+ }
setDirty(false);
- }catch(CoreException e){
+ }
+ catch(CoreException e) {
DebugUIPlugin.log(e);
setErrorMessage(SourceLookupUIMessages.sourceLookupPanel_1);
}
@@ -377,13 +372,14 @@ public class SourceLookupPanel extends AbstractLaunchConfigurationTab implements
}
}
+ /**
+ * determines of the current source lokoup path is the default path
+ * @param configuration
+ * @return
+ */
protected boolean isDefault(ILaunchConfiguration configuration) {
ISourceContainer[] current = getEntries();
- return !isFindDuplicates() && current.length == 1 && current[0] instanceof DefaultSourceContainer;
- }
-
- private boolean isFindDuplicates() {
- return fDuplicatesButton.getSelection();
+ return !fDuplicatesButton.getSelection() && current.length == 1 && current[0] instanceof DefaultSourceContainer;
}
/**
@@ -400,7 +396,6 @@ public class SourceLookupPanel extends AbstractLaunchConfigurationTab implements
}
-
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java
index 7d91f761a..3e3470ab6 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java
@@ -16,8 +16,16 @@ import org.eclipse.osgi.util.NLS;
public class SourceLookupUIMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages";//$NON-NLS-1$
+ public static String CommonSourceNotFoundEditor_0;
+
+ public static String CommonSourceNotFoundEditor_1;
+
// Source search launch configuration tab/errors/dialogs
public static String EditContainerAction_0;
+
+ public static String SourceLookupDialog_0;
+
+ public static String SourceLookupDialog_1;
public static String sourceTab_lookupLabel;
public static String sourceTab_searchDuplicateLabel;
public static String sourceTab_upButton;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
index e7737f3a6..ab28335f8 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties
@@ -58,3 +58,7 @@ DirectorySourceContainerDialog_6=Search sub&folders
DirectorySourceContainerDialog_7=Add File System Directory
DirectorySourceContainerDialog_8=Edit File System Directory
Prompter_0=Failed to get the root status handler.
+CommonSourceNotFoundEditor_0=Select a Context
+CommonSourceNotFoundEditor_1=You must select an item in the debug view to use as context for source lookup path changes.\n\nFor example: the launch or one of the threads in the view.
+SourceLookupDialog_0=Launch configuration
+SourceLookupDialog_1=\ is read only, no source lookup path changes will be saved
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 afe158cb7..305c95598 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
@@ -247,7 +247,9 @@ public abstract class AbstractLaunchConfigurationTab implements ILaunchConfigura
}
/**
- * Create some empty space.
+ * Creates vertical space in the parent <code>Composite</code>
+ * @param comp the parent to add the vertical space to
+ * @param colSpan the number of line of vertical space to add
*/
protected void createVerticalSpacer(Composite comp, int colSpan) {
Label label = new Label(comp, SWT.NONE);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java
index 4e7cd10c2..98e4dab60 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java
@@ -24,6 +24,8 @@ import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupManager;
import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.JFaceColors;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
@@ -163,9 +165,15 @@ public class CommonSourceNotFoundEditor extends EditorPart implements IReusableE
ISourceLocator locator = null;
ILaunch launch = null;
IAdaptable selection = DebugUITools.getDebugContext();
-
- if(selection == null) return;
-
+ if(selection == null) {
+ new MessageDialog(getSite().getShell(),
+ SourceLookupUIMessages.CommonSourceNotFoundEditor_0,
+ null,
+ SourceLookupUIMessages.CommonSourceNotFoundEditor_1,
+ MessageDialog.INFORMATION,
+ new String[] {IDialogConstants.OK_LABEL}, 0).open();
+ return;
+ }
if (selection.getAdapter(ILaunch.class) != null ) {
launch = (ILaunch) selection.getAdapter(ILaunch.class);
locator = launch.getSourceLocator();
@@ -174,15 +182,14 @@ public class CommonSourceNotFoundEditor extends EditorPart implements IReusableE
launch = ((IDebugElement)selection.getAdapter(IDebugElement.class)).getLaunch();
locator = launch.getSourceLocator();
}
- else return; //should not occur
- if (locator == null || !(locator instanceof AbstractSourceLookupDirector))
+ else {
+ return; //should not occur
+ }
+ if (locator == null || !(locator instanceof AbstractSourceLookupDirector)) {
return;
-
- final SourceLookupDialog dialog =
- new SourceLookupDialog(DebugUIPlugin.getShell(),(AbstractSourceLookupDirector) locator);
-
- int result = dialog.open();
- if(result == Window.OK) {
+ }
+ final SourceLookupDialog dialog = new SourceLookupDialog(DebugUIPlugin.getShell(),(AbstractSourceLookupDirector) locator);
+ if(dialog.open() == Window.OK) {
IWorkbenchPage page = getEditorSite().getPage();
SourceLookupManager.getDefault().displaySource(getArtifact(), page, true);
closeEditor();
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java
index 30c2fad6f..d479ad567 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/SourceLookupDialog.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.debug.ui.sourcelookup;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
import org.eclipse.debug.internal.ui.DebugPluginImages;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
@@ -85,6 +88,10 @@ public class SourceLookupDialog extends TitleAreaDialog {
fPanel.createControl(composite);
fPanel.initializeFrom(fDirector);
Dialog.applyDialogFont(composite);
+ ILaunchConfiguration config = fDirector.getLaunchConfiguration();
+ if(config != null && config.isReadOnly()) {
+ setErrorMessage(SourceLookupUIMessages.SourceLookupDialog_0+config.getName()+SourceLookupUIMessages.SourceLookupDialog_1);
+ }
PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IDebugHelpContextIds.EDIT_SOURCELOOKUP_DIALOG);
return composite;
@@ -94,7 +101,15 @@ public class SourceLookupDialog extends TitleAreaDialog {
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
*/
protected void okPressed() {
- fPanel.performApply(null);
+ ILaunchConfiguration config = fDirector.getLaunchConfiguration();
+ ILaunchConfigurationWorkingCopy copy = null;
+ if(config != null) {
+ try {
+ copy = config.getWorkingCopy();
+ }
+ catch (CoreException e) {DebugUIPlugin.log(e);}
+ }
+ fPanel.performApply(copy);
super.okPressed();
}

Back to the top