From f9c95d6fc82da6624d378f8b459a13fed46d6dde Mon Sep 17 00:00:00 2001 From: Xuan Chen Date: Tue, 11 Mar 2008 15:54:40 +0000 Subject: [PATCH] [187395] First attempt to make user define action and compile command support work in open RSE --- .../META-INF/MANIFEST.MF | 6 +- .../plugin.properties | 3 + .../org.eclipse.rse.useractions/plugin.xml | 34 +- .../files/compile/LocalCompileProfile.java | 4 +- .../compile/UniversalCompilableSource.java | 9 +- .../compile/UniversalCompileProfile.java | 4 +- .../compile/UniversalIBMCompileCommand.java | 6 +- .../files/uda/UDActionSubsystemFiles.java | 20 +- .../files/uda/UDTypesEditPaneFiles.java | 14 +- .../useractions/ui/DynamicMenuTest.java | 46 -- .../ui/SystemDynamicCompileMenu.java | 124 ++++ .../ui/SystemDynamicUserActionMenu.java | 104 +++ .../compile/ISystemCompileXMLConstants.java | 3 +- .../SystemCompileCascadeByProfileAction.java | 44 +- .../compile/SystemCompileCommandEditPane.java | 2 +- .../ui/compile/SystemCompileManager.java | 7 + .../SystemCompileMultipleSelectAction.java | 6 +- .../ui/compile/SystemCompileProfile.java | 271 ++++---- .../SystemWorkWithCompileCommandsDialog.java | 3 +- .../SystemTeamViewCompileTypeAdapter.java | 2 +- ...temTeamViewCompileCommandPropertyPage.java | 6 +- ...SystemTeamViewCompileTypePropertyPage.java | 6 +- .../SystemTeamViewUserActionPropertyPage.java | 4 +- .../ui/uda/ISystemUDAConstants.java | 16 +- .../uda/ISystemXMLElementWrapperFactory.java | 4 +- .../ui/uda/SystemUDACascadeAction.java | 2 +- .../ui/uda/SystemUDAResources.java | 12 + .../ui/uda/SystemUDAResources.properties | 10 + .../ui/uda/SystemUDActionEditPane.java | 62 +- .../ui/uda/SystemUDActionElement.java | 78 ++- .../ui/uda/SystemUDActionManager.java | 32 +- .../ui/uda/SystemUDActionSubsystem.java | 80 ++- .../ui/uda/SystemUDActionTreeView.java | 5 +- .../ui/uda/SystemUDBaseManager.java | 615 +++++++----------- .../ui/uda/SystemUDBaseTreeView.java | 25 +- .../ui/uda/SystemUDSelectTypesForm.java | 2 +- .../ui/uda/SystemUDTypeEditPane.java | 21 +- .../ui/uda/SystemUDTypeElement.java | 24 +- .../ui/uda/SystemUDTypeManager.java | 95 +-- .../ui/uda/SystemUDTypeTreeView.java | 4 +- .../ui/uda/SystemUserActionExtension.java | 2 +- .../ui/uda/SystemWorkWithUDAsDialog.java | 29 +- .../ui/uda/SystemWorkWithUDTypeDialog.java | 29 +- .../ui/uda/SystemXMLElementWrapper.java | 292 ++++----- .../SystemWorkWithFileTypesAction.java | 11 +- .../uda/actions/SystemWorkWithUDAsAction.java | 15 +- .../compile/ISystemCompileManagerAdapter.java | 11 + .../UniversalCompileManagerAdapter.java | 27 + .../uda/ISystemUDActionSubsystemAdapter.java | 11 + ...iversalSystemUDActionSubsystemAdapter.java | 26 + .../compile/SystemCascadingCompileAction.java | 3 +- .../ui/compile/SystemCompileAction.java | 12 +- .../SystemWorkWithCompileCommandsAction.java | 70 +- 53 files changed, 1230 insertions(+), 1123 deletions(-) delete mode 100644 rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/DynamicMenuTest.java create mode 100644 rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemDynamicCompileMenu.java create mode 100644 rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemDynamicUserActionMenu.java create mode 100644 rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/compile/ISystemCompileManagerAdapter.java create mode 100644 rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/compile/UniversalCompileManagerAdapter.java create mode 100644 rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/uda/ISystemUDActionSubsystemAdapter.java create mode 100644 rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/uda/UniversalSystemUDActionSubsystemAdapter.java rename rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/{internal => }/useractions/ui/compile/SystemCascadingCompileAction.java (96%) rename rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/{internal => }/useractions/ui/compile/SystemCompileAction.java (93%) rename rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/{internal => }/useractions/ui/compile/SystemWorkWithCompileCommandsAction.java (76%) diff --git a/rse/plugins/org.eclipse.rse.useractions/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.useractions/META-INF/MANIFEST.MF index 03bc1d82242..32b95386dea 100644 --- a/rse/plugins/org.eclipse.rse.useractions/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.useractions/META-INF/MANIFEST.MF @@ -20,7 +20,11 @@ Require-Bundle: org.eclipse.core.resources, org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)" Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true -Export-Package: org.eclipse.rse.internal.useractions, +Export-Package: org.eclipse.rse.useractions.ui.compile, + org.eclipse.rse.useractions.files.compile, + org.eclipse.rse.useractions.files.uda, + org.eclipse.rse.internal.useractions.ui.compile, + org.eclipse.rse.internal.useractions, org.eclipse.rse.internal.useractions.files.compile, org.eclipse.rse.internal.useractions.files.uda, org.eclipse.rse.internal.useractions.ui, diff --git a/rse/plugins/org.eclipse.rse.useractions/plugin.properties b/rse/plugins/org.eclipse.rse.useractions/plugin.properties index 7990f1fce06..b377d10ea52 100644 --- a/rse/plugins/org.eclipse.rse.useractions/plugin.properties +++ b/rse/plugins/org.eclipse.rse.useractions/plugin.properties @@ -20,3 +20,6 @@ providerName = Eclipse.org PropertyPage.TeamViewUserActionNode = User Action Information PropertyPage.TeamViewCompileTypeNode = Compile Type Information PropertyPage.TeamViewCompileCommandNode = Compile Command Information + +DynamicLabel.CompileActionNode = Compile +DynamicLabel.UserActionNode = User Action diff --git a/rse/plugins/org.eclipse.rse.useractions/plugin.xml b/rse/plugins/org.eclipse.rse.useractions/plugin.xml index 1e22aab2deb..48c4a9364c5 100644 --- a/rse/plugins/org.eclipse.rse.useractions/plugin.xml +++ b/rse/plugins/org.eclipse.rse.useractions/plugin.xml @@ -39,21 +39,31 @@ - - + - - - + + - + - + + + + + + - - + diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/LocalCompileProfile.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/LocalCompileProfile.java index 1ec4dce1d26..fe42ef8618f 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/LocalCompileProfile.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/LocalCompileProfile.java @@ -19,8 +19,8 @@ import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; public class LocalCompileProfile extends UniversalCompileProfile { /** * Constructor - * @param manager - * @param profileName + * @param manager SystemCompileManager of this compile file + * @param profileName System profile name */ public LocalCompileProfile(SystemCompileManager manager, String profileName) { super(manager, profileName); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompilableSource.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompilableSource.java index d1bc1e7e5a1..8556a042d0e 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompilableSource.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompilableSource.java @@ -23,10 +23,11 @@ import org.eclipse.swt.widgets.Shell; public class UniversalCompilableSource extends SystemCompilableSource { /** * Constructor for UniversalCompilableSource. - * @param shell - * @param firstSelection - * @param compileCmd - * @param isPrompt + * @param shell - the shell to use if need to prompt + * @param firstSelection - the selected compilable source member + * @param compileCmd - the Compile Command that is to be run against the selected compilable source member + * @param isPrompt - true if the user choose the flavor of the action to prompt the compile command + * @param viewer - the viewer that originated the compile action */ public UniversalCompilableSource(Shell shell, Object firstSelection, SystemCompileCommand compileCmd, boolean isPrompt, Viewer viewer) { super(shell, firstSelection, compileCmd, isPrompt, viewer); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileProfile.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileProfile.java index b818b7621cf..53ae332aefb 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileProfile.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalCompileProfile.java @@ -24,8 +24,8 @@ import org.eclipse.swt.widgets.Shell; public class UniversalCompileProfile extends SystemCompileProfile { /** * Constructor for UniversalCompileProfile. - * @param manager - * @param profileName + * @param manager SystemCompileManager of this compile file + * @param profileName System profile name */ public UniversalCompileProfile(SystemCompileManager manager, String profileName) { super(manager, profileName); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalIBMCompileCommand.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalIBMCompileCommand.java index 354137024ef..831e8671d40 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalIBMCompileCommand.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/UniversalIBMCompileCommand.java @@ -19,8 +19,8 @@ import org.eclipse.rse.internal.useractions.ui.compile.SystemDefaultCompileComma public class UniversalIBMCompileCommand extends SystemDefaultCompileCommand { /** * Constructor for UniversalCompileIBMCommand. - * @param commandLabel - * @param commandName + * @param commandLabel label of the command + * @param commandName name of the command */ public UniversalIBMCompileCommand(String commandLabel, String commandName) { super(commandLabel, commandName); @@ -28,7 +28,7 @@ public class UniversalIBMCompileCommand extends SystemDefaultCompileCommand { /** * Constructor for UniversalCompileIBMCommand. - * @param commandName + * @param commandName name of the command */ public UniversalIBMCompileCommand(String commandName) { super(commandName); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemFiles.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemFiles.java index dec701a25ec..0920fe82adc 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemFiles.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDActionSubsystemFiles.java @@ -19,11 +19,11 @@ import java.util.Vector; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.Viewer; +import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.internal.useractions.UserActionsIcon; import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; +import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDAConstants; import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDAEditPaneHoster; import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTreeView; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; @@ -283,7 +283,7 @@ public class UDActionSubsystemFiles extends SystemUDActionSubsystem { * @param cmdString - the resolved command * @param cmdSubSystem - this connection's command subsystem, which will run the command * @param context - the selected IRemoteFile object - * @param viewer + * @param viewer the viewer that originated the compile action * @return true if we should continue, false if something went wrong */ protected boolean runCommand(Shell shell, SystemUDActionElement action, String cmdString, IRemoteCmdSubSystem cmdSubSystem, Object context, Viewer viewer) { @@ -356,8 +356,8 @@ public class UDActionSubsystemFiles extends SystemUDActionSubsystem { /** * Subclasses may override to provide a custom type edit pane subclass */ - public SystemUDTypeEditPane getCustomUDTypeEditPane(ISubSystem ss, ISubSystemConfiguration ssf, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - return new UDTypesEditPaneFiles(ss, ssf, profile, parent, tv); + public SystemUDTypeEditPane getCustomUDTypeEditPane(ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { + return new UDTypesEditPaneFiles(this, parent, tv); } /** @@ -445,9 +445,19 @@ public class UDActionSubsystemFiles extends SystemUDActionSubsystem { public static SystemUDActionElement[] primeDefaultUniversalActions(SystemUDActionManager actionMgr, ISystemProfile profile, Vector vectorOfActions) { Vector v = vectorOfActions; if (v == null) v = new Vector(); + String osType = actionMgr.getActionSubSystem().getOSType(); + String userDefinedActionPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + actionMgr.getDocumentRootTagName(); //$NON-NLS-1$ + IPropertySet userDefinedActionPropertySet = profile.getPropertySet(userDefinedActionPropertySetName); + if (null == userDefinedActionPropertySet) + { + userDefinedActionPropertySet = profile.createPropertySet(userDefinedActionPropertySetName); + userDefinedActionPropertySet.addProperty(ISystemUDAConstants.RELEASE_ATTR, ISystemUDAConstants.RELEASE_VALUE); + userDefinedActionPropertySet.addProperty(ISystemUDAConstants.UDA_ROOT_ATTR, actionMgr.getDocumentRootTagName()); + } // add file actions int domain = DOMAIN_FILE; SystemUDActionElement newAction; + //IPropertySet domainFilePropertySet = userDefinedActionPropertySet.createPropertySet(DOMAINS[1]); for (int idx = 0; idx < FILE_ACTIONS.length; idx++) { newAction = actionMgr.addAction(profile, FILE_ACTIONS[idx][0], domain); v.addElement(newAction); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDTypesEditPaneFiles.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDTypesEditPaneFiles.java index 8524d89b18a..cc315092c1b 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDTypesEditPaneFiles.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/uda/UDTypesEditPaneFiles.java @@ -10,12 +10,10 @@ package org.eclipse.rse.internal.useractions.files.uda; * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -import org.eclipse.rse.core.model.ISystemProfile; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDAEditPaneHoster; import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTreeView; import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTypeEditPaneTypesSelector; +import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeEditPane; import org.eclipse.swt.widgets.Composite; @@ -30,12 +28,12 @@ import org.eclipse.swt.widgets.Composite; public class UDTypesEditPaneFiles extends SystemUDTypeEditPane { /** * Constructor for UDTypesEditPaneFiles. - * @param ss - * @param parent - * @param tv + * @param udaActionSubsys User Defined Action subsystem + * @param parent any dialog or property page that wants to host a user action edit pane. + * @param tv User Defined Action tree view */ - public UDTypesEditPaneFiles(ISubSystem ss, ISubSystemConfiguration ssf, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - super(ss, ssf, profile, parent, tv); + public UDTypesEditPaneFiles(SystemUDActionSubsystem udaActionSubsys, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { + super(udaActionSubsys, parent, tv); } /** diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/DynamicMenuTest.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/DynamicMenuTest.java deleted file mode 100644 index 039e90757f5..00000000000 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/DynamicMenuTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2008 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ -package org.eclipse.rse.internal.useractions.ui; - -import org.eclipse.jface.action.ContributionItem; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.ui.actions.CompoundContributionItem; - -public class DynamicMenuTest extends CompoundContributionItem -{ - private class TestContribution extends ContributionItem { - public void fill(Menu menu, int index) - { - MenuItem menuItem = new MenuItem(menu, SWT.RADIO); - menuItem.setText("My First Contribution"); - } - } - - protected IContributionItem[] getContributionItems() { - // Here's where you would dynamically generate your list - IContributionItem[] list = new IContributionItem[1]; - - list[0] = new TestContribution(); - - - //IAction searchAction = new SystemSearchAction(null); - // ActionContributionItem item = new ActionContributionItem(searchAction); - // list[1] = item; - return list; - } - -} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemDynamicCompileMenu.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemDynamicCompileMenu.java new file mode 100644 index 00000000000..2a61f40c974 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemDynamicCompileMenu.java @@ -0,0 +1,124 @@ +package org.eclipse.rse.internal.useractions.ui; + +import java.util.ArrayList; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.model.ISystemProfile; +import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCommand; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileProfile; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileType; +import org.eclipse.rse.ui.SystemBasePlugin; +import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; +import org.eclipse.rse.ui.view.SystemAdapterHelpers; +import org.eclipse.rse.useractions.files.compile.ISystemCompileManagerAdapter; +import org.eclipse.rse.useractions.ui.compile.SystemCompileAction; +import org.eclipse.rse.useractions.ui.compile.SystemWorkWithCompileCommandsAction; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.CompoundContributionItem; + +public class SystemDynamicCompileMenu extends CompoundContributionItem +{ + private class TestContribution extends ActionContributionItem { + + public TestContribution(Action action) + { + super(action); + } + + /* + public void fill(Menu menu, int index) + { + + MenuItem menuItem = new MenuItem(menu, SWT.RADIO); + menuItem.setText("My First Contribution"); + } + */ + } + + protected IContributionItem[] getContributionItems() { + + ArrayList returnedItemList = new ArrayList(); + + ISystemProfile[] activeProfiles = RSECorePlugin.getTheSystemRegistry().getActiveSystemProfiles(); + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + ISelection selection = window.getSelectionService().getSelection(); + Object firstSelection = ((IStructuredSelection) selection).getFirstElement(); + + Shell shell = SystemBasePlugin.getActiveWorkbenchShell(); + + for (int idx = 0; idx < activeProfiles.length; idx++) + { + String srcType = null; + ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(firstSelection); + if (rmtAdapter != null) { + srcType = rmtAdapter.getRemoteSourceType(firstSelection); + if (srcType == null) + srcType = "null"; //$NON-NLS-1$ + else if (srcType.equals("")) //$NON-NLS-1$ + srcType = "blank"; //$NON-NLS-1$ + } + ISubSystem subsystem = rmtAdapter.getSubSystem(firstSelection); + ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration(); + + SystemCompileManager compileManager = null; + + if (firstSelection instanceof IAdaptable) { + ISystemCompileManagerAdapter adapter = (ISystemCompileManagerAdapter)((IAdaptable)firstSelection).getAdapter(ISystemCompileManagerAdapter.class); + if (null != adapter) + { + compileManager = adapter.getSystemCompileManager(ssc); + } + } + + if (null != compileManager) + { + SystemCompileManager thisCompileManager = compileManager; + SystemCompileProfile compileProfile = thisCompileManager.getCompileProfile(activeProfiles[idx]); + // compileProfile.addContributions(firstSelection); + SystemCompileType compileType = compileProfile.getCompileType(srcType); + + if (compileType != null) + { + SystemCompileCommand[] cmds = compileType.getCompileCommandsArray(); + for (int idx2=0; idx2 0); + return types; } /** diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemWorkWithCompileCommandsDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemWorkWithCompileCommandsDialog.java index 999c36106fe..1cb05d45ef5 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemWorkWithCompileCommandsDialog.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemWorkWithCompileCommandsDialog.java @@ -28,7 +28,6 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.events.ISystemModelChangeEvents; -import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.ui.view.SystemViewMenuListener; import org.eclipse.rse.internal.useractions.IUserActionsModelChangeEvents; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; @@ -122,7 +121,7 @@ public class SystemWorkWithCompileCommandsDialog extends SystemPromptDialog impl this.currentCompProfile = currentCompProfile; this.compProfiles = new SystemCompileProfile[] { currentCompProfile }; this.supportsAddSrcTypeButton = true; - setCancelButtonLabel(SystemResources.BUTTON_CLOSE); + setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE); setShowOkButton(false); setOutputObject(null); setHelp(); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/teamview/SystemTeamViewCompileTypeAdapter.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/teamview/SystemTeamViewCompileTypeAdapter.java index 2a5079c662b..0a5606edb60 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/teamview/SystemTeamViewCompileTypeAdapter.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/teamview/SystemTeamViewCompileTypeAdapter.java @@ -20,11 +20,11 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.internal.useractions.UserActionsResources; import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCommand; -import org.eclipse.rse.internal.useractions.ui.compile.SystemWorkWithCompileCommandsAction; import org.eclipse.rse.ui.SystemMenuManager; import org.eclipse.rse.ui.view.AbstractSystemViewAdapter; import org.eclipse.rse.ui.view.ISystemPropertyConstants; import org.eclipse.rse.ui.view.ISystemViewElementAdapter; +import org.eclipse.rse.useractions.ui.compile.SystemWorkWithCompileCommandsAction; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.views.properties.PropertyDescriptor; diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewCompileCommandPropertyPage.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewCompileCommandPropertyPage.java index 92f748b26ac..ebe9605ab6e 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewCompileCommandPropertyPage.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewCompileCommandPropertyPage.java @@ -18,7 +18,6 @@ package org.eclipse.rse.internal.useractions.ui.propertypages; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.events.ISystemModelChangeEvents; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.useractions.IUserActionsModelChangeEvents; import org.eclipse.rse.internal.useractions.UserActionsResources; import org.eclipse.rse.internal.useractions.ui.compile.ISystemCompileCommandEditPaneHoster; @@ -27,6 +26,7 @@ import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCommand; import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCommandEditPane; import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; import org.eclipse.rse.internal.useractions.ui.compile.teamview.SystemTeamViewCompileCommandNode; +import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage; @@ -70,8 +70,8 @@ public class SystemTeamViewCompileCommandPropertyPage extends SystemBaseProperty nbrColumns = 2; composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns); // Type prompt - String typeLabel = SystemResources.RESID_PP_PROPERTIES_TYPE_LABEL; - String typeTooltip = SystemResources.RESID_PP_PROPERTIES_TYPE_TOOLTIP; + String typeLabel = SystemUDAResources.RESID_PP_PROPERTIES_TYPE_LABEL; + String typeTooltip = SystemUDAResources.RESID_PP_PROPERTIES_TYPE_TOOLTIP; labelType = SystemWidgetHelpers.createLabeledLabel(composite_prompts, typeLabel, typeTooltip, false); labelType.setText(UserActionsResources.RESID_PP_COMPILECMD_TYPE_VALUE); // Profile prompt diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewCompileTypePropertyPage.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewCompileTypePropertyPage.java index 421b3a23efa..38fcc1fe1cb 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewCompileTypePropertyPage.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewCompileTypePropertyPage.java @@ -10,9 +10,9 @@ package org.eclipse.rse.internal.useractions.ui.propertypages; * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.useractions.UserActionsResources; import org.eclipse.rse.internal.useractions.ui.compile.teamview.SystemTeamViewCompileTypeNode; +import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage; import org.eclipse.swt.widgets.Composite; @@ -43,8 +43,8 @@ public class SystemTeamViewCompileTypePropertyPage extends SystemBasePropertyPag // Inner composite Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, 2); // Type prompt - String typeLabel = SystemResources.RESID_PP_PROPERTIES_TYPE_LABEL; - String typeTooltip = SystemResources.RESID_PP_PROPERTIES_TYPE_TOOLTIP; + String typeLabel = SystemUDAResources.RESID_PP_PROPERTIES_TYPE_LABEL; + String typeTooltip = SystemUDAResources.RESID_PP_PROPERTIES_TYPE_TOOLTIP; labelType = createLabeledLabel(composite_prompts, typeLabel, typeTooltip); labelType.setText(UserActionsResources.RESID_PP_COMPILETYPE_TYPE_VALUE); // Profile prompt diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewUserActionPropertyPage.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewUserActionPropertyPage.java index c647f4a61b2..55b46125de6 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewUserActionPropertyPage.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/propertypages/SystemTeamViewUserActionPropertyPage.java @@ -13,10 +13,10 @@ package org.eclipse.rse.internal.useractions.ui.propertypages; import org.eclipse.jface.viewers.ISelection; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.useractions.UserActionsResources; import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDAEditPaneHoster; import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTreeView; +import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionEditPane; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionElement; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; @@ -63,7 +63,7 @@ public class SystemTeamViewUserActionPropertyPage extends SystemBasePropertyPage // Inner composite composite_prompts = SystemWidgetHelpers.createComposite(parent, 2); // Type prompt - labelType = createLabeledLabel(composite_prompts, SystemResources.RESID_PP_PROPERTIES_TYPE_LABEL, SystemResources.RESID_PP_PROPERTIES_TYPE_TOOLTIP); + labelType = createLabeledLabel(composite_prompts, SystemUDAResources.RESID_PP_PROPERTIES_TYPE_LABEL, SystemUDAResources.RESID_PP_PROPERTIES_TYPE_TOOLTIP); labelType.setText(UserActionsResources.RESID_PP_USERACTION_TYPE_VALUE); // Profile prompt labelProfile = createLabeledLabel(composite_prompts, UserActionsResources.RESID_PP_USERACTION_PROFILE_LABEL, UserActionsResources.RESID_PP_USERACTION_PROFILE_TOOLTIP); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDAConstants.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDAConstants.java index 27dd64e53d3..00c55c77d49 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDAConstants.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemUDAConstants.java @@ -16,6 +16,13 @@ package org.eclipse.rse.internal.useractions.ui.uda; * Constants used throughout the User Defined Action framework. */ public interface ISystemUDAConstants { + + public static final String USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX = "UDA."; //$NON-NLS-1$ + + static final String UDA_ROOT_ATTR = "uda_root"; //$NON-NLS-1$ + static final String FILETYPES_ROOT = "FileTypes"; //$NON-NLS-1$ + static final String ACTIONS_ROOT = "Actions"; //$NON-NLS-1$ + /** * The name of the xml tag for domain tags. * Domains are used to partition actions. @@ -28,7 +35,7 @@ public interface ISystemUDAConstants { * identifies the domain type. Its values will be * an untranslated name like "Object" or "Folder". */ - public static final String XE_DOMTYPE = "Type"; //$NON-NLS-1$ + public static final String XE_DOMTYPE = "DomainType"; //$NON-NLS-1$ /** * The name of the xml attribute of domain tags which * identifies the domain name. Its values will be @@ -39,6 +46,11 @@ public interface ISystemUDAConstants { * The name of the attribute we consistently use to store an element's name */ public static final String NAME_ATTR = "Name"; //$NON-NLS-1$ + /** + * The type of the attribute we consistently use to store an element's name + */ + public static final String TYPE_ATTR = "Type"; //$NON-NLS-1$ + /** * The name of the attribute we consistently use to store an element's original IBM-supplied name */ @@ -47,4 +59,6 @@ public interface ISystemUDAConstants { * The name of the attribute we consistently use to store a release number */ public static final String RELEASE_ATTR = "release"; //$NON-NLS-1$ + + public static final String RELEASE_VALUE = "7.5"; //$NON-NLS-1$ } diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemXMLElementWrapperFactory.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemXMLElementWrapperFactory.java index 819a95d0db2..a46a6b7c60e 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemXMLElementWrapperFactory.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/ISystemXMLElementWrapperFactory.java @@ -10,8 +10,8 @@ package org.eclipse.rse.internal.useractions.ui.uda; * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ +import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.ISystemProfile; -import org.w3c.dom.Element; /** * @author coulthar @@ -24,7 +24,7 @@ public interface ISystemXMLElementWrapperFactory { * Given an xml element node, create an instance of the appropriate * subclass of SystemXMLElementWrapper to represent it. */ - public SystemXMLElementWrapper createElementWrapper(Element xmlElementToWrap, ISystemProfile profile, int domain); + public SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain); /** * Return the tag name for these elements. Will be "Action" or "Type" diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDACascadeAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDACascadeAction.java index 16d68bf93a8..4aae81c41a8 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDACascadeAction.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDACascadeAction.java @@ -84,7 +84,7 @@ public class SystemUDACascadeAction extends SystemBaseSubMenuAction implements I } ourSubMenu.add(new Separator(ISystemContextMenuConstants.GROUP_WORKWITH)); if (wwAction == null) { - wwAction = new SystemWorkWithUDAsAction(shell, udsubsystem.getSubsystem()); + wwAction = new SystemWorkWithUDAsAction(shell, udsubsystem.getSubsystem(), udsubsystem); wwAction.setText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_LABEL); wwAction.setToolTipText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_TOOLTIP); wwAction.allowOnMultipleSelection(true); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.java index 7ae4da3f041..46c2df3507d 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.java @@ -260,6 +260,18 @@ public class SystemUDAResources extends NLS { public static String RESID_PREF_UDAS_CASCADEBYPROFILE_LABEL; public static String RESID_PREF_UDAS_CASCADEBYPROFILE_TOOLTIP; public static String SystemCompileManager_0; + + //Resources used to be in other internal plugins: + public static String EditorManager_saveResourcesMessage; + public static String EditorManager_saveResourcesTitle; + + public static String BUTTON_CLOSE; + public static String RESID_PP_PROPERTIES_TYPE_LABEL; + public static String RESID_PP_PROPERTIES_TYPE_TOOLTIP; + public static String ACTION_CASCADING_NEW_LABEL; + public static String ACTION_CASCADING_NEW_TOOLTIP; + + static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, SystemUDAResources.class); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.properties b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.properties index 55ab87eb963..f89ce418eb8 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.properties +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDAResources.properties @@ -436,3 +436,13 @@ RESID_UCMD_COMMAND_TOOLTIP = Enter the command to invoke RESID_UCMD_COMAMND_SHELL_LABEL = Command Shell SystemCompileManager_0=An error has been detected that is probably a programming bug. Please submit your .log file in the .metadata subfolder for service. + + +EditorManager_saveResourcesMessage = Select the &resources to save: +EditorManager_saveResourcesTitle = Save Resources + +BUTTON_CLOSE=Close +RESID_PP_PROPERTIES_TYPE_LABEL=Resource type +RESID_PP_PROPERTIES_TYPE_TOOLTIP=What type of artifact is this? +ACTION_CASCADING_NEW_LABEL=New +ACTION_CASCADING_NEW_TOOLTIP=Create a new resource diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionEditPane.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionEditPane.java index ee8b9de7a2b..e150edc437d 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionEditPane.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionEditPane.java @@ -88,6 +88,7 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che // Current selection not valid if errorMessage not null protected SystemMessage errorMessage; protected ISubSystem subsystem; + protected SystemUDActionSubsystem udaActionSubsys; protected ISubSystemConfiguration subsystemFactory; protected ISystemProfile profile; public SystemUDActionElement currentAction; @@ -119,11 +120,12 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che /** * Constructor when we have a subsystem or a subsystemconfiguration/profile pair. */ - public SystemUDActionEditPane(ISubSystem subsys, ISubSystemConfiguration ssf, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { + public SystemUDActionEditPane(SystemUDActionSubsystem udaActionSubsys, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { super(); - this.subsystem = subsys; - this.subsystemFactory = (ssf == null) ? subsys.getSubSystemConfiguration() : ssf; - this.profile = (profile == null) ? subsys.getSystemProfile() : profile; + this.udaActionSubsys = udaActionSubsys; + this.subsystem = udaActionSubsys.getSubsystem(); + this.subsystemFactory = subsystem.getSubSystemConfiguration(); + this.profile = (profile == null) ? subsystem.getSystemProfile() : profile; parentDialog = parent; treeView = tv; commandField = new SystemCommandTextField(getCommandTextViewerConfiguration()); @@ -134,15 +136,7 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che * Return the user defined action subsystem */ protected SystemUDActionSubsystem getUDActionSubsystem() { - // FIXME - uda can't be coupled to subsystem api - // if (subsystem!=null) - // return subsystem.getUDActionSubsystem(); - // else - // { - // ISubsystemFactoryAdapter adapter = (ISubsystemFactoryAdapter)subsystemFactory.getAdapter(ISubsystemFactoryAdapter.class); - // return adapter.getActionSubSystem(subsystemFactory, null); - // } - return null; + return udaActionSubsys; } /** @@ -168,13 +162,6 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che return subsystem; } - /** - * For child classes to access current subsystem factory. - */ - protected ISubSystemConfiguration getSubSystemFactory() { - return subsystemFactory; - } - /** * For child classes to access current profile */ @@ -246,7 +233,7 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che // ------------------------------ /** * Method createContents. - * @param parent + * @param parent parent of this pane * @return Control */ public Control createContents(Composite parent) { @@ -318,10 +305,12 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che //Label filler2 = SystemWidgetHelpers.createLabel(comp, ""); //((GridData)filler2.getLayoutData()).horizontalSpan = nbrColumns; // TYPE SELECTION FORM - if (subsystem != null) - selectTypesForm = createSelectTypesForm(parentDialog.getShell(), subsystem); + if (udaActionSubsys != null) + selectTypesForm = createSelectTypesForm(parentDialog.getShell(), subsystem, udaActionSubsys); else - selectTypesForm = createSelectTypesForm(parentDialog.getShell(), subsystemFactory, profile); + { + // FIXME: Xuan - selectTypesForm = createSelectTypesForm(parentDialog.getShell(), profile); + } if (selectTypesForm != null) { selectTypesForm.createContents(comp, nbrColumns); } @@ -683,25 +672,12 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che * Or override and return null to not prompt user for file types in your edit pane. * @return the created form, or null if you don't wish to include the GUI for selecting types */ - protected SystemUDSelectTypesForm createSelectTypesForm(Shell shell, ISubSystem subsystem) { - // FIXME - UDA can't be coupled to subsystem api - // if (getUDActionSubsystem().supportsTypes()) - // return new SystemUDSelectTypesForm(shell, subsystem, subsystem.getUDActionSubsystem().getUDTypeManager()); - // else - return null; - } - - /** - * Override to use when we have a subsystem factory vs subsystem... eg, when launched from Team view. - */ - protected SystemUDSelectTypesForm createSelectTypesForm(Shell shell, ISubSystemConfiguration subsystemFactory, ISystemProfile profile) { - // FIXME - UDA can't be coupled to subsystem api - // if (getUDActionSubsystem().supportsTypes()) - // { - // ISubsystemFactoryAdapter adapter = (ISubsystemFactoryAdapter)subsystemFactory.getAdapter(ISubsystemFactoryAdapter.class); - // return new SystemUDSelectTypesForm(shell, subsystemFactory, profile, adapter.getActionSubSystem(subsystemFactory, null).getUDTypeManager()); - // } - // else + protected SystemUDSelectTypesForm createSelectTypesForm(Shell shell, ISubSystem subsystem, SystemUDActionSubsystem udaActionSubsys) { + + if (udaActionSubsys.supportsTypes()) + { + return new SystemUDSelectTypesForm(shell, subsystem, udaActionSubsys.getUDTypeManager()); + } return null; } diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionElement.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionElement.java index 95893ad94ac..7ef11a1e181 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionElement.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionElement.java @@ -12,10 +12,11 @@ package org.eclipse.rse.internal.useractions.ui.uda; *******************************************************************************/ import java.util.StringTokenizer; +import org.eclipse.rse.core.model.IProperty; +import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.internal.useractions.UserActionsIcon; import org.eclipse.swt.graphics.Image; -import org.w3c.dom.Element; /** * Represents a single user defined action, as an adaptable @@ -42,7 +43,7 @@ public class SystemUDActionElement extends SystemXMLElementWrapper { * @param profile - The system profile which owns this action * @param domainType - The integer representation of the domain this is in (or this is, for a domain element) */ - public SystemUDActionElement(Element e, SystemUDActionManager am, ISystemProfile profile, int domainType) { + public SystemUDActionElement(IPropertySet e, SystemUDActionManager am, ISystemProfile profile, int domainType) { super(e, am, profile, domainType); } @@ -79,15 +80,28 @@ public class SystemUDActionElement extends SystemXMLElementWrapper { /** * Return value of the "Comment" sub-tag */ + public String getComment() { - return getTextNode(COMMENT_TAG); + //Get the property for this + IProperty commentProperty = elm.getProperty(COMMENT_TAG); + if (commentProperty != null) + { + return commentProperty.getValue(); + } + return ""; //$NON-NLS-1$ } /** * Return value of the "Command" sub-tag, which is the current command value */ public String getCommand() { - return getTextNode(COMMAND_TAG); + //Get the property for this + IProperty commentProperty = elm.getProperty(COMMAND_TAG); + if (commentProperty != null) + { + return commentProperty.getValue(); + } + return ""; //$NON-NLS-1$ } /** @@ -129,22 +143,38 @@ public class SystemUDActionElement extends SystemXMLElementWrapper { * Return value of the "FileTypes" sub-tag */ public String[] getFileTypes() { - String fts = getTextNode(FILETYPES_TAG); - // returns an empty string if no attribute - StringTokenizer st = new StringTokenizer(fts); - int n = st.countTokens(); - String sa[] = new String[n]; - for (int i = 0; i < n; i++) { - sa[i] = st.nextToken(); + //Get the property for this + IProperty fileTypeProperty = elm.getProperty(FILETYPES_TAG); + if (fileTypeProperty != null) + { + String fts = fileTypeProperty.getValue(); + // returns an empty string if no attribute + StringTokenizer st = new StringTokenizer(fts); + int n = st.countTokens(); + String sa[] = new String[n]; + for (int i = 0; i < n; i++) { + sa[i] = st.nextToken(); + } + return sa; } - return sa; + + return new String[0]; } /** * Set the value of the "Comment" sub-tag */ public void setComment(String s) { - setTextNode(COMMENT_TAG, s); + IProperty commentProperty = elm.getProperty(COMMENT_TAG); + if (null != commentProperty) + { + commentProperty.setValue(s); + } + else + { + elm.addProperty(COMMENT_TAG, s); + } + setUserChanged(true); } @@ -152,7 +182,15 @@ public class SystemUDActionElement extends SystemXMLElementWrapper { * Set the value of the "Command" sub-tag. */ public void setCommand(String s) { - setTextNode(COMMAND_TAG, s); + IProperty commandProperty = elm.getProperty(COMMAND_TAG); + if (null != commandProperty) + { + commandProperty.setValue(s); + } + else + { + elm.addProperty(COMMAND_TAG, s); + } setUserChanged(true); } @@ -204,7 +242,17 @@ public class SystemUDActionElement extends SystemXMLElementWrapper { for (int i = 0; i < sa.length; i++) { s = s + " " + sa[i]; //$NON-NLS-1$ } - setTextNode(FILETYPES_TAG, s); + + IProperty fileTypeProperty = elm.getProperty(FILETYPES_TAG); + if (null != fileTypeProperty) + { + fileTypeProperty.setValue(s); + } + else + { + elm.addProperty(FILETYPES_TAG, s); + } + setUserChanged(true); } diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionManager.java index f957ad4b9aa..896a20a7896 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionManager.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionManager.java @@ -11,17 +11,16 @@ *******************************************************************************/ package org.eclipse.rse.internal.useractions.ui.uda; -import java.io.File; import java.util.Vector; import org.eclipse.core.resources.IFolder; import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.internal.useractions.UserActionsIcon; import org.eclipse.rse.internal.useractions.UserActionsPersistenceUtil; import org.eclipse.swt.graphics.Image; -import org.w3c.dom.Element; /** * Instances of this class hold the UDA definitions unique to: @@ -39,9 +38,8 @@ import org.w3c.dom.Element; public class SystemUDActionManager extends SystemUDBaseManager // implements ErrorHandler, implements ITreeContentProvider { - private static final String XE_ROOT = "Actions"; //$NON-NLS-1$ + private static final String XE_ROOT = ISystemUDAConstants.ACTIONS_ROOT; private static final String XE_ACTION = "Action"; //$NON-NLS-1$ - private final static String UDA_FILENAME = "uda.xml"; //$NON-NLS-1$ /** * Constructor @@ -84,13 +82,6 @@ public class SystemUDActionManager extends SystemUDBaseManager return getActionSubSystem().doActionsMigration(profile, oldRelease); } - /** - * Get name of the xml file used to persist the actions. - */ - public String getFileName() { - return UDA_FILENAME; - } - /** * Get the document root tag name. * We return "Actions" @@ -148,23 +139,6 @@ public class SystemUDActionManager extends SystemUDBaseManager return (SystemUDActionElement) super.addElement(profile, domain, name); } - /** - * Return true if there are any actions, currently. - */ - public boolean hasActions(ISystemProfile profile, ISubSystemConfiguration ssFactory) { - boolean hasActions = false; - boolean folderExists = UserActionsPersistenceUtil.testUserActionsFolder(profile.getName(), ssFactory); - if (folderExists) { - String fileName = getFilePath(profile); - if (fileName != null) { - File file = new File(fileName); - if (file.canRead()) hasActions = true; - } - } - //System.out.println("Inside hasActions for SystemUDActionManager, for ssFactory "+ssFactory.getId()+": "+hasActions); - return hasActions; - } - /** * Return xml element wrapper objects for all actions, for the * given domain, or for the whole document if domain is -1 (iff @@ -219,7 +193,7 @@ public class SystemUDActionManager extends SystemUDBaseManager * Given an xml element node, create an instance of the appropriate * subclass of SystemXMLElementWrapper to represent it. */ - public SystemXMLElementWrapper createElementWrapper(Element xmlElementToWrap, ISystemProfile profile, int domain) { + public SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain) { SystemUDActionElement elementWrapper = new SystemUDActionElement(xmlElementToWrap, this, profile, domain); return elementWrapper; } diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java index ec87353bd31..e6442e02788 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java @@ -24,10 +24,10 @@ import java.util.List; import java.util.StringTokenizer; import java.util.Vector; -import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.IStructuredSelection; @@ -40,8 +40,6 @@ import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.ui.GenericMessages; -import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.ui.view.SystemTableViewProvider; import org.eclipse.rse.internal.useractions.UserActionsIcon; import org.eclipse.rse.internal.useractions.ui.ISystemSubstitutor; @@ -87,6 +85,7 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { protected SystemUDAResolvedTypes udaResolvedTypes; protected SystemUDActionElement currentAction; // current action being processed protected boolean testAction; // is current action the test action? + protected String osType = "default"; //$NON-NLS-1$ /** * Constructor @@ -120,7 +119,7 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { * @return translated label */ protected String getNewNodeActionLabel() { - return SystemResources.ACTION_CASCADING_NEW_LABEL; + return SystemUDAResources.ACTION_CASCADING_NEW_LABEL; } /** @@ -131,7 +130,7 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { * @return translated label */ protected String getNewNodeTypeLabel() { - return SystemResources.ACTION_CASCADING_NEW_LABEL; + return SystemUDAResources.ACTION_CASCADING_NEW_LABEL; } /** @@ -235,7 +234,7 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { * @param tv - the tree view if the parent is a dialog. * */ public SystemUDActionEditPane getCustomUDActionEditPane(ISubSystem ss, ISubSystemConfiguration ssFactory, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - return new SystemUDActionEditPane(ss, ssFactory, profile, parent, tv); + return new SystemUDActionEditPane(this, parent, tv); } /** @@ -257,30 +256,11 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { /** * Subclasses may override to provide a custom type edit pane subclass. * Subclasses should override if they want to return their own types pane. - * @param ss - the subsystem if you have it. If you don't have it, pass null. - * @param ssconfig - the subsystem factory, if you don't have the subsystem. - * @param profile - the subsystem factory, if you don't have the subsystem. * @param parent - the hosting dialog/property page * @param tv - the tree view if the parent is a dialog. */ - public SystemUDTypeEditPane getCustomUDTypeEditPane(ISubSystem ss, ISubSystemConfiguration ssconfig, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - return new SystemUDTypeEditPane(ss, ssconfig, profile, parent, tv); - } - - /** - * Historical. - * Now replaced with {@link #getCustomUDTypeEditPane(ISubSystem, ISubSystemConfiguration, ISystemProfile, ISystemUDAEditPaneHoster, ISystemUDTreeView)} - */ - protected final SystemUDTypeEditPane getCustomUDTypeEditPane(ISubSystem ss, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - return getCustomUDTypeEditPane(ss, null, null, parent, tv); - } - - /** - * Historical. - * Now replaced with {@link #getCustomUDTypeEditPane(ISubSystem, ISubSystemConfiguration, ISystemProfile, ISystemUDAEditPaneHoster, ISystemUDTreeView)} - */ - public SystemUDTypeEditPane getCustomUDTypeEditPane(ISubSystemConfiguration ssFactory, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { - return getCustomUDTypeEditPane(null, ssFactory, profile, parent, tv); + public SystemUDTypeEditPane getCustomUDTypeEditPane(ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { + return new SystemUDTypeEditPane(this, parent, tv); } // ************************************************************** @@ -364,7 +344,7 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { * @param viewer - the viewer we are running this from. Used to do the refresh if requested in this action. Can be null. */ public void run(Shell shell, SystemUDActionElement action, IStructuredSelection selection, ISystemResourceChangeListener viewer) { - Assert.isLegal(shell != null, "shell argument is null"); //$NON-NLS-1$ + //Assert.isLegal(shell != null, "shell argument is null"); //$NON-NLS-1$ processingSelection(true); Iterator elements = selection.iterator(); this.currentAction = action; @@ -500,7 +480,7 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { Thread.sleep(500L); } catch (Exception exc) { } // defect 46380: give action's command time to run? I don't know, but this works! - sr.fireEvent(viewer, new SystemResourceChangeEvent(sr, ISystemResourceChangeEvents.EVENT_REFRESH_SELECTED_PARENT, null)); + sr.fireEvent(viewer, new SystemResourceChangeEvent(sr, ISystemResourceChangeEvents.EVENT_REFRESH_REMOTE, null)); // todo! verify we are sending the right event! ok, done... its the right one. } if (testWriter != null && testFile != null) { @@ -769,7 +749,7 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { * If given a profile, the list is scoped to that, else it includes actions * for all active profiles. */ - public void addUserActions(IMenuManager menu, IStructuredSelection selection, ISystemProfile profile, Shell shell) { + public Action[] addUserActions(IMenuManager menu, IStructuredSelection selection, ISystemProfile profile, Shell shell) { // access UDA tree for this subsystem SystemUDActionManager actMgr = getUDActionManager(); // Go through each profile for this subsystem's factory @@ -781,28 +761,39 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { int domain = -1; if (supportsDomains()) { domain = getDomainFromSelection(selection); - if (domain == -1) return; + if (domain == -1) + return new Action[0]; } boolean multiSelection = (selection.size() != 1); + ArrayList actionList = new ArrayList(); for (int idx = 0; idx < profiles.length; idx++) { profile = profiles[idx]; - SystemUDActionElement[] actions = actMgr.getActions(null, profile, domain); + SystemUDActionElement[] actionElements = actMgr.getActions(null, profile, domain); // Scan UDA's for matching types and add to menu. // if any match, then create the initial UDA submenu cascade item - for (int i = 0; i < actions.length; i++) { - SystemUDActionElement action = actions[i]; - if (!action.getShow()) continue; - if (multiSelection && action.getSingleSelection()) continue; - if (supportsDomains() && (domain != action.getDomain())) continue; // newly added... we were getting file actions on folders - if (!supportsTypes() || meetsSelection(action, selection, domain)) { - SystemUDAsBaseAction uda = new SystemUDAsBaseAction(action, shell, this); + for (int i = 0; i < actionElements.length; i++) { + SystemUDActionElement actionElement = actionElements[i]; + if (!actionElement.getShow()) continue; + if (multiSelection && actionElement.getSingleSelection()) continue; + if (supportsDomains() && (domain != actionElement.getDomain())) continue; // newly added... we were getting file actions on folders + if (!supportsTypes() || meetsSelection(actionElement, selection, domain)) { + SystemUDAsBaseAction uda = new SystemUDAsBaseAction(actionElement, shell, this); uda.setSelection(selection); uda.setShell(shell); uda.setEnabled(!getWorkingOfflineMode()); - menu.add(uda); + actionList.add(uda); + if (null != menu) + { + menu.add(uda); + } + } } // end for-loop } // end for all profiles loop + Action[] list = (Action[])actionList.toArray(new Action[]{}); + + return list; + } /** @@ -1120,9 +1111,9 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { WorkbenchContentProvider cprovider = new WorkbenchContentProvider(); SystemTableViewProvider lprovider = new SystemTableViewProvider(); // TODO: Cannot use WorkbenchMessages -- it's internal - ListSelectionDialog dlg = new ListSelectionDialog(SystemBasePlugin.getActiveWorkbenchShell(), input, cprovider, lprovider, GenericMessages.EditorManager_saveResourcesMessage); + ListSelectionDialog dlg = new ListSelectionDialog(SystemBasePlugin.getActiveWorkbenchShell(), input, cprovider, lprovider, SystemUDAResources.EditorManager_saveResourcesMessage); dlg.setInitialSelections(input.getChildren()); - dlg.setTitle(GenericMessages.EditorManager_saveResourcesTitle); + dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle); int result = dlg.open(); //Just return false to prevent the operation continuing if (result == IDialogConstants.CANCEL_ID) return false; @@ -1144,4 +1135,9 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor { */ protected void processingSelection(boolean processingSelection) { } + + public String getOSType() + { + return osType; + } } diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionTreeView.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionTreeView.java index c7b2477b6e7..dd518a72c1b 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionTreeView.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionTreeView.java @@ -28,9 +28,8 @@ public class SystemUDActionTreeView extends SystemUDBaseTreeView { /** * Constructor when we have a subsystem */ - public SystemUDActionTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystem ss) { - // FIXME - UDA can't be coupled with subsystem API - super(parent, editPane, ss, /*ss.getUDActionSubsystem().getUDActionManager()*/null); + public SystemUDActionTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystem ss, SystemUDActionSubsystem udaActionSubsystem) { + super(parent, editPane, ss, udaActionSubsystem.getUDActionManager()); } /** diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java index d90ba1f4290..a671f8f8b60 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java @@ -11,32 +11,13 @@ * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands * API to the user actions plugin - * David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared *******************************************************************************/ package org.eclipse.rse.internal.useractions.ui.uda; -import java.io.File; -import java.io.FileOutputStream; import java.util.Hashtable; import java.util.Vector; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerFactoryConfigurationError; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; @@ -44,39 +25,25 @@ import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.osgi.util.NLS; import org.eclipse.rse.core.RSECorePlugin; -import org.eclipse.rse.core.SystemResourceHelpers; import org.eclipse.rse.core.SystemResourceManager; +import org.eclipse.rse.core.model.IPropertySet; +import org.eclipse.rse.core.model.IPropertySetContainer; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.ui.SystemResources; -import org.eclipse.rse.internal.useractions.Activator; -import org.eclipse.rse.internal.useractions.IUserActionsMessageIds; -import org.eclipse.rse.internal.useractions.UserActionsResources; -import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.ISystemMessages; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.rse.ui.messages.SystemMessageDialog; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.model.IWorkbenchAdapter; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; + /** * Instances of this class hold the UDA definitions unique to *
    @@ -96,7 +63,7 @@ import org.xml.sax.SAXParseException; * Architecturally, this class and the SystemXMLElementWrapper class * encapsulate all knowledge of the fact the underlying store is a xml document. */ -public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChangeListener, ISystemXMLElementWrapperFactory, ITreeContentProvider { +public abstract class SystemUDBaseManager implements IResourceChangeListener, ISystemXMLElementWrapperFactory, ITreeContentProvider { // state protected SystemUDActionSubsystem _udas; protected IFolder importCaseFolder; // Only set during Import processing @@ -109,13 +76,13 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan private Hashtable hasChangedByProfile; private Hashtable dirPathByProfile; // used by subclasses that are not profile-indexed - private Document udocNoProfile; + private IPropertySet udocNoProfile; private boolean hasChangedNoProfile = false; private Object[] dirPathNoProfile; // Profile for which we are working for actions for... private ISystemProfile currentlyActiveProfile; // set in UDA GUI // Clipboard copy/paste support - private Element currentNodeClone = null; + private IPropertySet currentNodeClone = null; private String currentNodeCloneID = ""; //$NON-NLS-1$ // private String currentNodeCloneName = ""; //$NON-NLS-1$ private int currentNodeCloneDomain = -1; @@ -167,7 +134,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Given an xml element node, create an instance of the appropriate * subclass of SystemXMLElementWrapper to represent it. */ - public abstract SystemXMLElementWrapper createElementWrapper(Element xmlElementToWrap, ISystemProfile profile, int domain); + public abstract SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain); // ----------------------------------------------------------- // ITREECONTENTPROVIDER METHODS... @@ -213,7 +180,17 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan if (!wrapper.isDomain()) return false; else - return (wrapper.getElement().getFirstChild() != null); + { + IPropertySet[] childrenPropertySet = wrapper.getElement().getPropertySets(); + if (childrenPropertySet == null || childrenPropertySet.length == 0) + { + return false; + } + else + { + return true; + } + } } else return false; } else if (element == null) { @@ -276,11 +253,11 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan */ public Vector getXMLWrappers(Vector children, Object parentOrDomain, ISystemProfile profile) { int domain = -1; - Element parentElement = null; + IPropertySet parentElement = null; if (parentOrDomain instanceof SystemXMLElementWrapper) { parentElement = ((SystemXMLElementWrapper) parentOrDomain).getElement(); domain = ((SystemXMLElementWrapper) parentOrDomain).getDomain(); - } else if (parentOrDomain instanceof Element) parentElement = (Element) parentOrDomain; + } else if (parentOrDomain instanceof IPropertySet) parentElement = (IPropertySet) parentOrDomain; children = SystemXMLElementWrapper.getChildren(children, parentElement, getDocument(profile), profile, this, domain); return children; } @@ -315,34 +292,6 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan */ } - /** - * Return name of the xml file used to persist the actions - */ - public abstract String getFileName(); - - /** - * Initialize a new document - */ - public Document initializeDocument() { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = null; - Document doc = null; - try { - builder = factory.newDocumentBuilder(); - } catch (ParserConfigurationException e) { - } - if (builder != null) { - doc = builder.newDocument(); - // Document doc= new DocumentImpl(); - // create root element. Eg or - Element root = doc.createElement(getDocumentRootTagName()); - // set current release as an attribute - root.setAttribute(ISystemUDAConstants.RELEASE_ATTR, CURRENT_RELEASE_NAME); - // assign root - doc.appendChild(root); // Add Root to Document - } - return doc; - } /** * Get the current subsystem. Will be null for import, or working in team view when @@ -365,113 +314,27 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan else return null; } + + - /** - * Get the path of the XML document containing the user actions, - * for the given profile (and current subsystem) - */ - protected String getFilePath(ISystemProfile profile) { - IFolder folder = getFolder(profile); - if (folder == null) return null; - String fn = folder.getLocation().toOSString() + File.separator + getFileName(); - // System.out.println("UD file: " + fn); - return fn; - } - - /** - * Build a vector of the folder names, in order, from workspace - * to our data file. Do once only. - * (To be used when resolving resource change events) - */ - private void resolveDirPath(ISystemProfile profile) { - // System.out.println("UD file:" ); - Vector dirFolder = new Vector(); - dirFolder.add(getFileName()); - IContainer folder = getFolder(profile); - while (folder != null) { - // Insert at start of vector - String s = folder.getName(); - // Workspace is empty string, dont add it - if (!"".equals(s)) //$NON-NLS-1$ - { - dirFolder.add(0, s); - // System.out.println("+" + s ); - } - folder = folder.getParent(); - } - Object[] dirPath = dirFolder.toArray(); - setProfileIndexedInstanceVariable_dirPath(profile, dirPath); - } /** * loadAndParseXMLFile: * tries to load and parse the specified XML file. - * @param fileName the name of xml file which will contain the messages * @param profile the profile in which the user defined actions are kept * @return the document containing the user defined actions */ - protected Document loadAndParseXMLFile(String fileName, ISystemProfile profile) { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder parser = null; - try { - parser = factory.newDocumentBuilder(); - } catch (ParserConfigurationException e) { - SystemBasePlugin.logError("SystemUDBaseManager: loadAndParseXMLFile, configuration not valid " + e.toString(), e); //$NON-NLS-1$ - return null; - } - // DOMParser parser = new DOMParser(); - parser.setErrorHandler(this); - try { - Document doc = parser.parse(fileName); - // verify the document is what we expect... - Element docroot = doc.getDocumentElement(); // get Root Element - // ?? Confirm root is XE_ROOT ?? - // ok, I took on the job of handling this. I also decided to put it - // here so we don't have this code scattered everywhere after calls to getDocument() - // Phil. 08/2002 - if ((null == docroot) || !docroot.getTagName().equals(getDocumentRootTagName())) { - Shell activeShell = getActiveShell(); - - - String oldFileName = getFilePath(profile); - String newFileName = getFileName() + ".bad"; //$NON-NLS-1$ - IFile file = getFolder(profile).getFile(getFileName()); - try { - SystemResourceHelpers.getResourceHelpers().renameFile(file, newFileName); - } catch (Exception exc) { - } - - - String msgTxt = NLS.bind(UserActionsResources.MSG_UDA_ROOTTAG_ERROR, getFilePath(profile)); - String msgDetails = NLS.bind(UserActionsResources.MSG_UDA_ROOTTAG_ERROR_DETAILS, getDocumentRootTagName(), newFileName); - - SystemMessage docRootMsg = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_UDA_ROOTTAG_ERROR, - IStatus.ERROR, msgTxt, msgDetails); + protected IPropertySet loadAndParseXMLFile(ISystemProfile profile) { + + String osType = _udas.getOSType(); + String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$ + IPropertySet userDefinedActionPropertySet = profile.getPropertySet(udaRootPropertySetName); + + return userDefinedActionPropertySet; - doc = createAndPrimeDocument(profile); - docRootMsg.makeSubstitution(oldFileName, getDocumentRootTagName(), newFileName); - SystemBasePlugin.logWarning(docRootMsg.getLevelOneText()); - if (activeShell != null) { - SystemMessageDialog.displayErrorMessage(activeShell, docRootMsg); - } - } - return doc; - } catch (Exception exc) { - // Provide a non-null value. Might as well prime - // with a "proper" doc structure. - Document doc = initializeDocument(); - - String msgTxt = NLS.bind(UserActionsResources.MSG_UDA_LOAD_ERROR, fileName); - SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, - IUserActionsMessageIds.MSG_UDA_LOAD_ERROR, - IStatus.ERROR, msgTxt, exc); - SystemMessageDialog msgdlg = new SystemMessageDialog(SystemBasePlugin.getActiveWorkbenchShell(), msg); - msgdlg.open(); - return doc; - } } + // ********************************************************** // ErrorHandler Interface: (XML SAX parsing) // ********************************************************** @@ -546,20 +409,15 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan ISystemProfile[] activeProfiles = getActiveSystemProfiles(); for (int idx = 0; idx < activeProfiles.length; idx++) { ISystemProfile profile = activeProfiles[idx]; - ensureDirPathResolved(profile); + //ensureDirPathResolved(profile); searchDelta(profile, delta, 0); } } else { - ensureDirPathResolved(null); + //ensureDirPathResolved(null); searchDelta(null, delta, 0); } } - private void ensureDirPathResolved(ISystemProfile profile) { - Object[] dirPath = getProfileIndexedInstanceVariable_dirPath(profile); - if (dirPath == null) resolveDirPath(profile); - } - private void searchDelta(ISystemProfile profile, IResourceDelta parent, int nestLevel) { Object[] dirPath = getProfileIndexedInstanceVariable_dirPath(profile); String target = (String) dirPath[nestLevel]; @@ -631,6 +489,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Get the release of the document. Eg, value of the "release"attribute of the root. * If not set then we assume it is release "4.0" */ + /* public String getDocumentRelease(ISystemProfile profile) { Document doc = getDocument(profile); Element root = doc.getDocumentElement(); @@ -640,17 +499,24 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan else return rel; } + */ /** * Load document for given SystemProfile only if not already done. */ - public Document getDocument(ISystemProfile profile) { - Document doc = getProfileIndexedInstanceVariable_Document(profile); + public IPropertySet getDocument(ISystemProfile profile) { + IPropertySet doc = getProfileIndexedInstanceVariable_Document(profile); if (doc == null) { doc = loadUserData(profile); + if (doc == null) + { + //No user action for this profile + return doc; + } setProfileIndexedInstanceVariable_Document(profile, doc); // document is good. Now, check the release date stamped on it. // if not the current release, then we must consider migration... + /* Element docroot = doc.getDocumentElement(); String docRelease = docroot.getAttribute(ISystemUDAConstants.RELEASE_ATTR); if ((docRelease == null) || (docRelease.length() == 0)) docRelease = "4.0"; //$NON-NLS-1$ @@ -663,8 +529,10 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan saveUserData(profile); } } + */ } else { } + return doc; } @@ -676,12 +544,6 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan */ protected abstract boolean doMigration(ISystemProfile profile, String oldRelease); - /** - * Get the active shell so we can show an error message - */ - private Shell getActiveShell() { - return Display.getCurrent().getActiveShell(); - } /** * Indicate the data has changed for the document for the given system profile @@ -707,32 +569,6 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan dataChanged(profile); } - /** - * Get the folder containing the xml file used to persist the actions, - * for the given profile - */ - private IFolder getFolder(ISystemProfile profile) { - ISubSystem subsystem = getSubSystem(); - // Import action: no subsystem - if ((subsystem == null) && (getSubSystemFactory() == null)) - return importCaseFolder; - else { - if ((profile == null) && (subsystem != null)) profile = subsystem.getSystemProfile(); - return getDocumentFolder(getSubSystemFactory(), profile); - } - } - - /** - * Get the folder containing the xml file used to persist the actions, - * for the given profile - */ - protected abstract IFolder getDocumentFolder(ISubSystemConfiguration subsystemFactory, ISystemProfile profile); - - /** - * Intended for IMPORT actions only, where no Subsystem instance available: - */ - public abstract void setFolder(String profileName, String factoryId); - /** * Indicate data has changed for the given profile */ @@ -742,10 +578,11 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan /** * Load the user actions from the XML document, for the given profile */ - protected Document loadUserData(ISystemProfile profile) { + protected IPropertySet loadUserData(ISystemProfile profile) { //System.out.println("UD load: " + getFileName() ); dataChanged(profile); // not sure why we call this, at this time!! Phil setProfileIndexedInstanceVariable_hasChanged(profile, false); + /* String fn = getFilePath(profile); Document doc = null; if (!(new File(fn)).canRead()) @@ -753,25 +590,49 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan else doc = loadAndParseXMLFile(fn, profile); //addListener(); - return doc; + */ + //We use PropertySet to store User Action instead. + //We need to get the compile command information from the system profile now. + //Get the propertySet first + String osType = _udas.getOSType(); + String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$ + IPropertySet udaRootPropertySet = profile.getPropertySet(udaRootPropertySetName); + if (null == udaRootPropertySet) + { + if (profile.isDefaultPrivate()) // we only prime the user's private profile with default compile commands + { + udaRootPropertySet = createAndPrimeDocument(profile); + } + } + else + { + udaRootPropertySet = loadAndParseXMLFile(profile); + } + return udaRootPropertySet; } /** * Create and prime the XML document */ - protected Document createAndPrimeDocument(ISystemProfile profile) { - Document doc = initializeDocument(); - setProfileIndexedInstanceVariable_Document(profile, doc); + protected IPropertySet createAndPrimeDocument(ISystemProfile profile) { + //Document doc = initializeDocument(); + //setProfileIndexedInstanceVariable_Document(profile, doc); SystemXMLElementWrapper[] primedElements = primeDocument(profile); if (primedElements != null) { for (int idx = 0; idx < primedElements.length; idx++) { SystemXMLElementWrapper newElement = primedElements[idx]; newElement.setIBM(true); - newElement.setUserChanged(false); + newElement.setUserChanged(true); } } saveUserData(profile); - return doc; + + String osType = _udas.getOSType(); + String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$ + IPropertySet userDefinedActionPropertySet = profile.getPropertySet(udaRootPropertySetName); + + return userDefinedActionPropertySet; + } /** @@ -783,108 +644,30 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan //System.out.println("UD save: No changes. " + getFileName() ); return; } - /* Old way of toggling off/on resource change monitoring wasnt working - for case of two connections with same subsystems with UDA data loaded, - and user changes UDA data in one. Change wasn't propagated to other, - which might later update the UDA file with old data. - - Better appraoch is to toggle my (ignoreMyResourceChange) flag around - my update, and check that flag in my resource change listener so that I - dont reload the data I just saved. (But other connection subsystem - instances do.) - */ - String fn = getFilePath(profile); - // Disable our resource change monitoring temporarily while we - // update the XML file - ignoreMyResourceChange = true; - SystemResourceManager.turnOffResourceEventListening(); - File xf = new File(fn); - if (!xf.getParentFile().exists()) // test added by Phil - { - xf.getParentFile().mkdirs(); // this is bad! Who refreshes from local? - try { // ok, now we do. I added this. Phil - getFolder(profile).getParent().refreshLocal(IResource.DEPTH_INFINITE, null); - } catch (Exception exc) { - } - } - Document udoc = getProfileIndexedInstanceVariable_Document(profile); - try // address various file I/O exceptions - { - FileOutputStream fo = new FileOutputStream(xf); - try { - Source source = new DOMSource(udoc); - Result result = new StreamResult(fo); - Transformer t = TransformerFactory.newInstance().newTransformer(); - t.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ - t.transform(source, result); - } catch (TransformerConfigurationException e) { - } catch (TransformerFactoryConfigurationError e) { - } catch (TransformerException e) { - } - // XMLSerializer xs = new XMLSerializer(fo, null); - // // Select "readable" format. (multiple lines) - // OutputFormat fmt = new OutputFormat(udoc); - // xs.setOutputFormat(fmt); - // fmt.setIndenting(true); - // fmt.setIndent(1); // 0 turns off indenting - // // Line width 300, so that we don't cut long comments/commands/actions at a certain length. - // fmt.setLineWidth(300); - // fmt.setPreserveSpace(true); - // xs.serialize(udoc); - // fo.close(); - // fo = null; - setProfileIndexedInstanceVariable_hasChanged(profile, false); - // Always refresh-from-local: - // If this saves, don't want next refresh-from-local to trigger - // a change event when we were the ones to change it. (and have the - // current data already loaded.) - // Refresh the workspace to recognise (new) file. - // getFolder().refreshLocal( IResource.DEPTH_ONE, null); - // A more specific refresh: - IFile file = getFolder(profile).getFile(getFileName()); - // file.touch(null); - file.refreshLocal(IResource.DEPTH_ONE, null); - } catch (Exception exc) { - // if (null != fo) - // fo.close(); - SystemMessageDialog msgdlg = new SystemMessageDialog(SystemBasePlugin.getActiveWorkbenchShell(), RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_SAVE_FAILED).makeSubstitution(exc)); - msgdlg.open(); - } + profile.commit(); ignoreMyResourceChange = false; SystemResourceManager.turnOnResourceEventListening(); } - /** - * Refresh the xml file from disk. Eg equivalent to use selecting Refresh. - */ - public void refreshLocal(ISystemProfile profile) { - try { - IFile file = getFolder(profile).getFile(getFileName()); - file.touch(null); - file.refreshLocal(IResource.DEPTH_ONE, null); - } catch (Exception e) { - SystemBasePlugin.logError("Error refreshing in SystemUDBaseManager.", e); //$NON-NLS-1$ - } - } - /** * Move given element down one in document, save document * @return true if move successful */ - public boolean moveElementDown(SystemXMLElementWrapper elementWrapper, SystemXMLElementWrapper nextNextElementWrapper) { + public boolean moveElementDown(SystemXMLElementWrapper elementWrapper/*, SystemXMLElementWrapper nextNextElementWrapper*/) { getDocument(elementWrapper.getProfile()); - Element element = elementWrapper.getElement(); - try { - Node parentElement = element.getParentNode(); - //Node nextElement = element.getNextSibling(); - //Node nextNextElement = nextElement.getNextSibling(); - if (nextNextElementWrapper != null) - parentElement.insertBefore(element, nextNextElementWrapper.getElement()); - else - parentElement.insertBefore(element, null); - } catch (Exception exc) { - SystemBasePlugin.logError("Error moving user action/type down", exc); //$NON-NLS-1$ - return false; + IPropertySet element = elementWrapper.getElement(); + IPropertySetContainer parentElement = element.getContainer(); + IPropertySet[] allChildren = parentElement.getPropertySets(); + for (int i = 0; i < allChildren.length; ++i) + { + if (allChildren[i] == element) + { + if (i < allChildren.length - 1) //not the last one + { + allChildren[i] = allChildren[i+1]; + allChildren[i+1] = element; + } + } } saveUserData(elementWrapper.getProfile()); return true; @@ -894,16 +677,21 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Move given element up one in document, save document * @return true if move successful */ - public boolean moveElementUp(SystemXMLElementWrapper elementWrapper, SystemXMLElementWrapper previousElementWrapper) { + public boolean moveElementUp(SystemXMLElementWrapper elementWrapper/*, SystemXMLElementWrapper previousElementWrapper*/) { getDocument(elementWrapper.getProfile()); - Element element = elementWrapper.getElement(); - try { - Node parentElement = element.getParentNode(); - //Node previousElement = element.getPreviousSibling(); - parentElement.insertBefore(element, previousElementWrapper.getElement()); - } catch (Exception exc) { - SystemBasePlugin.logError("Error moving user action/type up", exc); //$NON-NLS-1$ - return false; + IPropertySet element = elementWrapper.getElement(); + IPropertySetContainer parentElement = element.getContainer(); + IPropertySet[] allChildren = parentElement.getPropertySets(); + for (int i = 0; i < allChildren.length; ++i) + { + if (allChildren[i] == element) + { + if (i > 0) //not the first one + { + allChildren[i] = allChildren[i-1]; + allChildren[i-1] = element; + } + } } saveUserData(elementWrapper.getProfile()); return true; @@ -916,6 +704,8 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * if the reference in the clipboard corresponds to a node clone in this object. * @return an id that uniquely identifies the cloned node, or null if it failed. */ + //TODO - XUAN + /* public String prepareClipboardCopy(SystemXMLElementWrapper elementWrapper) { getDocument(elementWrapper.getProfile()); Element element = elementWrapper.getElement(); @@ -933,6 +723,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan // currentNodeCloneName = elementWrapper.getName(); return currentNodeCloneID; } + */ /** * Test if the given ID, read from the clipboard, matches a node we prepared for @@ -953,17 +744,20 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan */ public SystemXMLElementWrapper pasteClipboardCopy(SystemXMLElementWrapper selectedElementWrapper, String id) { getDocument(selectedElementWrapper.getProfile()); - Element selectedElement = selectedElementWrapper.getElement(); + IPropertySet selectedElement = selectedElementWrapper.getElement(); SystemXMLElementWrapper pastedElementWrapper = null; try { - Node parentElement = null; - Element pastedElement = null; + IPropertySetContainer parentElement = null; + IPropertySet pastedElement = null; if (selectedElementWrapper.isDomain()) { parentElement = selectedElement; - pastedElement = (Element) parentElement.appendChild(currentNodeClone); + parentElement.addPropertySet(currentNodeClone); + pastedElement = currentNodeClone; } else { - parentElement = selectedElement.getParentNode(); - pastedElement = (Element) parentElement.insertBefore(currentNodeClone, selectedElement); + parentElement = selectedElement.getContainer(); + //TODO - Xuan: need to take care of order here. + parentElement.addPropertySet(currentNodeClone); + pastedElement = currentNodeClone; } pastedElementWrapper = createElementWrapper(pastedElement, selectedElementWrapper.getProfile(), selectedElementWrapper.getDomain()); pastedElementWrapper.setName(getUniqueCloneName(pastedElementWrapper)); @@ -1007,6 +801,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Returns root elements for the currently set profile (see setCurrentProfile). * If this is null, returns root elements for all active profiles */ + public Object[] getElements(Object element) { if (!supportsProfiles()) return getElements((ISystemProfile) null, element); @@ -1018,6 +813,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan return getElements(getActiveSystemProfiles(), element); } } + /** * Return root elements for given profile. @@ -1062,7 +858,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan // if domains not supported, return singleton New item, plus wrappers // of any action/type elements found else { - Element parentDomainElement = null; + IPropertySetContainer parentDomainElement = null; if (onlyDomain == -1) v.add(SystemUDTreeViewNewItem.getOnlyNewItem(isUserActionsManager(), getNewNodeLabel())); else @@ -1089,7 +885,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * @return translated value for "New" in new icon. Default is "New" */ protected String getNewNodeLabel() { - return SystemResources.ACTION_CASCADING_NEW_LABEL; + return SystemUDAResources.ACTION_CASCADING_NEW_LABEL; } /** @@ -1143,10 +939,10 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Find a child element of a given name. * Returns the xml node element or null */ - public Element findChildByName(ISystemProfile profile, String name, int domain) { - Document xdoc = getDocument(profile); + public IPropertySet findChildByName(ISystemProfile profile, String name, int domain) { + IPropertySet xdoc = getDocument(profile); if (getActionSubSystem().supportsDomains() && (domain >= 0)) { - Element domainElement = findDomainElement(xdoc, domain); + IPropertySet domainElement = findDomainElement(xdoc, domain); return SystemXMLElementWrapper.findChildByName(domainElement, xdoc, getTagName(), name); } else { return SystemXMLElementWrapper.findChildByName(null, xdoc, getTagName(), name); @@ -1158,7 +954,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Returns the wrapper of the xml node element or null */ public SystemXMLElementWrapper findByName(ISystemProfile profile, String name, int domain) { - Element element = findChildByName(profile, name, domain); + IPropertySet element = findChildByName(profile, name, domain); if (element == null) return null; else @@ -1169,9 +965,9 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Get a list of existing names, for unique-name checking. */ public Vector getExistingNames(ISystemProfile profile, int domain) { - Document xdoc = getDocument(profile); + IPropertySet xdoc = getDocument(profile); if (getActionSubSystem().supportsDomains() && (domain >= 0)) { - Element domainElement = findDomainElement(xdoc, domain); + IPropertySet domainElement = findDomainElement(xdoc, domain); if (domainElement == null) return new Vector(); // defect 46147 return SystemXMLElementWrapper.getExistingNames(domainElement, xdoc, getTagName()); } else { @@ -1185,17 +981,34 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * and creates and returns a wrapper object for it. */ public SystemXMLElementWrapper addElement(ISystemProfile profile, int domain, String name) { - Document xdoc = getDocument(profile); - SystemXMLElementWrapper newElementWrapper = null; - Element newtag = xdoc.createElement(getTagName()); - newtag.setAttribute("Name", uppercaseName() ? name.toUpperCase() : name); //$NON-NLS-1$ + + String osType = _udas.getOSType(); + String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$ + //String userDefinedActionPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType; + //ISystemProfile systemProfile = SystemRegistry.getInstance().getSystemProfile(profile.getName()); + IPropertySet udaRootPropertySet = profile.getPropertySet(udaRootPropertySetName); + if (udaRootPropertySet == null) + { + udaRootPropertySet = profile.createPropertySet(udaRootPropertySetName); + udaRootPropertySet.addProperty(ISystemUDAConstants.RELEASE_ATTR, CURRENT_RELEASE_NAME); + udaRootPropertySet.addProperty(ISystemUDAConstants.UDA_ROOT_ATTR, getDocumentRootTagName()); + } + IPropertySet child = null; // Get domain element, create if necessary - if (getActionSubSystem().supportsDomains()) { - Element se = findOrCreateDomainElement(xdoc, domain); - se.appendChild(newtag); - } else - xdoc.getDocumentElement().appendChild(newtag); - newElementWrapper = createElementWrapper(newtag, profile, domain); + if (getActionSubSystem().supportsDomains()) + { + IPropertySet se = findOrCreateDomainElement(udaRootPropertySet, domain); + child = se.createPropertySet(name); + } + else + { + child = udaRootPropertySet.createPropertySet(name); + } + child.addProperty(ISystemUDAConstants.NAME_ATTR, uppercaseName() ? name.toUpperCase() : name); + child.addProperty(ISystemUDAConstants.TYPE_ATTR, getTagName()); + SystemXMLElementWrapper newElementWrapper = null; + + newElementWrapper = createElementWrapper(child, profile, domain); setChanged(profile); return newElementWrapper; } @@ -1215,7 +1028,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan /** * Set the profile-indexed document instance variable */ - private void setProfileIndexedInstanceVariable_Document(ISystemProfile profile, Document doc) { + private void setProfileIndexedInstanceVariable_Document(ISystemProfile profile, IPropertySet doc) { if (!supportsProfiles()) udocNoProfile = doc; else @@ -1225,11 +1038,11 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan /** * Get the profile-indexed document instance variable */ - private Document getProfileIndexedInstanceVariable_Document(ISystemProfile profile) { + private IPropertySet getProfileIndexedInstanceVariable_Document(ISystemProfile profile) { if (!supportsProfiles()) return udocNoProfile; else - return (Document) udocsByProfile.get(profile); + return (IPropertySet) udocsByProfile.get(profile); } /** @@ -1261,16 +1074,6 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan } } - /** - * Set the profile-indexed dir-path instance variable - */ - private void setProfileIndexedInstanceVariable_dirPath(ISystemProfile profile, Object[] dirPath) { - if (!supportsProfiles()) - dirPathNoProfile = dirPath; - else - dirPathByProfile.put(profile, dirPath); - } - /** * Get the dir-path has-changed instance variable */ @@ -1290,7 +1093,12 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * returns null */ protected SystemXMLElementWrapper getDomainWrapper(ISystemProfile profile, int domain) { - Element element = findDomainElement(getDocument(profile), domain); + IPropertySet udaRootPropertySet = getDocument(profile); + if (udaRootPropertySet == null) + { + return null; + } + IPropertySet element = findDomainElement(getDocument(profile), domain); if (element != null) return createDomainElementWrapper(element, profile, domain); else @@ -1305,23 +1113,20 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * not the order they are found in the document! */ protected Vector createExistingDomainElementWrappers(Vector v, ISystemProfile profile) { - Document xdoc = getDocument(profile); - Element docroot = xdoc.getDocumentElement(); + IPropertySet xdoc = getDocument(profile); // get the "domain" children of the root, in the pre-determined order of domains - NodeList subList = docroot.getChildNodes(); - if ((subList == null) || (subList.getLength() == 0)) return v; + IPropertySet[] subList = xdoc.getPropertySets(); + if ((subList == null) || (subList.length == 0)) return v; String[] domains = getActionSubSystem().getDomainNames(); - int subListLen = subList.getLength(); + int subListLen = subList.length; for (int idx = 0; idx < domains.length; idx++) { - Element match = null; + IPropertySet match = null; for (int jdx = 0; (match == null) && (jdx < subListLen); jdx++) { - Node currNode = subList.item(jdx); - if ((currNode instanceof Element) && - // is "Domain" tag, and "Type" attr value matches domains[idx]? - isDomainElement((Element) currNode, domains[idx])) { + IPropertySet currNode = subList[jdx]; + if (isDomainElement(currNode, domains[idx])) { //Element currElement = (Element)currNode; //if (currElement.getAttribute(XE_DOMTYPE).equals(domains[idx])) - match = (Element) currNode; + match = currNode; } } if (match != null) v.add(createDomainElementWrapper(match, profile, idx)); @@ -1332,7 +1137,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan /** * Create a domain element wrapper */ - protected SystemXMLElementWrapper createDomainElementWrapper(Element xmlDomainElementToWrap, ISystemProfile profile, int domain) { + protected SystemXMLElementWrapper createDomainElementWrapper(IPropertySet xmlDomainElementToWrap, ISystemProfile profile, int domain) { return createElementWrapper(xmlDomainElementToWrap, profile, domain); } @@ -1340,7 +1145,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Given an xml action/type document, try to find a domain element ("Domain" tag) * of the given domain type. If not found, do NOT create it. */ - protected Element findDomainElement(Document xdoc, int domain) { + protected IPropertySet findDomainElement(IPropertySet xdoc, int domain) { return findOrCreateDomainElement(xdoc, domain, false); } @@ -1348,7 +1153,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Given an xml action/type document, try to find a domain element ("Domain" tag) * of the given untranslated name ("Type" attribute). If not found, create it. */ - protected Element findOrCreateDomainElement(Document xdoc, int domain) { + protected IPropertySet findOrCreateDomainElement(IPropertySet xdoc, int domain) { return findOrCreateDomainElement(xdoc, domain, true); } @@ -1356,7 +1161,25 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Given an xml action/type document, try to find a domain element ("Domain" tag) * of the given untranslated name ("Type" attribute). If not found, optionally create it. */ - protected Element findOrCreateDomainElement(Document xdoc, int domain, boolean create) { + protected IPropertySet findOrCreateDomainElement(IPropertySet xdoc, int domain, boolean create) { + + IPropertySet[] domainSets = xdoc.getPropertySets(); + String domainName = getActionSubSystem().mapDomainName(domain); // unxlated name. Eg "Type" parm + IPropertySet domainElement = null; + for (int i = 0; i < domainSets.length; i++) + { + IPropertySet thisDomain = domainSets[i]; + if (null != thisDomain) + { + if (isDomainElement(thisDomain, domainName)) + { + domainElement = thisDomain; + } + } + + } + + /* NodeList subList = xdoc.getDocumentElement().getChildNodes(); String domainName = getActionSubSystem().mapDomainName(domain); // unxlated name. Eg "Type" parm Element domainElement = null; @@ -1368,6 +1191,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan } } } + */ if (create && (domainElement == null)) domainElement = createDomainElement(xdoc, domain); return domainElement; } @@ -1377,11 +1201,11 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * @param xdoc - the document to add it to. Will be added as child of root * @param domain - the integer representation of the domain, used to get its name and translated name */ - protected Element createDomainElement(Document xdoc, int domain) { - Element element = xdoc.createElement(ISystemUDAConstants.XE_DOMAIN); - xdoc.getDocumentElement().appendChild(element); - element.setAttribute(ISystemUDAConstants.XE_DOMTYPE, getActionSubSystem().mapDomainName(domain)); - element.setAttribute(ISystemUDAConstants.XE_DOMNAME, getActionSubSystem().mapDomainXlatedName(domain)); + protected IPropertySet createDomainElement(IPropertySet xdoc, int domain) { + IPropertySet element = xdoc.createPropertySet(getActionSubSystem().mapDomainXlatedName(domain)); + element.addProperty(ISystemUDAConstants.XE_DOMTYPE, getActionSubSystem().mapDomainName(domain)); + element.addProperty(ISystemUDAConstants.XE_DOMNAME, getActionSubSystem().mapDomainXlatedName(domain)); + element.addProperty(ISystemUDAConstants.TYPE_ATTR, ISystemUDAConstants.XE_DOMAIN); return element; } @@ -1392,15 +1216,15 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Given an xml Element object, return true if it is a Domain * element. That is, if its tag name is "Domain" */ - public static boolean isDomainElement(Element element) { - return (element.getTagName().equals(ISystemUDAConstants.XE_DOMAIN)); + public static boolean isDomainElement(IPropertySet element) { + return (element.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(ISystemUDAConstants.XE_DOMAIN)); } /** * Given an xml Element object, return true if it is a Domain * element and its "Type" attribute matches the given name. */ - public static boolean isDomainElement(Element element, String domainName) { + public static boolean isDomainElement(IPropertySet element, String domainName) { return isDomainElement(element) && domainTypeEquals(element, domainName); } @@ -1408,8 +1232,8 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Given an xml Domain element, return true if it's "type" attribute matches * the given untranslated domain name */ - public static boolean domainTypeEquals(Element element, String domainName) { - return (element.getAttribute(ISystemUDAConstants.XE_DOMTYPE).equals(domainName)); + public static boolean domainTypeEquals(IPropertySet element, String domainName) { + return (element.getPropertyValue(ISystemUDAConstants.XE_DOMTYPE).equals(domainName)); } /** @@ -1423,17 +1247,32 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan * Do so by traversing the tree backwards, back to the Document root, * then forwards again to verify the child links are in place. */ - public static boolean inCurrentTree(Node n) { - if (n instanceof Document) return true; - Node parent = n.getParentNode(); + public static boolean inCurrentTree(IPropertySet n) { + String udaRootType = n.getPropertyValue(ISystemUDAConstants.UDA_ROOT_ATTR); + if (udaRootType != null && (udaRootType.equals(ISystemUDAConstants.ACTIONS_ROOT) || udaRootType.equals(ISystemUDAConstants.FILETYPES_ROOT))) + { + //It is one of the UDA related root. + return true; + } + IPropertySetContainer parent = n.getContainer(); if (null == parent) return false; // Recursive, walk tree back to root, then finally Document. - if (!inCurrentTree(parent)) return false; + if (parent instanceof IPropertySet) + { + if (!inCurrentTree((IPropertySet)parent)) return false; + } + else + { + return false; + } // Finally, check this is still a child of the parent - Node sibling = parent.getFirstChild(); - while (null != sibling) { - if (n == sibling) return true; - sibling = sibling.getNextSibling(); + IPropertySet[] siblings = parent.getPropertySets(); + for (int i=0; i= 0); + return (types.indexOf(type.getId()) >= 0); } } } diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDAsDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDAsDialog.java index c45a0faf77d..d90aecf9a60 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDAsDialog.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDAsDialog.java @@ -16,7 +16,6 @@ import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.dialogs.SystemPromptDialog; @@ -56,6 +55,7 @@ public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISys // inputs protected ISubSystem subsystem; protected ISubSystemConfiguration subsystemFactory; + protected SystemUDActionSubsystem udaActionSubsystem; //protected String defaultProfileName; //protected String[] defaultProfileNames; protected ISystemProfile[] systemProfiles; @@ -68,13 +68,14 @@ public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISys /** * Constructor when we have a subsystem */ - public SystemWorkWithUDAsDialog(Shell shell, ISubSystem ss) { + public SystemWorkWithUDAsDialog(Shell shell, ISubSystem ss, SystemUDActionSubsystem udaActionSubsystem) { super(shell, SystemUDAResources.RESID_WORKWITH_UDAS_TITLE); - setCancelButtonLabel(SystemResources.BUTTON_CLOSE); + setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE); setShowOkButton(false); this.shell = shell; this.subsystem = ss; this.subsystemFactory = ss.getSubSystemConfiguration(); + this.udaActionSubsystem = udaActionSubsystem; setProfiles(RSECorePlugin.getTheSystemProfileManager().getActiveSystemProfiles(), subsystem.getSystemProfile()); //setMinimumSize(600, 520); // x, y //pack(); @@ -84,12 +85,13 @@ public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISys /** * Constructor when we have a subsystem factory */ - public SystemWorkWithUDAsDialog(Shell shell, ISubSystemConfiguration ssFactory, ISystemProfile profile) { + public SystemWorkWithUDAsDialog(Shell shell, ISubSystemConfiguration ssFactory, ISystemProfile profile, SystemUDActionSubsystem udaActionSubsystem) { super(shell, SystemUDAResources.RESID_WORKWITH_UDAS_TITLE); - setCancelButtonLabel(SystemResources.BUTTON_CLOSE); + setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE); setShowOkButton(false); this.shell = shell; this.subsystemFactory = ssFactory; + this.udaActionSubsystem = udaActionSubsystem; setProfiles(RSECorePlugin.getTheSystemProfileManager().getActiveSystemProfiles(), profile); //setMinimumSize(600, 520); // x, y //pack(); @@ -126,15 +128,7 @@ public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISys * Return the user defined action subsystem */ protected SystemUDActionSubsystem getUDActionSubsystem() { - /* FIXME - UDA not coupled with subsystem API anymore - if (subsystem!=null) - return subsystem.getUDActionSubsystem(); - else - { - return ((ISubsystemFactoryAdapter)subsystemFactory.getAdapter(ISubsystemFactoryAdapter.class)).getActionSubSystem(subsystemFactory, null); - } - */ - return null; + return udaActionSubsystem; } /** @@ -155,9 +149,12 @@ public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISys getUDActionSubsystem().getUDActionManager().setCurrentProfile(currentProfile); // create tree view on left if (subsystem != null) - treeView = new SystemUDActionTreeView(composite, this, subsystem); + treeView = new SystemUDActionTreeView(composite, this, subsystem, udaActionSubsystem); else - treeView = new SystemUDActionTreeView(composite, this, subsystemFactory, currentProfile); + { + // FIXME - Xuan + //treeView = new SystemUDActionTreeView(composite, this, subsystemFactory, currentProfile); + } Control c = treeView.getControl(); //c.setToolTipText(RSEUIPlugin.getString(RESID_UDA_TREE_TIP)); GridData data = (GridData) c.getLayoutData(); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDTypeDialog.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDTypeDialog.java index af09cc5d4cf..a12523d4238 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDTypeDialog.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemWorkWithUDTypeDialog.java @@ -17,7 +17,6 @@ import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.dialogs.SystemPromptDialog; @@ -41,6 +40,7 @@ import org.eclipse.swt.widgets.Widget; public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements ISystemUDWorkWithDialog, Listener, Runnable, ISystemUDAEditPaneHoster { protected Shell shell; // shell hosting this viewer protected ResourceBundle rb; + protected SystemUDActionSubsystem udaActionSubsystem; protected ISubSystem subsystem; protected ISubSystemConfiguration subsystemFactory; protected ISystemProfile profile; @@ -58,11 +58,12 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS /** * Constructor when we have a subsystem */ - public SystemWorkWithUDTypeDialog(Shell shell, ISubSystem ss) { + public SystemWorkWithUDTypeDialog(Shell shell, ISubSystem ss, SystemUDActionSubsystem udaActionSubsystem) { super(shell, SystemUDAResources.RESID_WORKWITH_UDT_TITLE); - setCancelButtonLabel(SystemResources.BUTTON_CLOSE); + setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE); setShowOkButton(false); this.shell = shell; + this.udaActionSubsystem = udaActionSubsystem; this.subsystem = ss; this.subsystemFactory = subsystem.getSubSystemConfiguration(); this.profile = subsystem.getSystemProfile(); @@ -76,7 +77,7 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS */ public SystemWorkWithUDTypeDialog(Shell shell, ISubSystemConfiguration ssFactory, ISystemProfile profile) { super(shell, SystemUDAResources.RESID_WORKWITH_UDT_TITLE); - setCancelButtonLabel(SystemResources.BUTTON_CLOSE); + setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE); setShowOkButton(false); this.shell = shell; this.subsystemFactory = ssFactory; @@ -119,7 +120,7 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS Composite composite = SystemWidgetHelpers.createComposite(parent, nbrColumns); // create tree view on left if (subsystem != null) - treeView = new SystemUDTypeTreeView(composite, this, subsystem); + treeView = new SystemUDTypeTreeView(composite, this, subsystem, udaActionSubsystem); else treeView = new SystemUDTypeTreeView(composite, this, subsystemFactory, profile); Control c = treeView.getControl(); @@ -143,7 +144,7 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS // editpane = getUDActionSubsystem().getCustomUDTypeEditPane( subsystem, this, treeView); //else // editpane = getUDActionSubsystem().getCustomUDTypeEditPane( subsystemFactory, profile, this, treeView); - editpane = getUDActionSubsystem().getCustomUDTypeEditPane(subsystem, subsystemFactory, profile, this, treeView); + editpane = getUDActionSubsystem().getCustomUDTypeEditPane(this, treeView); editpane.createContents(rightSideComposite); // now add a visual separator line addSeparatorLine(rightSideComposite, 1); @@ -176,7 +177,10 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS } // add listeners, after expansion... treeView.addSelectionChangedListener(editpane); - type = (SystemUDTypeElement) udtm.findByName(null, typeToPreSelect, preSelectTypeDomain); + if (subsystem != null) + { + type = (SystemUDTypeElement) udtm.findByName(subsystem.getSystemProfile(), typeToPreSelect, preSelectTypeDomain); + } if (type != null) objectToPreSelect = type; } else { //treeView.expandDomainNodes(); @@ -201,16 +205,7 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS * Return the user defined action subsystem */ protected SystemUDActionSubsystem getUDActionSubsystem() { - /* FIXME - UDA not coupled with subsystem API anymore - if (subsystem!=null) - return subsystem.getUDActionSubsystem(); - else - { - return ((ISubsystemFactoryAdapter)subsystemFactory.getAdapter(ISubsystemFactoryAdapter.class)).getActionSubSystem(subsystemFactory, null); - - } - */ - return null; + return udaActionSubsystem; } /** diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemXMLElementWrapper.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemXMLElementWrapper.java index 4243199ab9b..cf67a7987e7 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemXMLElementWrapper.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemXMLElementWrapper.java @@ -16,43 +16,41 @@ import java.util.Vector; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; +import org.eclipse.rse.core.model.IProperty; +import org.eclipse.rse.core.model.IPropertySet; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.swt.graphics.Image; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; + /** - * This is a base class for classes that wrapper xml elements. - * Eg, there are child classes to represent action xml elements, and - * type xml elements. + * This is a base class for classes that wrapper UDA elements. + * Eg, there are child classes to represent action UDA elements, and + * type UDA elements. */ public abstract class SystemXMLElementWrapper implements IAdaptable { //parameters - protected Element elm; + protected IPropertySet elm; private boolean isDomainElement; private SystemUDBaseManager database; // For setChanged() private ISystemProfile profile; private int domainType; // constants /** - * What we store in XML document for TRUE + * What we store in UDA document for TRUE */ - private static final String XML_TRUE = "True"; //$NON-NLS-1$ + private static final String UDA_TRUE = "True"; //$NON-NLS-1$ /** - * What we store in XML document for FALSE + * What we store in UDA document for FALSE */ - private static final String XML_FALSE = "False"; //$NON-NLS-1$ + private static final String UDA_FALSE = "False"; //$NON-NLS-1$ /** * The XML attribute name for the "IBM-Supplied" attribute */ - private static final String XML_ATTR_VENDOR = "Vendor"; //$NON-NLS-1$ + private static final String UDA_ATTR_VENDOR = "Vendor"; //$NON-NLS-1$ /** * The XML attribute name for the "User-Changed" attribute */ - private static final String XML_ATTR_CHANGED = "UserChanged"; //$NON-NLS-1$ + private static final String UDA_ATTR_CHANGED = "UserChanged"; //$NON-NLS-1$ /** * The value we place in the Vendor attribute for IBM-supplied actions/types */ @@ -60,15 +58,15 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { /** * Constructor - * @param elm - The actual xml document element for this action/type + * @param elm - The actual UDA element for this action/type * @param mgr - The parent manager of these actions/types * @param profile - The system profile which owns this action * @param domainType - The integer representation of the domain this is in (or this is, for a domain element) */ - public SystemXMLElementWrapper(Element elm, SystemUDBaseManager mgr, ISystemProfile profile, int domainType) { + public SystemXMLElementWrapper(IPropertySet elm, SystemUDBaseManager mgr, ISystemProfile profile, int domainType) { super(); this.elm = elm; - this.isDomainElement = elm.getTagName().equals(ISystemUDAConstants.XE_DOMAIN); + this.isDomainElement = elm.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(ISystemUDAConstants.XE_DOMAIN); this.domainType = domainType; database = mgr; this.profile = profile; @@ -115,41 +113,41 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { } /** - * Get the XML document element this node wraps + * Get the UDA element this node wraps */ - public Element getElement() { + public IPropertySet getElement() { return elm; } /** * Get the document this element is a part of */ - public Document getDocument() { + public IPropertySet getDocument() { // this method added by phil. // this allows getChildren in xxxmanager classes to avoid deducing the document - return elm.getOwnerDocument(); + return (IPropertySet)elm.getContainer(); } /** - * Get the parent xml domain element of this element. + * Get the parent UDA element of this element. * If domains aren't supported, this will return null */ - public Element getParentDomainElement() { - Element parent = getParentElement(); - if ((parent != null) && parent.getTagName().equals(ISystemUDAConstants.XE_DOMAIN)) + public IPropertySet getParentDomainElement() { + IPropertySet parent = getParentElement(); + if ((parent != null) && parent.getPropertyValue(ISystemUDAConstants.NAME_ATTR).equals(ISystemUDAConstants.XE_DOMAIN)) return parent; else return null; } /** - * Get the parent xml element of this element. + * Get the parent UDA element of this element. * Only returns null if this is the root, which should never happen. */ - public Element getParentElement() { - Node parent = elm.getParentNode(); - if (parent instanceof Element) - return (Element) parent; + public IPropertySet getParentElement() { + Object parent = elm.getContainer(); + if (parent instanceof IPropertySet) + return (IPropertySet) parent; else return null; } @@ -174,7 +172,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * Return the value of this node's "Name" attribute */ public String getName() { - return elm.getAttribute(ISystemUDAConstants.NAME_ATTR); + return elm.getPropertyValue(ISystemUDAConstants.NAME_ATTR); } /** @@ -184,11 +182,22 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { */ public void setName(String s) { if (isIBM()) { - String orgName = elm.getAttribute(ISystemUDAConstants.ORIGINAL_NAME_ATTR); + String orgName = elm.getPropertyValue(ISystemUDAConstants.ORIGINAL_NAME_ATTR); if ((orgName != null) && (orgName.length() > 0)) { // no need to do anything, as its already set. - } else - elm.setAttribute(ISystemUDAConstants.ORIGINAL_NAME_ATTR, getName()); + } + else + { + IProperty property = elm.getProperty(ISystemUDAConstants.ORIGINAL_NAME_ATTR); + if (null == property) + { + elm.addProperty(ISystemUDAConstants.ORIGINAL_NAME_ATTR, getName()); + } + else + { + property.setValue(getName()); + } + } } setAttribute(ISystemUDAConstants.NAME_ATTR, s); setUserChanged(true); @@ -198,7 +207,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * For IBM-supplied elements that have been edited, returns the original IBM-supplied name */ public String getOriginalName() { - String s = elm.getAttribute(ISystemUDAConstants.ORIGINAL_NAME_ATTR); + String s = elm.getPropertyValue(ISystemUDAConstants.ORIGINAL_NAME_ATTR); if ((s == null) || (s.length() == 0)) return getName(); else @@ -210,7 +219,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * That is, is this an IBM-supplied tag? */ public boolean isIBM() { - String vendor = elm.getAttribute(XML_ATTR_VENDOR); + String vendor = elm.getPropertyValue(UDA_ATTR_VENDOR); if (vendor == null) return false; else @@ -221,7 +230,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * Set the name of the vendor who supplied this user action or type */ public void setVendor(String vendor) { - setAttribute(XML_ATTR_VENDOR, vendor); + setAttribute(UDA_ATTR_VENDOR, vendor); } /** @@ -229,7 +238,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * May be null, if created by a user */ public String getVendor() { - return elm.getAttribute(XML_ATTR_VENDOR); + return elm.getPropertyValue(UDA_ATTR_VENDOR); } /** @@ -238,9 +247,9 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { */ public void setIBM(boolean isFromIBM) { if (isFromIBM) - setAttribute(XML_ATTR_VENDOR, VENDOR_IBM); + setAttribute(UDA_ATTR_VENDOR, VENDOR_IBM); else - setAttribute(XML_ATTR_VENDOR, null); + setAttribute(UDA_ATTR_VENDOR, null); } /** @@ -254,7 +263,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { else if (isDomainElement) changed = false; else - changed = getBooleanAttribute(XML_ATTR_CHANGED, false); + changed = getBooleanAttribute(UDA_ATTR_CHANGED, false); //System.out.println("Inside isUserChanged, returning "+changed+": isIBM()="+isIBM()+", isDomainElement="+isDomainElement); return changed; } @@ -263,7 +272,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * Set the value of this tag's "user-changed" attribute */ public void setUserChanged(boolean isUserChanged) { - if (isIBM() && !isDomainElement) setBooleanAttribute(XML_ATTR_CHANGED, isUserChanged); + if (isIBM() && !isDomainElement) setBooleanAttribute(UDA_ATTR_CHANGED, isUserChanged); } /** @@ -271,82 +280,23 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { */ public void deleteElement() { // Not intended for root. Only for Actions - elm.getParentNode().removeChild(elm); + //elm.getParentNode().removeChild(elm); + elm.getContainer().removePropertySet(elm.getName()); } - - // -------------------------- - // INTERNAL HELPER METHODS... - // -------------------------- - /** - * Given the name of a child xml tag, return the data for that tag - */ - protected String getTextNode(String tagname) { - Element tag = getChildTag(tagname, false); - if (null != tag) { - Node n = tag.getFirstChild(); - if (null != n) { - if (n instanceof Text) { - Text tn = (Text) n; - return tn.getData(); - } - } - } - return ""; //$NON-NLS-1$ - } - - /** - * Given the name of a child xml tag and a data value, - * update the data of that tag - */ - protected void setTextNode(String tagname, String val) { - Element tag = getChildTag(tagname, true); - if (null != tag) { - database.setChanged(profile); - // ?? Loop on all children, removing? - Node n = tag.getFirstChild(); - if (null != n) { - if (n instanceof Text) { - Text tn = (Text) n; - tn.setData(val); - return; - } - // ?? Loop on all children, removing? - tag.removeChild(n); - } - tag.appendChild(elm.getOwnerDocument().createTextNode(val)); - return; - } - } - - /** - * Given a tag name, return the xml node for that child tag - * @param tagname - the name of the tag to find - * @param create - true if tag is to be created if not found - */ - protected Element getChildTag(String tagname, boolean create) { - NodeList subList = elm.getChildNodes(); - if (null != subList) { - for (int i = 0; i < subList.getLength(); i++) { - Node sn = subList.item(i); - if (sn instanceof Element) { - Element se = (Element) sn; - if (tagname.equals(se.getTagName())) return se; - } - } - } - if (create) { - Element newchild = elm.getOwnerDocument().createElement(tagname); - elm.appendChild(newchild); - return newchild; - } - return null; - } - + /** * Set the value of a boolean attribute */ public void setBooleanAttribute(String attr, boolean b) { - elm.setAttribute(attr, (b) ? XML_TRUE : XML_FALSE); + IProperty property = elm.getProperty(attr); + if (null == property) + { + elm.addProperty(attr, (b) ? UDA_TRUE : UDA_FALSE); + } + else + { + property.setValue((b) ? UDA_TRUE : UDA_FALSE); + } database.setChanged(profile); } @@ -355,8 +305,8 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * @param attr - name of the attribute to query */ public boolean getBooleanAttribute(String attr) { - String val = elm.getAttribute(attr); - if (XML_TRUE.equals(val)) return true; + String val = elm.getPropertyValue(attr); + if (UDA_TRUE.equals(val)) return true; return false; } @@ -366,9 +316,9 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * @param defaultValue - value to return if the attribute is not found */ public boolean getBooleanAttribute(String attr, boolean defaultValue) { - String val = elm.getAttribute(attr); + String val = elm.getPropertyValue(attr); if (val == null) return defaultValue; - if (XML_TRUE.equals(val)) return true; + if (UDA_TRUE.equals(val)) return true; return false; } @@ -377,7 +327,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * Specify a default value to return if the attribute is not found */ public String getAttribute(String attr, String defaultValue) { - String value = elm.getAttribute(attr); + String value = elm.getPropertyValue(attr); if (value == null) value = defaultValue; return value; } @@ -387,9 +337,21 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { */ public void setAttribute(String attr, String value) { if (value != null) - elm.setAttribute(attr, value); + { + IProperty property = elm.getProperty(attr); + if (property == null) + { + elm.addProperty(attr, value); + } + else + { + property.setValue(value); + } + } else - elm.removeAttribute(attr); + { + elm.removeProperty(attr); + } database.setChanged(profile); } @@ -400,7 +362,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * Always returns a non-null vector, although it may be empty */ public Vector getExistingNames() { - Element parentElement = null; + IPropertySet parentElement = null; String currName = null; if (isDomain()) parentElement = this.getElement(); @@ -418,55 +380,39 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * Given a parent element XML node, returns all child action names. * Always returns a non-null vector, although it may be empty */ - public Vector getExistingNames(Element parentElement, Document xdoc) { + public Vector getExistingNames(IPropertySet parentElement, IPropertySet xdoc) { return getExistingNames(parentElement, xdoc, getTagName()); } /** * For unique-name checking. - * Given a parent element XML node, returns all child action names. + * Given a parent UDA node, returns all child action names. * Always returns a non-null vector of Strings, although it may be empty */ - public static Vector getExistingNames(Element parentElement, Document xdoc, String tagName) { + public static Vector getExistingNames(IPropertySet parentElement, IPropertySet xdoc, String tagName) { Vector nameList = new Vector(); - Element se = null; - NodeList subList = null; + IPropertySet[] subList = null; if (parentElement != null) - subList = parentElement.getChildNodes(); + subList = parentElement.getPropertySets(); else - subList = xdoc.getElementsByTagName(tagName); + subList = xdoc.getPropertySets(); if (subList != null) { - for (int idx = 0; idx < subList.getLength(); idx++) { - Node sn = subList.item(idx); - if (sn instanceof Element) { - se = (Element) sn; - if (se.getTagName().equals(tagName)) { - nameList.add(se.getAttribute(ISystemUDAConstants.NAME_ATTR)); - } + for (int idx = 0; idx < subList.length; idx++) { + IPropertySet sn = subList[idx]; + if (sn.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(tagName)) + { + nameList.add(sn.getPropertyValue(ISystemUDAConstants.NAME_ATTR)); } } // end for all subnodes } // end if sublist != null return nameList; } - /** - * Returns element wrappers of children (if this is a domain) or siblings - */ - public Vector getChildren(Vector children, ISystemProfile profile) { - Element parentElement = null; - if (isDomain()) - parentElement = this.getElement(); - else - parentElement = getParentElement(); - children = getChildren(children, parentElement, getDocument(), profile); - return children; - } - /** * Given a parent element XML node, returns wrappers of all child tags of which we are interested * Always returns a non-null vector, although it may be empty */ - public Vector getChildren(Vector children, Element parentElement, Document xdoc, ISystemProfile profile) { + public Vector getChildren(Vector children, IPropertySet parentElement, IPropertySet xdoc, ISystemProfile profile) { return getChildren(children, parentElement, xdoc, profile, database, getDomain()); } @@ -476,23 +422,22 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * If the parentElement is null, uses the roots of the given document. Should only be true if domains not supported! * @return Vector of SystemXMLElementWrapper objects */ - public static Vector getChildren(Vector children, Element parentElement, Document xdoc, ISystemProfile profile, ISystemXMLElementWrapperFactory factory, int domain) { + public static Vector getChildren(Vector children, IPropertySet parentElement, IPropertySet xdoc, ISystemProfile profile, ISystemXMLElementWrapperFactory factory, int domain) { if (children == null) children = new Vector(); String tagName = factory.getTagName(); - Element se = null; - NodeList subList = null; + + IPropertySet[] subList = null; if (parentElement != null) - subList = parentElement.getChildNodes(); + subList = parentElement.getPropertySets(); else - subList = xdoc.getElementsByTagName(tagName); + subList = xdoc.getPropertySets(); if (subList != null) { - for (int idx = 0; idx < subList.getLength(); idx++) { - Node sn = subList.item(idx); - if (sn instanceof Element) { - se = (Element) sn; - if (se.getTagName().equals(tagName)) { - children.add(factory.createElementWrapper(se, profile, domain)); - } + for (int idx = 0; idx < subList.length; idx++) { + IPropertySet sn = subList[idx]; + if (sn.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(tagName)) + { + SystemXMLElementWrapper thisWrapper = factory.createElementWrapper(sn, profile, domain); + children.add(thisWrapper); } } // end for all subnodes } // end if sublist != null @@ -504,19 +449,22 @@ public abstract class SystemXMLElementWrapper implements IAdaptable { * Given a parent element XML node, returns the xml Element node with the given name attribute, * or null if not found. */ - public static Element findChildByName(Element parentElement, Document xdoc, String tagName, String searchName) { - Element match = null; - NodeList subList = null; + public static IPropertySet findChildByName(IPropertySet parentElement, IPropertySet xdoc, String tagName, String searchName) { + IPropertySet match = null; + IPropertySet[] subList = null; if (parentElement != null) - subList = parentElement.getChildNodes(); + subList = parentElement.getPropertySets(); else - subList = xdoc.getElementsByTagName(tagName); + subList = xdoc.getPropertySets(); if (subList != null) { - for (int idx = 0; (match == null) && (idx < subList.getLength()); idx++) { - Node sn = subList.item(idx); - if (sn instanceof Element) { - if (((Element) sn).getTagName().equals(tagName)) { - if (((Element) sn).getAttribute(ISystemUDAConstants.NAME_ATTR).equals(searchName)) match = (Element) sn; + for (int idx = 0; (match == null) && (idx < subList.length); idx++) { + IPropertySet sn = subList[idx]; + if (sn.getName().equals(searchName)) + { + IProperty typeProperty = sn.getProperty(ISystemUDAConstants.TYPE_ATTR); + if (typeProperty.getValue().equals(tagName)) + { + match = sn; } } } // end for all subnodes diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithFileTypesAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithFileTypesAction.java index 689379df872..5556fd96878 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithFileTypesAction.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithFileTypesAction.java @@ -19,6 +19,7 @@ import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.internal.ui.view.team.SystemTeamViewSubSystemConfigurationNode; import org.eclipse.rse.internal.useractions.IUserActionsImageIds; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; +import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; import org.eclipse.rse.internal.useractions.ui.uda.SystemWorkWithUDTypeDialog; import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.RSEUIPlugin; @@ -31,6 +32,7 @@ import org.eclipse.swt.widgets.Shell; public class SystemWorkWithFileTypesAction extends SystemBaseDialogAction { private ISubSystem subsystem = null; private ISubSystemConfiguration subsystemFactory = null; + private SystemUDActionSubsystem udaActionSubsystem; private ISystemProfile profile; private SystemWorkWithUDTypeDialog ourDlg = null; private String typeToPreSelect = null; @@ -41,11 +43,12 @@ public class SystemWorkWithFileTypesAction extends SystemBaseDialogAction { /** * Constructor when we have a subsystem * @param parent The Shell of the parent UI for this dialog - * @param subSystem The subsystem we are launching this from/for + * @param udaActionSubsystem The User Define Action subsystem we are launching this from/for */ - public SystemWorkWithFileTypesAction(Shell parent, ISubSystem subSystem) { + public SystemWorkWithFileTypesAction(Shell parent, SystemUDActionSubsystem udaActionSubsystem) { this(parent); - this.subsystem = subSystem; + this.udaActionSubsystem = udaActionSubsystem; + this.subsystem = udaActionSubsystem.getSubsystem(); if (subsystem != null) { this.subsystemFactory = subsystem.getSubSystemConfiguration(); this.profile = subsystem.getSystemProfile(); @@ -115,7 +118,7 @@ public class SystemWorkWithFileTypesAction extends SystemBaseDialogAction { profile = ssfNode.getProfile(); } if (subsystem != null) - ourDlg = new SystemWorkWithUDTypeDialog(parent, subsystem); + ourDlg = new SystemWorkWithUDTypeDialog(parent, subsystem, udaActionSubsystem); else ourDlg = new SystemWorkWithUDTypeDialog(parent, subsystemFactory, profile); if (typeToPreSelect != null) ourDlg.preSelectType(preSelectTypeDomain, typeToPreSelect); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithUDAsAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithUDAsAction.java index 549b7554d08..c430c493030 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithUDAsAction.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/actions/SystemWorkWithUDAsAction.java @@ -21,6 +21,7 @@ import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.internal.ui.view.team.SystemTeamViewSubSystemConfigurationNode; import org.eclipse.rse.internal.useractions.IUserActionsImageIds; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; +import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; import org.eclipse.rse.internal.useractions.ui.uda.SystemWorkWithUDAsDialog; import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.RSEUIPlugin; @@ -34,15 +35,17 @@ public class SystemWorkWithUDAsAction extends SystemBaseDialogAction { private ISubSystem subsystem = null; private ISubSystemConfiguration subsystemFactory = null; private ISystemProfile profile; + private SystemUDActionSubsystem udaActionSubsystem = null; /** * Constructor when starting with a subsystem (such as in RS view) * @param parent The Shell of the parent UI for this dialog * @param subSystem The subsystem we are launching this from/for */ - public SystemWorkWithUDAsAction(Shell parent, ISubSystem subSystem) { + public SystemWorkWithUDAsAction(Shell parent, ISubSystem subSystem, SystemUDActionSubsystem udaActionSubsystem) { this(parent); setSubSystem(subSystem); + setActionSubsystem(udaActionSubsystem); setAvailableOffline(true); } @@ -51,9 +54,10 @@ public class SystemWorkWithUDAsAction extends SystemBaseDialogAction { * @param parent The Shell of the parent UI for this dialog * @param subSystemFactory The subsystem factory we are launching this from/for */ - public SystemWorkWithUDAsAction(Shell parent, ISubSystemConfiguration subSystemFactory, ISystemProfile profile) { + public SystemWorkWithUDAsAction(Shell parent, ISubSystemConfiguration subSystemFactory, ISystemProfile profile, SystemUDActionSubsystem udaActionSubsystem) { this(parent); setSubSystemFactory(subsystemFactory, profile); + setActionSubsystem(udaActionSubsystem); } /** @@ -117,6 +121,9 @@ public class SystemWorkWithUDAsAction extends SystemBaseDialogAction { this.profile = profile; } + public void setActionSubsystem(SystemUDActionSubsystem udaActionSubsystem) { + this.udaActionSubsystem = udaActionSubsystem; + } /** * Called by SystemBaseAction when selection is set. * Our opportunity to verify we are allowed for this selected type. @@ -156,9 +163,9 @@ public class SystemWorkWithUDAsAction extends SystemBaseDialogAction { } SystemWorkWithUDAsDialog dlg = null; if (subsystem != null) - dlg = new SystemWorkWithUDAsDialog(parent, subsystem); + dlg = new SystemWorkWithUDAsDialog(parent, subsystem, udaActionSubsystem); else - dlg = new SystemWorkWithUDAsDialog(parent, subsystemFactory, profile); + dlg = new SystemWorkWithUDAsDialog(parent, subsystemFactory, profile, udaActionSubsystem); return dlg; } diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/compile/ISystemCompileManagerAdapter.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/compile/ISystemCompileManagerAdapter.java new file mode 100644 index 00000000000..9c25b7cc813 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/compile/ISystemCompileManagerAdapter.java @@ -0,0 +1,11 @@ +package org.eclipse.rse.useractions.files.compile; + +import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; + + +public interface ISystemCompileManagerAdapter { + + public SystemCompileManager getSystemCompileManager(ISubSystemConfiguration ssc); + +} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/compile/UniversalCompileManagerAdapter.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/compile/UniversalCompileManagerAdapter.java new file mode 100644 index 00000000000..195b538efdf --- /dev/null +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/compile/UniversalCompileManagerAdapter.java @@ -0,0 +1,27 @@ +package org.eclipse.rse.useractions.files.compile; + +import java.util.HashMap; + +import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.internal.useractions.files.compile.UniversalCompileManager; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; + +public class UniversalCompileManagerAdapter implements + ISystemCompileManagerAdapter { + private HashMap compileManagers = new HashMap(); + + public SystemCompileManager getSystemCompileManager(ISubSystemConfiguration ssc) { + String configID = ssc.getId(); + + SystemCompileManager thisCompileManager = (SystemCompileManager)compileManagers.get(configID); + if (thisCompileManager == null) + { + thisCompileManager = new UniversalCompileManager(); + thisCompileManager.setSubSystemFactory(ssc); + compileManagers.put(configID, thisCompileManager); + } + + return thisCompileManager; + } + +} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/uda/ISystemUDActionSubsystemAdapter.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/uda/ISystemUDActionSubsystemAdapter.java new file mode 100644 index 00000000000..71afde75325 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/uda/ISystemUDActionSubsystemAdapter.java @@ -0,0 +1,11 @@ +package org.eclipse.rse.useractions.files.uda; + +import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; + + +public interface ISystemUDActionSubsystemAdapter { + + public SystemUDActionSubsystem getSystemUDActionSubsystem(ISubSystemConfiguration ssc); + +} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/uda/UniversalSystemUDActionSubsystemAdapter.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/uda/UniversalSystemUDActionSubsystemAdapter.java new file mode 100644 index 00000000000..d2315c29f33 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/files/uda/UniversalSystemUDActionSubsystemAdapter.java @@ -0,0 +1,26 @@ +package org.eclipse.rse.useractions.files.uda; + +import java.util.HashMap; + +import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; +import org.eclipse.rse.internal.useractions.files.uda.UDActionSubsystemUniversalFiles; +import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; + +public class UniversalSystemUDActionSubsystemAdapter implements ISystemUDActionSubsystemAdapter { + private HashMap uDActionSubsystems = new HashMap(); + + public SystemUDActionSubsystem getSystemUDActionSubsystem(ISubSystemConfiguration ssc) { + String configID = ssc.getId(); + + SystemUDActionSubsystem thisuDActionSubsystem = (SystemUDActionSubsystem)uDActionSubsystems.get(configID); + if (thisuDActionSubsystem == null) + { + thisuDActionSubsystem = new UDActionSubsystemUniversalFiles(); + thisuDActionSubsystem.setSubSystemFactory(ssc); + uDActionSubsystems.put(configID, thisuDActionSubsystem); + } + + return thisuDActionSubsystem; + } + +} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCascadingCompileAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/ui/compile/SystemCascadingCompileAction.java similarity index 96% rename from rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCascadingCompileAction.java rename to rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/ui/compile/SystemCascadingCompileAction.java index 6ae294389be..0b57c45c93f 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCascadingCompileAction.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/ui/compile/SystemCascadingCompileAction.java @@ -9,7 +9,7 @@ * IBM Corporation - initial API and implementation * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.compile; +package org.eclipse.rse.useractions.ui.compile; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; @@ -18,6 +18,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.internal.useractions.UserActionsResources; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCascadeByProfileAction; import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemPreferencesManager; diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/ui/compile/SystemCompileAction.java similarity index 93% rename from rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileAction.java rename to rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/ui/compile/SystemCompileAction.java index f7214d0c779..77369ff61c1 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileAction.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/ui/compile/SystemCompileAction.java @@ -10,7 +10,7 @@ * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin * David Dykstal (IBM) - [186589] move user actions API out of org.eclipse.rse.ui *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.compile; +package org.eclipse.rse.useractions.ui.compile; import java.util.ArrayList; import java.util.List; @@ -18,10 +18,14 @@ import java.util.List; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.internal.ui.GenericMessages; import org.eclipse.rse.internal.ui.view.SystemTableViewProvider; import org.eclipse.rse.internal.useractions.Activator; import org.eclipse.rse.internal.useractions.IUserActionsImageIds; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompilableSource; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCommand; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileType; +import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.actions.SystemBaseAction; import org.eclipse.rse.ui.view.ISystemEditableRemoteObject; @@ -178,10 +182,10 @@ public class SystemCompileAction extends SystemBaseAction { WorkbenchContentProvider cprovider = new WorkbenchContentProvider(); SystemTableViewProvider lprovider = new SystemTableViewProvider(null); // TODO: Cannot use WorkbenchMessages -- it's internal - ListSelectionDialog dlg = new ListSelectionDialog(getShell(), input, cprovider, lprovider, GenericMessages.EditorManager_saveResourcesMessage); + ListSelectionDialog dlg = new ListSelectionDialog(getShell(), input, cprovider, lprovider, SystemUDAResources.EditorManager_saveResourcesMessage); dlg.setInitialSelections(input.getChildren()); // TODO: Cannot use WorkbenchMessages -- it's internal - dlg.setTitle(GenericMessages.EditorManager_saveResourcesTitle); + dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle); int result = dlg.open(); //Just return false to prevent the operation continuing if (result == IDialogConstants.CANCEL_ID) return false; diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemWorkWithCompileCommandsAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/ui/compile/SystemWorkWithCompileCommandsAction.java similarity index 76% rename from rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemWorkWithCompileCommandsAction.java rename to rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/ui/compile/SystemWorkWithCompileCommandsAction.java index 24b40863459..8b906af4559 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemWorkWithCompileCommandsAction.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/useractions/ui/compile/SystemWorkWithCompileCommandsAction.java @@ -11,8 +11,9 @@ * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands * API to the user actions plugin *******************************************************************************/ -package org.eclipse.rse.internal.useractions.ui.compile; +package org.eclipse.rse.useractions.ui.compile; +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.rse.core.model.ISystemProfile; @@ -20,6 +21,9 @@ import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.internal.ui.view.team.SystemTeamViewSubSystemConfigurationNode; import org.eclipse.rse.internal.useractions.IUserActionsImageIds; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileProfile; +import org.eclipse.rse.internal.useractions.ui.compile.SystemWorkWithCompileCommandsDialog; import org.eclipse.rse.internal.useractions.ui.compile.teamview.SystemTeamViewCompileTypeNode; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; import org.eclipse.rse.ui.ISystemContextMenuConstants; @@ -27,6 +31,7 @@ import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.actions.SystemBaseDialogAction; import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; import org.eclipse.rse.ui.view.SystemAdapterHelpers; +import org.eclipse.rse.useractions.files.compile.ISystemCompileManagerAdapter; import org.eclipse.swt.widgets.Shell; /** @@ -113,33 +118,46 @@ public class SystemWorkWithCompileCommandsAction extends SystemBaseDialogAction if (currSystemProfile == null) currSystemProfile = subsystem.getSystemProfile(); } if (ssf != null) { - /* FIXME - compile actions not coupled with subsystem API anymore - - compileManager = ssf.getCompileManager(); - if (subsystem != null) - { - compileManager.setSystemConnection(subsystem.getHost()); + + ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration(); + + + + if (inputObject instanceof IAdaptable) { + ISystemCompileManagerAdapter adapter = (ISystemCompileManagerAdapter)((IAdaptable)inputObject).getAdapter(ISystemCompileManagerAdapter.class); + if (null != adapter) + { + compileManager = adapter.getSystemCompileManager(ssc); + } + } + + if (null != compileManager) + { + if (currSystemProfile != null) + { + currProfile = compileManager.getCompileProfile(currSystemProfile); + currProfiles = compileManager.getAllCompileProfiles(); + } + + caseSensitive = ssf.isCaseSensitive(); + + SystemWorkWithCompileCommandsDialog dlg = new SystemWorkWithCompileCommandsDialog(shell, compileManager, currProfile); + /* FIXME - currProfiles cannot be null since above stuff was commented out + if (currProfiles != null) { + dlg.setProfiles(currProfiles); + } + */ + dlg.setProfiles(currProfiles); + dlg.setCaseSensitive(caseSensitive); + if (inputObject instanceof SystemTeamViewCompileTypeNode) { + SystemTeamViewCompileTypeNode node = (SystemTeamViewCompileTypeNode) inputObject; + dlg.setCompileType(node.getCompileType()); + dlg.setSupportsAddSrcTypeButton(false); + } + return dlg; } - if (currSystemProfile != null) - currProfile = compileManager.getCompileProfile(currSystemProfile); - currProfiles = compileManager.getAllCompileProfiles(); - */ - caseSensitive = ssf.isCaseSensitive(); } - SystemWorkWithCompileCommandsDialog dlg = new SystemWorkWithCompileCommandsDialog(shell, compileManager, currProfile); - /* FIXME - currProfiles cannot be null since above stuff was commented out - if (currProfiles != null) { - dlg.setProfiles(currProfiles); - } - */ - dlg.setProfiles(currProfiles); - dlg.setCaseSensitive(caseSensitive); - if (inputObject instanceof SystemTeamViewCompileTypeNode) { - SystemTeamViewCompileTypeNode node = (SystemTeamViewCompileTypeNode) inputObject; - dlg.setCompileType(node.getCompileType()); - dlg.setSupportsAddSrcTypeButton(false); - } - return dlg; + return null; } /**