mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 07:15:39 +02:00
update cpath ui
This commit is contained in:
parent
69bab80e56
commit
dd0baea2ea
7 changed files with 168 additions and 41 deletions
|
@ -1,7 +1,18 @@
|
||||||
|
2004-04-20 David Inglis
|
||||||
|
|
||||||
|
Work in progress CPath UI changes
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElement.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathBasePage.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.properties
|
||||||
|
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathIncludeEntryPage.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathSymbolEntryPage.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/ExtendedCPathBasePage.java
|
||||||
|
|
||||||
2004-04-20 Alain Magloire
|
2004-04-20 Alain Magloire
|
||||||
Fix NPE in CDocumentProvider
|
Fix NPE in CDocumentProvider
|
||||||
* src/org/eclipse/cdt/internalu/ui/editor/CDocumentProvider.java
|
* src/org/eclipse/cdt/internalu/ui/editor/CDocumentProvider.java
|
||||||
|
|
||||||
2004-04-20 David Inglis
|
2004-04-20 David Inglis
|
||||||
|
|
||||||
More of the model throws CModeLException.
|
More of the model throws CModeLException.
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class CPListElement {
|
||||||
public static final String MACRO_NAME = "macroname"; //$NON-NLS-1$
|
public static final String MACRO_NAME = "macroname"; //$NON-NLS-1$
|
||||||
public static final String MACRO_VALUE = "macrovalue"; //$NON-NLS-1$
|
public static final String MACRO_VALUE = "macrovalue"; //$NON-NLS-1$
|
||||||
public static final String BASE_REF = "baseref"; //$NON-NLS-1$
|
public static final String BASE_REF = "baseref"; //$NON-NLS-1$
|
||||||
|
public static final String BASE = "base"; //$NON-NLS-1$
|
||||||
|
|
||||||
private ICProject fProject;
|
private ICProject fProject;
|
||||||
|
|
||||||
|
@ -77,12 +78,14 @@ public class CPListElement {
|
||||||
createAttributeElement(EXCLUSION, new Path[0]);
|
createAttributeElement(EXCLUSION, new Path[0]);
|
||||||
createAttributeElement(SYSTEM_INCLUDE, Boolean.valueOf(false));
|
createAttributeElement(SYSTEM_INCLUDE, Boolean.valueOf(false));
|
||||||
createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
|
createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
|
||||||
|
createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
case IPathEntry.CDT_MACRO:
|
case IPathEntry.CDT_MACRO:
|
||||||
createAttributeElement(MACRO_NAME, ""); //$NON-NLS-1$
|
createAttributeElement(MACRO_NAME, ""); //$NON-NLS-1$
|
||||||
createAttributeElement(MACRO_VALUE, ""); //$NON-NLS-1$
|
createAttributeElement(MACRO_VALUE, ""); //$NON-NLS-1$
|
||||||
createAttributeElement(EXCLUSION, new Path[0]);
|
createAttributeElement(EXCLUSION, new Path[0]);
|
||||||
createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
|
createAttributeElement(BASE_REF, new Path("")); //$NON-NLS-1$
|
||||||
|
createAttributeElement(BASE, new Path("")); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
case IPathEntry.CDT_CONTAINER:
|
case IPathEntry.CDT_CONTAINER:
|
||||||
try {
|
try {
|
||||||
|
@ -131,7 +134,7 @@ public class CPListElement {
|
||||||
((Boolean) getAttribute(SYSTEM_INCLUDE)).booleanValue(), exclusionPattern);
|
((Boolean) getAttribute(SYSTEM_INCLUDE)).booleanValue(), exclusionPattern);
|
||||||
case IPathEntry.CDT_MACRO:
|
case IPathEntry.CDT_MACRO:
|
||||||
exclusionPattern = (IPath[]) getAttribute(EXCLUSION);
|
exclusionPattern = (IPath[]) getAttribute(EXCLUSION);
|
||||||
return CoreModel.newMacroEntry(fPath, (String) getAttribute(MACRO_NAME), (String) getAttribute(MACRO_NAME));
|
return CoreModel.newMacroEntry(fPath, (String) getAttribute(MACRO_NAME), (String) getAttribute(MACRO_NAME), exclusionPattern);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -261,7 +264,20 @@ public class CPListElement {
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other != null && other.getClass().equals(getClass())) {
|
if (other != null && other.getClass().equals(getClass())) {
|
||||||
CPListElement elem = (CPListElement) other;
|
CPListElement elem = (CPListElement) other;
|
||||||
return elem.fEntryKind == fEntryKind && elem.fPath.equals(fPath);
|
if ( elem.fEntryKind != fEntryKind || !elem.fPath.equals(fPath)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (fEntryKind) {
|
||||||
|
case IPathEntry.CDT_INCLUDE:
|
||||||
|
return (getAttribute(INCLUDE).equals(elem.getAttribute(INCLUDE)) &&
|
||||||
|
getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) &&
|
||||||
|
getAttribute(BASE).equals(elem.getAttribute(BASE)));
|
||||||
|
case IPathEntry.CDT_MACRO:
|
||||||
|
return (getAttribute(MACRO_NAME).equals(elem.getAttribute(MACRO_NAME)) &&
|
||||||
|
getAttribute(BASE_REF).equals(elem.getAttribute(BASE_REF)) &&
|
||||||
|
getAttribute(BASE).equals(elem.getAttribute(BASE)));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -337,6 +353,7 @@ public class CPListElement {
|
||||||
String macroValue = null;
|
String macroValue = null;
|
||||||
boolean sysInclude = false;
|
boolean sysInclude = false;
|
||||||
IPath baseRef = null;
|
IPath baseRef = null;
|
||||||
|
IPath base = null;
|
||||||
|
|
||||||
// get the resource
|
// get the resource
|
||||||
IResource res = null;
|
IResource res = null;
|
||||||
|
@ -398,6 +415,8 @@ public class CPListElement {
|
||||||
exclusion = ((IIncludeEntry) curr).getExclusionPatterns();
|
exclusion = ((IIncludeEntry) curr).getExclusionPatterns();
|
||||||
sysInclude = ((IIncludeEntry) curr).isSystemInclude();
|
sysInclude = ((IIncludeEntry) curr).isSystemInclude();
|
||||||
baseRef = ((IIncludeEntry) curr).getBasePath();
|
baseRef = ((IIncludeEntry) curr).getBasePath();
|
||||||
|
base = new Path("");
|
||||||
|
// base = ((IIncludeEntry) curr).getBasePath();
|
||||||
include = ((IIncludeEntry) curr).getIncludePath();
|
include = ((IIncludeEntry) curr).getIncludePath();
|
||||||
break;
|
break;
|
||||||
case IPathEntry.CDT_MACRO:
|
case IPathEntry.CDT_MACRO:
|
||||||
|
@ -413,6 +432,8 @@ public class CPListElement {
|
||||||
macroName = ((IMacroEntry) curr).getMacroName();
|
macroName = ((IMacroEntry) curr).getMacroName();
|
||||||
macroValue = ((IMacroEntry) curr).getMacroValue();
|
macroValue = ((IMacroEntry) curr).getMacroValue();
|
||||||
baseRef = ((IMacroEntry) curr).getBasePath();
|
baseRef = ((IMacroEntry) curr).getBasePath();
|
||||||
|
base = new Path("");
|
||||||
|
// base = ((IIncludeEntry) curr).getBasePath();
|
||||||
break;
|
break;
|
||||||
case IPathEntry.CDT_PROJECT:
|
case IPathEntry.CDT_PROJECT:
|
||||||
res = root.findMember(path);
|
res = root.findMember(path);
|
||||||
|
@ -427,6 +448,7 @@ public class CPListElement {
|
||||||
elem.setAttribute(MACRO_VALUE, macroValue);
|
elem.setAttribute(MACRO_VALUE, macroValue);
|
||||||
elem.setAttribute(SYSTEM_INCLUDE, Boolean.valueOf(sysInclude));
|
elem.setAttribute(SYSTEM_INCLUDE, Boolean.valueOf(sysInclude));
|
||||||
elem.setAttribute(BASE_REF, baseRef);
|
elem.setAttribute(BASE_REF, baseRef);
|
||||||
|
elem.setAttribute(BASE, base);
|
||||||
elem.setExported(curr.isExported());
|
elem.setExported(curr.isExported());
|
||||||
|
|
||||||
if (project.exists()) {
|
if (project.exists()) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public abstract class CPathBasePage extends AbstractCOptionPage {
|
||||||
IPath currPath = curr.getPath();
|
IPath currPath = curr.getPath();
|
||||||
if (currPath.isPrefixOf(entryPath) && !currPath.equals(entryPath)) {
|
if (currPath.isPrefixOf(entryPath) && !currPath.equals(entryPath)) {
|
||||||
IPath[] exclusionFilters = (IPath[]) curr.getAttribute(CPListElement.EXCLUSION);
|
IPath[] exclusionFilters = (IPath[]) curr.getAttribute(CPListElement.EXCLUSION);
|
||||||
if (!CoreModelUtil.isExcludedPath(entryPath, exclusionFilters)) {
|
if (!CoreModelUtil.isExcludedPath(entryPath.removeFirstSegments(1), exclusionFilters)) {
|
||||||
IPath pathToExclude = entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator();
|
IPath pathToExclude = entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator();
|
||||||
IPath[] newExclusionFilters = new IPath[exclusionFilters.length + 1];
|
IPath[] newExclusionFilters = new IPath[exclusionFilters.length + 1];
|
||||||
System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length);
|
System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length);
|
||||||
|
|
|
@ -29,6 +29,8 @@ SymbolEntryPage.remove=Remove
|
||||||
SymbolEntryPage.listName=Defines:
|
SymbolEntryPage.listName=Defines:
|
||||||
SymbolEntryPage.editSourcePaths=Edit Source Paths...
|
SymbolEntryPage.editSourcePaths=Edit Source Paths...
|
||||||
SymbolEntryPage.sourcePaths=Source Paths:
|
SymbolEntryPage.sourcePaths=Source Paths:
|
||||||
|
IncludeEntryPage.addExternal.title=Add User Symbol
|
||||||
|
IncludeEntryPage.addExternal.message=Symbol definition:
|
||||||
|
|
||||||
# ------- IncludeEntryPage ----------
|
# ------- IncludeEntryPage ----------
|
||||||
IncludeEntryPage.title=Include Paths
|
IncludeEntryPage.title=Include Paths
|
||||||
|
@ -39,7 +41,9 @@ IncludeEntryPage.remove=Remove
|
||||||
IncludeEntryPage.listName=Include Paths:
|
IncludeEntryPage.listName=Include Paths:
|
||||||
IncludeEntryPage.editSourcePaths=Edit Source Paths...
|
IncludeEntryPage.editSourcePaths=Edit Source Paths...
|
||||||
IncludeEntryPage.sourcePaths=Source Paths:
|
IncludeEntryPage.sourcePaths=Source Paths:
|
||||||
|
IncludeEntryPage.addExternal.button.browse=Browse...
|
||||||
|
IncludeEntryPage.addExternal.title=Add External Include Path
|
||||||
|
IncludeEntryPage.addExternal.message=Include path:
|
||||||
# ------- BuildPathsBlock -------
|
# ------- BuildPathsBlock -------
|
||||||
CPathsBlock.path.up.button=&Up
|
CPathsBlock.path.up.button=&Up
|
||||||
CPathsBlock.path.down.button=&Down
|
CPathsBlock.path.down.button=&Down
|
||||||
|
|
|
@ -9,8 +9,23 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
||||||
|
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.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;
|
||||||
|
|
||||||
public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
|
public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
|
||||||
|
|
||||||
|
@ -23,6 +38,53 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addPath() {
|
protected void addPath() {
|
||||||
|
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 = fPathList.getElements();
|
||||||
|
|
||||||
|
CPListElement newPath = newCPElement(((ICElement) getSelection().get(0)).getResource());
|
||||||
|
newPath.setAttribute(CPListElement.INCLUDE, new Path(newItem));
|
||||||
|
if (!cplist.contains(newPath)) {
|
||||||
|
fPathList.addElement(newPath);
|
||||||
|
fCPathList.add(newPath);
|
||||||
|
fPathList.postSetSelection(new StructuredSelection(newPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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,16 +1,22 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. and others. All
|
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. and others. All
|
||||||
* rights reserved. This program and the accompanying materials are made
|
* rights reserved. This program and the accompanying materials are made
|
||||||
* available under the terms of the Common Public License v1.0 which
|
* available under the terms of the Common Public License v1.0 which accompanies
|
||||||
* accompanies this distribution, and is available at
|
* this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/cpl-v10.html
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors: QNX Software Systems - Initial API and implementation
|
* Contributors: QNX Software Systems - Initial API and implementation
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
||||||
|
import org.eclipse.jface.dialogs.InputDialog;
|
||||||
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
|
import org.eclipse.jface.window.Window;
|
||||||
|
|
||||||
public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
|
public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
|
||||||
|
|
||||||
|
@ -21,8 +27,26 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
|
||||||
protected int getEntryKind() {
|
protected int getEntryKind() {
|
||||||
return IPathEntry.CDT_MACRO;
|
return IPathEntry.CDT_MACRO;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addPath() {
|
|
||||||
|
|
||||||
|
protected void addPath() {
|
||||||
|
// 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 = fPathList.getElements();
|
||||||
|
|
||||||
|
CPListElement newPath = newCPElement(((ICElement) getSelection().get(0)).getResource());
|
||||||
|
newPath.setAttribute(CPListElement.MACRO_NAME, symbol);
|
||||||
|
if (!cplist.contains(newPath)) {
|
||||||
|
fPathList.addElement(newPath);
|
||||||
|
fCPathList.add(newPath);
|
||||||
|
fPathList.postSetSelection(new StructuredSelection(newPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -73,16 +73,16 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
|
|
||||||
public void customButtonPressed(ListDialogField field, int index) {
|
public void customButtonPressed(ListDialogField field, int index) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case IDX_ADD :
|
case IDX_ADD:
|
||||||
addPath();
|
addPath();
|
||||||
break;
|
break;
|
||||||
case IDX_ADD_WORKSPACE :
|
case IDX_ADD_WORKSPACE:
|
||||||
addFromWorkspace();
|
addFromWorkspace();
|
||||||
break;
|
break;
|
||||||
case IDX_ADD_CONTRIBUTED :
|
case IDX_ADD_CONTRIBUTED:
|
||||||
addContributed();
|
addContributed();
|
||||||
break;
|
break;
|
||||||
case IDX_REMOVE :
|
case IDX_REMOVE:
|
||||||
if (canRemove(field.getSelectedElements())) {
|
if (canRemove(field.getSelectedElements())) {
|
||||||
removePath((CPListElement) field.getSelectedElements().get(0));
|
removePath((CPListElement) field.getSelectedElements().get(0));
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
fPrefix = prefix;
|
fPrefix = prefix;
|
||||||
IncludeListAdapter includeListAdaper = new IncludeListAdapter();
|
IncludeListAdapter includeListAdaper = new IncludeListAdapter();
|
||||||
|
|
||||||
String[] buttonLabel = new String[]{ /* 0 */CPathEntryMessages.getString(prefix + ".add"), //$NON-NLS-1$
|
String[] buttonLabel = new String[] { /* 0 */CPathEntryMessages.getString(prefix + ".add"), //$NON-NLS-1$
|
||||||
/* 1 */CPathEntryMessages.getString(prefix + ".addFromWorkspace"), //$NON-NLS-1$
|
/* 1 */CPathEntryMessages.getString(prefix + ".addFromWorkspace"), //$NON-NLS-1$
|
||||||
/* 2 */CPathEntryMessages.getString(prefix + ".addContributed"), null, //$NON-NLS-1$
|
/* 2 */CPathEntryMessages.getString(prefix + ".addContributed"), null, //$NON-NLS-1$
|
||||||
/* 4 */CPathEntryMessages.getString(prefix + ".remove")}; //$NON-NLS-1$
|
/* 4 */CPathEntryMessages.getString(prefix + ".remove")}; //$NON-NLS-1$
|
||||||
|
@ -139,7 +139,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
};
|
};
|
||||||
fPathList.setDialogFieldListener(includeListAdaper);
|
fPathList.setDialogFieldListener(includeListAdaper);
|
||||||
fPathList.setLabelText(CPathEntryMessages.getString(prefix + ".listName")); //$NON-NLS-1$
|
fPathList.setLabelText(CPathEntryMessages.getString(prefix + ".listName")); //$NON-NLS-1$
|
||||||
fSrcList = new TreeListDialogField(adapter, new String[]{CPathEntryMessages.getString(prefix + ".editSourcePaths")}, //$NON-NLS-1$
|
fSrcList = new TreeListDialogField(adapter, new String[] { CPathEntryMessages.getString(prefix + ".editSourcePaths")}, //$NON-NLS-1$
|
||||||
new CElementLabelProvider()) {
|
new CElementLabelProvider()) {
|
||||||
|
|
||||||
protected int getTreeStyle() {
|
protected int getTreeStyle() {
|
||||||
|
@ -156,7 +156,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
|
|
||||||
setControl(composite);
|
setControl(composite);
|
||||||
|
|
||||||
LayoutUtil.doDefaultLayout(composite, new DialogField[]{fSrcList, fPathList}, true);
|
LayoutUtil.doDefaultLayout(composite, new DialogField[] { fSrcList, fPathList}, true);
|
||||||
LayoutUtil.setHorizontalGrabbing(fPathList.getListControl(null));
|
LayoutUtil.setHorizontalGrabbing(fPathList.getListControl(null));
|
||||||
|
|
||||||
int buttonBarWidth = converter.convertWidthInCharsToPixels(30);
|
int buttonBarWidth = converter.convertWidthInCharsToPixels(30);
|
||||||
|
@ -164,15 +164,15 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
fPathList.enableButton(IDX_REMOVE, false);
|
fPathList.enableButton(IDX_REMOVE, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEntryKind(int kind) {
|
public boolean isEntryKind(int kind) {
|
||||||
return kind == getEntryKind();
|
return kind == getEntryKind();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected void addPath();
|
abstract protected void addPath();
|
||||||
|
|
||||||
abstract int getEntryKind();
|
abstract int getEntryKind();
|
||||||
|
|
||||||
protected boolean canRemove(List selected) {
|
protected boolean canRemove(List selected) {
|
||||||
return !selected.isEmpty();
|
return !selected.isEmpty();
|
||||||
}
|
}
|
||||||
|
@ -180,8 +180,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
protected void removePath(CPListElement element) {
|
protected void removePath(CPListElement element) {
|
||||||
ICElement celem = (ICElement) getSelection().get(0);
|
ICElement celem = (ICElement) getSelection().get(0);
|
||||||
if (!celem.getPath().equals(element.getPath())) {
|
if (!celem.getPath().equals(element.getPath())) {
|
||||||
IPath exclude = celem.getPath();
|
IPath exclude = element.getPath().removeFirstSegments(element.getPath().segmentCount()).addTrailingSeparator();
|
||||||
|
|
||||||
IPath[] exclusions = (IPath[]) element.getAttribute(CPListElement.EXCLUSION);
|
IPath[] exclusions = (IPath[]) element.getAttribute(CPListElement.EXCLUSION);
|
||||||
IPath[] newExlusions = new IPath[exclusions.length + 1];
|
IPath[] newExlusions = new IPath[exclusions.length + 1];
|
||||||
System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
|
System.arraycopy(exclusions, 0, newExlusions, 0, exclusions.length);
|
||||||
|
@ -256,7 +255,9 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
CPListElement element = (CPListElement) iter.next();
|
CPListElement element = (CPListElement) iter.next();
|
||||||
if (element.getPath().isPrefixOf(resPath)
|
if (element.getPath().isPrefixOf(resPath)
|
||||||
&& !CoreModelUtil.isExcludedPath(resPath, (IPath[]) element.getAttribute(CPListElement.EXCLUSION))) { //$NON-NLS-1$
|
&& (element.getPath().equals(resPath)
|
||||||
|
|| !CoreModelUtil.isExcludedPath(resPath.removeFirstSegments(1),
|
||||||
|
(IPath[]) element.getAttribute(CPListElement.EXCLUSION)))) {
|
||||||
newList.add(element);
|
newList.add(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,7 +295,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CPListElement newCPElement(IResource resource) {
|
protected CPListElement newCPElement(IResource resource) {
|
||||||
return new CPListElement(fCurrCProject, getEntryKind(), resource.getFullPath(), resource);
|
return new CPListElement(fCurrCProject, getEntryKind(), resource.getFullPath(), resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,9 +365,10 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CPListElement[] openWorkspacePathEntryDialog(CPListElement existing) {
|
protected CPListElement[] openWorkspacePathEntryDialog(CPListElement existing) {
|
||||||
Class[] acceptedClasses = new Class[]{CPListElement.class};
|
Class[] acceptedClasses = new Class[] { CPListElement.class};
|
||||||
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
|
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
|
||||||
ViewerFilter filter = new CPListElementFilter((CPListElement[]) fPathList.getElements().toArray(new CPListElement[0]), getEntryKind(), true);
|
ViewerFilter filter = new CPListElementFilter((CPListElement[]) fPathList.getElements().toArray(new CPListElement[0]),
|
||||||
|
getEntryKind(), true);
|
||||||
|
|
||||||
ILabelProvider lp = new WorkbenchCPathLabelProvider();
|
ILabelProvider lp = new WorkbenchCPathLabelProvider();
|
||||||
ITreeContentProvider cp = new WorkbenchCPathContentProvider();
|
ITreeContentProvider cp = new WorkbenchCPathContentProvider();
|
||||||
|
@ -403,19 +405,20 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
protected void addContributed() {
|
protected void addContributed() {
|
||||||
CPListElement[] includes = openContainerSelectionDialog(null);
|
CPListElement[] includes = openContainerSelectionDialog(null);
|
||||||
if (includes != null) {
|
if (includes != null) {
|
||||||
int nElementsChosen= includes.length;
|
int nElementsChosen = includes.length;
|
||||||
// remove duplicates
|
// remove duplicates
|
||||||
List cplist= fPathList.getElements();
|
List cplist = fPathList.getElements();
|
||||||
List elementsToAdd= new ArrayList(nElementsChosen);
|
List elementsToAdd = new ArrayList(nElementsChosen);
|
||||||
|
|
||||||
for (int i= 0; i < nElementsChosen; i++) {
|
for (int i = 0; i < nElementsChosen; i++) {
|
||||||
CPListElement curr= includes[i];
|
CPListElement curr = includes[i];
|
||||||
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
||||||
elementsToAdd.add(curr);
|
elementsToAdd.add(curr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fPathList.addElements(elementsToAdd);
|
fPathList.addElements(elementsToAdd);
|
||||||
|
fCPathList.addAll(elementsToAdd);
|
||||||
fPathList.postSetSelection(new StructuredSelection(includes));
|
fPathList.postSetSelection(new StructuredSelection(includes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,22 +426,23 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||||
protected void addFromWorkspace() {
|
protected void addFromWorkspace() {
|
||||||
CPListElement[] includes = openWorkspacePathEntryDialog(null);
|
CPListElement[] includes = openWorkspacePathEntryDialog(null);
|
||||||
if (includes != null) {
|
if (includes != null) {
|
||||||
int nElementsChosen= includes.length;
|
int nElementsChosen = includes.length;
|
||||||
// remove duplicates
|
// remove duplicates
|
||||||
List cplist= fPathList.getElements();
|
List cplist = fPathList.getElements();
|
||||||
List elementsToAdd= new ArrayList(nElementsChosen);
|
List elementsToAdd = new ArrayList(nElementsChosen);
|
||||||
|
|
||||||
for (int i= 0; i < nElementsChosen; i++) {
|
for (int i = 0; i < nElementsChosen; i++) {
|
||||||
CPListElement curr= includes[i];
|
CPListElement curr = includes[i];
|
||||||
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
||||||
elementsToAdd.add(curr);
|
elementsToAdd.add(curr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fPathList.addElements(elementsToAdd);
|
fPathList.addElements(elementsToAdd);
|
||||||
fPathList.postSetSelection(new StructuredSelection(includes));
|
fCPathList.addAll(elementsToAdd);
|
||||||
|
fPathList.postSetSelection(new StructuredSelection(elementsToAdd));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private IPathEntry[] getUsedPathFiles(CPListElement existing) {
|
// private IPathEntry[] getUsedPathFiles(CPListElement existing) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue