1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-02 06:35:28 +02:00

[239700] Compile Commands are available on items it shouldn't

This commit is contained in:
Kevin Doyle 2008-11-14 15:54:39 +00:00
parent fc67aaae37
commit 71f5f0bcc2
13 changed files with 307 additions and 42 deletions

View file

@ -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">
</propertyTester>
</extension>

View file

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

View file

@ -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,

View file

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

View file

@ -13,15 +13,76 @@
<visibleWhen>
<with
variable="activeMenuSelection">
<count
value="1">
</count>
<iterate
ifEmpty="false">
<adapt
type="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile">
</adapt>
<and>
<adapt
type="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile">
</adapt>
<test
property="org.eclipse.rse.internal.useractions.files.compile.iscompilable"
value="true">
</test>
<test
property="org.eclipse.rse.subsystems.files.isdirectory"
value="false">
</test>
<test
property="org.eclipse.rse.subsystems.files.isvirtual"
value="false">
</test>
<test
property="org.eclipse.rse.subsystems.files.isarchive"
value="false">
</test>
</and>
</iterate>
</with>
</visibleWhen>
</menu>
<menu
id="org.eclipse.rse.ui.useractions.compileprompt.menu"
label="%DynamicLabel.CompilePromptActionNode">
<dynamic
class="org.eclipse.rse.internal.useractions.api.ui.compile.SystemDynamicCompilePromptMenu"
id="org.eclipse.ui.rse.ui.views.dynamiccompilepromptmenu">
</dynamic>
<visibleWhen>
<with
variable="activeMenuSelection">
<count
value="1">
</count>
<iterate
ifEmpty="false">
<and>
<adapt
type="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile">
</adapt>
<test
property="org.eclipse.rse.internal.useractions.files.compile.iscompilable"
value="true">
</test>
<test
property="org.eclipse.rse.subsystems.files.isdirectory"
value="false">
</test>
<test
property="org.eclipse.rse.subsystems.files.isvirtual"
value="false">
</test>
<test
property="org.eclipse.rse.subsystems.files.isarchive"
value="false">
</test>
</and>
</iterate>
</with>
</visibleWhen>
</menu>
<menu id="org.eclipse.rse.ui.useractions.useraction.menu"
label="%DynamicLabel.UserActionNode">
<dynamic class="org.eclipse.rse.internal.useractions.api.ui.uda.SystemDynamicUserActionMenu"
@ -32,15 +93,32 @@
variable="activeMenuSelection">
<iterate
ifEmpty="false">
<adapt
type="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile">
</adapt>
<and>
<adapt
type="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile">
</adapt>
<test
property="org.eclipse.rse.subsystems.files.isvirtual"
value="false">
</test>
</and>
</iterate>
</with>
</visibleWhen>
</menu>
</menuContribution>
</extension>
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="org.eclipse.rse.internal.useractions.files.compile.CompilablePropertyTester"
id="org.eclipse.rse.internal.useractions.files.compile.CompilablePropertyTester"
namespace="org.eclipse.rse.internal.useractions.files.compile"
properties="iscompilable"
type="org.eclipse.core.runtime.IAdaptable">
</propertyTester>
</extension>
</plugin>

View file

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

View file

@ -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<cmds.length; idx2++)
{
SystemCompileAction action = new SystemCompileAction(shell, cmds[idx2], true);
SystemCompileAction action = new SystemCompileAction(shell, cmds[idx2], false);
action.setSelection(selection);
TestContribution testContribution = new TestContribution(action);
ActionContributionItem testContribution = new ActionContributionItem(action);
returnedItemList.add(testContribution);
//ourSubMenu.add(action);
}
@ -142,7 +126,7 @@ public class SystemDynamicCompileMenu extends CompoundContributionItem
// Here's where you would dynamically generate your list
SystemWorkWithCompileCommandsAction workWithCompileCommandAction = new SystemWorkWithCompileCommandsAction(shell, true, subsystem, compileManager);
workWithCompileCommandAction.setSelection(selection);
TestContribution testContribution = new TestContribution(workWithCompileCommandAction);
ActionContributionItem testContribution = new ActionContributionItem(workWithCompileCommandAction);
returnedItemList.add(testContribution);
IContributionItem[] list = (IContributionItem[])returnedItemList.toArray(new IContributionItem[]{});
//String[] array = (String[])arrayList.toArray(new String[]{});

View file

@ -0,0 +1,138 @@
/*********************************************************************************
* 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
*
* Contributors:
* Xuan Chen (IBM) - [222470] initial contribution.
* Kevin Doyle (IBM) - [239700] Compile Commands are available on items it shouldn't -- Modified SystemDynamicCompileMenu
*********************************************************************************/
package org.eclipse.rse.internal.useractions.api.ui.compile;
import java.util.ArrayList;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.Separator;
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.api.files.compile.ISystemCompileManagerAdapter;
import org.eclipse.rse.internal.useractions.files.compile.UniversalCompileManager;
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.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.CompoundContributionItem;
/**
* Dynamic Compile Menu.
* <p>
* <strong>EXPERIMENTAL</strong>. 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 <a href="http://www.eclipse.org/dsdp/tm/">Target Management</a> team.
* </p>
*/
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<cmds.length; idx2++)
{
SystemCompileAction action = new SystemCompileAction(shell, cmds[idx2], true);
action.setSelection(selection);
ActionContributionItem testContribution = new ActionContributionItem(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
if (returnedItemList.size() > 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;
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -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) {