mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
2005-03-12 Alain Magloire
Plan item 79518: for PathEntry variable manager. Enable. * src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java * puglin.xml
This commit is contained in:
parent
a939d75b5d
commit
4be89c40a4
3 changed files with 24 additions and 20 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2005-03-12 Alain Magloire
|
||||||
|
Plan item 79518: for PathEntry variable manager. Enable.
|
||||||
|
* src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java
|
||||||
|
* puglin.xml
|
||||||
|
|
||||||
2005-03-07 Alain Magloire
|
2005-03-07 Alain Magloire
|
||||||
Part of plan item 79518: for PathEntry variable manager.
|
Part of plan item 79518: for PathEntry variable manager.
|
||||||
Not enable.
|
Not enable.
|
||||||
|
|
|
@ -627,12 +627,12 @@
|
||||||
class="org.eclipse.cdt.internal.ui.preferences.AppearancePreferencePage"
|
class="org.eclipse.cdt.internal.ui.preferences.AppearancePreferencePage"
|
||||||
id="org.eclipse.cdt.ui.preferences.AppearancePreferencePage">
|
id="org.eclipse.cdt.ui.preferences.AppearancePreferencePage">
|
||||||
</page>
|
</page>
|
||||||
<!--page
|
<page
|
||||||
name="%pathEntryVariablesPrefName"
|
name="%pathEntryVariablesPrefName"
|
||||||
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
|
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
|
||||||
class="org.eclipse.cdt.internal.ui.preferences.PathEntryVariablePreferencePage"
|
class="org.eclipse.cdt.internal.ui.preferences.PathEntryVariablePreferencePage"
|
||||||
id="org.eclipse.cdt.ui.preferences.PathEntryVariablePreferencePage">
|
id="org.eclipse.cdt.ui.preferences.PathEntryVariablePreferencePage">
|
||||||
</page-->
|
</page>
|
||||||
<!--page
|
<!--page
|
||||||
name="%WorkInProgress.name"
|
name="%WorkInProgress.name"
|
||||||
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
|
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
|
||||||
|
|
|
@ -25,6 +25,8 @@ import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
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.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
|
@ -59,7 +61,7 @@ public class PathEntryVariablesGroup {
|
||||||
public static class PathEntryVariableElement {
|
public static class PathEntryVariableElement {
|
||||||
public String name;
|
public String name;
|
||||||
|
|
||||||
public String value;
|
public IPath path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sizing constants
|
// sizing constants
|
||||||
|
@ -159,7 +161,7 @@ public class PathEntryVariablesGroup {
|
||||||
// otherwise, adds the new variable (or updates an existing one) in the
|
// otherwise, adds the new variable (or updates an existing one) in the
|
||||||
// temporary collection of currently defined variables
|
// temporary collection of currently defined variables
|
||||||
String newVariableName = dialog.getVariableName();
|
String newVariableName = dialog.getVariableName();
|
||||||
String newVariableValue = dialog.getVariableValue();
|
IPath newVariableValue = new Path(dialog.getVariableValue());
|
||||||
tempPathVariables.put(newVariableName, newVariableValue);
|
tempPathVariables.put(newVariableName, newVariableValue);
|
||||||
|
|
||||||
// the UI must be updated
|
// the UI must be updated
|
||||||
|
@ -250,13 +252,13 @@ public class PathEntryVariablesGroup {
|
||||||
TableItem item = variableTable.getItem(variableTable
|
TableItem item = variableTable.getItem(variableTable
|
||||||
.getSelectionIndex());
|
.getSelectionIndex());
|
||||||
String variableName = (String) item.getData();
|
String variableName = (String) item.getData();
|
||||||
String variableValue = (String) tempPathVariables.get(variableName);
|
IPath variableValue = (IPath) tempPathVariables.get(variableName);
|
||||||
|
|
||||||
// constructs a dialog for editing the variable's current name and value
|
// constructs a dialog for editing the variable's current name and value
|
||||||
PathEntryVariableDialog dialog = new PathEntryVariableDialog(shell,
|
PathEntryVariableDialog dialog = new PathEntryVariableDialog(shell,
|
||||||
PathEntryVariableDialog.EXISTING_VARIABLE, variableType, tempPathVariables.keySet());
|
PathEntryVariableDialog.EXISTING_VARIABLE, variableType, tempPathVariables.keySet());
|
||||||
dialog.setVariableName(variableName);
|
dialog.setVariableName(variableName);
|
||||||
dialog.setVariableValue(variableValue);
|
dialog.setVariableValue(variableValue.toOSString());
|
||||||
|
|
||||||
// opens the dialog - just returns if the user cancels it
|
// opens the dialog - just returns if the user cancels it
|
||||||
if (dialog.open() == Window.CANCEL)
|
if (dialog.open() == Window.CANCEL)
|
||||||
|
@ -267,7 +269,7 @@ public class PathEntryVariablesGroup {
|
||||||
tempPathVariables.remove(variableName);
|
tempPathVariables.remove(variableName);
|
||||||
|
|
||||||
String newVariableName = dialog.getVariableName();
|
String newVariableName = dialog.getVariableName();
|
||||||
String newVariableValue = dialog.getVariableValue();
|
IPath newVariableValue = new Path(dialog.getVariableValue());
|
||||||
|
|
||||||
// and add it again (maybe with a different name)
|
// and add it again (maybe with a different name)
|
||||||
tempPathVariables.put(newVariableName, newVariableValue);
|
tempPathVariables.put(newVariableName, newVariableValue);
|
||||||
|
@ -310,7 +312,7 @@ public class PathEntryVariablesGroup {
|
||||||
String name = (String) items[i].getData();
|
String name = (String) items[i].getData();
|
||||||
selection[i] = new PathEntryVariableElement();
|
selection[i] = new PathEntryVariableElement();
|
||||||
selection[i].name = name;
|
selection[i].name = name;
|
||||||
selection[i].value = (String)tempPathVariables.get(name);
|
selection[i].path = (IPath)tempPathVariables.get(name);
|
||||||
}
|
}
|
||||||
return selection;
|
return selection;
|
||||||
}
|
}
|
||||||
|
@ -393,11 +395,11 @@ public class PathEntryVariablesGroup {
|
||||||
|
|
||||||
tempPathVariables.clear();
|
tempPathVariables.clear();
|
||||||
for (int i = 0; i < varNames.length; i++) {
|
for (int i = 0; i < varNames.length; i++) {
|
||||||
String value = pathEntryVariableManager.getValue(varNames[i]);
|
IPath value = pathEntryVariableManager.getValue(varNames[i]);
|
||||||
|
|
||||||
// the value may not exist any more
|
// the value may not exist any more
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
boolean isFile = new File(value).isFile();
|
boolean isFile = value.toFile().isFile();
|
||||||
if ((isFile && (variableType & IResource.FILE) != 0)
|
if ((isFile && (variableType & IResource.FILE) != 0)
|
||||||
|| (isFile == false && (variableType & IResource.FOLDER) != 0)) {
|
|| (isFile == false && (variableType & IResource.FOLDER) != 0)) {
|
||||||
|
|
||||||
|
@ -432,14 +434,13 @@ public class PathEntryVariablesGroup {
|
||||||
private void updateVariableTable(String selectedVarName) {
|
private void updateVariableTable(String selectedVarName) {
|
||||||
variableTable.removeAll();
|
variableTable.removeAll();
|
||||||
int selectedVarIndex = 0;
|
int selectedVarIndex = 0;
|
||||||
for (Iterator varNames = tempPathVariables.keySet().iterator(); varNames
|
for (Iterator varNames = tempPathVariables.keySet().iterator(); varNames.hasNext();) {
|
||||||
.hasNext();) {
|
|
||||||
TableItem item = new TableItem(variableTable, SWT.NONE);
|
TableItem item = new TableItem(variableTable, SWT.NONE);
|
||||||
String varName = (String) varNames.next();
|
String varName = (String) varNames.next();
|
||||||
String value = (String) tempPathVariables.get(varName);
|
IPath value = (IPath) tempPathVariables.get(varName);
|
||||||
File file = new File(value);
|
File file = value.toFile();
|
||||||
|
|
||||||
item.setText(varName + " - " + value); //$NON-NLS-1$
|
item.setText(varName + " - " + value.toOSString()); //$NON-NLS-1$
|
||||||
// the corresponding variable name is stored in each table widget item
|
// the corresponding variable name is stored in each table widget item
|
||||||
item.setData(varName);
|
item.setData(varName);
|
||||||
item.setImage(file.exists() ? (file.isFile() ? FILE_IMG
|
item.setImage(file.exists() ? (file.isFile() ? FILE_IMG
|
||||||
|
@ -465,8 +466,7 @@ public class PathEntryVariablesGroup {
|
||||||
public boolean performOk() {
|
public boolean performOk() {
|
||||||
try {
|
try {
|
||||||
// first process removed variables
|
// first process removed variables
|
||||||
for (Iterator removed = removedVariableNames.iterator(); removed
|
for (Iterator removed = removedVariableNames.iterator(); removed.hasNext();) {
|
||||||
.hasNext();) {
|
|
||||||
String removedVariableName = (String) removed.next();
|
String removedVariableName = (String) removed.next();
|
||||||
// only removes variables that have not been added again
|
// only removes variables that have not been added again
|
||||||
if (!tempPathVariables.containsKey(removedVariableName))
|
if (!tempPathVariables.containsKey(removedVariableName))
|
||||||
|
@ -474,11 +474,10 @@ public class PathEntryVariablesGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
// then process the current collection of variables, adding/updating them
|
// then process the current collection of variables, adding/updating them
|
||||||
for (Iterator current = tempPathVariables.entrySet().iterator(); current
|
for (Iterator current = tempPathVariables.entrySet().iterator(); current.hasNext();) {
|
||||||
.hasNext();) {
|
|
||||||
Map.Entry entry = (Map.Entry) current.next();
|
Map.Entry entry = (Map.Entry) current.next();
|
||||||
String variableName = (String) entry.getKey();
|
String variableName = (String) entry.getKey();
|
||||||
String variableValue = (String) entry.getValue();
|
IPath variableValue = (IPath) entry.getValue();
|
||||||
pathEntryVariableManager.setValue(variableName, variableValue);
|
pathEntryVariableManager.setValue(variableName, variableValue);
|
||||||
}
|
}
|
||||||
// re-initialize temporary state
|
// re-initialize temporary state
|
||||||
|
|
Loading…
Add table
Reference in a new issue