mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
cpath ui update
This commit is contained in:
parent
2a0432dada
commit
fe6b0c576b
3 changed files with 74 additions and 39 deletions
|
@ -126,7 +126,7 @@ public class CPathContainerWizard extends Wizard {
|
||||||
addPage(fContainerPage);
|
addPage(fContainerPage);
|
||||||
}
|
}
|
||||||
if (fFilterType != -1) {
|
if (fFilterType != -1) {
|
||||||
fFilterPage = new CPathFilterPage(fFilterType);
|
fFilterPage = new CPathFilterPage(fCurrProject, fFilterType);
|
||||||
}
|
}
|
||||||
super.addPages();
|
super.addPages();
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,9 @@ public class CPathContainerWizard extends Wizard {
|
||||||
fContainerPage = getContainerPage(selected);
|
fContainerPage = getContainerPage(selected);
|
||||||
return fContainerPage;
|
return fContainerPage;
|
||||||
} else if (page == fContainerPage) {
|
} else if (page == fContainerPage) {
|
||||||
fFilterPage.setEntries(fContainerPage.getContainerEntries()[0]);
|
if ( fContainerPage.getContainerEntries().length > 0 ) {
|
||||||
|
fFilterPage.setParentEntry(fContainerPage.getContainerEntries()[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.getNextPage(page);
|
return super.getNextPage(page);
|
||||||
}
|
}
|
||||||
|
@ -193,13 +195,14 @@ public class CPathContainerWizard extends Wizard {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
boolean canFinish = false;
|
||||||
if (fContainerPage != null) {
|
if (fContainerPage != null) {
|
||||||
return fContainerPage.isPageComplete();
|
canFinish = fContainerPage.isPageComplete();
|
||||||
}
|
}
|
||||||
if (fFilterPage != null) {
|
if (canFinish == true && fFilterPage != null) {
|
||||||
return fFilterPage.isPageComplete();
|
canFinish = fFilterPage.isPageComplete();
|
||||||
}
|
}
|
||||||
return false;
|
return canFinish;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int openWizard(Shell shell, CPathContainerWizard wizard) {
|
public static int openWizard(Shell shell, CPathContainerWizard wizard) {
|
||||||
|
|
|
@ -8,10 +8,17 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
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.core.model.IPathEntryContainer;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||||
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
||||||
|
@ -31,12 +38,14 @@ public class CPathFilterPage extends WizardPage {
|
||||||
private final int fFilterType;
|
private final int fFilterType;
|
||||||
|
|
||||||
private CheckboxTableViewer viewer;
|
private CheckboxTableViewer viewer;
|
||||||
private IPathEntry fContainerPath;
|
private IPathEntry fParentEntry;
|
||||||
private List fPaths;
|
private List fPaths;
|
||||||
|
private ICProject fCProject;
|
||||||
|
|
||||||
protected CPathFilterPage(int filterType) {
|
protected CPathFilterPage(ICProject cProject, int filterType) {
|
||||||
super("CPathFilterPage"); //$NON-NLS-1$
|
super("CPathFilterPage"); //$NON-NLS-1$
|
||||||
fFilterType = filterType;
|
fFilterType = filterType;
|
||||||
|
fCProject = cProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,8 +94,24 @@ public class CPathFilterPage extends WizardPage {
|
||||||
protected void handleSelectionChanged(IStructuredSelection selection) {
|
protected void handleSelectionChanged(IStructuredSelection selection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEntries(IPathEntry entry) {
|
public void setParentEntry(IPathEntry entry) {
|
||||||
fContainerPath = entry;
|
fParentEntry = entry;
|
||||||
|
if (fParentEntry.getEntryKind() == IPathEntry.CDT_PROJECT) {
|
||||||
|
IProject project = CUIPlugin.getWorkspace().getRoot().getProject(fParentEntry.getPath().segment(0));
|
||||||
|
if (project.isAccessible()) {
|
||||||
|
ICProject cProject = CoreModel.getDefault().create(project);
|
||||||
|
try {
|
||||||
|
fPaths = Arrays.asList(cProject.getRawPathEntries());
|
||||||
|
} catch (CModelException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (fParentEntry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
|
||||||
|
try {
|
||||||
|
IPathEntryContainer container = CoreModel.getPathEntryContainer(fParentEntry.getPath(), fCProject);
|
||||||
|
fPaths = Arrays.asList(container.getPathEntries());
|
||||||
|
} catch (CModelException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPathEntry[] getSelectedEntries() {
|
public IPathEntry[] getSelectedEntries() {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
/*
|
/***********************************************************************************************************************************
|
||||||
* Created on Apr 27, 2004
|
* Created on Apr 27, 2004
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
|
* Copyright (c) 2002,2003 QNX Software Systems Ltd.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors: QNX Software Systems - Initial API and implementation
|
||||||
* 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.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -20,9 +19,9 @@ import org.eclipse.cdt.ui.wizards.ICPathContainerPage;
|
||||||
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||||
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
||||||
import org.eclipse.jface.viewers.ICheckStateListener;
|
import org.eclipse.jface.viewers.ICheckStateListener;
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
import org.eclipse.jface.viewers.ViewerFilter;
|
||||||
import org.eclipse.jface.wizard.WizardPage;
|
import org.eclipse.jface.wizard.WizardPage;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
@ -31,11 +30,11 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.ui.model.WorkbenchContentProvider;
|
import org.eclipse.ui.model.WorkbenchContentProvider;
|
||||||
|
|
||||||
|
|
||||||
public class ProjectContainerPage extends WizardPage implements ICPathContainerPage {
|
public class ProjectContainerPage extends WizardPage implements ICPathContainerPage {
|
||||||
|
|
||||||
private int fFilterType;
|
private int fFilterType;
|
||||||
private CheckboxTableViewer viewer;
|
private CheckboxTableViewer viewer;
|
||||||
|
private ICProject fCProject;
|
||||||
|
|
||||||
private class WorkbenchCPathContentProvider extends WorkbenchContentProvider {
|
private class WorkbenchCPathContentProvider extends WorkbenchContentProvider {
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ public class ProjectContainerPage extends WizardPage implements ICPathContainerP
|
||||||
IPathEntry[] entries = ((ICProject) element).getRawPathEntries();
|
IPathEntry[] entries = ((ICProject) element).getRawPathEntries();
|
||||||
List list = new ArrayList(entries.length);
|
List list = new ArrayList(entries.length);
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
if (entries[i].isExported()) {
|
if (fFilterType == entries[i].getEntryKind() && entries[i].isExported()) {
|
||||||
list.add(CPElement.createFromExisting(entries[i], (ICProject) element));
|
list.add(CPElement.createFromExisting(entries[i], (ICProject) element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +62,7 @@ public class ProjectContainerPage extends WizardPage implements ICPathContainerP
|
||||||
try {
|
try {
|
||||||
IPathEntry[] entries = ((ICProject) element).getRawPathEntries();
|
IPathEntry[] entries = ((ICProject) element).getRawPathEntries();
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
if (entries[i].isExported()) {
|
if (fFilterType == entries[i].getEntryKind() && entries[i].isExported()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,20 +88,25 @@ public class ProjectContainerPage extends WizardPage implements ICPathContainerP
|
||||||
setDescription(CPathEntryMessages.getString("ProjectContainerPage.description")); //$NON-NLS-1$
|
setDescription(CPathEntryMessages.getString("ProjectContainerPage.description")); //$NON-NLS-1$
|
||||||
setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
|
setImageDescriptor(CPluginImages.DESC_WIZBAN_ADD_LIBRARY);
|
||||||
fFilterType = filterType;
|
fFilterType = filterType;
|
||||||
|
validatePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(ICProject project, IPathEntry[] currentEntries) {
|
public void initialize(ICProject project, IPathEntry[] currentEntries) {
|
||||||
|
fCProject = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean finish() {
|
public boolean finish() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPathEntry[] getContainerEntries() {
|
public IPathEntry[] getContainerEntries() {
|
||||||
return new IPathEntry[0];
|
return /*viewer != null ? (IPathEntry[]) viewer.getCheckedElements(): */new IPathEntry[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection(IPathEntry containerEntry) {
|
public void setSelection(IPathEntry containerEntry) {
|
||||||
|
if (containerEntry != null) {
|
||||||
|
viewer.setSelection(new StructuredSelection(containerEntry));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
|
@ -116,34 +120,37 @@ public class ProjectContainerPage extends WizardPage implements ICPathContainerP
|
||||||
GridData gd = new GridData();
|
GridData gd = new GridData();
|
||||||
gd.horizontalSpan = 2;
|
gd.horizontalSpan = 2;
|
||||||
label.setLayoutData(gd);
|
label.setLayoutData(gd);
|
||||||
viewer =
|
viewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||||
CheckboxTableViewer.newCheckList(
|
|
||||||
container,
|
|
||||||
SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
|
|
||||||
viewer.setContentProvider(new WorkbenchCPathContentProvider());
|
viewer.setContentProvider(new WorkbenchCPathContentProvider());
|
||||||
viewer.setLabelProvider(new CPElementLabelProvider());
|
viewer.setLabelProvider(new CPElementLabelProvider());
|
||||||
viewer.addCheckStateListener(new ICheckStateListener() {
|
viewer.addCheckStateListener(new ICheckStateListener() {
|
||||||
|
|
||||||
public void checkStateChanged(CheckStateChangedEvent event) {
|
public void checkStateChanged(CheckStateChangedEvent event) {
|
||||||
// Prevent user to change checkbox states
|
validatePage();
|
||||||
viewer.setChecked(event.getElement(), !event.getChecked());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
|
||||||
public void selectionChanged(SelectionChangedEvent e) {
|
|
||||||
handleSelectionChanged((IStructuredSelection) e.getSelection());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
gd = new GridData(GridData.FILL_BOTH);
|
gd = new GridData(GridData.FILL_BOTH);
|
||||||
gd.widthHint = 400;
|
gd.widthHint = 400;
|
||||||
gd.heightHint = 300;
|
gd.heightHint = 300;
|
||||||
viewer.getTable().setLayoutData(gd);
|
viewer.getTable().setLayoutData(gd);
|
||||||
|
viewer.addFilter(new ViewerFilter() {
|
||||||
|
|
||||||
|
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
setControl(container);
|
setControl(container);
|
||||||
|
validatePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleSelectionChanged(IStructuredSelection selection) {
|
/**
|
||||||
// dinglis-TODO Auto-generated method stub
|
* Method validatePage.
|
||||||
|
*/
|
||||||
|
private void validatePage() {
|
||||||
|
setPageComplete(getSelected() != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IPathEntry getSelected() {
|
||||||
|
return getContainerEntries().length > 0 ? getContainerEntries()[0] : null;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue