mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
work in progress - cpath ui stuff
This commit is contained in:
parent
2ae68378fa
commit
8a496f8607
13 changed files with 335 additions and 213 deletions
|
@ -1,3 +1,19 @@
|
|||
2004-04-16 David Inglis
|
||||
|
||||
Work in Progress - CPath ui stuff
|
||||
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/AbstractPathOptionBlock.java
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElement.java
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListLabelProvider.java
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerDescriptor.java
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathContainerSelectionPage.java
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPathEntryMessages.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
|
||||
* src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElementFilter.java
|
||||
|
||||
2004-04-16 Andrew Niefer
|
||||
modify CompletionEngine.completionOnFunctionReference for bug 50807
|
||||
|
||||
|
|
|
@ -285,7 +285,8 @@ abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock imple
|
|||
|
||||
monitor.worked(1);
|
||||
|
||||
getCProject().setRawPathEntries((IPathEntry[]) cpath.toArray(new IPathEntry[cpath.size()]), new SubProgressMonitor(monitor, 7));
|
||||
getCProject().setRawPathEntries((IPathEntry[]) cpath.toArray(new IPathEntry[cpath.size()]),
|
||||
new SubProgressMonitor(monitor, 7));
|
||||
}
|
||||
|
||||
// -------- creation -------------------------------
|
||||
|
|
|
@ -1,94 +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.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
|
||||
/**
|
||||
* Viewer filter for archive selection dialogs. Archives are files with file
|
||||
* extension '.so', '.dll' and '.a'. The filter is not case sensitive.
|
||||
*/
|
||||
public class ArchiveFileFilter extends ViewerFilter {
|
||||
|
||||
private static final String[] fgArchiveExtensions = { ".so", ".a", ".dll"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
private List fExcludes;
|
||||
private boolean fRecursive;
|
||||
|
||||
/**
|
||||
* @param excludedFiles
|
||||
* Excluded files will not pass the filter. <code>null</code> is
|
||||
* allowed if no files should be excluded.
|
||||
* @param recusive
|
||||
* Folders are only shown if, searched recursivly, contain an archive
|
||||
*/
|
||||
public ArchiveFileFilter(IFile[] excludedFiles, boolean recusive) {
|
||||
if (excludedFiles != null) {
|
||||
fExcludes = Arrays.asList(excludedFiles);
|
||||
} else {
|
||||
fExcludes = null;
|
||||
}
|
||||
fRecursive = recusive;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ViewerFilter#select
|
||||
*/
|
||||
public boolean select(Viewer viewer, Object parent, Object element) {
|
||||
if (element instanceof IFile) {
|
||||
if (fExcludes != null && fExcludes.contains(element)) {
|
||||
return false;
|
||||
}
|
||||
return isArchivePath(((IFile) element).getFullPath());
|
||||
} else if (element instanceof IContainer) { // IProject, IFolder
|
||||
if (!fRecursive) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
IResource[] resources = ((IContainer) element).members();
|
||||
for (int i = 0; i < resources.length; i++) {
|
||||
// recursive! Only show containers that contain an archive
|
||||
if (select(viewer, parent, resources[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e.getStatus());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isArchivePath(IPath path) {
|
||||
String ext = path.getFileExtension();
|
||||
if (ext != null && ext.length() != 0) {
|
||||
return isArchiveFileExtension(ext);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isArchiveFileExtension(String ext) {
|
||||
for (int i = 0; i < fgArchiveExtensions.length; i++) {
|
||||
if (ext.equalsIgnoreCase(fgArchiveExtensions[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -354,12 +354,12 @@ public class CPListElement {
|
|||
case IPathEntry.CDT_LIBRARY:
|
||||
res = root.findMember(path);
|
||||
if (res == null) {
|
||||
if (!ArchiveFileFilter.isArchivePath(path)) {
|
||||
if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()
|
||||
&& root.getProject(path.segment(0)).exists()) {
|
||||
res = root.getFolder(path);
|
||||
}
|
||||
}
|
||||
// if (!ArchiveFileFilter.isArchivePath(path)) {
|
||||
// if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()
|
||||
// && root.getProject(path.segment(0)).exists()) {
|
||||
// res = root.getFolder(path);
|
||||
// }
|
||||
// }
|
||||
isMissing = !path.toFile().isFile(); // look for external
|
||||
}
|
||||
sourceAttachment = ((ILibraryEntry) curr).getSourceAttachmentPath();
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
|
||||
/**
|
||||
* Viewer filter for archive selection dialogs. Archives are files with file extension '.so', '.dll' and '.a'. The filter is not
|
||||
* case sensitive.
|
||||
*/
|
||||
public class CPListElementFilter extends ViewerFilter {
|
||||
|
||||
private List fExcludes;
|
||||
private int fKind;
|
||||
private boolean fExportedOnly;
|
||||
|
||||
/**
|
||||
* @param excludedFiles
|
||||
* Excluded paths will not pass the filter. <code>null</code> is allowed if no files should be excluded.
|
||||
* @param recusive
|
||||
* Folders are only shown if, searched recursivly, contain an archive
|
||||
*/
|
||||
public CPListElementFilter(CPListElement[] excludedElements, int kind, boolean exportedOnly) {
|
||||
if (excludedElements != null) {
|
||||
fExcludes = Arrays.asList(excludedElements);
|
||||
}
|
||||
fKind = kind;
|
||||
fExportedOnly = exportedOnly;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ViewerFilter#select
|
||||
*/
|
||||
public boolean select(Viewer viewer, Object parent, Object element) {
|
||||
if (element instanceof CPListElement) {
|
||||
if (((CPListElement) element).getEntryKind() == fKind) {
|
||||
if (fExcludes != null && !fExcludes.contains(element)) {
|
||||
if (fExportedOnly == true && !((CPListElement) element).isExported()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (element instanceof ICProject) {
|
||||
try {
|
||||
IPathEntry[] entries = ((ICProject) element).getRawPathEntries();
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
if (select(viewer, parent, CPListElement.createFromExisting(entries[i], (ICProject) element))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e.getStatus());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -120,8 +120,6 @@ class CPListLabelProvider extends LabelProvider {
|
|||
}
|
||||
}
|
||||
return buf.toString();
|
||||
} else if (ArchiveFileFilter.isArchivePath(path)) {
|
||||
return getPathString(path, resource == null);
|
||||
}
|
||||
// should not come here
|
||||
return path.makeRelative().toString();
|
||||
|
@ -183,14 +181,14 @@ class CPListLabelProvider extends LabelProvider {
|
|||
}
|
||||
|
||||
private String getPathString(IPath path, boolean isExternal) {
|
||||
if (ArchiveFileFilter.isArchivePath(path)) {
|
||||
IPath appendedPath = path.removeLastSegments(1);
|
||||
String appended = isExternal ? appendedPath.toOSString() : appendedPath.makeRelative().toString();
|
||||
return CPathEntryMessages.getFormattedString("CPListLabelProvider.twopart", //$NON-NLS-1$
|
||||
new String[] { path.lastSegment(), appended});
|
||||
} else {
|
||||
// if (ArchiveFileFilter.isArchivePath(path)) {
|
||||
// IPath appendedPath = path.removeLastSegments(1);
|
||||
// String appended = isExternal ? appendedPath.toOSString() : appendedPath.makeRelative().toString();
|
||||
// return CPathEntryMessages.getFormattedString("CPListLabelProvider.twopart", //$NON-NLS-1$
|
||||
// new String[] { path.lastSegment(), appended});
|
||||
// } else {
|
||||
return isExternal ? path.toOSString() : path.makeRelative().toString();
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
private ImageDescriptor getCPListElementBaseImage(CPListElement cpentry) {
|
||||
|
|
|
@ -97,7 +97,7 @@ public class CPathContainerDescriptor {
|
|||
}
|
||||
}
|
||||
if (defaultPageName != null && containers.isEmpty()) {
|
||||
// default page only added of no other extensions found
|
||||
// default page only added if no other extensions found
|
||||
containers.add(defaultPage);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2003 IBM Corporation 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
|
||||
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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
|
||||
*******************************************************************************/
|
||||
* Contributors: QNX Software Systems - Initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2001 Rational Software Corp. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
* Copyright (c) 2002, 2003, 2004 QNX Software Systems Ltd. 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:
|
||||
* Rational Software - initial implementation
|
||||
* Contributors: QNX Software Systems - Initial API and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
|
|
|
@ -22,22 +22,22 @@ BuildPathsBlock.tab.libraries=&Libraries
|
|||
|
||||
# -------- SymbolsEntryPage ---------
|
||||
SymbolEntryPage.title=Symbols
|
||||
SymbolEntryPage.add=Add...
|
||||
SymbolEntryPage.addFromWorkspace=Add from project...
|
||||
SymbolEntryPage.addContributed=Add contributed...
|
||||
SymbolEntryPage.add=Add User Defined...
|
||||
SymbolEntryPage.addFromWorkspace=Add from Workspace...
|
||||
SymbolEntryPage.addContributed=Add Contributed...
|
||||
SymbolEntryPage.remove=Remove
|
||||
SymbolEntryPage.listName=Defines:
|
||||
SymbolEntryPage.editSourcePaths=Edit source paths...
|
||||
SymbolEntryPage.editSourcePaths=Edit Source Paths...
|
||||
SymbolEntryPage.sourcePaths=Source Paths:
|
||||
|
||||
# ------- IncludeEntryPage ----------
|
||||
IncludeEntryPage.title=Include Paths
|
||||
IncludeEntryPage.add=Add External...
|
||||
IncludeEntryPage.addFromWorkspace=Add from Workspace...
|
||||
IncludeEntryPage.addFromWorkspace=Add From Workspace...
|
||||
IncludeEntryPage.addContributed=Add Contributed...
|
||||
IncludeEntryPage.remove=Remove
|
||||
IncludeEntryPage.listName=Include Paths:
|
||||
IncludeEntryPage.editSourcePaths=Edit source paths...
|
||||
IncludeEntryPage.editSourcePaths=Edit Source Paths...
|
||||
IncludeEntryPage.sourcePaths=Source Paths:
|
||||
|
||||
# ------- BuildPathsBlock -------
|
||||
|
|
|
@ -9,14 +9,8 @@
|
|||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.internal.ui.wizards.NewWizardMessages;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.window.Window;
|
||||
|
||||
public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
|
||||
|
||||
|
@ -24,63 +18,11 @@ public class CPathIncludeEntryPage extends ExtendedCPathBasePage {
|
|||
super(adapter, "IncludeEntryPage"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public boolean isEntryKind(int kind) {
|
||||
return kind == IPathEntry.CDT_INCLUDE;
|
||||
}
|
||||
|
||||
protected void addContributed() {
|
||||
CPListElement[] includes = openContainerSelectionDialog(null);
|
||||
if (includes != null) {
|
||||
int nElementsChosen= includes.length;
|
||||
// remove duplicates
|
||||
List cplist= fPathList.getElements();
|
||||
List elementsToAdd= new ArrayList(nElementsChosen);
|
||||
|
||||
for (int i= 0; i < nElementsChosen; i++) {
|
||||
CPListElement curr= includes[i];
|
||||
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
||||
elementsToAdd.add(curr);
|
||||
// curr.setAttribute(CPListElement.SOURCEATTACHMENT, BuildPathSupport.guessSourceAttachment(curr));
|
||||
// curr.setAttribute(CPListElement.JAVADOC, JavaUI.getLibraryJavadocLocation(curr.getPath()));
|
||||
}
|
||||
}
|
||||
|
||||
fPathList.addElements(elementsToAdd);
|
||||
fPathList.postSetSelection(new StructuredSelection(includes));
|
||||
}
|
||||
}
|
||||
|
||||
protected void addFromWorkspace() {
|
||||
// dinglis-TODO Auto-generated method stub
|
||||
|
||||
public int getEntryKind() {
|
||||
return IPathEntry.CDT_INCLUDE;
|
||||
}
|
||||
|
||||
protected void addPath() {
|
||||
// dinglis-TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private CPListElement[] openContainerSelectionDialog(CPListElement 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, fCurrCProject, getRawClasspath());
|
||||
wizard.setWindowTitle(title);
|
||||
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
||||
IPathEntry[] created= wizard.getNewEntries();
|
||||
if (created != null) {
|
||||
CPListElement[] res= new CPListElement[created.length];
|
||||
for (int i= 0; i < res.length; i++) {
|
||||
res[i]= new CPListElement(fCurrCProject, IPathEntry.CDT_CONTAINER, created[i].getPath(), null);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -18,22 +18,11 @@ public class CPathSymbolEntryPage extends ExtendedCPathBasePage {
|
|||
super(adapter, "SymbolEntryPage"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public boolean isEntryKind(int kind) {
|
||||
return kind == IPathEntry.CDT_MACRO;
|
||||
protected int getEntryKind() {
|
||||
return IPathEntry.CDT_MACRO;
|
||||
}
|
||||
|
||||
protected void addContributed() {
|
||||
// dinglis-TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
protected void addFromWorkspace() {
|
||||
// dinglis-TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void addPath() {
|
||||
// dinglis-TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -13,12 +13,16 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||
import org.eclipse.cdt.internal.ui.wizards.NewWizardMessages;
|
||||
import org.eclipse.cdt.internal.ui.wizards.TypedElementSelectionValidator;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
|
||||
|
@ -27,17 +31,27 @@ import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
|
|||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField;
|
||||
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.viewers.IColorProvider;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
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.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
|
||||
import org.eclipse.ui.model.WorkbenchContentProvider;
|
||||
import org.eclipse.ui.model.WorkbenchLabelProvider;
|
||||
|
||||
public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
||||
|
||||
|
@ -50,6 +64,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
|||
private static final int IDX_ADD_WORKSPACE = 1;
|
||||
private static final int IDX_ADD_CONTRIBUTED = 2;
|
||||
private static final int IDX_REMOVE = 4;
|
||||
private String fPrefix;
|
||||
|
||||
private class IncludeListAdapter implements IListAdapter, IDialogFieldListener {
|
||||
|
||||
|
@ -109,6 +124,7 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
|||
|
||||
public ExtendedCPathBasePage(ITreeListAdapter adapter, String prefix) {
|
||||
super(CPathEntryMessages.getString(prefix + ".title")); //$NON-NLS-1$
|
||||
fPrefix = prefix;
|
||||
IncludeListAdapter includeListAdaper = new IncludeListAdapter();
|
||||
|
||||
String[] buttonLabel = new String[]{ /* 0 */CPathEntryMessages.getString(prefix + ".add"), //$NON-NLS-1$
|
||||
|
@ -148,11 +164,15 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
|||
fPathList.enableButton(IDX_REMOVE, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean isEntryKind(int kind) {
|
||||
return kind == getEntryKind();
|
||||
}
|
||||
|
||||
abstract protected void addPath();
|
||||
abstract protected void addFromWorkspace();
|
||||
abstract protected void addContributed();
|
||||
|
||||
abstract int getEntryKind();
|
||||
|
||||
protected boolean canRemove(List selected) {
|
||||
return !selected.isEmpty();
|
||||
}
|
||||
|
@ -197,14 +217,14 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
|||
}
|
||||
|
||||
protected IPathEntry[] getRawClasspath() {
|
||||
IPathEntry[] currEntries= new IPathEntry[fCPathList.size()];
|
||||
for (int i= 0; i < currEntries.length; i++) {
|
||||
CPListElement curr= (CPListElement) fCPathList.get(i);
|
||||
currEntries[i]= curr.getPathEntry();
|
||||
IPathEntry[] currEntries = new IPathEntry[fCPathList.size()];
|
||||
for (int i = 0; i < currEntries.length; i++) {
|
||||
CPListElement curr = (CPListElement) fCPathList.get(i);
|
||||
currEntries[i] = curr.getPathEntry();
|
||||
}
|
||||
return currEntries;
|
||||
}
|
||||
|
||||
|
||||
public List getSelection() {
|
||||
return fSrcList.getSelectedElements();
|
||||
}
|
||||
|
@ -241,5 +261,193 @@ public abstract class ExtendedCPathBasePage extends CPathBasePage {
|
|||
|
||||
public void performDefaults() {
|
||||
}
|
||||
|
||||
protected CPListElement[] openContainerSelectionDialog(CPListElement existing) {
|
||||
IPathEntry elem = null;
|
||||
String title;
|
||||
if (existing == null) {
|
||||
title = CPathEntryMessages.getString(fPrefix + ".ContainerDialog.new.title"); //$NON-NLS-1$
|
||||
} else {
|
||||
title = CPathEntryMessages.getString(fPrefix + ".ContainerDialog.edit.title"); //$NON-NLS-1$
|
||||
elem = existing.getPathEntry();
|
||||
}
|
||||
CPathContainerWizard wizard = new CPathContainerWizard(elem, fCurrCProject, getRawClasspath());
|
||||
wizard.setWindowTitle(title);
|
||||
if (CPathContainerWizard.openWizard(getShell(), wizard) == Window.OK) {
|
||||
IPathEntry[] created = wizard.getNewEntries();
|
||||
if (created != null) {
|
||||
CPListElement[] res = new CPListElement[created.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
res[i] = newCPElement(((ICElement) getSelection().get(0)).getResource());
|
||||
res[i].setAttribute(CPListElement.BASE_REF, created[i].getPath());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private CPListElement newCPElement(IResource resource) {
|
||||
return new CPListElement(fCurrCProject, getEntryKind(), resource.getFullPath(), resource);
|
||||
}
|
||||
|
||||
private class WorkbenchCPathLabelProvider extends CPListLabelProvider {
|
||||
|
||||
WorkbenchLabelProvider fWorkbenchLabelProvider = new WorkbenchLabelProvider();
|
||||
|
||||
public String getText(Object element) {
|
||||
if (element instanceof CPListElement) {
|
||||
return super.getText(element);
|
||||
}
|
||||
return fWorkbenchLabelProvider.getText(element);
|
||||
}
|
||||
|
||||
public Image getImage(Object element) {
|
||||
if (element instanceof CPListElement) {
|
||||
return super.getImage(element);
|
||||
}
|
||||
return fWorkbenchLabelProvider.getImage(element);
|
||||
}
|
||||
}
|
||||
|
||||
private class WorkbenchCPathContentProvider extends WorkbenchContentProvider {
|
||||
|
||||
public Object[] getChildren(Object element) {
|
||||
if (element instanceof ICProject) {
|
||||
try {
|
||||
IPathEntry[] entries = ((ICProject) element).getRawPathEntries();
|
||||
List list = new ArrayList(entries.length);
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
if (entries[i].isExported()) {
|
||||
list.add(CPListElement.createFromExisting(entries[i], (ICProject) element));
|
||||
}
|
||||
}
|
||||
return list.toArray();
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
return new Object[0];
|
||||
}
|
||||
}
|
||||
return super.getChildren(element);
|
||||
}
|
||||
|
||||
public boolean hasChildren(Object element) {
|
||||
if (element instanceof ICProject) {
|
||||
try {
|
||||
IPathEntry[] entries = ((ICProject) element).getRawPathEntries();
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
if (entries[i].isExported()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.hasChildren(element);
|
||||
}
|
||||
|
||||
public Object getParent(Object element) {
|
||||
if (element instanceof CPListElement) {
|
||||
return ((CPListElement) element).getCProject().getProject();
|
||||
}
|
||||
return super.getParent(element);
|
||||
}
|
||||
}
|
||||
|
||||
protected CPListElement[] openWorkspacePathEntryDialog(CPListElement existing) {
|
||||
Class[] acceptedClasses = new Class[]{CPListElement.class};
|
||||
TypedElementSelectionValidator validator = new TypedElementSelectionValidator(acceptedClasses, existing == null);
|
||||
ViewerFilter filter = new CPListElementFilter((CPListElement[]) fPathList.getElements().toArray(new CPListElement[0]), getEntryKind(), true);
|
||||
|
||||
ILabelProvider lp = new WorkbenchCPathLabelProvider();
|
||||
ITreeContentProvider cp = new WorkbenchCPathContentProvider();
|
||||
|
||||
String title = (existing == null) ? CPathEntryMessages.getString(fPrefix + ".fromWorkspaceDialog.new.title") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString(fPrefix + ".fromWorkspaceDialog.edit.title"); //$NON-NLS-1$
|
||||
String message = (existing == null) ? CPathEntryMessages.getString(fPrefix + ".fromWorkspaceDialog.new.description") //$NON-NLS-1$
|
||||
: NewWizardMessages.getString(fPrefix + ".fromWorkspaceDialog.edit.description"); //$NON-NLS-1$
|
||||
|
||||
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
|
||||
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();
|
||||
CPListElement[] res = new CPListElement[elements.length];
|
||||
for (int i = 0; i < res.length; i++) {
|
||||
res[i] = newCPElement(((ICElement) getSelection().get(0)).getResource());
|
||||
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void addContributed() {
|
||||
CPListElement[] includes = openContainerSelectionDialog(null);
|
||||
if (includes != null) {
|
||||
int nElementsChosen= includes.length;
|
||||
// remove duplicates
|
||||
List cplist= fPathList.getElements();
|
||||
List elementsToAdd= new ArrayList(nElementsChosen);
|
||||
|
||||
for (int i= 0; i < nElementsChosen; i++) {
|
||||
CPListElement curr= includes[i];
|
||||
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
||||
elementsToAdd.add(curr);
|
||||
}
|
||||
}
|
||||
|
||||
fPathList.addElements(elementsToAdd);
|
||||
fPathList.postSetSelection(new StructuredSelection(includes));
|
||||
}
|
||||
}
|
||||
|
||||
protected void addFromWorkspace() {
|
||||
CPListElement[] includes = openWorkspacePathEntryDialog(null);
|
||||
if (includes != null) {
|
||||
int nElementsChosen= includes.length;
|
||||
// remove duplicates
|
||||
List cplist= fPathList.getElements();
|
||||
List elementsToAdd= new ArrayList(nElementsChosen);
|
||||
|
||||
for (int i= 0; i < nElementsChosen; i++) {
|
||||
CPListElement curr= includes[i];
|
||||
if (!cplist.contains(curr) && !elementsToAdd.contains(curr)) {
|
||||
elementsToAdd.add(curr);
|
||||
}
|
||||
}
|
||||
|
||||
fPathList.addElements(elementsToAdd);
|
||||
fPathList.postSetSelection(new StructuredSelection(includes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// private IPathEntry[] getUsedPathFiles(CPListElement existing) {
|
||||
// List res= new ArrayList();
|
||||
// List cplist= fPathList.getElements();
|
||||
// for (int i= 0; i < cplist.size(); i++) {
|
||||
// CPListElement elem= (CPListElement)cplist.get(i);
|
||||
// if (isEntryKind(elem.getEntryKind()) && (elem != existing)) {
|
||||
// IResource resource= elem.getResource();
|
||||
// if (resource instanceof IFile) {
|
||||
// res.add(resource);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return (IFile[]) res.toArray(new IFile[res.size()]);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue