1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 15:15:25 +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)"
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
Export-Package: org.eclipse.rse.internal.useractions,
Export-Package: org.eclipse.rse.useractions.ui.compile,
org.eclipse.rse.useractions.files.compile,
org.eclipse.rse.useractions.files.uda,
org.eclipse.rse.internal.useractions.ui.compile,
org.eclipse.rse.internal.useractions,
org.eclipse.rse.internal.useractions.files.compile,
org.eclipse.rse.internal.useractions.files.uda,
org.eclipse.rse.internal.useractions.ui,

View file

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

View file

@ -39,21 +39,31 @@
</page>
</extension>
<extension point="org.eclipse.ui.menus">
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.rse.ui.view.systemView">
<menu id="org.eclipse.rse.ui.useractions.menu"
label="Dynamic menu test"
mnemonic="useractions.dynamicmenu.mnemonic">
<dynamic class="org.eclipse.rse.internal.useractions.ui.DynamicMenuTest"
id="org.eclipse.ui.rse.ui.views.dynamicmenutest">
<menu id="org.eclipse.rse.ui.useractions.compile.menu"
label="%DynamicLabel.CompileActionNode"
mnemonic="useractions.dynamiccompilemenu.mnemonic">
<dynamic class="org.eclipse.rse.internal.useractions.ui.SystemDynamicCompileMenu"
id="org.eclipse.ui.rse.ui.views.dynamiccompilemenu">
</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>
</menuContribution>
</extension>
</plugin>

View file

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

View file

@ -23,10 +23,11 @@ import org.eclipse.swt.widgets.Shell;
public class UniversalCompilableSource extends SystemCompilableSource {
/**
* Constructor for UniversalCompilableSource.
* @param shell
* @param firstSelection
* @param compileCmd
* @param isPrompt
* @param shell - the shell to use if need to prompt
* @param firstSelection - the selected compilable source member
* @param compileCmd - the Compile Command that is to be run against the selected compilable source member
* @param isPrompt - true if the user choose the flavor of the action to prompt the compile command
* @param viewer - the viewer that originated the compile action
*/
public UniversalCompilableSource(Shell shell, Object firstSelection, SystemCompileCommand compileCmd, boolean isPrompt, Viewer viewer) {
super(shell, firstSelection, compileCmd, isPrompt, viewer);

View file

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

View file

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

View file

@ -19,11 +19,11 @@ import java.util.Vector;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.useractions.UserActionsIcon;
import org.eclipse.rse.internal.useractions.ui.SystemCmdSubstVarList;
import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDAConstants;
import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDAEditPaneHoster;
import org.eclipse.rse.internal.useractions.ui.uda.ISystemUDTreeView;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources;
@ -283,7 +283,7 @@ public class UDActionSubsystemFiles extends SystemUDActionSubsystem {
* @param cmdString - the resolved command
* @param cmdSubSystem - this connection's command subsystem, which will run the command
* @param context - the selected IRemoteFile object
* @param viewer
* @param viewer the viewer that originated the compile action
* @return true if we should continue, false if something went wrong
*/
protected boolean runCommand(Shell shell, SystemUDActionElement action, String cmdString, IRemoteCmdSubSystem cmdSubSystem, Object context, Viewer viewer) {
@ -356,8 +356,8 @@ public class UDActionSubsystemFiles extends SystemUDActionSubsystem {
/**
* Subclasses may override to provide a custom type edit pane subclass
*/
public SystemUDTypeEditPane getCustomUDTypeEditPane(ISubSystem ss, ISubSystemConfiguration ssf, ISystemProfile profile, ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) {
return new UDTypesEditPaneFiles(ss, ssf, profile, parent, tv);
public SystemUDTypeEditPane getCustomUDTypeEditPane(ISystemUDAEditPaneHoster parent, ISystemUDTreeView tv) {
return new UDTypesEditPaneFiles(this, parent, tv);
}
/**
@ -445,9 +445,19 @@ public class UDActionSubsystemFiles extends SystemUDActionSubsystem {
public static SystemUDActionElement[] primeDefaultUniversalActions(SystemUDActionManager actionMgr, ISystemProfile profile, Vector vectorOfActions) {
Vector v = vectorOfActions;
if (v == null) v = new Vector();
String osType = actionMgr.getActionSubSystem().getOSType();
String userDefinedActionPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + actionMgr.getDocumentRootTagName(); //$NON-NLS-1$
IPropertySet userDefinedActionPropertySet = profile.getPropertySet(userDefinedActionPropertySetName);
if (null == userDefinedActionPropertySet)
{
userDefinedActionPropertySet = profile.createPropertySet(userDefinedActionPropertySetName);
userDefinedActionPropertySet.addProperty(ISystemUDAConstants.RELEASE_ATTR, ISystemUDAConstants.RELEASE_VALUE);
userDefinedActionPropertySet.addProperty(ISystemUDAConstants.UDA_ROOT_ATTR, actionMgr.getDocumentRootTagName());
}
// add file actions
int domain = DOMAIN_FILE;
SystemUDActionElement newAction;
//IPropertySet domainFilePropertySet = userDefinedActionPropertySet.createPropertySet(DOMAINS[1]);
for (int idx = 0; idx < FILE_ACTIONS.length; idx++) {
newAction = actionMgr.addAction(profile, FILE_ACTIONS[idx][0], domain);
v.addElement(newAction);

View file

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

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
// holds info on compile name associations for a
// 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$
// root tag
/**
@ -40,7 +41,7 @@ public interface ISystemCompileXMLConstants {
* The xml element is named "compiletype".
*/
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
* command via its label value.

View file

@ -12,9 +12,12 @@
*******************************************************************************/
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.IMenuManager;
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.ui.ISystemIconConstants;
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.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.swt.widgets.Shell;
/**
@ -91,22 +96,37 @@ public class SystemCompileCascadeByProfileAction extends SystemBaseSubMenuAction
srcType = "blank"; //$NON-NLS-1$
} else
return ourSubMenu; // should never happen
/* FIXME - compile actions not coupled with subsystem API anymore
ISubSystem subsystem = rmtAdapter.getSubSystem(firstSelection);
SystemCompileProfile compileProfile = subsystem.getParentSubSystemFactory().getCompileManager().getCompileProfile(profile);
// compileProfile.addContributions(firstSelection);
SystemCompileType compileType = (SystemCompileType)compileProfile.getCompileType(srcType);
ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration();
if (compileType != null)
{
SystemCompileCommand[] cmds = compileType.getCompileCommandsArray();
for (int idx=0; idx<cmds.length; idx++)
{
SystemCompileAction action = new SystemCompileAction(shell, cmds[idx], isPrompt);
ourSubMenu.add(action);
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);
SystemCompileType compileType = compileProfile.getCompileType(srcType);
if (compileType != null)
{
SystemCompileCommand[] cmds = compileType.getCompileCommandsArray();
for (int idx=0; idx<cmds.length; idx++)
{
SystemCompileAction action = new SystemCompileAction(shell, cmds[idx], isPrompt);
ourSubMenu.add(action);
}
}
}
*/
return ourSubMenu;
}
}

View file

@ -313,7 +313,7 @@ public class SystemCompileCommandEditPane implements SelectionListener, ISystemC
/**
* Populate the pane with the GUI widgets
* @param parent
* @param parent of the pane
* @return Control
*/
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.view.ISystemRemoteElementAdapter;
import org.eclipse.rse.ui.view.SystemAdapterHelpers;
import org.eclipse.rse.useractions.ui.compile.SystemCascadingCompileAction;
import org.eclipse.swt.widgets.Shell;
/**
@ -83,6 +84,7 @@ public abstract class SystemCompileManager {
private Hashtable compileProfilesPerProfile = new Hashtable();
private Hashtable compileSubstitutorsPerConnection = new Hashtable();
protected IHost systemConnection;
protected String osType = "default"; //$NON-NLS-1$
protected ISubSystemConfiguration subsystemFactory;
/**
* As last set by calling setCurrentCompileCommand. Sometimes needed by subclasses.
@ -420,4 +422,9 @@ public abstract class SystemCompileManager {
public String getSourceTypePromptMRITooltip() {
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.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.internal.ui.GenericMessages;
import org.eclipse.rse.internal.ui.view.SystemTableViewProvider;
import org.eclipse.rse.internal.useractions.UserActionsResources;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
@ -141,10 +141,10 @@ public class SystemCompileMultipleSelectAction extends SystemBaseAction {
WorkbenchContentProvider cprovider = new WorkbenchContentProvider();
SystemTableViewProvider lprovider = new SystemTableViewProvider(null);
// TODO: Cannot use WorkbenchMessages -- it's internal
ListSelectionDialog dlg = new ListSelectionDialog(getShell(), input, cprovider, lprovider, GenericMessages.EditorManager_saveResourcesMessage);
ListSelectionDialog dlg = new ListSelectionDialog(getShell(), input, cprovider, lprovider, SystemUDAResources.EditorManager_saveResourcesMessage);
dlg.setInitialSelections(input.getChildren());
// TODO: Cannot use WorkbenchMessages -- it's internal
dlg.setTitle(GenericMessages.EditorManager_saveResourcesTitle);
dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle);
int result = dlg.open();
//Just return false to prevent the operation continuing
if (result == IDialogConstants.CANCEL_ID) return false;

View file

@ -14,32 +14,17 @@
package org.eclipse.rse.internal.useractions.ui.compile;
import java.io.File;
import java.util.Iterator;
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.IFolder;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.viewers.Viewer;
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.ui.SystemBasePlugin;
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
@ -181,7 +166,9 @@ public abstract class SystemCompileProfile {
* folder.
*/
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;
}
@ -277,6 +264,29 @@ public abstract class SystemCompileProfile {
*/
private Vector read() {
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();
// If the file does not exist, then write all IBM supplied default
// types and compile names first before reading
@ -288,14 +298,7 @@ public abstract class SystemCompileProfile {
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;
}
@ -303,70 +306,82 @@ public abstract class SystemCompileProfile {
* Get all the compile types.
* @return a vector of SystemCompileType objects.
*/
private Vector getTypes(Document doc) {
private Vector getTypes(ISystemProfile systemProfile) {
Vector types = new Vector();
Element root = doc.getDocumentElement();
String oldvrm = root.getAttribute(ISystemCompileXMLConstants.VERSION_ATTRIBUTE);
boolean oldversion = (oldvrm != null) && !oldvrm.equals(ISystemCompileXMLConstants.VERSION_VALUE);
NodeList list = doc.getElementsByTagName(ISystemCompileXMLConstants.TYPE_ELEMENT);
//Get the propertySet first
String osType = getParentManager().getOSType();
String compileCommandPropertySetName = ISystemCompileXMLConstants.COMPILE_COMMAND_PROPRERTY_SET_PREFIX + osType;
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;
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
NamedNodeMap map = node.getAttributes();
// get the type
Node typeAttr = map.getNamedItem(ISystemCompileXMLConstants.TYPE_ATTRIBUTE);
String type = typeAttr.getNodeValue();
// get the label of the last compile name
Node lastUsedAttr = map.getNamedItem(ISystemCompileXMLConstants.LASTUSED_ATTRIBUTE);
String lastUsed = lastUsedAttr.getNodeValue();
for (int i = 0; i < list.length; i++) {
IPropertySet compileType = list[i]; //This is one compile type
IPropertySet[] compileNameList = compileType.getPropertySets();
IProperty typeProperty = compileType.getProperty(ISystemCompileXMLConstants.TYPE_ATTRIBUTE);
String type = typeProperty.getValue();
IProperty lastUsedProperty = compileType.getProperty(ISystemCompileXMLConstants.LASTUSED_ATTRIBUTE);
String lastUsed = lastUsedProperty.getValue();
SystemCompileType newType = new SystemCompileType(this, type);
NodeList childList = node.getChildNodes();
for (int j = 0; j < childList.getLength(); j++) {
Node child = childList.item(j);
NamedNodeMap childAttrMap = child.getAttributes();
for (int j = 0; j < compileNameList.length; j++) {
IPropertySet compileName = compileNameList[j]; //This is one compilename
// get the name of the compile name
Node nameAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.LABEL_ATTRIBUTE);
String name = nameAttr.getNodeValue();
IProperty labelProperty = compileName.getProperty(ISystemCompileXMLConstants.LABEL_ATTRIBUTE);
String name = labelProperty.getValue();
// get the nature of the compile name
Node natureAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.NATURE_ATTRIBUTE);
String nature = natureAttr.getNodeValue();
IProperty natureProperty = compileName.getProperty(ISystemCompileXMLConstants.NATURE_ATTRIBUTE);
String nature = natureProperty.getValue();
// get the default command string
Node defaultAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.DEFAULT_ATTRIBUTE);
String defaultString = (defaultAttr != null) ? defaultAttr.getNodeValue() : ""; //$NON-NLS-1$
IProperty defaultProperty = compileName.getProperty(ISystemCompileXMLConstants.DEFAULT_ATTRIBUTE);
String defaultString = (defaultProperty != null) ? defaultProperty.getValue() : ""; //$NON-NLS-1$
// get the current string
Node currentAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.CURRENT_ATTRIBUTE);
String currentString = currentAttr.getNodeValue();
IProperty currentProperty = compileName.getProperty(ISystemCompileXMLConstants.CURRENT_ATTRIBUTE);
String currentString = currentProperty.getValue();
// get the menu option
Node menuAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.MENU_ATTRIBUTE);
String menuOption = menuAttr.getNodeValue();
IProperty menuProperty = compileName.getProperty(ISystemCompileXMLConstants.MENU_ATTRIBUTE);
String menuOption = menuProperty.getValue();
// get the jobenv option
Node jobenvAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.JOBENV_ATTRIBUTE);
IProperty jobenvProperty = compileName.getProperty(ISystemCompileXMLConstants.JOBENV_ATTRIBUTE);
String jobEnv = null;
if (jobenvAttr != null) jobEnv = jobenvAttr.getNodeValue();
if (null != jobenvProperty)
{
jobEnv = jobenvProperty.getValue();
}
// get the ordering
IProperty orderProperty = compileName.getProperty(ISystemCompileXMLConstants.ORDER_ATTRIBUTE);
int order = j;
Node orderAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.ORDER_ATTRIBUTE);
// to ensure previous beta customers do not have problems
if (orderAttr != null) {
order = Integer.valueOf(orderAttr.getNodeValue()).intValue();
if (null != orderProperty)
{
order = Integer.valueOf(orderProperty.getValue()).intValue();
}
// get the id option
Node idAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.ID_ATTRIBUTE);
IProperty idProperty = compileName.getProperty(ISystemCompileXMLConstants.ID_ATTRIBUTE);
String id = null;
if (idAttr != null) {
id = idAttr.getNodeValue();
if (null != idProperty)
{
id = idProperty.getValue();
}
// get the label editable option
Node labelEditableAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.LABEL_EDITABLE_ATTRIBUTE);
IProperty labelEditableProperty = compileName.getProperty(ISystemCompileXMLConstants.LABEL_EDITABLE_ATTRIBUTE);
String labelEditable = null;
if (labelEditableAttr != null) {
labelEditable = labelEditableAttr.getNodeValue();
if (null != labelEditableProperty)
{
labelEditable = labelEditableProperty.getValue();
}
// get the label editable option
Node stringEditableAttr = childAttrMap.getNamedItem(ISystemCompileXMLConstants.STRING_EDITABLE_ATTRIBUTE);
// get the string editable option
IProperty stringEditableProperty = compileName.getProperty(ISystemCompileXMLConstants.STRING_EDITABLE_ATTRIBUTE);
String stringEditable = null;
if (stringEditableAttr != null) {
stringEditable = stringEditableAttr.getNodeValue();
if (null != stringEditableProperty)
{
stringEditable = stringEditableProperty.getValue();
}
// 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
@ -387,7 +402,10 @@ public abstract class SystemCompileProfile {
}
if (jobEnv != null) newCmd.setJobEnvironment(jobEnv);
if (name.equalsIgnoreCase(lastUsed)) newType.setLastUsedCompileCommand(newCmd);
//TODO - XUAN need to handling migration later on
/*
if (oldversion) newCmd = migrateCompileCommand(newCmd, oldvrm);
*/
newType.addCompileCommandInOrder(newCmd);
}
// 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.
// 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.
//TODO - XUAN need to handling migration later on
/*
if (parentManager.wantToPrimeWithDefaults(this) && oldversion) {
SystemDefaultCompileCommands allCmds = parentManager.getDefaultCompileCommands();
if (allCmds == null) {
@ -449,6 +469,7 @@ public abstract class SystemCompileProfile {
}
}
}
*/
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.
*/
private void write(Vector types) {
File file = getCompileProfileJavaFile();
try {
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document doc = builder.getDOMImplementation().createDocument(null, ISystemCompileXMLConstants.ROOT_ELEMENT, null);
// get root element and set attributes
Element root = doc.getDocumentElement();
root.setAttribute(ISystemCompileXMLConstants.VERSION_ATTRIBUTE, ISystemCompileXMLConstants.VERSION_VALUE);
// 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
for (int i = 0; i < types.size(); i++) {
SystemCompileType type = (SystemCompileType) (types.get(i));
Element typeElement = doc.createElement(ISystemCompileXMLConstants.TYPE_ELEMENT);
typeElement.setAttribute(ISystemCompileXMLConstants.TYPE_ATTRIBUTE, type.getType());
SystemCompileCommand lastUsedCompileName = type.getLastUsedCompileCommand();
String lastUsedName = null;
if (lastUsedCompileName == null) {
lastUsedName = ""; //$NON-NLS-1$
} else {
lastUsedName = lastUsedCompileName.getLabel();
}
typeElement.setAttribute(ISystemCompileXMLConstants.LASTUSED_ATTRIBUTE, lastUsedName);
Vector cmds = type.getCompileCommands();
for (int j = 0; j < cmds.size(); j++) {
SystemCompileCommand cmd = (SystemCompileCommand) (cmds.get(j));
Element cmdElement = doc.createElement(ISystemCompileXMLConstants.COMPILECOMMAND_ELEMENT);
if (cmd.getId() != null) {
cmdElement.setAttribute(ISystemCompileXMLConstants.ID_ATTRIBUTE, cmd.getId());
}
cmdElement.setAttribute(ISystemCompileXMLConstants.LABEL_ATTRIBUTE, cmd.getLabel());
cmdElement.setAttribute(ISystemCompileXMLConstants.NATURE_ATTRIBUTE, cmd.getNature());
cmdElement.setAttribute(ISystemCompileXMLConstants.DEFAULT_ATTRIBUTE, cmd.getDefaultString());
cmdElement.setAttribute(ISystemCompileXMLConstants.CURRENT_ATTRIBUTE, cmd.getCurrentString());
cmdElement.setAttribute(ISystemCompileXMLConstants.MENU_ATTRIBUTE, cmd.getMenuOption());
cmdElement.setAttribute(ISystemCompileXMLConstants.ORDER_ATTRIBUTE, String.valueOf(j));
cmdElement.setAttribute(ISystemCompileXMLConstants.LABEL_EDITABLE_ATTRIBUTE, String.valueOf(cmd.isLabelEditable()));
cmdElement.setAttribute(ISystemCompileXMLConstants.STRING_EDITABLE_ATTRIBUTE, String.valueOf(cmd.isCommandStringEditable()));
if (cmd.getJobEnvironment() != null) {
cmdElement.setAttribute(ISystemCompileXMLConstants.JOBENV_ATTRIBUTE, cmd.getJobEnvironment());
}
typeElement.appendChild(cmdElement);
}
root.appendChild(typeElement);
private void write(Vector types, ISystemProfile systemProfile) {
//Get the propertySet first
String osType = getParentManager().getOSType();
String compileCommandPropertySetName = ISystemCompileXMLConstants.COMPILE_COMMAND_PROPRERTY_SET_PREFIX + osType;
IPropertySet compileCommandPropertySet = systemProfile.getPropertySet(compileCommandPropertySetName);
if (null == compileCommandPropertySet)
{
compileCommandPropertySet = systemProfile.createPropertySet(compileCommandPropertySetName);
}
// write type and compile commands for each
for (int i = 0; i < types.size(); i++) {
SystemCompileType compileType = (SystemCompileType) (types.get(i));
//Element typeElement = doc.createElement(ISystemCompileXMLConstants.TYPE_ELEMENT);
//typeElement.setAttribute(ISystemCompileXMLConstants.TYPE_ATTRIBUTE, type.getType());
SystemCompileCommand lastUsedCompileName = compileType.getLastUsedCompileCommand();
String lastUsedName = null;
if (lastUsedCompileName == null) {
lastUsedName = ""; //$NON-NLS-1$
} else {
lastUsedName = lastUsedCompileName.getLabel();
}
//now create a propertySet for this compile type
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++) {
SystemCompileCommand cmd = (SystemCompileCommand) (cmds.get(j));
IPropertySet thisCompileCommandPropertySet = thisCompileTypePropertySet.createPropertySet(cmd.getLabel() + j);
if (null != cmd.getId())
{
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.ID_ATTRIBUTE, cmd.getId());
}
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.LABEL_ATTRIBUTE, cmd.getLabel());
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.NATURE_ATTRIBUTE, cmd.getNature());
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.DEFAULT_ATTRIBUTE, cmd.getDefaultString());
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.CURRENT_ATTRIBUTE, cmd.getCurrentString());
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.ID_ATTRIBUTE, cmd.getId());
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.MENU_ATTRIBUTE, cmd.getMenuOption());
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.ORDER_ATTRIBUTE, String.valueOf(j));
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.LABEL_EDITABLE_ATTRIBUTE, String.valueOf(cmd.isLabelEditable()));
if (cmd.getJobEnvironment() != null) {
thisCompileCommandPropertySet.addProperty(ISystemCompileXMLConstants.JOBENV_ATTRIBUTE, cmd.getJobEnvironment());
}
}
}
//Need to persist it.
systemProfile.commit();
/*
// write out document to XML file
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
@ -558,18 +583,16 @@ public abstract class SystemCompileProfile {
transformer.transform(input, output);
// now refresh the eclipse workspace model for the parent folder, to recognize changes we made
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.
* Return true if any written, false if none to write.
*/
private boolean writeDefaults() {
private Vector writeDefaults(ISystemProfile systemProfile) {
SystemDefaultCompileCommands allCmds = parentManager.getDefaultCompileCommands();
if (allCmds == null) return false;
if (allCmds == null) return null;
String[] defaultTypes = allCmds.getAllDefaultSuppliedSourceTypes();
Vector types = new Vector();
for (int i = 0; i < defaultTypes.length; i++) {
@ -595,9 +618,9 @@ public abstract class SystemCompileProfile {
}
types.add(type);
}
write(types);
write(types, systemProfile);
//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.rse.core.RSECorePlugin;
import org.eclipse.rse.core.events.ISystemModelChangeEvents;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.view.SystemViewMenuListener;
import org.eclipse.rse.internal.useractions.IUserActionsModelChangeEvents;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources;
@ -122,7 +121,7 @@ public class SystemWorkWithCompileCommandsDialog extends SystemPromptDialog impl
this.currentCompProfile = currentCompProfile;
this.compProfiles = new SystemCompileProfile[] { currentCompProfile };
this.supportsAddSrcTypeButton = true;
setCancelButtonLabel(SystemResources.BUTTON_CLOSE);
setCancelButtonLabel(SystemUDAResources.BUTTON_CLOSE);
setShowOkButton(false);
setOutputObject(null);
setHelp();

View file

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

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

View file

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

View file

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

View file

@ -16,6 +16,13 @@ package org.eclipse.rse.internal.useractions.ui.uda;
* Constants used throughout the User Defined Action framework.
*/
public interface ISystemUDAConstants {
public static final String USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX = "UDA."; //$NON-NLS-1$
static final String UDA_ROOT_ATTR = "uda_root"; //$NON-NLS-1$
static final String FILETYPES_ROOT = "FileTypes"; //$NON-NLS-1$
static final String ACTIONS_ROOT = "Actions"; //$NON-NLS-1$
/**
* The name of the xml tag for domain tags.
* Domains are used to partition actions.
@ -28,7 +35,7 @@ public interface ISystemUDAConstants {
* identifies the domain type. Its values will be
* an untranslated name like "Object" or "Folder".
*/
public static final String XE_DOMTYPE = "Type"; //$NON-NLS-1$
public static final String XE_DOMTYPE = "DomainType"; //$NON-NLS-1$
/**
* The name of the xml attribute of domain tags which
* identifies the domain name. Its values will be
@ -39,6 +46,11 @@ public interface ISystemUDAConstants {
* The name of the attribute we consistently use to store an element's name
*/
public static final String NAME_ATTR = "Name"; //$NON-NLS-1$
/**
* The type of the attribute we consistently use to store an element's name
*/
public static final String TYPE_ATTR = "Type"; //$NON-NLS-1$
/**
* The name of the attribute we consistently use to store an element's original IBM-supplied name
*/
@ -47,4 +59,6 @@ public interface ISystemUDAConstants {
* The name of the attribute we consistently use to store a release number
*/
public static final String RELEASE_ATTR = "release"; //$NON-NLS-1$
public static final String RELEASE_VALUE = "7.5"; //$NON-NLS-1$
}

View file

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

View file

@ -84,7 +84,7 @@ public class SystemUDACascadeAction extends SystemBaseSubMenuAction implements I
}
ourSubMenu.add(new Separator(ISystemContextMenuConstants.GROUP_WORKWITH));
if (wwAction == null) {
wwAction = new SystemWorkWithUDAsAction(shell, udsubsystem.getSubsystem());
wwAction = new SystemWorkWithUDAsAction(shell, udsubsystem.getSubsystem(), udsubsystem);
wwAction.setText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_LABEL);
wwAction.setToolTipText(SystemUDAResources.RESID_WORKWITH_UDAS_ACTION_TOOLTIP);
wwAction.allowOnMultipleSelection(true);

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_TOOLTIP;
public static String SystemCompileManager_0;
//Resources used to be in other internal plugins:
public static String EditorManager_saveResourcesMessage;
public static String EditorManager_saveResourcesTitle;
public static String BUTTON_CLOSE;
public static String RESID_PP_PROPERTIES_TYPE_LABEL;
public static String RESID_PP_PROPERTIES_TYPE_TOOLTIP;
public static String ACTION_CASCADING_NEW_LABEL;
public static String ACTION_CASCADING_NEW_TOOLTIP;
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, SystemUDAResources.class);

View file

@ -436,3 +436,13 @@ RESID_UCMD_COMMAND_TOOLTIP = Enter the command to invoke
RESID_UCMD_COMAMND_SHELL_LABEL = Command Shell
SystemCompileManager_0=An error has been detected that is probably a programming bug. Please submit your .log file in the .metadata subfolder for service.
EditorManager_saveResourcesMessage = Select the &resources to save:
EditorManager_saveResourcesTitle = Save Resources
BUTTON_CLOSE=Close
RESID_PP_PROPERTIES_TYPE_LABEL=Resource type
RESID_PP_PROPERTIES_TYPE_TOOLTIP=What type of artifact is this?
ACTION_CASCADING_NEW_LABEL=New
ACTION_CASCADING_NEW_TOOLTIP=Create a new resource

View file

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

View file

@ -12,10 +12,11 @@ package org.eclipse.rse.internal.useractions.ui.uda;
*******************************************************************************/
import java.util.StringTokenizer;
import org.eclipse.rse.core.model.IProperty;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.useractions.UserActionsIcon;
import org.eclipse.swt.graphics.Image;
import org.w3c.dom.Element;
/**
* Represents a single user defined action, as an adaptable
@ -42,7 +43,7 @@ public class SystemUDActionElement extends SystemXMLElementWrapper {
* @param profile - The system profile which owns this action
* @param domainType - The integer representation of the domain this is in (or this is, for a domain element)
*/
public SystemUDActionElement(Element e, SystemUDActionManager am, ISystemProfile profile, int domainType) {
public SystemUDActionElement(IPropertySet e, SystemUDActionManager am, ISystemProfile profile, int domainType) {
super(e, am, profile, domainType);
}
@ -79,15 +80,28 @@ public class SystemUDActionElement extends SystemXMLElementWrapper {
/**
* Return value of the "Comment" sub-tag
*/
public String getComment() {
return getTextNode(COMMENT_TAG);
//Get the property for this
IProperty commentProperty = elm.getProperty(COMMENT_TAG);
if (commentProperty != null)
{
return commentProperty.getValue();
}
return ""; //$NON-NLS-1$
}
/**
* Return value of the "Command" sub-tag, which is the current command value
*/
public String getCommand() {
return getTextNode(COMMAND_TAG);
//Get the property for this
IProperty commentProperty = elm.getProperty(COMMAND_TAG);
if (commentProperty != null)
{
return commentProperty.getValue();
}
return ""; //$NON-NLS-1$
}
/**
@ -129,22 +143,38 @@ public class SystemUDActionElement extends SystemXMLElementWrapper {
* Return value of the "FileTypes" sub-tag
*/
public String[] getFileTypes() {
String fts = getTextNode(FILETYPES_TAG);
// returns an empty string if no attribute
StringTokenizer st = new StringTokenizer(fts);
int n = st.countTokens();
String sa[] = new String[n];
for (int i = 0; i < n; i++) {
sa[i] = st.nextToken();
//Get the property for this
IProperty fileTypeProperty = elm.getProperty(FILETYPES_TAG);
if (fileTypeProperty != null)
{
String fts = fileTypeProperty.getValue();
// returns an empty string if no attribute
StringTokenizer st = new StringTokenizer(fts);
int n = st.countTokens();
String sa[] = new String[n];
for (int i = 0; i < n; i++) {
sa[i] = st.nextToken();
}
return sa;
}
return sa;
return new String[0];
}
/**
* Set the value of the "Comment" sub-tag
*/
public void setComment(String s) {
setTextNode(COMMENT_TAG, s);
IProperty commentProperty = elm.getProperty(COMMENT_TAG);
if (null != commentProperty)
{
commentProperty.setValue(s);
}
else
{
elm.addProperty(COMMENT_TAG, s);
}
setUserChanged(true);
}
@ -152,7 +182,15 @@ public class SystemUDActionElement extends SystemXMLElementWrapper {
* Set the value of the "Command" sub-tag.
*/
public void setCommand(String s) {
setTextNode(COMMAND_TAG, s);
IProperty commandProperty = elm.getProperty(COMMAND_TAG);
if (null != commandProperty)
{
commandProperty.setValue(s);
}
else
{
elm.addProperty(COMMAND_TAG, s);
}
setUserChanged(true);
}
@ -204,7 +242,17 @@ public class SystemUDActionElement extends SystemXMLElementWrapper {
for (int i = 0; i < sa.length; i++) {
s = s + " " + sa[i]; //$NON-NLS-1$
}
setTextNode(FILETYPES_TAG, s);
IProperty fileTypeProperty = elm.getProperty(FILETYPES_TAG);
if (null != fileTypeProperty)
{
fileTypeProperty.setValue(s);
}
else
{
elm.addProperty(FILETYPES_TAG, s);
}
setUserChanged(true);
}

View file

@ -11,17 +11,16 @@
*******************************************************************************/
package org.eclipse.rse.internal.useractions.ui.uda;
import java.io.File;
import java.util.Vector;
import org.eclipse.core.resources.IFolder;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.useractions.UserActionsIcon;
import org.eclipse.rse.internal.useractions.UserActionsPersistenceUtil;
import org.eclipse.swt.graphics.Image;
import org.w3c.dom.Element;
/**
* Instances of this class hold the UDA definitions unique to:
@ -39,9 +38,8 @@ import org.w3c.dom.Element;
public class SystemUDActionManager extends SystemUDBaseManager
// implements ErrorHandler,
implements ITreeContentProvider {
private static final String XE_ROOT = "Actions"; //$NON-NLS-1$
private static final String XE_ROOT = ISystemUDAConstants.ACTIONS_ROOT;
private static final String XE_ACTION = "Action"; //$NON-NLS-1$
private final static String UDA_FILENAME = "uda.xml"; //$NON-NLS-1$
/**
* Constructor
@ -84,13 +82,6 @@ public class SystemUDActionManager extends SystemUDBaseManager
return getActionSubSystem().doActionsMigration(profile, oldRelease);
}
/**
* Get name of the xml file used to persist the actions.
*/
public String getFileName() {
return UDA_FILENAME;
}
/**
* Get the document root tag name.
* We return "Actions"
@ -148,23 +139,6 @@ public class SystemUDActionManager extends SystemUDBaseManager
return (SystemUDActionElement) super.addElement(profile, domain, name);
}
/**
* Return true if there are any actions, currently.
*/
public boolean hasActions(ISystemProfile profile, ISubSystemConfiguration ssFactory) {
boolean hasActions = false;
boolean folderExists = UserActionsPersistenceUtil.testUserActionsFolder(profile.getName(), ssFactory);
if (folderExists) {
String fileName = getFilePath(profile);
if (fileName != null) {
File file = new File(fileName);
if (file.canRead()) hasActions = true;
}
}
//System.out.println("Inside hasActions for SystemUDActionManager, for ssFactory "+ssFactory.getId()+": "+hasActions);
return hasActions;
}
/**
* Return xml element wrapper objects for all actions, for the
* given domain, or for the whole document if domain is -1 (iff
@ -219,7 +193,7 @@ public class SystemUDActionManager extends SystemUDBaseManager
* Given an xml element node, create an instance of the appropriate
* subclass of SystemXMLElementWrapper to represent it.
*/
public SystemXMLElementWrapper createElementWrapper(Element xmlElementToWrap, ISystemProfile profile, int domain) {
public SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain) {
SystemUDActionElement elementWrapper = new SystemUDActionElement(xmlElementToWrap, this, profile, domain);
return elementWrapper;
}

View file

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

View file

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

View file

@ -11,32 +11,13 @@
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* David Dykstal (IBM) - [186589] move user types, user actions, and compile commands
* API to the user actions plugin
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
*******************************************************************************/
package org.eclipse.rse.internal.useractions.ui.uda;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Hashtable;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
@ -44,39 +25,25 @@ import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.osgi.util.NLS;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.SystemResourceHelpers;
import org.eclipse.rse.core.SystemResourceManager;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.IPropertySetContainer;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.useractions.Activator;
import org.eclipse.rse.internal.useractions.IUserActionsMessageIds;
import org.eclipse.rse.internal.useractions.UserActionsResources;
import org.eclipse.rse.services.clientserver.messages.SimpleSystemMessage;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.ISystemMessages;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.messages.SystemMessageDialog;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
/**
* Instances of this class hold the UDA definitions unique to
* <ol>
@ -96,7 +63,7 @@ import org.xml.sax.SAXParseException;
* Architecturally, this class and the SystemXMLElementWrapper class
* encapsulate all knowledge of the fact the underlying store is a xml document.
*/
public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChangeListener, ISystemXMLElementWrapperFactory, ITreeContentProvider {
public abstract class SystemUDBaseManager implements IResourceChangeListener, ISystemXMLElementWrapperFactory, ITreeContentProvider {
// state
protected SystemUDActionSubsystem _udas;
protected IFolder importCaseFolder; // Only set during Import processing
@ -109,13 +76,13 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
private Hashtable hasChangedByProfile;
private Hashtable dirPathByProfile;
// used by subclasses that are not profile-indexed
private Document udocNoProfile;
private IPropertySet udocNoProfile;
private boolean hasChangedNoProfile = false;
private Object[] dirPathNoProfile;
// Profile for which we are working for actions for...
private ISystemProfile currentlyActiveProfile; // set in UDA GUI
// Clipboard copy/paste support
private Element currentNodeClone = null;
private IPropertySet currentNodeClone = null;
private String currentNodeCloneID = ""; //$NON-NLS-1$
// private String currentNodeCloneName = ""; //$NON-NLS-1$
private int currentNodeCloneDomain = -1;
@ -167,7 +134,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Given an xml element node, create an instance of the appropriate
* subclass of SystemXMLElementWrapper to represent it.
*/
public abstract SystemXMLElementWrapper createElementWrapper(Element xmlElementToWrap, ISystemProfile profile, int domain);
public abstract SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain);
// -----------------------------------------------------------
// ITREECONTENTPROVIDER METHODS...
@ -213,7 +180,17 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
if (!wrapper.isDomain())
return false;
else
return (wrapper.getElement().getFirstChild() != null);
{
IPropertySet[] childrenPropertySet = wrapper.getElement().getPropertySets();
if (childrenPropertySet == null || childrenPropertySet.length == 0)
{
return false;
}
else
{
return true;
}
}
} else
return false;
} else if (element == null) {
@ -276,11 +253,11 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
*/
public Vector getXMLWrappers(Vector children, Object parentOrDomain, ISystemProfile profile) {
int domain = -1;
Element parentElement = null;
IPropertySet parentElement = null;
if (parentOrDomain instanceof SystemXMLElementWrapper) {
parentElement = ((SystemXMLElementWrapper) parentOrDomain).getElement();
domain = ((SystemXMLElementWrapper) parentOrDomain).getDomain();
} else if (parentOrDomain instanceof Element) parentElement = (Element) parentOrDomain;
} else if (parentOrDomain instanceof IPropertySet) parentElement = (IPropertySet) parentOrDomain;
children = SystemXMLElementWrapper.getChildren(children, parentElement, getDocument(profile), profile, this, domain);
return children;
}
@ -315,34 +292,6 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
*/
}
/**
* Return name of the xml file used to persist the actions
*/
public abstract String getFileName();
/**
* Initialize a new document
*/
public Document initializeDocument() {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
Document doc = null;
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
}
if (builder != null) {
doc = builder.newDocument();
// Document doc= new DocumentImpl();
// create root element. Eg <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
@ -365,113 +314,27 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
else
return null;
}
/**
* Get the path of the XML document containing the user actions,
* for the given profile (and current subsystem)
*/
protected String getFilePath(ISystemProfile profile) {
IFolder folder = getFolder(profile);
if (folder == null) return null;
String fn = folder.getLocation().toOSString() + File.separator + getFileName();
// System.out.println("UD file: " + fn);
return fn;
}
/**
* Build a vector of the folder names, in order, from workspace
* to our data file. Do once only.
* (To be used when resolving resource change events)
*/
private void resolveDirPath(ISystemProfile profile) {
// System.out.println("UD file:" );
Vector dirFolder = new Vector();
dirFolder.add(getFileName());
IContainer folder = getFolder(profile);
while (folder != null) {
// Insert at start of vector
String s = folder.getName();
// Workspace is empty string, dont add it
if (!"".equals(s)) //$NON-NLS-1$
{
dirFolder.add(0, s);
// System.out.println("+" + s );
}
folder = folder.getParent();
}
Object[] dirPath = dirFolder.toArray();
setProfileIndexedInstanceVariable_dirPath(profile, dirPath);
}
/**
* loadAndParseXMLFile:
* tries to load and parse the specified XML file.
* @param fileName the name of xml file which will contain the messages
* @param profile the profile in which the user defined actions are kept
* @return the document containing the user defined actions
*/
protected Document loadAndParseXMLFile(String fileName, ISystemProfile profile) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = null;
try {
parser = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
SystemBasePlugin.logError("SystemUDBaseManager: loadAndParseXMLFile, configuration not valid " + e.toString(), e); //$NON-NLS-1$
return null;
}
// DOMParser parser = new DOMParser();
parser.setErrorHandler(this);
try {
Document doc = parser.parse(fileName);
// verify the document is what we expect...
Element docroot = doc.getDocumentElement(); // get Root Element
// ?? Confirm root is XE_ROOT ??
// ok, I took on the job of handling this. I also decided to put it
// here so we don't have this code scattered everywhere after calls to getDocument()
// Phil. 08/2002
if ((null == docroot) || !docroot.getTagName().equals(getDocumentRootTagName())) {
Shell activeShell = getActiveShell();
String oldFileName = getFilePath(profile);
String newFileName = getFileName() + ".bad"; //$NON-NLS-1$
IFile file = getFolder(profile).getFile(getFileName());
try {
SystemResourceHelpers.getResourceHelpers().renameFile(file, newFileName);
} catch (Exception exc) {
}
String msgTxt = NLS.bind(UserActionsResources.MSG_UDA_ROOTTAG_ERROR, getFilePath(profile));
String msgDetails = NLS.bind(UserActionsResources.MSG_UDA_ROOTTAG_ERROR_DETAILS, getDocumentRootTagName(), newFileName);
SystemMessage docRootMsg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IUserActionsMessageIds.MSG_UDA_ROOTTAG_ERROR,
IStatus.ERROR, msgTxt, msgDetails);
protected IPropertySet loadAndParseXMLFile(ISystemProfile profile) {
String osType = _udas.getOSType();
String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$
IPropertySet userDefinedActionPropertySet = profile.getPropertySet(udaRootPropertySetName);
return userDefinedActionPropertySet;
doc = createAndPrimeDocument(profile);
docRootMsg.makeSubstitution(oldFileName, getDocumentRootTagName(), newFileName);
SystemBasePlugin.logWarning(docRootMsg.getLevelOneText());
if (activeShell != null) {
SystemMessageDialog.displayErrorMessage(activeShell, docRootMsg);
}
}
return doc;
} catch (Exception exc) {
// Provide a non-null value. Might as well prime
// with a "proper" doc structure.
Document doc = initializeDocument();
String msgTxt = NLS.bind(UserActionsResources.MSG_UDA_LOAD_ERROR, fileName);
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IUserActionsMessageIds.MSG_UDA_LOAD_ERROR,
IStatus.ERROR, msgTxt, exc);
SystemMessageDialog msgdlg = new SystemMessageDialog(SystemBasePlugin.getActiveWorkbenchShell(), msg);
msgdlg.open();
return doc;
}
}
// **********************************************************
// ErrorHandler Interface: (XML SAX parsing)
// **********************************************************
@ -546,20 +409,15 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
ISystemProfile[] activeProfiles = getActiveSystemProfiles();
for (int idx = 0; idx < activeProfiles.length; idx++) {
ISystemProfile profile = activeProfiles[idx];
ensureDirPathResolved(profile);
//ensureDirPathResolved(profile);
searchDelta(profile, delta, 0);
}
} else {
ensureDirPathResolved(null);
//ensureDirPathResolved(null);
searchDelta(null, delta, 0);
}
}
private void ensureDirPathResolved(ISystemProfile profile) {
Object[] dirPath = getProfileIndexedInstanceVariable_dirPath(profile);
if (dirPath == null) resolveDirPath(profile);
}
private void searchDelta(ISystemProfile profile, IResourceDelta parent, int nestLevel) {
Object[] dirPath = getProfileIndexedInstanceVariable_dirPath(profile);
String target = (String) dirPath[nestLevel];
@ -631,6 +489,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Get the release of the document. Eg, value of the "release"attribute of the root.
* If not set then we assume it is release "4.0"
*/
/*
public String getDocumentRelease(ISystemProfile profile) {
Document doc = getDocument(profile);
Element root = doc.getDocumentElement();
@ -640,17 +499,24 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
else
return rel;
}
*/
/**
* Load document for given SystemProfile only if not already done.
*/
public Document getDocument(ISystemProfile profile) {
Document doc = getProfileIndexedInstanceVariable_Document(profile);
public IPropertySet getDocument(ISystemProfile profile) {
IPropertySet doc = getProfileIndexedInstanceVariable_Document(profile);
if (doc == null) {
doc = loadUserData(profile);
if (doc == null)
{
//No user action for this profile
return doc;
}
setProfileIndexedInstanceVariable_Document(profile, doc);
// document is good. Now, check the release date stamped on it.
// if not the current release, then we must consider migration...
/*
Element docroot = doc.getDocumentElement();
String docRelease = docroot.getAttribute(ISystemUDAConstants.RELEASE_ATTR);
if ((docRelease == null) || (docRelease.length() == 0)) docRelease = "4.0"; //$NON-NLS-1$
@ -663,8 +529,10 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
saveUserData(profile);
}
}
*/
} else {
}
return doc;
}
@ -676,12 +544,6 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
*/
protected abstract boolean doMigration(ISystemProfile profile, String oldRelease);
/**
* Get the active shell so we can show an error message
*/
private Shell getActiveShell() {
return Display.getCurrent().getActiveShell();
}
/**
* Indicate the data has changed for the document for the given system profile
@ -707,32 +569,6 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
dataChanged(profile);
}
/**
* Get the folder containing the xml file used to persist the actions,
* for the given profile
*/
private IFolder getFolder(ISystemProfile profile) {
ISubSystem subsystem = getSubSystem();
// Import action: no subsystem
if ((subsystem == null) && (getSubSystemFactory() == null))
return importCaseFolder;
else {
if ((profile == null) && (subsystem != null)) profile = subsystem.getSystemProfile();
return getDocumentFolder(getSubSystemFactory(), profile);
}
}
/**
* Get the folder containing the xml file used to persist the actions,
* for the given profile
*/
protected abstract IFolder getDocumentFolder(ISubSystemConfiguration subsystemFactory, ISystemProfile profile);
/**
* Intended for IMPORT actions only, where no Subsystem instance available:
*/
public abstract void setFolder(String profileName, String factoryId);
/**
* Indicate data has changed for the given profile
*/
@ -742,10 +578,11 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
/**
* Load the user actions from the XML document, for the given profile
*/
protected Document loadUserData(ISystemProfile profile) {
protected IPropertySet loadUserData(ISystemProfile profile) {
//System.out.println("UD load: " + getFileName() );
dataChanged(profile); // not sure why we call this, at this time!! Phil
setProfileIndexedInstanceVariable_hasChanged(profile, false);
/*
String fn = getFilePath(profile);
Document doc = null;
if (!(new File(fn)).canRead())
@ -753,25 +590,49 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
else
doc = loadAndParseXMLFile(fn, profile);
//addListener();
return doc;
*/
//We use PropertySet to store User Action instead.
//We need to get the compile command information from the system profile now.
//Get the propertySet first
String osType = _udas.getOSType();
String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$
IPropertySet udaRootPropertySet = profile.getPropertySet(udaRootPropertySetName);
if (null == udaRootPropertySet)
{
if (profile.isDefaultPrivate()) // we only prime the user's private profile with default compile commands
{
udaRootPropertySet = createAndPrimeDocument(profile);
}
}
else
{
udaRootPropertySet = loadAndParseXMLFile(profile);
}
return udaRootPropertySet;
}
/**
* Create and prime the XML document
*/
protected Document createAndPrimeDocument(ISystemProfile profile) {
Document doc = initializeDocument();
setProfileIndexedInstanceVariable_Document(profile, doc);
protected IPropertySet createAndPrimeDocument(ISystemProfile profile) {
//Document doc = initializeDocument();
//setProfileIndexedInstanceVariable_Document(profile, doc);
SystemXMLElementWrapper[] primedElements = primeDocument(profile);
if (primedElements != null) {
for (int idx = 0; idx < primedElements.length; idx++) {
SystemXMLElementWrapper newElement = primedElements[idx];
newElement.setIBM(true);
newElement.setUserChanged(false);
newElement.setUserChanged(true);
}
}
saveUserData(profile);
return doc;
String osType = _udas.getOSType();
String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$
IPropertySet userDefinedActionPropertySet = profile.getPropertySet(udaRootPropertySetName);
return userDefinedActionPropertySet;
}
/**
@ -783,108 +644,30 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
//System.out.println("UD save: No changes. " + getFileName() );
return;
}
/* Old way of toggling off/on resource change monitoring wasnt working
for case of two connections with same subsystems with UDA data loaded,
and user changes UDA data in one. Change wasn't propagated to other,
which might later update the UDA file with old data.
Better appraoch is to toggle my (ignoreMyResourceChange) flag around
my update, and check that flag in my resource change listener so that I
dont reload the data I just saved. (But other connection subsystem
instances do.)
*/
String fn = getFilePath(profile);
// Disable our resource change monitoring temporarily while we
// update the XML file
ignoreMyResourceChange = true;
SystemResourceManager.turnOffResourceEventListening();
File xf = new File(fn);
if (!xf.getParentFile().exists()) // test added by Phil
{
xf.getParentFile().mkdirs(); // this is bad! Who refreshes from local?
try { // ok, now we do. I added this. Phil
getFolder(profile).getParent().refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (Exception exc) {
}
}
Document udoc = getProfileIndexedInstanceVariable_Document(profile);
try // address various file I/O exceptions
{
FileOutputStream fo = new FileOutputStream(xf);
try {
Source source = new DOMSource(udoc);
Result result = new StreamResult(fo);
Transformer t = TransformerFactory.newInstance().newTransformer();
t.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
t.transform(source, result);
} catch (TransformerConfigurationException e) {
} catch (TransformerFactoryConfigurationError e) {
} catch (TransformerException e) {
}
// XMLSerializer xs = new XMLSerializer(fo, null);
// // Select "readable" format. (multiple lines)
// OutputFormat fmt = new OutputFormat(udoc);
// xs.setOutputFormat(fmt);
// fmt.setIndenting(true);
// fmt.setIndent(1); // 0 turns off indenting
// // Line width 300, so that we don't cut long comments/commands/actions at a certain length.
// fmt.setLineWidth(300);
// fmt.setPreserveSpace(true);
// xs.serialize(udoc);
// fo.close();
// fo = null;
setProfileIndexedInstanceVariable_hasChanged(profile, false);
// Always refresh-from-local:
// If this saves, don't want next refresh-from-local to trigger
// a change event when we were the ones to change it. (and have the
// current data already loaded.)
// Refresh the workspace to recognise (new) file.
// getFolder().refreshLocal( IResource.DEPTH_ONE, null);
// A more specific refresh:
IFile file = getFolder(profile).getFile(getFileName());
// file.touch(null);
file.refreshLocal(IResource.DEPTH_ONE, null);
} catch (Exception exc) {
// if (null != fo)
// fo.close();
SystemMessageDialog msgdlg = new SystemMessageDialog(SystemBasePlugin.getActiveWorkbenchShell(), RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_SAVE_FAILED).makeSubstitution(exc));
msgdlg.open();
}
profile.commit();
ignoreMyResourceChange = false;
SystemResourceManager.turnOnResourceEventListening();
}
/**
* Refresh the xml file from disk. Eg equivalent to use selecting Refresh.
*/
public void refreshLocal(ISystemProfile profile) {
try {
IFile file = getFolder(profile).getFile(getFileName());
file.touch(null);
file.refreshLocal(IResource.DEPTH_ONE, null);
} catch (Exception e) {
SystemBasePlugin.logError("Error refreshing in SystemUDBaseManager.", e); //$NON-NLS-1$
}
}
/**
* Move given element down one in document, save document
* @return true if move successful
*/
public boolean moveElementDown(SystemXMLElementWrapper elementWrapper, SystemXMLElementWrapper nextNextElementWrapper) {
public boolean moveElementDown(SystemXMLElementWrapper elementWrapper/*, SystemXMLElementWrapper nextNextElementWrapper*/) {
getDocument(elementWrapper.getProfile());
Element element = elementWrapper.getElement();
try {
Node parentElement = element.getParentNode();
//Node nextElement = element.getNextSibling();
//Node nextNextElement = nextElement.getNextSibling();
if (nextNextElementWrapper != null)
parentElement.insertBefore(element, nextNextElementWrapper.getElement());
else
parentElement.insertBefore(element, null);
} catch (Exception exc) {
SystemBasePlugin.logError("Error moving user action/type down", exc); //$NON-NLS-1$
return false;
IPropertySet element = elementWrapper.getElement();
IPropertySetContainer parentElement = element.getContainer();
IPropertySet[] allChildren = parentElement.getPropertySets();
for (int i = 0; i < allChildren.length; ++i)
{
if (allChildren[i] == element)
{
if (i < allChildren.length - 1) //not the last one
{
allChildren[i] = allChildren[i+1];
allChildren[i+1] = element;
}
}
}
saveUserData(elementWrapper.getProfile());
return true;
@ -894,16 +677,21 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Move given element up one in document, save document
* @return true if move successful
*/
public boolean moveElementUp(SystemXMLElementWrapper elementWrapper, SystemXMLElementWrapper previousElementWrapper) {
public boolean moveElementUp(SystemXMLElementWrapper elementWrapper/*, SystemXMLElementWrapper previousElementWrapper*/) {
getDocument(elementWrapper.getProfile());
Element element = elementWrapper.getElement();
try {
Node parentElement = element.getParentNode();
//Node previousElement = element.getPreviousSibling();
parentElement.insertBefore(element, previousElementWrapper.getElement());
} catch (Exception exc) {
SystemBasePlugin.logError("Error moving user action/type up", exc); //$NON-NLS-1$
return false;
IPropertySet element = elementWrapper.getElement();
IPropertySetContainer parentElement = element.getContainer();
IPropertySet[] allChildren = parentElement.getPropertySets();
for (int i = 0; i < allChildren.length; ++i)
{
if (allChildren[i] == element)
{
if (i > 0) //not the first one
{
allChildren[i] = allChildren[i-1];
allChildren[i-1] = element;
}
}
}
saveUserData(elementWrapper.getProfile());
return true;
@ -916,6 +704,8 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* if the reference in the clipboard corresponds to a node clone in this object.
* @return an id that uniquely identifies the cloned node, or null if it failed.
*/
//TODO - XUAN
/*
public String prepareClipboardCopy(SystemXMLElementWrapper elementWrapper) {
getDocument(elementWrapper.getProfile());
Element element = elementWrapper.getElement();
@ -933,6 +723,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
// currentNodeCloneName = elementWrapper.getName();
return currentNodeCloneID;
}
*/
/**
* Test if the given ID, read from the clipboard, matches a node we prepared for
@ -953,17 +744,20 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
*/
public SystemXMLElementWrapper pasteClipboardCopy(SystemXMLElementWrapper selectedElementWrapper, String id) {
getDocument(selectedElementWrapper.getProfile());
Element selectedElement = selectedElementWrapper.getElement();
IPropertySet selectedElement = selectedElementWrapper.getElement();
SystemXMLElementWrapper pastedElementWrapper = null;
try {
Node parentElement = null;
Element pastedElement = null;
IPropertySetContainer parentElement = null;
IPropertySet pastedElement = null;
if (selectedElementWrapper.isDomain()) {
parentElement = selectedElement;
pastedElement = (Element) parentElement.appendChild(currentNodeClone);
parentElement.addPropertySet(currentNodeClone);
pastedElement = currentNodeClone;
} else {
parentElement = selectedElement.getParentNode();
pastedElement = (Element) parentElement.insertBefore(currentNodeClone, selectedElement);
parentElement = selectedElement.getContainer();
//TODO - Xuan: need to take care of order here.
parentElement.addPropertySet(currentNodeClone);
pastedElement = currentNodeClone;
}
pastedElementWrapper = createElementWrapper(pastedElement, selectedElementWrapper.getProfile(), selectedElementWrapper.getDomain());
pastedElementWrapper.setName(getUniqueCloneName(pastedElementWrapper));
@ -1007,6 +801,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Returns root elements for the currently set profile (see setCurrentProfile).
* If this is null, returns root elements for all active profiles
*/
public Object[] getElements(Object element) {
if (!supportsProfiles())
return getElements((ISystemProfile) null, element);
@ -1018,6 +813,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
return getElements(getActiveSystemProfiles(), element);
}
}
/**
* Return root elements for given profile.
@ -1062,7 +858,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
// if domains not supported, return singleton New item, plus wrappers
// of any action/type elements found
else {
Element parentDomainElement = null;
IPropertySetContainer parentDomainElement = null;
if (onlyDomain == -1)
v.add(SystemUDTreeViewNewItem.getOnlyNewItem(isUserActionsManager(), getNewNodeLabel()));
else
@ -1089,7 +885,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* @return translated value for "New" in new icon. Default is "New"
*/
protected String getNewNodeLabel() {
return SystemResources.ACTION_CASCADING_NEW_LABEL;
return SystemUDAResources.ACTION_CASCADING_NEW_LABEL;
}
/**
@ -1143,10 +939,10 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Find a child element of a given name.
* Returns the xml node element or null
*/
public Element findChildByName(ISystemProfile profile, String name, int domain) {
Document xdoc = getDocument(profile);
public IPropertySet findChildByName(ISystemProfile profile, String name, int domain) {
IPropertySet xdoc = getDocument(profile);
if (getActionSubSystem().supportsDomains() && (domain >= 0)) {
Element domainElement = findDomainElement(xdoc, domain);
IPropertySet domainElement = findDomainElement(xdoc, domain);
return SystemXMLElementWrapper.findChildByName(domainElement, xdoc, getTagName(), name);
} else {
return SystemXMLElementWrapper.findChildByName(null, xdoc, getTagName(), name);
@ -1158,7 +954,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Returns the wrapper of the xml node element or null
*/
public SystemXMLElementWrapper findByName(ISystemProfile profile, String name, int domain) {
Element element = findChildByName(profile, name, domain);
IPropertySet element = findChildByName(profile, name, domain);
if (element == null)
return null;
else
@ -1169,9 +965,9 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Get a list of existing names, for unique-name checking.
*/
public Vector getExistingNames(ISystemProfile profile, int domain) {
Document xdoc = getDocument(profile);
IPropertySet xdoc = getDocument(profile);
if (getActionSubSystem().supportsDomains() && (domain >= 0)) {
Element domainElement = findDomainElement(xdoc, domain);
IPropertySet domainElement = findDomainElement(xdoc, domain);
if (domainElement == null) return new Vector(); // defect 46147
return SystemXMLElementWrapper.getExistingNames(domainElement, xdoc, getTagName());
} else {
@ -1185,17 +981,34 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* and creates and returns a wrapper object for it.
*/
public SystemXMLElementWrapper addElement(ISystemProfile profile, int domain, String name) {
Document xdoc = getDocument(profile);
SystemXMLElementWrapper newElementWrapper = null;
Element newtag = xdoc.createElement(getTagName());
newtag.setAttribute("Name", uppercaseName() ? name.toUpperCase() : name); //$NON-NLS-1$
String osType = _udas.getOSType();
String udaRootPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType + "." + getDocumentRootTagName(); //$NON-NLS-1$
//String userDefinedActionPropertySetName = ISystemUDAConstants.USER_DEFINED_ACTION_PROPRERTY_SET_PREFIX + osType;
//ISystemProfile systemProfile = SystemRegistry.getInstance().getSystemProfile(profile.getName());
IPropertySet udaRootPropertySet = profile.getPropertySet(udaRootPropertySetName);
if (udaRootPropertySet == null)
{
udaRootPropertySet = profile.createPropertySet(udaRootPropertySetName);
udaRootPropertySet.addProperty(ISystemUDAConstants.RELEASE_ATTR, CURRENT_RELEASE_NAME);
udaRootPropertySet.addProperty(ISystemUDAConstants.UDA_ROOT_ATTR, getDocumentRootTagName());
}
IPropertySet child = null;
// Get domain element, create if necessary
if (getActionSubSystem().supportsDomains()) {
Element se = findOrCreateDomainElement(xdoc, domain);
se.appendChild(newtag);
} else
xdoc.getDocumentElement().appendChild(newtag);
newElementWrapper = createElementWrapper(newtag, profile, domain);
if (getActionSubSystem().supportsDomains())
{
IPropertySet se = findOrCreateDomainElement(udaRootPropertySet, domain);
child = se.createPropertySet(name);
}
else
{
child = udaRootPropertySet.createPropertySet(name);
}
child.addProperty(ISystemUDAConstants.NAME_ATTR, uppercaseName() ? name.toUpperCase() : name);
child.addProperty(ISystemUDAConstants.TYPE_ATTR, getTagName());
SystemXMLElementWrapper newElementWrapper = null;
newElementWrapper = createElementWrapper(child, profile, domain);
setChanged(profile);
return newElementWrapper;
}
@ -1215,7 +1028,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
/**
* Set the profile-indexed document instance variable
*/
private void setProfileIndexedInstanceVariable_Document(ISystemProfile profile, Document doc) {
private void setProfileIndexedInstanceVariable_Document(ISystemProfile profile, IPropertySet doc) {
if (!supportsProfiles())
udocNoProfile = doc;
else
@ -1225,11 +1038,11 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
/**
* Get the profile-indexed document instance variable
*/
private Document getProfileIndexedInstanceVariable_Document(ISystemProfile profile) {
private IPropertySet getProfileIndexedInstanceVariable_Document(ISystemProfile profile) {
if (!supportsProfiles())
return udocNoProfile;
else
return (Document) udocsByProfile.get(profile);
return (IPropertySet) udocsByProfile.get(profile);
}
/**
@ -1261,16 +1074,6 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
}
}
/**
* Set the profile-indexed dir-path instance variable
*/
private void setProfileIndexedInstanceVariable_dirPath(ISystemProfile profile, Object[] dirPath) {
if (!supportsProfiles())
dirPathNoProfile = dirPath;
else
dirPathByProfile.put(profile, dirPath);
}
/**
* Get the dir-path has-changed instance variable
*/
@ -1290,7 +1093,12 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* returns null
*/
protected SystemXMLElementWrapper getDomainWrapper(ISystemProfile profile, int domain) {
Element element = findDomainElement(getDocument(profile), domain);
IPropertySet udaRootPropertySet = getDocument(profile);
if (udaRootPropertySet == null)
{
return null;
}
IPropertySet element = findDomainElement(getDocument(profile), domain);
if (element != null)
return createDomainElementWrapper(element, profile, domain);
else
@ -1305,23 +1113,20 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* not the order they are found in the document!
*/
protected Vector createExistingDomainElementWrappers(Vector v, ISystemProfile profile) {
Document xdoc = getDocument(profile);
Element docroot = xdoc.getDocumentElement();
IPropertySet xdoc = getDocument(profile);
// get the "domain" children of the root, in the pre-determined order of domains
NodeList subList = docroot.getChildNodes();
if ((subList == null) || (subList.getLength() == 0)) return v;
IPropertySet[] subList = xdoc.getPropertySets();
if ((subList == null) || (subList.length == 0)) return v;
String[] domains = getActionSubSystem().getDomainNames();
int subListLen = subList.getLength();
int subListLen = subList.length;
for (int idx = 0; idx < domains.length; idx++) {
Element match = null;
IPropertySet match = null;
for (int jdx = 0; (match == null) && (jdx < subListLen); jdx++) {
Node currNode = subList.item(jdx);
if ((currNode instanceof Element) &&
// is "Domain" tag, and "Type" attr value matches domains[idx]?
isDomainElement((Element) currNode, domains[idx])) {
IPropertySet currNode = subList[jdx];
if (isDomainElement(currNode, domains[idx])) {
//Element currElement = (Element)currNode;
//if (currElement.getAttribute(XE_DOMTYPE).equals(domains[idx]))
match = (Element) currNode;
match = currNode;
}
}
if (match != null) v.add(createDomainElementWrapper(match, profile, idx));
@ -1332,7 +1137,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
/**
* Create a domain element wrapper
*/
protected SystemXMLElementWrapper createDomainElementWrapper(Element xmlDomainElementToWrap, ISystemProfile profile, int domain) {
protected SystemXMLElementWrapper createDomainElementWrapper(IPropertySet xmlDomainElementToWrap, ISystemProfile profile, int domain) {
return createElementWrapper(xmlDomainElementToWrap, profile, domain);
}
@ -1340,7 +1145,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Given an xml action/type document, try to find a domain element ("Domain" tag)
* of the given domain type. If not found, do NOT create it.
*/
protected Element findDomainElement(Document xdoc, int domain) {
protected IPropertySet findDomainElement(IPropertySet xdoc, int domain) {
return findOrCreateDomainElement(xdoc, domain, false);
}
@ -1348,7 +1153,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Given an xml action/type document, try to find a domain element ("Domain" tag)
* of the given untranslated name ("Type" attribute). If not found, create it.
*/
protected Element findOrCreateDomainElement(Document xdoc, int domain) {
protected IPropertySet findOrCreateDomainElement(IPropertySet xdoc, int domain) {
return findOrCreateDomainElement(xdoc, domain, true);
}
@ -1356,7 +1161,25 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Given an xml action/type document, try to find a domain element ("Domain" tag)
* of the given untranslated name ("Type" attribute). If not found, optionally create it.
*/
protected Element findOrCreateDomainElement(Document xdoc, int domain, boolean create) {
protected IPropertySet findOrCreateDomainElement(IPropertySet xdoc, int domain, boolean create) {
IPropertySet[] domainSets = xdoc.getPropertySets();
String domainName = getActionSubSystem().mapDomainName(domain); // unxlated name. Eg "Type" parm
IPropertySet domainElement = null;
for (int i = 0; i < domainSets.length; i++)
{
IPropertySet thisDomain = domainSets[i];
if (null != thisDomain)
{
if (isDomainElement(thisDomain, domainName))
{
domainElement = thisDomain;
}
}
}
/*
NodeList subList = xdoc.getDocumentElement().getChildNodes();
String domainName = getActionSubSystem().mapDomainName(domain); // unxlated name. Eg "Type" parm
Element domainElement = null;
@ -1368,6 +1191,7 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
}
}
}
*/
if (create && (domainElement == null)) domainElement = createDomainElement(xdoc, domain);
return domainElement;
}
@ -1377,11 +1201,11 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* @param xdoc - the document to add it to. Will be added as child of root
* @param domain - the integer representation of the domain, used to get its name and translated name
*/
protected Element createDomainElement(Document xdoc, int domain) {
Element element = xdoc.createElement(ISystemUDAConstants.XE_DOMAIN);
xdoc.getDocumentElement().appendChild(element);
element.setAttribute(ISystemUDAConstants.XE_DOMTYPE, getActionSubSystem().mapDomainName(domain));
element.setAttribute(ISystemUDAConstants.XE_DOMNAME, getActionSubSystem().mapDomainXlatedName(domain));
protected IPropertySet createDomainElement(IPropertySet xdoc, int domain) {
IPropertySet element = xdoc.createPropertySet(getActionSubSystem().mapDomainXlatedName(domain));
element.addProperty(ISystemUDAConstants.XE_DOMTYPE, getActionSubSystem().mapDomainName(domain));
element.addProperty(ISystemUDAConstants.XE_DOMNAME, getActionSubSystem().mapDomainXlatedName(domain));
element.addProperty(ISystemUDAConstants.TYPE_ATTR, ISystemUDAConstants.XE_DOMAIN);
return element;
}
@ -1392,15 +1216,15 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Given an xml Element object, return true if it is a Domain
* element. That is, if its tag name is "Domain"
*/
public static boolean isDomainElement(Element element) {
return (element.getTagName().equals(ISystemUDAConstants.XE_DOMAIN));
public static boolean isDomainElement(IPropertySet element) {
return (element.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(ISystemUDAConstants.XE_DOMAIN));
}
/**
* Given an xml Element object, return true if it is a Domain
* element and its "Type" attribute matches the given name.
*/
public static boolean isDomainElement(Element element, String domainName) {
public static boolean isDomainElement(IPropertySet element, String domainName) {
return isDomainElement(element) && domainTypeEquals(element, domainName);
}
@ -1408,8 +1232,8 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Given an xml Domain element, return true if it's "type" attribute matches
* the given untranslated domain name
*/
public static boolean domainTypeEquals(Element element, String domainName) {
return (element.getAttribute(ISystemUDAConstants.XE_DOMTYPE).equals(domainName));
public static boolean domainTypeEquals(IPropertySet element, String domainName) {
return (element.getPropertyValue(ISystemUDAConstants.XE_DOMTYPE).equals(domainName));
}
/**
@ -1423,17 +1247,32 @@ public abstract class SystemUDBaseManager implements ErrorHandler, IResourceChan
* Do so by traversing the tree backwards, back to the Document root,
* then forwards again to verify the child links are in place.
*/
public static boolean inCurrentTree(Node n) {
if (n instanceof Document) return true;
Node parent = n.getParentNode();
public static boolean inCurrentTree(IPropertySet n) {
String udaRootType = n.getPropertyValue(ISystemUDAConstants.UDA_ROOT_ATTR);
if (udaRootType != null && (udaRootType.equals(ISystemUDAConstants.ACTIONS_ROOT) || udaRootType.equals(ISystemUDAConstants.FILETYPES_ROOT)))
{
//It is one of the UDA related root.
return true;
}
IPropertySetContainer parent = n.getContainer();
if (null == parent) return false;
// Recursive, walk tree back to root, then finally Document.
if (!inCurrentTree(parent)) return false;
if (parent instanceof IPropertySet)
{
if (!inCurrentTree((IPropertySet)parent)) return false;
}
else
{
return false;
}
// Finally, check this is still a child of the parent
Node sibling = parent.getFirstChild();
while (null != sibling) {
if (n == sibling) return true;
sibling = sibling.getNextSibling();
IPropertySet[] siblings = parent.getPropertySets();
for (int i=0; i<siblings.length; i++)
{
if (n == siblings[i])
{
return true;
}
}
return false;
}

View file

@ -29,6 +29,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.rse.core.RSECorePlugin;
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.subsystems.ISubSystem;
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.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
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.TreeItem;
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.
@ -417,8 +415,8 @@ public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, I
public boolean doMoveUp() {
IStructuredSelection selection = (IStructuredSelection) getSelection();
SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement();
SystemXMLElementWrapper previousElement = (SystemXMLElementWrapper) getSelectedPreviousTreeItem().getData();
boolean moved = docManager.moveElementUp(firstSelect, previousElement);
//SystemXMLElementWrapper previousElement = (SystemXMLElementWrapper) getSelectedPreviousTreeItem().getData();
boolean moved = docManager.moveElementUp(firstSelect/*, previousElement*/);
if (moved) {
refreshElementParent(firstSelect);
selectElement(firstSelect);
@ -436,10 +434,9 @@ public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, I
public boolean doMoveDown() {
IStructuredSelection selection = (IStructuredSelection) getSelection();
SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement();
TreeItem nextNextItem = getSelectedNextNextTreeItem();
SystemXMLElementWrapper nextElement = null;
if (nextNextItem != null) nextElement = (SystemXMLElementWrapper) nextNextItem.getData();
boolean moved = docManager.moveElementDown(firstSelect, nextElement);
//SystemXMLElementWrapper nextElement = null;
//if (nextNextItem != null) nextElement = (SystemXMLElementWrapper) nextNextItem.getData();
boolean moved = docManager.moveElementDown(firstSelect/*, nextElement*/);
if (moved) {
refreshElementParent(firstSelect);
selectElement(firstSelect);
@ -455,6 +452,7 @@ public class SystemUDBaseTreeView extends TreeViewer implements IMenuListener, I
* Called by the SystemChangeFilterActionCopyString action class.
*/
public boolean doCopy() {
/*
IStructuredSelection selection = (IStructuredSelection) getSelection();
SystemXMLElementWrapper firstSelect = (SystemXMLElementWrapper) selection.getFirstElement();
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;
TextTransfer transfer = TextTransfer.getInstance();
clipboard.setContents(new Object[] { id }, new Transfer[] { transfer });
*/
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.
*/
public TreeItem findParentItem(SystemXMLElementWrapper element) {
Element parentElement = element.getParentDomainElement();
IPropertySet parentElement = element.getParentDomainElement();
TreeItem parentItem = null;
if (parentElement != null)
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,
* scanning entire tree.
*/
private TreeItem findElement(Node searchNode) {
private TreeItem findElement(IPropertySet searchNode) {
TreeItem match = null;
TreeItem[] roots = getTree().getItems();
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
* under the given parent.
*/
private TreeItem findElement(TreeItem parentItem, Node searchNode) {
private TreeItem findElement(TreeItem parentItem, IPropertySet searchNode) {
TreeItem match = null;
// first, check for match on the given parent itself...
Object itemData = parentItem.getData();
Element itemNode = null;
IPropertySet itemNode = null;
if ((itemData != null) && (itemData instanceof SystemXMLElementWrapper)) {
itemNode = ((SystemXMLElementWrapper) itemData).getElement();
if (itemNode == searchNode) return parentItem;

View file

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

View file

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

View file

@ -10,14 +10,16 @@ package org.eclipse.rse.internal.useractions.ui.uda;
* Contributors:
* 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.swt.graphics.Image;
import org.w3c.dom.Element;
/**
* Wraps a "Type" XML tag
*/
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 TYPE_TAG = "Type"; //$NON-NLS-1$
@ -27,7 +29,7 @@ public class SystemUDTypeElement extends SystemXMLElementWrapper {
* @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)
*/
public SystemUDTypeElement(Element element, SystemUDTypeManager tm, int domainType) {
public SystemUDTypeElement(IPropertySet element, SystemUDTypeManager tm, int 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
*/
public Image getImage() {
//System.out.println("in getImage(): isIBM()="+isIBM()+", isUserChanged()="+isUserChanged());
Image image = null;
if (isIBM()) {
if (isUserChanged())
@ -59,14 +60,27 @@ public class SystemUDTypeElement extends SystemXMLElementWrapper {
* Return the list of types
*/
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
*/
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);
setTextNode(TYPES_TAG, s);
}
}

View file

@ -12,21 +12,12 @@
*******************************************************************************/
package org.eclipse.rse.internal.useractions.ui.uda;
import java.io.File;
import java.util.Vector;
import org.eclipse.core.resources.IFile;
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.IPropertySet;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.useractions.UserActionsIcon;
import org.eclipse.rse.internal.useractions.UserActionsPersistenceUtil;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.swt.graphics.Image;
import org.w3c.dom.Element;
/**
* 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 {
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 ALL_TYPE = "ALL"; //$NON-NLS-1$
public final static String UDT_FILENAME = "udtype.xml"; //$NON-NLS-1$
private boolean oldFolderChecked = false;
/**
* Constructor
@ -67,12 +56,6 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
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.
@ -109,7 +92,7 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
* Given an xml element node, create an instance of the appropriate
* subclass of SystemXMLElementWrapper to represent it.
*/
public SystemXMLElementWrapper createElementWrapper(Element xmlElementToWrap, ISystemProfile profile, int domain) {
public SystemXMLElementWrapper createElementWrapper(IPropertySet xmlElementToWrap, ISystemProfile profile, int domain) {
SystemUDTypeElement elementWrapper = new SystemUDTypeElement(xmlElementToWrap, this, domain);
return elementWrapper;
}
@ -150,68 +133,9 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
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
@ -229,7 +153,8 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
* its types, or null if not found
*/
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)
return element.getTypes();
else
@ -247,7 +172,7 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
* @return array of type objects
*/
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];
SystemUDTypeElement[] types = new SystemUDTypeElement[v.size()];
for (int idx = 0; idx < types.length; idx++)
@ -290,7 +215,8 @@ public class SystemUDTypeManager extends SystemUDBaseManager {
* and is typed to return SystemUDTypeElement
*/
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
*/
public void saveUserData() {
super.saveUserData(null);
ISystemProfile profile = getActionSubSystem().getSubsystem().getSystemProfile();
super.saveUserData(profile);
}
/*
* Get our xml document

View file

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

View file

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

View file

@ -16,43 +16,41 @@ import java.util.Vector;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Platform;
import org.eclipse.rse.core.model.IProperty;
import org.eclipse.rse.core.model.IPropertySet;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.swt.graphics.Image;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
/**
* This is a base class for classes that wrapper xml elements.
* Eg, there are child classes to represent action xml elements, and
* type xml elements.
* This is a base class for classes that wrapper UDA elements.
* Eg, there are child classes to represent action UDA elements, and
* type UDA elements.
*/
public abstract class SystemXMLElementWrapper implements IAdaptable {
//parameters
protected Element elm;
protected IPropertySet elm;
private boolean isDomainElement;
private SystemUDBaseManager database; // For setChanged()
private ISystemProfile profile;
private int domainType;
// constants
/**
* What we store in XML document for TRUE
* What we store in UDA document for TRUE
*/
private static final String XML_TRUE = "True"; //$NON-NLS-1$
private static final String UDA_TRUE = "True"; //$NON-NLS-1$
/**
* What we store in XML document for FALSE
* What we store in UDA document for FALSE
*/
private static final String XML_FALSE = "False"; //$NON-NLS-1$
private static final String UDA_FALSE = "False"; //$NON-NLS-1$
/**
* The XML attribute name for the "IBM-Supplied" attribute
*/
private static final String XML_ATTR_VENDOR = "Vendor"; //$NON-NLS-1$
private static final String UDA_ATTR_VENDOR = "Vendor"; //$NON-NLS-1$
/**
* The XML attribute name for the "User-Changed" attribute
*/
private static final String XML_ATTR_CHANGED = "UserChanged"; //$NON-NLS-1$
private static final String UDA_ATTR_CHANGED = "UserChanged"; //$NON-NLS-1$
/**
* The value we place in the Vendor attribute for IBM-supplied actions/types
*/
@ -60,15 +58,15 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
/**
* Constructor
* @param elm - The actual xml document element for this action/type
* @param elm - The actual UDA element for this action/type
* @param mgr - The parent manager of these actions/types
* @param profile - The system profile which owns this action
* @param domainType - The integer representation of the domain this is in (or this is, for a domain element)
*/
public SystemXMLElementWrapper(Element elm, SystemUDBaseManager mgr, ISystemProfile profile, int domainType) {
public SystemXMLElementWrapper(IPropertySet elm, SystemUDBaseManager mgr, ISystemProfile profile, int domainType) {
super();
this.elm = elm;
this.isDomainElement = elm.getTagName().equals(ISystemUDAConstants.XE_DOMAIN);
this.isDomainElement = elm.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(ISystemUDAConstants.XE_DOMAIN);
this.domainType = domainType;
database = mgr;
this.profile = profile;
@ -115,41 +113,41 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
}
/**
* Get the XML document element this node wraps
* Get the UDA element this node wraps
*/
public Element getElement() {
public IPropertySet getElement() {
return elm;
}
/**
* Get the document this element is a part of
*/
public Document getDocument() {
public IPropertySet getDocument() {
// this method added by phil.
// this allows getChildren in xxxmanager classes to avoid deducing the document
return elm.getOwnerDocument();
return (IPropertySet)elm.getContainer();
}
/**
* Get the parent xml domain element of this element.
* Get the parent UDA element of this element.
* If domains aren't supported, this will return null
*/
public Element getParentDomainElement() {
Element parent = getParentElement();
if ((parent != null) && parent.getTagName().equals(ISystemUDAConstants.XE_DOMAIN))
public IPropertySet getParentDomainElement() {
IPropertySet parent = getParentElement();
if ((parent != null) && parent.getPropertyValue(ISystemUDAConstants.NAME_ATTR).equals(ISystemUDAConstants.XE_DOMAIN))
return parent;
else
return null;
}
/**
* Get the parent xml element of this element.
* Get the parent UDA element of this element.
* Only returns null if this is the root, which should never happen.
*/
public Element getParentElement() {
Node parent = elm.getParentNode();
if (parent instanceof Element)
return (Element) parent;
public IPropertySet getParentElement() {
Object parent = elm.getContainer();
if (parent instanceof IPropertySet)
return (IPropertySet) parent;
else
return null;
}
@ -174,7 +172,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Return the value of this node's "Name" attribute
*/
public String getName() {
return elm.getAttribute(ISystemUDAConstants.NAME_ATTR);
return elm.getPropertyValue(ISystemUDAConstants.NAME_ATTR);
}
/**
@ -184,11 +182,22 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
*/
public void setName(String s) {
if (isIBM()) {
String orgName = elm.getAttribute(ISystemUDAConstants.ORIGINAL_NAME_ATTR);
String orgName = elm.getPropertyValue(ISystemUDAConstants.ORIGINAL_NAME_ATTR);
if ((orgName != null) && (orgName.length() > 0)) {
// no need to do anything, as its already set.
} else
elm.setAttribute(ISystemUDAConstants.ORIGINAL_NAME_ATTR, getName());
}
else
{
IProperty property = elm.getProperty(ISystemUDAConstants.ORIGINAL_NAME_ATTR);
if (null == property)
{
elm.addProperty(ISystemUDAConstants.ORIGINAL_NAME_ATTR, getName());
}
else
{
property.setValue(getName());
}
}
}
setAttribute(ISystemUDAConstants.NAME_ATTR, s);
setUserChanged(true);
@ -198,7 +207,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* For IBM-supplied elements that have been edited, returns the original IBM-supplied name
*/
public String getOriginalName() {
String s = elm.getAttribute(ISystemUDAConstants.ORIGINAL_NAME_ATTR);
String s = elm.getPropertyValue(ISystemUDAConstants.ORIGINAL_NAME_ATTR);
if ((s == null) || (s.length() == 0))
return getName();
else
@ -210,7 +219,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* That is, is this an IBM-supplied tag?
*/
public boolean isIBM() {
String vendor = elm.getAttribute(XML_ATTR_VENDOR);
String vendor = elm.getPropertyValue(UDA_ATTR_VENDOR);
if (vendor == null)
return false;
else
@ -221,7 +230,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Set the name of the vendor who supplied this user action or type
*/
public void setVendor(String vendor) {
setAttribute(XML_ATTR_VENDOR, vendor);
setAttribute(UDA_ATTR_VENDOR, vendor);
}
/**
@ -229,7 +238,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* May be null, if created by a user
*/
public String getVendor() {
return elm.getAttribute(XML_ATTR_VENDOR);
return elm.getPropertyValue(UDA_ATTR_VENDOR);
}
/**
@ -238,9 +247,9 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
*/
public void setIBM(boolean isFromIBM) {
if (isFromIBM)
setAttribute(XML_ATTR_VENDOR, VENDOR_IBM);
setAttribute(UDA_ATTR_VENDOR, VENDOR_IBM);
else
setAttribute(XML_ATTR_VENDOR, null);
setAttribute(UDA_ATTR_VENDOR, null);
}
/**
@ -254,7 +263,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
else if (isDomainElement)
changed = false;
else
changed = getBooleanAttribute(XML_ATTR_CHANGED, false);
changed = getBooleanAttribute(UDA_ATTR_CHANGED, false);
//System.out.println("Inside isUserChanged, returning "+changed+": isIBM()="+isIBM()+", isDomainElement="+isDomainElement);
return changed;
}
@ -263,7 +272,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Set the value of this tag's "user-changed" attribute
*/
public void setUserChanged(boolean isUserChanged) {
if (isIBM() && !isDomainElement) setBooleanAttribute(XML_ATTR_CHANGED, isUserChanged);
if (isIBM() && !isDomainElement) setBooleanAttribute(UDA_ATTR_CHANGED, isUserChanged);
}
/**
@ -271,82 +280,23 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
*/
public void deleteElement() {
// Not intended for root. Only for Actions
elm.getParentNode().removeChild(elm);
//elm.getParentNode().removeChild(elm);
elm.getContainer().removePropertySet(elm.getName());
}
// --------------------------
// INTERNAL HELPER METHODS...
// --------------------------
/**
* Given the name of a child xml tag, return the data for that tag
*/
protected String getTextNode(String tagname) {
Element tag = getChildTag(tagname, false);
if (null != tag) {
Node n = tag.getFirstChild();
if (null != n) {
if (n instanceof Text) {
Text tn = (Text) n;
return tn.getData();
}
}
}
return ""; //$NON-NLS-1$
}
/**
* Given the name of a child xml tag and a data value,
* update the data of that tag
*/
protected void setTextNode(String tagname, String val) {
Element tag = getChildTag(tagname, true);
if (null != tag) {
database.setChanged(profile);
// ?? Loop on all children, removing?
Node n = tag.getFirstChild();
if (null != n) {
if (n instanceof Text) {
Text tn = (Text) n;
tn.setData(val);
return;
}
// ?? Loop on all children, removing?
tag.removeChild(n);
}
tag.appendChild(elm.getOwnerDocument().createTextNode(val));
return;
}
}
/**
* Given a tag name, return the xml node for that child tag
* @param tagname - the name of the tag to find
* @param create - true if tag is to be created if not found
*/
protected Element getChildTag(String tagname, boolean create) {
NodeList subList = elm.getChildNodes();
if (null != subList) {
for (int i = 0; i < subList.getLength(); i++) {
Node sn = subList.item(i);
if (sn instanceof Element) {
Element se = (Element) sn;
if (tagname.equals(se.getTagName())) return se;
}
}
}
if (create) {
Element newchild = elm.getOwnerDocument().createElement(tagname);
elm.appendChild(newchild);
return newchild;
}
return null;
}
/**
* Set the value of a boolean attribute
*/
public void setBooleanAttribute(String attr, boolean b) {
elm.setAttribute(attr, (b) ? XML_TRUE : XML_FALSE);
IProperty property = elm.getProperty(attr);
if (null == property)
{
elm.addProperty(attr, (b) ? UDA_TRUE : UDA_FALSE);
}
else
{
property.setValue((b) ? UDA_TRUE : UDA_FALSE);
}
database.setChanged(profile);
}
@ -355,8 +305,8 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* @param attr - name of the attribute to query
*/
public boolean getBooleanAttribute(String attr) {
String val = elm.getAttribute(attr);
if (XML_TRUE.equals(val)) return true;
String val = elm.getPropertyValue(attr);
if (UDA_TRUE.equals(val)) return true;
return false;
}
@ -366,9 +316,9 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* @param defaultValue - value to return if the attribute is not found
*/
public boolean getBooleanAttribute(String attr, boolean defaultValue) {
String val = elm.getAttribute(attr);
String val = elm.getPropertyValue(attr);
if (val == null) return defaultValue;
if (XML_TRUE.equals(val)) return true;
if (UDA_TRUE.equals(val)) return true;
return false;
}
@ -377,7 +327,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Specify a default value to return if the attribute is not found
*/
public String getAttribute(String attr, String defaultValue) {
String value = elm.getAttribute(attr);
String value = elm.getPropertyValue(attr);
if (value == null) value = defaultValue;
return value;
}
@ -387,9 +337,21 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
*/
public void setAttribute(String attr, String value) {
if (value != null)
elm.setAttribute(attr, value);
{
IProperty property = elm.getProperty(attr);
if (property == null)
{
elm.addProperty(attr, value);
}
else
{
property.setValue(value);
}
}
else
elm.removeAttribute(attr);
{
elm.removeProperty(attr);
}
database.setChanged(profile);
}
@ -400,7 +362,7 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Always returns a non-null vector, although it may be empty
*/
public Vector getExistingNames() {
Element parentElement = null;
IPropertySet parentElement = null;
String currName = null;
if (isDomain())
parentElement = this.getElement();
@ -418,55 +380,39 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Given a parent element XML node, returns all child action names.
* Always returns a non-null vector, although it may be empty
*/
public Vector getExistingNames(Element parentElement, Document xdoc) {
public Vector getExistingNames(IPropertySet parentElement, IPropertySet xdoc) {
return getExistingNames(parentElement, xdoc, getTagName());
}
/**
* For unique-name checking.
* Given a parent element XML node, returns all child action names.
* Given a parent UDA node, returns all child action names.
* Always returns a non-null vector of Strings, although it may be empty
*/
public static Vector getExistingNames(Element parentElement, Document xdoc, String tagName) {
public static Vector getExistingNames(IPropertySet parentElement, IPropertySet xdoc, String tagName) {
Vector nameList = new Vector();
Element se = null;
NodeList subList = null;
IPropertySet[] subList = null;
if (parentElement != null)
subList = parentElement.getChildNodes();
subList = parentElement.getPropertySets();
else
subList = xdoc.getElementsByTagName(tagName);
subList = xdoc.getPropertySets();
if (subList != null) {
for (int idx = 0; idx < subList.getLength(); idx++) {
Node sn = subList.item(idx);
if (sn instanceof Element) {
se = (Element) sn;
if (se.getTagName().equals(tagName)) {
nameList.add(se.getAttribute(ISystemUDAConstants.NAME_ATTR));
}
for (int idx = 0; idx < subList.length; idx++) {
IPropertySet sn = subList[idx];
if (sn.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(tagName))
{
nameList.add(sn.getPropertyValue(ISystemUDAConstants.NAME_ATTR));
}
} // end for all subnodes
} // end if sublist != null
return nameList;
}
/**
* Returns element wrappers of children (if this is a domain) or siblings
*/
public Vector getChildren(Vector children, ISystemProfile profile) {
Element parentElement = null;
if (isDomain())
parentElement = this.getElement();
else
parentElement = getParentElement();
children = getChildren(children, parentElement, getDocument(), profile);
return children;
}
/**
* Given a parent element XML node, returns wrappers of all child tags of which we are interested
* Always returns a non-null vector, although it may be empty
*/
public Vector getChildren(Vector children, Element parentElement, Document xdoc, ISystemProfile profile) {
public Vector getChildren(Vector children, IPropertySet parentElement, IPropertySet xdoc, ISystemProfile profile) {
return getChildren(children, parentElement, xdoc, profile, database, getDomain());
}
@ -476,23 +422,22 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* If the parentElement is null, uses the roots of the given document. Should only be true if domains not supported!
* @return Vector of SystemXMLElementWrapper objects
*/
public static Vector getChildren(Vector children, Element parentElement, Document xdoc, ISystemProfile profile, ISystemXMLElementWrapperFactory factory, int domain) {
public static Vector getChildren(Vector children, IPropertySet parentElement, IPropertySet xdoc, ISystemProfile profile, ISystemXMLElementWrapperFactory factory, int domain) {
if (children == null) children = new Vector();
String tagName = factory.getTagName();
Element se = null;
NodeList subList = null;
IPropertySet[] subList = null;
if (parentElement != null)
subList = parentElement.getChildNodes();
subList = parentElement.getPropertySets();
else
subList = xdoc.getElementsByTagName(tagName);
subList = xdoc.getPropertySets();
if (subList != null) {
for (int idx = 0; idx < subList.getLength(); idx++) {
Node sn = subList.item(idx);
if (sn instanceof Element) {
se = (Element) sn;
if (se.getTagName().equals(tagName)) {
children.add(factory.createElementWrapper(se, profile, domain));
}
for (int idx = 0; idx < subList.length; idx++) {
IPropertySet sn = subList[idx];
if (sn.getPropertyValue(ISystemUDAConstants.TYPE_ATTR).equals(tagName))
{
SystemXMLElementWrapper thisWrapper = factory.createElementWrapper(sn, profile, domain);
children.add(thisWrapper);
}
} // end for all subnodes
} // end if sublist != null
@ -504,19 +449,22 @@ public abstract class SystemXMLElementWrapper implements IAdaptable {
* Given a parent element XML node, returns the xml Element node with the given name attribute,
* or null if not found.
*/
public static Element findChildByName(Element parentElement, Document xdoc, String tagName, String searchName) {
Element match = null;
NodeList subList = null;
public static IPropertySet findChildByName(IPropertySet parentElement, IPropertySet xdoc, String tagName, String searchName) {
IPropertySet match = null;
IPropertySet[] subList = null;
if (parentElement != null)
subList = parentElement.getChildNodes();
subList = parentElement.getPropertySets();
else
subList = xdoc.getElementsByTagName(tagName);
subList = xdoc.getPropertySets();
if (subList != null) {
for (int idx = 0; (match == null) && (idx < subList.getLength()); idx++) {
Node sn = subList.item(idx);
if (sn instanceof Element) {
if (((Element) sn).getTagName().equals(tagName)) {
if (((Element) sn).getAttribute(ISystemUDAConstants.NAME_ATTR).equals(searchName)) match = (Element) sn;
for (int idx = 0; (match == null) && (idx < subList.length); idx++) {
IPropertySet sn = subList[idx];
if (sn.getName().equals(searchName))
{
IProperty typeProperty = sn.getProperty(ISystemUDAConstants.TYPE_ATTR);
if (typeProperty.getValue().equals(tagName))
{
match = sn;
}
}
} // end for all subnodes

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

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

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
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
*******************************************************************************/
package org.eclipse.rse.internal.useractions.ui.compile;
package org.eclipse.rse.useractions.ui.compile;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@ -18,6 +18,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.model.ISystemProfile;
import org.eclipse.rse.internal.useractions.UserActionsResources;
import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileCascadeByProfileAction;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemPreferencesManager;

View file

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

View file

@ -11,8 +11,9 @@
* David Dykstal (IBM) - [186589] move user types, user actions, and compile commands
* API to the user actions plugin
*******************************************************************************/
package org.eclipse.rse.internal.useractions.ui.compile;
package org.eclipse.rse.useractions.ui.compile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.rse.core.model.ISystemProfile;
@ -20,6 +21,9 @@ import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
import org.eclipse.rse.internal.ui.view.team.SystemTeamViewSubSystemConfigurationNode;
import org.eclipse.rse.internal.useractions.IUserActionsImageIds;
import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager;
import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileProfile;
import org.eclipse.rse.internal.useractions.ui.compile.SystemWorkWithCompileCommandsDialog;
import org.eclipse.rse.internal.useractions.ui.compile.teamview.SystemTeamViewCompileTypeNode;
import org.eclipse.rse.internal.useractions.ui.uda.SystemUDAResources;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
@ -27,6 +31,7 @@ import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemBaseDialogAction;
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
import org.eclipse.rse.ui.view.SystemAdapterHelpers;
import org.eclipse.rse.useractions.files.compile.ISystemCompileManagerAdapter;
import org.eclipse.swt.widgets.Shell;
/**
@ -113,33 +118,46 @@ public class SystemWorkWithCompileCommandsAction extends SystemBaseDialogAction
if (currSystemProfile == null) currSystemProfile = subsystem.getSystemProfile();
}
if (ssf != null) {
/* FIXME - compile actions not coupled with subsystem API anymore
compileManager = ssf.getCompileManager();
if (subsystem != null)
{
compileManager.setSystemConnection(subsystem.getHost());
ISubSystemConfiguration ssc = subsystem.getSubSystemConfiguration();
if (inputObject instanceof IAdaptable) {
ISystemCompileManagerAdapter adapter = (ISystemCompileManagerAdapter)((IAdaptable)inputObject).getAdapter(ISystemCompileManagerAdapter.class);
if (null != adapter)
{
compileManager = adapter.getSystemCompileManager(ssc);
}
}
if (null != compileManager)
{
if (currSystemProfile != null)
{
currProfile = compileManager.getCompileProfile(currSystemProfile);
currProfiles = compileManager.getAllCompileProfiles();
}
caseSensitive = ssf.isCaseSensitive();
SystemWorkWithCompileCommandsDialog dlg = new SystemWorkWithCompileCommandsDialog(shell, compileManager, currProfile);
/* FIXME - currProfiles cannot be null since above stuff was commented out
if (currProfiles != null) {
dlg.setProfiles(currProfiles);
}
*/
dlg.setProfiles(currProfiles);
dlg.setCaseSensitive(caseSensitive);
if (inputObject instanceof SystemTeamViewCompileTypeNode) {
SystemTeamViewCompileTypeNode node = (SystemTeamViewCompileTypeNode) inputObject;
dlg.setCompileType(node.getCompileType());
dlg.setSupportsAddSrcTypeButton(false);
}
return dlg;
}
if (currSystemProfile != null)
currProfile = compileManager.getCompileProfile(currSystemProfile);
currProfiles = compileManager.getAllCompileProfiles();
*/
caseSensitive = ssf.isCaseSensitive();
}
SystemWorkWithCompileCommandsDialog dlg = new SystemWorkWithCompileCommandsDialog(shell, compileManager, currProfile);
/* FIXME - currProfiles cannot be null since above stuff was commented out
if (currProfiles != null) {
dlg.setProfiles(currProfiles);
}
*/
dlg.setProfiles(currProfiles);
dlg.setCaseSensitive(caseSensitive);
if (inputObject instanceof SystemTeamViewCompileTypeNode) {
SystemTeamViewCompileTypeNode node = (SystemTeamViewCompileTypeNode) inputObject;
dlg.setCompileType(node.getCompileType());
dlg.setSupportsAddSrcTypeButton(false);
}
return dlg;
return null;
}
/**