mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
NLS-style string resources.
This commit is contained in:
parent
bd51ec8825
commit
f257c2f55d
21 changed files with 649 additions and 698 deletions
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
|
@ -25,5 +25,4 @@ public class AbsolutePathSourceContainerBrowser extends AbstractSourceContainerB
|
|||
AbsolutePathSourceContainer absolutePathSourceContainer = new AbsolutePathSourceContainer();
|
||||
return new ISourceContainer[] { absolutePathSourceContainer };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
|
@ -19,11 +19,10 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
|||
* and the EditSourceLookupPathDialog.
|
||||
*/
|
||||
public class AddContainerAction extends SourceContainerAction {
|
||||
|
||||
private ISourceLookupDirector fDirector;
|
||||
|
||||
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)
|
||||
*/
|
||||
protected boolean updateSelection(IStructuredSelection selection) {
|
||||
if(selection == null || selection.isEmpty()) {
|
||||
if (selection == null || selection.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
return getViewer().getTree().getSelection()[0].getParentItem()==null;
|
||||
return getViewer().getTree().getSelection()[0].getParentItem() == null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.eclipse.ui.PlatformUI;
|
|||
* @since 3.0
|
||||
*/
|
||||
public class AddSourceContainerDialog extends TitleAreaDialog {
|
||||
|
||||
private TableViewer fViewer;
|
||||
private SourceContainerViewer fSourceContainerViewer;
|
||||
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"
|
||||
*/
|
||||
protected Control createDialogArea(Composite ancestor) {
|
||||
|
||||
getShell().setText(SourceLookupUIMessages.getString( "AddSourceContainerDialog.0" )); //$NON-NLS-1$
|
||||
setTitle(SourceLookupUIMessages.getString( "AddSourceContainerDialog.1" )); //$NON-NLS-1$
|
||||
getShell().setText(SourceLookupUIMessages.AddSourceContainerDialog_0);
|
||||
setTitle(SourceLookupUIMessages.AddSourceContainerDialog_1);
|
||||
|
||||
Composite parent = new Composite(ancestor, SWT.NULL);
|
||||
GridData gd= new GridData(GridData.FILL_BOTH);
|
||||
|
@ -107,7 +105,7 @@ public class AddSourceContainerDialog extends TitleAreaDialog {
|
|||
setMessage(desc);
|
||||
}
|
||||
});
|
||||
if(types.length != 0) {
|
||||
if (types.length != 0) {
|
||||
fViewer.setInput(types);
|
||||
}
|
||||
Dialog.applyDialogFont(parent);
|
||||
|
@ -121,18 +119,17 @@ public class AddSourceContainerDialog extends TitleAreaDialog {
|
|||
* @return the list of source container types that have browsers
|
||||
*/
|
||||
private ISourceContainerType[] filterTypes(ISourceContainerType[] types){
|
||||
ArrayList validTypes = new ArrayList();
|
||||
for (int i=0; i< types.length; i++) {
|
||||
ArrayList<ISourceContainerType> validTypes = new ArrayList<ISourceContainerType>();
|
||||
for (int i=0; i < types.length; i++) {
|
||||
ISourceContainerType type = types[i];
|
||||
if (fDirector.supportsSourceContainerType(type)) {
|
||||
ISourceContainerBrowser sourceContainerBrowser = DebugUITools.getSourceContainerBrowser(type.getId());
|
||||
if(sourceContainerBrowser != null && sourceContainerBrowser.canAddSourceContainers(fDirector)) {
|
||||
if (sourceContainerBrowser != null && sourceContainerBrowser.canAddSourceContainers(fDirector)) {
|
||||
validTypes.add(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (ISourceContainerType[]) validTypes.toArray(new ISourceContainerType[validTypes.size()]);
|
||||
|
||||
return validTypes.toArray(new ISourceContainerType[validTypes.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -145,11 +142,10 @@ public class AddSourceContainerDialog extends TitleAreaDialog {
|
|||
ISourceContainerBrowser browser = DebugUITools.getSourceContainerBrowser(type.getId());
|
||||
if (browser != null) {
|
||||
ISourceContainer[] results = browser.addSourceContainers(getShell(), fDirector);
|
||||
if(results != null) {
|
||||
if (results != null) {
|
||||
fSourceContainerViewer.addEntries(results);
|
||||
}
|
||||
}
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
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.ui.sourcelookup.CommonSourceNotFoundEditor;
|
||||
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
|
@ -55,15 +55,11 @@ import org.eclipse.ui.IWorkbenchPage;
|
|||
import org.eclipse.ui.PartInitException;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.ibm.icu.text.MessageFormat;
|
||||
|
||||
/**
|
||||
* Editor that lets you select a replacement for the missing source file
|
||||
* and modifies the source locator accordingly.
|
||||
*
|
||||
*/
|
||||
public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
||||
|
||||
public final String foundMappingsContainerName = "Found Mappings"; //$NON-NLS-1$
|
||||
private static final String UID_KEY = ".uid"; //$NON-NLS-1$
|
||||
private static final String UID_CLASS_NAME = CSourceNotFoundEditor.class.getName();
|
||||
|
@ -110,8 +106,9 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
|||
IPath tuPath = tunit.getLocation();
|
||||
if (tuPath != null)
|
||||
missingFile = tuPath.toOSString();
|
||||
} else
|
||||
} else {
|
||||
missingFile = ""; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
super.setInput(input);
|
||||
syncButtons();
|
||||
|
@ -126,9 +123,8 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
|||
|
||||
protected String getText() {
|
||||
if (missingFile.length() > 0) {
|
||||
return MessageFormat.format(SourceLookupUIMessages.getString( "CSourceNotFoundEditor.0" ), new String[] { missingFile }); //$NON-NLS-1$
|
||||
}
|
||||
else {
|
||||
return NLS.bind(SourceLookupUIMessages.CSourceNotFoundEditor_0, missingFile);
|
||||
} else {
|
||||
if (context == null)
|
||||
return super.getText();
|
||||
String contextDescription;
|
||||
|
@ -137,21 +133,19 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
|||
contextDescription = description.getDescription();
|
||||
else
|
||||
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) {
|
||||
|
||||
if (isDebugElement)
|
||||
{
|
||||
if (isDebugElement) {
|
||||
GridData data;
|
||||
disassemblyButton = new Button(parent, SWT.PUSH);
|
||||
data = new GridData();
|
||||
data.grabExcessHorizontalSpace = false;
|
||||
data.grabExcessVerticalSpace = false;
|
||||
disassemblyButton.setLayoutData(data);
|
||||
disassemblyButton.setText(SourceLookupUIMessages.getString( "CSourceNotFoundEditor.4" )); //$NON-NLS-1$
|
||||
disassemblyButton.setText(SourceLookupUIMessages.CSourceNotFoundEditor_4);
|
||||
disassemblyButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent evt) {
|
||||
viewDisassembly();
|
||||
|
@ -167,7 +161,7 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
|||
data.grabExcessHorizontalSpace = false;
|
||||
data.grabExcessVerticalSpace = false;
|
||||
locateFileButton.setLayoutData(data);
|
||||
locateFileButton.setText(SourceLookupUIMessages.getString( "CSourceNotFoundEditor.1" )); //$NON-NLS-1$
|
||||
locateFileButton.setText(SourceLookupUIMessages.CSourceNotFoundEditor_1);
|
||||
locateFileButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent evt) {
|
||||
locateFile();
|
||||
|
@ -176,25 +170,22 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
|||
locateFileButton.setData(UID_KEY, UID_LOCATE_FILE_BUTTON);
|
||||
}
|
||||
|
||||
if (isDebugElement)
|
||||
{
|
||||
if (isDebugElement) {
|
||||
GridData data;
|
||||
editLookupButton = new Button(parent, SWT.PUSH);
|
||||
data = new GridData();
|
||||
data.grabExcessHorizontalSpace = false;
|
||||
data.grabExcessVerticalSpace = false;
|
||||
editLookupButton.setLayoutData(data);
|
||||
editLookupButton.setText(SourceLookupUIMessages.getString( "CSourceNotFoundEditor.5" )); //$NON-NLS-1$
|
||||
editLookupButton.setText(SourceLookupUIMessages.CSourceNotFoundEditor_5);
|
||||
editLookupButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent evt) {
|
||||
editSourceLookupPath();
|
||||
}
|
||||
});
|
||||
editLookupButton.setData(UID_KEY, UID_EDIT_LOOKUP_BUTTON);
|
||||
|
||||
}
|
||||
syncButtons();
|
||||
|
||||
}
|
||||
|
||||
protected void viewDisassembly() {
|
||||
|
@ -202,36 +193,31 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
|||
if (page != null) {
|
||||
try {
|
||||
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 {
|
||||
|
||||
ArrayList containerList = new ArrayList(Arrays.asList(director.getSourceContainers()));
|
||||
|
||||
boolean hasFoundMappings = false;
|
||||
|
||||
ArrayList<ISourceContainer> containerList = new ArrayList<ISourceContainer>(Arrays.asList(director.getSourceContainers()));
|
||||
MappingSourceContainer foundMappings = null;
|
||||
|
||||
for (Iterator iter = containerList.iterator(); iter.hasNext() && !hasFoundMappings;) {
|
||||
ISourceContainer container = (ISourceContainer) iter.next();
|
||||
if (container instanceof MappingSourceContainer)
|
||||
{
|
||||
hasFoundMappings = container.getName().equals(foundMappingsContainerName);
|
||||
if (hasFoundMappings)
|
||||
for (ISourceContainer container : containerList) {
|
||||
if (container instanceof MappingSourceContainer) {
|
||||
if (container.getName().equals(foundMappingsContainerName)) {
|
||||
foundMappings = (MappingSourceContainer) container;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasFoundMappings) {
|
||||
if (foundMappings == null) {
|
||||
foundMappings = new MappingSourceContainer(foundMappingsContainerName);
|
||||
foundMappings.init(director);
|
||||
containerList.add(foundMappings);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, director.getMemento());
|
||||
configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, director.getId());
|
||||
configuration.doSave();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void locateFile() {
|
||||
FileDialog dialog = new FileDialog(getEditorSite().getShell(), SWT.NONE);
|
||||
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$
|
||||
String res = dialog.open();
|
||||
if (res != null) {
|
||||
Path newPath = new Path(res);
|
||||
|
||||
if (newPath.lastSegment().equalsIgnoreCase(missingPath.lastSegment())) {
|
||||
|
||||
if (missingPath.segmentCount() > 1) {
|
||||
IPath compPath = missingPath.removeLastSegments(1);
|
||||
IPath newSourcePath = newPath.removeLastSegments(1);
|
||||
|
@ -298,22 +281,18 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
|||
addSourceMappingToLaunch(compPath, newSourcePath);
|
||||
else
|
||||
addSourceMappingToCommon(compPath, newSourcePath);
|
||||
} catch (CoreException e) {}
|
||||
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
|
||||
IWorkbenchPage page = getEditorSite().getPage();
|
||||
|
||||
if (isDebugElement)
|
||||
{
|
||||
if (isDebugElement) {
|
||||
ISourceDisplay adapter = (ISourceDisplay)context.getAdapter(ISourceDisplay.class);
|
||||
if (adapter != null) {
|
||||
adapter.displaySource(context, page, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (isTranslationUnit)
|
||||
{
|
||||
} else if (isTranslationUnit) {
|
||||
reopenTranslationUnit(tunit);
|
||||
}
|
||||
closeEditor();
|
||||
|
@ -321,41 +300,34 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean reopenTranslationUnit(ITranslationUnit tu)
|
||||
{
|
||||
if (tu != null)
|
||||
{
|
||||
private boolean reopenTranslationUnit(ITranslationUnit tu){
|
||||
if (tu != null){
|
||||
IPath tuPath = tu.getLocation();
|
||||
if (tuPath != null)
|
||||
{
|
||||
if (tuPath != null){
|
||||
String filePath = tuPath.toOSString();
|
||||
try {
|
||||
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]);
|
||||
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];
|
||||
if (newLocation.getFullPath().toFile().exists())
|
||||
{
|
||||
if (newLocation.getFullPath().toFile().exists()) {
|
||||
ITranslationUnit remappedTU = tu;
|
||||
if (tu instanceof ExternalTranslationUnit)
|
||||
|
||||
// TODO: source lookup needs to be modified to use URIs
|
||||
remappedTU = new ExternalTranslationUnit(tu.getParent(), URIUtil.toURI(newLocation.getFullPath()), tu.getContentTypeId());
|
||||
EditorUtility.openInEditor(remappedTU);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Override
|
||||
* @see org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor#getArtifact()
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
* Contributors:
|
||||
* Nokia - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceNotFoundElement;
|
||||
|
@ -34,11 +33,9 @@ public class CSourceNotFoundEditorInput extends CommonSourceNotFoundEditorInput
|
|||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,36 +9,38 @@
|
|||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
/**
|
||||
* The action for sorting the order of source containers in the dialog.
|
||||
*
|
||||
*/
|
||||
public class DownAction extends SourceContainerAction {
|
||||
|
||||
public DownAction() {
|
||||
super(SourceLookupUIMessages.getString( "DownAction.0" )); //$NON-NLS-1$
|
||||
super(SourceLookupUIMessages.DownAction_0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IAction#run()
|
||||
*/
|
||||
public void run() {
|
||||
List targets = getOrderedSelection();
|
||||
List<ISourceContainer> targets = getOrderedSelection();
|
||||
if (targets.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List list = getEntriesAsList();
|
||||
List<ISourceContainer> list = getEntriesAsList();
|
||||
int bottom = list.size() - 1;
|
||||
int index = 0;
|
||||
for (int i = targets.size() - 1; i >= 0; i--) {
|
||||
Object target = targets.get(i);
|
||||
ISourceContainer target = targets.get(i);
|
||||
index = list.indexOf(target);
|
||||
if (index < bottom) {
|
||||
bottom = index + 1;
|
||||
Object temp = list.get(bottom);
|
||||
ISourceContainer temp = list.get(bottom);
|
||||
list.set(bottom, target);
|
||||
list.set(index, temp);
|
||||
}
|
||||
|
@ -51,7 +53,7 @@ public class DownAction extends SourceContainerAction {
|
|||
* @see SelectionListenerAction#updateSelection(IStructuredSelection)
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,13 +22,12 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
|||
* Action used to edit source containers on a source lookup path
|
||||
*/
|
||||
public class EditContainerAction extends SourceContainerAction {
|
||||
|
||||
private ISourceLookupDirector fDirector;
|
||||
private ISourceContainer[] fContainers;
|
||||
private ISourceContainerBrowser fBrowser;
|
||||
|
||||
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)
|
||||
*/
|
||||
protected boolean updateSelection(IStructuredSelection selection) {
|
||||
if(selection == null || selection.isEmpty()) {
|
||||
if (selection == null || selection.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (getViewer().getTree().getSelection()[0].getParentItem()==null) {
|
||||
// can only edit top level items of same type
|
||||
fContainers = new ISourceContainer[selection.size()];
|
||||
Iterator iterator = selection.iterator();
|
||||
Iterator<?> iterator = selection.iterator();
|
||||
ISourceContainer container = (ISourceContainer) iterator.next();
|
||||
ISourceContainerType type = container.getType();
|
||||
fContainers[0] = container;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
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.
|
||||
*/
|
||||
public class MappingSourceContainerBrowser extends AbstractSourceContainerBrowser {
|
||||
|
||||
private static final String MAPPING = SourceLookupUIMessages.getString( "MappingSourceContainerBrowser.0" ); //$NON-NLS-1$
|
||||
private static final String MAPPING = SourceLookupUIMessages.MappingSourceContainerBrowser_0;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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 ) {
|
||||
return new ISourceContainer[] { new MappingSourceContainer( generateName( director ) ) };
|
||||
public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
|
||||
return new ISourceContainer[] { new MappingSourceContainer(generateName(director)) };
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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 ) {
|
||||
return ( containers.length == 1 && containers[0] instanceof MappingSourceContainer );
|
||||
public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) {
|
||||
return (containers.length == 1 && containers[0] instanceof MappingSourceContainer);
|
||||
}
|
||||
|
||||
/* (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[])
|
||||
*/
|
||||
public ISourceContainer[] editSourceContainers( Shell shell, ISourceLookupDirector director, ISourceContainer[] containers ) {
|
||||
if ( containers.length == 1 && containers[0] instanceof MappingSourceContainer ) {
|
||||
PathMappingDialog dialog = new PathMappingDialog( shell, (MappingSourceContainer)containers[0] );
|
||||
if ( dialog.open() == Window.OK ) {
|
||||
public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) {
|
||||
if (containers.length == 1 && containers[0] instanceof MappingSourceContainer) {
|
||||
PathMappingDialog dialog = new PathMappingDialog(shell, (MappingSourceContainer)containers[0]);
|
||||
if (dialog.open() == Window.OK) {
|
||||
return new ISourceContainer[] { dialog.getMapping() };
|
||||
}
|
||||
}
|
||||
return new ISourceContainer[0];
|
||||
}
|
||||
|
||||
private String generateName( ISourceLookupDirector director ) {
|
||||
private String generateName(ISourceLookupDirector director) {
|
||||
// int counter = 1;
|
||||
// ISourceContainer[] containers = director.getSourceContainers();
|
||||
// for ( int i = 0; i < containers.length; ++i ) {
|
||||
// if ( MappingSourceContainer.TYPE_ID.equals( containers[i].getType().getId() ) ) {
|
||||
// for (int i = 0; i < containers.length; ++i) {
|
||||
// if (MappingSourceContainer.TYPE_ID.equals(containers[i].getType().getId())) {
|
||||
// String name = containers[i].getName();
|
||||
// if ( name.startsWith( MAPPING ) ) {
|
||||
// if (name.startsWith(MAPPING)) {
|
||||
// try {
|
||||
// int number = Integer.valueOf( name.substring( MAPPING.length() ) ).intValue();
|
||||
// if ( number == counter )
|
||||
// int number = Integer.valueOf(name.substring(MAPPING.length())).intValue();
|
||||
// if (number == counter)
|
||||
// ++counter;
|
||||
// }
|
||||
// catch( NumberFormatException e ) {
|
||||
// } catch (NumberFormatException e) {
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -65,23 +65,22 @@ import org.eclipse.ui.PlatformUI;
|
|||
public class MappingSourceContainerDialog extends TitleAreaDialog {
|
||||
|
||||
class EntryCellModifier implements ICellModifier {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
public boolean canModify( Object element, String property ) {
|
||||
return ( CP_COMPILATION_PATH.equals( property ) || CP_FILE_SYSTEM_PATH.equals( property ) );
|
||||
public boolean canModify(Object element, String property) {
|
||||
return (CP_COMPILATION_PATH.equals(property) || CP_FILE_SYSTEM_PATH.equals(property));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
public Object getValue( Object element, String property ) {
|
||||
if ( element instanceof MapEntrySourceContainer ) {
|
||||
public Object getValue(Object element, String property) {
|
||||
if (element instanceof MapEntrySourceContainer) {
|
||||
MapEntrySourceContainer entry = (MapEntrySourceContainer)element;
|
||||
if ( CP_COMPILATION_PATH.equals( property ) )
|
||||
if (CP_COMPILATION_PATH.equals(property))
|
||||
return entry.getBackendPath().toOSString();
|
||||
if ( CP_FILE_SYSTEM_PATH.equals( property ) )
|
||||
if (CP_FILE_SYSTEM_PATH.equals(property))
|
||||
return entry.getLocalPath().toOSString();
|
||||
}
|
||||
return null;
|
||||
|
@ -90,39 +89,39 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
/* (non-Javadoc)
|
||||
* @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 =
|
||||
( element instanceof Item ) ?
|
||||
(element instanceof Item) ?
|
||||
(MapEntrySourceContainer)((Item)element).getData()
|
||||
: (MapEntrySourceContainer)element;
|
||||
boolean isDirty = false;
|
||||
if ( CP_COMPILATION_PATH.equals( property ) ) {
|
||||
entry.setBackendPath( new Path( (String)value) );
|
||||
if (CP_COMPILATION_PATH.equals(property)) {
|
||||
entry.setBackendPath(new Path((String)value));
|
||||
isDirty = true;
|
||||
}
|
||||
else if ( CP_FILE_SYSTEM_PATH.equals( property ) ) {
|
||||
entry.setLocalPath( new Path( (String)value) );
|
||||
else if (CP_FILE_SYSTEM_PATH.equals(property)) {
|
||||
entry.setLocalPath(new Path((String)value));
|
||||
isDirty = true;
|
||||
}
|
||||
if ( isDirty )
|
||||
if (isDirty)
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
class DirectoryCellEditor extends DialogCellEditor {
|
||||
|
||||
DirectoryCellEditor( Composite parent ) {
|
||||
super( parent );
|
||||
DirectoryCellEditor(Composite parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
|
||||
*/
|
||||
@Override
|
||||
protected Object openDialogBox( Control cellEditorWindow ) {
|
||||
protected Object openDialogBox(Control cellEditorWindow) {
|
||||
TableItem[] selection = ((Table)cellEditorWindow.getParent()).getSelection();
|
||||
DirectoryDialog dialog = new DirectoryDialog( cellEditorWindow.getShell() );
|
||||
dialog.setFilterPath( selection[0].getText( 1 ) );
|
||||
DirectoryDialog dialog = new DirectoryDialog(cellEditorWindow.getShell());
|
||||
dialog.setFilterPath(selection[0].getText(1));
|
||||
return dialog.open();
|
||||
}
|
||||
}
|
||||
|
@ -132,9 +131,9 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
|
||||
*/
|
||||
public Image getColumnImage( Object element, int columnIndex ) {
|
||||
if ( element instanceof MapEntrySourceContainer && columnIndex == 0 ) {
|
||||
return CDebugImages.get( CDebugImages.IMG_OBJS_PATH_MAP_ENTRY );
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
if (element instanceof MapEntrySourceContainer && columnIndex == 0) {
|
||||
return CDebugImages.get(CDebugImages.IMG_OBJS_PATH_MAP_ENTRY);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -142,12 +141,12 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||
*/
|
||||
public String getColumnText( Object element, int columnIndex ) {
|
||||
if ( element instanceof MapEntrySourceContainer ) {
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
if (element instanceof MapEntrySourceContainer) {
|
||||
MapEntrySourceContainer entry = (MapEntrySourceContainer)element;
|
||||
if ( columnIndex == 0 )
|
||||
if (columnIndex == 0)
|
||||
return entry.getBackendPath().toOSString();
|
||||
if ( columnIndex == 1 )
|
||||
if (columnIndex == 1)
|
||||
return entry.getLocalPath().toOSString();
|
||||
}
|
||||
return null;
|
||||
|
@ -172,24 +171,23 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
|
||||
private boolean fIsValid = true;
|
||||
|
||||
public MappingSourceContainerDialog( Shell shell, MappingSourceContainer container ) {
|
||||
super( shell );
|
||||
public MappingSourceContainerDialog(Shell shell, MappingSourceContainer container) {
|
||||
super(shell);
|
||||
fOriginalContainer = container;
|
||||
fContainer = container.copy();
|
||||
fTableListener = new ControlListener() {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent)
|
||||
*/
|
||||
public void controlMoved( ControlEvent e ) {
|
||||
MappingSourceContainerDialog.this.controlMoved( e );
|
||||
public void controlMoved(ControlEvent e) {
|
||||
MappingSourceContainerDialog.this.controlMoved(e);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent)
|
||||
*/
|
||||
public void controlResized( ControlEvent e ) {
|
||||
MappingSourceContainerDialog.this.controlResized( e );
|
||||
public void controlResized(ControlEvent e) {
|
||||
MappingSourceContainerDialog.this.controlResized(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -199,7 +197,7 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
*/
|
||||
@Override
|
||||
public boolean close() {
|
||||
fViewer.getTable().removeControlListener( fTableListener );
|
||||
fViewer.getTable().removeControlListener(fTableListener);
|
||||
fContainer.dispose();
|
||||
return super.close();
|
||||
}
|
||||
|
@ -216,19 +214,19 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
@Override
|
||||
protected void configureShell( Shell newShell ) {
|
||||
super.configureShell( newShell );
|
||||
newShell.setText( SourceLookupUIMessages.getString( "PathMappingDialog.16" ) ); //$NON-NLS-1$
|
||||
newShell.setToolTipText( SourceLookupUIMessages.getString( "MappingSourceContainerDialog.0" ) ); //$NON-NLS-1$
|
||||
newShell.setImage( CDebugImages.get( CDebugImages.IMG_OBJS_PATH_MAPPING ) );
|
||||
protected void configureShell(Shell newShell) {
|
||||
super.configureShell(newShell);
|
||||
newShell.setText(SourceLookupUIMessages.PathMappingDialog_16);
|
||||
newShell.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_0);
|
||||
newShell.setImage(CDebugImages.get( CDebugImages.IMG_OBJS_PATH_MAPPING));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
protected Control createContents( Composite parent ) {
|
||||
Control control = super.createContents( parent );
|
||||
protected Control createContents(Composite parent) {
|
||||
Control control = super.createContents(parent);
|
||||
initialize();
|
||||
return control;
|
||||
}
|
||||
|
@ -237,24 +235,20 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
protected Control createDialogArea( Composite parent ) {
|
||||
Composite control = (Composite)super.createDialogArea( parent );
|
||||
protected Control createDialogArea(Composite 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$
|
||||
setTitleImage( CDebugImages.get( CDebugImages.IMG_WIZBAN_PATH_MAPPING ) );
|
||||
Composite composite = new Composite(control, SWT.None);
|
||||
composite.setLayout(new GridLayout(2, false));
|
||||
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
|
||||
Composite composite = new Composite( control, SWT.None );
|
||||
composite.setLayout( new GridLayout( 2, false ) );
|
||||
composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
|
||||
|
||||
createNameArea( composite );
|
||||
|
||||
createViewer( composite );
|
||||
|
||||
createViewerButtonBar( composite );
|
||||
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAP_ENTRY_DIALOG );
|
||||
createNameArea(composite);
|
||||
createViewer(composite);
|
||||
createViewerButtonBar(composite);
|
||||
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAP_ENTRY_DIALOG);
|
||||
return control;
|
||||
}
|
||||
|
||||
|
@ -264,11 +258,10 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
@Override
|
||||
protected void okPressed() {
|
||||
fOriginalContainer.clear();
|
||||
fOriginalContainer.setName( fNameText.getText().trim() );
|
||||
fOriginalContainer.setName(fNameText.getText().trim());
|
||||
try {
|
||||
fOriginalContainer.addMapEntries( (MapEntrySourceContainer[])fContainer.getSourceContainers() );
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
fOriginalContainer.addMapEntries((MapEntrySourceContainer[])fContainer.getSourceContainers());
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
super.okPressed();
|
||||
}
|
||||
|
@ -277,79 +270,76 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
* @see org.eclipse.jface.dialogs.TitleAreaDialog#setErrorMessage(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setErrorMessage( String newErrorMessage ) {
|
||||
fIsValid = ( newErrorMessage == null );
|
||||
super.setErrorMessage( newErrorMessage );
|
||||
public void setErrorMessage(String newErrorMessage) {
|
||||
fIsValid = (newErrorMessage == null);
|
||||
super.setErrorMessage(newErrorMessage);
|
||||
}
|
||||
|
||||
public MappingSourceContainer getContainer() {
|
||||
return fOriginalContainer;
|
||||
}
|
||||
|
||||
private void createNameArea( Composite parent ) {
|
||||
Composite composite = new Composite( parent, SWT.None );
|
||||
composite.setLayout( new GridLayout( 2, false ) );
|
||||
composite.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false, 2, 1 ) );
|
||||
private void createNameArea(Composite parent) {
|
||||
Composite composite = new Composite(parent, SWT.None);
|
||||
composite.setLayout(new GridLayout(2, false));
|
||||
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
|
||||
|
||||
Label label = new Label( composite, SWT.NONE );
|
||||
label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.12" ) ); //$NON-NLS-1$
|
||||
fNameText = new Text( composite, SWT.BORDER | SWT.SINGLE );
|
||||
GridData data = new GridData( SWT.FILL, SWT.CENTER, false, false );
|
||||
Label label = new Label(composite, SWT.NONE);
|
||||
label.setText(SourceLookupUIMessages.PathMappingDialog_12);
|
||||
fNameText = new Text(composite, SWT.BORDER | SWT.SINGLE);
|
||||
GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false);
|
||||
data.widthHint = 200;
|
||||
fNameText.setLayoutData( data );
|
||||
fNameText.addModifyListener( new ModifyListener() {
|
||||
|
||||
fNameText.setLayoutData(data);
|
||||
fNameText.addModifyListener(new ModifyListener() {
|
||||
/* (non-Javadoc)
|
||||
* @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 ) {
|
||||
Composite tableComp = new Composite( parent, SWT.NONE );
|
||||
tableComp.setLayout( new GridLayout() );
|
||||
tableComp.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
|
||||
private void createViewer(Composite parent) {
|
||||
Composite tableComp = new Composite(parent, SWT.NONE);
|
||||
tableComp.setLayout(new GridLayout());
|
||||
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.setLinesVisible( true );
|
||||
table.setHeaderVisible( true );
|
||||
GridData data = new GridData( SWT.FILL, SWT.FILL, true, true );
|
||||
table.setLinesVisible(true);
|
||||
table.setHeaderVisible(true);
|
||||
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
data.widthHint = 500;
|
||||
data.heightHint = 200;
|
||||
table.setLayoutData( data );
|
||||
table.setLayoutData(data);
|
||||
|
||||
table.addControlListener( fTableListener );
|
||||
table.addControlListener(fTableListener);
|
||||
|
||||
TableColumn nameColumn = new TableColumn( table, SWT.NULL );
|
||||
nameColumn.setResizable( true );
|
||||
nameColumn.setText( SourceLookupUIMessages.getString( "PathMappingDialog.1" ) ); //$NON-NLS-1$
|
||||
nameColumn.setToolTipText( SourceLookupUIMessages.getString( "MappingSourceContainerDialog.1" ) ); //$NON-NLS-1$
|
||||
TableColumn nameColumn = new TableColumn(table, SWT.NULL);
|
||||
nameColumn.setResizable(true);
|
||||
nameColumn.setText(SourceLookupUIMessages.PathMappingDialog_1);
|
||||
nameColumn.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_1);
|
||||
|
||||
TableColumn valueColumn = new TableColumn( table, SWT.NULL );
|
||||
valueColumn.setResizable( true );
|
||||
valueColumn.setText( SourceLookupUIMessages.getString( "PathMappingDialog.2" ) ); //$NON-NLS-1$
|
||||
valueColumn.setToolTipText( SourceLookupUIMessages.getString( "MappingSourceContainerDialog.2" ) ); //$NON-NLS-1$
|
||||
TableColumn valueColumn = new TableColumn(table, SWT.NULL);
|
||||
valueColumn.setResizable(true);
|
||||
valueColumn.setText(SourceLookupUIMessages.PathMappingDialog_2);
|
||||
valueColumn.setToolTipText(SourceLookupUIMessages.MappingSourceContainerDialog_2);
|
||||
|
||||
fViewer.setColumnProperties(
|
||||
new String[] {
|
||||
CP_COMPILATION_PATH,
|
||||
CP_FILE_SYSTEM_PATH,
|
||||
} );
|
||||
|
||||
fViewer.setContentProvider( new IStructuredContentProvider() {
|
||||
});
|
||||
|
||||
fViewer.setContentProvider(new IStructuredContentProvider() {
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
||||
*/
|
||||
public Object[] getElements( Object inputElement ) {
|
||||
if ( inputElement instanceof MappingSourceContainer ) {
|
||||
public Object[] getElements(Object inputElement) {
|
||||
if (inputElement instanceof MappingSourceContainer) {
|
||||
try {
|
||||
return ((MappingSourceContainer)inputElement).getSourceContainers();
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
}
|
||||
return new Object[0];
|
||||
|
@ -364,137 +354,136 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
fViewer.setCellEditors( new CellEditor[] {
|
||||
new TextCellEditor( table ),
|
||||
new DirectoryCellEditor( table ),
|
||||
} );
|
||||
fViewer.setCellEditors(new CellEditor[] {
|
||||
new TextCellEditor(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)
|
||||
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
|
||||
*/
|
||||
public void selectionChanged( SelectionChangedEvent event ) {
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
updateViewerButtons();
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
private void createViewerButtonBar( Composite parent ) {
|
||||
Composite buttonComp = new Composite( parent, SWT.NONE );
|
||||
buttonComp.setLayout( new GridLayout() );
|
||||
buttonComp.setLayoutData( new GridData( SWT.RIGHT, SWT.FILL, false, false ) );
|
||||
private void createViewerButtonBar(Composite parent) {
|
||||
Composite buttonComp = new Composite(parent, SWT.NONE);
|
||||
buttonComp.setLayout(new GridLayout());
|
||||
buttonComp.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
|
||||
|
||||
fAddButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "MappingSourceContainerDialog.3" ) ); //$NON-NLS-1$
|
||||
fAddButton.addSelectionListener( new SelectionAdapter() {
|
||||
fAddButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_3);
|
||||
fAddButton.addSelectionListener(new SelectionAdapter() {
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void widgetSelected( SelectionEvent event ) {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
addPathEntry();
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
fRemoveButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.15" ) ); //$NON-NLS-1$
|
||||
fRemoveButton.addSelectionListener( new SelectionAdapter() {
|
||||
fRemoveButton = createPushButton(buttonComp, SourceLookupUIMessages.PathMappingDialog_15);
|
||||
fRemoveButton.addSelectionListener(new SelectionAdapter() {
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void widgetSelected( SelectionEvent event ) {
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
removePathEntries();
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
fUpButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "MappingSourceContainerDialog.4" ) ); //$NON-NLS-1$
|
||||
fUpButton.addSelectionListener( new SelectionAdapter() {
|
||||
fUpButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_4);
|
||||
fUpButton.addSelectionListener(new SelectionAdapter() {
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void widgetSelected( SelectionEvent event ) {
|
||||
move( true );
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
move(true);
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
fDownButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "MappingSourceContainerDialog.5" ) ); //$NON-NLS-1$
|
||||
fDownButton.addSelectionListener( new SelectionAdapter() {
|
||||
fDownButton = createPushButton(buttonComp, SourceLookupUIMessages.MappingSourceContainerDialog_5);
|
||||
fDownButton.addSelectionListener(new SelectionAdapter() {
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
@Override
|
||||
public void widgetSelected( SelectionEvent event ) {
|
||||
move( false );
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
move(false);
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
fNameText.setText( fContainer.getName() );
|
||||
fNameText.setText(fContainer.getName());
|
||||
fNameText.selectAll();
|
||||
fViewer.setInput( fContainer );
|
||||
fViewer.setInput(fContainer);
|
||||
updateViewerButtons();
|
||||
}
|
||||
|
||||
private Button createPushButton( Composite parent, String label ) {
|
||||
Button button = new Button( parent, SWT.PUSH );
|
||||
button.setText( label );
|
||||
GridData gd = new GridData( SWT.FILL, SWT.BEGINNING, true, false );
|
||||
gd.widthHint = SWTUtil.getButtonWidthHint( button );
|
||||
button.setLayoutData( gd );
|
||||
private Button createPushButton(Composite parent, String label) {
|
||||
Button button = new Button(parent, SWT.PUSH);
|
||||
button.setText(label);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
|
||||
gd.widthHint = SWTUtil.getButtonWidthHint(button);
|
||||
button.setLayoutData(gd);
|
||||
return button;
|
||||
}
|
||||
|
||||
private MapEntrySourceContainer[] getSelectedEntries() {
|
||||
List<?> list = ((IStructuredSelection)fViewer.getSelection()).toList();
|
||||
return list.toArray( new MapEntrySourceContainer[list.size()] );
|
||||
return list.toArray(new MapEntrySourceContainer[list.size()]);
|
||||
}
|
||||
|
||||
private void updateErrorMessage() {
|
||||
setErrorMessage( null );
|
||||
setErrorMessage(null);
|
||||
try {
|
||||
ISourceContainer[] containers = fContainer.getSourceContainers();
|
||||
if ( containers.length == 0 )
|
||||
if (containers.length == 0)
|
||||
return;
|
||||
for ( ISourceContainer c : containers ) {
|
||||
for (ISourceContainer c : containers) {
|
||||
MapEntrySourceContainer entry = (MapEntrySourceContainer)c;
|
||||
IPath backendPath = entry.getBackendPath();
|
||||
if ( backendPath.isEmpty() ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.5" ) ); //$NON-NLS-1$
|
||||
if (backendPath.isEmpty()) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_5);
|
||||
break;
|
||||
}
|
||||
if ( !backendPath.isValidPath( backendPath.toString() ) ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.6" ) ); //$NON-NLS-1$
|
||||
if (!backendPath.isValidPath(backendPath.toString())) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_6);
|
||||
break;
|
||||
}
|
||||
IPath localPath = entry.getLocalPath();
|
||||
if ( localPath.isEmpty() ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.7" ) ); //$NON-NLS-1$
|
||||
if (localPath.isEmpty()) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_7);
|
||||
break;
|
||||
}
|
||||
if ( !localPath.toFile().exists() ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.8" ) ); //$NON-NLS-1$
|
||||
if (!localPath.toFile().exists()) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_8);
|
||||
break;
|
||||
}
|
||||
if ( !localPath.toFile().isDirectory() ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.9" ) ); //$NON-NLS-1$
|
||||
if (!localPath.toFile().isDirectory()) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_9);
|
||||
break;
|
||||
}
|
||||
if ( !localPath.toFile().isAbsolute() ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.10" ) ); //$NON-NLS-1$
|
||||
if (!localPath.toFile().isAbsolute()) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
} catch (CoreException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
@ -508,51 +497,49 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
try {
|
||||
ISourceContainer[] allEntries = fContainer.getSourceContainers();
|
||||
MapEntrySourceContainer[] entries = getSelectedEntries();
|
||||
if ( entries.length == 0 ) {
|
||||
if (entries.length == 0) {
|
||||
remove = false;
|
||||
}
|
||||
|
||||
if ( entries.length != 1 ) {
|
||||
if (entries.length != 1) {
|
||||
up = false;
|
||||
down = false;
|
||||
}
|
||||
else {
|
||||
up = ( !entries[0].equals( allEntries[0] ) );
|
||||
down = ( !entries[0].equals( allEntries[allEntries.length - 1] ) );
|
||||
} else {
|
||||
up = (!entries[0].equals(allEntries[0]));
|
||||
down = (!entries[0].equals(allEntries[allEntries.length - 1]));
|
||||
}
|
||||
|
||||
ok = ( allEntries.length != 0 && fIsValid );
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
ok = (allEntries.length != 0 && fIsValid);
|
||||
} catch (CoreException e) {
|
||||
// ignore, shouldn't happen
|
||||
}
|
||||
getButton( IDialogConstants.OK_ID ).setEnabled( ok );
|
||||
fRemoveButton.setEnabled( remove );
|
||||
fUpButton.setEnabled( up );
|
||||
fDownButton.setEnabled( down );
|
||||
getButton(IDialogConstants.OK_ID).setEnabled(ok);
|
||||
fRemoveButton.setEnabled(remove);
|
||||
fUpButton.setEnabled(up);
|
||||
fDownButton.setEnabled(down);
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
ISelection s = fViewer.getSelection();
|
||||
fViewer.refresh();
|
||||
fViewer.setSelection( s );
|
||||
fViewer.setSelection(s);
|
||||
updateErrorMessage();
|
||||
updateViewerButtons();
|
||||
}
|
||||
|
||||
void controlMoved( ControlEvent e ) {
|
||||
void controlMoved(ControlEvent e) {
|
||||
}
|
||||
|
||||
void controlResized( ControlEvent e ) {
|
||||
void controlResized(ControlEvent e) {
|
||||
// resize columns
|
||||
Table table = fViewer.getTable();
|
||||
int width = table.getSize().x;
|
||||
if ( width > 0 ) {
|
||||
if (width > 0) {
|
||||
TableColumn[] columns = table.getColumns();
|
||||
int colWidth = width / columns.length;
|
||||
for ( TableColumn col : columns ) {
|
||||
if ( col.getWidth() == 0 ) {
|
||||
col.setWidth( colWidth );
|
||||
for (TableColumn col : columns) {
|
||||
if (col.getWidth() == 0) {
|
||||
col.setWidth(colWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -560,41 +547,39 @@ public class MappingSourceContainerDialog extends TitleAreaDialog {
|
|||
|
||||
void addPathEntry() {
|
||||
MapEntrySourceContainer entry = new MapEntrySourceContainer();
|
||||
fContainer.addMapEntry( entry );
|
||||
fContainer.addMapEntry(entry);
|
||||
fViewer.refresh();
|
||||
fViewer.setSelection( new StructuredSelection( entry ), true );
|
||||
fViewer.setSelection(new StructuredSelection(entry), true);
|
||||
updateViewerButtons();
|
||||
fViewer.editElement( entry, 0 );
|
||||
fViewer.editElement(entry, 0);
|
||||
}
|
||||
|
||||
void removePathEntries() {
|
||||
MapEntrySourceContainer[] entries = getSelectedEntries();
|
||||
fContainer.removeMapEntries( entries );
|
||||
fContainer.removeMapEntries(entries);
|
||||
refresh();
|
||||
}
|
||||
|
||||
void move( boolean up ) {
|
||||
void move(boolean up) {
|
||||
MapEntrySourceContainer[] selEntries = getSelectedEntries();
|
||||
if ( selEntries.length != 1 )
|
||||
if (selEntries.length != 1)
|
||||
return;
|
||||
MapEntrySourceContainer entry = selEntries[0];
|
||||
try {
|
||||
ISourceContainer[] containers = fContainer.getSourceContainers();
|
||||
List<MapEntrySourceContainer> list = new ArrayList<MapEntrySourceContainer>( containers.length );
|
||||
for ( ISourceContainer container : containers ) {
|
||||
list.add( ((MapEntrySourceContainer)container).copy() );
|
||||
List<MapEntrySourceContainer> list = new ArrayList<MapEntrySourceContainer>(containers.length);
|
||||
for (ISourceContainer container : containers) {
|
||||
list.add(((MapEntrySourceContainer)container).copy());
|
||||
}
|
||||
int index = list.indexOf( entry );
|
||||
list.remove( index );
|
||||
index = ( up ) ? index - 1 : index + 1;
|
||||
list.add( index, entry );
|
||||
int index = list.indexOf(entry);
|
||||
list.remove(index);
|
||||
index = (up) ? index - 1 : index + 1;
|
||||
list.add(index, entry);
|
||||
fContainer.clear();
|
||||
fContainer.addMapEntries( list.toArray( new MapEntrySourceContainer[list.size()] ) );
|
||||
fContainer.addMapEntries(list.toArray(new MapEntrySourceContainer[list.size()]));
|
||||
refresh();
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
}
|
||||
catch( IndexOutOfBoundsException e ) {
|
||||
} catch (CoreException e) {
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* ARM Limited - Initial API and implementation
|
||||
* ARM Limited - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
|
||||
|
@ -19,17 +18,16 @@ import org.eclipse.jface.window.Window;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class NewMappingSourceContainerBrowser extends AbstractSourceContainerBrowser {
|
||||
|
||||
private static final String MAPPING = SourceLookupUIMessages.getString( "MappingSourceContainerBrowser.0" ); //$NON-NLS-1$
|
||||
private static final String MAPPING = SourceLookupUIMessages.MappingSourceContainerBrowser_0;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#addSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
|
||||
*/
|
||||
@Override
|
||||
public ISourceContainer[] addSourceContainers( Shell shell, ISourceLookupDirector director ) {
|
||||
public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
|
||||
MappingSourceContainerDialog dialog =
|
||||
new MappingSourceContainerDialog( shell, new MappingSourceContainer( MAPPING ) );
|
||||
if ( dialog.open() == Window.OK ) {
|
||||
new MappingSourceContainerDialog(shell, new MappingSourceContainer(MAPPING));
|
||||
if (dialog.open() == Window.OK) {
|
||||
return new ISourceContainer[] { dialog.getContainer() };
|
||||
}
|
||||
return new ISourceContainer[0];
|
||||
|
@ -38,18 +36,18 @@ public class NewMappingSourceContainerBrowser extends AbstractSourceContainerBro
|
|||
/* (non-Javadoc)
|
||||
* @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 ) {
|
||||
return ( containers.length == 1 && containers[0] instanceof MappingSourceContainer );
|
||||
public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) {
|
||||
return (containers.length == 1 && containers[0] instanceof MappingSourceContainer);
|
||||
}
|
||||
|
||||
/* (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[])
|
||||
*/
|
||||
public ISourceContainer[] editSourceContainers( Shell shell, ISourceLookupDirector director, ISourceContainer[] containers ) {
|
||||
if ( containers.length == 1 && containers[0] instanceof MappingSourceContainer ) {
|
||||
public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) {
|
||||
if (containers.length == 1 && containers[0] instanceof MappingSourceContainer) {
|
||||
MappingSourceContainerDialog dialog =
|
||||
new MappingSourceContainerDialog( shell, (MappingSourceContainer)containers[0] );
|
||||
if ( dialog.open() == Window.OK ) {
|
||||
new MappingSourceContainerDialog(shell, (MappingSourceContainer)containers[0]);
|
||||
if (dialog.open() == Window.OK) {
|
||||
return new ISourceContainer[] { dialog.getContainer() };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
|
||||
import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
|
||||
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
|
||||
|
@ -60,218 +62,214 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
|
|||
public class PathMappingDialog extends TitleAreaDialog {
|
||||
|
||||
class MapEntryDialog extends TitleAreaDialog {
|
||||
|
||||
private MapEntrySourceContainer fEntry;
|
||||
|
||||
protected Text fBackendPathText;
|
||||
protected Text fLocalPathText;
|
||||
|
||||
/**
|
||||
* Constructor for MapEntryDialog.
|
||||
*/
|
||||
public MapEntryDialog( Shell parentShell ) {
|
||||
super( parentShell );
|
||||
public MapEntryDialog(Shell parentShell) {
|
||||
super(parentShell);
|
||||
fEntry = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for MapEntryDialog.
|
||||
*/
|
||||
public MapEntryDialog( Shell parentShell, MapEntrySourceContainer entry ) {
|
||||
super( parentShell );
|
||||
public MapEntryDialog(Shell parentShell, MapEntrySourceContainer entry) {
|
||||
super(parentShell);
|
||||
fEntry = entry;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected Control createDialogArea( Composite parent ) {
|
||||
setTitle( SourceLookupUIMessages.getString( "PathMappingDialog.0" ) ); //$NON-NLS-1$
|
||||
setTitleImage( CDebugImages.get( CDebugImages.IMG_WIZBAN_PATH_MAP_ENTRY ) );
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
setTitle(SourceLookupUIMessages.PathMappingDialog_0);
|
||||
setTitleImage(CDebugImages.get(CDebugImages.IMG_WIZBAN_PATH_MAP_ENTRY));
|
||||
|
||||
Font font = parent.getFont();
|
||||
Composite composite = new Composite( parent, SWT.NONE );
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 2;
|
||||
layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN );
|
||||
layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN );
|
||||
layout.verticalSpacing = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING );
|
||||
layout.horizontalSpacing = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_SPACING );
|
||||
composite.setLayout( layout );
|
||||
GridData data = new GridData( GridData.FILL_BOTH );
|
||||
composite.setLayoutData( data );
|
||||
composite.setFont( font );
|
||||
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
|
||||
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
|
||||
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
|
||||
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
|
||||
composite.setLayout(layout);
|
||||
GridData data = new GridData(GridData.FILL_BOTH);
|
||||
composite.setLayoutData(data);
|
||||
composite.setFont(font);
|
||||
|
||||
Dialog.applyDialogFont( composite );
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAP_ENTRY_DIALOG );
|
||||
Dialog.applyDialogFont(composite);
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAP_ENTRY_DIALOG);
|
||||
|
||||
setMessage( null );
|
||||
setMessage(null);
|
||||
|
||||
Label label = new Label( composite, SWT.LEFT );
|
||||
label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.1" ) ); //$NON-NLS-1$
|
||||
data = new GridData( GridData.FILL_HORIZONTAL );
|
||||
Label label = new Label(composite, SWT.LEFT);
|
||||
label.setText(SourceLookupUIMessages.PathMappingDialog_1);
|
||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
data.horizontalSpan = 2;
|
||||
label.setLayoutData( data );
|
||||
label.setFont( font );
|
||||
label.setLayoutData(data);
|
||||
label.setFont(font);
|
||||
|
||||
fBackendPathText = new Text( composite, SWT.SINGLE | SWT.BORDER );
|
||||
data = new GridData( GridData.FILL_HORIZONTAL );
|
||||
fBackendPathText = new Text(composite, SWT.SINGLE | SWT.BORDER);
|
||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
data.horizontalSpan = 2;
|
||||
fBackendPathText.setLayoutData( data );
|
||||
fBackendPathText.setFont( font );
|
||||
fBackendPathText.addModifyListener( new ModifyListener() {
|
||||
public void modifyText( ModifyEvent e ) {
|
||||
fBackendPathText.setLayoutData(data);
|
||||
fBackendPathText.setFont(font);
|
||||
fBackendPathText.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
update();
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
label = new Label( composite, SWT.LEFT );
|
||||
label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.2" ) ); //$NON-NLS-1$
|
||||
data = new GridData( GridData.FILL_HORIZONTAL );
|
||||
label = new Label(composite, SWT.LEFT);
|
||||
label.setText(SourceLookupUIMessages.PathMappingDialog_2);
|
||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
data.horizontalSpan = 2;
|
||||
label.setLayoutData( data );
|
||||
label.setFont( font );
|
||||
label.setLayoutData(data);
|
||||
label.setFont(font);
|
||||
|
||||
fLocalPathText = new Text( composite, SWT.SINGLE | SWT.BORDER );
|
||||
data = new GridData( GridData.FILL_HORIZONTAL );
|
||||
fLocalPathText.setLayoutData( data );
|
||||
fLocalPathText.setFont( font );
|
||||
fLocalPathText.addModifyListener( new ModifyListener() {
|
||||
public void modifyText( ModifyEvent e ) {
|
||||
fLocalPathText = new Text(composite, SWT.SINGLE | SWT.BORDER);
|
||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
fLocalPathText.setLayoutData(data);
|
||||
fLocalPathText.setFont(font);
|
||||
fLocalPathText.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
update();
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
Button button = new Button( composite, SWT.PUSH );
|
||||
button.setFont( font );
|
||||
button.setText( SourceLookupUIMessages.getString( "PathMappingDialog.3" ) ); //$NON-NLS-1$
|
||||
button.addSelectionListener( new SelectionListener() {
|
||||
Button button = new Button(composite, SWT.PUSH);
|
||||
button.setFont(font);
|
||||
button.setText(SourceLookupUIMessages.PathMappingDialog_3);
|
||||
button.addSelectionListener(new SelectionListener() {
|
||||
|
||||
public void widgetSelected( SelectionEvent e ) {
|
||||
DirectoryDialog dialog = new DirectoryDialog( MapEntryDialog.this.getShell() );
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
DirectoryDialog dialog = new DirectoryDialog(MapEntryDialog.this.getShell());
|
||||
String path = dialog.open();
|
||||
if ( path != null ) {
|
||||
fLocalPathText.setText( path );
|
||||
if (path != null) {
|
||||
fLocalPathText.setText(path);
|
||||
}
|
||||
}
|
||||
|
||||
public void widgetDefaultSelected( SelectionEvent e ) {
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
||||
protected Control createContents( Composite parent ) {
|
||||
Control control = super.createContents( parent );
|
||||
protected Control createContents(Composite parent) {
|
||||
Control control = super.createContents(parent);
|
||||
initialize();
|
||||
update();
|
||||
return control;
|
||||
}
|
||||
|
||||
protected void configureShell( Shell newShell ) {
|
||||
newShell.setText( SourceLookupUIMessages.getString( "PathMappingDialog.4" ) ); //$NON-NLS-1$
|
||||
super.configureShell( newShell );
|
||||
protected void configureShell(Shell newShell) {
|
||||
newShell.setText(SourceLookupUIMessages.PathMappingDialog_4);
|
||||
super.configureShell(newShell);
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
if ( fEntry != null ) {
|
||||
fBackendPathText.setText( fEntry.getBackendPath().toOSString() );
|
||||
fLocalPathText.setText( fEntry.getLocalPath().toOSString() );
|
||||
if (fEntry != null) {
|
||||
fBackendPathText.setText(fEntry.getBackendPath().toOSString());
|
||||
fLocalPathText.setText(fEntry.getLocalPath().toOSString());
|
||||
}
|
||||
}
|
||||
|
||||
protected void update() {
|
||||
boolean isOk = updateErrorMessage();
|
||||
Button ok = getButton( IDialogConstants.OK_ID );
|
||||
if ( ok != null )
|
||||
ok.setEnabled( isOk );
|
||||
Button ok = getButton(IDialogConstants.OK_ID);
|
||||
if (ok != null)
|
||||
ok.setEnabled(isOk);
|
||||
}
|
||||
|
||||
protected boolean updateErrorMessage() {
|
||||
setErrorMessage( null );
|
||||
setErrorMessage(null);
|
||||
String backendText = fBackendPathText.getText().trim();
|
||||
if ( backendText.length() == 0 ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.5" ) ); //$NON-NLS-1$
|
||||
if (backendText.length() == 0) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_5);
|
||||
return false;
|
||||
}
|
||||
if ( !new Path( backendText ).isValidPath( backendText ) ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.6" ) ); //$NON-NLS-1$
|
||||
if (!new Path(backendText).isValidPath(backendText)) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_6);
|
||||
return false;
|
||||
}
|
||||
String localText = fLocalPathText.getText().trim();
|
||||
if ( localText.length() == 0 ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.7" ) ); //$NON-NLS-1$
|
||||
if (localText.length() == 0) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_7);
|
||||
return false;
|
||||
}
|
||||
File localPath = new File( localText );
|
||||
if ( !localPath.exists() ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.8" ) ); //$NON-NLS-1$
|
||||
File localPath = new File(localText);
|
||||
if (!localPath.exists()) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_8);
|
||||
return false;
|
||||
}
|
||||
if ( !localPath.isDirectory() ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.9" ) ); //$NON-NLS-1$
|
||||
if (!localPath.isDirectory()) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_9);
|
||||
return false;
|
||||
}
|
||||
if ( !localPath.isAbsolute() ) {
|
||||
setErrorMessage( SourceLookupUIMessages.getString( "PathMappingDialog.10" ) ); //$NON-NLS-1$
|
||||
if (!localPath.isAbsolute()) {
|
||||
setErrorMessage(SourceLookupUIMessages.PathMappingDialog_10);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected IPath getBackendPath() {
|
||||
return new Path( fBackendPathText.getText().trim() );
|
||||
return new Path(fBackendPathText.getText().trim());
|
||||
}
|
||||
|
||||
protected IPath getLocalPath() {
|
||||
return new Path( fLocalPathText.getText().trim() );
|
||||
return new Path(fLocalPathText.getText().trim());
|
||||
}
|
||||
|
||||
protected void okPressed() {
|
||||
if ( fEntry == null ) {
|
||||
if (fEntry == null) {
|
||||
fEntry = new MapEntrySourceContainer();
|
||||
fMapping.addMapEntry( fEntry );
|
||||
fMapping.addMapEntry(fEntry);
|
||||
}
|
||||
fEntry.setBackendPath( getBackendPath() );
|
||||
fEntry.setLocalPath( getLocalPath() );
|
||||
fEntry.setBackendPath(getBackendPath());
|
||||
fEntry.setLocalPath(getLocalPath());
|
||||
super.okPressed();
|
||||
}
|
||||
}
|
||||
|
||||
class PathMappingLabelProvider extends LabelProvider {
|
||||
|
||||
private ILabelProvider fLabelProvider = null;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
|
||||
*/
|
||||
public Image getImage( Object element ) {
|
||||
Image image = getWorkbenchLabelProvider().getImage( element );
|
||||
if ( image != null ) {
|
||||
public Image getImage(Object element) {
|
||||
Image image = getWorkbenchLabelProvider().getImage(element);
|
||||
if (image != null) {
|
||||
return image;
|
||||
}
|
||||
return super.getImage( element );
|
||||
return super.getImage(element);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
||||
*/
|
||||
public String getText( Object element ) {
|
||||
String label = getWorkbenchLabelProvider().getText( element );
|
||||
if ( label == null || label.length() == 0 ) {
|
||||
if ( element instanceof ISourceContainer ) {
|
||||
public String getText(Object element) {
|
||||
String label = getWorkbenchLabelProvider().getText(element);
|
||||
if (label == null || label.length() == 0) {
|
||||
if (element instanceof ISourceContainer) {
|
||||
return ((ISourceContainer)element).getName();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return label;
|
||||
}
|
||||
return super.getText( element );
|
||||
return super.getText(element);
|
||||
}
|
||||
|
||||
private ILabelProvider getWorkbenchLabelProvider() {
|
||||
if ( fLabelProvider == null ) {
|
||||
if (fLabelProvider == null) {
|
||||
fLabelProvider = new WorkbenchLabelProvider();
|
||||
}
|
||||
return fLabelProvider;
|
||||
|
@ -282,24 +280,22 @@ public class PathMappingDialog extends TitleAreaDialog {
|
|||
*/
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
if ( fLabelProvider != null ) {
|
||||
if (fLabelProvider != null) {
|
||||
fLabelProvider.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ContentProvider implements IStructuredContentProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
||||
*/
|
||||
public Object[] getElements( Object input ) {
|
||||
if ( input instanceof MappingSourceContainer ) {
|
||||
public Object[] getElements(Object input) {
|
||||
if (input instanceof MappingSourceContainer) {
|
||||
try {
|
||||
return ((MappingSourceContainer)input).getSourceContainers();
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
setErrorMessage( e.getMessage() );
|
||||
} catch(CoreException e) {
|
||||
setErrorMessage(e.getMessage());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -314,14 +310,12 @@ public class PathMappingDialog extends TitleAreaDialog {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
}
|
||||
}
|
||||
|
||||
private MappingSourceContainer fOriginalMapping;
|
||||
|
||||
protected MappingSourceContainer fMapping;
|
||||
|
||||
private TableViewer fViewer;
|
||||
|
||||
private Text fNameText;
|
||||
|
@ -329,8 +323,8 @@ public class PathMappingDialog extends TitleAreaDialog {
|
|||
private Button fEditButton;
|
||||
private Button fRemoveButton;
|
||||
|
||||
public PathMappingDialog( Shell parentShell, MappingSourceContainer mapping ) {
|
||||
super( parentShell );
|
||||
public PathMappingDialog(Shell parentShell, MappingSourceContainer mapping) {
|
||||
super(parentShell);
|
||||
fOriginalMapping = mapping;
|
||||
fMapping = fOriginalMapping.copy();
|
||||
}
|
||||
|
@ -338,8 +332,8 @@ public class PathMappingDialog extends TitleAreaDialog {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.window.Window#createContents(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected Control createContents( Composite parent ) {
|
||||
Control control = super.createContents( parent );
|
||||
protected Control createContents(Composite parent) {
|
||||
Control control = super.createContents(parent);
|
||||
updateButtons();
|
||||
return control;
|
||||
}
|
||||
|
@ -347,119 +341,118 @@ public class PathMappingDialog extends TitleAreaDialog {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
protected Control createDialogArea( Composite parent ) {
|
||||
setTitle( SourceLookupUIMessages.getString( "PathMappingDialog.11" ) ); //$NON-NLS-1$
|
||||
setTitleImage( CDebugImages.get( CDebugImages.IMG_WIZBAN_PATH_MAPPING ) );
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
setTitle(SourceLookupUIMessages.PathMappingDialog_11);
|
||||
setTitleImage(CDebugImages.get(CDebugImages.IMG_WIZBAN_PATH_MAPPING));
|
||||
|
||||
Font font = parent.getFont();
|
||||
Composite composite = new Composite( parent, SWT.NONE );
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 2;
|
||||
layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN );
|
||||
layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN );
|
||||
layout.verticalSpacing = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_SPACING );
|
||||
layout.horizontalSpacing = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_SPACING );
|
||||
composite.setLayout( layout );
|
||||
GridData data = new GridData( GridData.FILL_BOTH );
|
||||
composite.setLayoutData( data );
|
||||
composite.setFont( font );
|
||||
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
|
||||
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
|
||||
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
|
||||
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
|
||||
composite.setLayout(layout);
|
||||
GridData data = new GridData(GridData.FILL_BOTH);
|
||||
composite.setLayoutData(data);
|
||||
composite.setFont(font);
|
||||
|
||||
Dialog.applyDialogFont( composite );
|
||||
PlatformUI.getWorkbench().getHelpSystem().setHelp( getShell(), ICDebugHelpContextIds.SOURCE_PATH_MAPPING_DIALOG );
|
||||
Dialog.applyDialogFont(composite);
|
||||
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.numColumns = 2;
|
||||
nameComp.setLayout( layout );
|
||||
data = new GridData( GridData.FILL_HORIZONTAL );
|
||||
nameComp.setLayout(layout);
|
||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
data.horizontalSpan = 2;
|
||||
nameComp.setLayoutData( data );
|
||||
nameComp.setFont( font );
|
||||
nameComp.setLayoutData(data);
|
||||
nameComp.setFont(font);
|
||||
|
||||
Label label = new Label( nameComp, SWT.LEFT );
|
||||
data = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
|
||||
label.setLayoutData( data );
|
||||
label.setFont( font );
|
||||
label.setText( SourceLookupUIMessages.getString( "PathMappingDialog.12" ) ); //$NON-NLS-1$
|
||||
fNameText = new Text( nameComp, SWT.SINGLE | SWT.BORDER );
|
||||
data = new GridData( GridData.FILL_HORIZONTAL );
|
||||
fNameText.setLayoutData( data );
|
||||
fNameText.setFont( font );
|
||||
fNameText.setText( getMapping().getName() );
|
||||
fNameText.addModifyListener( new ModifyListener() {
|
||||
public void modifyText( ModifyEvent e ) {
|
||||
Label label = new Label(nameComp, SWT.LEFT);
|
||||
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
||||
label.setLayoutData(data);
|
||||
label.setFont(font);
|
||||
label.setText(SourceLookupUIMessages.PathMappingDialog_12);
|
||||
fNameText = new Text(nameComp, SWT.SINGLE | SWT.BORDER);
|
||||
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||
fNameText.setLayoutData(data);
|
||||
fNameText.setFont(font);
|
||||
fNameText.setText(getMapping().getName());
|
||||
fNameText.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
fViewer = createViewer( composite );
|
||||
data = new GridData( GridData.FILL_BOTH );
|
||||
fViewer.getControl().setLayoutData( data );
|
||||
fViewer.getControl().setFont( font );
|
||||
fViewer.addSelectionChangedListener( new ISelectionChangedListener() {
|
||||
public void selectionChanged( SelectionChangedEvent event ) {
|
||||
fViewer = createViewer(composite);
|
||||
data = new GridData(GridData.FILL_BOTH);
|
||||
fViewer.getControl().setLayoutData(data);
|
||||
fViewer.getControl().setFont(font);
|
||||
fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
updateButtons();
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
Composite buttonComp = new Composite( composite, SWT.NONE );
|
||||
Composite buttonComp = new Composite(composite, SWT.NONE);
|
||||
GridLayout buttonLayout = new GridLayout();
|
||||
buttonLayout.marginHeight = 0;
|
||||
buttonLayout.marginWidth = 0;
|
||||
buttonComp.setLayout( buttonLayout );
|
||||
data = new GridData( GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL );
|
||||
buttonComp.setLayoutData( data );
|
||||
buttonComp.setFont( font );
|
||||
buttonComp.setLayout(buttonLayout);
|
||||
data = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
|
||||
buttonComp.setLayoutData(data);
|
||||
buttonComp.setFont(font);
|
||||
|
||||
GC gc = new GC( parent );
|
||||
gc.setFont( parent.getFont() );
|
||||
GC gc = new GC(parent);
|
||||
gc.setFont(parent.getFont());
|
||||
FontMetrics fontMetrics = gc.getFontMetrics();
|
||||
gc.dispose();
|
||||
|
||||
fAddButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.13" ), fontMetrics ); //$NON-NLS-1$
|
||||
fAddButton.addSelectionListener( new SelectionAdapter() {
|
||||
public void widgetSelected( SelectionEvent evt ) {
|
||||
MapEntryDialog dialog = new MapEntryDialog( getShell() );
|
||||
if ( dialog.open() == Window.OK ) {
|
||||
fAddButton = createPushButton(buttonComp, SourceLookupUIMessages.PathMappingDialog_13, fontMetrics);
|
||||
fAddButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent evt) {
|
||||
MapEntryDialog dialog = new MapEntryDialog(getShell());
|
||||
if (dialog.open() == Window.OK) {
|
||||
getViewer().refresh();
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
fEditButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.14" ), fontMetrics ); //$NON-NLS-1$
|
||||
fEditButton.addSelectionListener( new SelectionAdapter() {
|
||||
public void widgetSelected( SelectionEvent evt ) {
|
||||
fEditButton = createPushButton(buttonComp, SourceLookupUIMessages.PathMappingDialog_14, fontMetrics);
|
||||
fEditButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent evt) {
|
||||
MapEntrySourceContainer[] entries = getSelection();
|
||||
if ( entries.length > 0 ) {
|
||||
MapEntryDialog dialog = new MapEntryDialog( getShell(), entries[0] );
|
||||
if ( dialog.open() == Window.OK ) {
|
||||
if (entries.length > 0) {
|
||||
MapEntryDialog dialog = new MapEntryDialog(getShell(), entries[0]);
|
||||
if (dialog.open() == Window.OK) {
|
||||
getViewer().refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
fRemoveButton = createPushButton( buttonComp, SourceLookupUIMessages.getString( "PathMappingDialog.15" ), fontMetrics ); //$NON-NLS-1$
|
||||
fRemoveButton.addSelectionListener( new SelectionAdapter() {
|
||||
public void widgetSelected( SelectionEvent evt ) {
|
||||
fRemoveButton = createPushButton(buttonComp, SourceLookupUIMessages.PathMappingDialog_15, fontMetrics);
|
||||
fRemoveButton.addSelectionListener(new SelectionAdapter() {
|
||||
public void widgetSelected(SelectionEvent evt) {
|
||||
MapEntrySourceContainer[] entries = getSelection();
|
||||
for ( int i = 0; i < entries.length; ++i ) {
|
||||
fMapping.removeMapEntry( entries[i] );
|
||||
for (int i = 0; i < entries.length; ++i) {
|
||||
fMapping.removeMapEntry(entries[i]);
|
||||
}
|
||||
getViewer().refresh();
|
||||
}
|
||||
} );
|
||||
});
|
||||
|
||||
setMessage( null );
|
||||
|
||||
fViewer.setInput( fMapping );
|
||||
setMessage(null);
|
||||
fViewer.setInput(fMapping);
|
||||
|
||||
return composite;
|
||||
}
|
||||
|
||||
private TableViewer createViewer( Composite parent ) {
|
||||
TableViewer viewer = new TableViewer( parent );
|
||||
viewer.setContentProvider( new ContentProvider() );
|
||||
viewer.setLabelProvider( new PathMappingLabelProvider() );
|
||||
private TableViewer createViewer(Composite parent) {
|
||||
TableViewer viewer = new TableViewer(parent);
|
||||
viewer.setContentProvider(new ContentProvider());
|
||||
viewer.setLabelProvider(new PathMappingLabelProvider());
|
||||
return viewer;
|
||||
}
|
||||
|
||||
|
@ -467,28 +460,28 @@ public class PathMappingDialog extends TitleAreaDialog {
|
|||
return fOriginalMapping;
|
||||
}
|
||||
|
||||
protected Button createPushButton( Composite parent, String label, FontMetrics fontMetrics ) {
|
||||
Button button = new Button( parent, SWT.PUSH );
|
||||
button.setFont( parent.getFont() );
|
||||
button.setText( label );
|
||||
GridData gd = getButtonGridData( button, fontMetrics );
|
||||
button.setLayoutData( gd );
|
||||
protected Button createPushButton(Composite parent, String label, FontMetrics fontMetrics) {
|
||||
Button button = new Button(parent, SWT.PUSH);
|
||||
button.setFont(parent.getFont());
|
||||
button.setText(label);
|
||||
GridData gd = getButtonGridData(button, fontMetrics);
|
||||
button.setLayoutData(gd);
|
||||
return button;
|
||||
}
|
||||
|
||||
private GridData getButtonGridData( Button button, FontMetrics fontMetrics ) {
|
||||
GridData gd = new GridData( GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING );
|
||||
int widthHint = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH );
|
||||
gd.widthHint = Math.max( widthHint, button.computeSize( SWT.DEFAULT, SWT.DEFAULT, true ).x );
|
||||
private GridData getButtonGridData(Button button, FontMetrics fontMetrics) {
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
|
||||
int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
|
||||
gd.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
|
||||
return gd;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
protected void configureShell( Shell newShell ) {
|
||||
newShell.setText( SourceLookupUIMessages.getString( "PathMappingDialog.16" ) ); //$NON-NLS-1$
|
||||
super.configureShell( newShell );
|
||||
protected void configureShell(Shell newShell) {
|
||||
newShell.setText(SourceLookupUIMessages.PathMappingDialog_16);
|
||||
super.configureShell(newShell);
|
||||
}
|
||||
|
||||
protected Viewer getViewer() {
|
||||
|
@ -500,11 +493,10 @@ public class PathMappingDialog extends TitleAreaDialog {
|
|||
*/
|
||||
protected void okPressed() {
|
||||
fOriginalMapping.clear();
|
||||
fOriginalMapping.setName( fNameText.getText().trim() );
|
||||
fOriginalMapping.setName(fNameText.getText().trim());
|
||||
try {
|
||||
fOriginalMapping.addMapEntries( (MapEntrySourceContainer[])fMapping.getSourceContainers() );
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
fOriginalMapping.addMapEntries((MapEntrySourceContainer[])fMapping.getSourceContainers());
|
||||
} catch(CoreException e) {
|
||||
}
|
||||
fMapping.dispose();
|
||||
super.okPressed();
|
||||
|
@ -513,20 +505,21 @@ public class PathMappingDialog extends TitleAreaDialog {
|
|||
protected MapEntrySourceContainer[] getSelection() {
|
||||
MapEntrySourceContainer[] result = new MapEntrySourceContainer[0];
|
||||
ISelection s = getViewer().getSelection();
|
||||
if ( s instanceof IStructuredSelection ) {
|
||||
if (s instanceof IStructuredSelection) {
|
||||
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;
|
||||
}
|
||||
|
||||
protected void updateButtons() {
|
||||
MapEntrySourceContainer[] entries = getSelection();
|
||||
if ( fEditButton != null ) {
|
||||
fEditButton.setEnabled( entries.length == 1 );
|
||||
if (fEditButton != null) {
|
||||
fEditButton.setEnabled(entries.length == 1);
|
||||
}
|
||||
if ( fRemoveButton != null ) {
|
||||
fRemoveButton.setEnabled( entries.length > 0 );
|
||||
if (fRemoveButton != null) {
|
||||
fRemoveButton.setEnabled(entries.length > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,24 +12,25 @@ package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
/**
|
||||
* The action used to remove source containers in the source location dialog/tab.
|
||||
*
|
||||
*/
|
||||
public class RemoveAction extends SourceContainerAction {
|
||||
public RemoveAction() {
|
||||
super(SourceLookupUIMessages.getString( "RemoveAction.0" )); //$NON-NLS-1$
|
||||
super(SourceLookupUIMessages.RemoveAction_0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all selected entries.
|
||||
*
|
||||
* @see IAction#run()
|
||||
*/
|
||||
public void run() {
|
||||
List targets = getOrderedSelection();
|
||||
List list = getEntriesAsList();
|
||||
List<ISourceContainer> targets = getOrderedSelection();
|
||||
List<ISourceContainer> list = getEntriesAsList();
|
||||
list.removeAll(targets);
|
||||
setEntries(list);
|
||||
}
|
||||
|
@ -39,7 +40,6 @@ public class RemoveAction extends SourceContainerAction {
|
|||
*/
|
||||
protected boolean updateSelection(IStructuredSelection selection) {
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,10 +71,9 @@ public abstract class SourceContainerAction extends SelectionListenerAction {
|
|||
*
|
||||
* @return targets for an action
|
||||
*/
|
||||
protected List getOrderedSelection() {
|
||||
List targets = new ArrayList();
|
||||
List selection =
|
||||
((IStructuredSelection) getViewer().getSelection()).toList();
|
||||
protected List<ISourceContainer> getOrderedSelection() {
|
||||
List<ISourceContainer> targets = new ArrayList<ISourceContainer>();
|
||||
List<?> selection = ((IStructuredSelection) getViewer().getSelection()).toList();
|
||||
ISourceContainer[] entries = getViewer().getEntries();
|
||||
for (int i = 0; i < entries.length; 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
|
||||
*/
|
||||
protected List getEntriesAsList() {
|
||||
protected List<ISourceContainer> getEntriesAsList() {
|
||||
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++) {
|
||||
list.add(entries[i]);
|
||||
}
|
||||
|
@ -100,9 +99,8 @@ public abstract class SourceContainerAction extends SelectionListenerAction {
|
|||
/**
|
||||
* Updates the entries to the entries in the given list
|
||||
*/
|
||||
protected void setEntries(List list) {
|
||||
getViewer().setEntries(
|
||||
(ISourceContainer[]) list.toArray(new ISourceContainer[list.size()]));
|
||||
protected void setEntries(List<ISourceContainer> list) {
|
||||
getViewer().setEntries(list.toArray(new ISourceContainer[list.size()]));
|
||||
// update all selection listeners
|
||||
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
|
||||
* (visually) is selected.
|
||||
*/
|
||||
protected boolean isIndexSelected(
|
||||
IStructuredSelection selection,
|
||||
int index) {
|
||||
protected boolean isIndexSelected(IStructuredSelection selection, int index) {
|
||||
if (selection.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Iterator entries = selection.iterator();
|
||||
List list = getEntriesAsList();
|
||||
Iterator<?> entries = selection.iterator();
|
||||
List<?> list = getEntriesAsList();
|
||||
while (entries.hasNext()) {
|
||||
Object next = entries.next();
|
||||
if (list.indexOf(next) == index) {
|
||||
|
|
|
@ -21,8 +21,8 @@ public class SourceContainerAdapterFactory implements IAdapterFactory {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
|
||||
*/
|
||||
public Object getAdapter( Object adaptableObject, Class adapterType ) {
|
||||
if ( adapterType.equals( IWorkbenchAdapter.class ) ) {
|
||||
public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
|
||||
if (adapterType.equals(IWorkbenchAdapter.class)) {
|
||||
return new SourceContainerWorkbenchAdapter();
|
||||
}
|
||||
return null;
|
||||
|
@ -31,7 +31,7 @@ public class SourceContainerAdapterFactory implements IAdapterFactory {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
|
||||
*/
|
||||
public Class[] getAdapterList() {
|
||||
public Class<?>[] getAdapterList() {
|
||||
return new Class[]{ IWorkbenchAdapter.class };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
|
|||
* Label provider for source containers and source container types.
|
||||
*/
|
||||
public class SourceContainerLabelProvider extends LabelProvider {
|
||||
|
||||
private ILabelProvider fLabelProvider = null;
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -33,7 +32,7 @@ public class SourceContainerLabelProvider extends LabelProvider {
|
|||
if (image == null) {
|
||||
ISourceContainerType type = null;
|
||||
if (element instanceof ISourceContainer) {
|
||||
type = ((ISourceContainer)element).getType();
|
||||
type = ((ISourceContainer) element).getType();
|
||||
} else if (element instanceof ISourceContainerType) {
|
||||
type = (ISourceContainerType) element;
|
||||
}
|
||||
|
@ -58,7 +57,7 @@ public class SourceContainerLabelProvider extends LabelProvider {
|
|||
if (element instanceof ISourceContainer) {
|
||||
return ((ISourceContainer) element).getName();
|
||||
} else if (element instanceof ISourceContainerType) {
|
||||
return ((ISourceContainerType)element).getName();
|
||||
return ((ISourceContainerType) element).getName();
|
||||
}
|
||||
} else {
|
||||
return label;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
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.
|
||||
*/
|
||||
public class SourceContainerViewer extends TreeViewer {
|
||||
|
||||
/**
|
||||
* Whether enabled/editable.
|
||||
*/
|
||||
|
@ -34,10 +33,9 @@ public class SourceContainerViewer extends TreeViewer {
|
|||
/**
|
||||
* The source container entries displayed in this viewer
|
||||
*/
|
||||
protected List fEntries = new ArrayList();
|
||||
protected List<ISourceContainer> fEntries = new ArrayList<ISourceContainer>();
|
||||
|
||||
class ContentProvider implements ITreeContentProvider {
|
||||
|
||||
/**
|
||||
* @see IStructuredContentProvider#getElements(Object)
|
||||
*/
|
||||
|
@ -81,7 +79,6 @@ public class SourceContainerViewer extends TreeViewer {
|
|||
public boolean hasChildren(Object element) {
|
||||
return ((ISourceContainer)element).isComposite();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,13 +102,13 @@ public class SourceContainerViewer extends TreeViewer {
|
|||
public void setEntries(ISourceContainer[] entries) {
|
||||
fEntries.clear();
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
if(entries[i] != null)
|
||||
if (entries[i] != null)
|
||||
fEntries.add(entries[i]);
|
||||
}
|
||||
if (getInput() == null) {
|
||||
setInput(fEntries);
|
||||
//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)));
|
||||
} else {
|
||||
refresh();
|
||||
|
@ -124,7 +121,7 @@ public class SourceContainerViewer extends TreeViewer {
|
|||
* @return the entries in this viewer
|
||||
*/
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
int index = fEntries.indexOf(sel.getFirstElement());
|
||||
for (int i = 0; i < entries.length; 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)));
|
||||
refresh();
|
||||
}
|
||||
|
@ -166,7 +162,7 @@ public class SourceContainerViewer extends TreeViewer {
|
|||
*/
|
||||
public void setEnabled(boolean enabled) {
|
||||
fEnabled = enabled;
|
||||
// fire selection change to upate actions
|
||||
// fire selection change to update actions
|
||||
setSelection(getSelection());
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
|
@ -31,33 +31,33 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
|
||||
*/
|
||||
public Object[] getChildren( Object o ) {
|
||||
public Object[] getChildren(Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
|
||||
*/
|
||||
public ImageDescriptor getImageDescriptor( Object o ) {
|
||||
if ( o instanceof MappingSourceContainer ) {
|
||||
public ImageDescriptor getImageDescriptor(Object o) {
|
||||
if (o instanceof MappingSourceContainer) {
|
||||
return CDebugImages.DESC_OBJS_PATH_MAPPING;
|
||||
}
|
||||
if ( o instanceof MapEntrySourceContainer ) {
|
||||
if (o instanceof MapEntrySourceContainer) {
|
||||
return CDebugImages.DESC_OBJS_PATH_MAP_ENTRY;
|
||||
}
|
||||
if ( o instanceof ProjectSourceContainer ) {
|
||||
if (o instanceof ProjectSourceContainer) {
|
||||
IProject project = ((ProjectSourceContainer)o).getProject();
|
||||
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create( project );
|
||||
if ( cProject != null )
|
||||
return getImageDescriptor( cProject );
|
||||
ICProject cProject = CCorePlugin.getDefault().getCoreModel().create(project);
|
||||
if (cProject != null)
|
||||
return getImageDescriptor(cProject);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ImageDescriptor getImageDescriptor( ICElement element ) {
|
||||
IWorkbenchAdapter adapter = (IWorkbenchAdapter)element.getAdapter( IWorkbenchAdapter.class );
|
||||
if ( adapter != null ) {
|
||||
return adapter.getImageDescriptor( element );
|
||||
protected ImageDescriptor getImageDescriptor(ICElement element) {
|
||||
IWorkbenchAdapter adapter = (IWorkbenchAdapter)element.getAdapter(IWorkbenchAdapter.class);
|
||||
if (adapter != null) {
|
||||
return adapter.getImageDescriptor(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -65,11 +65,11 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
|
||||
*/
|
||||
public String getLabel( Object o ) {
|
||||
if ( o instanceof MappingSourceContainer ) {
|
||||
return SourceLookupUIMessages.getString( "SourceContainerWorkbenchAdapter.0" ) + ((MappingSourceContainer)o).getName(); //$NON-NLS-1$
|
||||
public String getLabel(Object o) {
|
||||
if (o instanceof MappingSourceContainer) {
|
||||
return SourceLookupUIMessages.SourceContainerWorkbenchAdapter_0 + ((MappingSourceContainer)o).getName();
|
||||
}
|
||||
if ( o instanceof MapEntrySourceContainer ) {
|
||||
if (o instanceof MapEntrySourceContainer) {
|
||||
return ((MapEntrySourceContainer)o).getName();
|
||||
}
|
||||
return null;
|
||||
|
@ -78,23 +78,23 @@ public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
|
||||
*/
|
||||
public Object getParent( Object o ) {
|
||||
public Object getParent(Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getQualifiedName( IPath path ) {
|
||||
public String getQualifiedName(IPath path) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
String[] segments = path.segments();
|
||||
if ( segments.length > 0 ) {
|
||||
buffer.append( path.lastSegment() );
|
||||
if ( segments.length > 1 ) {
|
||||
buffer.append( " - " ); //$NON-NLS-1$
|
||||
if ( path.getDevice() != null ) {
|
||||
buffer.append( path.getDevice() );
|
||||
if (segments.length > 0) {
|
||||
buffer.append(path.lastSegment());
|
||||
if (segments.length > 1) {
|
||||
buffer.append(" - "); //$NON-NLS-1$
|
||||
if (path.getDevice() != null) {
|
||||
buffer.append(path.getDevice());
|
||||
}
|
||||
for( int i = 0; i < segments.length - 1; i++ ) {
|
||||
buffer.append( File.separatorChar );
|
||||
buffer.append( segments[i] );
|
||||
for(int i = 0; i < segments.length - 1; i++) {
|
||||
buffer.append(File.separatorChar);
|
||||
buffer.append(segments[i]);
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* ARM Limited - Initial API and implementation
|
||||
* ARM Limited - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import org.eclipse.cdt.debug.core.model.ICStackFrame;
|
||||
|
@ -34,10 +33,9 @@ import org.eclipse.ui.progress.UIJob;
|
|||
public class SourceDisplayAdapter implements ISourceDisplay {
|
||||
|
||||
class DelegatingStackFrame implements IStackFrame {
|
||||
|
||||
private ICStackFrame fDelegate;
|
||||
|
||||
DelegatingStackFrame( ICStackFrame delegate ) {
|
||||
DelegatingStackFrame(ICStackFrame delegate) {
|
||||
super();
|
||||
fDelegate = delegate;
|
||||
}
|
||||
|
@ -129,11 +127,10 @@ public class SourceDisplayAdapter implements ISourceDisplay {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAdapter( Class adapter ) {
|
||||
if ( ICStackFrame.class.equals( adapter ) )
|
||||
public Object getAdapter(@SuppressWarnings("rawtypes") Class adapter) {
|
||||
if (ICStackFrame.class.equals(adapter))
|
||||
return fDelegate;
|
||||
return fDelegate.getAdapter( adapter );
|
||||
return fDelegate.getAdapter(adapter);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -240,56 +237,53 @@ public class SourceDisplayAdapter implements ISourceDisplay {
|
|||
public void terminate() throws DebugException {
|
||||
fDelegate.terminate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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 ) {
|
||||
if ( element instanceof ICStackFrame ) {
|
||||
public void displaySource(Object element, IWorkbenchPage page, boolean forceSourceLookup) {
|
||||
if (element instanceof ICStackFrame) {
|
||||
ICStackFrame frame = (ICStackFrame)element;
|
||||
if ( isDisplayDisassembly( frame, page ) ) {
|
||||
displayDisassembly( page, frame );
|
||||
}
|
||||
else {
|
||||
DelegatingStackFrame delegatingFrame = new DelegatingStackFrame( (ICStackFrame)element );
|
||||
ISourceDisplay sd = (ISourceDisplay)Platform.getAdapterManager().getAdapter( delegatingFrame, ISourceDisplay.class );
|
||||
if ( sd != null )
|
||||
sd.displaySource( element, page, forceSourceLookup );
|
||||
if (isDisplayDisassembly(frame, page)) {
|
||||
displayDisassembly(page, frame);
|
||||
} else {
|
||||
DelegatingStackFrame delegatingFrame = new DelegatingStackFrame((ICStackFrame)element);
|
||||
ISourceDisplay sd = (ISourceDisplay)Platform.getAdapterManager().getAdapter(delegatingFrame, ISourceDisplay.class);
|
||||
if (sd != null)
|
||||
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
|
||||
IEditorPart editor = getDisassemblyEditorManager().findEditor( page, frame );
|
||||
return ( editor != null );
|
||||
IEditorPart editor = getDisassemblyEditorManager().findEditor(page, frame);
|
||||
return (editor != null);
|
||||
}
|
||||
|
||||
protected DisassemblyEditorManager getDisassemblyEditorManager() {
|
||||
return CDebugUIPlugin.getDefault().getDisassemblyEditorManager();
|
||||
}
|
||||
|
||||
private void displayDisassembly( final IWorkbenchPage page, final Object debugContext ) {
|
||||
Job uijob = new UIJob( "Display Disassembly Job" ) { //$NON-NLS-1$
|
||||
|
||||
private void displayDisassembly(final IWorkbenchPage page, final Object debugContext) {
|
||||
Job uijob = new UIJob("Display Disassembly Job") { //$NON-NLS-1$
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public IStatus runInUIThread( IProgressMonitor monitor ) {
|
||||
public IStatus runInUIThread(IProgressMonitor monitor) {
|
||||
try {
|
||||
getDisassemblyEditorManager().openEditor( page, debugContext );
|
||||
getDisassemblyEditorManager().openEditor(page, debugContext);
|
||||
}
|
||||
catch( DebugException e ) {
|
||||
catch(DebugException e) {
|
||||
return e.getStatus();
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
};
|
||||
uijob.setSystem( true );
|
||||
uijob.setSystem(true);
|
||||
uijob.schedule();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,29 +6,59 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* 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;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
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$
|
||||
|
||||
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
|
||||
static {
|
||||
NLS.initializeMessages(SourceLookupUIMessages.class.getName(), SourceLookupUIMessages.class);
|
||||
}
|
||||
|
||||
private SourceLookupUIMessages() {
|
||||
}
|
||||
|
||||
public static String getString( String key ) {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
return RESOURCE_BUNDLE.getString( key );
|
||||
}
|
||||
catch( MissingResourceException e ) {
|
||||
return '!' + key + '!';
|
||||
}
|
||||
// Do not instantiate
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,42 +10,42 @@
|
|||
# Ken Ryall (Nokia) - Added support for CSourceNotFoundElement ( 167305 )
|
||||
# Ken Ryall (Nokia) - Option to open disassembly view when no source ( 81353 )
|
||||
###############################################################################
|
||||
AddContainerAction.0=&Add...
|
||||
AddSourceContainerDialog.0=Add Source
|
||||
AddSourceContainerDialog.1=Select the type of source to add to the source lookup path
|
||||
DownAction.0=&Down
|
||||
EditContainerAction.0=&Edit...
|
||||
MappingSourceContainerBrowser.0=New Mapping
|
||||
MappingSourceContainerDialog.0=Add/Modify path mapping
|
||||
MappingSourceContainerDialog.1=Compilation path
|
||||
MappingSourceContainerDialog.2=Local file system path
|
||||
MappingSourceContainerDialog.3=Add
|
||||
MappingSourceContainerDialog.4=Up
|
||||
MappingSourceContainerDialog.5=Down
|
||||
AbsolutePathSourceContainerBrowser.0=Absolute Path
|
||||
PathMappingDialog.0=Specify the mapping paths
|
||||
PathMappingDialog.1=Compilation path:
|
||||
PathMappingDialog.2=Local file system path:
|
||||
PathMappingDialog.3=&Browse...
|
||||
PathMappingDialog.4=Path Mapping
|
||||
PathMappingDialog.5=The compilation path must not be empty
|
||||
PathMappingDialog.6=Invalid compilation path.
|
||||
PathMappingDialog.7=The local file systems path must not be empty
|
||||
PathMappingDialog.8=The specified local file system path doesn't exist
|
||||
PathMappingDialog.9=The local file system path must be a directory
|
||||
PathMappingDialog.10=The local file system path must be absolute
|
||||
PathMappingDialog.11=Modify the path mappings
|
||||
PathMappingDialog.12=Name:
|
||||
PathMappingDialog.13=&Add...
|
||||
PathMappingDialog.14=&Edit...
|
||||
PathMappingDialog.15=Re&move
|
||||
PathMappingDialog.16=Path Mappings
|
||||
RemoveAction.0=Re&move
|
||||
SourceContainerWorkbenchAdapter.0=Path Mapping:
|
||||
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.1=Locate File...
|
||||
CSourceNotFoundEditor.2=Missing Source File
|
||||
CSourceNotFoundEditor.3=No source available for \"{0}\" \n
|
||||
CSourceNotFoundEditor.4=View Disassembly...
|
||||
CSourceNotFoundEditor.5=Edit Source Lookup Path...
|
||||
AddContainerAction_0=&Add...
|
||||
AddSourceContainerDialog_0=Add Source
|
||||
AddSourceContainerDialog_1=Select the type of source to add to the source lookup path
|
||||
DownAction_0=&Down
|
||||
EditContainerAction_0=&Edit...
|
||||
MappingSourceContainerBrowser_0=New Mapping
|
||||
MappingSourceContainerDialog_0=Add/Modify path mapping
|
||||
MappingSourceContainerDialog_1=Compilation path
|
||||
MappingSourceContainerDialog_2=Local file system path
|
||||
MappingSourceContainerDialog_3=Add
|
||||
MappingSourceContainerDialog_4=Up
|
||||
MappingSourceContainerDialog_5=Down
|
||||
AbsolutePathSourceContainerBrowser_0=Absolute Path
|
||||
PathMappingDialog_0=Specify the mapping paths
|
||||
PathMappingDialog_1=Compilation path:
|
||||
PathMappingDialog_2=Local file system path:
|
||||
PathMappingDialog_3=&Browse...
|
||||
PathMappingDialog_4=Path Mapping
|
||||
PathMappingDialog_5=The compilation path must not be empty
|
||||
PathMappingDialog_6=Invalid compilation path.
|
||||
PathMappingDialog_7=The local file systems path must not be empty
|
||||
PathMappingDialog_8=The specified local file system path doesn't exist
|
||||
PathMappingDialog_9=The local file system path must be a directory
|
||||
PathMappingDialog_10=The local file system path must be absolute
|
||||
PathMappingDialog_11=Modify the path mappings
|
||||
PathMappingDialog_12=Name:
|
||||
PathMappingDialog_13=&Add...
|
||||
PathMappingDialog_14=&Edit...
|
||||
PathMappingDialog_15=Re&move
|
||||
PathMappingDialog_16=Path Mappings
|
||||
RemoveAction_0=Re&move
|
||||
SourceContainerWorkbenchAdapter_0=Path Mapping:
|
||||
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_1=Locate File...
|
||||
CSourceNotFoundEditor_2=Missing Source File
|
||||
CSourceNotFoundEditor_3=No source available for \"{0}\" \n
|
||||
CSourceNotFoundEditor_4=View Disassembly...
|
||||
CSourceNotFoundEditor_5=Edit Source Lookup Path...
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.sourcelookup;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
||||
/**
|
||||
|
@ -21,28 +21,27 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
|||
public class UpAction extends SourceContainerAction {
|
||||
|
||||
public UpAction() {
|
||||
super(SourceLookupUIMessages.getString( "UpAction.0" )); //$NON-NLS-1$
|
||||
super(SourceLookupUIMessages.UpAction_0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves all selected entries up one position (if possible).
|
||||
*
|
||||
* @see IAction#run()
|
||||
*/
|
||||
public void run() {
|
||||
List targets = getOrderedSelection();
|
||||
List<ISourceContainer> targets = getOrderedSelection();
|
||||
if (targets.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int top = 0;
|
||||
int index = 0;
|
||||
List list = getEntriesAsList();
|
||||
Iterator entries = targets.iterator();
|
||||
while (entries.hasNext()) {
|
||||
Object target = entries.next();
|
||||
List<ISourceContainer> list = getEntriesAsList();
|
||||
for (ISourceContainer target : targets) {
|
||||
index = list.indexOf(target);
|
||||
if (index > top) {
|
||||
top = index - 1;
|
||||
Object temp = list.get(top);
|
||||
ISourceContainer temp = list.get(top);
|
||||
list.set(top, target);
|
||||
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.
|
||||
return !selection.isEmpty() && !isIndexSelected(selection, 0) && getViewer().getTree().getSelection()[0].getParentItem()==null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue