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

[261019] New File/Folder actions available in Work Offline mode

This commit is contained in:
David McKnight 2009-01-23 15:59:45 +00:00
parent ef55e61199
commit e863f9e6ae
7 changed files with 160 additions and 70 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2006, 2008 IBM Corporation and others. All rights reserved.
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
@ -12,12 +12,7 @@ Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
Contributors:
Martin Oberhuber (Wind River) - [180519] declaratively register adapter factories
Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
David McKnight (IBM) - [187711] Link with Editor action for System View
David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
Johnson Ma (Wind River) - [195402] Add tar.gz archive support
David McKnight (IBM) - [261019] New File/Folder actions available in Work Offline mode
-->
<?eclipse version="3.0"?>
<plugin>
@ -448,14 +443,17 @@ Johnson Ma (Wind River) - [195402] Add tar.gz archive support
objectClass="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"
id="org.eclipse.rse.files.ui.actions.synchronizeCache">
<visibility>
<objectState name="isdirectory" value="true"/>
</visibility>
<objectState name="isdirectory" value="true"/>
</visibility>
<action
label="%synchronizeCache.label"
tooltip="%synchronizeCache.tooltip"
class="org.eclipse.rse.internal.files.ui.actions.SynchronizeCacheActionDelegate"
menubarPath="group.importexport"
id="synchronizeCache">
<enablement>
<objectState name="offline" value="false"/>
</enablement>
</action>
</objectContribution>
</extension>

View file

@ -24,6 +24,7 @@
* David McKnight (IBM) - [224313] [api] Create RSE Events for MOVE and COPY holding both source and destination fields
* David McKnight (IBM) - [224377] "open with" menu does not have "other" option
* David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService
* David McKnight (IBM) - [261019] New File/Folder actions available in Work Offline mode
********************************************************************************/
package org.eclipse.rse.internal.files.ui.actions;
@ -130,6 +131,9 @@ implements IValidatorRemoteSelection
Object selectedObject = e.next();
if (!(selectedObject instanceof IRemoteFile))
enable = false;
else {
enable = !((IRemoteFile)selectedObject).getParentRemoteFileSubSystem().isOffline();
}
}
return enable;
}
@ -588,4 +592,7 @@ implements IValidatorRemoteSelection
{
return null;
}
}

View file

@ -12,18 +12,21 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* David McKnight (IBM) - [261019] New File/Folder actions available in Work Offline mode
*******************************************************************************/
package org.eclipse.rse.internal.files.ui.actions;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.files.ui.wizards.SystemNewFileWizard;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemBaseWizardAction;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
import org.eclipse.swt.widgets.Shell;
@ -65,5 +68,21 @@ public class SystemNewFileAction extends SystemBaseWizardAction
// newFileWizard.setInputObject(getValue());
return newFileWizard;
}
public boolean checkObjectType(Object selectedObject)
{
if (selectedObject instanceof IAdaptable){
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)selectedObject).getAdapter(ISystemViewElementAdapter.class);
if (adapter != null){
ISubSystem ss = adapter.getSubSystem(selectedObject);
if (ss != null){
if (ss.isOffline()){
return false;
}
}
}
}
return true;
}
}

View file

@ -12,19 +12,22 @@
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* {Name} (company) - description of contribution.
* David McKnight (IBM) - [261019] New File/Folder actions available in Work Offline mode
*******************************************************************************/
package org.eclipse.rse.internal.files.ui.actions;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.files.ui.FileResources;
import org.eclipse.rse.internal.files.ui.wizards.SystemNewFolderWizard;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.actions.SystemBaseWizardAction;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
import org.eclipse.swt.widgets.Shell;
@ -65,4 +68,19 @@ public class SystemNewFolderAction extends SystemBaseWizardAction
return newFolderWizard;
}
public boolean checkObjectType(Object selectedObject)
{
if (selectedObject instanceof IAdaptable){
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)selectedObject).getAdapter(ISystemViewElementAdapter.class);
if (adapter != null){
ISubSystem ss = adapter.getSubSystem(selectedObject);
if (ss != null){
if (ss.isOffline()){
return false;
}
}
}
}
return true;
}
}

View file

@ -12,16 +12,20 @@
*
* Contributors:
* Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin
* David McKnight (IBM) - [261019] New File/Folder actions available in Work Offline mode
********************************************************************************/
package org.eclipse.rse.internal.files.ui.actions;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.files.ui.search.SystemSearchPage;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
import org.eclipse.rse.ui.actions.SystemBaseAction;
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.swt.widgets.Shell;
@ -41,4 +45,20 @@ public class SystemSearchAction extends SystemBaseAction {
public void run() {
NewSearchUI.openSearchDialog(SystemBasePlugin.getActiveWorkbenchWindow(), SystemSearchPage.SYSTEM_SEARCH_PAGE_ID);
}
public boolean checkObjectType(Object selectedObject)
{
if (selectedObject instanceof IAdaptable){
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)selectedObject).getAdapter(ISystemViewElementAdapter.class);
if (adapter != null){
ISubSystem ss = adapter.getSubSystem(selectedObject);
if (ss != null){
if (ss.isOffline()){
return false;
}
}
}
}
return true;
}
}

View file

@ -58,6 +58,7 @@
* Anna Dushistova (MontaVista) - [226550] [api] Launch Shell and Launch Terminal actions should be contributed declaratively
* Martin Oberhuber (Wind River) - [234215] improve API documentation for doDelete and doDeleteBatch
* David McKnight (IBM) - [251860] Rename a file/folder to a hidden file causes problems
* David McKnight (IBM) - [261019] New File/Folder actions available in Work Offline mode
*******************************************************************************/
package org.eclipse.rse.internal.files.ui.view;
@ -317,7 +318,8 @@ public class SystemViewRemoteFileAdapter
boolean canRead = true;
boolean supportsSearch = true;
boolean supportsArchiveManagement = false;
boolean offline = false;
// perf improvement... phil
Object firstSelection = selection.getFirstElement();
IRemoteFile firstFile = null;
@ -327,9 +329,13 @@ public class SystemViewRemoteFileAdapter
elementType = firstFile.isDirectory() || firstFile.isRoot() ? 1 : 0;
isArchive = firstFile.isArchive();
canRead = firstFile.canRead();
IRemoteFileSubSystem fileSubSystem = firstFile.getParentRemoteFileSubSystem();
offline = fileSubSystem.isOffline();
supportsSearch = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsSearch();
supportsArchiveManagement = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement();
supportsSearch = fileSubSystem.getParentRemoteFileSubSystemConfiguration().supportsSearch();
supportsArchiveManagement = fileSubSystem.getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement();
}
else
return;
@ -353,25 +359,24 @@ public class SystemViewRemoteFileAdapter
if ((elementType == 1 || (isArchive && supportsArchiveManagement)))
{
if (!foldersOnly && canRead)
if (!foldersOnly)
{
if (addNewFile == null)
{
addNewFile = new SystemNewFileAction(shell);
addNewFile = new SystemNewFileAction(shell);
}
addNewFile.setEnabled(canRead && !offline);
menu.add(ISystemContextMenuConstants.GROUP_NEW, addNewFile);
}
if (!filesOnly)
{
if (canRead)
{
if (addNewFolder == null)
{
addNewFolder = new SystemNewFolderAction(shell);
}
menu.add(ISystemContextMenuConstants.GROUP_NEW, addNewFolder);
}
if (addNewFolder == null)
{
addNewFolder = new SystemNewFolderAction(shell);
}
addNewFolder.setEnabled(canRead && !offline);
menu.add(ISystemContextMenuConstants.GROUP_NEW, addNewFolder);
if (addNewFilter == null)
{
addNewFilter = new SystemNewFileFilterFromFolderAction(shell);
@ -382,33 +387,27 @@ public class SystemViewRemoteFileAdapter
}
}
else
{
if (canRead)
{
// open
String label = SystemResources.ACTION_CASCADING_OPEN_LABEL;
String tooltip = SystemResources.ACTION_CASCADING_OPEN_TOOLTIP;
SystemEditFilesAction action = new SystemEditFilesAction(label, tooltip, shell);
menu.add(ISystemContextMenuConstants.GROUP_OPEN, action);
else {
// open
String label = SystemResources.ACTION_CASCADING_OPEN_LABEL;
String tooltip = SystemResources.ACTION_CASCADING_OPEN_TOOLTIP;
SystemEditFilesAction action = new SystemEditFilesAction(label, tooltip, shell);
menu.add(ISystemContextMenuConstants.GROUP_OPEN, action);
action.setEnabled(canRead && !offline);
// open with ->
// open with ->
MenuManager submenu =
new MenuManager(FileResources.ResourceNavigator_openWith,
ISystemContextMenuConstants.GROUP_OPENWITH);
MenuManager submenu =
new MenuManager(FileResources.ResourceNavigator_openWith,
ISystemContextMenuConstants.GROUP_OPENWITH);
if (openWithMenu == null)
{
openWithMenu = new SystemRemoteFileOpenWithMenu();
}
openWithMenu.updateSelection(selection);
submenu.add(openWithMenu);
menu.getMenuManager().appendToGroup(ISystemContextMenuConstants.GROUP_OPENWITH, submenu);
}
if (openWithMenu == null)
{
openWithMenu = new SystemRemoteFileOpenWithMenu();
}
openWithMenu.updateSelection(selection);
submenu.add(openWithMenu);
menu.getMenuManager().appendToGroup(ISystemContextMenuConstants.GROUP_OPENWITH, submenu);
}
@ -444,35 +443,40 @@ public class SystemViewRemoteFileAdapter
{
replaceEditionAction = new SystemReplaceWithEditionAction(shell);
}
if (canRead && supportsSearch)
if (supportsSearch)
{
//menu.add(ISystemContextMenuConstants.GROUP_IMPORTEXPORT, addToArchiveAction);
// add search action
menu.add(ISystemContextMenuConstants.GROUP_SEARCH, searchAction);
searchAction.setEnabled(canRead && !offline);
}
if (!firstFile.isRoot() && canRead)
if (!firstFile.isRoot())
{
menu.add(menuGroup, copyClipboardAction);
copyClipboardAction.setEnabled(canRead && !offline);
if (elementType == 0)
{
menu.add(ISystemContextMenuConstants.GROUP_COMPAREWITH, compareFilesAction);
menu.add(ISystemContextMenuConstants.GROUP_COMPAREWITH, compareEditionAction);
menu.add(ISystemContextMenuConstants.GROUP_REPLACEWITH, replaceEditionAction);
compareFilesAction.setEnabled(canRead && !offline);
compareEditionAction.setEnabled(canRead && !offline);
replaceEditionAction.setEnabled(canRead && !offline);
}
}
if (elementType == 1 || (isArchive && supportsArchiveManagement))
{
if (canRead)
{
menu.add(menuGroup, pasteClipboardAction);
}
menu.add(menuGroup, pasteClipboardAction);
pasteClipboardAction.setEnabled(canRead && !offline);
}
if (!firstFile.isRoot() && canRead)
if (!firstFile.isRoot())
{
menu.add(menuGroup, moveAction);
moveAction.setEnabled(canRead && !offline);
}
}
@ -1491,7 +1495,9 @@ public class SystemViewRemoteFileAdapter
{
if (element instanceof IRemoteFile)
{
return ((IRemoteFile)element).canRead();
IRemoteFile file = (IRemoteFile)element;
boolean offline = file.getParentRemoteFileSubSystem().isOffline();
return file.canRead() && !offline;
}
return true;
}
@ -1506,8 +1512,9 @@ public class SystemViewRemoteFileAdapter
if (element instanceof IRemoteFile)
{
IRemoteFile file = (IRemoteFile) element;
boolean offline = file.getParentRemoteFileSubSystem().isOffline();
boolean supportsArchiveManagement = file.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement();
return file.canRead() && file.canWrite() && (file.isDirectory() || file.isRoot() || (file.isArchive() && supportsArchiveManagement));
return !offline && file.canRead() && file.canWrite() && (file.isDirectory() || file.isRoot() || (file.isArchive() && supportsArchiveManagement));
}
return false;
@ -2727,8 +2734,8 @@ public class SystemViewRemoteFileAdapter
public boolean canDelete(Object element)
{
IRemoteFile file = (IRemoteFile) element;
//System.out.println("INSIDE CANDELETE FOR ADAPTER: RETURNING " + !file.isRoot());
return !file.isRoot() && file.canRead();
boolean offline = file.getParentRemoteFileSubSystem().isOffline();
return !file.isRoot() && file.canRead() && !offline;
}
@ -2861,7 +2868,8 @@ public class SystemViewRemoteFileAdapter
public boolean canRename(Object element)
{
IRemoteFile file = (IRemoteFile) element;
return !file.isRoot() && file.canRead();
boolean offline = file.getParentRemoteFileSubSystem().isOffline();
return !file.isRoot() && file.canRead() && !offline;
}
private void moveTempResource(IResource localResource, IPath newLocalPath, IRemoteFileSubSystem ss, String newRemotePath)
@ -3357,7 +3365,8 @@ public class SystemViewRemoteFileAdapter
IRemoteFile remoteFile = (IRemoteFile) element;
if (remoteFile.isFile())
{
return remoteFile.canRead();
boolean offline = remoteFile.getParentRemoteFileSubSystem().isOffline();
return remoteFile.canRead() && !offline;
}
return false;
}

View file

@ -1,4 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
Initial Contributors:
The following IBM employees contributed to the Remote System Explorer
component that contains this file: David McKnight, Kushal Munir,
Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
Contributors:
David McKnight (IBM) - [261019] New File/Folder actions available in Work Offline mode
-->
<?eclipse version="3.0"?>
<plugin>
@ -100,19 +116,19 @@
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"
id="org.eclipse.rse.files.importexport.projectImportExport">
<filter
name="isDirectory"
value="true">
</filter>
id="org.eclipse.rse.files.importexport.projectImportExport">
<filter name="isDirectory" value="true"/>
<action
label="%ImportToProject.label"
label="%ImportToProject.label"
tooltip="%ImportToProject.tooltip"
class="org.eclipse.rse.internal.importexport.files.RemoteFileImportToProjectActionDelegate"
menubarPath="group.importexport"
enablesFor="1"
enablesFor="1"
id="importToProject">
<enablement>
<objectState name="offline" value="false"/>
</enablement>
</action>
<action
@ -122,6 +138,9 @@
menubarPath="group.importexport"
enablesFor="1"
id="exportFromProject">
<enablement>
<objectState name="offline" value="false"/>
</enablement>
</action>
</objectContribution>
</extension>