mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
small ui fix fo button enablement, show of export label and export handling
This commit is contained in:
parent
00c80d0e7e
commit
e789040647
7 changed files with 44 additions and 57 deletions
|
@ -11,10 +11,7 @@ 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;
|
||||
|
||||
|
@ -24,9 +21,9 @@ import org.eclipse.jface.viewers.ViewerFilter;
|
|||
*/
|
||||
public class CPElementFilter extends ViewerFilter {
|
||||
|
||||
private List fExcludes;
|
||||
private int fKind;
|
||||
private boolean fExportedOnly;
|
||||
protected List fExcludes;
|
||||
protected int fKind;
|
||||
protected boolean fExportedOnly;
|
||||
|
||||
/**
|
||||
* @param excludedFiles
|
||||
|
@ -34,7 +31,7 @@ public class CPElementFilter extends ViewerFilter {
|
|||
* @param recusive
|
||||
* Folders are only shown if, searched recursivly, contain an archive
|
||||
*/
|
||||
public CPElementFilter(CPElement[] excludedElements, int kind, boolean exportedOnly) {
|
||||
public CPElementFilter(Object[] excludedElements, int kind, boolean exportedOnly) {
|
||||
if (excludedElements != null) {
|
||||
fExcludes = Arrays.asList(excludedElements);
|
||||
}
|
||||
|
@ -52,30 +49,21 @@ public class CPElementFilter extends ViewerFilter {
|
|||
public boolean select(Viewer viewer, Object parent, Object element) {
|
||||
if (element instanceof CPElement) {
|
||||
if ( ((CPElement)element).getEntryKind() == fKind) {
|
||||
if (fExcludes != null && !fExcludes.contains(element)) {
|
||||
if (fExportedOnly == true && ! ((CPElement) element).isExported()) {
|
||||
return false;
|
||||
if (fExcludes == null || !fExcludes.contains(element)) {
|
||||
if (fExportedOnly == true) {
|
||||
return ((CPElement)element).isExported();
|
||||
}
|
||||
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, CPElement.createFromExisting(entries[i], (ICProject) element))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e.getStatus());
|
||||
}
|
||||
} else if (element instanceof IPathEntry) {
|
||||
boolean bShow = ((IPathEntry) element).getEntryKind() == fKind;
|
||||
if (bShow && fExportedOnly == true) {
|
||||
if ( ((IPathEntry)element).getEntryKind() == fKind) {
|
||||
if (fExcludes == null || !fExcludes.contains(element)) {
|
||||
if (fExportedOnly == true) {
|
||||
return ((IPathEntry)element).isExported();
|
||||
}
|
||||
return bShow;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -30,10 +30,14 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
private String fNewLabel, fCreateLabel;
|
||||
private ImageDescriptor fIncludeIcon, fMacroIcon, fLibWSrcIcon, fLibIcon;
|
||||
private ImageDescriptor fFolderImage, fOutputImage, fProjectImage, fContainerImage;
|
||||
|
||||
private boolean bShowExported;
|
||||
private ImageDescriptorRegistry fRegistry;
|
||||
|
||||
public CPElementLabelProvider() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
public CPElementLabelProvider(boolean showExported) {
|
||||
fNewLabel = CPathEntryMessages.getString("CPElementLabelProvider.new"); //$NON-NLS-1$
|
||||
fCreateLabel = CPathEntryMessages.getString("CPElementLabelProvider.willbecreated"); //$NON-NLS-1$
|
||||
fRegistry = CUIPlugin.getImageDescriptorRegistry();
|
||||
|
@ -49,6 +53,7 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
IWorkbench workbench = CUIPlugin.getDefault().getWorkbench();
|
||||
|
||||
fProjectImage = workbench.getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT);
|
||||
bShowExported = showExported;
|
||||
}
|
||||
|
||||
public String getText(Object element) {
|
||||
|
@ -177,7 +182,7 @@ class CPElementLabelProvider extends LabelProvider {
|
|||
return CPathEntryMessages.getString("CPElementLabelProvider.unknown_element.label"); //$NON-NLS-1$
|
||||
}
|
||||
private void addExport(CPElement cpentry, StringBuffer str) {
|
||||
if (cpentry.isExported()) {
|
||||
if (bShowExported && cpentry.isExported()) {
|
||||
str.append(' ');
|
||||
str.append(CPathEntryMessages.getString("CPElementLabelProvider.export.label")); //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -25,6 +26,7 @@ import org.eclipse.jface.dialogs.Dialog;
|
|||
import org.eclipse.jface.viewers.CheckStateChangedEvent;
|
||||
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
||||
import org.eclipse.jface.viewers.ICheckStateListener;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
|
@ -39,7 +41,10 @@ public class CPathFilterPage extends WizardPage {
|
|||
private CheckboxTableViewer viewer;
|
||||
private IPathEntry fParentEntry;
|
||||
private List fPaths;
|
||||
private ICElement fCElement;
|
||||
private List fExclusions;
|
||||
private ViewerFilter filter;
|
||||
|
||||
protected ICElement fCElement;
|
||||
|
||||
protected CPathFilterPage(ICElement cElement, int filterType) {
|
||||
super("CPathFilterPage"); //$NON-NLS-1$
|
||||
|
@ -63,14 +68,13 @@ public class CPathFilterPage extends WizardPage {
|
|||
label.setLayoutData(gd);
|
||||
viewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
|
||||
viewer.setContentProvider(new ListContentProvider());
|
||||
viewer.setLabelProvider(new CPElementLabelProvider());
|
||||
viewer.setLabelProvider(new CPElementLabelProvider(false));
|
||||
viewer.addCheckStateListener(new ICheckStateListener() {
|
||||
|
||||
public void checkStateChanged(CheckStateChangedEvent event) {
|
||||
validatePage();
|
||||
}
|
||||
});
|
||||
viewer.addFilter(new CPElementFilter(fFilterType, true));
|
||||
gd = new GridData(GridData.FILL_BOTH);
|
||||
gd.widthHint = 400;
|
||||
gd.heightHint = 300;
|
||||
|
@ -106,6 +110,17 @@ public class CPathFilterPage extends WizardPage {
|
|||
} catch (CModelException e) {
|
||||
}
|
||||
}
|
||||
createExlusions();
|
||||
}
|
||||
|
||||
|
||||
private void createExlusions() {
|
||||
fExclusions = new ArrayList();
|
||||
if (filter != null) {
|
||||
viewer.removeFilter(filter);
|
||||
}
|
||||
filter = new CPElementFilter(fExclusions.toArray(), fFilterType, true);
|
||||
viewer.addFilter(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -98,6 +98,7 @@ public class CPathLibraryEntryPage extends CPathBasePage {
|
|||
|
||||
fLibrariesList.setViewerSorter(new CPElementSorter());
|
||||
fLibrariesList.enableButton(IDX_EDIT, false);
|
||||
fLibrariesList.enableButton(IDX_REMOVE, false);
|
||||
fLibrariesList.enableButton(IDX_EXPORT, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ public class CPathOutputEntryPage extends CPathBasePage {
|
|||
|
||||
fOutputList.setViewerSorter(new CPElementSorter());
|
||||
fOutputList.enableButton(IDX_EDIT, false);
|
||||
fOutputList.enableButton(IDX_REMOVE, false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ public class CPathSourceEntryPage extends CPathBasePage {
|
|||
|
||||
fFoldersList.setViewerSorter(new CPElementSorter());
|
||||
fFoldersList.enableButton(IDX_EDIT, false);
|
||||
fFoldersList.enableButton(IDX_REMOVE, false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,15 +8,14 @@
|
|||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
|
||||
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.IDialogFieldListener;
|
||||
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
|
@ -25,7 +24,7 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
|||
|
||||
private int[] pathTypes = { IPathEntry.CDT_SOURCE, IPathEntry.CDT_PROJECT, IPathEntry.CDT_OUTPUT, IPathEntry.CDT_LIBRARY,
|
||||
IPathEntry.CDT_CONTAINER};
|
||||
private CheckedListDialogField fCPathList;
|
||||
private ListDialogField fCPathList;
|
||||
|
||||
private CPathSourceEntryPage fSourcePage;
|
||||
private CPathProjectsEntryPage fProjectsPage;
|
||||
|
@ -59,14 +58,8 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
|||
};
|
||||
BuildPathAdapter adapter = new BuildPathAdapter();
|
||||
|
||||
fCPathList = new CheckedListDialogField(null, buttonLabels, new CPElementLabelProvider());
|
||||
fCPathList = new ListDialogField(null, buttonLabels, null);
|
||||
fCPathList.setDialogFieldListener(adapter);
|
||||
fCPathList.setLabelText(CPathEntryMessages.getString("CPathsBlock.path.label")); //$NON-NLS-1$
|
||||
fCPathList.setUpButtonIndex(0);
|
||||
fCPathList.setDownButtonIndex(1);
|
||||
fCPathList.setCheckAllButtonIndex(3);
|
||||
fCPathList.setUncheckAllButtonIndex(4);
|
||||
|
||||
}
|
||||
|
||||
protected List getCPaths() {
|
||||
|
@ -107,16 +100,7 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
|||
|
||||
protected void initialize(ICElement element, List cPaths) {
|
||||
|
||||
List exportedEntries = new ArrayList();
|
||||
for (int i = 0; i < cPaths.size(); i++) {
|
||||
CPElement curr = (CPElement) cPaths.get(i);
|
||||
if (curr.isExported() && curr.getEntryKind() != IPathEntry.CDT_SOURCE) {
|
||||
exportedEntries.add(curr);
|
||||
}
|
||||
}
|
||||
|
||||
fCPathList.setElements(cPaths);
|
||||
fCPathList.setCheckedElements(exportedEntries);
|
||||
|
||||
if (fProjectsPage != null) {
|
||||
fSourcePage.init(getCProject());
|
||||
|
@ -149,14 +133,6 @@ public class CPathTabBlock extends AbstractPathOptionBlock {
|
|||
|
||||
for (int i = elements.size() - 1; i >= 0; i--) {
|
||||
CPElement currElement = (CPElement) elements.get(i);
|
||||
boolean isChecked = fCPathList.isChecked(currElement);
|
||||
if (currElement.getEntryKind() == IPathEntry.CDT_SOURCE) {
|
||||
if (isChecked) {
|
||||
fCPathList.setCheckedWithoutUpdate(currElement, false);
|
||||
}
|
||||
} else {
|
||||
currElement.setExported(isChecked);
|
||||
}
|
||||
|
||||
entries[i] = currElement.getPathEntry();
|
||||
if (currElement.isMissing()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue