mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 19:35:36 +02:00
fixed up labels
This commit is contained in:
parent
0d7e22298e
commit
948279d055
3 changed files with 254 additions and 139 deletions
|
@ -9,6 +9,7 @@
|
|||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -85,6 +86,10 @@ public class CPElementGroup {
|
|||
}
|
||||
}
|
||||
|
||||
public void setChildren(CPElement[] elements) {
|
||||
children = new ArrayList(Arrays.asList(elements));
|
||||
}
|
||||
|
||||
public void addChildren(CPElement[] elements) {
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
addChild(elements[i]);
|
||||
|
|
|
@ -71,13 +71,16 @@ IncludeSymbolEntryPage.addSymbol.message=Symbol definition:
|
|||
IncludeSymbolEntryPage.addExternal.button.browse=Browse...
|
||||
IncludeSymbolEntryPage.addExternal.title=Add External Include Path
|
||||
IncludeSymbolEntryPage.addExternal.message=Include path:
|
||||
IncludeSymbolEntryPage.editExternal.title=Edit External Include Path
|
||||
IncludeSymbolEntryPage.editExternal.message=Include path:
|
||||
IncludeSymbolEntryPage.ContainerDialog.new.title=Contributed Include Path Selection
|
||||
IncludeSymbolEntryPage.ContainerDialog.edit.title=Contributed Include Path Selection
|
||||
IncludeSymbolEntryPage.fromWorkspaceDialog.new.title=New Include Path from Workspace
|
||||
IncludeSymbolEntryPage.fromWorkspaceDialog.new.description=Select a folder as a include path from the workspace.
|
||||
IncludeSymbolEntryPage.fromWorkspaceDialog.edit.title=Edit Include Path from Workspace
|
||||
IncludeSymbolEntryPage.fromWorkspaceDialog.edit.description=Select a folder as a include path from the workspace.
|
||||
|
||||
IncludeSymbolEntryPage.newResource.title=Add File/Folder
|
||||
IncludeSymbolEntryPage.newResource.description=Select a file or folder to add to the include/symbol list to add/remove paths or symbols on.
|
||||
# -------- SymbolsEntryPage ---------
|
||||
SymbolEntryPage.title=Symbols
|
||||
SymbolEntryPage.addUser=Add User Defined...
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
package org.eclipse.cdt.internal.ui.dialogs.cpaths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
|
@ -156,8 +158,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
super(CPathEntryMessages.getString("IncludeSymbolEntryPage.title")); //$NON-NLS-1$
|
||||
fCPathList = cPathList;
|
||||
IncludeSymbolAdapter adapter = new IncludeSymbolAdapter();
|
||||
fIncludeSymPathsList = new TreeListDialogField(adapter, buttonLabel, new CPElementLabelProvider(true,
|
||||
true)) {
|
||||
fIncludeSymPathsList = new TreeListDialogField(adapter, buttonLabel, new CPElementLabelProvider(true, true)) {
|
||||
|
||||
protected int getTreeStyle() {
|
||||
return super.getTreeStyle() & ~SWT.MULTI;
|
||||
|
@ -179,7 +180,8 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
fShowInheritedPaths.setLabelText(CPathEntryMessages.getString("IncludeSymbolsEntryPage.show_inherited.check")); //$NON-NLS-1$
|
||||
fShowInheritedPaths.setDialogFieldListener(adapter);
|
||||
|
||||
fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER}, false, true);
|
||||
fFilter = new CPElementFilter(new int[] { -1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER},
|
||||
false, true);
|
||||
}
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
|
@ -310,7 +312,15 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected boolean canRemove(List selected) {
|
||||
private boolean canAddPath(List selected) {
|
||||
CPElementGroup group = getSelectedGroup();
|
||||
if (group != null) {
|
||||
return group.getEntryKind() == -1; // resource group
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canRemove(List selected) {
|
||||
if (selected.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
@ -331,7 +341,28 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected boolean canEdit(List selected) {
|
||||
private void removeEntry() {
|
||||
List selected = getSelection();
|
||||
Object elem = selected.get(0);
|
||||
if (elem instanceof CPElement) {
|
||||
CPElement removed = removePathFromResourceGroups((CPElement) elem, fIncludeSymPathsList.getElements());
|
||||
if (removed != null) {
|
||||
fCPathList.removeElement(removed);
|
||||
}
|
||||
fCPathList.dialogFieldChanged(); // validate
|
||||
fIncludeSymPathsList.refresh();
|
||||
} else if (elem instanceof CPElementAttribute) {
|
||||
CPElementAttribute attrib = (CPElementAttribute) elem;
|
||||
String key = attrib.getKey();
|
||||
Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
|
||||
attrib.getParent().setAttribute(key, value);
|
||||
updatePathOnResourceGroups(attrib.getParent(), fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean canEdit(List selected) {
|
||||
if (selected.size() != 1) {
|
||||
return false;
|
||||
}
|
||||
|
@ -348,13 +379,120 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
return false;
|
||||
}
|
||||
|
||||
private void editEntry() {
|
||||
List selElements = fIncludeSymPathsList.getSelectedElements();
|
||||
if (selElements.size() != 1) {
|
||||
return;
|
||||
}
|
||||
Object element = selElements.get(0);
|
||||
|
||||
if (element instanceof CPElement) {
|
||||
|
||||
} else if (element instanceof CPElementAttribute) {
|
||||
editAttributeEntry((CPElementAttribute) element);
|
||||
}
|
||||
}
|
||||
|
||||
private void editAttributeEntry(CPElementAttribute elem) {
|
||||
String key = elem.getKey();
|
||||
if (key.equals(CPElement.EXCLUSION)) {
|
||||
CPElement selElement = elem.getParent();
|
||||
ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
|
||||
if (dialog.open() == Window.OK) {
|
||||
selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
|
||||
fCPathList.dialogFieldChanged(); // validate
|
||||
updatePathOnResourceGroups(selElement, fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void exportEntry() {
|
||||
|
||||
}
|
||||
|
||||
private boolean canExport(List selectedElements) {
|
||||
// dinglis-TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canMoveUp(List element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canMoveDown(List element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean moveUp() {
|
||||
boolean rc = false;
|
||||
List selElements = fIncludeSymPathsList.getSelectedElements();
|
||||
for (Iterator i = selElements.iterator(); i.hasNext();) {
|
||||
CPElement elem = (CPElement) i.next();
|
||||
CPElementGroup parent = elem.getParent();
|
||||
CPElement[] children = parent.getChildren();
|
||||
for (int j = 0; j < children.length; ++j) {
|
||||
CPElement child = children[j];
|
||||
if (elem.equals(child)) {
|
||||
int prevIndex = j - 1;
|
||||
if (prevIndex >= 0) {
|
||||
// swap the two
|
||||
children[j] = children[prevIndex];
|
||||
children[prevIndex] = elem;
|
||||
rc = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
parent.setChildren(children);
|
||||
}
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.postSetSelection(new StructuredSelection(selElements));
|
||||
fIncludeSymPathsList.setFocus();
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private boolean moveDown() {
|
||||
boolean rc = false;
|
||||
List selElements = fIncludeSymPathsList.getSelectedElements();
|
||||
List revSelElements = new ArrayList(selElements);
|
||||
Collections.reverse(revSelElements);
|
||||
for (Iterator i = revSelElements.iterator(); i.hasNext();) {
|
||||
CPElement elem = (CPElement) i.next();
|
||||
CPElementGroup parent = elem.getParent();
|
||||
CPElement[] children = parent.getChildren();
|
||||
for (int j = children.length - 1; j >= 0; --j) {
|
||||
CPElement child = children[j];
|
||||
if (elem.equals(child)) {
|
||||
int prevIndex = j + 1;
|
||||
if (prevIndex < children.length) {
|
||||
// swap the two
|
||||
children[j] = children[prevIndex];
|
||||
children[prevIndex] = elem;
|
||||
rc = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
parent.setChildren(children);
|
||||
}
|
||||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.postSetSelection(new StructuredSelection(selElements));
|
||||
fIncludeSymPathsList.setFocus();
|
||||
return rc;
|
||||
}
|
||||
|
||||
protected void ListPageDialogFieldChanged(DialogField field) {
|
||||
if (field == fShowInheritedPaths) {
|
||||
boolean showInherited = fShowInheritedPaths.isSelected();
|
||||
if (fFilter != null) {
|
||||
fIncludeSymPathsList.getTreeViewer().removeFilter(fFilter);
|
||||
}
|
||||
fFilter = new CPElementFilter(new int[]{-1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER}, false, showInherited);
|
||||
fFilter = new CPElementFilter(new int[] { -1, IPathEntry.CDT_INCLUDE, IPathEntry.CDT_MACRO, IPathEntry.CDT_CONTAINER},
|
||||
false, showInherited);
|
||||
fIncludeSymPathsList.getTreeViewer().addFilter(fFilter);
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
|
@ -370,17 +508,6 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
field.enableButton(IDX_ADD_SYMBOL, canAddPath(selected));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param selected
|
||||
* @return
|
||||
*/
|
||||
private boolean canAddPath(List selected) {
|
||||
CPElementGroup group = getSelectedGroup();
|
||||
if (group != null) {
|
||||
return group.getEntryKind() == -1; // resource group
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private CPElementGroup getSelectedGroup() {
|
||||
List selected = fIncludeSymPathsList.getSelectedElements();
|
||||
|
@ -402,10 +529,10 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
addNewPathResource();
|
||||
break;
|
||||
case IDX_ADD_SYMBOL:
|
||||
addSymbol();
|
||||
addSymbol(null);
|
||||
break;
|
||||
case IDX_ADD_EXT_INCLUDE:
|
||||
addInclude();
|
||||
addInclude(null);
|
||||
break;
|
||||
case IDX_ADD_WS_INCLUDE:
|
||||
addFromWorkspace();
|
||||
|
@ -422,6 +549,22 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
if (canRemove(field.getSelectedElements())) {
|
||||
removeEntry();
|
||||
}
|
||||
break;
|
||||
case IDX_DOWN:
|
||||
if (canMoveDown(field.getSelectedElements())) {
|
||||
moveDown();
|
||||
}
|
||||
break;
|
||||
case IDX_UP:
|
||||
if (canMoveUp(field.getSelectedElements())) {
|
||||
moveUp();
|
||||
}
|
||||
break;
|
||||
case IDX_EXPORT:
|
||||
if (canExport(field.getSelectedElements())) {
|
||||
exportEntry();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,54 +613,6 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
}
|
||||
}
|
||||
|
||||
private void editEntry() {
|
||||
List selElements = fIncludeSymPathsList.getSelectedElements();
|
||||
if (selElements.size() != 1) {
|
||||
return;
|
||||
}
|
||||
Object element = selElements.get(0);
|
||||
|
||||
if (element instanceof CPElement) {
|
||||
} else if (element instanceof CPElementAttribute) {
|
||||
editAttributeEntry((CPElementAttribute)element);
|
||||
}
|
||||
}
|
||||
|
||||
private void editAttributeEntry(CPElementAttribute elem) {
|
||||
String key = elem.getKey();
|
||||
if (key.equals(CPElement.EXCLUSION)) {
|
||||
CPElement selElement = elem.getParent();
|
||||
ExclusionPatternDialog dialog = new ExclusionPatternDialog(getShell(), selElement);
|
||||
if (dialog.open() == Window.OK) {
|
||||
selElement.setAttribute(CPElement.EXCLUSION, dialog.getExclusionPattern());
|
||||
fCPathList.dialogFieldChanged(); // validate
|
||||
updatePathOnResourceGroups(selElement, fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeEntry() {
|
||||
List selected = getSelection();
|
||||
Object elem = selected.get(0);
|
||||
if (elem instanceof CPElement) {
|
||||
CPElement removed = removePathFromResourceGroups((CPElement)elem, fIncludeSymPathsList.getElements());
|
||||
if (removed != null) {
|
||||
fCPathList.removeElement(removed);
|
||||
}
|
||||
fCPathList.dialogFieldChanged(); // validate
|
||||
fIncludeSymPathsList.refresh();
|
||||
} else if (elem instanceof CPElementAttribute) {
|
||||
CPElementAttribute attrib = (CPElementAttribute)elem;
|
||||
String key = attrib.getKey();
|
||||
Object value = key.equals(CPElement.EXCLUSION) ? new Path[0] : null;
|
||||
attrib.getParent().setAttribute(key, value);
|
||||
updatePathOnResourceGroups(attrib.getParent(), fIncludeSymPathsList.getElements());
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void ListPageDoubleClicked(TreeListDialogField field) {
|
||||
if (canEdit(fIncludeSymPathsList.getSelectedElements())) {
|
||||
editEntry();
|
||||
|
@ -544,7 +639,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
return currEntries;
|
||||
}
|
||||
|
||||
protected void addSymbol() {
|
||||
protected void addSymbol(CPElement existing) {
|
||||
// Popup an entry dialog
|
||||
InputDialog dialog = new InputDialog(getShell(), CPathEntryMessages.getString("IncludeSymbolEntryPage.addSymbol.title"), //$NON-NLS-1$
|
||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.addSymbol.message"), "", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -578,14 +673,23 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
}
|
||||
}
|
||||
|
||||
protected void addInclude() {
|
||||
InputDialog dialog = new SelectPathInputDialog(getShell(),
|
||||
protected void addInclude(CPElement existing) {
|
||||
InputDialog dialog;
|
||||
if (existing == null) {
|
||||
dialog = new SelectPathInputDialog(getShell(),
|
||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.addExternal.title"), //$NON-NLS-1$
|
||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.addExternal.message"), null, null); //$NON-NLS-1$
|
||||
} else {
|
||||
dialog = new SelectPathInputDialog(
|
||||
getShell(),
|
||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.editExternal.title"), //$NON-NLS-1$
|
||||
CPathEntryMessages.getString("IncludeSymbolEntryPage.editExternal.message"), ((IPath) existing.getAttribute(CPElement.INCLUDE)).toOSString(), null); //$NON-NLS-1$
|
||||
}
|
||||
String newItem = null;
|
||||
if (dialog.open() == Window.OK) {
|
||||
newItem = dialog.getValue();
|
||||
if (newItem != null && !newItem.equals("")) { //$NON-NLS-1$
|
||||
if (existing == null) {
|
||||
List cplist = fCPathList.getElements();
|
||||
CPElementGroup group = getSelectedGroup();
|
||||
CPElement newPath = new CPElement(fCurrCProject, IPathEntry.CDT_INCLUDE, group.getResource().getFullPath(),
|
||||
|
@ -597,6 +701,10 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
fIncludeSymPathsList.refresh();
|
||||
fIncludeSymPathsList.expandElement(getSelectedGroup(), 1);
|
||||
}
|
||||
} else {
|
||||
existing.setAttribute(CPElement.INCLUDE, new Path(newItem));
|
||||
fIncludeSymPathsList.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -627,8 +735,7 @@ public class CPathIncludeSymbolEntryPage extends CPathBasePage {
|
|||
|
||||
String title = (existing == null) ? CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.new.title") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.edit.title"); //$NON-NLS-1$
|
||||
String message = (existing == null)
|
||||
? CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.new.description") //$NON-NLS-1$
|
||||
String message = (existing == null) ? CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.new.description") //$NON-NLS-1$
|
||||
: CPathEntryMessages.getString("IncludeSymbolEntryPage.fromWorkspaceDialog.edit.description"); //$NON-NLS-1$
|
||||
|
||||
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
|
||||
|
|
Loading…
Add table
Reference in a new issue