mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
This commit is contained in:
parent
8b2e0e8b4d
commit
ee609e18b2
4 changed files with 2 additions and 626 deletions
|
@ -15,7 +15,6 @@ CPathsPropertyPage.unsavedchanges.title=Setting C/C++ Project Path
|
|||
CPathsPropertyPage.unsavedchanges.message=The C/C++ Project path property page contains unsaved modifications. Do you want to save changes so that other path related property pages can be updated?
|
||||
CPathsPropertyPage.unsavedchanges.button.save=Apply
|
||||
CPathsPropertyPage.unsavedchanges.button.discard=Discard
|
||||
CPathsPropertyPage.unsavedchanges.button.ignore=Apply Later
|
||||
|
||||
# ------- CPathFilterPage-------
|
||||
|
||||
|
@ -68,6 +67,8 @@ IncludeSymbolEntryPage.down=Down
|
|||
IncludeSymbolsEntryPage.show_inherited.check=Show Inherited Paths
|
||||
IncludeSymbolEntryPage.addSymbol.title=Add Preprocessor Symbol
|
||||
IncludeSymbolEntryPage.addSymbol.message=Symbol definition:
|
||||
IncludeSymbolEntryPage.editSymbol.title=Edit Preprocessor Symbol
|
||||
IncludeSymbolEntryPage.editSymbol.message=Symbol definition:
|
||||
IncludeSymbolEntryPage.addExternal.button.browse=Browse...
|
||||
IncludeSymbolEntryPage.addExternal.title=Add External Include Path
|
||||
IncludeSymbolEntryPage.addExternal.message=Include path:
|
||||
|
@ -81,35 +82,6 @@ IncludeSymbolEntryPage.fromWorkspaceDialog.edit.title=Edit Include Path from Wor
|
|||
IncludeSymbolEntryPage.fromWorkspaceDialog.edit.description=Select a folder as a include path from the workspace.
|
||||
IncludeSymbolEntryPage.newResource.title=Add File/Folder
|
||||
IncludeSymbolEntryPage.newResource.description=Select a file or folder to add to the include/symbol list to add/remove paths or symbols on.
|
||||
# -------- SymbolsEntryPage ---------
|
||||
SymbolEntryPage.title=Symbols
|
||||
SymbolEntryPage.addUser=Add User Defined...
|
||||
SymbolEntryPage.addContributed=Add Contributed...
|
||||
SymbolEntryPage.remove=Remove
|
||||
SymbolEntryPage.edit=Edit...
|
||||
SymbolEntryPage.listName=Defines:
|
||||
SymbolEntryPage.addExternal.title=Add User Symbol
|
||||
SymbolEntryPage.addExternal.message=Symbol definition:
|
||||
SymbolEntryPage.ContainerDialog.new.title=Contributed Symbols Selection
|
||||
SymbolEntryPage.ContainerDialog.edit.title=Contributed Symbols Path Selection
|
||||
|
||||
# ------- IncludeEntryPage ----------
|
||||
IncludeEntryPage.title=Include Paths
|
||||
IncludeEntryPage.addExternal=Add External...
|
||||
IncludeEntryPage.addFromWorkspace=Add From Workspace...
|
||||
IncludeEntryPage.addContributed=Add Contributed...
|
||||
IncludeEntryPage.remove=Remove
|
||||
IncludeEntryPage.edit=Edit...
|
||||
IncludeEntryPage.listName=Include Paths:
|
||||
IncludeEntryPage.addExternal.button.browse=Browse...
|
||||
IncludeEntryPage.addExternal.title=Add External Include Path
|
||||
IncludeEntryPage.addExternal.message=Include path:
|
||||
IncludeEntryPage.ContainerDialog.new.title=Contributed Include Path Selection
|
||||
IncludeEntryPage.ContainerDialog.edit.title=Contributed Include Path Selection
|
||||
IncludeEntryPage.fromWorkspaceDialog.new.title=New Include Path from Workspace
|
||||
IncludeEntryPage.fromWorkspaceDialog.new.description=Select a folder as a include path from the workspace.
|
||||
IncludeEntryPage.fromWorkspaceDialog.edit.title=Edit Include Path from Workspace
|
||||
IncludeEntryPage.fromWorkspaceDialog.edit.description=Select a folder as a include path from the workspace.
|
||||
|
||||
# ------- CPathContainerEntryPage ------
|
||||
ContainerEntryPage.title=Path Containers
|
||||
|
@ -126,7 +98,6 @@ CPathsBlock.path.up.button=&Up
|
|||
CPathsBlock.path.down.button=&Down
|
||||
CPathsBlock.path.checkall.button=Select &All
|
||||
CPathsBlock.path.uncheckall.button=D&eselect All
|
||||
CPathsBlock.path.label=Path order and exported entries:\n(Exported entries are contributed to dependent projects)
|
||||
CPathsBlock.warning.EntryMissing=Build path entry is missing: {0}
|
||||
CPathsBlock.warning.EntriesMissing={0} project path entries are missing.
|
||||
CPathsBlock.operationdesc_c=Setting project paths...
|
||||
|
|
|
@ -1,291 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
|
||||
* program and the accompanying materials are made available under the terms of
|
||||
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors: QNX Software Systems - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IIncludeEntry;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.internal.ui.wizards.TypedElementSelectionValidator;
|
||||
import org.eclipse.cdt.internal.ui.wizards.TypedViewerFilter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
||||
import org.eclipse.cdt.ui.CElementContentProvider;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.dialogs.IInputValidator;
|
||||
import org.eclipse.jface.dialogs.InputDialog;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
|
||||
import org.eclipse.ui.model.WorkbenchLabelProvider;
|
||||
|
||||
public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
|
||||
|
||||
private static final int IDX_ADD_USER = 0;
|
||||
private static final int IDX_ADD_WORKSPACE = 1;
|
||||
private static final int IDX_ADD_CONTRIBUTED = 2;
|
||||
private static final int IDX_EDIT = 4;
|
||||
private static final int IDX_REMOVE = 5;
|
||||
|
||||
private static final String[] buttonLabel = new String[]{
|
||||
/* 0 */CPathEntryMessages.getString("IncludeEntryPage.addExternal"), //$NON-NLS-1$
|
||||
/* 1 */CPathEntryMessages.getString("IncludeEntryPage.addFromWorkspace"), //$NON-NLS-1$
|
||||
/* 2 */CPathEntryMessages.getString("IncludeEntryPage.addContributed"), null, //$NON-NLS-1$
|
||||
/* 4 */CPathEntryMessages.getString("IncludeEntryPage.edit"), //$NON-NLS-1$
|
||||
/* 5 */CPathEntryMessages.getString("IncludeEntryPage.remove")}; //$NON-NLS-1$
|
||||
|
||||
public CPathIncludeEntryPage(ITreeListAdapter adapter) {
|
||||
super(adapter, CPathEntryMessages.getString("IncludeEntryPage.title"), //$NON-NLS-1$
|
||||
CPathEntryMessages.getString("IncludeEntryPage.listName"), buttonLabel); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
protected void buttonPressed(int indx, List selected) {
|
||||
switch (indx) {
|
||||
case IDX_ADD_USER :
|
||||
addInclude();
|
||||
break;
|
||||
case IDX_ADD_WORKSPACE :
|
||||
addFromWorkspace();
|
||||
break;
|
||||
case IDX_ADD_CONTRIBUTED :
|
||||
addContributed();
|
||||
break;
|
||||
case IDX_EDIT :
|
||||
if (canEdit(selected)) {
|
||||
editInclude((CPElement)selected.get(0));
|
||||
}
|
||||
break;
|
||||
case IDX_REMOVE :
|
||||
if (canRemove(selected)) {
|
||||
removeInclude((CPElement)selected.get(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEntryKind(int kind) {
|
||||
return IPathEntry.CDT_INCLUDE == kind;
|
||||
}
|
||||
|
||||
protected void pathSelectionChanged() {
|
||||
List selected = getPathList().getSelectedElements();
|
||||
getPathList().enableButton(IDX_REMOVE, canRemove(selected));
|
||||
getPathList().enableButton(IDX_EDIT, canEdit(selected));
|
||||
}
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
super.createControl(parent);
|
||||
getPathList().enableButton(IDX_REMOVE, false);
|
||||
getPathList().enableButton(IDX_EDIT, false);
|
||||
}
|
||||
|
||||
protected boolean canRemove(List selected) {
|
||||
return !selected.isEmpty();
|
||||
}
|
||||
|
||||
protected boolean canEdit(List selected) {
|
||||
if (!selected.isEmpty()) {
|
||||
return !isPathInheritedFromSelected((CPElement)selected.get(0));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void editInclude(CPElement element) {
|
||||
}
|
||||
|
||||
protected void removeInclude(CPElement element) {
|
||||
removeFromSelectedPath(element);
|
||||
}
|
||||
|
||||
protected void addInclude() {
|
||||
InputDialog dialog = new SelectPathInputDialog(getShell(),
|
||||
CPathEntryMessages.getString("IncludeEntryPage.addExternal.title"), //$NON-NLS-1$
|
||||
CPathEntryMessages.getString("IncludeEntryPage.addExternal.message"), null, null); //$NON-NLS-1$
|
||||
String newItem = null;
|
||||
if (dialog.open() == Window.OK) {
|
||||
newItem = dialog.getValue();
|
||||
if (newItem != null && !newItem.equals("")) { //$NON-NLS-1$
|
||||
List cplist = getPathList().getElements();
|
||||
ICElement element = (ICElement)getSelection().get(0);
|
||||
CPElement newPath = new CPElement(element.getCProject(), IPathEntry.CDT_INCLUDE, element.getPath(),
|
||||
element.getResource());
|
||||
newPath.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
||||
if (!cplist.contains(newPath)) {
|
||||
getPathList().addElement(newPath);
|
||||
fCPathList.add(newPath);
|
||||
getPathList().postSetSelection(new StructuredSelection(newPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addFromWorkspace() {
|
||||
CPElement[] includes = openWorkspacePathEntryDialog(null);
|
||||
if (includes != null) {
|
||||
int nElementsChosen = includes.length;
|
||||
// remove duplicates
|
||||
List cplist = getPathList().getElements();
|
||||
List elementsToAdd = new ArrayList(nElementsChosen);
|
||||
|
||||
for (int i = 0; i < nElementsChosen; i++) {
|
||||
CPElement curr = includes[i];
|
||||
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
||||
elementsToAdd.add(curr);
|
||||
}
|
||||
}
|
||||
|
||||
getPathList().addElements(elementsToAdd);
|
||||
fCPathList.addAll(elementsToAdd);
|
||||
getPathList().postSetSelection(new StructuredSelection(elementsToAdd));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected CPElement[] openWorkspacePathEntryDialog(CPElement existing) {
|
||||
Class[] acceptedClasses = new Class[]{ICProject.class, IProject.class, IContainer.class, ICContainer.class};
|
||||
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
|
||||
ViewerFilter filter = new TypedViewerFilter(acceptedClasses);
|
||||
|
||||
String title = (existing == null) ? CPathEntryMessages.getString("IncludeEntryPage.fromWorkspaceDialog.new.title") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("IncludeEntryPage.fromWorkspaceDialog.edit.title"); //$NON-NLS-1$
|
||||
String message = (existing == null) ? CPathEntryMessages.getString("IncludeEntryPage.fromWorkspaceDialog.new.description") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("IncludeEntryPage.fromWorkspaceDialog.edit.description"); //$NON-NLS-1$
|
||||
|
||||
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
|
||||
new CElementContentProvider());
|
||||
dialog.setValidator(validator);
|
||||
dialog.setTitle(title);
|
||||
dialog.setMessage(message);
|
||||
dialog.addFilter(filter);
|
||||
dialog.setInput(CoreModel.getDefault().getCModel());
|
||||
if (existing == null) {
|
||||
dialog.setInitialSelection(fCurrCProject);
|
||||
} else {
|
||||
dialog.setInitialSelection(existing.getCProject());
|
||||
}
|
||||
|
||||
if (dialog.open() == Window.OK) {
|
||||
Object[] elements = dialog.getResult();
|
||||
CPElement[] res = new CPElement[elements.length];
|
||||
ICElement element = (ICElement)getSelection().get(0);
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
IProject project;
|
||||
IPath includePath;
|
||||
if (elements[i] instanceof IResource) {
|
||||
project = ((IResource)elements[i]).getProject();
|
||||
includePath = ((IResource)elements[i]).getProjectRelativePath();
|
||||
} else {
|
||||
project = ((ICElement)elements[i]).getCProject().getProject();
|
||||
includePath = ((ICElement)elements[i]).getResource().getProjectRelativePath();
|
||||
}
|
||||
res[i] = new CPElement(element.getCProject(), IPathEntry.CDT_INCLUDE, element.getPath(), element.getResource());
|
||||
res[i].setAttribute(CPElement.BASE, project.getFullPath().makeRelative());
|
||||
res[i].setAttribute(CPElement.INCLUDE, includePath);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected CPElement[] openContainerSelectionDialog(CPElement existing) {
|
||||
IPathEntry elem = null;
|
||||
String title;
|
||||
if (existing == null) {
|
||||
title = CPathEntryMessages.getString("IncludeEntryPage.ContainerDialog.new.title"); //$NON-NLS-1$
|
||||
} else {
|
||||
title = CPathEntryMessages.getString("IncludeEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
|
||||
elem = existing.getPathEntry();
|
||||
}
|
||||
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, (ICElement)getSelection().get(0), getRawPathEntries(),
|
||||
new int[] {IPathEntry.CDT_INCLUDE});
|
||||
wizard.setWindowTitle(title);
|
||||
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
||||
IPathEntry parent = wizard.getEntriesParent();
|
||||
IPathEntry[] elements = wizard.getEntries();
|
||||
IResource resource = ((ICElement)getSelection().get(0)).getResource();
|
||||
|
||||
if (elements != null) {
|
||||
CPElement[] res = new CPElement[elements.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, resource.getFullPath(), resource);
|
||||
res[i].setAttribute(CPElement.INCLUDE, ((IIncludeEntry)elements[i]).getIncludePath());
|
||||
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void addContributed() {
|
||||
CPElement[] includes = openContainerSelectionDialog(null);
|
||||
if (includes != null) {
|
||||
int nElementsChosen = includes.length;
|
||||
// remove duplicates
|
||||
List cplist = getPathList().getElements();
|
||||
List elementsToAdd = new ArrayList(nElementsChosen);
|
||||
|
||||
for (int i = 0; i < nElementsChosen; i++) {
|
||||
CPElement curr = includes[i];
|
||||
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
||||
elementsToAdd.add(curr);
|
||||
}
|
||||
}
|
||||
|
||||
getPathList().addElements(elementsToAdd);
|
||||
fCPathList.addAll(elementsToAdd);
|
||||
getPathList().postSetSelection(new StructuredSelection(includes));
|
||||
}
|
||||
}
|
||||
|
||||
private class SelectPathInputDialog extends InputDialog {
|
||||
|
||||
public SelectPathInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue,
|
||||
IInputValidator validator) {
|
||||
super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
|
||||
}
|
||||
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
super.createButtonsForButtonBar(parent);
|
||||
Button browse = createButton(parent, 3, CPathEntryMessages.getString("IncludeEntryPage.addExternal.button.browse"), //$NON-NLS-1$
|
||||
true); //$NON-NLS-1$
|
||||
browse.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
public void widgetSelected(SelectionEvent ev) {
|
||||
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
|
||||
String currentName = getText().getText();
|
||||
if (currentName != null && currentName.trim().length() != 0) {
|
||||
dialog.setFilterPath(currentName);
|
||||
}
|
||||
String dirname = dialog.open();
|
||||
if (dirname != null) {
|
||||
getText().setText(dirname);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,178 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
|
||||
* program and the accompanying materials are made available under the terms of
|
||||
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors: QNX Software Systems - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IMacroEntry;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.jface.dialogs.InputDialog;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
|
||||
|
||||
private static final int IDX_ADD = 0;
|
||||
private static final int IDX_ADD_CONTRIBUTED = 1;
|
||||
private static final int IDX_EDIT = 3;
|
||||
private static final int IDX_REMOVE = 4;
|
||||
|
||||
private final static String[] buttonLabel = new String[]{
|
||||
/* 0 */CPathEntryMessages.getString("SymbolEntryPage.addUser"), //$NON-NLS-1$
|
||||
/* 1 */CPathEntryMessages.getString("SymbolEntryPage.addContributed"), //$NON-NLS-1$
|
||||
null, //$NON-NLS-1$
|
||||
/* 3 */CPathEntryMessages.getString("SymbolEntryPage.edit"), //$NON-NLS-1$
|
||||
/* 4 */CPathEntryMessages.getString("SymbolEntryPage.remove")}; //$NON-NLS-1$
|
||||
|
||||
public CPathSymbolEntryPage(ITreeListAdapter adapter) {
|
||||
super(adapter, CPathEntryMessages.getString("SymbolEntryPage.title"), //$NON-NLS-1$
|
||||
CPathEntryMessages.getString("SymbolEntryPage.listName"), buttonLabel); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
protected void buttonPressed(int indx, List selected) {
|
||||
switch (indx) {
|
||||
case IDX_ADD :
|
||||
addSymbol();
|
||||
break;
|
||||
case IDX_ADD_CONTRIBUTED :
|
||||
addContributed();
|
||||
break;
|
||||
case IDX_EDIT :
|
||||
if (canEdit(selected)) {
|
||||
editSymbol((CPElement)selected.get(0));
|
||||
}
|
||||
break;
|
||||
case IDX_REMOVE :
|
||||
if (canRemove(selected)) {
|
||||
removeSymbol((CPElement)selected.get(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void pathSelectionChanged() {
|
||||
List selected = getPathList().getSelectedElements();
|
||||
getPathList().enableButton(IDX_REMOVE, canRemove(selected));
|
||||
getPathList().enableButton(IDX_EDIT, canEdit(selected));
|
||||
}
|
||||
|
||||
protected boolean canRemove(List selected) {
|
||||
return !selected.isEmpty();
|
||||
}
|
||||
|
||||
protected boolean canEdit(List selected) {
|
||||
if (!selected.isEmpty()) {
|
||||
return !isPathInheritedFromSelected((CPElement)selected.get(0));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void editSymbol(CPElement element) {
|
||||
}
|
||||
|
||||
protected void removeSymbol(CPElement element) {
|
||||
removeFromSelectedPath(element);
|
||||
}
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
super.createControl(parent);
|
||||
getPathList().enableButton(IDX_REMOVE, false);
|
||||
getPathList().enableButton(IDX_EDIT, false);
|
||||
}
|
||||
|
||||
public boolean isEntryKind(int kind) {
|
||||
return IPathEntry.CDT_MACRO == kind;
|
||||
}
|
||||
|
||||
protected void addSymbol() {
|
||||
// Popup an entry dialog
|
||||
InputDialog dialog = new InputDialog(getShell(), CPathEntryMessages.getString("SymbolEntryPage.addExternal.title"), //$NON-NLS-1$
|
||||
CPathEntryMessages.getString("SymbolEntryPage.addExternal.message"), "", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
null);
|
||||
String symbol = null;
|
||||
if (dialog.open() == Window.OK) {
|
||||
symbol = dialog.getValue();
|
||||
if (symbol != null && symbol.length() > 0) {
|
||||
List cplist = getPathList().getElements();
|
||||
IResource resource = ((ICElement)getSelection().get(0)).getResource();
|
||||
CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, resource.getFullPath(), resource);
|
||||
String name, value = ""; //$NON-NLS-1$
|
||||
int index = symbol.indexOf("="); //$NON-NLS-1$
|
||||
if (index != -1) {
|
||||
name = symbol.substring(0, index).trim();
|
||||
value = symbol.substring(index + 1).trim();
|
||||
} else {
|
||||
name = symbol.trim();
|
||||
}
|
||||
newPath.setAttribute(CPElement.MACRO_NAME, name);
|
||||
newPath.setAttribute(CPElement.MACRO_VALUE, value);
|
||||
if (!cplist.contains(newPath)) {
|
||||
getPathList().addElement(newPath);
|
||||
fCPathList.add(newPath);
|
||||
getPathList().postSetSelection(new StructuredSelection(newPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addContributed() {
|
||||
CPElement[] includes = openContainerSelectionDialog(null);
|
||||
if (includes != null) {
|
||||
int nElementsChosen = includes.length;
|
||||
// remove duplicates
|
||||
List cplist = getPathList().getElements();
|
||||
List elementsToAdd = new ArrayList(nElementsChosen);
|
||||
|
||||
for (int i = 0; i < nElementsChosen; i++) {
|
||||
CPElement curr = includes[i];
|
||||
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
||||
elementsToAdd.add(curr);
|
||||
}
|
||||
}
|
||||
|
||||
getPathList().addElements(elementsToAdd);
|
||||
fCPathList.addAll(elementsToAdd);
|
||||
getPathList().postSetSelection(new StructuredSelection(includes));
|
||||
}
|
||||
}
|
||||
|
||||
protected CPElement[] openContainerSelectionDialog(CPElement existing) {
|
||||
IPathEntry elem = null;
|
||||
String title;
|
||||
if (existing == null) {
|
||||
title = CPathEntryMessages.getString("SymbolEntryPage.ContainerDialog.new.title"); //$NON-NLS-1$
|
||||
} else {
|
||||
title = CPathEntryMessages.getString("SymbolEntryPage.ContainerDialog.edit.title"); //$NON-NLS-1$
|
||||
elem = existing.getPathEntry();
|
||||
}
|
||||
CPathContainerWizard wizard = new CPathContainerWizard(elem, null, (ICElement)getSelection().get(0), getRawPathEntries(),
|
||||
new int[] {IPathEntry.CDT_MACRO});
|
||||
wizard.setWindowTitle(title);
|
||||
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
||||
IPathEntry parent = wizard.getEntriesParent();
|
||||
IPathEntry[] elements = wizard.getEntries();
|
||||
IResource resource = ((ICElement)getSelection().get(0)).getResource();
|
||||
if (elements != null) {
|
||||
CPElement[] res = new CPElement[elements.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
res[i] = new CPElement(fCurrCProject, IPathEntry.CDT_MACRO, resource.getFullPath(), resource);
|
||||
res[i].setAttribute(CPElement.MACRO_NAME, ((IMacroEntry)elements[i]).getMacroName());
|
||||
res[i].setAttribute(CPElement.BASE_REF, parent.getPath());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This
|
||||
* program and the accompanying materials are made available under the terms of
|
||||
* the Common Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors: QNX Software Systems - initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICContainer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.swt.events.KeyEvent;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
|
||||
public class IncludesSymbolsTabBlock extends AbstractPathOptionBlock {
|
||||
|
||||
private int[] pathTypes = { IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO};
|
||||
|
||||
private CPathIncludeEntryPage fIncludePage;
|
||||
private CPathSymbolEntryPage fSymbolsPage;
|
||||
private SourceTreeAdapter fSourceTreeAdapter;
|
||||
|
||||
private List fCPaths;
|
||||
|
||||
private class SourceTreeAdapter implements ITreeListAdapter {
|
||||
|
||||
public void customButtonPressed(TreeListDialogField field, int index) {
|
||||
}
|
||||
|
||||
public void selectionChanged(TreeListDialogField field) {
|
||||
((ExtendedCPathBasePage)getCurrentPage()).selectionChanged(new StructuredSelection(field.getSelectedElements()));
|
||||
}
|
||||
|
||||
public void doubleClicked(TreeListDialogField field) {
|
||||
}
|
||||
|
||||
public void keyPressed(TreeListDialogField field, KeyEvent event) {
|
||||
}
|
||||
|
||||
public Object[] getChildren(TreeListDialogField field, Object element) {
|
||||
List children = new ArrayList();
|
||||
if (element instanceof ICContainer) {
|
||||
try {
|
||||
children.addAll(((ICContainer) element).getChildrenOfType(ICElement.C_CCONTAINER));
|
||||
children.addAll(((ICContainer) element).getChildrenOfType(ICElement.C_UNIT));
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
return children.toArray();
|
||||
}
|
||||
|
||||
public Object getParent(TreeListDialogField field, Object element) {
|
||||
if (element instanceof ICElement) {
|
||||
return ((ICElement) element).getParent();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasChildren(TreeListDialogField field, Object element) {
|
||||
if (element instanceof ICContainer) {
|
||||
return ((ICContainer) element).hasChildren();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IncludesSymbolsTabBlock(IStatusChangeListener context, int pageToShow) {
|
||||
super(context, pageToShow);
|
||||
fSourceTreeAdapter = new SourceTreeAdapter();
|
||||
}
|
||||
|
||||
protected void addTabs() {
|
||||
fIncludePage = new CPathIncludeEntryPage(fSourceTreeAdapter);
|
||||
addPage(fIncludePage);
|
||||
fSymbolsPage = new CPathSymbolEntryPage(fSourceTreeAdapter);
|
||||
addPage(fSymbolsPage);
|
||||
}
|
||||
|
||||
public Control createContents(Composite parent) {
|
||||
Control control = super.createContents(parent);
|
||||
if (getCProject() != null) {
|
||||
fIncludePage.init(getCProject(), fCPaths);
|
||||
fSymbolsPage.init(getCProject(), fCPaths);
|
||||
}
|
||||
Dialog.applyDialogFont(control);
|
||||
return control;
|
||||
}
|
||||
|
||||
protected List getCPaths() {
|
||||
if (fIncludePage == null) {
|
||||
return fCPaths;
|
||||
}
|
||||
fCPaths.clear();
|
||||
fCPaths.addAll(fIncludePage.getCPaths());
|
||||
fCPaths.addAll(fSymbolsPage.getCPaths());
|
||||
return fCPaths;
|
||||
}
|
||||
|
||||
protected int[] getFilteredTypes() {
|
||||
return pathTypes;
|
||||
}
|
||||
|
||||
protected void initialize(ICElement element, List cPaths) {
|
||||
fCPaths = cPaths;
|
||||
if (fIncludePage != null) {
|
||||
fIncludePage.init(getCProject(), fCPaths);
|
||||
fSymbolsPage.init(getCProject(), fCPaths);
|
||||
}
|
||||
doStatusLineUpdate();
|
||||
initializeTimeStamps();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue