1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-07 08:15:48 +02:00

begining of new include/symbols page.

This commit is contained in:
David Inglis 2004-04-07 20:31:03 +00:00
parent 9ae54e47ff
commit 6df42f9ccf
15 changed files with 844 additions and 314 deletions

View file

@ -1,3 +1,13 @@
2004-04-07 David Inglis
Begining of new Include/Symbols UI pages.
* src/org/eclipse/cdt/internal/dialogs/cpaths/*.java
Changes here due to refactor
* src/org/eclipse/cdt/internal/ui/preferences/
2004-04-05 Alain Magloire 2004-04-05 Alain Magloire
From Chris Wiebe From Chris Wiebe
This patch cleans up the layout of the checkboxes on the Open Type dialog. This patch cleans up the layout of the checkboxes on the Open Type dialog.

View file

@ -0,0 +1,224 @@
/*******************************************************************************
* 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
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.internal.core.model.CModelStatus;
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
abstract public class AbstractPathOptionBlock extends TabFolderOptionBlock implements ICOptionContainer {
private StatusInfo fCPathStatus;
private StatusInfo fBuildPathStatus;
private ICProject fCurrCProject;
private String fUserSettingsTimeStamp;
private long fFileTimeStamp;
private int fPageIndex, fPageCount;
private CPathBasePage fCurrPage;
private IStatusChangeListener fContext;
public AbstractPathOptionBlock(IStatusChangeListener context, int pageToShow) {
super(false);
fContext = context;
fPageIndex = pageToShow;
fCPathStatus = new StatusInfo();
fBuildPathStatus = new StatusInfo();
setOptionContainer(this);
}
// -------- public api --------
/**
* @return Returns the current class path (raw). Note that the entries
* returned must not be valid.
*/
public IPathEntry[] getRawCPath() {
List elements = getCPaths();
int nElements = elements.size();
IPathEntry[] entries = new IPathEntry[elements.size()];
for (int i = 0; i < nElements; i++) {
CPListElement currElement = (CPListElement) elements.get(i);
entries[i] = currElement.getPathEntry();
}
return entries;
}
protected ArrayList getExistingEntries(IPathEntry[] cPathEntries) {
ArrayList newCPath = new ArrayList();
for (int i = 0; i < cPathEntries.length; i++) {
IPathEntry curr = cPathEntries[i];
newCPath.add(CPListElement.createFromExisting(curr, fCurrCProject));
}
return newCPath;
}
abstract protected List getCPaths();
private String getEncodedSettings() {
StringBuffer buf = new StringBuffer();
int nElements = getCPaths().size();
buf.append('[').append(nElements).append(']');
for (int i = 0; i < nElements; i++) {
CPListElement elem = (CPListElement) getCPaths().get(i);
elem.appendEncodedSettings(buf);
}
return buf.toString();
}
public boolean hasChangesInDialog() {
String currSettings = getEncodedSettings();
return !currSettings.equals(fUserSettingsTimeStamp);
}
public boolean hasChangesInCPathFile() {
IFile file = fCurrCProject.getProject().getFile(".cdtproject"); //$NON-NLS-1$
return fFileTimeStamp != file.getModificationStamp();
}
public void initializeTimeStamps() {
IFile file = fCurrCProject.getProject().getFile(".cdtproject"); //$NON-NLS-1$
fFileTimeStamp = file.getModificationStamp();
fUserSettingsTimeStamp = getEncodedSettings();
}
abstract protected void addTabs();
protected void setCProject(ICProject project) {
fCurrCProject = project;
}
protected ICProject getCProject() {
return fCurrCProject;
}
public IProject getProject() {
return fCurrCProject.getProject();
}
protected void doStatusLineUpdate() {
IStatus res = findMostSevereStatus();
fContext.statusChanged(res);
}
private IStatus findMostSevereStatus() {
return StatusUtil.getMostSevere(new IStatus[] { fCPathStatus, fBuildPathStatus});
}
protected StatusInfo getPathStatus() {
return fCPathStatus;
}
// -------- tab switching ----------
public void setCurrentPage(ICOptionPage page) {
super.setCurrentPage(page);
CPathBasePage newPage = (CPathBasePage) page;
if (fCurrPage != null) {
List selection = fCurrPage.getSelection();
if (!selection.isEmpty()) {
newPage.setSelection(selection);
}
}
fCurrPage = (CPathBasePage) page;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#updateContainer()
*/
public void updateContainer() {
update();
}
protected void updateBuildPathStatus() {
List elements = getCPaths();
IPathEntry[] entries = new IPathEntry[elements.size()];
for (int i = elements.size() - 1; i >= 0; i--) {
CPListElement currElement = (CPListElement) elements.get(i);
entries[i] = currElement.getPathEntry();
}
ICModelStatus status = CModelStatus.VERIFIED_OK; // CoreModelUtil.validateCPathEntries(fCurrCProject, entries);
if (!status.isOK()) {
fBuildPathStatus.setError(status.getMessage());
return;
}
fBuildPathStatus.setOK();
}
public Preferences getPreferences() {
return null;
}
protected void addPage(CPathBasePage page) {
addTab(page);
if (fPageIndex == fPageCount) {
fCurrPage = page;
}
fPageCount++;
}
protected ICOptionPage getStartPage() {
if (fCurrPage == null) {
return super.getStartPage();
}
return fCurrPage;
}
abstract protected void internalConfigureCProject(List cPathEntries, IProgressMonitor monitor) throws CoreException, InterruptedException;
// -------- creation -------------------------------
public void configureCProject(IProgressMonitor monitor) throws CoreException, InterruptedException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.setTaskName(CPathEntryMessages.getString("CPathsBlock.operationdesc_c")); //$NON-NLS-1$
monitor.beginTask("", 10); //$NON-NLS-1$
try {
internalConfigureCProject(getCPaths(), monitor);
initializeTimeStamps();
} finally {
monitor.done();
}
}
}

View file

@ -8,24 +8,17 @@
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths; package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.core.model.CoreModelUtil; import org.eclipse.cdt.core.model.CoreModelUtil;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage; import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
public abstract class CPathBasePage extends AbstractCOptionPage { public abstract class CPathBasePage extends AbstractCOptionPage {
public abstract List getSelection();
public abstract void setSelection(List selection);
public abstract boolean isEntryKind(int kind);
public CPathBasePage(String title) { public CPathBasePage(String title) {
super(title); super(title);
} }
@ -33,20 +26,6 @@ public abstract class CPathBasePage extends AbstractCOptionPage {
super(title, image); super(title, image);
} }
protected void filterAndSetSelection(List list) {
ArrayList res = new ArrayList(list.size());
for (int i = list.size() - 1; i >= 0; i--) {
Object curr = list.get(i);
if (curr instanceof CPListElement) {
CPListElement elem = (CPListElement) curr;
if (elem.getParentContainer() == null && isEntryKind(elem.getEntryKind())) {
res.add(curr);
}
}
}
setSelection(res);
}
protected void fixNestingConflicts(List newEntries, List existing, Set modifiedSourceEntries) { protected void fixNestingConflicts(List newEntries, List existing, Set modifiedSourceEntries) {
for (int i = 0; i < newEntries.size(); i++) { for (int i = 0; i < newEntries.size(); i++) {
CPListElement curr = (CPListElement) newEntries.get(i); CPListElement curr = (CPListElement) newEntries.get(i);
@ -74,4 +53,10 @@ public abstract class CPathBasePage extends AbstractCOptionPage {
} }
} }
} }
public abstract List getSelection();
public abstract void setSelection(List selection);
public abstract boolean isEntryKind(int kind);
} }

View file

@ -20,17 +20,34 @@ CPathsPropertyPage.unsavedchanges.button.ignore=Apply Later
BuildPathsBlock.tab.libraries=&Libraries BuildPathsBlock.tab.libraries=&Libraries
# ------- BuildPathsBlock ------- # -------- SymbolsEntryPage ---------
SymbolEntryPage.title=Symbols
SymbolEntryPage.add=Add...
SymbolEntryPage.addFromProject=Add from project...
SymbolEntryPage.addContributed=Add contributed...
SymbolEntryPage.remove=Remove
SymbolEntryPage.defines=Defines:
SymbolEntryPage.editSourcePaths=Edit source paths...
SymbolEntryPage.sourcePath=Source Paths:
# ------- IncludeEntryPage ----------
IncludeEntryPage.title=Include Paths
IncludeEntryPage.addFromWorksapce=Add from Workspace...
IncludeEntryPage.addExternal=Add External...
IncludeEntryPage.addContributed=Add Contributed...
IncludeEntryPage.remove=Remove
IncludeEntryPage.includePath=Include Paths:
IncludeEntryPage.editSourcePaths=Edit source paths...
IncludeEntryPage.sourcePaths=Source Paths:
# ------- BuildPathsBlock -------
CPathsBlock.path.up.button=&Up CPathsBlock.path.up.button=&Up
CPathsBlock.path.down.button=&Down CPathsBlock.path.down.button=&Down
CPathsBlock.path.checkall.button=Select &All CPathsBlock.path.checkall.button=Select &All
CPathsBlock.path.uncheckall.button=D&eselect 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.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.EntryMissing=Build path entry is missing: {0}
CPathsBlock.warning.EntriesMissing={0} build path entries are missing. CPathsBlock.warning.EntriesMissing={0} build path entries are missing.
CPathsBlock.operationdesc_project=Creating project... CPathsBlock.operationdesc_project=Creating project...
CPathsBlock.operationdesc_c=Setting build paths... CPathsBlock.operationdesc_c=Setting build paths...
@ -136,16 +153,18 @@ LibrariesWorkbookPage.AdvancedDialog.createfolder=Create &New Class Folder
LibrariesWorkbookPage.AdvancedDialog.addfolder=Add &Existing Class Folder LibrariesWorkbookPage.AdvancedDialog.addfolder=Add &Existing Class Folder
LibrariesWorkbookPage.AdvancedDialog.addcontainer=Add &Container: LibrariesWorkbookPage.AdvancedDialog.addcontainer=Add &Container:
# -------- OrderExportPage ---------
OrderExportsPage.title=&Order and Export
OrderExportsPage.description=
# ------- ExclusionPatternDialog ------- # ------- ExclusionPatternDialog -------
ExclusionPatternDialog.title=Source Folder Exclusion Patterns ExclusionPatternDialog.title=Source Folder Exclusion Patterns
ExclusionPatternDialog.pattern.label=E&xclusion patterns for ''{0}'': ExclusionPatternDialog.pattern.label=E&xclusion patterns for ''{0}'':
ExclusionPatternDialog.pattern.add=A&dd... ExclusionPatternDialog.pattern.add=A&dd...
ExclusionPatternDialog.pattern.add.multiple=Add &Multiple... ExclusionPatternDialog.pattern.add.multiple=Add &Multiple...
ExclusionPatternDialog.pattern.remove=&Remove ExclusionPatternDialog.pattern.remove=&Remove
ExclusionPatternDialog.pattern.edit=&Edit... ExclusionPatternDialog.pattern.edit=&Edit...
ExclusionPatternDialog.ChooseExclusionPattern.title=Exclusion Pattern Selection ExclusionPatternDialog.ChooseExclusionPattern.title=Exclusion Pattern Selection
ExclusionPatternDialog.ChooseExclusionPattern.description=&Choose folders or files to exclude: ExclusionPatternDialog.ChooseExclusionPattern.description=&Choose folders or files to exclude:
@ -154,36 +173,14 @@ ExclusionPatternDialog.ChooseExclusionPattern.description=&Choose folders or fil
ExclusionPatternEntryDialog.add.title=Add Exclusion Pattern ExclusionPatternEntryDialog.add.title=Add Exclusion Pattern
ExclusionPatternEntryDialog.edit.title=Edit Exclusion Pattern ExclusionPatternEntryDialog.edit.title=Edit Exclusion Pattern
ExclusionPatternEntryDialog.description=Enter a pattern for excluding files from the source folder. Allowed wildcards are '*', '?' and '**'. Examples: 'java/util/A*.java', 'java/util/', '**/Test*'. ExclusionPatternEntryDialog.description=Enter a pattern for excluding files from the source folder. Allowed wildcards are '*', '?' and '**'. Examples: 'java/util/A*.java', 'java/util/', '**/Test*'.
ExclusionPatternEntryDialog.pattern.label=E&xclusion pattern (Path relative to ''{0}''): ExclusionPatternEntryDialog.pattern.label=E&xclusion pattern (Path relative to ''{0}''):
ExclusionPatternEntryDialog.pattern.button=Bro&wse... ExclusionPatternEntryDialog.pattern.button=Bro&wse...
ExclusionPatternEntryDialog.error.empty=Enter a pattern. ExclusionPatternEntryDialog.error.empty=Enter a pattern.
ExclusionPatternEntryDialog.error.notrelative=Pattern must be a relative path. ExclusionPatternEntryDialog.error.notrelative=Pattern must be a relative path.
ExclusionPatternEntryDialog.error.exists=Pattern already exists. ExclusionPatternEntryDialog.error.exists=Pattern already exists.
ExclusionPatternEntryDialog.ChooseExclusionPattern.title=Exclusion Pattern Selection ExclusionPatternEntryDialog.ChooseExclusionPattern.title=Exclusion Pattern Selection
ExclusionPatternEntryDialog.ChooseExclusionPattern.description=&Choose a folder or file to exclude: ExclusionPatternEntryDialog.ChooseExclusionPattern.description=&Choose a folder or file to exclude:
OrderExportsPage.title=&Order and Export
OrderExportsPage.description=
# ------- ClasspathContainerDefaultPage-------
ClasspathContainerDefaultPage.title=Classpath Container
ClasspathContainerDefaultPage.description=Select classpath container path. First segment is the container type.
ClasspathContainerDefaultPage.path.label=&Classpath container path:
ClasspathContainerDefaultPage.path.error.enterpath=Enter path.
ClasspathContainerDefaultPage.path.error.invalidpath=Invalid path.
ClasspathContainerDefaultPage.path.error.needssegment=Path needs at least one segment.
ClasspathContainerDefaultPage.path.error.alreadyexists=Entry already exists.
# ------- ClasspathContainerSelectionPage-------
ClasspathContainerSelectionPage.title=Add Library
ClasspathContainerSelectionPage.description=Select the library type to add.
# ------- CPListLabelProvider ------- # ------- CPListLabelProvider -------
CPListLabelProvider.new=(new) CPListLabelProvider.new=(new)

View file

@ -0,0 +1,99 @@
/*******************************************************************************
* 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
******************************************************************************/
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.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.internal.ui.util.PixelConverter;
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;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
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.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
public class CPathIncludeEntryPage extends CPathBasePage {
private ListDialogField fIncludeList;
private TreeListDialogField fSrcList;
private class IncludeListAdapter implements IListAdapter, IDialogFieldListener {
public void dialogFieldChanged(DialogField field) {
}
public void customButtonPressed(ListDialogField field, int index) {
}
public void selectionChanged(ListDialogField field) {
}
public void doubleClicked(ListDialogField field) {
}
}
public CPathIncludeEntryPage(ITreeListAdapter adapter) {
super(CPathEntryMessages.getString("IncludeEntryPage.title")); //$NON-NLS-1$
IncludeListAdapter includeListAdaper = new IncludeListAdapter();
String[] buttonLabel = new String[] { CPathEntryMessages.getString("IncludeEntryPage.addFromWorksapce"), CPathEntryMessages.getString("IncludeEntryPage.addExternal"), CPathEntryMessages.getString("IncludeEntryPage.addContributed"), null, CPathEntryMessages.getString("IncludeEntryPage.remove")}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
fIncludeList = new ListDialogField(includeListAdaper, buttonLabel, new CPListLabelProvider());
fIncludeList.setDialogFieldListener(includeListAdaper);
fIncludeList.setLabelText(CPathEntryMessages.getString("IncludeEntryPage.includePath")); //$NON-NLS-1$
fSrcList = new TreeListDialogField(adapter, new String[] { CPathEntryMessages.getString("IncludeEntryPage.editSourcePaths")}, new CElementLabelProvider()); //$NON-NLS-1$
fSrcList.setLabelText(CPathEntryMessages.getString("IncludeEntryPage.sourcePaths")); //$NON-NLS-1$
}
public void createControl(Composite parent) {
PixelConverter converter = new PixelConverter(parent);
Composite composite = new Composite(parent, SWT.NONE);
setControl(composite);
LayoutUtil.doDefaultLayout(composite, new DialogField[] { fSrcList, fIncludeList}, true);
LayoutUtil.setHorizontalGrabbing(fIncludeList.getListControl(null));
int buttonBarWidth = converter.convertWidthInCharsToPixels(30);
fIncludeList.setButtonsMinWidth(buttonBarWidth);
}
public void init(ICProject project) {
fSrcList.setElements(project.getChildrenOfType(ICElement.C_CCONTAINER));
}
public List getSelection() {
return fSrcList.getSelectedElements();
}
public void setSelection(List selection) {
fSrcList.selectElements(new StructuredSelection(selection));
}
public boolean isEntryKind(int kind) {
return kind == IPathEntry.CDT_INCLUDE;
}
public void performApply(IProgressMonitor monitor) throws CoreException {
}
public void performDefaults() {
}
}

View file

@ -52,7 +52,7 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
public class CPathSourceEntryPage extends CPathBasePage { public class CPathSourceEntryPage extends CPathBasePage {
private ListDialogField fClassPathList; private ListDialogField fCPathList;
private ICProject fCurrCProject; private ICProject fCurrCProject;
private IPath fProjPath; private IPath fProjPath;
@ -72,7 +72,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
setDescription(CPathEntryMessages.getString("SourcePathEntryPage.description")); //$NON-NLS-1$ setDescription(CPathEntryMessages.getString("SourcePathEntryPage.description")); //$NON-NLS-1$
fWorkspaceRoot = CUIPlugin.getWorkspace().getRoot(); fWorkspaceRoot = CUIPlugin.getWorkspace().getRoot();
fClassPathList = classPathList; fCPathList = classPathList;
SourceContainerAdapter adapter = new SourceContainerAdapter(); SourceContainerAdapter adapter = new SourceContainerAdapter();
@ -106,7 +106,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
private void updateFoldersList() { private void updateFoldersList() {
ArrayList folders = new ArrayList(); ArrayList folders = new ArrayList();
List cpelements = fClassPathList.getElements(); List cpelements = fCPathList.getElements();
for (int i = 0; i < cpelements.size(); i++) { for (int i = 0; i < cpelements.size(); i++) {
CPListElement cpe = (CPListElement) cpelements.get(i); CPListElement cpe = (CPListElement) cpelements.get(i);
if (cpe.getEntryKind() == IPathEntry.CDT_SOURCE) { if (cpe.getEntryKind() == IPathEntry.CDT_SOURCE) {
@ -306,7 +306,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
if (dialog.open() == Window.OK) { if (dialog.open() == Window.OK) {
selElement.setAttribute(CPListElement.EXCLUSION, dialog.getExclusionPattern()); selElement.setAttribute(CPListElement.EXCLUSION, dialog.getExclusionPattern());
fFoldersList.refresh(); fFoldersList.refresh();
fClassPathList.dialogFieldChanged(); // validate fCPathList.dialogFieldChanged(); // validate
} }
} }
} }
@ -331,7 +331,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
} }
if (selElements.isEmpty()) { if (selElements.isEmpty()) {
fFoldersList.refresh(); fFoldersList.refresh();
fClassPathList.dialogFieldChanged(); // validate fCPathList.dialogFieldChanged(); // validate
} else { } else {
fFoldersList.removeElements(selElements); fFoldersList.removeElements(selElements);
} }
@ -390,7 +390,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
private void updateClasspathList() { private void updateClasspathList() {
List srcelements = fFoldersList.getElements(); List srcelements = fFoldersList.getElements();
List cpelements = fClassPathList.getElements(); List cpelements = fCPathList.getElements();
int nEntries = cpelements.size(); int nEntries = cpelements.size();
// backwards, as entries will be deleted // backwards, as entries will be deleted
int lastRemovePos = nEntries; int lastRemovePos = nEntries;
@ -414,7 +414,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
} }
if (lastRemovePos != nEntries || !srcelements.isEmpty()) { if (lastRemovePos != nEntries || !srcelements.isEmpty()) {
fClassPathList.setElements(cpelements); fCPathList.setElements(cpelements);
} }
} }

View file

@ -0,0 +1,99 @@
/*******************************************************************************
* 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
******************************************************************************/
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.ICProject;
import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.internal.ui.util.PixelConverter;
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;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ITreeListAdapter;
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.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
public class CPathSymbolEntryPage extends CPathBasePage {
private ListDialogField fSymbolsList;
private TreeListDialogField fSrcList;
private class SymbolsListAdapter implements IListAdapter, IDialogFieldListener {
public void dialogFieldChanged(DialogField field) {
}
public void customButtonPressed(ListDialogField field, int index) {
}
public void selectionChanged(ListDialogField field) {
}
public void doubleClicked(ListDialogField field) {
}
}
public CPathSymbolEntryPage(ITreeListAdapter adapter) {
super(CPathEntryMessages.getString("SymbolEntryPage.title")); //$NON-NLS-1$
SymbolsListAdapter includeListAdaper = new SymbolsListAdapter();
String[] buttonLabel = new String[] { CPathEntryMessages.getString("SymbolEntryPage.add"), CPathEntryMessages.getString("SymbolEntryPage.addFromProject"), CPathEntryMessages.getString("SymbolEntryPage.addContributed"), null, CPathEntryMessages.getString("SymbolEntryPage.remove")}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
fSymbolsList = new ListDialogField(includeListAdaper, buttonLabel, new CPListLabelProvider());
fSymbolsList.setDialogFieldListener(includeListAdaper);
fSymbolsList.setLabelText(CPathEntryMessages.getString("SymbolEntryPage.defines")); //$NON-NLS-1$
fSrcList = new TreeListDialogField(adapter, new String[] { CPathEntryMessages.getString("SymbolEntryPage.editSourcePaths")}, new CElementLabelProvider()); //$NON-NLS-1$
fSrcList.setLabelText(CPathEntryMessages.getString("SymbolEntryPage.sourcePath")); //$NON-NLS-1$
}
public void createControl(Composite parent) {
PixelConverter converter = new PixelConverter(parent);
Composite composite = new Composite(parent, SWT.NONE);
setControl(composite);
LayoutUtil.doDefaultLayout(composite, new DialogField[] { fSrcList, fSymbolsList}, true);
LayoutUtil.setHorizontalGrabbing(fSymbolsList.getListControl(null));
int buttonBarWidth = converter.convertWidthInCharsToPixels(30);
fSymbolsList.setButtonsMinWidth(buttonBarWidth);
}
public List getSelection() {
return fSrcList.getSelectedElements();
}
public void setSelection(List selection) {
fSrcList.selectElements(new StructuredSelection(selection));
}
public boolean isEntryKind(int kind) {
return kind == IPathEntry.CDT_MACRO;
}
public void performApply(IProgressMonitor monitor) throws CoreException {
}
public void performDefaults() {
}
public void init(ICProject project) {
fSrcList.setElements(project.getChildrenOfType(ICElement.C_CCONTAINER));
}
}

View file

@ -12,57 +12,32 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICModelStatus;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.model.IPathEntry;
import org.eclipse.cdt.internal.core.model.CModelStatus;
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener; import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; 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.IDialogFieldListener;
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionContainer { public class CPathTabBlock extends AbstractPathOptionBlock {
private CheckedListDialogField fCPathList; private CheckedListDialogField fCPathList;
private StatusInfo fCPathStatus;
private StatusInfo fBuildPathStatus;
private ICProject fCurrCProject;
private String fUserSettingsTimeStamp;
private long fFileTimeStamp;
private int fPageIndex, fPageCount;
private CPathSourceEntryPage fSourcePage; private CPathSourceEntryPage fSourcePage;
private CPathProjectsEntryPage fProjectsPage; private CPathProjectsEntryPage fProjectsPage;
private CPathOutputEntryPage fOutputPage; private CPathOutputEntryPage fOutputPage;
//private LibrariesWorkbookPage fLibrariesPage; //private LibrariesWorkbookPage fLibrariesPage;
private CPathBasePage fCurrPage;
private IStatusChangeListener fContext;
private CPathOrderExportPage fOrderExportPage; private CPathOrderExportPage fOrderExportPage;
private class BuildPathAdapter implements IDialogFieldListener { private class BuildPathAdapter implements IDialogFieldListener {
@ -75,15 +50,13 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
void buildPathDialogFieldChanged(DialogField field) { void buildPathDialogFieldChanged(DialogField field) {
if (field == fCPathList) { if (field == fCPathList) {
updateClassPathStatus(); updateCPathStatus();
} }
doStatusLineUpdate(); doStatusLineUpdate();
} }
public CPathTabBlock(IStatusChangeListener context, int pageToShow) { public CPathTabBlock(IStatusChangeListener context, int pageToShow) {
super(true); super(context, pageToShow);
fContext = context;
fPageIndex = pageToShow;
String[] buttonLabels = new String[] { /* 0 */CPathEntryMessages.getString("CPathsBlock.path.up.button"), //$NON-NLS-1$ String[] buttonLabels = new String[] { /* 0 */CPathEntryMessages.getString("CPathsBlock.path.up.button"), //$NON-NLS-1$
/* 1 */CPathEntryMessages.getString("CPathsBlock.path.down.button"), //$NON-NLS-1$ /* 1 */CPathEntryMessages.getString("CPathsBlock.path.down.button"), //$NON-NLS-1$
@ -101,11 +74,10 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
fCPathList.setCheckAllButtonIndex(3); fCPathList.setCheckAllButtonIndex(3);
fCPathList.setUncheckAllButtonIndex(4); fCPathList.setUncheckAllButtonIndex(4);
fCPathStatus = new StatusInfo(); }
fBuildPathStatus = new StatusInfo();
fCurrCProject = null; protected List getCPaths() {
setOptionContainer(this); return fCPathList.getElements();
} }
protected void addTabs() { protected void addTabs() {
@ -119,26 +91,6 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
addPage(fOrderExportPage); addPage(fOrderExportPage);
} }
private void addPage(CPathBasePage page) {
addTab(page);
if (fPageIndex == fPageCount) {
fCurrPage = page;
}
fPageCount++;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#getStartPage()
*/
protected ICOptionPage getStartPage() {
if (fCurrPage == null) {
return super.getStartPage();
}
return fCurrPage;
}
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -146,10 +98,10 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
*/ */
public Control createContents(Composite parent) { public Control createContents(Composite parent) {
Control control = super.createContents(parent); Control control = super.createContents(parent);
if (fCurrCProject != null) { if (getCProject() != null) {
fSourcePage.init(fCurrCProject); fSourcePage.init(getCProject());
fOutputPage.init(fCurrCProject); fOutputPage.init(getCProject());
fProjectsPage.init(fCurrCProject); fProjectsPage.init(getCProject());
//fLibrariesPage.init(fCurrCProject); //fLibrariesPage.init(fCurrCProject);
} }
Dialog.applyDialogFont(control); Dialog.applyDialogFont(control);
@ -175,20 +127,17 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
* project * project
*/ */
public void init(ICProject cproject, IPathEntry[] cpathEntries) { public void init(ICProject cproject, IPathEntry[] cpathEntries) {
fCurrCProject = cproject; setCProject(cproject);
boolean projectExists = false; boolean projectExists = false;
List newClassPath = null; List newClassPath = null;
IProject project = fCurrCProject.getProject(); IProject project = getProject();
projectExists = (project.exists() && project.getFile(".cdtproject").exists()); //$NON-NLS-1$
if (projectExists) {
if (cpathEntries == null) { if (cpathEntries == null) {
try { try {
cpathEntries = fCurrCProject.getRawPathEntries(); cpathEntries = getCProject().getRawPathEntries();
} catch (CModelException e) { } catch (CModelException e) {
} }
} }
}
if (cpathEntries != null) { if (cpathEntries != null) {
newClassPath = getExistingEntries(cpathEntries); newClassPath = getExistingEntries(cpathEntries);
} }
@ -208,9 +157,9 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
fCPathList.setCheckedElements(exportedEntries); fCPathList.setCheckedElements(exportedEntries);
if (fProjectsPage != null) { if (fProjectsPage != null) {
fSourcePage.init(fCurrCProject); fSourcePage.init(getCProject());
fOutputPage.init(fCurrCProject); fOutputPage.init(getCProject());
fProjectsPage.init(fCurrCProject); fProjectsPage.init(getCProject());
// fLibrariesPage.init(fCurrCProject); // fLibrariesPage.init(fCurrCProject);
} }
@ -218,43 +167,6 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
initializeTimeStamps(); initializeTimeStamps();
} }
private ArrayList getExistingEntries(IPathEntry[] cPathEntries) {
ArrayList newCPath = new ArrayList();
for (int i = 0; i < cPathEntries.length; i++) {
IPathEntry curr = cPathEntries[i];
newCPath.add(CPListElement.createFromExisting(curr, fCurrCProject));
}
return newCPath;
}
private String getEncodedSettings() {
StringBuffer buf = new StringBuffer();
int nElements = fCPathList.getSize();
buf.append('[').append(nElements).append(']');
for (int i = 0; i < nElements; i++) {
CPListElement elem = (CPListElement) fCPathList.getElement(i);
elem.appendEncodedSettings(buf);
}
return buf.toString();
}
public boolean hasChangesInDialog() {
String currSettings = getEncodedSettings();
return !currSettings.equals(fUserSettingsTimeStamp);
}
public boolean hasChangesInCPathFile() {
IFile file = fCurrCProject.getProject().getFile(".cdtproject"); //$NON-NLS-1$
return fFileTimeStamp != file.getModificationStamp();
}
public void initializeTimeStamps() {
IFile file = fCurrCProject.getProject().getFile(".cdtproject"); //$NON-NLS-1$
fFileTimeStamp = file.getModificationStamp();
fUserSettingsTimeStamp = getEncodedSettings();
}
private List getDefaultCPath(ICProject cproj) { private List getDefaultCPath(ICProject cproj) {
List list = new ArrayList(); List list = new ArrayList();
// IResource srcFolder; // IResource srcFolder;
@ -277,33 +189,6 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
return list; return list;
} }
// -------- public api --------
/**
* @return Returns the Java project. Can return
* <code>null<code> if the page has not
* been initialized.
*/
public ICProject getCProject() {
return fCurrCProject;
}
/**
* @return Returns the current class path (raw). Note that the entries
* returned must not be valid.
*/
public IPathEntry[] getRawCPath() {
List elements = fCPathList.getElements();
int nElements = elements.size();
IPathEntry[] entries = new IPathEntry[elements.size()];
for (int i = 0; i < nElements; i++) {
CPListElement currElement = (CPListElement) elements.get(i);
entries[i] = currElement.getPathEntry();
}
return entries;
}
// -------- evaluate default settings -------- // -------- evaluate default settings --------
// private List getDefaultClassPath(IJavaProject jproj) { // private List getDefaultClassPath(IJavaProject jproj) {
@ -328,20 +213,11 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
// } // }
// //
private void doStatusLineUpdate() {
IStatus res = findMostSevereStatus();
fContext.statusChanged(res);
}
private IStatus findMostSevereStatus() {
return StatusUtil.getMostSevere(new IStatus[] { fCPathStatus, fBuildPathStatus});
}
/** /**
* Validates the build path. * Validates the build path.
*/ */
public void updateClassPathStatus() { public void updateCPathStatus() {
fCPathStatus.setOK(); getPathStatus().setOK();
List elements = fCPathList.getElements(); List elements = fCPathList.getElements();
@ -352,7 +228,7 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
for (int i = elements.size() - 1; i >= 0; i--) { for (int i = elements.size() - 1; i >= 0; i--) {
CPListElement currElement = (CPListElement) elements.get(i); CPListElement currElement = (CPListElement) elements.get(i);
boolean isChecked = fCPathList.isChecked(currElement); boolean isChecked = fCPathList.isChecked(currElement);
if ( currElement.getEntryKind() == IPathEntry.CDT_SOURCE) { if (currElement.getEntryKind() == IPathEntry.CDT_SOURCE) {
if (isChecked) { if (isChecked) {
fCPathList.setCheckedWithoutUpdate(currElement, false); fCPathList.setCheckedWithoutUpdate(currElement, false);
} }
@ -371,10 +247,10 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
if (nEntriesMissing > 0) { if (nEntriesMissing > 0) {
if (nEntriesMissing == 1) { if (nEntriesMissing == 1) {
fCPathStatus.setWarning(CPathEntryMessages.getFormattedString("BuildPathsBlock.warning.EntryMissing", //$NON-NLS-1$ getPathStatus().setWarning(CPathEntryMessages.getFormattedString("CPathsBlock.warning.EntryMissing", //$NON-NLS-1$
entryMissing.getPath().toString())); entryMissing.getPath().toString()));
} else { } else {
fCPathStatus.setWarning(CPathEntryMessages.getFormattedString("BuildPathsBlock.warning.EntriesMissing", //$NON-NLS-1$ getPathStatus().setWarning(CPathEntryMessages.getFormattedString("CPathsBlock.warning.EntriesMissing", //$NON-NLS-1$
String.valueOf(nEntriesMissing))); String.valueOf(nEntriesMissing)));
} }
} }
@ -387,44 +263,12 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
updateBuildPathStatus(); updateBuildPathStatus();
} }
private void updateBuildPathStatus() {
List elements = fCPathList.getElements();
IPathEntry[] entries = new IPathEntry[elements.size()];
for (int i = elements.size() - 1; i >= 0; i--) {
CPListElement currElement = (CPListElement) elements.get(i);
entries[i] = currElement.getPathEntry();
}
ICModelStatus status = CModelStatus.VERIFIED_OK; // CoreModelUtil.validateCPathEntries(fCurrCProject, entries);
if (!status.isOK()) {
fBuildPathStatus.setError(status.getMessage());
return;
}
fBuildPathStatus.setOK();
}
// -------- creation -------------------------------
public void configureCProject(IProgressMonitor monitor) throws CoreException, InterruptedException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.setTaskName(CPathEntryMessages.getString("CPathsBlock.operationdesc_c")); //$NON-NLS-1$
monitor.beginTask("", 10); //$NON-NLS-1$
try {
internalConfigureCProject(fCPathList.getElements(), monitor);
} finally {
monitor.done();
}
}
/* /*
* Creates the Java project and sets the configured build path and output * Creates the Java project and sets the configured build path and output
* location. If the project already exists only build paths are updated. * location. If the project already exists only build paths are updated.
*/ */
private void internalConfigureCProject(List cPathEntries, IProgressMonitor monitor) throws CoreException, InterruptedException { protected void internalConfigureCProject(List cPathEntries, IProgressMonitor monitor) throws CoreException, InterruptedException {
// 10 monitor steps to go // 10 monitor steps to go
monitor.worked(2); monitor.worked(2);
@ -444,8 +288,7 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
monitor.worked(1); monitor.worked(1);
fCurrCProject.setRawPathEntries(classpath, new SubProgressMonitor(monitor, 7)); getCProject().setRawPathEntries(classpath, new SubProgressMonitor(monitor, 7));
initializeTimeStamps();
} }
/** /**
@ -462,50 +305,4 @@ public class CPathTabBlock extends TabFolderOptionBlock implements ICOptionConta
folder.create(force, local, monitor); folder.create(force, local, monitor);
} }
} }
// -------- tab switching ----------
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#setCurrentPage(org.eclipse.cdt.ui.dialogs.ICOptionPage)
*/
public void setCurrentPage(ICOptionPage page) {
super.setCurrentPage(page);
CPathBasePage newPage = (CPathBasePage) page;
if (fCurrPage != null) {
List selection = fCurrPage.getSelection();
if (!selection.isEmpty()) {
newPage.setSelection(selection);
}
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#updateContainer()
*/
public void updateContainer() {
update();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getProject()
*/
public IProject getProject() {
return fCurrCProject.getProject();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#getPreferences()
*/
public Preferences getPreferences() {
return null;
}
} }

View file

@ -0,0 +1,218 @@
/*******************************************************************************
* 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
******************************************************************************/
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.cdt.core.CProjectNature;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
import org.eclipse.ui.dialogs.PropertyPage;
public class IncludesSymbolsPropertyPage extends PropertyPage implements IStatusChangeListener {
private static final String PAGE_SETTINGS = "IncludeSysmbolsPropertyPage"; //$NON-NLS-1$
private static final String INDEX = "pageIndex"; //$NON-NLS-1$
IncludesSymbolsTabBlock fIncludesSymbolsBlock;
/**
* @see PropertyPage#createContents
*/
protected Control createContents(Composite parent) {
IProject project = getProject();
Control result;
if (project == null || !isCProject(project)) {
result = createWithoutCProject(parent);
} else if (!project.isOpen()) {
result = createForClosedProject(parent);
} else {
result = createWithCProject(parent, project);
}
Dialog.applyDialogFont(result);
return result;
}
private IDialogSettings getSettings() {
IDialogSettings cSettings = CUIPlugin.getDefault().getDialogSettings();
IDialogSettings pageSettings = cSettings.getSection(PAGE_SETTINGS);
if (pageSettings == null) {
pageSettings = cSettings.addNewSection(PAGE_SETTINGS);
pageSettings.put(INDEX, 3);
}
return pageSettings;
}
/*
* Content for valid projects.
*/
private Control createWithCProject(Composite parent, IProject project) {
fIncludesSymbolsBlock = new IncludesSymbolsTabBlock(this, getSettings().getInt(INDEX));
fIncludesSymbolsBlock.init(getCElement(), null);
return fIncludesSymbolsBlock.createContents(parent);
}
/*
* Content for non-C projects.
*/
private Control createWithoutCProject(Composite parent) {
Label label = new Label(parent, SWT.LEFT);
label.setText(CPathEntryMessages.getString("CPathsPropertyPage.no_C_project.message")); //$NON-NLS-1$
fIncludesSymbolsBlock = null;
setValid(true);
return label;
}
/*
* Content for closed projects.
*/
private Control createForClosedProject(Composite parent) {
Label label = new Label(parent, SWT.LEFT);
label.setText(CPathEntryMessages.getString("CPathsPropertyPage.closed_project.message")); //$NON-NLS-1$
fIncludesSymbolsBlock = null;
setValid(true);
return label;
}
public void setVisible(boolean visible) {
if (fIncludesSymbolsBlock != null) {
if (!visible) {
if (fIncludesSymbolsBlock.hasChangesInDialog()) {
String title= CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.title"); //$NON-NLS-1$
String message= CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.message"); //$NON-NLS-1$
String[] buttonLabels= new String[] {
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.save"), //$NON-NLS-1$
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.discard"), //$NON-NLS-1$
CPathEntryMessages.getString("CPathsPropertyPage.unsavedchanges.button.ignore") //$NON-NLS-1$
};
MessageDialog dialog= new MessageDialog(getShell(), title, null, message, MessageDialog.QUESTION, buttonLabels, 0);
int res= dialog.open();
if (res == 0) {
performOk();
} else if (res == 1) {
fIncludesSymbolsBlock.init(getCElement(), null);
} else {
fIncludesSymbolsBlock.initializeTimeStamps();
}
}
} else {
if (!fIncludesSymbolsBlock.hasChangesInDialog() && fIncludesSymbolsBlock.hasChangesInCPathFile()) {
fIncludesSymbolsBlock.init(getCElement(), null);
}
}
}
super.setVisible(visible);
}
private IProject getProject() {
IAdaptable adaptable = getElement();
if (adaptable != null) {
ICElement elem = (ICElement) adaptable.getAdapter(ICElement.class);
return elem.getCProject().getProject();
}
return null;
}
private ICElement getCElement() {
IAdaptable adaptable = getElement();
if (adaptable != null) {
ICElement elem = (ICElement) adaptable.getAdapter(ICElement.class);
return elem;
}
return null;
}
private boolean isCProject(IProject proj) {
try {
return proj.hasNature(CProjectNature.C_NATURE_ID);
} catch (CoreException e) {
CUIPlugin.getDefault().log(e);
}
return false;
}
/*
* @see IPreferencePage#performOk
*/
public boolean performOk() {
if (fIncludesSymbolsBlock != null) {
getSettings().put(INDEX, fIncludesSymbolsBlock.getPageIndex());
Shell shell = getControl().getShell();
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
fIncludesSymbolsBlock.configureCProject(monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
};
IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
try {
new ProgressMonitorDialog(shell).run(true, true, op);
} catch (InvocationTargetException e) {
String title = CPathEntryMessages.getString("CPathsPropertyPage.error.title"); //$NON-NLS-1$
String message = CPathEntryMessages.getString("CPathsPropertyPage.error.message"); //$NON-NLS-1$
ExceptionHandler.handle(e, shell, title, message);
return false;
} catch (InterruptedException e) {
// cancelled
return false;
}
}
return true;
}
/*
* (non-Javadoc)
*
* @see IStatusChangeListener#statusChanged
*/
public void statusChanged(IStatus status) {
setValid(!status.matches(IStatus.ERROR));
StatusUtil.applyToStatusLine(this, status);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferencePage#performCancel()
*/
public boolean performCancel() {
if (fIncludesSymbolsBlock != null) {
getSettings().put(INDEX, fIncludesSymbolsBlock.getPageIndex());
}
return super.performCancel();
}
}

View file

@ -0,0 +1,124 @@
/*******************************************************************************
* 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
******************************************************************************/
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.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
public class IncludesSymbolsTabBlock extends AbstractPathOptionBlock {
private CPathIncludeEntryPage fIncludePage;
private CPathSymbolEntryPage fSymbolsPage;
private SourceTreeAdapter fSourceTreeAdapter;
private class SourceTreeAdapter implements ITreeListAdapter {
public void customButtonPressed(TreeListDialogField field, int index) {
}
public void selectionChanged(TreeListDialogField field) {
}
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) {
children.addAll(((ICContainer) element).getChildrenOfType(ICElement.C_CCONTAINER));
children.addAll(((ICContainer) element).getChildrenOfType(ICElement.C_UNIT));
}
return children.toArray();
}
public Object getParent(TreeListDialogField field, Object element) {
return ((ICElement) element).getParent();
}
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());
fSymbolsPage.init(getCProject());
}
Dialog.applyDialogFont(control);
return control;
}
protected List getCPaths() {
return new ArrayList();
}
public void init(ICElement cElement, IPathEntry[] cpathEntries) {
setCProject(cElement.getCProject());
boolean projectExists = false;
List newClassPath = null;
IProject project = getProject();
if (cpathEntries == null) {
try {
cpathEntries = getCProject().getRawPathEntries();
} catch (CModelException e) {
}
}
if (cpathEntries != null) {
newClassPath = getExistingEntries(cpathEntries);
}
if (fIncludePage != null) {
fIncludePage.init(getCProject());
fSymbolsPage.init(getCProject());
}
doStatusLineUpdate();
initializeTimeStamps();
}
protected void internalConfigureCProject(List cPathEntries, IProgressMonitor monitor) throws CoreException,
InterruptedException {
}
}

View file

@ -56,7 +56,7 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.util.ExceptionHandler; import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
import org.eclipse.cdt.internal.ui.util.EditorUtility; import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener; import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
/** /**
*/ */

View file

@ -32,12 +32,12 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.util.PixelConverter; import org.eclipse.cdt.internal.ui.util.PixelConverter;
import org.eclipse.cdt.internal.ui.util.SWTUtil; import org.eclipse.cdt.internal.ui.util.SWTUtil;
import org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; 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.IDialogFieldListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter; import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; 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.ListDialogField;
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
/** /**
*/ */

View file

@ -25,7 +25,7 @@ import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener; import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
/* /*
* The page to configure the compiler options. * The page to configure the compiler options.

View file

@ -36,7 +36,7 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener; import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; 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.IDialogFieldListener;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;

View file

@ -1,23 +0,0 @@
/*******************************************************************************
* 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
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.wizards;
import org.eclipse.core.runtime.IStatus;
public interface IStatusChangeListener {
/**
* Notifies this listener that the given status has changed.
*
* @param status the new status
*/
void statusChanged(IStatus status);
}