1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

NLS-style string resources.

This commit is contained in:
Sergey Prigogin 2010-12-02 23:13:07 +00:00
parent bd51ec8825
commit f257c2f55d
21 changed files with 649 additions and 698 deletions

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
@ -25,5 +25,4 @@ public class AbsolutePathSourceContainerBrowser extends AbstractSourceContainerB
AbsolutePathSourceContainer absolutePathSourceContainer = new AbsolutePathSourceContainer(); AbsolutePathSourceContainer absolutePathSourceContainer = new AbsolutePathSourceContainer();
return new ISourceContainer[] { absolutePathSourceContainer }; return new ISourceContainer[] { absolutePathSourceContainer };
} }
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
@ -19,11 +19,10 @@ import org.eclipse.jface.viewers.IStructuredSelection;
* and the EditSourceLookupPathDialog. * and the EditSourceLookupPathDialog.
*/ */
public class AddContainerAction extends SourceContainerAction { public class AddContainerAction extends SourceContainerAction {
private ISourceLookupDirector fDirector; private ISourceLookupDirector fDirector;
public AddContainerAction() { public AddContainerAction() {
super(SourceLookupUIMessages.getString( "AddContainerAction.0" )); //$NON-NLS-1$ super(SourceLookupUIMessages.AddContainerAction_0);
} }
/** /**
@ -44,9 +43,9 @@ public class AddContainerAction extends SourceContainerAction {
* @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
*/ */
protected boolean updateSelection(IStructuredSelection selection) { protected boolean updateSelection(IStructuredSelection selection) {
if(selection == null || selection.isEmpty()) { if (selection == null || selection.isEmpty()) {
return true; return true;
} }
return getViewer().getTree().getSelection()[0].getParentItem()==null; return getViewer().getTree().getSelection()[0].getParentItem() == null;
} }
} }

View file

@ -46,7 +46,6 @@ import org.eclipse.ui.PlatformUI;
* @since 3.0 * @since 3.0
*/ */
public class AddSourceContainerDialog extends TitleAreaDialog { public class AddSourceContainerDialog extends TitleAreaDialog {
private TableViewer fViewer; private TableViewer fViewer;
private SourceContainerViewer fSourceContainerViewer; private SourceContainerViewer fSourceContainerViewer;
private boolean fDoubleClickSelects = true; private boolean fDoubleClickSelects = true;
@ -66,9 +65,8 @@ public class AddSourceContainerDialog extends TitleAreaDialog {
* Creates the dialog area to display source container types that are "browseable" * Creates the dialog area to display source container types that are "browseable"
*/ */
protected Control createDialogArea(Composite ancestor) { protected Control createDialogArea(Composite ancestor) {
getShell().setText(SourceLookupUIMessages.AddSourceContainerDialog_0);
getShell().setText(SourceLookupUIMessages.getString( "AddSourceContainerDialog.0" )); //$NON-NLS-1$ setTitle(SourceLookupUIMessages.AddSourceContainerDialog_1);
setTitle(SourceLookupUIMessages.getString( "AddSourceContainerDialog.1" )); //$NON-NLS-1$
Composite parent = new Composite(ancestor, SWT.NULL); Composite parent = new Composite(ancestor, SWT.NULL);
GridData gd= new GridData(GridData.FILL_BOTH); GridData gd= new GridData(GridData.FILL_BOTH);
@ -107,7 +105,7 @@ public class AddSourceContainerDialog extends TitleAreaDialog {
setMessage(desc); setMessage(desc);
} }
}); });
if(types.length != 0) { if (types.length != 0) {
fViewer.setInput(types); fViewer.setInput(types);
} }
Dialog.applyDialogFont(parent); Dialog.applyDialogFont(parent);
@ -121,18 +119,17 @@ public class AddSourceContainerDialog extends TitleAreaDialog {
* @return the list of source container types that have browsers * @return the list of source container types that have browsers
*/ */
private ISourceContainerType[] filterTypes(ISourceContainerType[] types){ private ISourceContainerType[] filterTypes(ISourceContainerType[] types){
ArrayList validTypes = new ArrayList(); ArrayList<ISourceContainerType> validTypes = new ArrayList<ISourceContainerType>();
for (int i=0; i< types.length; i++) { for (int i=0; i < types.length; i++) {
ISourceContainerType type = types[i]; ISourceContainerType type = types[i];
if (fDirector.supportsSourceContainerType(type)) { if (fDirector.supportsSourceContainerType(type)) {
ISourceContainerBrowser sourceContainerBrowser = DebugUITools.getSourceContainerBrowser(type.getId()); ISourceContainerBrowser sourceContainerBrowser = DebugUITools.getSourceContainerBrowser(type.getId());
if(sourceContainerBrowser != null && sourceContainerBrowser.canAddSourceContainers(fDirector)) { if (sourceContainerBrowser != null && sourceContainerBrowser.canAddSourceContainers(fDirector)) {
validTypes.add(type); validTypes.add(type);
} }
} }
} }
return (ISourceContainerType[]) validTypes.toArray(new ISourceContainerType[validTypes.size()]); return validTypes.toArray(new ISourceContainerType[validTypes.size()]);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -145,11 +142,10 @@ public class AddSourceContainerDialog extends TitleAreaDialog {
ISourceContainerBrowser browser = DebugUITools.getSourceContainerBrowser(type.getId()); ISourceContainerBrowser browser = DebugUITools.getSourceContainerBrowser(type.getId());
if (browser != null) { if (browser != null) {
ISourceContainer[] results = browser.addSourceContainers(getShell(), fDirector); ISourceContainer[] results = browser.addSourceContainers(getShell(), fDirector);
if(results != null) { if (results != null) {
fSourceContainerViewer.addEntries(results); fSourceContainerViewer.addEntries(results);
} }
} }
super.okPressed(); super.okPressed();
} }
} }

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Iterator;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
@ -43,6 +42,7 @@ import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor; import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor;
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay; import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionEvent;
@ -55,15 +55,11 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException; import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import com.ibm.icu.text.MessageFormat;
/** /**
* Editor that lets you select a replacement for the missing source file * Editor that lets you select a replacement for the missing source file
* and modifies the source locator accordingly. * and modifies the source locator accordingly.
*
*/ */
public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
public final String foundMappingsContainerName = "Found Mappings"; //$NON-NLS-1$ public final String foundMappingsContainerName = "Found Mappings"; //$NON-NLS-1$
private static final String UID_KEY = ".uid"; //$NON-NLS-1$ private static final String UID_KEY = ".uid"; //$NON-NLS-1$
private static final String UID_CLASS_NAME = CSourceNotFoundEditor.class.getName(); private static final String UID_CLASS_NAME = CSourceNotFoundEditor.class.getName();
@ -110,8 +106,9 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
IPath tuPath = tunit.getLocation(); IPath tuPath = tunit.getLocation();
if (tuPath != null) if (tuPath != null)
missingFile = tuPath.toOSString(); missingFile = tuPath.toOSString();
} else } else {
missingFile = ""; //$NON-NLS-1$ missingFile = ""; //$NON-NLS-1$
}
} }
super.setInput(input); super.setInput(input);
syncButtons(); syncButtons();
@ -126,9 +123,8 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
protected String getText() { protected String getText() {
if (missingFile.length() > 0) { if (missingFile.length() > 0) {
return MessageFormat.format(SourceLookupUIMessages.getString( "CSourceNotFoundEditor.0" ), new String[] { missingFile }); //$NON-NLS-1$ return NLS.bind(SourceLookupUIMessages.CSourceNotFoundEditor_0, missingFile);
} } else {
else {
if (context == null) if (context == null)
return super.getText(); return super.getText();
String contextDescription; String contextDescription;
@ -137,21 +133,19 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
contextDescription = description.getDescription(); contextDescription = description.getDescription();
else else
contextDescription = context.toString(); contextDescription = context.toString();
return MessageFormat.format(SourceLookupUIMessages.getString( "CSourceNotFoundEditor.3" ), new String[] { contextDescription }); //$NON-NLS-1$ return NLS.bind(SourceLookupUIMessages.CSourceNotFoundEditor_3, contextDescription);
} }
} }
protected void createButtons(Composite parent) { protected void createButtons(Composite parent) {
if (isDebugElement) {
if (isDebugElement)
{
GridData data; GridData data;
disassemblyButton = new Button(parent, SWT.PUSH); disassemblyButton = new Button(parent, SWT.PUSH);
data = new GridData(); data = new GridData();
data.grabExcessHorizontalSpace = false; data.grabExcessHorizontalSpace = false;
data.grabExcessVerticalSpace = false; data.grabExcessVerticalSpace = false;
disassemblyButton.setLayoutData(data); disassemblyButton.setLayoutData(data);
disassemblyButton.setText(SourceLookupUIMessages.getString( "CSourceNotFoundEditor.4" )); //$NON-NLS-1$ disassemblyButton.setText(SourceLookupUIMessages.CSourceNotFoundEditor_4);
disassemblyButton.addSelectionListener(new SelectionAdapter() { disassemblyButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
viewDisassembly(); viewDisassembly();
@ -167,7 +161,7 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
data.grabExcessHorizontalSpace = false; data.grabExcessHorizontalSpace = false;
data.grabExcessVerticalSpace = false; data.grabExcessVerticalSpace = false;
locateFileButton.setLayoutData(data); locateFileButton.setLayoutData(data);
locateFileButton.setText(SourceLookupUIMessages.getString( "CSourceNotFoundEditor.1" )); //$NON-NLS-1$ locateFileButton.setText(SourceLookupUIMessages.CSourceNotFoundEditor_1);
locateFileButton.addSelectionListener(new SelectionAdapter() { locateFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
locateFile(); locateFile();
@ -176,25 +170,22 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
locateFileButton.setData(UID_KEY, UID_LOCATE_FILE_BUTTON); locateFileButton.setData(UID_KEY, UID_LOCATE_FILE_BUTTON);
} }
if (isDebugElement) if (isDebugElement) {
{
GridData data; GridData data;
editLookupButton = new Button(parent, SWT.PUSH); editLookupButton = new Button(parent, SWT.PUSH);
data = new GridData(); data = new GridData();
data.grabExcessHorizontalSpace = false; data.grabExcessHorizontalSpace = false;
data.grabExcessVerticalSpace = false; data.grabExcessVerticalSpace = false;
editLookupButton.setLayoutData(data); editLookupButton.setLayoutData(data);
editLookupButton.setText(SourceLookupUIMessages.getString( "CSourceNotFoundEditor.5" )); //$NON-NLS-1$ editLookupButton.setText(SourceLookupUIMessages.CSourceNotFoundEditor_5);
editLookupButton.addSelectionListener(new SelectionAdapter() { editLookupButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
editSourceLookupPath(); editSourceLookupPath();
} }
}); });
editLookupButton.setData(UID_KEY, UID_EDIT_LOOKUP_BUTTON); editLookupButton.setData(UID_KEY, UID_EDIT_LOOKUP_BUTTON);
} }
syncButtons(); syncButtons();
} }
protected void viewDisassembly() { protected void viewDisassembly() {
@ -202,36 +193,31 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
if (page != null) { if (page != null) {
try { try {
page.showView("org.eclipse.cdt.dsf.debug.ui.disassembly.view"); //$NON-NLS-1$ page.showView("org.eclipse.cdt.dsf.debug.ui.disassembly.view"); //$NON-NLS-1$
} catch (PartInitException e) {} } catch (PartInitException e) {
}
} }
} }
private void addSourceMappingToDirector(IPath missingPath, IPath newSourcePath, AbstractSourceLookupDirector director) throws CoreException { private void addSourceMappingToDirector(IPath missingPath, IPath newSourcePath, AbstractSourceLookupDirector director) throws CoreException {
ArrayList<ISourceContainer> containerList = new ArrayList<ISourceContainer>(Arrays.asList(director.getSourceContainers()));
ArrayList containerList = new ArrayList(Arrays.asList(director.getSourceContainers()));
boolean hasFoundMappings = false;
MappingSourceContainer foundMappings = null; MappingSourceContainer foundMappings = null;
for (ISourceContainer container : containerList) {
for (Iterator iter = containerList.iterator(); iter.hasNext() && !hasFoundMappings;) { if (container instanceof MappingSourceContainer) {
ISourceContainer container = (ISourceContainer) iter.next(); if (container.getName().equals(foundMappingsContainerName)) {
if (container instanceof MappingSourceContainer)
{
hasFoundMappings = container.getName().equals(foundMappingsContainerName);
if (hasFoundMappings)
foundMappings = (MappingSourceContainer) container; foundMappings = (MappingSourceContainer) container;
break;
}
} }
} }
if (!hasFoundMappings) { if (foundMappings == null) {
foundMappings = new MappingSourceContainer(foundMappingsContainerName); foundMappings = new MappingSourceContainer(foundMappingsContainerName);
foundMappings.init(director); foundMappings.init(director);
containerList.add(foundMappings); containerList.add(foundMappings);
} }
foundMappings.addMapEntry(new MapEntrySourceContainer(missingPath, newSourcePath)); foundMappings.addMapEntry(new MapEntrySourceContainer(missingPath, newSourcePath));
director.setSourceContainers((ISourceContainer[]) containerList.toArray(new ISourceContainer[containerList.size()])); director.setSourceContainers(containerList.toArray(new ISourceContainer[containerList.size()]));
} }
/** /**
@ -271,25 +257,22 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
} }
addSourceMappingToDirector(missingPath, newSourcePath, director); addSourceMappingToDirector(missingPath, newSourcePath, director);
configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, director.getMemento()); configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, director.getMemento());
configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, director.getId()); configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, director.getId());
configuration.doSave(); configuration.doSave();
} }
} }
protected void locateFile() { protected void locateFile() {
FileDialog dialog = new FileDialog(getEditorSite().getShell(), SWT.NONE); FileDialog dialog = new FileDialog(getEditorSite().getShell(), SWT.NONE);
Path missingPath = new Path(missingFile); Path missingPath = new Path(missingFile);
dialog.setFilterNames(new String[] {SourceLookupUIMessages.getString("CSourceNotFoundEditor.2")}); //$NON-NLS-1$ dialog.setFilterNames(new String[] {SourceLookupUIMessages.CSourceNotFoundEditor_2});
dialog.setFilterExtensions(new String[] {"*." + missingPath.getFileExtension()}); //$NON-NLS-1$ dialog.setFilterExtensions(new String[] {"*." + missingPath.getFileExtension()}); //$NON-NLS-1$
String res = dialog.open(); String res = dialog.open();
if (res != null) { if (res != null) {
Path newPath = new Path(res); Path newPath = new Path(res);
if (newPath.lastSegment().equalsIgnoreCase(missingPath.lastSegment())) { if (newPath.lastSegment().equalsIgnoreCase(missingPath.lastSegment())) {
if (missingPath.segmentCount() > 1) { if (missingPath.segmentCount() > 1) {
IPath compPath = missingPath.removeLastSegments(1); IPath compPath = missingPath.removeLastSegments(1);
IPath newSourcePath = newPath.removeLastSegments(1); IPath newSourcePath = newPath.removeLastSegments(1);
@ -298,22 +281,18 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
addSourceMappingToLaunch(compPath, newSourcePath); addSourceMappingToLaunch(compPath, newSourcePath);
else else
addSourceMappingToCommon(compPath, newSourcePath); addSourceMappingToCommon(compPath, newSourcePath);
} catch (CoreException e) {} } catch (CoreException e) {
}
} }
IWorkbenchPage page = getEditorSite().getPage(); IWorkbenchPage page = getEditorSite().getPage();
if (isDebugElement) if (isDebugElement) {
{
ISourceDisplay adapter = (ISourceDisplay)context.getAdapter(ISourceDisplay.class); ISourceDisplay adapter = (ISourceDisplay)context.getAdapter(ISourceDisplay.class);
if (adapter != null) { if (adapter != null) {
adapter.displaySource(context, page, true); adapter.displaySource(context, page, true);
} }
} } else if (isTranslationUnit) {
else
if (isTranslationUnit)
{
reopenTranslationUnit(tunit); reopenTranslationUnit(tunit);
} }
closeEditor(); closeEditor();
@ -321,41 +300,34 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
} }
} }
private boolean reopenTranslationUnit(ITranslationUnit tu) private boolean reopenTranslationUnit(ITranslationUnit tu){
{ if (tu != null){
if (tu != null)
{
IPath tuPath = tu.getLocation(); IPath tuPath = tu.getLocation();
if (tuPath != null) if (tuPath != null){
{
String filePath = tuPath.toOSString(); String filePath = tuPath.toOSString();
try { try {
Object[] foundElements = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().findSourceElements(filePath); Object[] foundElements = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().findSourceElements(filePath);
if (foundElements.length == 1 && foundElements[0] instanceof IFile) if (foundElements.length == 1 && foundElements[0] instanceof IFile){
{
EditorUtility.openInEditor(foundElements[0]); EditorUtility.openInEditor(foundElements[0]);
return true; return true;
} } else if (foundElements.length == 1 && foundElements[0] instanceof LocalFileStorage) {
else
if (foundElements.length == 1 && foundElements[0] instanceof LocalFileStorage)
{
LocalFileStorage newLocation = (LocalFileStorage) foundElements[0]; LocalFileStorage newLocation = (LocalFileStorage) foundElements[0];
if (newLocation.getFullPath().toFile().exists()) if (newLocation.getFullPath().toFile().exists()) {
{
ITranslationUnit remappedTU = tu; ITranslationUnit remappedTU = tu;
if (tu instanceof ExternalTranslationUnit) if (tu instanceof ExternalTranslationUnit)
// TODO: source lookup needs to be modified to use URIs // TODO: source lookup needs to be modified to use URIs
remappedTU = new ExternalTranslationUnit(tu.getParent(), URIUtil.toURI(newLocation.getFullPath()), tu.getContentTypeId()); remappedTU = new ExternalTranslationUnit(tu.getParent(), URIUtil.toURI(newLocation.getFullPath()), tu.getContentTypeId());
EditorUtility.openInEditor(remappedTU); EditorUtility.openInEditor(remappedTU);
return true; return true;
} }
} }
} catch (CoreException e) {} } catch (CoreException e) {
}
} }
} }
return false; return false;
} }
/** /**
* @Override * @Override
* @see org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor#getArtifact() * @see org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor#getArtifact()

View file

@ -8,7 +8,6 @@
* Contributors: * Contributors:
* Nokia - initial API and implementation * Nokia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceNotFoundElement; import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceNotFoundElement;
@ -34,11 +33,9 @@ public class CSourceNotFoundEditorInput extends CommonSourceNotFoundEditorInput
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if (other instanceof CSourceNotFoundEditorInput) if (other instanceof CSourceNotFoundEditorInput) {
{
return super.equals(other) || (this.getName().equals(((CSourceNotFoundEditorInput) other).getName())); return super.equals(other) || (this.getName().equals(((CSourceNotFoundEditorInput) other).getName()));
} }
return super.equals(other); return super.equals(other);
} }
} }

View file

@ -9,36 +9,38 @@
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import java.util.List; import java.util.List;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
/** /**
* The action for sorting the order of source containers in the dialog. * The action for sorting the order of source containers in the dialog.
*
*/ */
public class DownAction extends SourceContainerAction { public class DownAction extends SourceContainerAction {
public DownAction() { public DownAction() {
super(SourceLookupUIMessages.getString( "DownAction.0" )); //$NON-NLS-1$ super(SourceLookupUIMessages.DownAction_0);
} }
/** /**
* @see IAction#run() * @see IAction#run()
*/ */
public void run() { public void run() {
List targets = getOrderedSelection(); List<ISourceContainer> targets = getOrderedSelection();
if (targets.isEmpty()) { if (targets.isEmpty()) {
return; return;
} }
List list = getEntriesAsList(); List<ISourceContainer> list = getEntriesAsList();
int bottom = list.size() - 1; int bottom = list.size() - 1;
int index = 0; int index = 0;
for (int i = targets.size() - 1; i >= 0; i--) { for (int i = targets.size() - 1; i >= 0; i--) {
Object target = targets.get(i); ISourceContainer target = targets.get(i);
index = list.indexOf(target); index = list.indexOf(target);
if (index < bottom) { if (index < bottom) {
bottom = index + 1; bottom = index + 1;
Object temp = list.get(bottom); ISourceContainer temp = list.get(bottom);
list.set(bottom, target); list.set(bottom, target);
list.set(index, temp); list.set(index, temp);
} }
@ -51,7 +53,7 @@ public class DownAction extends SourceContainerAction {
* @see SelectionListenerAction#updateSelection(IStructuredSelection) * @see SelectionListenerAction#updateSelection(IStructuredSelection)
*/ */
protected boolean updateSelection(IStructuredSelection selection) { protected boolean updateSelection(IStructuredSelection selection) {
return !selection.isEmpty() && !isIndexSelected(selection, getEntriesAsList().size() - 1) && getViewer().getTree().getSelection()[0].getParentItem()==null; return !selection.isEmpty() && !isIndexSelected(selection, getEntriesAsList().size() - 1) &&
getViewer().getTree().getSelection()[0].getParentItem() == null;
} }
} }

View file

@ -22,13 +22,12 @@ import org.eclipse.jface.viewers.IStructuredSelection;
* Action used to edit source containers on a source lookup path * Action used to edit source containers on a source lookup path
*/ */
public class EditContainerAction extends SourceContainerAction { public class EditContainerAction extends SourceContainerAction {
private ISourceLookupDirector fDirector; private ISourceLookupDirector fDirector;
private ISourceContainer[] fContainers; private ISourceContainer[] fContainers;
private ISourceContainerBrowser fBrowser; private ISourceContainerBrowser fBrowser;
public EditContainerAction() { public EditContainerAction() {
super(SourceLookupUIMessages.getString( "EditContainerAction.0" )); //$NON-NLS-1$ super(SourceLookupUIMessages.EditContainerAction_0);
} }
/** /**
@ -59,13 +58,13 @@ public class EditContainerAction extends SourceContainerAction {
* @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
*/ */
protected boolean updateSelection(IStructuredSelection selection) { protected boolean updateSelection(IStructuredSelection selection) {
if(selection == null || selection.isEmpty()) { if (selection == null || selection.isEmpty()) {
return false; return false;
} }
if (getViewer().getTree().getSelection()[0].getParentItem()==null) { if (getViewer().getTree().getSelection()[0].getParentItem()==null) {
// can only edit top level items of same type // can only edit top level items of same type
fContainers = new ISourceContainer[selection.size()]; fContainers = new ISourceContainer[selection.size()];
Iterator iterator = selection.iterator(); Iterator<?> iterator = selection.iterator();
ISourceContainer container = (ISourceContainer) iterator.next(); ISourceContainer container = (ISourceContainer) iterator.next();
ISourceContainerType type = container.getType(); ISourceContainerType type = container.getType();
fContainers[0] = container; fContainers[0] = container;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
@ -21,56 +21,54 @@ import org.eclipse.swt.widgets.Shell;
* Adds a path mapping to the source lookup path. * Adds a path mapping to the source lookup path.
*/ */
public class MappingSourceContainerBrowser extends AbstractSourceContainerBrowser { public class MappingSourceContainerBrowser extends AbstractSourceContainerBrowser {
private static final String MAPPING = SourceLookupUIMessages.MappingSourceContainerBrowser_0;
private static final String MAPPING = SourceLookupUIMessages.getString( "MappingSourceContainerBrowser.0" ); //$NON-NLS-1$
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#addSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector) * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#addSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
*/ */
public ISourceContainer[] addSourceContainers( Shell shell, ISourceLookupDirector director ) { public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
return new ISourceContainer[] { new MappingSourceContainer( generateName( director ) ) }; return new ISourceContainer[] { new MappingSourceContainer(generateName(director)) };
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canAddSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector) * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canAddSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
*/ */
public boolean canAddSourceContainers( ISourceLookupDirector director ) { public boolean canAddSourceContainers(ISourceLookupDirector director) {
return true; return true;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[])
*/ */
public boolean canEditSourceContainers( ISourceLookupDirector director, ISourceContainer[] containers ) { public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) {
return ( containers.length == 1 && containers[0] instanceof MappingSourceContainer ); return (containers.length == 1 && containers[0] instanceof MappingSourceContainer);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[])
*/ */
public ISourceContainer[] editSourceContainers( Shell shell, ISourceLookupDirector director, ISourceContainer[] containers ) { public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) {
if ( containers.length == 1 && containers[0] instanceof MappingSourceContainer ) { if (containers.length == 1 && containers[0] instanceof MappingSourceContainer) {
PathMappingDialog dialog = new PathMappingDialog( shell, (MappingSourceContainer)containers[0] ); PathMappingDialog dialog = new PathMappingDialog(shell, (MappingSourceContainer)containers[0]);
if ( dialog.open() == Window.OK ) { if (dialog.open() == Window.OK) {
return new ISourceContainer[] { dialog.getMapping() }; return new ISourceContainer[] { dialog.getMapping() };
} }
} }
return new ISourceContainer[0]; return new ISourceContainer[0];
} }
private String generateName( ISourceLookupDirector director ) { private String generateName(ISourceLookupDirector director) {
// int counter = 1; // int counter = 1;
// ISourceContainer[] containers = director.getSourceContainers(); // ISourceContainer[] containers = director.getSourceContainers();
// for ( int i = 0; i < containers.length; ++i ) { // for (int i = 0; i < containers.length; ++i) {
// if ( MappingSourceContainer.TYPE_ID.equals( containers[i].getType().getId() ) ) { // if (MappingSourceContainer.TYPE_ID.equals(containers[i].getType().getId())) {
// String name = containers[i].getName(); // String name = containers[i].getName();
// if ( name.startsWith( MAPPING ) ) { // if (name.startsWith(MAPPING)) {
// try { // try {
// int number = Integer.valueOf( name.substring( MAPPING.length() ) ).intValue(); // int number = Integer.valueOf(name.substring(MAPPING.length())).intValue();
// if ( number == counter ) // if (number == counter)
// ++counter; // ++counter;
// } // } catch (NumberFormatException e) {
// catch( NumberFormatException e ) {
// } // }
// } // }
// } // }

View file

@ -65,23 +65,22 @@ import org.eclipse.ui.PlatformUI;
public class MappingSourceContainerDialog extends TitleAreaDialog { public class MappingSourceContainerDialog extends TitleAreaDialog {
class EntryCellModifier implements ICellModifier { class EntryCellModifier implements ICellModifier {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String) * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
*/ */
public boolean canModify( Object element, String property ) { public boolean canModify(Object element, String property) {
return ( CP_COMPILATION_PATH.equals( property ) || CP_FILE_SYSTEM_PATH.equals( property ) ); return (CP_COMPILATION_PATH.equals(property) || CP_FILE_SYSTEM_PATH.equals(property));
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String) * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
*/ */
public Object getValue( Object element, String property ) { public Object getValue(Object element, String property) {
if ( element instanceof MapEntrySourceContainer ) { if (element instanceof MapEntrySourceContainer) {
MapEntrySourceContainer entry = (MapEntrySourceContainer)element; MapEntrySourceContainer entry = (MapEntrySourceContainer)element;
if ( CP_COMPILATION_PATH.equals( property ) ) if (CP_COMPILATION_PATH.equals(property))
return entry.getBackendPath().toOSString(); return entry.getBackendPath().toOSString();
if ( CP_FILE_SYSTEM_PATH.equals( property ) ) if (CP_FILE_SYSTEM_PATH.equals(property))
return entry.getLocalPath().toOSString(); return entry.getLocalPath().toOSString();
} }
return null; return null;
@ -90,39 +89,39 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object) * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
*/ */
public void modify( Object element, String property, Object value ) { public void modify(Object element, String property, Object value) {
MapEntrySourceContainer entry = MapEntrySourceContainer entry =
( element instanceof Item ) ? (element instanceof Item) ?
(MapEntrySourceContainer)((Item)element).getData() (MapEntrySourceContainer)((Item)element).getData()
: (MapEntrySourceContainer)element; : (MapEntrySourceContainer)element;
boolean isDirty = false; boolean isDirty = false;
if ( CP_COMPILATION_PATH.equals( property ) ) { if (CP_COMPILATION_PATH.equals(property)) {
entry.setBackendPath( new Path( (String)value) ); entry.setBackendPath(new Path((String)value));
isDirty = true; isDirty = true;
} }
else if ( CP_FILE_SYSTEM_PATH.equals( property ) ) { else if (CP_FILE_SYSTEM_PATH.equals(property)) {
entry.setLocalPath( new Path( (String)value) ); entry.setLocalPath(new Path((String)value));
isDirty = true; isDirty = true;
} }
if ( isDirty ) if (isDirty)
refresh(); refresh();
} }
} }
class DirectoryCellEditor extends DialogCellEditor { class DirectoryCellEditor extends DialogCellEditor {
DirectoryCellEditor( Composite parent ) { DirectoryCellEditor(Composite parent) {
super( parent ); super(parent);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
*/ */
@Override @Override
protected Object openDialogBox( Control cellEditorWindow ) { protected Object openDialogBox(Control cellEditorWindow) {
TableItem[] selection = ((Table)cellEditorWindow.getParent()).getSelection(); TableItem[] selection = ((Table)cellEditorWindow.getParent()).getSelection();
DirectoryDialog dialog = new DirectoryDialog( cellEditorWindow.getShell() ); DirectoryDialog dialog = new DirectoryDialog(cellEditorWindow.getShell());
dialog.setFilterPath( selection[0].getText( 1 ) ); dialog.setFilterPath(selection[0].getText(1));
return dialog.open(); return dialog.open();
} }
} }
@ -132,9 +131,9 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
*/ */
public Image getColumnImage( Object element, int columnIndex ) { public Image getColumnImage(Object element, int columnIndex) {
if ( element instanceof MapEntrySourceContainer && columnIndex == 0 ) { if (element instanceof MapEntrySourceContainer && columnIndex == 0) {
return CDebugImages.get( CDebugImages.IMG_OBJS_PATH_MAP_ENTRY ); return CDebugImages.get(CDebugImages.IMG_OBJS_PATH_MAP_ENTRY);
} }
return null; return null;
} }
@ -142,12 +141,12 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/ */
public String getColumnText( Object element, int columnIndex ) { public String getColumnText(Object element, int columnIndex) {
if ( element instanceof MapEntrySourceContainer ) { if (element instanceof MapEntrySourceContainer) {
MapEntrySourceContainer entry = (MapEntrySourceContainer)element; MapEntrySourceContainer entry = (MapEntrySourceContainer)element;
if ( columnIndex == 0 ) if (columnIndex == 0)
return entry.getBackendPath().toOSString(); return entry.getBackendPath().toOSString();
if ( columnIndex == 1 ) if (columnIndex == 1)
return entry.getLocalPath().toOSString(); return entry.getLocalPath().toOSString();
} }
return null; return null;
@ -172,24 +171,23 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
private boolean fIsValid = true; private boolean fIsValid = true;
public MappingSourceContainerDialog( Shell shell, MappingSourceContainer container ) { public MappingSourceContainerDialog(Shell shell, MappingSourceContainer container) {
super( shell ); super(shell);
fOriginalContainer = container; fOriginalContainer = container;
fContainer = container.copy(); fContainer = container.copy();
fTableListener = new ControlListener() { fTableListener = new ControlListener() {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent) * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent)
*/ */
public void controlMoved( ControlEvent e ) { public void controlMoved(ControlEvent e) {
MappingSourceContainerDialog.this.controlMoved( e ); MappingSourceContainerDialog.this.controlMoved(e);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent) * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent)
*/ */
public void controlResized( ControlEvent e ) { public void controlResized(ControlEvent e) {
MappingSourceContainerDialog.this.controlResized( e ); MappingSourceContainerDialog.this.controlResized(e);
} }
}; };
} }
@ -199,7 +197,7 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
*/ */
@Override @Override
public boolean close() { public boolean close() {
fViewer.getTable().removeControlListener( fTableListener ); fViewer.getTable().removeControlListener(fTableListener);
fContainer.dispose(); fContainer.dispose();
return super.close(); return super.close();
} }
@ -216,19 +214,19 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
*/ */
@Override @Override
protected void configureShell( Shell newShell ) { protected void configureShell(Shell newShell) {
super.configureShell( newShell ); super.configureShell(newShell);
newShell.setText( SourceLookupUIMessages.getString( "PathMappingDialog.16" ) ); //$NON-NLS-1$ newShell.setText(SourceLookupUIMessages.PathMappingDialog_16);
newShell.setToolTipText( SourceLookupUIMessages.getString( "MappingSourceContainerDialog.0" ) ); //$NON-NLS-1$ newShell.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_0);
newShell.setImage( CDebugImages.get( CDebugImages.IMG_OBJS_PATH_MAPPING ) ); newShell.setImage(CDebugImages.get( CDebugImages.IMG_OBJS_PATH_MAPPING));
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite) * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
*/ */
@Override @Override
protected Control createContents( Composite parent ) { protected Control createContents(Composite parent) {
Control control = super.createContents( parent ); Control control = super.createContents(parent);
initialize(); initialize();
return control; return control;
} }
@ -237,24 +235,20 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/ */
@Override @Override
protected Control createDialogArea( Composite parent ) { protected Control createDialogArea(Composite parent) {
Composite control = (Composite)super.createDialogArea( parent ); Composite control = (Composite)super.createDialogArea(parent);
setTitle(SourceLookupUIMessages.PathMappingDialog_0);
setTitleImage(CDebugImages.get(CDebugImages.IMG_WIZBAN_PATH_MAPPING));
setTitle( SourceLookupUIMessages.getString( "PathMappingDialog.0" ) ); //$NON-NLS-1$ Composite composite = new Composite(control, SWT.None);
setTitleImage( CDebugImages.get( CDebugImages.IMG_WIZBAN_PATH_MAPPING ) ); composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Composite composite = new Composite( control, SWT.None ); createNameArea(composite);
composite.setLayout( new GridLayout( 2, false ) ); createViewer(composite);
composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); createViewerButtonBar(composite);
createNameArea( composite );
createViewer( composite );
createViewerButtonBar( composite );
PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAP_ENTRY_DIALOG );
PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAP_ENTRY_DIALOG);
return control; return control;
} }
@ -264,11 +258,10 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
@Override @Override
protected void okPressed() { protected void okPressed() {
fOriginalContainer.clear(); fOriginalContainer.clear();
fOriginalContainer.setName( fNameText.getText().trim() ); fOriginalContainer.setName(fNameText.getText().trim());
try { try {
fOriginalContainer.addMapEntries( (MapEntrySourceContainer[])fContainer.getSourceContainers() ); fOriginalContainer.addMapEntries((MapEntrySourceContainer[])fContainer.getSourceContainers());
} } catch (CoreException e) {
catch( CoreException e ) {
} }
super.okPressed(); super.okPressed();
} }
@ -277,79 +270,76 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
* @see org.eclipse.jface.dialogs.TitleAreaDialog#setErrorMessage(java.lang.String) * @see org.eclipse.jface.dialogs.TitleAreaDialog#setErrorMessage(java.lang.String)
*/ */
@Override @Override
public void setErrorMessage( String newErrorMessage ) { public void setErrorMessage(String newErrorMessage) {
fIsValid = ( newErrorMessage == null ); fIsValid = (newErrorMessage == null);
super.setErrorMessage( newErrorMessage ); super.setErrorMessage(newErrorMessage);
} }
public MappingSourceContainer getContainer() { public MappingSourceContainer getContainer() {
return fOriginalContainer; return fOriginalContainer;
} }
private void createNameArea( Composite parent ) { private void createNameArea(Composite parent) {
Composite composite = new Composite( parent, SWT.None ); Composite composite = new Composite(parent, SWT.None);
composite.setLayout( new GridLayout( 2, false ) ); composite.setLayout(new GridLayout(2, false));
composite.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false, 2, 1 ) ); composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
Label label = new Label( composite, SWT.NONE ); Label label = new Label(composite, SWT.NONE);
label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.12" ) ); //$NON-NLS-1$ label.setText(SourceLookupUIMessages.PathMappingDialog_12);
fNameText = new Text( composite, SWT.BORDER | SWT.SINGLE ); fNameText = new Text(composite, SWT.BORDER | SWT.SINGLE);
GridData data = new GridData( SWT.FILL, SWT.CENTER, false, false ); GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false);
data.widthHint = 200; data.widthHint = 200;
fNameText.setLayoutData( data ); fNameText.setLayoutData(data);
fNameText.addModifyListener( new ModifyListener() { fNameText.addModifyListener(new ModifyListener() {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
*/ */
public void modifyText( ModifyEvent e ) { public void modifyText(ModifyEvent e) {
} }
} ); });
} }
private void createViewer( Composite parent ) { private void createViewer(Composite parent) {
Composite tableComp = new Composite( parent, SWT.NONE ); Composite tableComp = new Composite(parent, SWT.NONE);
tableComp.setLayout( new GridLayout() ); tableComp.setLayout(new GridLayout());
tableComp.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) ); tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
fViewer = new TableViewer( tableComp, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION ); fViewer = new TableViewer(tableComp, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
Table table = fViewer.getTable(); Table table = fViewer.getTable();
table.setLinesVisible( true ); table.setLinesVisible(true);
table.setHeaderVisible( true ); table.setHeaderVisible(true);
GridData data = new GridData( SWT.FILL, SWT.FILL, true, true ); GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.widthHint = 500; data.widthHint = 500;
data.heightHint = 200; data.heightHint = 200;
table.setLayoutData( data ); table.setLayoutData(data);
table.addControlListener( fTableListener ); table.addControlListener(fTableListener);
TableColumn nameColumn = new TableColumn( table, SWT.NULL ); TableColumn nameColumn = new TableColumn(table, SWT.NULL);
nameColumn.setResizable( true ); nameColumn.setResizable(true);
nameColumn.setText( SourceLookupUIMessages.getString( "PathMappingDialog.1" ) ); //$NON-NLS-1$ nameColumn.setText(SourceLookupUIMessages.PathMappingDialog_1);
nameColumn.setToolTipText( SourceLookupUIMessages.getString( "MappingSourceContainerDialog.1" ) ); //$NON-NLS-1$ nameColumn.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_1);
TableColumn valueColumn = new TableColumn( table, SWT.NULL ); TableColumn valueColumn = new TableColumn(table, SWT.NULL);
valueColumn.setResizable( true ); valueColumn.setResizable(true);
valueColumn.setText( SourceLookupUIMessages.getString( "PathMappingDialog.2" ) ); //$NON-NLS-1$ valueColumn.setText(SourceLookupUIMessages.PathMappingDialog_2);
valueColumn.setToolTipText( SourceLookupUIMessages.getString( "MappingSourceContainerDialog.2" ) ); //$NON-NLS-1$ valueColumn.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_2);
fViewer.setColumnProperties( fViewer.setColumnProperties(
new String[] { new String[] {
CP_COMPILATION_PATH, CP_COMPILATION_PATH,
CP_FILE_SYSTEM_PATH, CP_FILE_SYSTEM_PATH,
} ); });
fViewer.setContentProvider( new IStructuredContentProvider() {
fViewer.setContentProvider(new IStructuredContentProvider() {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/ */
public Object[] getElements( Object inputElement ) { public Object[] getElements(Object inputElement) {
if ( inputElement instanceof MappingSourceContainer ) { if (inputElement instanceof MappingSourceContainer) {
try { try {
return ((MappingSourceContainer)inputElement).getSourceContainers(); return ((MappingSourceContainer)inputElement).getSourceContainers();
} } catch (CoreException e) {
catch( CoreException e ) {
} }
} }
return new Object[0]; return new Object[0];
@ -364,137 +354,136 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) * @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) {
} }
} ); });
fViewer.setCellEditors( new CellEditor[] { fViewer.setCellEditors(new CellEditor[] {
new TextCellEditor( table ), new TextCellEditor(table),
new DirectoryCellEditor( table ), new DirectoryCellEditor(table),
} ); });
fViewer.setCellModifier( new EntryCellModifier() ); fViewer.setCellModifier(new EntryCellModifier());
fViewer.setLabelProvider( new EntryLabelProvider() ); fViewer.setLabelProvider(new EntryLabelProvider());
fViewer.addSelectionChangedListener( new ISelectionChangedListener() { fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/ */
public void selectionChanged( SelectionChangedEvent event ) { public void selectionChanged(SelectionChangedEvent event) {
updateViewerButtons(); updateViewerButtons();
} }
} ); });
} }
private void createViewerButtonBar( Composite parent ) { private void createViewerButtonBar(Composite parent) {
Composite buttonComp = new Composite( parent, SWT.NONE ); Composite buttonComp = new Composite(parent, SWT.NONE);
buttonComp.setLayout( new GridLayout() ); buttonComp.setLayout(new GridLayout());
buttonComp.setLayoutData( new GridData( SWT.RIGHT, SWT.FILL, false, false ) ); buttonComp.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
fAddButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "MappingSourceContainerDialog.3" ) ); //$NON-NLS-1$ fAddButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_3);
fAddButton.addSelectionListener( new SelectionAdapter() { fAddButton.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/ */
@Override @Override
public void widgetSelected( SelectionEvent event ) { public void widgetSelected(SelectionEvent event) {
addPathEntry(); addPathEntry();
} }
} ); });
fRemoveButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.15" ) ); //$NON-NLS-1$ fRemoveButton = createPushButton(buttonComp, SourceLookupUIMessages.PathMappingDialog_15);
fRemoveButton.addSelectionListener( new SelectionAdapter() { fRemoveButton.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/ */
@Override @Override
public void widgetSelected( SelectionEvent event ) { public void widgetSelected(SelectionEvent event) {
removePathEntries(); removePathEntries();
} }
} ); });
fUpButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "MappingSourceContainerDialog.4" ) ); //$NON-NLS-1$ fUpButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_4);
fUpButton.addSelectionListener( new SelectionAdapter() { fUpButton.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/ */
@Override @Override
public void widgetSelected( SelectionEvent event ) { public void widgetSelected(SelectionEvent event) {
move( true ); move(true);
} }
} ); });
fDownButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "MappingSourceContainerDialog.5" ) ); //$NON-NLS-1$ fDownButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_5);
fDownButton.addSelectionListener( new SelectionAdapter() { fDownButton.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/ */
@Override @Override
public void widgetSelected( SelectionEvent event ) { public void widgetSelected(SelectionEvent event) {
move( false ); move(false);
} }
} ); });
} }
private void initialize() { private void initialize() {
fNameText.setText( fContainer.getName() ); fNameText.setText(fContainer.getName());
fNameText.selectAll(); fNameText.selectAll();
fViewer.setInput( fContainer ); fViewer.setInput(fContainer);
updateViewerButtons(); updateViewerButtons();
} }
private Button createPushButton( Composite parent, String label ) { private Button createPushButton(Composite parent, String label) {
Button button = new Button( parent, SWT.PUSH ); Button button = new Button(parent, SWT.PUSH);
button.setText( label ); button.setText(label);
GridData gd = new GridData( SWT.FILL, SWT.BEGINNING, true, false ); GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
gd.widthHint = SWTUtil.getButtonWidthHint( button ); gd.widthHint = SWTUtil.getButtonWidthHint(button);
button.setLayoutData( gd ); button.setLayoutData(gd);
return button; return button;
} }
private MapEntrySourceContainer[] getSelectedEntries() { private MapEntrySourceContainer[] getSelectedEntries() {
List<?> list = ((IStructuredSelection)fViewer.getSelection()).toList(); List<?> list = ((IStructuredSelection)fViewer.getSelection()).toList();
return list.toArray( new MapEntrySourceContainer[list.size()] ); return list.toArray(new MapEntrySourceContainer[list.size()]);
} }
private void updateErrorMessage() { private void updateErrorMessage() {
setErrorMessage( null ); setErrorMessage(null);
try { try {
ISourceContainer[] containers = fContainer.getSourceContainers(); ISourceContainer[] containers = fContainer.getSourceContainers();
if ( containers.length == 0 ) if (containers.length == 0)
return; return;
for ( ISourceContainer c : containers ) { for (ISourceContainer c : containers) {
MapEntrySourceContainer entry = (MapEntrySourceContainer)c; MapEntrySourceContainer entry = (MapEntrySourceContainer)c;
IPath backendPath = entry.getBackendPath(); IPath backendPath = entry.getBackendPath();
if ( backendPath.isEmpty() ) { if (backendPath.isEmpty()) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.5" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_5);
break; break;
} }
if ( !backendPath.isValidPath( backendPath.toString() ) ) { if (!backendPath.isValidPath(backendPath.toString())) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.6" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_6);
break; break;
} }
IPath localPath = entry.getLocalPath(); IPath localPath = entry.getLocalPath();
if ( localPath.isEmpty() ) { if (localPath.isEmpty()) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.7" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_7);
break; break;
} }
if ( !localPath.toFile().exists() ) { if (!localPath.toFile().exists()) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.8" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_8);
break; break;
} }
if ( !localPath.toFile().isDirectory() ) { if (!localPath.toFile().isDirectory()) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.9" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_9);
break; break;
} }
if ( !localPath.toFile().isAbsolute() ) { if (!localPath.toFile().isAbsolute()) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.10" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_10);
break; break;
} }
} }
} } catch (CoreException e) {
catch( CoreException e ) {
// ignore // ignore
} }
} }
@ -508,51 +497,49 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
try { try {
ISourceContainer[] allEntries = fContainer.getSourceContainers(); ISourceContainer[] allEntries = fContainer.getSourceContainers();
MapEntrySourceContainer[] entries = getSelectedEntries(); MapEntrySourceContainer[] entries = getSelectedEntries();
if ( entries.length == 0 ) { if (entries.length == 0) {
remove = false; remove = false;
} }
if ( entries.length != 1 ) { if (entries.length != 1) {
up = false; up = false;
down = false; down = false;
} } else {
else { up = (!entries[0].equals(allEntries[0]));
up = ( !entries[0].equals( allEntries[0] ) ); down = (!entries[0].equals(allEntries[allEntries.length - 1]));
down = ( !entries[0].equals( allEntries[allEntries.length - 1] ) );
} }
ok = ( allEntries.length != 0 && fIsValid ); ok = (allEntries.length != 0 && fIsValid);
} } catch (CoreException e) {
catch( CoreException e ) {
// ignore, shouldn't happen // ignore, shouldn't happen
} }
getButton( IDialogConstants.OK_ID ).setEnabled( ok ); getButton(IDialogConstants.OK_ID).setEnabled(ok);
fRemoveButton.setEnabled( remove ); fRemoveButton.setEnabled(remove);
fUpButton.setEnabled( up ); fUpButton.setEnabled(up);
fDownButton.setEnabled( down ); fDownButton.setEnabled(down);
} }
private void refresh() { private void refresh() {
ISelection s = fViewer.getSelection(); ISelection s = fViewer.getSelection();
fViewer.refresh(); fViewer.refresh();
fViewer.setSelection( s ); fViewer.setSelection(s);
updateErrorMessage(); updateErrorMessage();
updateViewerButtons(); updateViewerButtons();
} }
void controlMoved( ControlEvent e ) { void controlMoved(ControlEvent e) {
} }
void controlResized( ControlEvent e ) { void controlResized(ControlEvent e) {
// resize columns // resize columns
Table table = fViewer.getTable(); Table table = fViewer.getTable();
int width = table.getSize().x; int width = table.getSize().x;
if ( width > 0 ) { if (width > 0) {
TableColumn[] columns = table.getColumns(); TableColumn[] columns = table.getColumns();
int colWidth = width / columns.length; int colWidth = width / columns.length;
for ( TableColumn col : columns ) { for (TableColumn col : columns) {
if ( col.getWidth() == 0 ) { if (col.getWidth() == 0) {
col.setWidth( colWidth ); col.setWidth(colWidth);
} }
} }
} }
@ -560,41 +547,39 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
void addPathEntry() { void addPathEntry() {
MapEntrySourceContainer entry = new MapEntrySourceContainer(); MapEntrySourceContainer entry = new MapEntrySourceContainer();
fContainer.addMapEntry( entry ); fContainer.addMapEntry(entry);
fViewer.refresh(); fViewer.refresh();
fViewer.setSelection( new StructuredSelection( entry ), true ); fViewer.setSelection(new StructuredSelection(entry), true);
updateViewerButtons(); updateViewerButtons();
fViewer.editElement( entry, 0 ); fViewer.editElement(entry, 0);
} }
void removePathEntries() { void removePathEntries() {
MapEntrySourceContainer[] entries = getSelectedEntries(); MapEntrySourceContainer[] entries = getSelectedEntries();
fContainer.removeMapEntries( entries ); fContainer.removeMapEntries(entries);
refresh(); refresh();
} }
void move( boolean up ) { void move(boolean up) {
MapEntrySourceContainer[] selEntries = getSelectedEntries(); MapEntrySourceContainer[] selEntries = getSelectedEntries();
if ( selEntries.length != 1 ) if (selEntries.length != 1)
return; return;
MapEntrySourceContainer entry = selEntries[0]; MapEntrySourceContainer entry = selEntries[0];
try { try {
ISourceContainer[] containers = fContainer.getSourceContainers(); ISourceContainer[] containers = fContainer.getSourceContainers();
List<MapEntrySourceContainer> list = new ArrayList<MapEntrySourceContainer>( containers.length ); List<MapEntrySourceContainer> list = new ArrayList<MapEntrySourceContainer>(containers.length);
for ( ISourceContainer container : containers ) { for (ISourceContainer container : containers) {
list.add( ((MapEntrySourceContainer)container).copy() ); list.add(((MapEntrySourceContainer)container).copy());
} }
int index = list.indexOf( entry ); int index = list.indexOf(entry);
list.remove( index ); list.remove(index);
index = ( up ) ? index - 1 : index + 1; index = (up) ? index - 1 : index + 1;
list.add( index, entry ); list.add(index, entry);
fContainer.clear(); fContainer.clear();
fContainer.addMapEntries( list.toArray( new MapEntrySourceContainer[list.size()] ) ); fContainer.addMapEntries(list.toArray(new MapEntrySourceContainer[list.size()]));
refresh(); refresh();
} } catch (CoreException e) {
catch( CoreException e ) { } catch (IndexOutOfBoundsException e) {
}
catch( IndexOutOfBoundsException e ) {
} }
} }
} }

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* ARM Limited - Initial API and implementation * ARM Limited - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer; import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
@ -19,17 +18,16 @@ import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
public class NewMappingSourceContainerBrowser extends AbstractSourceContainerBrowser { public class NewMappingSourceContainerBrowser extends AbstractSourceContainerBrowser {
private static final String MAPPING = SourceLookupUIMessages.MappingSourceContainerBrowser_0;
private static final String MAPPING = SourceLookupUIMessages.getString( "MappingSourceContainerBrowser.0" ); //$NON-NLS-1$
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#addSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector) * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#addSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
*/ */
@Override @Override
public ISourceContainer[] addSourceContainers( Shell shell, ISourceLookupDirector director ) { public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
MappingSourceContainerDialog dialog = MappingSourceContainerDialog dialog =
new MappingSourceContainerDialog( shell, new MappingSourceContainer( MAPPING ) ); new MappingSourceContainerDialog(shell, new MappingSourceContainer(MAPPING));
if ( dialog.open() == Window.OK ) { if (dialog.open() == Window.OK) {
return new ISourceContainer[] { dialog.getContainer() }; return new ISourceContainer[] { dialog.getContainer() };
} }
return new ISourceContainer[0]; return new ISourceContainer[0];
@ -38,18 +36,18 @@ public class NewMappingSourceContainerBrowser extends AbstractSourceContainerBro
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[])
*/ */
public boolean canEditSourceContainers( ISourceLookupDirector director, ISourceContainer[] containers ) { public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) {
return ( containers.length == 1 && containers[0] instanceof MappingSourceContainer ); return (containers.length == 1 && containers[0] instanceof MappingSourceContainer);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[])
*/ */
public ISourceContainer[] editSourceContainers( Shell shell, ISourceLookupDirector director, ISourceContainer[] containers ) { public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) {
if ( containers.length == 1 && containers[0] instanceof MappingSourceContainer ) { if (containers.length == 1 && containers[0] instanceof MappingSourceContainer) {
MappingSourceContainerDialog dialog = MappingSourceContainerDialog dialog =
new MappingSourceContainerDialog( shell, (MappingSourceContainer)containers[0] ); new MappingSourceContainerDialog(shell, (MappingSourceContainer)containers[0]);
if ( dialog.open() == Window.OK ) { if (dialog.open() == Window.OK) {
return new ISourceContainer[] { dialog.getContainer() }; return new ISourceContainer[] { dialog.getContainer() };
} }
} }

View file

@ -11,6 +11,8 @@
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import java.io.File; import java.io.File;
import java.util.List;
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer; import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer; import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
import org.eclipse.cdt.debug.internal.ui.CDebugImages; import org.eclipse.cdt.debug.internal.ui.CDebugImages;
@ -60,218 +62,214 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
public class PathMappingDialog extends TitleAreaDialog { public class PathMappingDialog extends TitleAreaDialog {
class MapEntryDialog extends TitleAreaDialog { class MapEntryDialog extends TitleAreaDialog {
private MapEntrySourceContainer fEntry; private MapEntrySourceContainer fEntry;
protected Text fBackendPathText; protected Text fBackendPathText;
protected Text fLocalPathText; protected Text fLocalPathText;
/** /**
* Constructor for MapEntryDialog. * Constructor for MapEntryDialog.
*/ */
public MapEntryDialog( Shell parentShell ) { public MapEntryDialog(Shell parentShell) {
super( parentShell ); super(parentShell);
fEntry = null; fEntry = null;
} }
/** /**
* Constructor for MapEntryDialog. * Constructor for MapEntryDialog.
*/ */
public MapEntryDialog( Shell parentShell, MapEntrySourceContainer entry ) { public MapEntryDialog(Shell parentShell, MapEntrySourceContainer entry) {
super( parentShell ); super(parentShell);
fEntry = entry; fEntry = entry;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/ */
protected Control createDialogArea( Composite parent ) { protected Control createDialogArea(Composite parent) {
setTitle( SourceLookupUIMessages.getString( "PathMappingDialog.0" ) ); //$NON-NLS-1$ setTitle(SourceLookupUIMessages.PathMappingDialog_0);
setTitleImage( CDebugImages.get( CDebugImages.IMG_WIZBAN_PATH_MAP_ENTRY ) ); setTitleImage(CDebugImages.get(CDebugImages.IMG_WIZBAN_PATH_MAP_ENTRY));
Font font = parent.getFont(); Font font = parent.getFont();
Composite composite = new Composite( parent, SWT.NONE ); Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
layout.numColumns = 2; layout.numColumns = 2;
layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN ); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN ); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING ); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_SPACING ); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout( layout ); composite.setLayout(layout);
GridData data = new GridData( GridData.FILL_BOTH ); GridData data = new GridData(GridData.FILL_BOTH);
composite.setLayoutData( data ); composite.setLayoutData(data);
composite.setFont( font ); composite.setFont(font);
Dialog.applyDialogFont( composite ); Dialog.applyDialogFont(composite);
PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAP_ENTRY_DIALOG ); PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAP_ENTRY_DIALOG);
setMessage( null ); setMessage(null);
Label label = new Label( composite, SWT.LEFT ); Label label = new Label(composite, SWT.LEFT);
label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.1" ) ); //$NON-NLS-1$ label.setText(SourceLookupUIMessages.PathMappingDialog_1);
data = new GridData( GridData.FILL_HORIZONTAL ); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2; data.horizontalSpan = 2;
label.setLayoutData( data ); label.setLayoutData(data);
label.setFont( font ); label.setFont(font);
fBackendPathText = new Text( composite, SWT.SINGLE | SWT.BORDER ); fBackendPathText = new Text(composite, SWT.SINGLE | SWT.BORDER);
data = new GridData( GridData.FILL_HORIZONTAL ); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2; data.horizontalSpan = 2;
fBackendPathText.setLayoutData( data ); fBackendPathText.setLayoutData(data);
fBackendPathText.setFont( font ); fBackendPathText.setFont(font);
fBackendPathText.addModifyListener( new ModifyListener() { fBackendPathText.addModifyListener(new ModifyListener() {
public void modifyText( ModifyEvent e ) { public void modifyText(ModifyEvent e) {
update(); update();
} }
} ); });
label = new Label( composite, SWT.LEFT ); label = new Label(composite, SWT.LEFT);
label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.2" ) ); //$NON-NLS-1$ label.setText(SourceLookupUIMessages.PathMappingDialog_2);
data = new GridData( GridData.FILL_HORIZONTAL ); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2; data.horizontalSpan = 2;
label.setLayoutData( data ); label.setLayoutData(data);
label.setFont( font ); label.setFont(font);
fLocalPathText = new Text( composite, SWT.SINGLE | SWT.BORDER ); fLocalPathText = new Text(composite, SWT.SINGLE | SWT.BORDER);
data = new GridData( GridData.FILL_HORIZONTAL ); data = new GridData(GridData.FILL_HORIZONTAL);
fLocalPathText.setLayoutData( data ); fLocalPathText.setLayoutData(data);
fLocalPathText.setFont( font ); fLocalPathText.setFont(font);
fLocalPathText.addModifyListener( new ModifyListener() { fLocalPathText.addModifyListener(new ModifyListener() {
public void modifyText( ModifyEvent e ) { public void modifyText(ModifyEvent e) {
update(); update();
} }
} ); });
Button button = new Button( composite, SWT.PUSH ); Button button = new Button(composite, SWT.PUSH);
button.setFont( font ); button.setFont(font);
button.setText( SourceLookupUIMessages.getString( "PathMappingDialog.3" ) ); //$NON-NLS-1$ button.setText(SourceLookupUIMessages.PathMappingDialog_3);
button.addSelectionListener( new SelectionListener() { button.addSelectionListener(new SelectionListener() {
public void widgetSelected( SelectionEvent e ) { public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog( MapEntryDialog.this.getShell() ); DirectoryDialog dialog = new DirectoryDialog(MapEntryDialog.this.getShell());
String path = dialog.open(); String path = dialog.open();
if ( path != null ) { if (path != null) {
fLocalPathText.setText( path ); fLocalPathText.setText(path);
} }
} }
public void widgetDefaultSelected( SelectionEvent e ) { public void widgetDefaultSelected(SelectionEvent e) {
} }
} ); });
return composite; return composite;
} }
protected Control createContents( Composite parent ) { protected Control createContents(Composite parent) {
Control control = super.createContents( parent ); Control control = super.createContents(parent);
initialize(); initialize();
update(); update();
return control; return control;
} }
protected void configureShell( Shell newShell ) { protected void configureShell(Shell newShell) {
newShell.setText( SourceLookupUIMessages.getString( "PathMappingDialog.4" ) ); //$NON-NLS-1$ newShell.setText(SourceLookupUIMessages.PathMappingDialog_4);
super.configureShell( newShell ); super.configureShell(newShell);
} }
private void initialize() { private void initialize() {
if ( fEntry != null ) { if (fEntry != null) {
fBackendPathText.setText( fEntry.getBackendPath().toOSString() ); fBackendPathText.setText(fEntry.getBackendPath().toOSString());
fLocalPathText.setText( fEntry.getLocalPath().toOSString() ); fLocalPathText.setText(fEntry.getLocalPath().toOSString());
} }
} }
protected void update() { protected void update() {
boolean isOk = updateErrorMessage(); boolean isOk = updateErrorMessage();
Button ok = getButton( IDialogConstants.OK_ID ); Button ok = getButton(IDialogConstants.OK_ID);
if ( ok != null ) if (ok != null)
ok.setEnabled( isOk ); ok.setEnabled(isOk);
} }
protected boolean updateErrorMessage() { protected boolean updateErrorMessage() {
setErrorMessage( null ); setErrorMessage(null);
String backendText = fBackendPathText.getText().trim(); String backendText = fBackendPathText.getText().trim();
if ( backendText.length() == 0 ) { if (backendText.length() == 0) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.5" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_5);
return false; return false;
} }
if ( !new Path( backendText ).isValidPath( backendText ) ) { if (!new Path(backendText).isValidPath(backendText)) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.6" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_6);
return false; return false;
} }
String localText = fLocalPathText.getText().trim(); String localText = fLocalPathText.getText().trim();
if ( localText.length() == 0 ) { if (localText.length() == 0) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.7" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_7);
return false; return false;
} }
File localPath = new File( localText ); File localPath = new File(localText);
if ( !localPath.exists() ) { if (!localPath.exists()) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.8" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_8);
return false; return false;
} }
if ( !localPath.isDirectory() ) { if (!localPath.isDirectory()) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.9" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_9);
return false; return false;
} }
if ( !localPath.isAbsolute() ) { if (!localPath.isAbsolute()) {
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.10" ) ); //$NON-NLS-1$ setErrorMessage(SourceLookupUIMessages.PathMappingDialog_10);
return false; return false;
} }
return true; return true;
} }
protected IPath getBackendPath() { protected IPath getBackendPath() {
return new Path( fBackendPathText.getText().trim() ); return new Path(fBackendPathText.getText().trim());
} }
protected IPath getLocalPath() { protected IPath getLocalPath() {
return new Path( fLocalPathText.getText().trim() ); return new Path(fLocalPathText.getText().trim());
} }
protected void okPressed() { protected void okPressed() {
if ( fEntry == null ) { if (fEntry == null) {
fEntry = new MapEntrySourceContainer(); fEntry = new MapEntrySourceContainer();
fMapping.addMapEntry( fEntry ); fMapping.addMapEntry(fEntry);
} }
fEntry.setBackendPath( getBackendPath() ); fEntry.setBackendPath(getBackendPath());
fEntry.setLocalPath( getLocalPath() ); fEntry.setLocalPath(getLocalPath());
super.okPressed(); super.okPressed();
} }
} }
class PathMappingLabelProvider extends LabelProvider { class PathMappingLabelProvider extends LabelProvider {
private ILabelProvider fLabelProvider = null; private ILabelProvider fLabelProvider = null;
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
*/ */
public Image getImage( Object element ) { public Image getImage(Object element) {
Image image = getWorkbenchLabelProvider().getImage( element ); Image image = getWorkbenchLabelProvider().getImage(element);
if ( image != null ) { if (image != null) {
return image; return image;
} }
return super.getImage( element ); return super.getImage(element);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/ */
public String getText( Object element ) { public String getText(Object element) {
String label = getWorkbenchLabelProvider().getText( element ); String label = getWorkbenchLabelProvider().getText(element);
if ( label == null || label.length() == 0 ) { if (label == null || label.length() == 0) {
if ( element instanceof ISourceContainer ) { if (element instanceof ISourceContainer) {
return ((ISourceContainer)element).getName(); return ((ISourceContainer)element).getName();
} }
} } else {
else {
return label; return label;
} }
return super.getText( element ); return super.getText(element);
} }
private ILabelProvider getWorkbenchLabelProvider() { private ILabelProvider getWorkbenchLabelProvider() {
if ( fLabelProvider == null ) { if (fLabelProvider == null) {
fLabelProvider = new WorkbenchLabelProvider(); fLabelProvider = new WorkbenchLabelProvider();
} }
return fLabelProvider; return fLabelProvider;
@ -282,24 +280,22 @@ public class PathMappingDialog extends TitleAreaDialog {
*/ */
public void dispose() { public void dispose() {
super.dispose(); super.dispose();
if ( fLabelProvider != null ) { if (fLabelProvider != null) {
fLabelProvider.dispose(); fLabelProvider.dispose();
} }
} }
} }
class ContentProvider implements IStructuredContentProvider { class ContentProvider implements IStructuredContentProvider {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/ */
public Object[] getElements( Object input ) { public Object[] getElements(Object input) {
if ( input instanceof MappingSourceContainer ) { if (input instanceof MappingSourceContainer) {
try { try {
return ((MappingSourceContainer)input).getSourceContainers(); return ((MappingSourceContainer)input).getSourceContainers();
} } catch(CoreException e) {
catch( CoreException e ) { setErrorMessage(e.getMessage());
setErrorMessage( e.getMessage() );
} }
} }
return null; return null;
@ -314,14 +310,12 @@ public class PathMappingDialog extends TitleAreaDialog {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) * @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) {
} }
} }
private MappingSourceContainer fOriginalMapping; private MappingSourceContainer fOriginalMapping;
protected MappingSourceContainer fMapping; protected MappingSourceContainer fMapping;
private TableViewer fViewer; private TableViewer fViewer;
private Text fNameText; private Text fNameText;
@ -329,8 +323,8 @@ public class PathMappingDialog extends TitleAreaDialog {
private Button fEditButton; private Button fEditButton;
private Button fRemoveButton; private Button fRemoveButton;
public PathMappingDialog( Shell parentShell, MappingSourceContainer mapping ) { public PathMappingDialog(Shell parentShell, MappingSourceContainer mapping) {
super( parentShell ); super(parentShell);
fOriginalMapping = mapping; fOriginalMapping = mapping;
fMapping = fOriginalMapping.copy(); fMapping = fOriginalMapping.copy();
} }
@ -338,8 +332,8 @@ public class PathMappingDialog extends TitleAreaDialog {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite) * @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
*/ */
protected Control createContents( Composite parent ) { protected Control createContents(Composite parent) {
Control control = super.createContents( parent ); Control control = super.createContents(parent);
updateButtons(); updateButtons();
return control; return control;
} }
@ -347,119 +341,118 @@ public class PathMappingDialog extends TitleAreaDialog {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite) * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/ */
protected Control createDialogArea( Composite parent ) { protected Control createDialogArea(Composite parent) {
setTitle( SourceLookupUIMessages.getString( "PathMappingDialog.11" ) ); //$NON-NLS-1$ setTitle(SourceLookupUIMessages.PathMappingDialog_11);
setTitleImage( CDebugImages.get( CDebugImages.IMG_WIZBAN_PATH_MAPPING ) ); setTitleImage(CDebugImages.get(CDebugImages.IMG_WIZBAN_PATH_MAPPING));
Font font = parent.getFont(); Font font = parent.getFont();
Composite composite = new Composite( parent, SWT.NONE ); Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(); GridLayout layout = new GridLayout();
layout.numColumns = 2; layout.numColumns = 2;
layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN ); layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN ); layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING ); layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_SPACING ); layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout( layout ); composite.setLayout(layout);
GridData data = new GridData( GridData.FILL_BOTH ); GridData data = new GridData(GridData.FILL_BOTH);
composite.setLayoutData( data ); composite.setLayoutData(data);
composite.setFont( font ); composite.setFont(font);
Dialog.applyDialogFont( composite ); Dialog.applyDialogFont(composite);
PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAPPING_DIALOG ); PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAPPING_DIALOG);
Composite nameComp = new Composite( composite, SWT.NONE ); Composite nameComp = new Composite(composite, SWT.NONE);
layout = new GridLayout(); layout = new GridLayout();
layout.numColumns = 2; layout.numColumns = 2;
nameComp.setLayout( layout ); nameComp.setLayout(layout);
data = new GridData( GridData.FILL_HORIZONTAL ); data = new GridData(GridData.FILL_HORIZONTAL);
data.horizontalSpan = 2; data.horizontalSpan = 2;
nameComp.setLayoutData( data ); nameComp.setLayoutData(data);
nameComp.setFont( font ); nameComp.setFont(font);
Label label = new Label( nameComp, SWT.LEFT ); Label label = new Label(nameComp, SWT.LEFT);
data = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING ); data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
label.setLayoutData( data ); label.setLayoutData(data);
label.setFont( font ); label.setFont(font);
label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.12" ) ); //$NON-NLS-1$ label.setText(SourceLookupUIMessages.PathMappingDialog_12);
fNameText = new Text( nameComp, SWT.SINGLE | SWT.BORDER ); fNameText = new Text(nameComp, SWT.SINGLE | SWT.BORDER);
data = new GridData( GridData.FILL_HORIZONTAL ); data = new GridData(GridData.FILL_HORIZONTAL);
fNameText.setLayoutData( data ); fNameText.setLayoutData(data);
fNameText.setFont( font ); fNameText.setFont(font);
fNameText.setText( getMapping().getName() ); fNameText.setText(getMapping().getName());
fNameText.addModifyListener( new ModifyListener() { fNameText.addModifyListener(new ModifyListener() {
public void modifyText( ModifyEvent e ) { public void modifyText(ModifyEvent e) {
} }
} ); });
fViewer = createViewer( composite ); fViewer = createViewer(composite);
data = new GridData( GridData.FILL_BOTH ); data = new GridData(GridData.FILL_BOTH);
fViewer.getControl().setLayoutData( data ); fViewer.getControl().setLayoutData(data);
fViewer.getControl().setFont( font ); fViewer.getControl().setFont(font);
fViewer.addSelectionChangedListener( new ISelectionChangedListener() { fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged( SelectionChangedEvent event ) { public void selectionChanged(SelectionChangedEvent event) {
updateButtons(); updateButtons();
} }
} ); });
Composite buttonComp = new Composite( composite, SWT.NONE ); Composite buttonComp = new Composite(composite, SWT.NONE);
GridLayout buttonLayout = new GridLayout(); GridLayout buttonLayout = new GridLayout();
buttonLayout.marginHeight = 0; buttonLayout.marginHeight = 0;
buttonLayout.marginWidth = 0; buttonLayout.marginWidth = 0;
buttonComp.setLayout( buttonLayout ); buttonComp.setLayout(buttonLayout);
data = new GridData( GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL ); data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
buttonComp.setLayoutData( data ); buttonComp.setLayoutData(data);
buttonComp.setFont( font ); buttonComp.setFont(font);
GC gc = new GC( parent ); GC gc = new GC(parent);
gc.setFont( parent.getFont() ); gc.setFont(parent.getFont());
FontMetrics fontMetrics = gc.getFontMetrics(); FontMetrics fontMetrics = gc.getFontMetrics();
gc.dispose(); gc.dispose();
fAddButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.13" ), fontMetrics ); //$NON-NLS-1$ fAddButton = createPushButton(buttonComp, SourceLookupUIMessages.PathMappingDialog_13, fontMetrics);
fAddButton.addSelectionListener( new SelectionAdapter() { fAddButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected( SelectionEvent evt ) { public void widgetSelected(SelectionEvent evt) {
MapEntryDialog dialog = new MapEntryDialog( getShell() ); MapEntryDialog dialog = new MapEntryDialog(getShell());
if ( dialog.open() == Window.OK ) { if (dialog.open() == Window.OK) {
getViewer().refresh(); getViewer().refresh();
} }
} }
} ); });
fEditButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.14" ), fontMetrics ); //$NON-NLS-1$ fEditButton = createPushButton(buttonComp, SourceLookupUIMessages.PathMappingDialog_14, fontMetrics);
fEditButton.addSelectionListener( new SelectionAdapter() { fEditButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected( SelectionEvent evt ) { public void widgetSelected(SelectionEvent evt) {
MapEntrySourceContainer[] entries = getSelection(); MapEntrySourceContainer[] entries = getSelection();
if ( entries.length > 0 ) { if (entries.length > 0) {
MapEntryDialog dialog = new MapEntryDialog( getShell(), entries[0] ); MapEntryDialog dialog = new MapEntryDialog(getShell(), entries[0]);
if ( dialog.open() == Window.OK ) { if (dialog.open() == Window.OK) {
getViewer().refresh(); getViewer().refresh();
} }
} }
} }
} ); });
fRemoveButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.15" ), fontMetrics ); //$NON-NLS-1$ fRemoveButton = createPushButton(buttonComp, SourceLookupUIMessages.PathMappingDialog_15, fontMetrics);
fRemoveButton.addSelectionListener( new SelectionAdapter() { fRemoveButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected( SelectionEvent evt ) { public void widgetSelected(SelectionEvent evt) {
MapEntrySourceContainer[] entries = getSelection(); MapEntrySourceContainer[] entries = getSelection();
for ( int i = 0; i < entries.length; ++i ) { for (int i = 0; i < entries.length; ++i) {
fMapping.removeMapEntry( entries[i] ); fMapping.removeMapEntry(entries[i]);
} }
getViewer().refresh(); getViewer().refresh();
} }
} ); });
setMessage( null ); setMessage(null);
fViewer.setInput(fMapping);
fViewer.setInput( fMapping );
return composite; return composite;
} }
private TableViewer createViewer( Composite parent ) { private TableViewer createViewer(Composite parent) {
TableViewer viewer = new TableViewer( parent ); TableViewer viewer = new TableViewer(parent);
viewer.setContentProvider( new ContentProvider() ); viewer.setContentProvider(new ContentProvider());
viewer.setLabelProvider( new PathMappingLabelProvider() ); viewer.setLabelProvider(new PathMappingLabelProvider());
return viewer; return viewer;
} }
@ -467,28 +460,28 @@ public class PathMappingDialog extends TitleAreaDialog {
return fOriginalMapping; return fOriginalMapping;
} }
protected Button createPushButton( Composite parent, String label, FontMetrics fontMetrics ) { protected Button createPushButton(Composite parent, String label, FontMetrics fontMetrics) {
Button button = new Button( parent, SWT.PUSH ); Button button = new Button(parent, SWT.PUSH);
button.setFont( parent.getFont() ); button.setFont(parent.getFont());
button.setText( label ); button.setText(label);
GridData gd = getButtonGridData( button, fontMetrics ); GridData gd = getButtonGridData(button, fontMetrics);
button.setLayoutData( gd ); button.setLayoutData(gd);
return button; return button;
} }
private GridData getButtonGridData( Button button, FontMetrics fontMetrics ) { private GridData getButtonGridData(Button button, FontMetrics fontMetrics) {
GridData gd = new GridData( GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING ); GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
int widthHint = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH ); int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
gd.widthHint = Math.max( widthHint, button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x ); gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
return gd; return gd;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
*/ */
protected void configureShell( Shell newShell ) { protected void configureShell(Shell newShell) {
newShell.setText( SourceLookupUIMessages.getString( "PathMappingDialog.16" ) ); //$NON-NLS-1$ newShell.setText(SourceLookupUIMessages.PathMappingDialog_16);
super.configureShell( newShell ); super.configureShell(newShell);
} }
protected Viewer getViewer() { protected Viewer getViewer() {
@ -500,11 +493,10 @@ public class PathMappingDialog extends TitleAreaDialog {
*/ */
protected void okPressed() { protected void okPressed() {
fOriginalMapping.clear(); fOriginalMapping.clear();
fOriginalMapping.setName( fNameText.getText().trim() ); fOriginalMapping.setName(fNameText.getText().trim());
try { try {
fOriginalMapping.addMapEntries( (MapEntrySourceContainer[])fMapping.getSourceContainers() ); fOriginalMapping.addMapEntries((MapEntrySourceContainer[])fMapping.getSourceContainers());
} } catch(CoreException e) {
catch( CoreException e ) {
} }
fMapping.dispose(); fMapping.dispose();
super.okPressed(); super.okPressed();
@ -513,20 +505,21 @@ public class PathMappingDialog extends TitleAreaDialog {
protected MapEntrySourceContainer[] getSelection() { protected MapEntrySourceContainer[] getSelection() {
MapEntrySourceContainer[] result = new MapEntrySourceContainer[0]; MapEntrySourceContainer[] result = new MapEntrySourceContainer[0];
ISelection s = getViewer().getSelection(); ISelection s = getViewer().getSelection();
if ( s instanceof IStructuredSelection ) { if (s instanceof IStructuredSelection) {
int size = ((IStructuredSelection)s).size(); int size = ((IStructuredSelection)s).size();
result = (MapEntrySourceContainer[])((IStructuredSelection)s).toList().toArray( new MapEntrySourceContainer[size] ); List<?> list = ((IStructuredSelection) s).toList();
result = list.toArray(new MapEntrySourceContainer[size]);
} }
return result; return result;
} }
protected void updateButtons() { protected void updateButtons() {
MapEntrySourceContainer[] entries = getSelection(); MapEntrySourceContainer[] entries = getSelection();
if ( fEditButton != null ) { if (fEditButton != null) {
fEditButton.setEnabled( entries.length == 1 ); fEditButton.setEnabled(entries.length == 1);
} }
if ( fRemoveButton != null ) { if (fRemoveButton != null) {
fRemoveButton.setEnabled( entries.length > 0 ); fRemoveButton.setEnabled(entries.length > 0);
} }
} }
} }

View file

@ -12,24 +12,25 @@ package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import java.util.List; import java.util.List;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
/** /**
* The action used to remove source containers in the source location dialog/tab. * The action used to remove source containers in the source location dialog/tab.
*
*/ */
public class RemoveAction extends SourceContainerAction { public class RemoveAction extends SourceContainerAction {
public RemoveAction() { public RemoveAction() {
super(SourceLookupUIMessages.getString( "RemoveAction.0" )); //$NON-NLS-1$ super(SourceLookupUIMessages.RemoveAction_0);
} }
/** /**
* Removes all selected entries. * Removes all selected entries.
* *
* @see IAction#run() * @see IAction#run()
*/ */
public void run() { public void run() {
List targets = getOrderedSelection(); List<ISourceContainer> targets = getOrderedSelection();
List list = getEntriesAsList(); List<ISourceContainer> list = getEntriesAsList();
list.removeAll(targets); list.removeAll(targets);
setEntries(list); setEntries(list);
} }
@ -39,7 +40,6 @@ public class RemoveAction extends SourceContainerAction {
*/ */
protected boolean updateSelection(IStructuredSelection selection) { protected boolean updateSelection(IStructuredSelection selection) {
//check that something is selected and it is a root tree node. //check that something is selected and it is a root tree node.
return !selection.isEmpty() && getViewer().getTree().getSelection()[0].getParentItem()==null; return !selection.isEmpty() && getViewer().getTree().getSelection()[0].getParentItem() == null;
} }
} }

View file

@ -71,10 +71,9 @@ public abstract class SourceContainerAction extends SelectionListenerAction {
* *
* @return targets for an action * @return targets for an action
*/ */
protected List getOrderedSelection() { protected List<ISourceContainer> getOrderedSelection() {
List targets = new ArrayList(); List<ISourceContainer> targets = new ArrayList<ISourceContainer>();
List selection = List<?> selection = ((IStructuredSelection) getViewer().getSelection()).toList();
((IStructuredSelection) getViewer().getSelection()).toList();
ISourceContainer[] entries = getViewer().getEntries(); ISourceContainer[] entries = getViewer().getEntries();
for (int i = 0; i < entries.length; i++) { for (int i = 0; i < entries.length; i++) {
ISourceContainer target = entries[i]; ISourceContainer target = entries[i];
@ -88,9 +87,9 @@ public abstract class SourceContainerAction extends SelectionListenerAction {
/** /**
* Returns a list (copy) of the entries in the viewer * Returns a list (copy) of the entries in the viewer
*/ */
protected List getEntriesAsList() { protected List<ISourceContainer> getEntriesAsList() {
ISourceContainer[] entries = getViewer().getEntries(); ISourceContainer[] entries = getViewer().getEntries();
List list = new ArrayList(entries.length); List<ISourceContainer> list = new ArrayList<ISourceContainer>(entries.length);
for (int i = 0; i < entries.length; i++) { for (int i = 0; i < entries.length; i++) {
list.add(entries[i]); list.add(entries[i]);
} }
@ -100,9 +99,8 @@ public abstract class SourceContainerAction extends SelectionListenerAction {
/** /**
* Updates the entries to the entries in the given list * Updates the entries to the entries in the given list
*/ */
protected void setEntries(List list) { protected void setEntries(List<ISourceContainer> list) {
getViewer().setEntries( getViewer().setEntries(list.toArray(new ISourceContainer[list.size()]));
(ISourceContainer[]) list.toArray(new ISourceContainer[list.size()]));
// update all selection listeners // update all selection listeners
getViewer().setSelection(getViewer().getSelection()); getViewer().setSelection(getViewer().getSelection());
} }
@ -111,14 +109,12 @@ public abstract class SourceContainerAction extends SelectionListenerAction {
* Returns whether the item at the given index in the list * Returns whether the item at the given index in the list
* (visually) is selected. * (visually) is selected.
*/ */
protected boolean isIndexSelected( protected boolean isIndexSelected(IStructuredSelection selection, int index) {
IStructuredSelection selection,
int index) {
if (selection.isEmpty()) { if (selection.isEmpty()) {
return false; return false;
} }
Iterator entries = selection.iterator(); Iterator<?> entries = selection.iterator();
List list = getEntriesAsList(); List<?> list = getEntriesAsList();
while (entries.hasNext()) { while (entries.hasNext()) {
Object next = entries.next(); Object next = entries.next();
if (list.indexOf(next) == index) { if (list.indexOf(next) == index) {

View file

@ -21,8 +21,8 @@ public class SourceContainerAdapterFactory implements IAdapterFactory {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/ */
public Object getAdapter( Object adaptableObject, Class adapterType ) { public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
if ( adapterType.equals( IWorkbenchAdapter.class ) ) { if (adapterType.equals(IWorkbenchAdapter.class)) {
return new SourceContainerWorkbenchAdapter(); return new SourceContainerWorkbenchAdapter();
} }
return null; return null;
@ -31,7 +31,7 @@ public class SourceContainerAdapterFactory implements IAdapterFactory {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/ */
public Class[] getAdapterList() { public Class<?>[] getAdapterList() {
return new Class[]{ IWorkbenchAdapter.class }; return new Class[]{ IWorkbenchAdapter.class };
} }
} }

View file

@ -22,7 +22,6 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
* Label provider for source containers and source container types. * Label provider for source containers and source container types.
*/ */
public class SourceContainerLabelProvider extends LabelProvider { public class SourceContainerLabelProvider extends LabelProvider {
private ILabelProvider fLabelProvider = null; private ILabelProvider fLabelProvider = null;
/* (non-Javadoc) /* (non-Javadoc)
@ -33,7 +32,7 @@ public class SourceContainerLabelProvider extends LabelProvider {
if (image == null) { if (image == null) {
ISourceContainerType type = null; ISourceContainerType type = null;
if (element instanceof ISourceContainer) { if (element instanceof ISourceContainer) {
type = ((ISourceContainer)element).getType(); type = ((ISourceContainer) element).getType();
} else if (element instanceof ISourceContainerType) { } else if (element instanceof ISourceContainerType) {
type = (ISourceContainerType) element; type = (ISourceContainerType) element;
} }
@ -58,7 +57,7 @@ public class SourceContainerLabelProvider extends LabelProvider {
if (element instanceof ISourceContainer) { if (element instanceof ISourceContainer) {
return ((ISourceContainer) element).getName(); return ((ISourceContainer) element).getName();
} else if (element instanceof ISourceContainerType) { } else if (element instanceof ISourceContainerType) {
return ((ISourceContainerType)element).getName(); return ((ISourceContainerType) element).getName();
} }
} else { } else {
return label; return label;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
@ -26,7 +26,6 @@ import org.eclipse.swt.widgets.Composite;
* It is a tree viewer since the containers are represented in tree form. * It is a tree viewer since the containers are represented in tree form.
*/ */
public class SourceContainerViewer extends TreeViewer { public class SourceContainerViewer extends TreeViewer {
/** /**
* Whether enabled/editable. * Whether enabled/editable.
*/ */
@ -34,10 +33,9 @@ public class SourceContainerViewer extends TreeViewer {
/** /**
* The source container entries displayed in this viewer * The source container entries displayed in this viewer
*/ */
protected List fEntries = new ArrayList(); protected List<ISourceContainer> fEntries = new ArrayList<ISourceContainer>();
class ContentProvider implements ITreeContentProvider { class ContentProvider implements ITreeContentProvider {
/** /**
* @see IStructuredContentProvider#getElements(Object) * @see IStructuredContentProvider#getElements(Object)
*/ */
@ -81,7 +79,6 @@ public class SourceContainerViewer extends TreeViewer {
public boolean hasChildren(Object element) { public boolean hasChildren(Object element) {
return ((ISourceContainer)element).isComposite(); return ((ISourceContainer)element).isComposite();
} }
} }
/** /**
@ -105,13 +102,13 @@ public class SourceContainerViewer extends TreeViewer {
public void setEntries(ISourceContainer[] entries) { public void setEntries(ISourceContainer[] entries) {
fEntries.clear(); fEntries.clear();
for (int i = 0; i < entries.length; i++) { for (int i = 0; i < entries.length; i++) {
if(entries[i] != null) if (entries[i] != null)
fEntries.add(entries[i]); fEntries.add(entries[i]);
} }
if (getInput() == null) { if (getInput() == null) {
setInput(fEntries); setInput(fEntries);
//select first item in list //select first item in list
if(!fEntries.isEmpty() && fEntries.get(0)!=null) if (!fEntries.isEmpty() && fEntries.get(0)!=null)
setSelection(new StructuredSelection(fEntries.get(0))); setSelection(new StructuredSelection(fEntries.get(0)));
} else { } else {
refresh(); refresh();
@ -124,7 +121,7 @@ public class SourceContainerViewer extends TreeViewer {
* @return the entries in this viewer * @return the entries in this viewer
*/ */
public ISourceContainer[] getEntries() { public ISourceContainer[] getEntries() {
return (ISourceContainer[])fEntries.toArray(new ISourceContainer[fEntries.size()]); return fEntries.toArray(new ISourceContainer[fEntries.size()]);
} }
/** /**
@ -143,8 +140,7 @@ public class SourceContainerViewer extends TreeViewer {
fEntries.add(entries[i]); fEntries.add(entries[i]);
} }
} }
} } else {
else {
int index = fEntries.indexOf(sel.getFirstElement()); int index = fEntries.indexOf(sel.getFirstElement());
for (int i = 0; i < entries.length; i++) { for (int i = 0; i < entries.length; i++) {
if (!fEntries.contains(entries[i])) { if (!fEntries.contains(entries[i])) {
@ -154,7 +150,7 @@ public class SourceContainerViewer extends TreeViewer {
} }
} }
if(!fEntries.isEmpty() && fEntries.get(0)!=null) if (!fEntries.isEmpty() && fEntries.get(0)!=null)
setSelection(new StructuredSelection(fEntries.get(0))); setSelection(new StructuredSelection(fEntries.get(0)));
refresh(); refresh();
} }
@ -166,7 +162,7 @@ public class SourceContainerViewer extends TreeViewer {
*/ */
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
fEnabled = enabled; fEnabled = enabled;
// fire selection change to upate actions // fire selection change to update actions
setSelection(getSelection()); setSelection(getSelection());
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
@ -31,33 +31,33 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
*/ */
public Object[] getChildren( Object o ) { public Object[] getChildren(Object o) {
return null; return null;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
*/ */
public ImageDescriptor getImageDescriptor( Object o ) { public ImageDescriptor getImageDescriptor(Object o) {
if ( o instanceof MappingSourceContainer ) { if (o instanceof MappingSourceContainer) {
return CDebugImages.DESC_OBJS_PATH_MAPPING; return CDebugImages.DESC_OBJS_PATH_MAPPING;
} }
if ( o instanceof MapEntrySourceContainer ) { if (o instanceof MapEntrySourceContainer) {
return CDebugImages.DESC_OBJS_PATH_MAP_ENTRY; return CDebugImages.DESC_OBJS_PATH_MAP_ENTRY;
} }
if ( o instanceof ProjectSourceContainer ) { if (o instanceof ProjectSourceContainer) {
IProject project = ((ProjectSourceContainer)o).getProject(); IProject project = ((ProjectSourceContainer)o).getProject();
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create( project ); ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
if ( cProject != null ) if (cProject != null)
return getImageDescriptor( cProject ); return getImageDescriptor(cProject);
} }
return null; return null;
} }
protected ImageDescriptor getImageDescriptor( ICElement element ) { protected ImageDescriptor getImageDescriptor(ICElement element) {
IWorkbenchAdapter adapter = (IWorkbenchAdapter)element.getAdapter( IWorkbenchAdapter.class ); IWorkbenchAdapter adapter = (IWorkbenchAdapter)element.getAdapter(IWorkbenchAdapter.class);
if ( adapter != null ) { if (adapter != null) {
return adapter.getImageDescriptor( element ); return adapter.getImageDescriptor(element);
} }
return null; return null;
} }
@ -65,11 +65,11 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
*/ */
public String getLabel( Object o ) { public String getLabel(Object o) {
if ( o instanceof MappingSourceContainer ) { if (o instanceof MappingSourceContainer) {
return SourceLookupUIMessages.getString( "SourceContainerWorkbenchAdapter.0" ) + ((MappingSourceContainer)o).getName(); //$NON-NLS-1$ return SourceLookupUIMessages.SourceContainerWorkbenchAdapter_0 + ((MappingSourceContainer)o).getName();
} }
if ( o instanceof MapEntrySourceContainer ) { if (o instanceof MapEntrySourceContainer) {
return ((MapEntrySourceContainer)o).getName(); return ((MapEntrySourceContainer)o).getName();
} }
return null; return null;
@ -78,23 +78,23 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
*/ */
public Object getParent( Object o ) { public Object getParent(Object o) {
return null; return null;
} }
public String getQualifiedName( IPath path ) { public String getQualifiedName(IPath path) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
String[] segments = path.segments(); String[] segments = path.segments();
if ( segments.length > 0 ) { if (segments.length > 0) {
buffer.append( path.lastSegment() ); buffer.append(path.lastSegment());
if ( segments.length > 1 ) { if (segments.length > 1) {
buffer.append( " - " ); //$NON-NLS-1$ buffer.append(" - "); //$NON-NLS-1$
if ( path.getDevice() != null ) { if (path.getDevice() != null) {
buffer.append( path.getDevice() ); buffer.append(path.getDevice());
} }
for( int i = 0; i < segments.length - 1; i++ ) { for(int i = 0; i < segments.length - 1; i++) {
buffer.append( File.separatorChar ); buffer.append(File.separatorChar);
buffer.append( segments[i] ); buffer.append(segments[i]);
} }
} }
return buffer.toString(); return buffer.toString();

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* ARM Limited - Initial API and implementation * ARM Limited - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import org.eclipse.cdt.debug.core.model.ICStackFrame; import org.eclipse.cdt.debug.core.model.ICStackFrame;
@ -34,10 +33,9 @@ import org.eclipse.ui.progress.UIJob;
public class SourceDisplayAdapter implements ISourceDisplay { public class SourceDisplayAdapter implements ISourceDisplay {
class DelegatingStackFrame implements IStackFrame { class DelegatingStackFrame implements IStackFrame {
private ICStackFrame fDelegate; private ICStackFrame fDelegate;
DelegatingStackFrame( ICStackFrame delegate ) { DelegatingStackFrame(ICStackFrame delegate) {
super(); super();
fDelegate = delegate; fDelegate = delegate;
} }
@ -129,11 +127,10 @@ public class SourceDisplayAdapter implements ISourceDisplay {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/ */
@SuppressWarnings("unchecked") public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
public Object getAdapter( Class adapter ) { if (ICStackFrame.class.equals(adapter))
if ( ICStackFrame.class.equals( adapter ) )
return fDelegate; return fDelegate;
return fDelegate.getAdapter( adapter ); return fDelegate.getAdapter(adapter);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -240,56 +237,53 @@ public class SourceDisplayAdapter implements ISourceDisplay {
public void terminate() throws DebugException { public void terminate() throws DebugException {
fDelegate.terminate(); fDelegate.terminate();
} }
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.ui.sourcelookup.ISourceDisplay#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean) * @see org.eclipse.debug.ui.sourcelookup.ISourceDisplay#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean)
*/ */
public void displaySource( Object element, IWorkbenchPage page, boolean forceSourceLookup ) { public void displaySource(Object element, IWorkbenchPage page, boolean forceSourceLookup) {
if ( element instanceof ICStackFrame ) { if (element instanceof ICStackFrame) {
ICStackFrame frame = (ICStackFrame)element; ICStackFrame frame = (ICStackFrame)element;
if ( isDisplayDisassembly( frame, page ) ) { if (isDisplayDisassembly(frame, page)) {
displayDisassembly( page, frame ); displayDisassembly(page, frame);
} } else {
else { DelegatingStackFrame delegatingFrame = new DelegatingStackFrame((ICStackFrame)element);
DelegatingStackFrame delegatingFrame = new DelegatingStackFrame( (ICStackFrame)element ); ISourceDisplay sd = (ISourceDisplay)Platform.getAdapterManager().getAdapter(delegatingFrame, ISourceDisplay.class);
ISourceDisplay sd = (ISourceDisplay)Platform.getAdapterManager().getAdapter( delegatingFrame, ISourceDisplay.class ); if (sd != null)
if ( sd != null ) sd.displaySource(element, page, forceSourceLookup);
sd.displaySource( element, page, forceSourceLookup );
} }
} }
} }
private boolean isDisplayDisassembly( ICStackFrame frame, IWorkbenchPage page ) { private boolean isDisplayDisassembly(ICStackFrame frame, IWorkbenchPage page) {
// always go to the disassembly window if it is already open // always go to the disassembly window if it is already open
IEditorPart editor = getDisassemblyEditorManager().findEditor( page, frame ); IEditorPart editor = getDisassemblyEditorManager().findEditor(page, frame);
return ( editor != null ); return (editor != null);
} }
protected DisassemblyEditorManager getDisassemblyEditorManager() { protected DisassemblyEditorManager getDisassemblyEditorManager() {
return CDebugUIPlugin.getDefault().getDisassemblyEditorManager(); return CDebugUIPlugin.getDefault().getDisassemblyEditorManager();
} }
private void displayDisassembly( final IWorkbenchPage page, final Object debugContext ) { private void displayDisassembly(final IWorkbenchPage page, final Object debugContext) {
Job uijob = new UIJob( "Display Disassembly Job" ) { //$NON-NLS-1$ Job uijob = new UIJob("Display Disassembly Job") { //$NON-NLS-1$
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
*/ */
@Override @Override
public IStatus runInUIThread( IProgressMonitor monitor ) { public IStatus runInUIThread(IProgressMonitor monitor) {
try { try {
getDisassemblyEditorManager().openEditor( page, debugContext ); getDisassemblyEditorManager().openEditor(page, debugContext);
} }
catch( DebugException e ) { catch(DebugException e) {
return e.getStatus(); return e.getStatus();
} }
return Status.OK_STATUS; return Status.OK_STATUS;
} }
}; };
uijob.setSystem( true ); uijob.setSystem(true);
uijob.schedule(); uijob.schedule();
} }
} }

View file

@ -6,29 +6,59 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import java.util.MissingResourceException; import org.eclipse.osgi.util.NLS;
import java.util.ResourceBundle;
public class SourceLookupUIMessages { public class SourceLookupUIMessages extends NLS {
public static String AddContainerAction_0;
public static String AddSourceContainerDialog_0;
public static String AddSourceContainerDialog_1;
public static String DownAction_0;
public static String EditContainerAction_0;
public static String MappingSourceContainerBrowser_0;
public static String MappingSourceContainerDialog_0;
public static String MappingSourceContainerDialog_1;
public static String MappingSourceContainerDialog_2;
public static String MappingSourceContainerDialog_3;
public static String MappingSourceContainerDialog_4;
public static String MappingSourceContainerDialog_5;
public static String AbsolutePathSourceContainerBrowser_0;
public static String PathMappingDialog_0;
public static String PathMappingDialog_1;
public static String PathMappingDialog_2;
public static String PathMappingDialog_3;
public static String PathMappingDialog_4;
public static String PathMappingDialog_5;
public static String PathMappingDialog_6;
public static String PathMappingDialog_7;
public static String PathMappingDialog_8;
public static String PathMappingDialog_9;
public static String PathMappingDialog_10;
public static String PathMappingDialog_11;
public static String PathMappingDialog_12;
public static String PathMappingDialog_13;
public static String PathMappingDialog_14;
public static String PathMappingDialog_15;
public static String PathMappingDialog_16;
public static String RemoveAction_0;
public static String SourceContainerWorkbenchAdapter_0;
public static String UpAction_0;
public static String CSourceNotFoundEditor_0;
public static String CSourceNotFoundEditor_1;
public static String CSourceNotFoundEditor_2;
public static String CSourceNotFoundEditor_3;
public static String CSourceNotFoundEditor_4;
public static String CSourceNotFoundEditor_5;
private static final String BUNDLE_NAME = "org.eclipse.cdt.debug.internal.ui.sourcelookup.SourceLookupUIMessages"; //$NON-NLS-1$ static {
NLS.initializeMessages(SourceLookupUIMessages.class.getName(), SourceLookupUIMessages.class);
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME ); }
private SourceLookupUIMessages() { private SourceLookupUIMessages() {
} // Do not instantiate
public static String getString( String key ) {
// TODO Auto-generated method stub
try {
return RESOURCE_BUNDLE.getString( key );
}
catch( MissingResourceException e ) {
return '!' + key + '!';
}
} }
} }

View file

@ -10,42 +10,42 @@
# Ken Ryall (Nokia) - Added support for CSourceNotFoundElement ( 167305 ) # Ken Ryall (Nokia) - Added support for CSourceNotFoundElement ( 167305 )
# Ken Ryall (Nokia) - Option to open disassembly view when no source ( 81353 ) # Ken Ryall (Nokia) - Option to open disassembly view when no source ( 81353 )
############################################################################### ###############################################################################
AddContainerAction.0=&Add... AddContainerAction_0=&Add...
AddSourceContainerDialog.0=Add Source AddSourceContainerDialog_0=Add Source
AddSourceContainerDialog.1=Select the type of source to add to the source lookup path AddSourceContainerDialog_1=Select the type of source to add to the source lookup path
DownAction.0=&Down DownAction_0=&Down
EditContainerAction.0=&Edit... EditContainerAction_0=&Edit...
MappingSourceContainerBrowser.0=New Mapping MappingSourceContainerBrowser_0=New Mapping
MappingSourceContainerDialog.0=Add/Modify path mapping MappingSourceContainerDialog_0=Add/Modify path mapping
MappingSourceContainerDialog.1=Compilation path MappingSourceContainerDialog_1=Compilation path
MappingSourceContainerDialog.2=Local file system path MappingSourceContainerDialog_2=Local file system path
MappingSourceContainerDialog.3=Add MappingSourceContainerDialog_3=Add
MappingSourceContainerDialog.4=Up MappingSourceContainerDialog_4=Up
MappingSourceContainerDialog.5=Down MappingSourceContainerDialog_5=Down
AbsolutePathSourceContainerBrowser.0=Absolute Path AbsolutePathSourceContainerBrowser_0=Absolute Path
PathMappingDialog.0=Specify the mapping paths PathMappingDialog_0=Specify the mapping paths
PathMappingDialog.1=Compilation path: PathMappingDialog_1=Compilation path:
PathMappingDialog.2=Local file system path: PathMappingDialog_2=Local file system path:
PathMappingDialog.3=&Browse... PathMappingDialog_3=&Browse...
PathMappingDialog.4=Path Mapping PathMappingDialog_4=Path Mapping
PathMappingDialog.5=The compilation path must not be empty PathMappingDialog_5=The compilation path must not be empty
PathMappingDialog.6=Invalid compilation path. PathMappingDialog_6=Invalid compilation path.
PathMappingDialog.7=The local file systems path must not be empty PathMappingDialog_7=The local file systems path must not be empty
PathMappingDialog.8=The specified local file system path doesn't exist PathMappingDialog_8=The specified local file system path doesn't exist
PathMappingDialog.9=The local file system path must be a directory PathMappingDialog_9=The local file system path must be a directory
PathMappingDialog.10=The local file system path must be absolute PathMappingDialog_10=The local file system path must be absolute
PathMappingDialog.11=Modify the path mappings PathMappingDialog_11=Modify the path mappings
PathMappingDialog.12=Name: PathMappingDialog_12=Name:
PathMappingDialog.13=&Add... PathMappingDialog_13=&Add...
PathMappingDialog.14=&Edit... PathMappingDialog_14=&Edit...
PathMappingDialog.15=Re&move PathMappingDialog_15=Re&move
PathMappingDialog.16=Path Mappings PathMappingDialog_16=Path Mappings
RemoveAction.0=Re&move RemoveAction_0=Re&move
SourceContainerWorkbenchAdapter.0=Path Mapping: SourceContainerWorkbenchAdapter_0=Path Mapping:
UpAction.0=U&p UpAction_0=U&p
CSourceNotFoundEditor.0=Can''t find a source file at \"{0}\" \nLocate the file or edit the source lookup path to include its location. CSourceNotFoundEditor_0=Can''t find a source file at \"{0}\" \nLocate the file or edit the source lookup path to include its location.
CSourceNotFoundEditor.1=Locate File... CSourceNotFoundEditor_1=Locate File...
CSourceNotFoundEditor.2=Missing Source File CSourceNotFoundEditor_2=Missing Source File
CSourceNotFoundEditor.3=No source available for \"{0}\" \n CSourceNotFoundEditor_3=No source available for \"{0}\" \n
CSourceNotFoundEditor.4=View Disassembly... CSourceNotFoundEditor_4=View Disassembly...
CSourceNotFoundEditor.5=Edit Source Lookup Path... CSourceNotFoundEditor_5=Edit Source Lookup Path...

View file

@ -10,9 +10,9 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.sourcelookup; package org.eclipse.cdt.debug.internal.ui.sourcelookup;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
/** /**
@ -21,28 +21,27 @@ import org.eclipse.jface.viewers.IStructuredSelection;
public class UpAction extends SourceContainerAction { public class UpAction extends SourceContainerAction {
public UpAction() { public UpAction() {
super(SourceLookupUIMessages.getString( "UpAction.0" )); //$NON-NLS-1$ super(SourceLookupUIMessages.UpAction_0);
} }
/** /**
* Moves all selected entries up one position (if possible). * Moves all selected entries up one position (if possible).
* *
* @see IAction#run() * @see IAction#run()
*/ */
public void run() { public void run() {
List targets = getOrderedSelection(); List<ISourceContainer> targets = getOrderedSelection();
if (targets.isEmpty()) { if (targets.isEmpty()) {
return; return;
} }
int top = 0; int top = 0;
int index = 0; int index = 0;
List list = getEntriesAsList(); List<ISourceContainer> list = getEntriesAsList();
Iterator entries = targets.iterator(); for (ISourceContainer target : targets) {
while (entries.hasNext()) {
Object target = entries.next();
index = list.indexOf(target); index = list.indexOf(target);
if (index > top) { if (index > top) {
top = index - 1; top = index - 1;
Object temp = list.get(top); ISourceContainer temp = list.get(top);
list.set(top, target); list.set(top, target);
list.set(index, temp); list.set(index, temp);
} }
@ -58,5 +57,4 @@ public class UpAction extends SourceContainerAction {
//check that something is selected, it's not first in the list, and it is a root tree node. //check that something is selected, it's not first in the list, and it is a root tree node.
return !selection.isEmpty() && !isIndexSelected(selection, 0) && getViewer().getTree().getSelection()[0].getParentItem()==null; return !selection.isEmpty() && !isIndexSelected(selection, 0) && getViewer().getTree().getSelection()[0].getParentItem()==null;
} }
} }