1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-15 04:55:22 +02:00

[187395] First attempt to make user define action and compile command support work in open RSE

This commit is contained in:
Xuan Chen 2008-03-11 15:54:40 +00:00
parent a6e7bc0b7f
commit f9c95d6fc8
53 changed files with 1230 additions and 1123 deletions

View file

@ -20,7 +20,11 @@ Require-Bundle: org.eclipse.core.resources,
org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)" org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)"
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true 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.compile,
org.eclipse.rse.internal.useractions.files.uda, org.eclipse.rse.internal.useractions.files.uda,
org.eclipse.rse.internal.useractions.ui, org.eclipse.rse.internal.useractions.ui,

View file

@ -20,3 +20,6 @@ providerName = Eclipse.org
PropertyPage.TeamViewUserActionNode = User Action Information PropertyPage.TeamViewUserActionNode = User Action Information
PropertyPage.TeamViewCompileTypeNode = Compile Type Information PropertyPage.TeamViewCompileTypeNode = Compile Type Information
PropertyPage.TeamViewCompileCommandNode = Compile Command Information PropertyPage.TeamViewCompileCommandNode = Compile Command Information
DynamicLabel.CompileActionNode = Compile
DynamicLabel.UserActionNode = User Action

View file

@ -39,21 +39,31 @@
</page> </page>
</extension> </extension>
<extension point="org.eclipse.ui.menus"> <extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.rse.ui.view.systemView"> <menuContribution locationURI="popup:org.eclipse.rse.ui.view.systemView">
<menu id="org.eclipse.rse.ui.useractions.menu" <menu id="org.eclipse.rse.ui.useractions.compile.menu"
label="Dynamic menu test" label="%DynamicLabel.CompileActionNode"
mnemonic="useractions.dynamicmenu.mnemonic"> mnemonic="useractions.dynamiccompilemenu.mnemonic">
<dynamic class="org.eclipse.rse.internal.useractions.ui.SystemDynamicCompileMenu"
<dynamic class="org.eclipse.rse.internal.useractions.ui.DynamicMenuTest" id="org.eclipse.ui.rse.ui.views.dynamiccompilemenu">
id="org.eclipse.ui.rse.ui.views.dynamicmenutest">
</dynamic> </dynamic>
<!--
<visibleWhen>
<instanceof
value="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"/>
</visibleWhen>
-->
</menu>
<menu id="org.eclipse.rse.ui.useractions.useraction.menu"
label="%DynamicLabel.UserActionNode"
mnemonic="useractions.dynamicuseractionmenu.mnemonic">
<dynamic class="org.eclipse.rse.internal.useractions.ui.SystemDynamicUserActionMenu"
id="org.eclipse.ui.rse.ui.views.dynamicuseractionmenu">
</dynamic>
</menu> </menu>
</menuContribution> </menuContribution>
</extension> </extension>
</plugin> </plugin>

View file

@ -19,8 +19,8 @@ import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager;
public class LocalCompileProfile extends UniversalCompileProfile { public class LocalCompileProfile extends UniversalCompileProfile {
/** /**
* Constructor * Constructor
* @param manager * @param manager SystemCompileManager of this compile file
* @param profileName * @param profileName System profile name
*/ */
public LocalCompileProfile(SystemCompileManager manager, String profileName) { public LocalCompileProfile(SystemCompileManager manager, String profileName) {
super(manager, profileName); super(manager, profileName);

View file

@ -23,10 +23,11 @@ import org.eclipse.swt.widgets.Shell;
public class UniversalCompilableSource extends SystemCompilableSource { public class UniversalCompilableSource extends SystemCompilableSource {
/** /**
* Constructor for UniversalCompilableSource. * Constructor for UniversalCompilableSource.
* @param shell * @param shell - the shell to use if need to prompt
* @param firstSelection * @param firstSelection - the selected compilable source member
* @param compileCmd * @param compileCmd - the Compile Command that is to be run against the selected compilable source member
* @param isPrompt * @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) { public UniversalCompilableSource(Shell shell, Object firstSelection, SystemCompileCommand compileCmd, boolean isPrompt, Viewer viewer) {
super(shell, firstSelection, compileCmd, isPrompt, viewer); super(shell, firstSelection, compileCmd, isPrompt, viewer);

View file

@ -24,8 +24,8 @@ import org.eclipse.swt.widgets.Shell;
public class UniversalCompileProfile extends SystemCompileProfile { public class UniversalCompileProfile extends SystemCompileProfile {
/** /**
* Constructor for UniversalCompileProfile. * Constructor for UniversalCompileProfile.
* @param manager * @param manager SystemCompileManager of this compile file
* @param profileName * @param profileName System profile name
*/ */
public UniversalCompileProfile(SystemCompileManager manager, String profileName) { public UniversalCompileProfile(SystemCompileManager manager, String profileName) {
super(manager, profileName); super(manager, profileName);

View file

@ -19,8 +19,8 @@ import org.eclipse.rse.internal.useractions.ui.compile.SystemDefaultCompileComma
public class UniversalIBMCompileCommand extends SystemDefaultCompileCommand { public class UniversalIBMCompileCommand extends SystemDefaultCompileCommand {
/** /**
* Constructor for UniversalCompileIBMCommand. * Constructor for UniversalCompileIBMCommand.
* @param commandLabel * @param commandLabel label of the command
* @param commandName * @param commandName name of the command
*/ */
public UniversalIBMCompileCommand(String commandLabel, String commandName) { public UniversalIBMCompileCommand(String commandLabel, String commandName) {
super(commandLabel, commandName); super(commandLabel, commandName);
@ -28,7 +28,7 @@ public class UniversalIBMCompileCommand extends SystemDefaultCompileCommand {
/** /**
* Constructor for UniversalCompileIBMCommand. * Constructor for UniversalCompileIBMCommand.
* @param commandName * @param commandName name of the command
*/ */
public UniversalIBMCompileCommand(String commandName) { public UniversalIBMCompileCommand(String commandName) {
super(commandName); super(commandName);

View file

@ -19,11 +19,11 @@ import java.util.Vector;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer; 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.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.UserActionsIcon;
import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList; 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.ISystemUDAEditPaneHoster;
import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTreeView; 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.SystemUDAResources;
@ -283,7 +283,7 @@ public class UDActionSubsystemFiles extends SystemUDActionSubsystem {
* @param cmdString - the resolved command * @param cmdString - the resolved command
* @param cmdSubSystem - this connection's command subsystem, which will run the command * @param cmdSubSystem - this connection's command subsystem, which will run the command
* @param context - the selected IRemoteFile object * @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 * @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) { 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 * Subclasses may override to provide a custom type edit pane subclass
*/ */
public SystemUDTypeEditPane getCustomUDTypeEditPane(ISubSystem ss, ISubSystemConfiguration ssf, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { public SystemUDTypeEditPane getCustomUDTypeEditPane(ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) {
return new UDTypesEditPaneFiles(ss, ssf, profile, parent, 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) { public static SystemUDActionElement[] primeDefaultUniversalActions(SystemUDActionManager actionMgr, ISystemProfile profile, Vector vectorOfActions) {
Vector v = vectorOfActions; Vector v = vectorOfActions;
if (v == null) v = new Vector(); 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 // add file actions
int domain = DOMAIN_FILE; int domain = DOMAIN_FILE;
SystemUDActionElement newAction; SystemUDActionElement newAction;
//IPropertySet domainFilePropertySet = userDefinedActionPropertySet.createPropertySet(DOMAINS[1]);
for (int idx = 0; idx < FILE_ACTIONS.length; idx++) { for (int idx = 0; idx < FILE_ACTIONS.length; idx++) {
newAction = actionMgr.addAction(profile, FILE_ACTIONS[idx][0], domain); newAction = actionMgr.addAction(profile, FILE_ACTIONS[idx][0], domain);
v.addElement(newAction); v.addElement(newAction);

View file

@ -10,12 +10,10 @@ package org.eclipse.rse.internal.useractions.files.uda;
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * 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.ISystemUDAEditPaneHoster;
import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTreeView; 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.ISystemUDTypeEditPaneTypesSelector;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeEditPane; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDTypeEditPane;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -30,12 +28,12 @@ import org.eclipse.swt.widgets.Composite;
public class UDTypesEditPaneFiles extends SystemUDTypeEditPane { public class UDTypesEditPaneFiles extends SystemUDTypeEditPane {
/** /**
* Constructor for UDTypesEditPaneFiles. * Constructor for UDTypesEditPaneFiles.
* @param ss * @param udaActionSubsys User Defined Action subsystem
* @param parent * @param parent any dialog or property page that wants to host a user action edit pane.
* @param tv * @param tv User Defined Action tree view
*/ */
public UDTypesEditPaneFiles(ISubSystem ss, ISubSystemConfiguration ssf, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { public UDTypesEditPaneFiles(SystemUDActionSubsystem udaActionSubsys, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) {
super(ss, ssf, profile, parent, tv); super(udaActionSubsys, parent, tv);
} }
/** /**

View file

@ -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;
}
}

View file

@ -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<cmds.length; idx2++)
{
SystemCompileAction action = new SystemCompileAction(shell, cmds[idx2], true);
action.setSelection(selection);
TestContribution testContribution = new TestContribution(action);
returnedItemList.add(testContribution);
//ourSubMenu.add(action);
}
}
}
}
// add a separator before Work With Compile Commands... menu item
//ourSubMenu.add(new Separator());
// add Work With Commands... action
// Here's where you would dynamically generate your list
SystemWorkWithCompileCommandsAction workWithCompileCommandAction = new SystemWorkWithCompileCommandsAction(shell, true);
workWithCompileCommandAction.setSelection(selection);
TestContribution testContribution = new TestContribution(workWithCompileCommandAction);
returnedItemList.add(testContribution);
IContributionItem[] list = (IContributionItem[])returnedItemList.toArray(new ActionContributionItem[]{});
//String[] array = (String[])arrayList.toArray(new String[]{});
//SystemCascadingCompileAction promptAction = new SystemCascadingCompileAction(null, true);
//list[0] = new TestContribution(/*promptAction*/);
return list;
}
}

View file

@ -0,0 +1,104 @@
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.uda.SystemUDAResources;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem;
import org.eclipse.rse.internal.useractions.ui.uda.actions.SystemWorkWithUDAsAction;
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.uda.ISystemUDActionSubsystemAdapter;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CompoundContributionItem;
public class SystemDynamicUserActionMenu extends CompoundContributionItem
{
private class UserActionContribution extends ActionContributionItem {
public UserActionContribution(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();
ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(firstSelection);
ISubSystem subsystem = rmtAdapter.getSubSystem(firstSelection);
ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration();
SystemUDActionSubsystem systemUDActionSubsystem = null;
if (firstSelection instanceof IAdaptable) {
ISystemUDActionSubsystemAdapter adapter = (ISystemUDActionSubsystemAdapter)((IAdaptable)firstSelection).getAdapter(ISystemUDActionSubsystemAdapter.class);
if (null != adapter)
{
systemUDActionSubsystem = adapter.getSystemUDActionSubsystem(ssc);
systemUDActionSubsystem.setSubsystem(subsystem);
}
}
Shell shell = SystemBasePlugin.getActiveWorkbenchShell();
for (int idx = 0; idx < activeProfiles.length; idx++)
{
//Xuan: the code for systemUDActionSubsystem#addUserActions go here...
// systemUDActionSubsystem.addUserActions(menu, (IStructuredSelection)selection, profi, shell);
if (null != systemUDActionSubsystem)
{
Action[] list = systemUDActionSubsystem.addUserActions(null, (IStructuredSelection)selection, activeProfiles[idx], shell);
for (int i = 0; i < list.length; i++)
{
UserActionContribution testContribution = new UserActionContribution(list[i]);
returnedItemList.add(testContribution);
}
}
}
// add a separator before Work With Compile Commands... menu item
//ourSubMenu.add(new Separator());
// add Work With Commands... action
SystemWorkWithUDAsAction wwAction;
wwAction = new SystemWorkWithUDAsAction(shell, systemUDActionSubsystem.getSubsystem(), systemUDActionSubsystem);
wwAction.setText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_LABEL);
wwAction.setToolTipText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_TOOLTIP);
wwAction.allowOnMultipleSelection(true);
wwAction.setSelection(selection);
UserActionContribution userActionContribution = new UserActionContribution(wwAction);
returnedItemList.add(userActionContribution);
IContributionItem[] list = (IContributionItem[])returnedItemList.toArray(new ActionContributionItem[]{});
return list;
}
}

View file

@ -9,6 +9,7 @@ public interface ISystemCompileXMLConstants {
// The file name to use to store the xml file that // The file name to use to store the xml file that
// holds info on compile name associations for a // holds info on compile name associations for a
// profile // profile
public static final String COMPILE_COMMAND_PROPRERTY_SET_PREFIX = "CC."; //$NON-NLS-1$
public static final String FILE_NAME = "compileCommands.xml"; //$NON-NLS-1$ public static final String FILE_NAME = "compileCommands.xml"; //$NON-NLS-1$
// root tag // root tag
/** /**
@ -40,7 +41,7 @@ public interface ISystemCompileXMLConstants {
* The xml element is named "compiletype". * The xml element is named "compiletype".
*/ */
public static final String TYPE_ELEMENT = "compiletype"; //$NON-NLS-1$ public static final String TYPE_ELEMENT = "compiletype"; //$NON-NLS-1$
public static final String TYPE_ATTRIBUTE = "type"; //$NON-NLS-1$ public static final String TYPE_ATTRIBUTE = "sourcetype"; //$NON-NLS-1$
/** /**
* The name of the attribute holding the last-used compile command. This value identifies that * The name of the attribute holding the last-used compile command. This value identifies that
* command via its label value. * command via its label value.

View file

@ -12,9 +12,12 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.useractions.ui.compile; package org.eclipse.rse.internal.useractions.ui.compile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IMenuManager;
import org.eclipse.rse.core.model.ISystemProfile; 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.view.SystemViewMenuListener; import org.eclipse.rse.internal.ui.view.SystemViewMenuListener;
import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
@ -22,6 +25,8 @@ import org.eclipse.rse.ui.actions.SystemBaseDummyAction;
import org.eclipse.rse.ui.actions.SystemBaseSubMenuAction; import org.eclipse.rse.ui.actions.SystemBaseSubMenuAction;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.rse.ui.view.SystemAdapterHelpers; 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.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
/** /**
@ -91,11 +96,25 @@ public class SystemCompileCascadeByProfileAction extends SystemBaseSubMenuAction
srcType = "blank"; //$NON-NLS-1$ srcType = "blank"; //$NON-NLS-1$
} else } else
return ourSubMenu; // should never happen return ourSubMenu; // should never happen
/* FIXME - compile actions not coupled with subsystem API anymore
ISubSystem subsystem = rmtAdapter.getSubSystem(firstSelection); ISubSystem subsystem = rmtAdapter.getSubSystem(firstSelection);
SystemCompileProfile compileProfile = subsystem.getParentSubSystemFactory().getCompileManager().getCompileProfile(profile); 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(profile);
// compileProfile.addContributions(firstSelection); // compileProfile.addContributions(firstSelection);
SystemCompileType compileType = (SystemCompileType)compileProfile.getCompileType(srcType); SystemCompileType compileType = compileProfile.getCompileType(srcType);
if (compileType != null) if (compileType != null)
{ {
@ -106,7 +125,8 @@ public class SystemCompileCascadeByProfileAction extends SystemBaseSubMenuAction
ourSubMenu.add(action); ourSubMenu.add(action);
} }
} }
*/ }
return ourSubMenu; return ourSubMenu;
} }
} }

View file

@ -313,7 +313,7 @@ public class SystemCompileCommandEditPane implements SelectionListener, ISystemC
/** /**
* Populate the pane with the GUI widgets * Populate the pane with the GUI widgets
* @param parent * @param parent of the pane
* @return Control * @return Control
*/ */
public Control createContents(Composite parent) { public Control createContents(Composite parent) {

View file

@ -35,6 +35,7 @@ import org.eclipse.rse.ui.SystemMenuManager;
import org.eclipse.rse.ui.messages.SystemMessageDialog; import org.eclipse.rse.ui.messages.SystemMessageDialog;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.rse.ui.view.SystemAdapterHelpers; import org.eclipse.rse.ui.view.SystemAdapterHelpers;
import org.eclipse.rse.useractions.ui.compile.SystemCascadingCompileAction;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
/** /**
@ -83,6 +84,7 @@ public abstract class SystemCompileManager {
private Hashtable compileProfilesPerProfile = new Hashtable(); private Hashtable compileProfilesPerProfile = new Hashtable();
private Hashtable compileSubstitutorsPerConnection = new Hashtable(); private Hashtable compileSubstitutorsPerConnection = new Hashtable();
protected IHost systemConnection; protected IHost systemConnection;
protected String osType = "default"; //$NON-NLS-1$
protected ISubSystemConfiguration subsystemFactory; protected ISubSystemConfiguration subsystemFactory;
/** /**
* As last set by calling setCurrentCompileCommand. Sometimes needed by subclasses. * As last set by calling setCurrentCompileCommand. Sometimes needed by subclasses.
@ -420,4 +422,9 @@ public abstract class SystemCompileManager {
public String getSourceTypePromptMRITooltip() { public String getSourceTypePromptMRITooltip() {
return SystemUDAResources.RESID_WWCOMPCMDS_TYPES_TOOLTIP; return SystemUDAResources.RESID_WWCOMPCMDS_TYPES_TOOLTIP;
} }
public String getOSType()
{
return osType;
}
} }

View file

@ -18,9 +18,9 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection; 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.ui.view.SystemTableViewProvider;
import org.eclipse.rse.internal.useractions.UserActionsResources; import org.eclipse.rse.internal.useractions.UserActionsResources;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources;
import org.eclipse.rse.ui.actions.SystemBaseAction; import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject; import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
@ -141,10 +141,10 @@ public class SystemCompileMultipleSelectAction extends SystemBaseAction {
WorkbenchContentProvider cprovider = new WorkbenchContentProvider(); WorkbenchContentProvider cprovider = new WorkbenchContentProvider();
SystemTableViewProvider lprovider = new SystemTableViewProvider(null); SystemTableViewProvider lprovider = new SystemTableViewProvider(null);
// TODO: Cannot use WorkbenchMessages -- it's internal // 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()); dlg.setInitialSelections(input.getChildren());
// TODO: Cannot use WorkbenchMessages -- it's internal // TODO: Cannot use WorkbenchMessages -- it's internal
dlg.setTitle(GenericMessages.EditorManager_saveResourcesTitle); dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle);
int result = dlg.open(); int result = dlg.open();
//Just return false to prevent the operation continuing //Just return false to prevent the operation continuing
if (result == IDialogConstants.CANCEL_ID) return false; if (result == IDialogConstants.CANCEL_ID) return false;

View file

@ -14,32 +14,17 @@
package org.eclipse.rse.internal.useractions.ui.compile; package org.eclipse.rse.internal.useractions.ui.compile;
import java.io.File; import java.io.File;
import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceHelpers; 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.core.model.ISystemProfile;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
/** /**
* A SystemCompileProfile has a one-to-one correspondence with a SystemProfile. There is one * A SystemCompileProfile has a one-to-one correspondence with a SystemProfile. There is one
@ -181,7 +166,9 @@ public abstract class SystemCompileProfile {
* folder. * folder.
*/ */
public void writeToDisk() { public void writeToDisk() {
write(compileTypes); //We need to get the compile command information from the system profile now.
ISystemProfile systemProfile = RSECorePlugin.getTheSystemProfileManager().getSystemProfile(profileName);
write(compileTypes, systemProfile);
isRead = false; isRead = false;
} }
@ -277,6 +264,29 @@ public abstract class SystemCompileProfile {
*/ */
private Vector read() { private Vector read() {
Vector types = null; Vector types = null;
//We need to get the compile command information from the system profile now.
//Get the propertySet first
String osType = getParentManager().getOSType();
String compileCommandPropertySetName = ISystemCompileXMLConstants.COMPILE_COMMAND_PROPRERTY_SET_PREFIX + osType;
ISystemProfile systemProfile = RSECorePlugin.getTheSystemProfileManager().getSystemProfile(profileName);
IPropertySet compileCommandPropertySet = systemProfile.getPropertySet(compileCommandPropertySetName);
if (null == compileCommandPropertySet)
{
if (parentManager.wantToPrimeWithDefaults(this)) // we only prime the user's private profile with default compile commands
{
types = writeDefaults(systemProfile);
}
else
{
return new Vector();
}
}
else
{
types = getTypes(systemProfile);
}
/*
File file = getCompileProfileJavaFile(); File file = getCompileProfileJavaFile();
// If the file does not exist, then write all IBM supplied default // If the file does not exist, then write all IBM supplied default
// types and compile names first before reading // types and compile names first before reading
@ -288,14 +298,7 @@ public abstract class SystemCompileProfile {
return new Vector(); return new Vector();
} }
} }
try { */
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(file);
types = getTypes(doc);
} catch (Exception e) {
SystemBasePlugin.logError("Error reading compile names XML file for profile " + getProfileName(), e); //$NON-NLS-1$
}
return types; return types;
} }
@ -303,70 +306,82 @@ public abstract class SystemCompileProfile {
* Get all the compile types. * Get all the compile types.
* @return a vector of SystemCompileType objects. * @return a vector of SystemCompileType objects.
*/ */
private Vector getTypes(Document doc) { private Vector getTypes(ISystemProfile systemProfile) {
Vector types = new Vector(); Vector types = new Vector();
Element root = doc.getDocumentElement(); //Get the propertySet first
String oldvrm = root.getAttribute(ISystemCompileXMLConstants.VERSION_ATTRIBUTE); String osType = getParentManager().getOSType();
boolean oldversion = (oldvrm != null) && !oldvrm.equals(ISystemCompileXMLConstants.VERSION_VALUE); String compileCommandPropertySetName = ISystemCompileXMLConstants.COMPILE_COMMAND_PROPRERTY_SET_PREFIX + osType;
NodeList list = doc.getElementsByTagName(ISystemCompileXMLConstants.TYPE_ELEMENT); IPropertySet compileCommandPropertySet = systemProfile.getPropertySet(compileCommandPropertySetName);
if (null == compileCommandPropertySet)
{
return null;
}
IPropertySet[] list = compileCommandPropertySet.getPropertySets(); //This is for all the compile types
if (list == null) return types; if (list == null) return types;
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i); for (int i = 0; i < list.length; i++) {
NamedNodeMap map = node.getAttributes(); IPropertySet compileType = list[i]; //This is one compile type
// get the type IPropertySet[] compileNameList = compileType.getPropertySets();
Node typeAttr = map.getNamedItem(ISystemCompileXMLConstants.TYPE_ATTRIBUTE);
String type = typeAttr.getNodeValue(); IProperty typeProperty = compileType.getProperty(ISystemCompileXMLConstants.TYPE_ATTRIBUTE);
// get the label of the last compile name String type = typeProperty.getValue();
Node lastUsedAttr = map.getNamedItem(ISystemCompileXMLConstants.LASTUSED_ATTRIBUTE); IProperty lastUsedProperty = compileType.getProperty(ISystemCompileXMLConstants.LASTUSED_ATTRIBUTE);
String lastUsed = lastUsedAttr.getNodeValue(); String lastUsed = lastUsedProperty.getValue();
SystemCompileType newType = new SystemCompileType(this, type); SystemCompileType newType = new SystemCompileType(this, type);
NodeList childList = node.getChildNodes();
for (int j = 0; j < childList.getLength(); j++) { for (int j = 0; j < compileNameList.length; j++) {
Node child = childList.item(j); IPropertySet compileName = compileNameList[j]; //This is one compilename
NamedNodeMap childAttrMap = child.getAttributes();
// get the name of the compile name // get the name of the compile name
Node nameAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.LABEL_ATTRIBUTE); IProperty labelProperty = compileName.getProperty(ISystemCompileXMLConstants.LABEL_ATTRIBUTE);
String name = nameAttr.getNodeValue(); String name = labelProperty.getValue();
// get the nature of the compile name // get the nature of the compile name
Node natureAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.NATURE_ATTRIBUTE); IProperty natureProperty = compileName.getProperty(ISystemCompileXMLConstants.NATURE_ATTRIBUTE);
String nature = natureAttr.getNodeValue(); String nature = natureProperty.getValue();
// get the default command string // get the default command string
Node defaultAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.DEFAULT_ATTRIBUTE); IProperty defaultProperty = compileName.getProperty(ISystemCompileXMLConstants.DEFAULT_ATTRIBUTE);
String defaultString = (defaultAttr != null) ? defaultAttr.getNodeValue() : ""; //$NON-NLS-1$ String defaultString = (defaultProperty != null) ? defaultProperty.getValue() : ""; //$NON-NLS-1$
// get the current string // get the current string
Node currentAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.CURRENT_ATTRIBUTE); IProperty currentProperty = compileName.getProperty(ISystemCompileXMLConstants.CURRENT_ATTRIBUTE);
String currentString = currentAttr.getNodeValue(); String currentString = currentProperty.getValue();
// get the menu option // get the menu option
Node menuAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.MENU_ATTRIBUTE); IProperty menuProperty = compileName.getProperty(ISystemCompileXMLConstants.MENU_ATTRIBUTE);
String menuOption = menuAttr.getNodeValue(); String menuOption = menuProperty.getValue();
// get the jobenv option // get the jobenv option
Node jobenvAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.JOBENV_ATTRIBUTE); IProperty jobenvProperty = compileName.getProperty(ISystemCompileXMLConstants.JOBENV_ATTRIBUTE);
String jobEnv = null; String jobEnv = null;
if (jobenvAttr != null) jobEnv = jobenvAttr.getNodeValue(); if (null != jobenvProperty)
{
jobEnv = jobenvProperty.getValue();
}
// get the ordering // get the ordering
IProperty orderProperty = compileName.getProperty(ISystemCompileXMLConstants.ORDER_ATTRIBUTE);
int order = j; int order = j;
Node orderAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.ORDER_ATTRIBUTE);
// to ensure previous beta customers do not have problems // to ensure previous beta customers do not have problems
if (orderAttr != null) { if (null != orderProperty)
order = Integer.valueOf(orderAttr.getNodeValue()).intValue(); {
order = Integer.valueOf(orderProperty.getValue()).intValue();
} }
// get the id option // get the id option
Node idAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.ID_ATTRIBUTE); IProperty idProperty = compileName.getProperty(ISystemCompileXMLConstants.ID_ATTRIBUTE);
String id = null; String id = null;
if (idAttr != null) { if (null != idProperty)
id = idAttr.getNodeValue(); {
id = idProperty.getValue();
} }
// get the label editable option // get the label editable option
Node labelEditableAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.LABEL_EDITABLE_ATTRIBUTE); IProperty labelEditableProperty = compileName.getProperty(ISystemCompileXMLConstants.LABEL_EDITABLE_ATTRIBUTE);
String labelEditable = null; String labelEditable = null;
if (labelEditableAttr != null) { if (null != labelEditableProperty)
labelEditable = labelEditableAttr.getNodeValue(); {
labelEditable = labelEditableProperty.getValue();
} }
// get the label editable option // get the string editable option
Node stringEditableAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.STRING_EDITABLE_ATTRIBUTE); IProperty stringEditableProperty = compileName.getProperty(ISystemCompileXMLConstants.STRING_EDITABLE_ATTRIBUTE);
String stringEditable = null; String stringEditable = null;
if (stringEditableAttr != null) { if (null != stringEditableProperty)
stringEditable = stringEditableAttr.getNodeValue(); {
stringEditable = stringEditableProperty.getValue();
} }
// id can be null, in which case the contructor will try to configure the id automatically // id can be null, in which case the contructor will try to configure the id automatically
// so no need to check for id == null here // so no need to check for id == null here
@ -387,7 +402,10 @@ public abstract class SystemCompileProfile {
} }
if (jobEnv != null) newCmd.setJobEnvironment(jobEnv); if (jobEnv != null) newCmd.setJobEnvironment(jobEnv);
if (name.equalsIgnoreCase(lastUsed)) newType.setLastUsedCompileCommand(newCmd); if (name.equalsIgnoreCase(lastUsed)) newType.setLastUsedCompileCommand(newCmd);
//TODO - XUAN need to handling migration later on
/*
if (oldversion) newCmd = migrateCompileCommand(newCmd, oldvrm); if (oldversion) newCmd = migrateCompileCommand(newCmd, oldvrm);
*/
newType.addCompileCommandInOrder(newCmd); newType.addCompileCommandInOrder(newCmd);
} }
// add compile type and all its contents to the types list // add compile type and all its contents to the types list
@ -399,6 +417,8 @@ public abstract class SystemCompileProfile {
// We only want to add these new default types to the default private profile. // We only want to add these new default types to the default private profile.
// Warning:: this will not handle the case where we want to change a default compile command for // Warning:: this will not handle the case where we want to change a default compile command for
// an existing type with a new release. Need to modify the code below for that. // an existing type with a new release. Need to modify the code below for that.
//TODO - XUAN need to handling migration later on
/*
if (parentManager.wantToPrimeWithDefaults(this) && oldversion) { if (parentManager.wantToPrimeWithDefaults(this) && oldversion) {
SystemDefaultCompileCommands allCmds = parentManager.getDefaultCompileCommands(); SystemDefaultCompileCommands allCmds = parentManager.getDefaultCompileCommands();
if (allCmds == null) { if (allCmds == null) {
@ -449,6 +469,7 @@ public abstract class SystemCompileProfile {
} }
} }
} }
*/
return types; return types;
} }
@ -501,55 +522,59 @@ public abstract class SystemCompileProfile {
/** /**
* Write the contents of the file, given the contents as a Vector of SystemCompileType objects. * Write the contents of the file, given the contents as a Vector of SystemCompileType objects.
*/ */
private void write(Vector types) { private void write(Vector types, ISystemProfile systemProfile) {
File file = getCompileProfileJavaFile();
try { //Get the propertySet first
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); String osType = getParentManager().getOSType();
DocumentBuilder builder = builderFactory.newDocumentBuilder(); String compileCommandPropertySetName = ISystemCompileXMLConstants.COMPILE_COMMAND_PROPRERTY_SET_PREFIX + osType;
Document doc = builder.getDOMImplementation().createDocument(null, ISystemCompileXMLConstants.ROOT_ELEMENT, null); IPropertySet compileCommandPropertySet = systemProfile.getPropertySet(compileCommandPropertySetName);
// get root element and set attributes if (null == compileCommandPropertySet)
Element root = doc.getDocumentElement(); {
root.setAttribute(ISystemCompileXMLConstants.VERSION_ATTRIBUTE, ISystemCompileXMLConstants.VERSION_VALUE); compileCommandPropertySet = systemProfile.createPropertySet(compileCommandPropertySetName);
// write the copyright info }
Element copyright = doc.createElement(ISystemCompileXMLConstants.COPYRIGHT_ELEMENT);
Text copyrightText = doc.createTextNode(ISystemCompileXMLConstants.COPYRIGHT_TEXT);
copyright.appendChild(copyrightText);
root.appendChild(copyright);
// write type and compile commands for each // write type and compile commands for each
for (int i = 0; i < types.size(); i++) { for (int i = 0; i < types.size(); i++) {
SystemCompileType type = (SystemCompileType) (types.get(i)); SystemCompileType compileType = (SystemCompileType) (types.get(i));
Element typeElement = doc.createElement(ISystemCompileXMLConstants.TYPE_ELEMENT); //Element typeElement = doc.createElement(ISystemCompileXMLConstants.TYPE_ELEMENT);
typeElement.setAttribute(ISystemCompileXMLConstants.TYPE_ATTRIBUTE, type.getType()); //typeElement.setAttribute(ISystemCompileXMLConstants.TYPE_ATTRIBUTE, type.getType());
SystemCompileCommand lastUsedCompileName = type.getLastUsedCompileCommand(); SystemCompileCommand lastUsedCompileName = compileType.getLastUsedCompileCommand();
String lastUsedName = null; String lastUsedName = null;
if (lastUsedCompileName == null) { if (lastUsedCompileName == null) {
lastUsedName = ""; //$NON-NLS-1$ lastUsedName = ""; //$NON-NLS-1$
} else { } else {
lastUsedName = lastUsedCompileName.getLabel(); lastUsedName = lastUsedCompileName.getLabel();
} }
typeElement.setAttribute(ISystemCompileXMLConstants.LASTUSED_ATTRIBUTE, lastUsedName); //now create a propertySet for this compile type
Vector cmds = type.getCompileCommands();
IPropertySet thisCompileTypePropertySet = compileCommandPropertySet.createPropertySet(compileType.getType() + i);
//Set its properties.
thisCompileTypePropertySet.addProperty(ISystemCompileXMLConstants.LASTUSED_ATTRIBUTE, lastUsedName);
thisCompileTypePropertySet.addProperty(ISystemCompileXMLConstants.TYPE_ATTRIBUTE, compileType.getType());
Vector cmds = compileType.getCompileCommands();
for (int j = 0; j < cmds.size(); j++) { for (int j = 0; j < cmds.size(); j++) {
SystemCompileCommand cmd = (SystemCompileCommand) (cmds.get(j)); SystemCompileCommand cmd = (SystemCompileCommand) (cmds.get(j));
Element cmdElement = doc.createElement(ISystemCompileXMLConstants.COMPILECOMMAND_ELEMENT); IPropertySet thisCompileCommandPropertySet = thisCompileTypePropertySet.createPropertySet(cmd.getLabel() + j);
if (cmd.getId() != null) { if (null != cmd.getId())
cmdElement.setAttribute(ISystemCompileXMLConstants.ID_ATTRIBUTE, cmd.getId()); {
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.ID_ATTRIBUTE, cmd.getId());
} }
cmdElement.setAttribute(ISystemCompileXMLConstants.LABEL_ATTRIBUTE, cmd.getLabel()); thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.LABEL_ATTRIBUTE, cmd.getLabel());
cmdElement.setAttribute(ISystemCompileXMLConstants.NATURE_ATTRIBUTE, cmd.getNature()); thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.NATURE_ATTRIBUTE, cmd.getNature());
cmdElement.setAttribute(ISystemCompileXMLConstants.DEFAULT_ATTRIBUTE, cmd.getDefaultString()); thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.DEFAULT_ATTRIBUTE, cmd.getDefaultString());
cmdElement.setAttribute(ISystemCompileXMLConstants.CURRENT_ATTRIBUTE, cmd.getCurrentString()); thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.CURRENT_ATTRIBUTE, cmd.getCurrentString());
cmdElement.setAttribute(ISystemCompileXMLConstants.MENU_ATTRIBUTE, cmd.getMenuOption()); thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.ID_ATTRIBUTE, cmd.getId());
cmdElement.setAttribute(ISystemCompileXMLConstants.ORDER_ATTRIBUTE, String.valueOf(j)); thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.MENU_ATTRIBUTE, cmd.getMenuOption());
cmdElement.setAttribute(ISystemCompileXMLConstants.LABEL_EDITABLE_ATTRIBUTE, String.valueOf(cmd.isLabelEditable())); thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.ORDER_ATTRIBUTE, String.valueOf(j));
cmdElement.setAttribute(ISystemCompileXMLConstants.STRING_EDITABLE_ATTRIBUTE, String.valueOf(cmd.isCommandStringEditable())); thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.LABEL_EDITABLE_ATTRIBUTE, String.valueOf(cmd.isLabelEditable()));
if (cmd.getJobEnvironment() != null) { if (cmd.getJobEnvironment() != null) {
cmdElement.setAttribute(ISystemCompileXMLConstants.JOBENV_ATTRIBUTE, cmd.getJobEnvironment()); thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.JOBENV_ATTRIBUTE, cmd.getJobEnvironment());
} }
typeElement.appendChild(cmdElement);
} }
root.appendChild(typeElement);
} }
//Need to persist it.
systemProfile.commit();
/*
// write out document to XML file // write out document to XML file
TransformerFactory transformerFactory = TransformerFactory.newInstance(); TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer(); Transformer transformer = transformerFactory.newTransformer();
@ -558,18 +583,16 @@ public abstract class SystemCompileProfile {
transformer.transform(input, output); transformer.transform(input, output);
// now refresh the eclipse workspace model for the parent folder, to recognize changes we made // now refresh the eclipse workspace model for the parent folder, to recognize changes we made
SystemResourceHelpers.getResourceHelpers().refreshResource(getCompileFolder()); SystemResourceHelpers.getResourceHelpers().refreshResource(getCompileFolder());
} catch (Exception e) { */
SystemBasePlugin.logError("Error writing compile names xml file for profile " + getProfileName(), e); //$NON-NLS-1$
}
} }
/** /**
* Prime document with default (supplied) types and names. * Prime document with default (supplied) types and names.
* Return true if any written, false if none to write. * Return true if any written, false if none to write.
*/ */
private boolean writeDefaults() { private Vector writeDefaults(ISystemProfile systemProfile) {
SystemDefaultCompileCommands allCmds = parentManager.getDefaultCompileCommands(); SystemDefaultCompileCommands allCmds = parentManager.getDefaultCompileCommands();
if (allCmds == null) return false; if (allCmds == null) return null;
String[] defaultTypes = allCmds.getAllDefaultSuppliedSourceTypes(); String[] defaultTypes = allCmds.getAllDefaultSuppliedSourceTypes();
Vector types = new Vector(); Vector types = new Vector();
for (int i = 0; i < defaultTypes.length; i++) { for (int i = 0; i < defaultTypes.length; i++) {
@ -595,9 +618,9 @@ public abstract class SystemCompileProfile {
} }
types.add(type); types.add(type);
} }
write(types); write(types, systemProfile);
//printCommandsByType(types); // temporary, for debugging //printCommandsByType(types); // temporary, for debugging
return (defaultTypes.length > 0); return types;
} }
/** /**

View file

@ -28,7 +28,6 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemModelChangeEvents; 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.ui.view.SystemViewMenuListener;
import org.eclipse.rse.internal.useractions.IUserActionsModelChangeEvents; import org.eclipse.rse.internal.useractions.IUserActionsModelChangeEvents;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources;
@ -122,7 +121,7 @@ public class SystemWorkWithCompileCommandsDialog extends SystemPromptDialog impl
this.currentCompProfile = currentCompProfile; this.currentCompProfile = currentCompProfile;
this.compProfiles = new SystemCompileProfile[] { currentCompProfile }; this.compProfiles = new SystemCompileProfile[] { currentCompProfile };
this.supportsAddSrcTypeButton = true; this.supportsAddSrcTypeButton = true;
setCancelButtonLabel(SystemResources.BUTTON_CLOSE); setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE);
setShowOkButton(false); setShowOkButton(false);
setOutputObject(null); setOutputObject(null);
setHelp(); setHelp();

View file

@ -20,11 +20,11 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.useractions.UserActionsResources; import org.eclipse.rse.internal.useractions.UserActionsResources;
import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCommand; 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.SystemMenuManager;
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter; import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
import org.eclipse.rse.ui.view.ISystemPropertyConstants; import org.eclipse.rse.ui.view.ISystemPropertyConstants;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter; import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
import org.eclipse.rse.useractions.ui.compile.SystemWorkWithCompileCommandsAction;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.views.properties.PropertyDescriptor; import org.eclipse.ui.views.properties.PropertyDescriptor;

View file

@ -18,7 +18,6 @@ package org.eclipse.rse.internal.useractions.ui.propertypages;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemModelChangeEvents; import org.eclipse.rse.core.events.ISystemModelChangeEvents;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; 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.IUserActionsModelChangeEvents;
import org.eclipse.rse.internal.useractions.UserActionsResources; import org.eclipse.rse.internal.useractions.UserActionsResources;
import org.eclipse.rse.internal.useractions.ui.compile.ISystemCompileCommandEditPaneHoster; 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.SystemCompileCommandEditPane;
import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; 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.compile.teamview.SystemTeamViewCompileCommandNode;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources;
import org.eclipse.rse.services.clientserver.messages.SystemMessage; import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.SystemWidgetHelpers;
import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage; import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage;
@ -70,8 +70,8 @@ public class SystemTeamViewCompileCommandPropertyPage extends SystemBaseProperty
nbrColumns = 2; nbrColumns = 2;
composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns); composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns);
// Type prompt // Type prompt
String typeLabel = SystemResources.RESID_PP_PROPERTIES_TYPE_LABEL; String typeLabel = SystemUDAResources.RESID_PP_PROPERTIES_TYPE_LABEL;
String typeTooltip = SystemResources.RESID_PP_PROPERTIES_TYPE_TOOLTIP; String typeTooltip = SystemUDAResources.RESID_PP_PROPERTIES_TYPE_TOOLTIP;
labelType = SystemWidgetHelpers.createLabeledLabel(composite_prompts, typeLabel, typeTooltip, false); labelType = SystemWidgetHelpers.createLabeledLabel(composite_prompts, typeLabel, typeTooltip, false);
labelType.setText(UserActionsResources.RESID_PP_COMPILECMD_TYPE_VALUE); labelType.setText(UserActionsResources.RESID_PP_COMPILECMD_TYPE_VALUE);
// Profile prompt // Profile prompt

View file

@ -10,9 +10,9 @@ package org.eclipse.rse.internal.useractions.ui.propertypages;
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * 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.UserActionsResources;
import org.eclipse.rse.internal.useractions.ui.compile.teamview.SystemTeamViewCompileTypeNode; 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.SystemWidgetHelpers;
import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage; import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -43,8 +43,8 @@ public class SystemTeamViewCompileTypePropertyPage extends SystemBasePropertyPag
// Inner composite // Inner composite
Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, 2); Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, 2);
// Type prompt // Type prompt
String typeLabel = SystemResources.RESID_PP_PROPERTIES_TYPE_LABEL; String typeLabel = SystemUDAResources.RESID_PP_PROPERTIES_TYPE_LABEL;
String typeTooltip = SystemResources.RESID_PP_PROPERTIES_TYPE_TOOLTIP; String typeTooltip = SystemUDAResources.RESID_PP_PROPERTIES_TYPE_TOOLTIP;
labelType = createLabeledLabel(composite_prompts, typeLabel, typeTooltip); labelType = createLabeledLabel(composite_prompts, typeLabel, typeTooltip);
labelType.setText(UserActionsResources.RESID_PP_COMPILETYPE_TYPE_VALUE); labelType.setText(UserActionsResources.RESID_PP_COMPILETYPE_TYPE_VALUE);
// Profile prompt // Profile prompt

View file

@ -13,10 +13,10 @@ package org.eclipse.rse.internal.useractions.ui.propertypages;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; 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.UserActionsResources;
import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDAEditPaneHoster; 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.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.SystemUDActionEditPane;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionElement; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionElement;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDActionSubsystem;
@ -63,7 +63,7 @@ public class SystemTeamViewUserActionPropertyPage extends SystemBasePropertyPage
// Inner composite // Inner composite
composite_prompts = SystemWidgetHelpers.createComposite(parent, 2); composite_prompts = SystemWidgetHelpers.createComposite(parent, 2);
// Type prompt // 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); labelType.setText(UserActionsResources.RESID_PP_USERACTION_TYPE_VALUE);
// Profile prompt // Profile prompt
labelProfile = createLabeledLabel(composite_prompts, UserActionsResources.RESID_PP_USERACTION_PROFILE_LABEL, UserActionsResources.RESID_PP_USERACTION_PROFILE_TOOLTIP); labelProfile = createLabeledLabel(composite_prompts, UserActionsResources.RESID_PP_USERACTION_PROFILE_LABEL, UserActionsResources.RESID_PP_USERACTION_PROFILE_TOOLTIP);

View file

@ -16,6 +16,13 @@ package org.eclipse.rse.internal.useractions.ui.uda;
* Constants used throughout the User Defined Action framework. * Constants used throughout the User Defined Action framework.
*/ */
public interface ISystemUDAConstants { 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. * The name of the xml tag for domain tags.
* Domains are used to partition actions. * Domains are used to partition actions.
@ -28,7 +35,7 @@ public interface ISystemUDAConstants {
* identifies the domain type. Its values will be * identifies the domain type. Its values will be
* an untranslated name like "Object" or "Folder". * 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 * The name of the xml attribute of domain tags which
* identifies the domain name. Its values will be * 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 * The name of the attribute we consistently use to store an element's name
*/ */
public static final String NAME_ATTR = "Name"; //$NON-NLS-1$ 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 * 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 * 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_ATTR = "release"; //$NON-NLS-1$
public static final String RELEASE_VALUE = "7.5"; //$NON-NLS-1$
} }

View file

@ -10,8 +10,8 @@ package org.eclipse.rse.internal.useractions.ui.uda;
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.w3c.dom.Element;
/** /**
* @author coulthar * @author coulthar
@ -24,7 +24,7 @@ public interface ISystemXMLElementWrapperFactory {
* Given an xml element node, create an instance of the appropriate * Given an xml element node, create an instance of the appropriate
* subclass of SystemXMLElementWrapper to represent it. * 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" * Return the tag name for these elements. Will be "Action" or "Type"

View file

@ -84,7 +84,7 @@ public class SystemUDACascadeAction extends SystemBaseSubMenuAction implements I
} }
ourSubMenu.add(new Separator(ISystemContextMenuConstants.GROUP_WORKWITH)); ourSubMenu.add(new Separator(ISystemContextMenuConstants.GROUP_WORKWITH));
if (wwAction == null) { 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.setText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_LABEL);
wwAction.setToolTipText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_TOOLTIP); wwAction.setToolTipText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_TOOLTIP);
wwAction.allowOnMultipleSelection(true); wwAction.allowOnMultipleSelection(true);

View file

@ -260,6 +260,18 @@ public class SystemUDAResources extends NLS {
public static String RESID_PREF_UDAS_CASCADEBYPROFILE_LABEL; public static String RESID_PREF_UDAS_CASCADEBYPROFILE_LABEL;
public static String RESID_PREF_UDAS_CASCADEBYPROFILE_TOOLTIP; public static String RESID_PREF_UDAS_CASCADEBYPROFILE_TOOLTIP;
public static String SystemCompileManager_0; 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 { static {
// load message values from bundle file // load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, SystemUDAResources.class); NLS.initializeMessages(BUNDLE_NAME, SystemUDAResources.class);

View file

@ -436,3 +436,13 @@ RESID_UCMD_COMMAND_TOOLTIP = Enter the command to invoke
RESID_UCMD_COMAMND_SHELL_LABEL = Command Shell 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. 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

View file

@ -88,6 +88,7 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che
// Current selection not valid if errorMessage not null // Current selection not valid if errorMessage not null
protected SystemMessage errorMessage; protected SystemMessage errorMessage;
protected ISubSystem subsystem; protected ISubSystem subsystem;
protected SystemUDActionSubsystem udaActionSubsys;
protected ISubSystemConfiguration subsystemFactory; protected ISubSystemConfiguration subsystemFactory;
protected ISystemProfile profile; protected ISystemProfile profile;
public SystemUDActionElement currentAction; 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. * 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(); super();
this.subsystem = subsys; this.udaActionSubsys = udaActionSubsys;
this.subsystemFactory = (ssf == null) ? subsys.getSubSystemConfiguration() : ssf; this.subsystem = udaActionSubsys.getSubsystem();
this.profile = (profile == null) ? subsys.getSystemProfile() : profile; this.subsystemFactory = subsystem.getSubSystemConfiguration();
this.profile = (profile == null) ? subsystem.getSystemProfile() : profile;
parentDialog = parent; parentDialog = parent;
treeView = tv; treeView = tv;
commandField = new SystemCommandTextField(getCommandTextViewerConfiguration()); commandField = new SystemCommandTextField(getCommandTextViewerConfiguration());
@ -134,15 +136,7 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che
* Return the user defined action subsystem * Return the user defined action subsystem
*/ */
protected SystemUDActionSubsystem getUDActionSubsystem() { protected SystemUDActionSubsystem getUDActionSubsystem() {
// FIXME - uda can't be coupled to subsystem api return udaActionSubsys;
// if (subsystem!=null)
// return subsystem.getUDActionSubsystem();
// else
// {
// ISubsystemFactoryAdapter adapter = (ISubsystemFactoryAdapter)subsystemFactory.getAdapter(ISubsystemFactoryAdapter.class);
// return adapter.getActionSubSystem(subsystemFactory, null);
// }
return null;
} }
/** /**
@ -168,13 +162,6 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che
return subsystem; return subsystem;
} }
/**
* For child classes to access current subsystem factory.
*/
protected ISubSystemConfiguration getSubSystemFactory() {
return subsystemFactory;
}
/** /**
* For child classes to access current profile * For child classes to access current profile
*/ */
@ -246,7 +233,7 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che
// ------------------------------ // ------------------------------
/** /**
* Method createContents. * Method createContents.
* @param parent * @param parent parent of this pane
* @return Control * @return Control
*/ */
public Control createContents(Composite parent) { public Control createContents(Composite parent) {
@ -318,10 +305,12 @@ public class SystemUDActionEditPane implements SelectionListener, // for the che
//Label filler2 = SystemWidgetHelpers.createLabel(comp, ""); //Label filler2 = SystemWidgetHelpers.createLabel(comp, "");
//((GridData)filler2.getLayoutData()).horizontalSpan = nbrColumns; //((GridData)filler2.getLayoutData()).horizontalSpan = nbrColumns;
// TYPE SELECTION FORM // TYPE SELECTION FORM
if (subsystem != null) if (udaActionSubsys != null)
selectTypesForm = createSelectTypesForm(parentDialog.getShell(), subsystem); selectTypesForm = createSelectTypesForm(parentDialog.getShell(), subsystem, udaActionSubsys);
else else
selectTypesForm = createSelectTypesForm(parentDialog.getShell(), subsystemFactory, profile); {
// FIXME: Xuan - selectTypesForm = createSelectTypesForm(parentDialog.getShell(), profile);
}
if (selectTypesForm != null) { if (selectTypesForm != null) {
selectTypesForm.createContents(comp, nbrColumns); 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. * 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 * @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) { protected SystemUDSelectTypesForm createSelectTypesForm(Shell shell, ISubSystem subsystem, SystemUDActionSubsystem udaActionSubsys) {
// FIXME - UDA can't be coupled to subsystem api
// if (getUDActionSubsystem().supportsTypes())
// return new SystemUDSelectTypesForm(shell, subsystem, subsystem.getUDActionSubsystem().getUDTypeManager());
// else
return null;
}
/** if (udaActionSubsys.supportsTypes())
* Override to use when we have a subsystem factory vs subsystem... eg, when launched from Team view. {
*/ return new SystemUDSelectTypesForm(shell, subsystem, udaActionSubsys.getUDTypeManager());
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
return null; return null;
} }

View file

@ -12,10 +12,11 @@ package org.eclipse.rse.internal.useractions.ui.uda;
*******************************************************************************/ *******************************************************************************/
import java.util.StringTokenizer; 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.core.model.ISystemProfile;
import org.eclipse.rse.internal.useractions.UserActionsIcon; import org.eclipse.rse.internal.useractions.UserActionsIcon;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.w3c.dom.Element;
/** /**
* Represents a single user defined action, as an adaptable * 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 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) * @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); super(e, am, profile, domainType);
} }
@ -79,15 +80,28 @@ public class SystemUDActionElement extends SystemXMLElementWrapper {
/** /**
* Return value of the "Comment" sub-tag * Return value of the "Comment" sub-tag
*/ */
public String getComment() { 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 * Return value of the "Command" sub-tag, which is the current command value
*/ */
public String getCommand() { 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,7 +143,11 @@ public class SystemUDActionElement extends SystemXMLElementWrapper {
* Return value of the "FileTypes" sub-tag * Return value of the "FileTypes" sub-tag
*/ */
public String[] getFileTypes() { public String[] getFileTypes() {
String fts = getTextNode(FILETYPES_TAG); //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 // returns an empty string if no attribute
StringTokenizer st = new StringTokenizer(fts); StringTokenizer st = new StringTokenizer(fts);
int n = st.countTokens(); int n = st.countTokens();
@ -140,11 +158,23 @@ public class SystemUDActionElement extends SystemXMLElementWrapper {
return sa; return sa;
} }
return new String[0];
}
/** /**
* Set the value of the "Comment" sub-tag * Set the value of the "Comment" sub-tag
*/ */
public void setComment(String s) { 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); setUserChanged(true);
} }
@ -152,7 +182,15 @@ public class SystemUDActionElement extends SystemXMLElementWrapper {
* Set the value of the "Command" sub-tag. * Set the value of the "Command" sub-tag.
*/ */
public void setCommand(String s) { 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); setUserChanged(true);
} }
@ -204,7 +242,17 @@ public class SystemUDActionElement extends SystemXMLElementWrapper {
for (int i = 0; i < sa.length; i++) { for (int i = 0; i < sa.length; i++) {
s = s + " " + sa[i]; //$NON-NLS-1$ 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); setUserChanged(true);
} }

View file

@ -11,17 +11,16 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.useractions.ui.uda; package org.eclipse.rse.internal.useractions.ui.uda;
import java.io.File;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.jface.viewers.ITreeContentProvider; 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.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.useractions.UserActionsIcon; import org.eclipse.rse.internal.useractions.UserActionsIcon;
import org.eclipse.rse.internal.useractions.UserActionsPersistenceUtil; import org.eclipse.rse.internal.useractions.UserActionsPersistenceUtil;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.w3c.dom.Element;
/** /**
* Instances of this class hold the UDA definitions unique to: * Instances of this class hold the UDA definitions unique to:
@ -39,9 +38,8 @@ import org.w3c.dom.Element;
public class SystemUDActionManager extends SystemUDBaseManager public class SystemUDActionManager extends SystemUDBaseManager
// implements ErrorHandler, // implements ErrorHandler,
implements ITreeContentProvider { 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 static final String XE_ACTION = "Action"; //$NON-NLS-1$
private final static String UDA_FILENAME = "uda.xml"; //$NON-NLS-1$
/** /**
* Constructor * Constructor
@ -84,13 +82,6 @@ public class SystemUDActionManager extends SystemUDBaseManager
return getActionSubSystem().doActionsMigration(profile, oldRelease); 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. * Get the document root tag name.
* We return "Actions" * We return "Actions"
@ -148,23 +139,6 @@ public class SystemUDActionManager extends SystemUDBaseManager
return (SystemUDActionElement) super.addElement(profile, domain, name); 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 * Return xml element wrapper objects for all actions, for the
* given domain, or for the whole document if domain is -1 (iff * 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 * Given an xml element node, create an instance of the appropriate
* subclass of SystemXMLElementWrapper to represent it. * 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); SystemUDActionElement elementWrapper = new SystemUDActionElement(xmlElementToWrap, this, profile, domain);
return elementWrapper; return elementWrapper;
} }

View file

@ -24,10 +24,10 @@ import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.IStructuredSelection; 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.model.ISystemRegistry;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; 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.ui.view.SystemTableViewProvider;
import org.eclipse.rse.internal.useractions.UserActionsIcon; import org.eclipse.rse.internal.useractions.UserActionsIcon;
import org.eclipse.rse.internal.useractions.ui.ISystemSubstitutor; import org.eclipse.rse.internal.useractions.ui.ISystemSubstitutor;
@ -87,6 +85,7 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor {
protected SystemUDAResolvedTypes udaResolvedTypes; protected SystemUDAResolvedTypes udaResolvedTypes;
protected SystemUDActionElement currentAction; // current action being processed protected SystemUDActionElement currentAction; // current action being processed
protected boolean testAction; // is current action the test action? protected boolean testAction; // is current action the test action?
protected String osType = "default"; //$NON-NLS-1$
/** /**
* Constructor * Constructor
@ -120,7 +119,7 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor {
* @return translated label * @return translated label
*/ */
protected String getNewNodeActionLabel() { 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 * @return translated label
*/ */
protected String getNewNodeTypeLabel() { 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. * @param tv - the tree view if the parent is a dialog.
* */ * */
public SystemUDActionEditPane getCustomUDActionEditPane(ISubSystem ss, ISubSystemConfiguration ssFactory, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { 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 may override to provide a custom type edit pane subclass.
* Subclasses should override if they want to return their own types pane. * 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 parent - the hosting dialog/property page
* @param tv - the tree view if the parent is a dialog. * @param tv - the tree view if the parent is a dialog.
*/ */
public SystemUDTypeEditPane getCustomUDTypeEditPane(ISubSystem ss, ISubSystemConfiguration ssconfig, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { public SystemUDTypeEditPane getCustomUDTypeEditPane(ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) {
return new SystemUDTypeEditPane(ss, ssconfig, profile, parent, tv); return new SystemUDTypeEditPane(this, 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);
} }
// ************************************************************** // **************************************************************
@ -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. * @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) { 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); processingSelection(true);
Iterator elements = selection.iterator(); Iterator elements = selection.iterator();
this.currentAction = action; this.currentAction = action;
@ -500,7 +480,7 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor {
Thread.sleep(500L); Thread.sleep(500L);
} catch (Exception exc) { } catch (Exception exc) {
} // defect 46380: give action's command time to run? I don't know, but this works! } // 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. // todo! verify we are sending the right event! ok, done... its the right one.
} }
if (testWriter != null && testFile != null) { 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 * If given a profile, the list is scoped to that, else it includes actions
* for all active profiles. * 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 // access UDA tree for this subsystem
SystemUDActionManager actMgr = getUDActionManager(); SystemUDActionManager actMgr = getUDActionManager();
// Go through each profile for this subsystem's factory // Go through each profile for this subsystem's factory
@ -781,28 +761,39 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor {
int domain = -1; int domain = -1;
if (supportsDomains()) { if (supportsDomains()) {
domain = getDomainFromSelection(selection); domain = getDomainFromSelection(selection);
if (domain == -1) return; if (domain == -1)
return new Action[0];
} }
boolean multiSelection = (selection.size() != 1); boolean multiSelection = (selection.size() != 1);
ArrayList actionList = new ArrayList();
for (int idx = 0; idx < profiles.length; idx++) { for (int idx = 0; idx < profiles.length; idx++) {
profile = profiles[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. // Scan UDA's for matching types and add to menu.
// if any match, then create the initial UDA submenu cascade item // if any match, then create the initial UDA submenu cascade item
for (int i = 0; i < actions.length; i++) { for (int i = 0; i < actionElements.length; i++) {
SystemUDActionElement action = actions[i]; SystemUDActionElement actionElement = actionElements[i];
if (!action.getShow()) continue; if (!actionElement.getShow()) continue;
if (multiSelection && action.getSingleSelection()) continue; if (multiSelection && actionElement.getSingleSelection()) continue;
if (supportsDomains() && (domain != action.getDomain())) continue; // newly added... we were getting file actions on folders if (supportsDomains() && (domain != actionElement.getDomain())) continue; // newly added... we were getting file actions on folders
if (!supportsTypes() || meetsSelection(action, selection, domain)) { if (!supportsTypes() || meetsSelection(actionElement, selection, domain)) {
SystemUDAsBaseAction uda = new SystemUDAsBaseAction(action, shell, this); SystemUDAsBaseAction uda = new SystemUDAsBaseAction(actionElement, shell, this);
uda.setSelection(selection); uda.setSelection(selection);
uda.setShell(shell); uda.setShell(shell);
uda.setEnabled(!getWorkingOfflineMode()); uda.setEnabled(!getWorkingOfflineMode());
actionList.add(uda);
if (null != menu)
{
menu.add(uda); menu.add(uda);
} }
}
} // end for-loop } // end for-loop
} // end for all profiles 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(); WorkbenchContentProvider cprovider = new WorkbenchContentProvider();
SystemTableViewProvider lprovider = new SystemTableViewProvider(); SystemTableViewProvider lprovider = new SystemTableViewProvider();
// TODO: Cannot use WorkbenchMessages -- it's internal // 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.setInitialSelections(input.getChildren());
dlg.setTitle(GenericMessages.EditorManager_saveResourcesTitle); dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle);
int result = dlg.open(); int result = dlg.open();
//Just return false to prevent the operation continuing //Just return false to prevent the operation continuing
if (result == IDialogConstants.CANCEL_ID) return false; if (result == IDialogConstants.CANCEL_ID) return false;
@ -1144,4 +1135,9 @@ public abstract class SystemUDActionSubsystem implements ISystemSubstitutor {
*/ */
protected void processingSelection(boolean processingSelection) { protected void processingSelection(boolean processingSelection) {
} }
public String getOSType()
{
return osType;
}
} }

View file

@ -28,9 +28,8 @@ public class SystemUDActionTreeView extends SystemUDBaseTreeView {
/** /**
* Constructor when we have a subsystem * Constructor when we have a subsystem
*/ */
public SystemUDActionTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystem ss) { public SystemUDActionTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystem ss, SystemUDActionSubsystem udaActionSubsystem) {
// FIXME - UDA can't be coupled with subsystem API super(parent, editPane, ss, udaActionSubsystem.getUDActionManager());
super(parent, editPane, ss, /*ss.getUDActionSubsystem().getUDActionManager()*/null);
} }
/** /**

View file

@ -11,32 +11,13 @@
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* David Dykstal (IBM) - [186589] move user types, user actions, and compile commands * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands
* API to the user actions plugin * 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; package org.eclipse.rse.internal.useractions.ui.uda;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; 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.IFolder;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent; 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.IResourceDelta;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceHelpers;
import org.eclipse.rse.core.SystemResourceManager; 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.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; 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.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin; import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.messages.SystemMessageDialog;
import org.eclipse.swt.graphics.Image; 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.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.SAXException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
/** /**
* Instances of this class hold the UDA definitions unique to * Instances of this class hold the UDA definitions unique to
* <ol> * <ol>
@ -96,7 +63,7 @@ import org.xml.sax.SAXParseException;
* Architecturally, this class and the SystemXMLElementWrapper class * Architecturally, this class and the SystemXMLElementWrapper class
* encapsulate all knowledge of the fact the underlying store is a xml document. * 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 // state
protected SystemUDActionSubsystem _udas; protected SystemUDActionSubsystem _udas;
protected IFolder importCaseFolder; // Only set during Import processing protected IFolder importCaseFolder; // Only set during Import processing
@ -109,13 +76,13 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
private Hashtable hasChangedByProfile; private Hashtable hasChangedByProfile;
private Hashtable dirPathByProfile; private Hashtable dirPathByProfile;
// used by subclasses that are not profile-indexed // used by subclasses that are not profile-indexed
private Document udocNoProfile; private IPropertySet udocNoProfile;
private boolean hasChangedNoProfile = false; private boolean hasChangedNoProfile = false;
private Object[] dirPathNoProfile; private Object[] dirPathNoProfile;
// Profile for which we are working for actions for... // Profile for which we are working for actions for...
private ISystemProfile currentlyActiveProfile; // set in UDA GUI private ISystemProfile currentlyActiveProfile; // set in UDA GUI
// Clipboard copy/paste support // Clipboard copy/paste support
private Element currentNodeClone = null; private IPropertySet currentNodeClone = null;
private String currentNodeCloneID = ""; //$NON-NLS-1$ private String currentNodeCloneID = ""; //$NON-NLS-1$
// private String currentNodeCloneName = ""; //$NON-NLS-1$ // private String currentNodeCloneName = ""; //$NON-NLS-1$
private int currentNodeCloneDomain = -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 * Given an xml element node, create an instance of the appropriate
* subclass of SystemXMLElementWrapper to represent it. * 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... // ITREECONTENTPROVIDER METHODS...
@ -213,7 +180,17 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
if (!wrapper.isDomain()) if (!wrapper.isDomain())
return false; return false;
else else
return (wrapper.getElement().getFirstChild() != null); {
IPropertySet[] childrenPropertySet = wrapper.getElement().getPropertySets();
if (childrenPropertySet == null || childrenPropertySet.length == 0)
{
return false;
}
else
{
return true;
}
}
} else } else
return false; return false;
} else if (element == null) { } else if (element == null) {
@ -276,11 +253,11 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
*/ */
public Vector getXMLWrappers(Vector children, Object parentOrDomain, ISystemProfile profile) { public Vector getXMLWrappers(Vector children, Object parentOrDomain, ISystemProfile profile) {
int domain = -1; int domain = -1;
Element parentElement = null; IPropertySet parentElement = null;
if (parentOrDomain instanceof SystemXMLElementWrapper) { if (parentOrDomain instanceof SystemXMLElementWrapper) {
parentElement = ((SystemXMLElementWrapper) parentOrDomain).getElement(); parentElement = ((SystemXMLElementWrapper) parentOrDomain).getElement();
domain = ((SystemXMLElementWrapper) parentOrDomain).getDomain(); 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); children = SystemXMLElementWrapper.getChildren(children, parentElement, getDocument(profile), profile, this, domain);
return children; 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 <Actions> or <Types>
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 * Get the current subsystem. Will be null for import, or working in team view when
@ -366,112 +315,26 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
return null; 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: * loadAndParseXMLFile:
* tries to load and parse the specified XML file. * 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 * @param profile the profile in which the user defined actions are kept
* @return the document containing the user defined actions * @return the document containing the user defined actions
*/ */
protected Document loadAndParseXMLFile(String fileName, ISystemProfile profile) { protected IPropertySet loadAndParseXMLFile(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 osType = _udas.getOSType();
String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$
IPropertySet userDefinedActionPropertySet = profile.getPropertySet(udaRootPropertySetName);
return userDefinedActionPropertySet;
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);
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) // ErrorHandler Interface: (XML SAX parsing)
// ********************************************************** // **********************************************************
@ -546,20 +409,15 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
ISystemProfile[] activeProfiles = getActiveSystemProfiles(); ISystemProfile[] activeProfiles = getActiveSystemProfiles();
for (int idx = 0; idx < activeProfiles.length; idx++) { for (int idx = 0; idx < activeProfiles.length; idx++) {
ISystemProfile profile = activeProfiles[idx]; ISystemProfile profile = activeProfiles[idx];
ensureDirPathResolved(profile); //ensureDirPathResolved(profile);
searchDelta(profile, delta, 0); searchDelta(profile, delta, 0);
} }
} else { } else {
ensureDirPathResolved(null); //ensureDirPathResolved(null);
searchDelta(null, delta, 0); 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) { private void searchDelta(ISystemProfile profile, IResourceDelta parent, int nestLevel) {
Object[] dirPath = getProfileIndexedInstanceVariable_dirPath(profile); Object[] dirPath = getProfileIndexedInstanceVariable_dirPath(profile);
String target = (String) dirPath[nestLevel]; 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. * 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" * If not set then we assume it is release "4.0"
*/ */
/*
public String getDocumentRelease(ISystemProfile profile) { public String getDocumentRelease(ISystemProfile profile) {
Document doc = getDocument(profile); Document doc = getDocument(profile);
Element root = doc.getDocumentElement(); Element root = doc.getDocumentElement();
@ -640,17 +499,24 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
else else
return rel; return rel;
} }
*/
/** /**
* Load document for given SystemProfile only if not already done. * Load document for given SystemProfile only if not already done.
*/ */
public Document getDocument(ISystemProfile profile) { public IPropertySet getDocument(ISystemProfile profile) {
Document doc = getProfileIndexedInstanceVariable_Document(profile); IPropertySet doc = getProfileIndexedInstanceVariable_Document(profile);
if (doc == null) { if (doc == null) {
doc = loadUserData(profile); doc = loadUserData(profile);
if (doc == null)
{
//No user action for this profile
return doc;
}
setProfileIndexedInstanceVariable_Document(profile, doc); setProfileIndexedInstanceVariable_Document(profile, doc);
// document is good. Now, check the release date stamped on it. // document is good. Now, check the release date stamped on it.
// if not the current release, then we must consider migration... // if not the current release, then we must consider migration...
/*
Element docroot = doc.getDocumentElement(); Element docroot = doc.getDocumentElement();
String docRelease = docroot.getAttribute(ISystemUDAConstants.RELEASE_ATTR); String docRelease = docroot.getAttribute(ISystemUDAConstants.RELEASE_ATTR);
if ((docRelease == null) || (docRelease.length() == 0)) docRelease = "4.0"; //$NON-NLS-1$ 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); saveUserData(profile);
} }
} }
*/
} else { } else {
} }
return doc; return doc;
} }
@ -676,12 +544,6 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
*/ */
protected abstract boolean doMigration(ISystemProfile profile, String oldRelease); 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 * 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); 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 * 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 * 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() ); //System.out.println("UD load: " + getFileName() );
dataChanged(profile); // not sure why we call this, at this time!! Phil dataChanged(profile); // not sure why we call this, at this time!! Phil
setProfileIndexedInstanceVariable_hasChanged(profile, false); setProfileIndexedInstanceVariable_hasChanged(profile, false);
/*
String fn = getFilePath(profile); String fn = getFilePath(profile);
Document doc = null; Document doc = null;
if (!(new File(fn)).canRead()) if (!(new File(fn)).canRead())
@ -753,25 +590,49 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
else else
doc = loadAndParseXMLFile(fn, profile); doc = loadAndParseXMLFile(fn, profile);
//addListener(); //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 * Create and prime the XML document
*/ */
protected Document createAndPrimeDocument(ISystemProfile profile) { protected IPropertySet createAndPrimeDocument(ISystemProfile profile) {
Document doc = initializeDocument(); //Document doc = initializeDocument();
setProfileIndexedInstanceVariable_Document(profile, doc); //setProfileIndexedInstanceVariable_Document(profile, doc);
SystemXMLElementWrapper[] primedElements = primeDocument(profile); SystemXMLElementWrapper[] primedElements = primeDocument(profile);
if (primedElements != null) { if (primedElements != null) {
for (int idx = 0; idx < primedElements.length; idx++) { for (int idx = 0; idx < primedElements.length; idx++) {
SystemXMLElementWrapper newElement = primedElements[idx]; SystemXMLElementWrapper newElement = primedElements[idx];
newElement.setIBM(true); newElement.setIBM(true);
newElement.setUserChanged(false); newElement.setUserChanged(true);
} }
} }
saveUserData(profile); 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() ); //System.out.println("UD save: No changes. " + getFileName() );
return; return;
} }
/* Old way of toggling off/on resource change monitoring wasnt working profile.commit();
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();
}
ignoreMyResourceChange = false; ignoreMyResourceChange = false;
SystemResourceManager.turnOnResourceEventListening(); 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 * Move given element down one in document, save document
* @return true if move successful * @return true if move successful
*/ */
public boolean moveElementDown(SystemXMLElementWrapper elementWrapper, SystemXMLElementWrapper nextNextElementWrapper) { public boolean moveElementDown(SystemXMLElementWrapper elementWrapper/*, SystemXMLElementWrapper nextNextElementWrapper*/) {
getDocument(elementWrapper.getProfile()); getDocument(elementWrapper.getProfile());
Element element = elementWrapper.getElement(); IPropertySet element = elementWrapper.getElement();
try { IPropertySetContainer parentElement = element.getContainer();
Node parentElement = element.getParentNode(); IPropertySet[] allChildren = parentElement.getPropertySets();
//Node nextElement = element.getNextSibling(); for (int i = 0; i < allChildren.length; ++i)
//Node nextNextElement = nextElement.getNextSibling(); {
if (nextNextElementWrapper != null) if (allChildren[i] == element)
parentElement.insertBefore(element, nextNextElementWrapper.getElement()); {
else if (i < allChildren.length - 1) //not the last one
parentElement.insertBefore(element, null); {
} catch (Exception exc) { allChildren[i] = allChildren[i+1];
SystemBasePlugin.logError("Error moving user action/type down", exc); //$NON-NLS-1$ allChildren[i+1] = element;
return false; }
}
} }
saveUserData(elementWrapper.getProfile()); saveUserData(elementWrapper.getProfile());
return true; return true;
@ -894,16 +677,21 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Move given element up one in document, save document * Move given element up one in document, save document
* @return true if move successful * @return true if move successful
*/ */
public boolean moveElementUp(SystemXMLElementWrapper elementWrapper, SystemXMLElementWrapper previousElementWrapper) { public boolean moveElementUp(SystemXMLElementWrapper elementWrapper/*, SystemXMLElementWrapper previousElementWrapper*/) {
getDocument(elementWrapper.getProfile()); getDocument(elementWrapper.getProfile());
Element element = elementWrapper.getElement(); IPropertySet element = elementWrapper.getElement();
try { IPropertySetContainer parentElement = element.getContainer();
Node parentElement = element.getParentNode(); IPropertySet[] allChildren = parentElement.getPropertySets();
//Node previousElement = element.getPreviousSibling(); for (int i = 0; i < allChildren.length; ++i)
parentElement.insertBefore(element, previousElementWrapper.getElement()); {
} catch (Exception exc) { if (allChildren[i] == element)
SystemBasePlugin.logError("Error moving user action/type up", exc); //$NON-NLS-1$ {
return false; if (i > 0) //not the first one
{
allChildren[i] = allChildren[i-1];
allChildren[i-1] = element;
}
}
} }
saveUserData(elementWrapper.getProfile()); saveUserData(elementWrapper.getProfile());
return true; 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. * 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. * @return an id that uniquely identifies the cloned node, or null if it failed.
*/ */
//TODO - XUAN
/*
public String prepareClipboardCopy(SystemXMLElementWrapper elementWrapper) { public String prepareClipboardCopy(SystemXMLElementWrapper elementWrapper) {
getDocument(elementWrapper.getProfile()); getDocument(elementWrapper.getProfile());
Element element = elementWrapper.getElement(); Element element = elementWrapper.getElement();
@ -933,6 +723,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
// currentNodeCloneName = elementWrapper.getName(); // currentNodeCloneName = elementWrapper.getName();
return currentNodeCloneID; return currentNodeCloneID;
} }
*/
/** /**
* Test if the given ID, read from the clipboard, matches a node we prepared for * 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) { public SystemXMLElementWrapper pasteClipboardCopy(SystemXMLElementWrapper selectedElementWrapper, String id) {
getDocument(selectedElementWrapper.getProfile()); getDocument(selectedElementWrapper.getProfile());
Element selectedElement = selectedElementWrapper.getElement(); IPropertySet selectedElement = selectedElementWrapper.getElement();
SystemXMLElementWrapper pastedElementWrapper = null; SystemXMLElementWrapper pastedElementWrapper = null;
try { try {
Node parentElement = null; IPropertySetContainer parentElement = null;
Element pastedElement = null; IPropertySet pastedElement = null;
if (selectedElementWrapper.isDomain()) { if (selectedElementWrapper.isDomain()) {
parentElement = selectedElement; parentElement = selectedElement;
pastedElement = (Element) parentElement.appendChild(currentNodeClone); parentElement.addPropertySet(currentNodeClone);
pastedElement = currentNodeClone;
} else { } else {
parentElement = selectedElement.getParentNode(); parentElement = selectedElement.getContainer();
pastedElement = (Element) parentElement.insertBefore(currentNodeClone, selectedElement); //TODO - Xuan: need to take care of order here.
parentElement.addPropertySet(currentNodeClone);
pastedElement = currentNodeClone;
} }
pastedElementWrapper = createElementWrapper(pastedElement, selectedElementWrapper.getProfile(), selectedElementWrapper.getDomain()); pastedElementWrapper = createElementWrapper(pastedElement, selectedElementWrapper.getProfile(), selectedElementWrapper.getDomain());
pastedElementWrapper.setName(getUniqueCloneName(pastedElementWrapper)); 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). * Returns root elements for the currently set profile (see setCurrentProfile).
* If this is null, returns root elements for all active profiles * If this is null, returns root elements for all active profiles
*/ */
public Object[] getElements(Object element) { public Object[] getElements(Object element) {
if (!supportsProfiles()) if (!supportsProfiles())
return getElements((ISystemProfile) null, element); return getElements((ISystemProfile) null, element);
@ -1019,6 +814,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
} }
} }
/** /**
* Return root elements for given profile. * 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 // if domains not supported, return singleton New item, plus wrappers
// of any action/type elements found // of any action/type elements found
else { else {
Element parentDomainElement = null; IPropertySetContainer parentDomainElement = null;
if (onlyDomain == -1) if (onlyDomain == -1)
v.add(SystemUDTreeViewNewItem.getOnlyNewItem(isUserActionsManager(), getNewNodeLabel())); v.add(SystemUDTreeViewNewItem.getOnlyNewItem(isUserActionsManager(), getNewNodeLabel()));
else else
@ -1089,7 +885,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* @return translated value for "New" in new icon. Default is "New" * @return translated value for "New" in new icon. Default is "New"
*/ */
protected String getNewNodeLabel() { 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. * Find a child element of a given name.
* Returns the xml node element or null * Returns the xml node element or null
*/ */
public Element findChildByName(ISystemProfile profile, String name, int domain) { public IPropertySet findChildByName(ISystemProfile profile, String name, int domain) {
Document xdoc = getDocument(profile); IPropertySet xdoc = getDocument(profile);
if (getActionSubSystem().supportsDomains() && (domain >= 0)) { if (getActionSubSystem().supportsDomains() && (domain >= 0)) {
Element domainElement = findDomainElement(xdoc, domain); IPropertySet domainElement = findDomainElement(xdoc, domain);
return SystemXMLElementWrapper.findChildByName(domainElement, xdoc, getTagName(), name); return SystemXMLElementWrapper.findChildByName(domainElement, xdoc, getTagName(), name);
} else { } else {
return SystemXMLElementWrapper.findChildByName(null, xdoc, getTagName(), name); 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 * Returns the wrapper of the xml node element or null
*/ */
public SystemXMLElementWrapper findByName(ISystemProfile profile, String name, int domain) { public SystemXMLElementWrapper findByName(ISystemProfile profile, String name, int domain) {
Element element = findChildByName(profile, name, domain); IPropertySet element = findChildByName(profile, name, domain);
if (element == null) if (element == null)
return null; return null;
else else
@ -1169,9 +965,9 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Get a list of existing names, for unique-name checking. * Get a list of existing names, for unique-name checking.
*/ */
public Vector getExistingNames(ISystemProfile profile, int domain) { public Vector getExistingNames(ISystemProfile profile, int domain) {
Document xdoc = getDocument(profile); IPropertySet xdoc = getDocument(profile);
if (getActionSubSystem().supportsDomains() && (domain >= 0)) { if (getActionSubSystem().supportsDomains() && (domain >= 0)) {
Element domainElement = findDomainElement(xdoc, domain); IPropertySet domainElement = findDomainElement(xdoc, domain);
if (domainElement == null) return new Vector(); // defect 46147 if (domainElement == null) return new Vector(); // defect 46147
return SystemXMLElementWrapper.getExistingNames(domainElement, xdoc, getTagName()); return SystemXMLElementWrapper.getExistingNames(domainElement, xdoc, getTagName());
} else { } else {
@ -1185,17 +981,34 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* and creates and returns a wrapper object for it. * and creates and returns a wrapper object for it.
*/ */
public SystemXMLElementWrapper addElement(ISystemProfile profile, int domain, String name) { public SystemXMLElementWrapper addElement(ISystemProfile profile, int domain, String name) {
Document xdoc = getDocument(profile);
SystemXMLElementWrapper newElementWrapper = null; String osType = _udas.getOSType();
Element newtag = xdoc.createElement(getTagName()); String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$
newtag.setAttribute("Name", uppercaseName() ? name.toUpperCase() : name); //$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 // Get domain element, create if necessary
if (getActionSubSystem().supportsDomains()) { if (getActionSubSystem().supportsDomains())
Element se = findOrCreateDomainElement(xdoc, domain); {
se.appendChild(newtag); IPropertySet se = findOrCreateDomainElement(udaRootPropertySet, domain);
} else child = se.createPropertySet(name);
xdoc.getDocumentElement().appendChild(newtag); }
newElementWrapper = createElementWrapper(newtag, profile, domain); 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); setChanged(profile);
return newElementWrapper; return newElementWrapper;
} }
@ -1215,7 +1028,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
/** /**
* Set the profile-indexed document instance variable * 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()) if (!supportsProfiles())
udocNoProfile = doc; udocNoProfile = doc;
else else
@ -1225,11 +1038,11 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
/** /**
* Get the profile-indexed document instance variable * Get the profile-indexed document instance variable
*/ */
private Document getProfileIndexedInstanceVariable_Document(ISystemProfile profile) { private IPropertySet getProfileIndexedInstanceVariable_Document(ISystemProfile profile) {
if (!supportsProfiles()) if (!supportsProfiles())
return udocNoProfile; return udocNoProfile;
else 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 * Get the dir-path has-changed instance variable
*/ */
@ -1290,7 +1093,12 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* returns null * returns null
*/ */
protected SystemXMLElementWrapper getDomainWrapper(ISystemProfile profile, int domain) { 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) if (element != null)
return createDomainElementWrapper(element, profile, domain); return createDomainElementWrapper(element, profile, domain);
else else
@ -1305,23 +1113,20 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* not the order they are found in the document! * not the order they are found in the document!
*/ */
protected Vector createExistingDomainElementWrappers(Vector v, ISystemProfile profile) { protected Vector createExistingDomainElementWrappers(Vector v, ISystemProfile profile) {
Document xdoc = getDocument(profile); IPropertySet xdoc = getDocument(profile);
Element docroot = xdoc.getDocumentElement();
// get the "domain" children of the root, in the pre-determined order of domains // get the "domain" children of the root, in the pre-determined order of domains
NodeList subList = docroot.getChildNodes(); IPropertySet[] subList = xdoc.getPropertySets();
if ((subList == null) || (subList.getLength() == 0)) return v; if ((subList == null) || (subList.length == 0)) return v;
String[] domains = getActionSubSystem().getDomainNames(); String[] domains = getActionSubSystem().getDomainNames();
int subListLen = subList.getLength(); int subListLen = subList.length;
for (int idx = 0; idx < domains.length; idx++) { for (int idx = 0; idx < domains.length; idx++) {
Element match = null; IPropertySet match = null;
for (int jdx = 0; (match == null) && (jdx < subListLen); jdx++) { for (int jdx = 0; (match == null) && (jdx < subListLen); jdx++) {
Node currNode = subList.item(jdx); IPropertySet currNode = subList[jdx];
if ((currNode instanceof Element) && if (isDomainElement(currNode, domains[idx])) {
// is "Domain" tag, and "Type" attr value matches domains[idx]?
isDomainElement((Element) currNode, domains[idx])) {
//Element currElement = (Element)currNode; //Element currElement = (Element)currNode;
//if (currElement.getAttribute(XE_DOMTYPE).equals(domains[idx])) //if (currElement.getAttribute(XE_DOMTYPE).equals(domains[idx]))
match = (Element) currNode; match = currNode;
} }
} }
if (match != null) v.add(createDomainElementWrapper(match, profile, idx)); 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 * 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); 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) * 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. * 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); 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) * 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. * 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); 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) * 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. * 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(); NodeList subList = xdoc.getDocumentElement().getChildNodes();
String domainName = getActionSubSystem().mapDomainName(domain); // unxlated name. Eg "Type" parm String domainName = getActionSubSystem().mapDomainName(domain); // unxlated name. Eg "Type" parm
Element domainElement = null; Element domainElement = null;
@ -1368,6 +1191,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
} }
} }
} }
*/
if (create && (domainElement == null)) domainElement = createDomainElement(xdoc, domain); if (create && (domainElement == null)) domainElement = createDomainElement(xdoc, domain);
return domainElement; 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 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 * @param domain - the integer representation of the domain, used to get its name and translated name
*/ */
protected Element createDomainElement(Document xdoc, int domain) { protected IPropertySet createDomainElement(IPropertySet xdoc, int domain) {
Element element = xdoc.createElement(ISystemUDAConstants.XE_DOMAIN); IPropertySet element = xdoc.createPropertySet(getActionSubSystem().mapDomainXlatedName(domain));
xdoc.getDocumentElement().appendChild(element); element.addProperty(ISystemUDAConstants.XE_DOMTYPE, getActionSubSystem().mapDomainName(domain));
element.setAttribute(ISystemUDAConstants.XE_DOMTYPE, getActionSubSystem().mapDomainName(domain)); element.addProperty(ISystemUDAConstants.XE_DOMNAME, getActionSubSystem().mapDomainXlatedName(domain));
element.setAttribute(ISystemUDAConstants.XE_DOMNAME, getActionSubSystem().mapDomainXlatedName(domain)); element.addProperty(ISystemUDAConstants.TYPE_ATTR, ISystemUDAConstants.XE_DOMAIN);
return element; 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 * Given an xml Element object, return true if it is a Domain
* element. That is, if its tag name is "Domain" * element. That is, if its tag name is "Domain"
*/ */
public static boolean isDomainElement(Element element) { public static boolean isDomainElement(IPropertySet element) {
return (element.getTagName().equals(ISystemUDAConstants.XE_DOMAIN)); return (element.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(ISystemUDAConstants.XE_DOMAIN));
} }
/** /**
* Given an xml Element object, return true if it is a Domain * Given an xml Element object, return true if it is a Domain
* element and its "Type" attribute matches the given name. * 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); 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 * Given an xml Domain element, return true if it's "type" attribute matches
* the given untranslated domain name * the given untranslated domain name
*/ */
public static boolean domainTypeEquals(Element element, String domainName) { public static boolean domainTypeEquals(IPropertySet element, String domainName) {
return (element.getAttribute(ISystemUDAConstants.XE_DOMTYPE).equals(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, * Do so by traversing the tree backwards, back to the Document root,
* then forwards again to verify the child links are in place. * then forwards again to verify the child links are in place.
*/ */
public static boolean inCurrentTree(Node n) { public static boolean inCurrentTree(IPropertySet n) {
if (n instanceof Document) return true; String udaRootType = n.getPropertyValue(ISystemUDAConstants.UDA_ROOT_ATTR);
Node parent = n.getParentNode(); 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; if (null == parent) return false;
// Recursive, walk tree back to root, then finally Document. // 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 // Finally, check this is still a child of the parent
Node sibling = parent.getFirstChild(); IPropertySet[] siblings = parent.getPropertySets();
while (null != sibling) { for (int i=0; i<siblings.length; i++)
if (n == sibling) return true; {
sibling = sibling.getNextSibling(); if (n == siblings[i])
{
return true;
}
} }
return false; return false;
} }

View file

@ -29,6 +29,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemModelChangeEvents; import org.eclipse.rse.core.events.ISystemModelChangeEvents;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
@ -45,7 +46,6 @@ import org.eclipse.rse.ui.messages.SystemMessageDialog;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
@ -54,8 +54,6 @@ import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TreeItem; import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.swt.widgets.Widget; import org.eclipse.swt.widgets.Widget;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
/** /**
* Base class for tree views for both actions and types. * Base class for tree views for both actions and types.
@ -417,8 +415,8 @@ public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, I
public boolean doMoveUp() { public boolean doMoveUp() {
IStructuredSelection selection = (IStructuredSelection) getSelection(); IStructuredSelection selection = (IStructuredSelection) getSelection();
SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement(); SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement();
SystemXMLElementWrapper previousElement = (SystemXMLElementWrapper) getSelectedPreviousTreeItem().getData(); //SystemXMLElementWrapper previousElement = (SystemXMLElementWrapper) getSelectedPreviousTreeItem().getData();
boolean moved = docManager.moveElementUp(firstSelect, previousElement); boolean moved = docManager.moveElementUp(firstSelect/*, previousElement*/);
if (moved) { if (moved) {
refreshElementParent(firstSelect); refreshElementParent(firstSelect);
selectElement(firstSelect); selectElement(firstSelect);
@ -436,10 +434,9 @@ public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, I
public boolean doMoveDown() { public boolean doMoveDown() {
IStructuredSelection selection = (IStructuredSelection) getSelection(); IStructuredSelection selection = (IStructuredSelection) getSelection();
SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement(); SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement();
TreeItem nextNextItem = getSelectedNextNextTreeItem(); //SystemXMLElementWrapper nextElement = null;
SystemXMLElementWrapper nextElement = null; //if (nextNextItem != null) nextElement = (SystemXMLElementWrapper) nextNextItem.getData();
if (nextNextItem != null) nextElement = (SystemXMLElementWrapper) nextNextItem.getData(); boolean moved = docManager.moveElementDown(firstSelect/*, nextElement*/);
boolean moved = docManager.moveElementDown(firstSelect, nextElement);
if (moved) { if (moved) {
refreshElementParent(firstSelect); refreshElementParent(firstSelect);
selectElement(firstSelect); selectElement(firstSelect);
@ -455,6 +452,7 @@ public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, I
* Called by the SystemChangeFilterActionCopyString action class. * Called by the SystemChangeFilterActionCopyString action class.
*/ */
public boolean doCopy() { public boolean doCopy() {
/*
IStructuredSelection selection = (IStructuredSelection) getSelection(); IStructuredSelection selection = (IStructuredSelection) getSelection();
SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement(); SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement();
if (clipboard == null) clipboard = new Clipboard(getShell().getDisplay()); if (clipboard == null) clipboard = new Clipboard(getShell().getDisplay());
@ -462,6 +460,7 @@ public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, I
if (id == null) return false; if (id == null) return false;
TextTransfer transfer = TextTransfer.getInstance(); TextTransfer transfer = TextTransfer.getInstance();
clipboard.setContents(new Object[] { id }, new Transfer[] { transfer }); clipboard.setContents(new Object[] { id }, new Transfer[] { transfer });
*/
return true; return true;
} }
@ -634,7 +633,7 @@ public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, I
* If it is not currently shown in the tree, or there is no parent, returns null. * If it is not currently shown in the tree, or there is no parent, returns null.
*/ */
public TreeItem findParentItem(SystemXMLElementWrapper element) { public TreeItem findParentItem(SystemXMLElementWrapper element) {
Element parentElement = element.getParentDomainElement(); IPropertySet parentElement = element.getParentDomainElement();
TreeItem parentItem = null; TreeItem parentItem = null;
if (parentElement != null) if (parentElement != null)
parentItem = findElement(parentElement); parentItem = findElement(parentElement);
@ -677,7 +676,7 @@ public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, I
* Given an xml node, find the wrapper for the element in the tree, * Given an xml node, find the wrapper for the element in the tree,
* scanning entire tree. * scanning entire tree.
*/ */
private TreeItem findElement(Node searchNode) { private TreeItem findElement(IPropertySet searchNode) {
TreeItem match = null; TreeItem match = null;
TreeItem[] roots = getTree().getItems(); TreeItem[] roots = getTree().getItems();
for (int idx = 0; (match == null) && (idx < roots.length); idx++) for (int idx = 0; (match == null) && (idx < roots.length); idx++)
@ -689,11 +688,11 @@ public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, I
* Given an xml node and parent tree item, find the wrapper for the element in the tree * Given an xml node and parent tree item, find the wrapper for the element in the tree
* under the given parent. * under the given parent.
*/ */
private TreeItem findElement(TreeItem parentItem, Node searchNode) { private TreeItem findElement(TreeItem parentItem, IPropertySet searchNode) {
TreeItem match = null; TreeItem match = null;
// first, check for match on the given parent itself... // first, check for match on the given parent itself...
Object itemData = parentItem.getData(); Object itemData = parentItem.getData();
Element itemNode = null; IPropertySet itemNode = null;
if ((itemData != null) && (itemData instanceof SystemXMLElementWrapper)) { if ((itemData != null) && (itemData instanceof SystemXMLElementWrapper)) {
itemNode = ((SystemXMLElementWrapper) itemData).getElement(); itemNode = ((SystemXMLElementWrapper) itemData).getElement();
if (itemNode == searchNode) return parentItem; if (itemNode == searchNode) return parentItem;

View file

@ -383,7 +383,7 @@ public class SystemUDSelectTypesForm implements SelectionListener {
} else if (src == editButton) { } else if (src == editButton) {
SystemWorkWithFileTypesAction editTypesAction = null; SystemWorkWithFileTypesAction editTypesAction = null;
if (subsystem != null) if (subsystem != null)
editTypesAction = new SystemWorkWithFileTypesAction(shell, subsystem); editTypesAction = new SystemWorkWithFileTypesAction(shell, udtm.getActionSubSystem());
else else
editTypesAction = new SystemWorkWithFileTypesAction(shell, subsystemFactory, profile); editTypesAction = new SystemWorkWithFileTypesAction(shell, subsystemFactory, profile);
if (selection != null) { if (selection != null) {

View file

@ -49,6 +49,7 @@ public class SystemUDTypeEditPane implements ISelectionChangedListener {
private Text textName; private Text textName;
private ISystemUDTypeEditPaneTypesSelector typesEditor; private ISystemUDTypeEditPaneTypesSelector typesEditor;
// input // input
protected SystemUDActionSubsystem udaActionSubsys;
protected ISubSystem subsystem; protected ISubSystem subsystem;
protected ISubSystemConfiguration subsystemFactory; protected ISubSystemConfiguration subsystemFactory;
protected ISystemProfile profile; protected ISystemProfile profile;
@ -79,11 +80,12 @@ public class SystemUDTypeEditPane implements ISelectionChangedListener {
/** /**
* Constructor * Constructor
*/ */
public SystemUDTypeEditPane(ISubSystem ss, ISubSystemConfiguration ssf, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) { public SystemUDTypeEditPane(SystemUDActionSubsystem udaActionSubsys, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) {
super(); super();
subsystem = ss; this.udaActionSubsys = udaActionSubsys;
subsystemFactory = (ssf == null) ? ss.getSubSystemConfiguration() : ssf; subsystem = udaActionSubsys.getSubsystem();
this.profile = (profile == null) ? ss.getSystemProfile() : profile; subsystemFactory = subsystem.getSubSystemConfiguration();
this.profile = subsystem.getSystemProfile();
//this.subsystemFactory = ss.getParentSubSystemFactory(); //this.subsystemFactory = ss.getParentSubSystemFactory();
//this.profile = ss.getSystemProfile(); //this.profile = ss.getSystemProfile();
treeView = tv; treeView = tv;
@ -442,16 +444,7 @@ public class SystemUDTypeEditPane implements ISelectionChangedListener {
* Return the user defined action subsystem * Return the user defined action subsystem
*/ */
protected SystemUDActionSubsystem getUDActionSubsystem() { protected SystemUDActionSubsystem getUDActionSubsystem() {
/* FIXME - UDA not coupled with subsystem API anymore return udaActionSubsys;
if (subsystem!=null)
return subsystem.getUDActionSubsystem();
else
{
ISubsystemFactoryAdapter adapter = (ISubsystemFactoryAdapter)subsystemFactory.getAdapter(ISubsystemFactoryAdapter.class);
return adapter.getActionSubSystem(subsystemFactory, null);
}
*/
return null;
} }
/** /**

View file

@ -10,14 +10,16 @@ package org.eclipse.rse.internal.useractions.ui.uda;
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
import org.eclipse.rse.core.model.IProperty;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.internal.useractions.UserActionsIcon; import org.eclipse.rse.internal.useractions.UserActionsIcon;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.w3c.dom.Element;
/** /**
* Wraps a "Type" XML tag * Wraps a "Type" XML tag
*/ */
public class SystemUDTypeElement extends SystemXMLElementWrapper { public class SystemUDTypeElement extends SystemXMLElementWrapper {
private final static String NO_TYPE = ""; //$NON-NLS-1$
private final static String TYPES_TAG = "Types"; //$NON-NLS-1$ private final static String TYPES_TAG = "Types"; //$NON-NLS-1$
private final static String TYPE_TAG = "Type"; //$NON-NLS-1$ private final static String TYPE_TAG = "Type"; //$NON-NLS-1$
@ -27,7 +29,7 @@ public class SystemUDTypeElement extends SystemXMLElementWrapper {
* @param tm The subsystemFactory-specific manager of actions * @param tm The subsystemFactory-specific manager of actions
* @param domainType - The integer representation of the domain this is in (or this is, for a domain element) * @param domainType - The integer representation of the domain this is in (or this is, for a domain element)
*/ */
public SystemUDTypeElement(Element element, SystemUDTypeManager tm, int domainType) { public SystemUDTypeElement(IPropertySet element, SystemUDTypeManager tm, int domainType) {
super(element, tm, null, domainType); super(element, tm, null, domainType);
} }
@ -35,7 +37,6 @@ public class SystemUDTypeElement extends SystemXMLElementWrapper {
* Return image to use for this item, in tree views * Return image to use for this item, in tree views
*/ */
public Image getImage() { public Image getImage() {
//System.out.println("in getImage(): isIBM()="+isIBM()+", isUserChanged()="+isUserChanged());
Image image = null; Image image = null;
if (isIBM()) { if (isIBM()) {
if (isUserChanged()) if (isUserChanged())
@ -59,14 +60,27 @@ public class SystemUDTypeElement extends SystemXMLElementWrapper {
* Return the list of types * Return the list of types
*/ */
public String getTypes() { public String getTypes() {
return getTextNode(TYPES_TAG); IProperty typesProperty = elm.getProperty(TYPES_TAG);
if (typesProperty != null)
{
return typesProperty.getValue();
}
return NO_TYPE;
} }
/** /**
* Set the list of types * Set the list of types
*/ */
public void setTypes(String s) { public void setTypes(String s) {
IProperty typesProperty = elm.getProperty(TYPES_TAG);
if (typesProperty == null)
{
typesProperty = elm.addProperty(TYPES_TAG, s);
}
else
{
typesProperty.setValue(s);
}
setUserChanged(true); setUserChanged(true);
setTextNode(TYPES_TAG, s);
} }
} }

View file

@ -12,21 +12,12 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.rse.internal.useractions.ui.uda; package org.eclipse.rse.internal.useractions.ui.uda;
import java.io.File;
import java.util.Vector; import java.util.Vector;
import org.eclipse.core.resources.IFile; import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.rse.core.SystemResourceHelpers;
import org.eclipse.rse.core.model.ISystemProfile; 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.UserActionsIcon;
import org.eclipse.rse.internal.useractions.UserActionsPersistenceUtil;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.w3c.dom.Element;
/** /**
* Instances of this class hold the UDA Type definitions unique to * Instances of this class hold the UDA Type definitions unique to
@ -40,11 +31,9 @@ import org.w3c.dom.Element;
* *
*/ */
public class SystemUDTypeManager extends SystemUDBaseManager { public class SystemUDTypeManager extends SystemUDBaseManager {
private static final String XE_ROOT = "FileTypes"; //$NON-NLS-1$ private static final String XE_ROOT = ISystemUDAConstants.FILETYPES_ROOT;
public static final String XE_TYPE = "Type"; //$NON-NLS-1$ public static final String XE_TYPE = "Type"; //$NON-NLS-1$
public static final String ALL_TYPE = "ALL"; //$NON-NLS-1$ public static final String ALL_TYPE = "ALL"; //$NON-NLS-1$
public final static String UDT_FILENAME = "udtype.xml"; //$NON-NLS-1$
private boolean oldFolderChecked = false;
/** /**
* Constructor * Constructor
@ -67,12 +56,6 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
return UserActionsIcon.USERTYPE_NEW.getImage(); return UserActionsIcon.USERTYPE_NEW.getImage();
} }
/**
* Get the name of the file to persist to: udtype.xml
*/
public String getFileName() {
return UDT_FILENAME;
}
/** /**
* Overridable extension point for child classes to do migration of their document. * Overridable extension point for child classes to do migration of their document.
@ -109,7 +92,7 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
* Given an xml element node, create an instance of the appropriate * Given an xml element node, create an instance of the appropriate
* subclass of SystemXMLElementWrapper to represent it. * subclass of SystemXMLElementWrapper to represent it.
*/ */
public SystemXMLElementWrapper createElementWrapper(Element xmlElementToWrap, ISystemProfile profile, int domain) { public SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain) {
SystemUDTypeElement elementWrapper = new SystemUDTypeElement(xmlElementToWrap, this, domain); SystemUDTypeElement elementWrapper = new SystemUDTypeElement(xmlElementToWrap, this, domain);
return elementWrapper; return elementWrapper;
} }
@ -150,68 +133,9 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
return getActionSubSystem().primeDefaultTypes(this); return getActionSubSystem().primeDefaultTypes(this);
} }
// -------------------------------------------------------------------
// OVERRIDE OF PARENT METHODS TO ACCOUNT FOR THE FACT TYPES ARE STORED
// ONLY BY SUBSYSTEM FACTORY, NOT PROFILE
// -------------------------------------------------------------------
/**
* Get the folder containing the xml file used to persist the actions,
* for the given profile
*/
protected IFolder getDocumentFolder(ISubSystemConfiguration subsystemFactory, ISystemProfile profile) {
// return new location, as of R2
IFolder typesFolder = UserActionsPersistenceUtil.getTypeFiltersFolder(subsystemFactory);
// we check here for any residual old types files from R1. If found, we move it
// to the new location right away!
// TODO: DELETE THIS EXPENSIVE LOGIC AFTER A FEW RELEASES.
if (!oldFolderChecked && (profile != null)) {
//if (profile == null)
// profile = subsystem.getSystemProfile();
//System.out.println("Is profile null? " + (profile==null));
IFolder oldFolder = UserActionsPersistenceUtil.getUserActionsFolder(profile.getName(), subsystemFactory);
IFile oldFile = oldFolder.getFile(getFileName());
if (exists(oldFile)) {
//System.out.println("Attempt to move old types folder...");
try {
if (!typesFolder.exists()) // if new folder location does not exist yet, create it...
{
SystemResourceHelpers.getResourceHelpers().createFolder(typesFolder);
}
SystemResourceHelpers.getResourceHelpers().moveFile(typesFolder, oldFile); // now move old file to new folder
} catch (Exception exc) {
SystemBasePlugin.logError("Exception moving old types file! ", exc); //$NON-NLS-1$
}
}
oldFolderChecked = true;
}
return typesFolder;
}
/**
* For some reason the exists() method on IResource is fundamentally not reliable.
* Because of this, we resort to looking ourselves at the file system.
*/
protected boolean exists(IResource resource) {
boolean exists = true;
IPath localOSLocation = resource.getLocation();
if (localOSLocation == null) {
//System.out.println("Testing if old file exists, and localOSLocation is null");
exists = false; // what else?
} else {
File osFile = new File(localOSLocation.toOSString());
//System.out.println("Testing if old file exists : " + localOSLocation.toOSString() + "... " + osFile.exists() );
exists = osFile.exists();
}
return exists;
}
/**
* Intended for IMPORT actions only, where no Subsystem instance available:
*/
public void setFolder(String profileName, String factoryId) {
//importCaseFolder = SystemResourceManager.getUserActionsFolder(profileName, factoryId);
importCaseFolder = UserActionsPersistenceUtil.getTypeFiltersFolder(factoryId);
}
/** /**
* Indicate data has changed for the given profile * Indicate data has changed for the given profile
@ -229,7 +153,8 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
* its types, or null if not found * its types, or null if not found
*/ */
public String getTypesForTypeName(String typeName, int domain) { public String getTypesForTypeName(String typeName, int domain) {
SystemUDTypeElement element = (SystemUDTypeElement) findByName(null, typeName, domain); ISystemProfile profile = getSubSystem().getSystemProfile();
SystemUDTypeElement element = (SystemUDTypeElement) findByName(profile, typeName, domain);
if (element != null) if (element != null)
return element.getTypes(); return element.getTypes();
else else
@ -247,7 +172,7 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
* @return array of type objects * @return array of type objects
*/ */
public SystemUDTypeElement[] getTypes(Vector v, int domain) { public SystemUDTypeElement[] getTypes(Vector v, int domain) {
v = super.getXMLWrappers(v, domain, null); v = super.getXMLWrappers(v, domain, _udas.getSubsystem().getSystemProfile());
if (v == null) return new SystemUDTypeElement[0]; if (v == null) return new SystemUDTypeElement[0];
SystemUDTypeElement[] types = new SystemUDTypeElement[v.size()]; SystemUDTypeElement[] types = new SystemUDTypeElement[v.size()];
for (int idx = 0; idx < types.length; idx++) for (int idx = 0; idx < types.length; idx++)
@ -290,7 +215,8 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
* and is typed to return SystemUDTypeElement * and is typed to return SystemUDTypeElement
*/ */
public SystemUDTypeElement addType(int domain, String name) { public SystemUDTypeElement addType(int domain, String name) {
return (SystemUDTypeElement) super.addElement(null, domain, name); ISystemProfile profile = getSubSystem().getSystemProfile();
return (SystemUDTypeElement) super.addElement(profile, domain, name);
} }
/** /**
@ -311,7 +237,8 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
* Save user data * Save user data
*/ */
public void saveUserData() { public void saveUserData() {
super.saveUserData(null); ISystemProfile profile = getActionSubSystem().getSubsystem().getSystemProfile();
super.saveUserData(profile);
} }
/* /*
* Get our xml document * Get our xml document

View file

@ -35,9 +35,9 @@ public class SystemUDTypeTreeView extends SystemUDBaseTreeView {
/** /**
* Constructor when we have a subsystem * Constructor when we have a subsystem
*/ */
public SystemUDTypeTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystem ss) { public SystemUDTypeTreeView(Composite parent, ISystemUDWorkWithDialog editPane, ISubSystem ss, SystemUDActionSubsystem udaActionSubsystem) {
/* FIXME - UDA not coupled with subsystem API anymore */ /* FIXME - UDA not coupled with subsystem API anymore */
super(parent, editPane, ss, /*ss.getUDActionSubsystem().getUDTypeManager()*/null); super(parent, editPane, ss, udaActionSubsystem.getUDTypeManager());
} }
/** /**

View file

@ -61,7 +61,7 @@ public class SystemUserActionExtension {
return true; return true;
else { else {
//FIXME migrate to using ID //FIXME migrate to using ID
return (types.indexOf(type.getName()) >= 0); return (types.indexOf(type.getId()) >= 0);
} }
} }
} }

View file

@ -16,7 +16,6 @@ import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; 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.RSEUIPlugin;
import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.SystemWidgetHelpers;
import org.eclipse.rse.ui.dialogs.SystemPromptDialog; import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
@ -56,6 +55,7 @@ public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISys
// inputs // inputs
protected ISubSystem subsystem; protected ISubSystem subsystem;
protected ISubSystemConfiguration subsystemFactory; protected ISubSystemConfiguration subsystemFactory;
protected SystemUDActionSubsystem udaActionSubsystem;
//protected String defaultProfileName; //protected String defaultProfileName;
//protected String[] defaultProfileNames; //protected String[] defaultProfileNames;
protected ISystemProfile[] systemProfiles; protected ISystemProfile[] systemProfiles;
@ -68,13 +68,14 @@ public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISys
/** /**
* Constructor when we have a subsystem * 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); super(shell, SystemUDAResources.RESID_WORKWITH_UDAS_TITLE);
setCancelButtonLabel(SystemResources.BUTTON_CLOSE); setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE);
setShowOkButton(false); setShowOkButton(false);
this.shell = shell; this.shell = shell;
this.subsystem = ss; this.subsystem = ss;
this.subsystemFactory = ss.getSubSystemConfiguration(); this.subsystemFactory = ss.getSubSystemConfiguration();
this.udaActionSubsystem = udaActionSubsystem;
setProfiles(RSECorePlugin.getTheSystemProfileManager().getActiveSystemProfiles(), subsystem.getSystemProfile()); setProfiles(RSECorePlugin.getTheSystemProfileManager().getActiveSystemProfiles(), subsystem.getSystemProfile());
//setMinimumSize(600, 520); // x, y //setMinimumSize(600, 520); // x, y
//pack(); //pack();
@ -84,12 +85,13 @@ public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISys
/** /**
* Constructor when we have a subsystem factory * 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); super(shell, SystemUDAResources.RESID_WORKWITH_UDAS_TITLE);
setCancelButtonLabel(SystemResources.BUTTON_CLOSE); setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE);
setShowOkButton(false); setShowOkButton(false);
this.shell = shell; this.shell = shell;
this.subsystemFactory = ssFactory; this.subsystemFactory = ssFactory;
this.udaActionSubsystem = udaActionSubsystem;
setProfiles(RSECorePlugin.getTheSystemProfileManager().getActiveSystemProfiles(), profile); setProfiles(RSECorePlugin.getTheSystemProfileManager().getActiveSystemProfiles(), profile);
//setMinimumSize(600, 520); // x, y //setMinimumSize(600, 520); // x, y
//pack(); //pack();
@ -126,15 +128,7 @@ public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISys
* Return the user defined action subsystem * Return the user defined action subsystem
*/ */
protected SystemUDActionSubsystem getUDActionSubsystem() { protected SystemUDActionSubsystem getUDActionSubsystem() {
/* FIXME - UDA not coupled with subsystem API anymore return udaActionSubsystem;
if (subsystem!=null)
return subsystem.getUDActionSubsystem();
else
{
return ((ISubsystemFactoryAdapter)subsystemFactory.getAdapter(ISubsystemFactoryAdapter.class)).getActionSubSystem(subsystemFactory, null);
}
*/
return null;
} }
/** /**
@ -155,9 +149,12 @@ public class SystemWorkWithUDAsDialog extends SystemPromptDialog implements ISys
getUDActionSubsystem().getUDActionManager().setCurrentProfile(currentProfile); getUDActionSubsystem().getUDActionManager().setCurrentProfile(currentProfile);
// create tree view on left // create tree view on left
if (subsystem != null) if (subsystem != null)
treeView = new SystemUDActionTreeView(composite, this, subsystem); treeView = new SystemUDActionTreeView(composite, this, subsystem, udaActionSubsystem);
else else
treeView = new SystemUDActionTreeView(composite, this, subsystemFactory, currentProfile); {
// FIXME - Xuan
//treeView = new SystemUDActionTreeView(composite, this, subsystemFactory, currentProfile);
}
Control c = treeView.getControl(); Control c = treeView.getControl();
//c.setToolTipText(RSEUIPlugin.getString(RESID_UDA_TREE_TIP)); //c.setToolTipText(RSEUIPlugin.getString(RESID_UDA_TREE_TIP));
GridData data = (GridData) c.getLayoutData(); GridData data = (GridData) c.getLayoutData();

View file

@ -17,7 +17,6 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystem; import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; 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.RSEUIPlugin;
import org.eclipse.rse.ui.SystemWidgetHelpers; import org.eclipse.rse.ui.SystemWidgetHelpers;
import org.eclipse.rse.ui.dialogs.SystemPromptDialog; 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 { public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements ISystemUDWorkWithDialog, Listener, Runnable, ISystemUDAEditPaneHoster {
protected Shell shell; // shell hosting this viewer protected Shell shell; // shell hosting this viewer
protected ResourceBundle rb; protected ResourceBundle rb;
protected SystemUDActionSubsystem udaActionSubsystem;
protected ISubSystem subsystem; protected ISubSystem subsystem;
protected ISubSystemConfiguration subsystemFactory; protected ISubSystemConfiguration subsystemFactory;
protected ISystemProfile profile; protected ISystemProfile profile;
@ -58,11 +58,12 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS
/** /**
* Constructor when we have a subsystem * 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); super(shell, SystemUDAResources.RESID_WORKWITH_UDT_TITLE);
setCancelButtonLabel(SystemResources.BUTTON_CLOSE); setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE);
setShowOkButton(false); setShowOkButton(false);
this.shell = shell; this.shell = shell;
this.udaActionSubsystem = udaActionSubsystem;
this.subsystem = ss; this.subsystem = ss;
this.subsystemFactory = subsystem.getSubSystemConfiguration(); this.subsystemFactory = subsystem.getSubSystemConfiguration();
this.profile = subsystem.getSystemProfile(); this.profile = subsystem.getSystemProfile();
@ -76,7 +77,7 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS
*/ */
public SystemWorkWithUDTypeDialog(Shell shell, ISubSystemConfiguration ssFactory, ISystemProfile profile) { public SystemWorkWithUDTypeDialog(Shell shell, ISubSystemConfiguration ssFactory, ISystemProfile profile) {
super(shell, SystemUDAResources.RESID_WORKWITH_UDT_TITLE); super(shell, SystemUDAResources.RESID_WORKWITH_UDT_TITLE);
setCancelButtonLabel(SystemResources.BUTTON_CLOSE); setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE);
setShowOkButton(false); setShowOkButton(false);
this.shell = shell; this.shell = shell;
this.subsystemFactory = ssFactory; this.subsystemFactory = ssFactory;
@ -119,7 +120,7 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS
Composite composite = SystemWidgetHelpers.createComposite(parent, nbrColumns); Composite composite = SystemWidgetHelpers.createComposite(parent, nbrColumns);
// create tree view on left // create tree view on left
if (subsystem != null) if (subsystem != null)
treeView = new SystemUDTypeTreeView(composite, this, subsystem); treeView = new SystemUDTypeTreeView(composite, this, subsystem, udaActionSubsystem);
else else
treeView = new SystemUDTypeTreeView(composite, this, subsystemFactory, profile); treeView = new SystemUDTypeTreeView(composite, this, subsystemFactory, profile);
Control c = treeView.getControl(); Control c = treeView.getControl();
@ -143,7 +144,7 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS
// editpane = getUDActionSubsystem().getCustomUDTypeEditPane( subsystem, this, treeView); // editpane = getUDActionSubsystem().getCustomUDTypeEditPane( subsystem, this, treeView);
//else //else
// editpane = getUDActionSubsystem().getCustomUDTypeEditPane( subsystemFactory, profile, this, treeView); // editpane = getUDActionSubsystem().getCustomUDTypeEditPane( subsystemFactory, profile, this, treeView);
editpane = getUDActionSubsystem().getCustomUDTypeEditPane(subsystem, subsystemFactory, profile, this, treeView); editpane = getUDActionSubsystem().getCustomUDTypeEditPane(this, treeView);
editpane.createContents(rightSideComposite); editpane.createContents(rightSideComposite);
// now add a visual separator line // now add a visual separator line
addSeparatorLine(rightSideComposite, 1); addSeparatorLine(rightSideComposite, 1);
@ -176,7 +177,10 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS
} }
// add listeners, after expansion... // add listeners, after expansion...
treeView.addSelectionChangedListener(editpane); 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; if (type != null) objectToPreSelect = type;
} else { } else {
//treeView.expandDomainNodes(); //treeView.expandDomainNodes();
@ -201,16 +205,7 @@ public class SystemWorkWithUDTypeDialog extends SystemPromptDialog implements IS
* Return the user defined action subsystem * Return the user defined action subsystem
*/ */
protected SystemUDActionSubsystem getUDActionSubsystem() { protected SystemUDActionSubsystem getUDActionSubsystem() {
/* FIXME - UDA not coupled with subsystem API anymore return udaActionSubsystem;
if (subsystem!=null)
return subsystem.getUDActionSubsystem();
else
{
return ((ISubsystemFactoryAdapter)subsystemFactory.getAdapter(ISubsystemFactoryAdapter.class)).getActionSubSystem(subsystemFactory, null);
}
*/
return null;
} }
/** /**

View file

@ -16,43 +16,41 @@ import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform; 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.rse.core.model.ISystemProfile;
import org.eclipse.swt.graphics.Image; 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. * This is a base class for classes that wrapper UDA elements.
* Eg, there are child classes to represent action xml elements, and * Eg, there are child classes to represent action UDA elements, and
* type xml elements. * type UDA elements.
*/ */
public abstract class SystemXMLElementWrapper implements IAdaptable { public abstract class SystemXMLElementWrapper implements IAdaptable {
//parameters //parameters
protected Element elm; protected IPropertySet elm;
private boolean isDomainElement; private boolean isDomainElement;
private SystemUDBaseManager database; // For setChanged() private SystemUDBaseManager database; // For setChanged()
private ISystemProfile profile; private ISystemProfile profile;
private int domainType; private int domainType;
// constants // 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 * 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 * 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 * The value we place in the Vendor attribute for IBM-supplied actions/types
*/ */
@ -60,15 +58,15 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
/** /**
* Constructor * 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 mgr - The parent manager of these actions/types
* @param profile - The system profile which owns this action * @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) * @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(); super();
this.elm = elm; 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; this.domainType = domainType;
database = mgr; database = mgr;
this.profile = profile; 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; return elm;
} }
/** /**
* Get the document this element is a part of * Get the document this element is a part of
*/ */
public Document getDocument() { public IPropertySet getDocument() {
// this method added by phil. // this method added by phil.
// this allows getChildren in xxxmanager classes to avoid deducing the document // 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 * If domains aren't supported, this will return null
*/ */
public Element getParentDomainElement() { public IPropertySet getParentDomainElement() {
Element parent = getParentElement(); IPropertySet parent = getParentElement();
if ((parent != null) && parent.getTagName().equals(ISystemUDAConstants.XE_DOMAIN)) if ((parent != null) && parent.getPropertyValue(ISystemUDAConstants.NAME_ATTR).equals(ISystemUDAConstants.XE_DOMAIN))
return parent; return parent;
else else
return null; 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. * Only returns null if this is the root, which should never happen.
*/ */
public Element getParentElement() { public IPropertySet getParentElement() {
Node parent = elm.getParentNode(); Object parent = elm.getContainer();
if (parent instanceof Element) if (parent instanceof IPropertySet)
return (Element) parent; return (IPropertySet) parent;
else else
return null; return null;
} }
@ -174,7 +172,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Return the value of this node's "Name" attribute * Return the value of this node's "Name" attribute
*/ */
public String getName() { 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) { public void setName(String s) {
if (isIBM()) { if (isIBM()) {
String orgName = elm.getAttribute(ISystemUDAConstants.ORIGINAL_NAME_ATTR); String orgName = elm.getPropertyValue(ISystemUDAConstants.ORIGINAL_NAME_ATTR);
if ((orgName != null) && (orgName.length() > 0)) { if ((orgName != null) && (orgName.length() > 0)) {
// no need to do anything, as its already set. // 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); setAttribute(ISystemUDAConstants.NAME_ATTR, s);
setUserChanged(true); 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 * For IBM-supplied elements that have been edited, returns the original IBM-supplied name
*/ */
public String getOriginalName() { 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)) if ((s == null) || (s.length() == 0))
return getName(); return getName();
else else
@ -210,7 +219,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* That is, is this an IBM-supplied tag? * That is, is this an IBM-supplied tag?
*/ */
public boolean isIBM() { public boolean isIBM() {
String vendor = elm.getAttribute(XML_ATTR_VENDOR); String vendor = elm.getPropertyValue(UDA_ATTR_VENDOR);
if (vendor == null) if (vendor == null)
return false; return false;
else else
@ -221,7 +230,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Set the name of the vendor who supplied this user action or type * Set the name of the vendor who supplied this user action or type
*/ */
public void setVendor(String vendor) { 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 * May be null, if created by a user
*/ */
public String getVendor() { 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) { public void setIBM(boolean isFromIBM) {
if (isFromIBM) if (isFromIBM)
setAttribute(XML_ATTR_VENDOR, VENDOR_IBM); setAttribute(UDA_ATTR_VENDOR, VENDOR_IBM);
else else
setAttribute(XML_ATTR_VENDOR, null); setAttribute(UDA_ATTR_VENDOR, null);
} }
/** /**
@ -254,7 +263,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
else if (isDomainElement) else if (isDomainElement)
changed = false; changed = false;
else else
changed = getBooleanAttribute(XML_ATTR_CHANGED, false); changed = getBooleanAttribute(UDA_ATTR_CHANGED, false);
//System.out.println("Inside isUserChanged, returning "+changed+": isIBM()="+isIBM()+", isDomainElement="+isDomainElement); //System.out.println("Inside isUserChanged, returning "+changed+": isIBM()="+isIBM()+", isDomainElement="+isDomainElement);
return changed; return changed;
} }
@ -263,7 +272,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Set the value of this tag's "user-changed" attribute * Set the value of this tag's "user-changed" attribute
*/ */
public void setUserChanged(boolean isUserChanged) { 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() { public void deleteElement() {
// Not intended for root. Only for Actions // 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 * Set the value of a boolean attribute
*/ */
public void setBooleanAttribute(String attr, boolean b) { 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); database.setChanged(profile);
} }
@ -355,8 +305,8 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* @param attr - name of the attribute to query * @param attr - name of the attribute to query
*/ */
public boolean getBooleanAttribute(String attr) { public boolean getBooleanAttribute(String attr) {
String val = elm.getAttribute(attr); String val = elm.getPropertyValue(attr);
if (XML_TRUE.equals(val)) return true; if (UDA_TRUE.equals(val)) return true;
return false; return false;
} }
@ -366,9 +316,9 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* @param defaultValue - value to return if the attribute is not found * @param defaultValue - value to return if the attribute is not found
*/ */
public boolean getBooleanAttribute(String attr, boolean defaultValue) { public boolean getBooleanAttribute(String attr, boolean defaultValue) {
String val = elm.getAttribute(attr); String val = elm.getPropertyValue(attr);
if (val == null) return defaultValue; if (val == null) return defaultValue;
if (XML_TRUE.equals(val)) return true; if (UDA_TRUE.equals(val)) return true;
return false; return false;
} }
@ -377,7 +327,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Specify a default value to return if the attribute is not found * Specify a default value to return if the attribute is not found
*/ */
public String getAttribute(String attr, String defaultValue) { public String getAttribute(String attr, String defaultValue) {
String value = elm.getAttribute(attr); String value = elm.getPropertyValue(attr);
if (value == null) value = defaultValue; if (value == null) value = defaultValue;
return value; return value;
} }
@ -387,9 +337,21 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
*/ */
public void setAttribute(String attr, String value) { public void setAttribute(String attr, String value) {
if (value != null) if (value != null)
elm.setAttribute(attr, value); {
IProperty property = elm.getProperty(attr);
if (property == null)
{
elm.addProperty(attr, value);
}
else else
elm.removeAttribute(attr); {
property.setValue(value);
}
}
else
{
elm.removeProperty(attr);
}
database.setChanged(profile); database.setChanged(profile);
} }
@ -400,7 +362,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Always returns a non-null vector, although it may be empty * Always returns a non-null vector, although it may be empty
*/ */
public Vector getExistingNames() { public Vector getExistingNames() {
Element parentElement = null; IPropertySet parentElement = null;
String currName = null; String currName = null;
if (isDomain()) if (isDomain())
parentElement = this.getElement(); parentElement = this.getElement();
@ -418,55 +380,39 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Given a parent element XML node, returns all child action names. * Given a parent element XML node, returns all child action names.
* Always returns a non-null vector, although it may be empty * 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()); return getExistingNames(parentElement, xdoc, getTagName());
} }
/** /**
* For unique-name checking. * 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 * 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(); Vector nameList = new Vector();
Element se = null; IPropertySet[] subList = null;
NodeList subList = null;
if (parentElement != null) if (parentElement != null)
subList = parentElement.getChildNodes(); subList = parentElement.getPropertySets();
else else
subList = xdoc.getElementsByTagName(tagName); subList = xdoc.getPropertySets();
if (subList != null) { if (subList != null) {
for (int idx = 0; idx < subList.getLength(); idx++) { for (int idx = 0; idx < subList.length; idx++) {
Node sn = subList.item(idx); IPropertySet sn = subList[idx];
if (sn instanceof Element) { if (sn.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(tagName))
se = (Element) sn; {
if (se.getTagName().equals(tagName)) { nameList.add(sn.getPropertyValue(ISystemUDAConstants.NAME_ATTR));
nameList.add(se.getAttribute(ISystemUDAConstants.NAME_ATTR));
}
} }
} // end for all subnodes } // end for all subnodes
} // end if sublist != null } // end if sublist != null
return nameList; 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 * 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 * 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()); 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! * 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 * @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(); if (children == null) children = new Vector();
String tagName = factory.getTagName(); String tagName = factory.getTagName();
Element se = null;
NodeList subList = null; IPropertySet[] subList = null;
if (parentElement != null) if (parentElement != null)
subList = parentElement.getChildNodes(); subList = parentElement.getPropertySets();
else else
subList = xdoc.getElementsByTagName(tagName); subList = xdoc.getPropertySets();
if (subList != null) { if (subList != null) {
for (int idx = 0; idx < subList.getLength(); idx++) { for (int idx = 0; idx < subList.length; idx++) {
Node sn = subList.item(idx); IPropertySet sn = subList[idx];
if (sn instanceof Element) { if (sn.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(tagName))
se = (Element) sn; {
if (se.getTagName().equals(tagName)) { SystemXMLElementWrapper thisWrapper = factory.createElementWrapper(sn, profile, domain);
children.add(factory.createElementWrapper(se, profile, domain)); children.add(thisWrapper);
}
} }
} // end for all subnodes } // end for all subnodes
} // end if sublist != null } // 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, * Given a parent element XML node, returns the xml Element node with the given name attribute,
* or null if not found. * or null if not found.
*/ */
public static Element findChildByName(Element parentElement, Document xdoc, String tagName, String searchName) { public static IPropertySet findChildByName(IPropertySet parentElement, IPropertySet xdoc, String tagName, String searchName) {
Element match = null; IPropertySet match = null;
NodeList subList = null; IPropertySet[] subList = null;
if (parentElement != null) if (parentElement != null)
subList = parentElement.getChildNodes(); subList = parentElement.getPropertySets();
else else
subList = xdoc.getElementsByTagName(tagName); subList = xdoc.getPropertySets();
if (subList != null) { if (subList != null) {
for (int idx = 0; (match == null) && (idx < subList.getLength()); idx++) { for (int idx = 0; (match == null) && (idx < subList.length); idx++) {
Node sn = subList.item(idx); IPropertySet sn = subList[idx];
if (sn instanceof Element) { if (sn.getName().equals(searchName))
if (((Element) sn).getTagName().equals(tagName)) { {
if (((Element) sn).getAttribute(ISystemUDAConstants.NAME_ATTR).equals(searchName)) match = (Element) sn; IProperty typeProperty = sn.getProperty(ISystemUDAConstants.TYPE_ATTR);
if (typeProperty.getValue().equals(tagName))
{
match = sn;
} }
} }
} // end for all subnodes } // end for all subnodes

View file

@ -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.ui.view.team.SystemTeamViewSubSystemConfigurationNode;
import org.eclipse.rse.internal.useractions.IUserActionsImageIds; import org.eclipse.rse.internal.useractions.IUserActionsImageIds;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; 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.internal.useractions.ui.uda.SystemWorkWithUDTypeDialog;
import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
@ -31,6 +32,7 @@ import org.eclipse.swt.widgets.Shell;
public class SystemWorkWithFileTypesAction extends SystemBaseDialogAction { public class SystemWorkWithFileTypesAction extends SystemBaseDialogAction {
private ISubSystem subsystem = null; private ISubSystem subsystem = null;
private ISubSystemConfiguration subsystemFactory = null; private ISubSystemConfiguration subsystemFactory = null;
private SystemUDActionSubsystem udaActionSubsystem;
private ISystemProfile profile; private ISystemProfile profile;
private SystemWorkWithUDTypeDialog ourDlg = null; private SystemWorkWithUDTypeDialog ourDlg = null;
private String typeToPreSelect = null; private String typeToPreSelect = null;
@ -41,11 +43,12 @@ public class SystemWorkWithFileTypesAction extends SystemBaseDialogAction {
/** /**
* Constructor when we have a subsystem * Constructor when we have a subsystem
* @param parent The Shell of the parent UI for this dialog * @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(parent);
this.subsystem = subSystem; this.udaActionSubsystem = udaActionSubsystem;
this.subsystem = udaActionSubsystem.getSubsystem();
if (subsystem != null) { if (subsystem != null) {
this.subsystemFactory = subsystem.getSubSystemConfiguration(); this.subsystemFactory = subsystem.getSubSystemConfiguration();
this.profile = subsystem.getSystemProfile(); this.profile = subsystem.getSystemProfile();
@ -115,7 +118,7 @@ public class SystemWorkWithFileTypesAction extends SystemBaseDialogAction {
profile = ssfNode.getProfile(); profile = ssfNode.getProfile();
} }
if (subsystem != null) if (subsystem != null)
ourDlg = new SystemWorkWithUDTypeDialog(parent, subsystem); ourDlg = new SystemWorkWithUDTypeDialog(parent, subsystem, udaActionSubsystem);
else else
ourDlg = new SystemWorkWithUDTypeDialog(parent, subsystemFactory, profile); ourDlg = new SystemWorkWithUDTypeDialog(parent, subsystemFactory, profile);
if (typeToPreSelect != null) ourDlg.preSelectType(preSelectTypeDomain, typeToPreSelect); if (typeToPreSelect != null) ourDlg.preSelectType(preSelectTypeDomain, typeToPreSelect);

View file

@ -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.ui.view.team.SystemTeamViewSubSystemConfigurationNode;
import org.eclipse.rse.internal.useractions.IUserActionsImageIds; import org.eclipse.rse.internal.useractions.IUserActionsImageIds;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; 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.internal.useractions.ui.uda.SystemWorkWithUDAsDialog;
import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
@ -34,15 +35,17 @@ public class SystemWorkWithUDAsAction extends SystemBaseDialogAction {
private ISubSystem subsystem = null; private ISubSystem subsystem = null;
private ISubSystemConfiguration subsystemFactory = null; private ISubSystemConfiguration subsystemFactory = null;
private ISystemProfile profile; private ISystemProfile profile;
private SystemUDActionSubsystem udaActionSubsystem = null;
/** /**
* Constructor when starting with a subsystem (such as in RS view) * Constructor when starting with a subsystem (such as in RS view)
* @param parent The Shell of the parent UI for this dialog * @param parent The Shell of the parent UI for this dialog
* @param subSystem The subsystem we are launching this from/for * @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); this(parent);
setSubSystem(subSystem); setSubSystem(subSystem);
setActionSubsystem(udaActionSubsystem);
setAvailableOffline(true); setAvailableOffline(true);
} }
@ -51,9 +54,10 @@ public class SystemWorkWithUDAsAction extends SystemBaseDialogAction {
* @param parent The Shell of the parent UI for this dialog * @param parent The Shell of the parent UI for this dialog
* @param subSystemFactory The subsystem factory we are launching this from/for * @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); this(parent);
setSubSystemFactory(subsystemFactory, profile); setSubSystemFactory(subsystemFactory, profile);
setActionSubsystem(udaActionSubsystem);
} }
/** /**
@ -117,6 +121,9 @@ public class SystemWorkWithUDAsAction extends SystemBaseDialogAction {
this.profile = profile; this.profile = profile;
} }
public void setActionSubsystem(SystemUDActionSubsystem udaActionSubsystem) {
this.udaActionSubsystem = udaActionSubsystem;
}
/** /**
* Called by SystemBaseAction when selection is set. * Called by SystemBaseAction when selection is set.
* Our opportunity to verify we are allowed for this selected type. * Our opportunity to verify we are allowed for this selected type.
@ -156,9 +163,9 @@ public class SystemWorkWithUDAsAction extends SystemBaseDialogAction {
} }
SystemWorkWithUDAsDialog dlg = null; SystemWorkWithUDAsDialog dlg = null;
if (subsystem != null) if (subsystem != null)
dlg = new SystemWorkWithUDAsDialog(parent, subsystem); dlg = new SystemWorkWithUDAsDialog(parent, subsystem, udaActionSubsystem);
else else
dlg = new SystemWorkWithUDAsDialog(parent, subsystemFactory, profile); dlg = new SystemWorkWithUDAsDialog(parent, subsystemFactory, profile, udaActionSubsystem);
return dlg; return dlg;
} }

View file

@ -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);
}

View file

@ -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;
}
}

View file

@ -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);
}

View file

@ -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;
}
}

View file

@ -9,7 +9,7 @@
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry * 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.IMenuListener;
import org.eclipse.jface.action.IMenuManager; 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.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.useractions.UserActionsResources; 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.ISystemContextMenuConstants;
import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemPreferencesManager; import org.eclipse.rse.ui.SystemPreferencesManager;

View file

@ -10,7 +10,7 @@
* Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin * 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 * 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.ArrayList;
import java.util.List; import java.util.List;
@ -18,10 +18,14 @@ import java.util.List;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.IStructuredSelection; 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.ui.view.SystemTableViewProvider;
import org.eclipse.rse.internal.useractions.Activator; import org.eclipse.rse.internal.useractions.Activator;
import org.eclipse.rse.internal.useractions.IUserActionsImageIds; 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.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemBaseAction; import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject; import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
@ -178,10 +182,10 @@ public class SystemCompileAction extends SystemBaseAction {
WorkbenchContentProvider cprovider = new WorkbenchContentProvider(); WorkbenchContentProvider cprovider = new WorkbenchContentProvider();
SystemTableViewProvider lprovider = new SystemTableViewProvider(null); SystemTableViewProvider lprovider = new SystemTableViewProvider(null);
// TODO: Cannot use WorkbenchMessages -- it's internal // 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()); dlg.setInitialSelections(input.getChildren());
// TODO: Cannot use WorkbenchMessages -- it's internal // TODO: Cannot use WorkbenchMessages -- it's internal
dlg.setTitle(GenericMessages.EditorManager_saveResourcesTitle); dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle);
int result = dlg.open(); int result = dlg.open();
//Just return false to prevent the operation continuing //Just return false to prevent the operation continuing
if (result == IDialogConstants.CANCEL_ID) return false; if (result == IDialogConstants.CANCEL_ID) return false;

View file

@ -11,8 +11,9 @@
* David Dykstal (IBM) - [186589] move user types, user actions, and compile commands * David Dykstal (IBM) - [186589] move user types, user actions, and compile commands
* API to the user actions plugin * 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.dialogs.Dialog;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile; 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.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.ui.view.team.SystemTeamViewSubSystemConfigurationNode; import org.eclipse.rse.internal.ui.view.team.SystemTeamViewSubSystemConfigurationNode;
import org.eclipse.rse.internal.useractions.IUserActionsImageIds; 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.compile.teamview.SystemTeamViewCompileTypeNode;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources; import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources;
import org.eclipse.rse.ui.ISystemContextMenuConstants; 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.actions.SystemBaseDialogAction;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.rse.ui.view.SystemAdapterHelpers; import org.eclipse.rse.ui.view.SystemAdapterHelpers;
import org.eclipse.rse.useractions.files.compile.ISystemCompileManagerAdapter;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
/** /**
@ -113,19 +118,29 @@ public class SystemWorkWithCompileCommandsAction extends SystemBaseDialogAction
if (currSystemProfile == null) currSystemProfile = subsystem.getSystemProfile(); if (currSystemProfile == null) currSystemProfile = subsystem.getSystemProfile();
} }
if (ssf != null) { if (ssf != null) {
/* FIXME - compile actions not coupled with subsystem API anymore
compileManager = ssf.getCompileManager(); ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration();
if (subsystem != null)
if (inputObject instanceof IAdaptable) {
ISystemCompileManagerAdapter adapter = (ISystemCompileManagerAdapter)((IAdaptable)inputObject).getAdapter(ISystemCompileManagerAdapter.class);
if (null != adapter)
{ {
compileManager.setSystemConnection(subsystem.getHost()); compileManager = adapter.getSystemCompileManager(ssc);
} }
}
if (null != compileManager)
{
if (currSystemProfile != null) if (currSystemProfile != null)
{
currProfile = compileManager.getCompileProfile(currSystemProfile); currProfile = compileManager.getCompileProfile(currSystemProfile);
currProfiles = compileManager.getAllCompileProfiles(); currProfiles = compileManager.getAllCompileProfiles();
*/
caseSensitive = ssf.isCaseSensitive();
} }
caseSensitive = ssf.isCaseSensitive();
SystemWorkWithCompileCommandsDialog dlg = new SystemWorkWithCompileCommandsDialog(shell, compileManager, currProfile); SystemWorkWithCompileCommandsDialog dlg = new SystemWorkWithCompileCommandsDialog(shell, compileManager, currProfile);
/* FIXME - currProfiles cannot be null since above stuff was commented out /* FIXME - currProfiles cannot be null since above stuff was commented out
if (currProfiles != null) { if (currProfiles != null) {
@ -141,6 +156,9 @@ public class SystemWorkWithCompileCommandsAction extends SystemBaseDialogAction
} }
return dlg; return dlg;
} }
}
return null;
}
/** /**
* Required by parent. We use it to return the new name. * Required by parent. We use it to return the new name.