From 8cbad41d7b91c99beb8d747157bed16b1338b6b0 Mon Sep 17 00:00:00 2001 From: sarsenau Date: Thu, 30 May 2002 19:53:55 +0000 Subject: Fix for PR 16079 --- .../internal/core/messages.properties | 27 ++++- .../ui/externaltools/internal/ui/EditDialog.java | 126 +++++++++++++++++---- 2 files changed, 124 insertions(+), 29 deletions(-) (limited to 'org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools') diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/messages.properties b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/messages.properties index aff111faf..a6619031d 100644 --- a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/messages.properties +++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/core/messages.properties @@ -43,17 +43,32 @@ EditDialog.browseWkspButton2 = Browse Wor&kspace... EditDialog.browseFileSysButton2 = Browse File &System... EditDialog.refreshOptionButton = Browse &Options... EditDialog.browseWorkspaceTitle = Browse Workspace -EditDialog.selectResource = &Select the external tool to use: +EditDialog.selectTool = &Select the external tool to use: +EditDialog.selectResource = &Select the resource to use: EditDialog.selectDirectory = &Select the working directory to use: EditDialog.selectTargets = &Select the Ant targets to use: EditDialog.selectFolder = &Select the folder to use: EditDialog.browseVarTitle = Browse Variables EditDialog.selectVar = &Select a variable to use: -EditDialog.varWorkspaceDirLabel = Current workspace location -EditDialog.varProjectDirLabel = Current project location -EditDialog.varProjectXDirLabel = Specific project location -EditDialog.varResourceDirLabel = Selected resource location -EditDialog.varResourceXDirLabel = Specific resource location +EditDialog.varWorkspaceLocLabel = Workspace location +EditDialog.varProjectLocLabel = Selected resource's project location +EditDialog.varContainerLocLabel = Selected resource's container location +EditDialog.varResourceLocLabel = Selected resource location +EditDialog.varProjectPathLabel = Selected resource's project full path +EditDialog.varContainerPathLabel = Selected resource's container full path +EditDialog.varResourcePathLabel = Selected resource full path +EditDialog.varProjectNameLabel = Selected resource's project name +EditDialog.varContainerNameLabel = Selected resource's container name +EditDialog.varResourceNameLabel = Selected resource name +EditDialog.varProjectXLocLabel = Specific resource's project location +EditDialog.varContainerXLocLabel = Specific resource's container location +EditDialog.varResourceXLocLabel = Specific resource location +EditDialog.varProjectXPathLabel = Specific resource's project full path +EditDialog.varContainerXPathLabel = Specific resource's container full path +EditDialog.varResourceXPathLabel = Specific resource full path +EditDialog.varProjectXNameLabel = Specific resource's project name +EditDialog.varContainerXNameLabel = Specific resource's container name +EditDialog.varResourceXNameLabel = Specific resource name EditDialog.varAntTargetLabel = Ant targets EditDialog.browseProjectTitle = Browse Projects EditDialog.selectProject = &Select a project to use: diff --git a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/EditDialog.java b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/EditDialog.java index 1b375ac4c..ec2f2faa8 100644 --- a/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/EditDialog.java +++ b/org.eclipse.ui.externaltools/External Tools/org/eclipse/ui/externaltools/internal/ui/EditDialog.java @@ -357,7 +357,10 @@ public class EditDialog extends TitleAreaDialog { locationBrowseWorkspace.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ResourceSelectionDialog dialog; - dialog = new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot()); + dialog = new ResourceSelectionDialog( + getShell(), + ResourcesPlugin.getWorkspace().getRoot(), + ToolMessages.getString("EditDialog.selectTool")); //$NON-NLS-1$ dialog.open(); Object[] results = dialog.getResult(); if (results == null || results.length < 1) @@ -586,12 +589,14 @@ public class EditDialog extends TitleAreaDialog { * the user can select one */ private class ResourceSelectionDialog extends SelectionDialog { + String labelText; IContainer root; TreeViewer wsTree; - public ResourceSelectionDialog(Shell parent, IContainer root) { + public ResourceSelectionDialog(Shell parent, IContainer root, String labelText) { super(parent); this.root = root; + this.labelText = labelText; setShellStyle(getShellStyle() | SWT.RESIZE); setTitle(ToolMessages.getString("EditDialog.browseWorkspaceTitle")); //$NON-NLS-1$ WorkbenchHelp.setHelp(parent, IHelpContextIds.RESOURCE_SELECTION_DIALOG); @@ -605,7 +610,7 @@ public class EditDialog extends TitleAreaDialog { Composite dialogArea = (Composite)super.createDialogArea(parent); Label label = new Label(dialogArea, SWT.LEFT); - label.setText(ToolMessages.getString("EditDialog.selectResource")); //$NON-NLS-1$ + label.setText(labelText); Tree tree = new Tree(dialogArea, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER); GridData data = new GridData(GridData.FILL_BOTH); @@ -661,17 +666,32 @@ public class EditDialog extends TitleAreaDialog { data.heightHint = SIZING_SELECTION_PANE_HEIGHT; data.widthHint = SIZING_SELECTION_PANE_WIDTH; list.setLayoutData(data); - - list.add(ToolMessages.getString("EditDialog.varWorkspaceDirLabel")); //$NON-NLS-1$ - list.add(ToolMessages.getString("EditDialog.varProjectDirLabel")); //$NON-NLS-1$ - list.add(ToolMessages.getString("EditDialog.varProjectXDirLabel")); //$NON-NLS-1$ - list.add(ToolMessages.getString("EditDialog.varResourceDirLabel")); //$NON-NLS-1$ - list.add(ToolMessages.getString("EditDialog.varResourceXDirLabel")); //$NON-NLS-1$ - + + list.add(ToolMessages.getString("EditDialog.varWorkspaceLocLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varProjectLocLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varContainerLocLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varResourceLocLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varProjectPathLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varContainerPathLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varResourcePathLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varProjectNameLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varContainerNameLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varResourceNameLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varProjectXLocLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varContainerXLocLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varResourceXLocLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varProjectXPathLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varContainerXPathLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varResourceXPathLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varProjectXNameLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varContainerXNameLabel")); //$NON-NLS-1$ + list.add(ToolMessages.getString("EditDialog.varResourceXNameLabel")); //$NON-NLS-1$ + location = ToolUtil.getLocationFromText(locationField.getText().trim()); if (location != null && location.endsWith(".xml")) { //$NON-NLS-1$ list.add(ToolMessages.getString("EditDialog.varAntTargetLabel")); //$NON-NLS-1$ } + return dialogArea; } @@ -692,28 +712,74 @@ public class EditDialog extends TitleAreaDialog { break; case 2 : - ProjectSelectionDialog dialog; - dialog = new ProjectSelectionDialog(getShell()); - dialog.open(); - Object[] name = dialog.getResult(); - if (name != null && name.length > 0) - result = ToolUtil.buildVariableTag(ExternalTool.VAR_PROJECT_LOC, (String)name[0]); + result = ToolUtil.buildVariableTag(ExternalTool.VAR_CONTAINER_LOC, null); break; - + case 3 : result = ToolUtil.buildVariableTag(ExternalTool.VAR_RESOURCE_LOC, null); break; case 4 : - ResourceSelectionDialog resDialog; - resDialog = new ResourceSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot()); - resDialog.open(); - Object[] resource = resDialog.getResult(); - if (resource != null && resource.length > 0) - result = ToolUtil.buildVariableTag(ExternalTool.VAR_RESOURCE_LOC, ((IResource)resource[0]).getFullPath().toString()); + result = ToolUtil.buildVariableTag(ExternalTool.VAR_PROJECT_PATH, null); break; case 5 : + result = ToolUtil.buildVariableTag(ExternalTool.VAR_CONTAINER_PATH, null); + break; + + case 6 : + result = ToolUtil.buildVariableTag(ExternalTool.VAR_RESOURCE_PATH, null); + break; + + case 7 : + result = ToolUtil.buildVariableTag(ExternalTool.VAR_PROJECT_NAME, null); + break; + + case 8 : + result = ToolUtil.buildVariableTag(ExternalTool.VAR_CONTAINER_NAME, null); + break; + + case 9 : + result = ToolUtil.buildVariableTag(ExternalTool.VAR_RESOURCE_NAME, null); + break; + + case 10 : + result = showResourceDialog(ExternalTool.VAR_PROJECT_LOC); + break; + + case 11 : + result = showResourceDialog(ExternalTool.VAR_CONTAINER_LOC); + break; + + case 12 : + result = showResourceDialog(ExternalTool.VAR_RESOURCE_LOC); + break; + + case 13 : + result = showResourceDialog(ExternalTool.VAR_PROJECT_PATH); + break; + + case 14 : + result = showResourceDialog(ExternalTool.VAR_CONTAINER_PATH); + break; + + case 15 : + result = showResourceDialog(ExternalTool.VAR_RESOURCE_PATH); + break; + + case 16 : + result = showResourceDialog(ExternalTool.VAR_PROJECT_NAME); + break; + + case 17 : + result = showResourceDialog(ExternalTool.VAR_CONTAINER_NAME); + break; + + case 18 : + result = showResourceDialog(ExternalTool.VAR_RESOURCE_NAME); + break; + + case 19 : AntTargetList targetList = null; try { targetList = AntUtil.getTargetList(new Path(location)); @@ -750,6 +816,20 @@ public class EditDialog extends TitleAreaDialog { setSelectionResult(new Object[] {result}); super.okPressed(); } + + private String showResourceDialog(String varName) { + ResourceSelectionDialog resDialog; + resDialog = new ResourceSelectionDialog( + getShell(), + ResourcesPlugin.getWorkspace().getRoot(), + ToolMessages.getString("EditDialog.selectResource")); //$NON-NLS-1$ + resDialog.open(); + Object[] resource = resDialog.getResult(); + if (resource != null && resource.length > 0) + return ToolUtil.buildVariableTag(varName, ((IResource)resource[0]).getFullPath().toString()); + else + return null; + } } /** -- cgit v1.2.3