From 71f5f0bcc2a379a94436eb43d25f1c0ee4f0aa21 Mon Sep 17 00:00:00 2001 From: Kevin Doyle Date: Fri, 14 Nov 2008 15:54:39 +0000 Subject: [PATCH] [239700] Compile Commands are available on items it shouldn't --- .../plugin.xml | 2 +- .../files/core/RemoteFilePropertyTester.java | 17 ++- .../META-INF/MANIFEST.MF | 3 +- .../plugin.properties | 4 +- .../org.eclipse.rse.useractions/plugin.xml | 90 +++++++++++- .../rse/internal/useractions/Activator.java | 3 - .../ui/compile/SystemDynamicCompileMenu.java | 24 +-- .../SystemDynamicCompilePromptMenu.java | 138 ++++++++++++++++++ .../compile/CompilablePropertyTester.java | 58 ++++++++ .../ui/SystemCommandTextField.java | 2 +- .../SystemCompileMultipleSelectAction.java | 4 +- .../ui/uda/SystemUDActionSubsystem.java | 1 - .../ui/uda/SystemUDBaseManager.java | 3 - 13 files changed, 307 insertions(+), 42 deletions(-) create mode 100644 rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemDynamicCompilePromptMenu.java create mode 100644 rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/CompilablePropertyTester.java diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/plugin.xml b/rse/plugins/org.eclipse.rse.subsystems.files.core/plugin.xml index c40c90aa47c..dc0fde4488d 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/plugin.xml +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/plugin.xml @@ -67,7 +67,7 @@ class="org.eclipse.rse.internal.subsystems.files.core.RemoteFilePropertyTester" id="org.eclipse.rse.subsystems.files.core.RemoteFilePropertyTester" namespace="org.eclipse.rse.subsystems.files" - properties="isdirectory" + properties="isdirectory,isvirtual,isroot,isarchive" type="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"> diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/RemoteFilePropertyTester.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/RemoteFilePropertyTester.java index 9912490760e..4ffa8d3c102 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/RemoteFilePropertyTester.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/internal/subsystems/files/core/RemoteFilePropertyTester.java @@ -6,20 +6,33 @@ * * Contributors: * Anna Dushistova (MontaVista) - initial API and implementation + * Kevin Doyle (IBM) - [239700] Compile Commands are available on items it shouldn't ********************************************************************************/ package org.eclipse.rse.internal.subsystems.files.core; import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; public class RemoteFilePropertyTester extends PropertyTester { + public static final String PROPERTY_ISDIRECTORY = "isdirectory"; //$NON-NLS-1$ + public static final String PROPERTY_ISROOT = "isroot"; //$NON-NLS-1$ + public static final String PROPERTY_ISVIRTUAL = "isvirtual"; //$NON-NLS-1$ + public static final String PROPERTY_ISARCHIVE = "isarchive"; //$NON-NLS-1$ + public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { boolean test = ((Boolean) expectedValue).booleanValue(); if (receiver != null && receiver instanceof IRemoteFile) { - return ((IRemoteFile) receiver).isDirectory() && test; - + if (property.equals(PROPERTY_ISDIRECTORY)) + return ((IRemoteFile) receiver).isDirectory() == test; + else if (property.equals(PROPERTY_ISROOT)) + return ((IRemoteFile) receiver).isRoot() == test; + else if (property.equals(PROPERTY_ISVIRTUAL)) + return ArchiveHandlerManager.isVirtual(((IRemoteFile) receiver).getAbsolutePath()) == test; + else if (property.equals(PROPERTY_ISARCHIVE)) + return ((IRemoteFile) receiver).isArchive() == test; } return !test; } diff --git a/rse/plugins/org.eclipse.rse.useractions/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.useractions/META-INF/MANIFEST.MF index 3ea61826a6f..6a7ba4f896e 100644 --- a/rse/plugins/org.eclipse.rse.useractions/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.useractions/META-INF/MANIFEST.MF @@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.core.resources, org.eclipse.rse.subsystems.shells.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.subsystems.files.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.shells.ui;bundle-version="[3.0.0,4.0.0)", - org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)" + org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)", + org.eclipse.core.expressions Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true Export-Package: org.eclipse.rse.internal.useractions;x-internal:=true, diff --git a/rse/plugins/org.eclipse.rse.useractions/plugin.properties b/rse/plugins/org.eclipse.rse.useractions/plugin.properties index abd866390a1..ccea6b73735 100644 --- a/rse/plugins/org.eclipse.rse.useractions/plugin.properties +++ b/rse/plugins/org.eclipse.rse.useractions/plugin.properties @@ -9,6 +9,7 @@ # IBM Corporation - initial API and implementation # Martin Oberhuber (Wind River) - add providerName # David Dykstal (IBM) - [186589] move properties from org.eclipse.rse.ui +# Kevin Doyle (IBM) - [239700] Compile Commands are available on items it shouldn't ############################################################################### # NLS_MESSAGEFORMAT_NONE @@ -22,4 +23,5 @@ PropertyPage.TeamViewCompileTypeNode = Compile Type Information PropertyPage.TeamViewCompileCommandNode = Compile Command Information DynamicLabel.CompileActionNode = Compile -DynamicLabel.UserActionNode = User Action +DynamicLabel.CompilePromptActionNode = Compile (Prompt) +DynamicLabel.UserActionNode = User Action \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.useractions/plugin.xml b/rse/plugins/org.eclipse.rse.useractions/plugin.xml index dc4ddc199cd..496e7f73486 100644 --- a/rse/plugins/org.eclipse.rse.useractions/plugin.xml +++ b/rse/plugins/org.eclipse.rse.useractions/plugin.xml @@ -13,15 +13,76 @@ + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/Activator.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/Activator.java index a4bdd2f7d46..83df7b39022 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/Activator.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/Activator.java @@ -12,9 +12,6 @@ *******************************************************************************/ package org.eclipse.rse.internal.useractions; -import java.net.URL; - -import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.rse.ui.SystemBasePlugin; import org.osgi.framework.BundleContext; diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemDynamicCompileMenu.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemDynamicCompileMenu.java index ae4e5582f83..55fe89c6f17 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemDynamicCompileMenu.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/api/ui/compile/SystemDynamicCompileMenu.java @@ -7,13 +7,13 @@ * Contributors: * Xuan Chen (IBM) - [222470] initial contribution. * Kevin Doyle (IBM) - [239805] User Action/Compile menu's shouldn't be tied to IRemoteFile + * Kevin Doyle (IBM) - [239700] Compile Commands are available on items it shouldn't *********************************************************************************/ package org.eclipse.rse.internal.useractions.api.ui.compile; 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.action.Separator; @@ -48,22 +48,6 @@ 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() { @@ -122,9 +106,9 @@ public class SystemDynamicCompileMenu extends CompoundContributionItem SystemCompileCommand[] cmds = compileType.getCompileCommandsArray(); for (int idx2=0; idx2 + * EXPERIMENTAL. This class or interface has been added as part + * of a work in progress. There is no guarantee that this API will work or that + * it will remain the same. Please do not use this API without consulting with + * the Target Management team. + *

+ */ +public class SystemDynamicCompilePromptMenu extends CompoundContributionItem +{ + + 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(); + if (firstSelection == null) + { + return new IContributionItem[0]; + } + Shell shell = SystemBasePlugin.getActiveWorkbenchShell(); + + ISystemRemoteElementAdapter rmtAdapter = SystemAdapterHelpers.getRemoteAdapter(firstSelection); + 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) + { + compileManager = new UniversalCompileManager(); + compileManager.setSubSystemFactory(ssc); + } + + for (int idx = 0; idx < activeProfiles.length; idx++) + { + String srcType = null; + 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$ + } + + if (null != compileManager) + { + SystemCompileManager thisCompileManager = compileManager; + SystemCompileProfile compileProfile = thisCompileManager.getCompileProfile(activeProfiles[idx]); + // compileProfile.addContributions(firstSelection); + SystemCompileType compileType = compileProfile.getCompileType(srcType); + + if (compileType != null) + { + SystemCompileCommand[] cmds = compileType.getCompileCommandsArray(); + for (int idx2=0; idx2 0) + returnedItemList.add(new Separator()); + + // Here's where you would dynamically generate your list + SystemWorkWithCompileCommandsAction workWithCompileCommandAction = new SystemWorkWithCompileCommandsAction(shell, true, subsystem, compileManager); + workWithCompileCommandAction.setSelection(selection); + ActionContributionItem testContribution = new ActionContributionItem(workWithCompileCommandAction); + returnedItemList.add(testContribution); + IContributionItem[] list = (IContributionItem[])returnedItemList.toArray(new IContributionItem[]{}); + //String[] array = (String[])arrayList.toArray(new String[]{}); + //SystemCascadingCompileAction promptAction = new SystemCascadingCompileAction(null, true); + //list[0] = new TestContribution(/*promptAction*/); + + return list; + } + +} diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/CompilablePropertyTester.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/CompilablePropertyTester.java new file mode 100644 index 00000000000..edc96b20e45 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/files/compile/CompilablePropertyTester.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * 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 + * + * Contributors: + * Kevin Doyle (IBM) - initial API and implementation + ********************************************************************************/ + +package org.eclipse.rse.internal.useractions.files.compile; + +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.internal.useractions.api.files.compile.ISystemCompileManagerAdapter; +import org.eclipse.rse.internal.useractions.ui.compile.SystemCompileManager; +import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; +import org.eclipse.rse.ui.view.SystemAdapterHelpers; + +public class CompilablePropertyTester extends PropertyTester { + + public static final String PROPERTY_ISCOMPILABLE = "iscompilable"; //$NON-NLS-1$ + + + public boolean test(Object receiver, String property, Object[] args, + Object expectedValue) { + + boolean test = ((Boolean) expectedValue).booleanValue(); + + if (property.equals(PROPERTY_ISCOMPILABLE) && receiver != null && receiver instanceof IAdaptable) { + ISubSystem subsystem = null; + + ISystemRemoteElementAdapter remoteAdapter = SystemAdapterHelpers.getRemoteAdapter(receiver); + if (remoteAdapter != null) + subsystem = remoteAdapter.getSubSystem(receiver); + + ISystemCompileManagerAdapter adapter = (ISystemCompileManagerAdapter) ((IAdaptable) receiver).getAdapter(ISystemCompileManagerAdapter.class); + if (subsystem != null) + { + SystemCompileManager compileManager = null; + + if (adapter != null) + compileManager = adapter.getSystemCompileManager(subsystem.getSubSystemConfiguration()); + + if (compileManager == null) + compileManager = new UniversalCompileManager(); // Use the Default Universal Compile Manager + + compileManager.setSubSystemFactory(subsystem.getSubSystemConfiguration()); + + return compileManager.isCompilable(receiver) == test; + } + } + return test == false; + } + +} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCommandTextField.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCommandTextField.java index cb9bd87959f..ce8c2b8d9af 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCommandTextField.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/SystemCommandTextField.java @@ -198,7 +198,7 @@ public class SystemCommandTextField implements SelectionListener { textCommand.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); break; // CTRL-Z - case (int) 'z' - (int) 'a' + 1 : + case 'z' - 'a' + 1 : textCommand.doOperation(ITextOperationTarget.UNDO); //e.doit = false; break; diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileMultipleSelectAction.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileMultipleSelectAction.java index cc1dffa972e..59a40235e99 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileMultipleSelectAction.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/compile/SystemCompileMultipleSelectAction.java @@ -96,7 +96,7 @@ public class SystemCompileMultipleSelectAction extends SystemBaseAction { // compileProfile.addContributions(element); // get the compile type for the current resource - SystemCompileType compType = (SystemCompileType)compileProfile.getCompileType(srcType); + SystemCompileType compType = compileProfile.getCompileType(srcType); // get the last used compile command for that type @@ -163,10 +163,8 @@ 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, SystemUDAResources.EditorManager_saveResourcesMessage); dlg.setInitialSelections(input.getChildren()); - // TODO: Cannot use WorkbenchMessages -- it's internal dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle); int result = dlg.open(); //Just return false to prevent the operation continuing diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java index 41dcf2a4ce9..6778835fcda 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDActionSubsystem.java @@ -1126,7 +1126,6 @@ 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, SystemUDAResources.EditorManager_saveResourcesMessage); dlg.setInitialSelections(input.getChildren()); dlg.setTitle(SystemUDAResources.EditorManager_saveResourcesTitle); diff --git a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java index 1dd75639b06..9939349305a 100644 --- a/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java +++ b/rse/plugins/org.eclipse.rse.useractions/src/org/eclipse/rse/internal/useractions/ui/uda/SystemUDBaseManager.java @@ -777,7 +777,6 @@ public abstract class SystemUDBaseManager implements IResourceChangeListener, IS SystemXMLElementWrapper pastedElementWrapper = null; try { IPropertySetContainer parentElement = null; - IPropertySet pastedElement = null; pastedElementWrapper = createElementWrapper(currentNodeClone, selectedElementWrapper.getProfile(), selectedElementWrapper.getDomain()); pastedElementWrapper.setName(getUniqueCloneName(pastedElementWrapper)); @@ -790,7 +789,6 @@ public abstract class SystemUDBaseManager implements IResourceChangeListener, IS currentNodeClone.addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(allChildren.length)); parentElement.addPropertySet(currentNodeClone); - pastedElement = currentNodeClone; } else { parentElement = selectedElement.getContainer(); IPropertySet[] allChildren = parentElement.getPropertySets(); @@ -809,7 +807,6 @@ public abstract class SystemUDBaseManager implements IResourceChangeListener, IS } currentNodeClone.addProperty(ISystemUDAConstants.ORDER_ATTR, Integer.toString(elementOrder + 1)); parentElement.addPropertySet(currentNodeClone); - pastedElement = currentNodeClone; } } catch (Exception exc) {