1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-02 05:03:36 +02:00

[187130] disable actions for non-writeables

This commit is contained in:
David McKnight 2007-07-13 19:31:38 +00:00
parent b15aab9835
commit f640ab5508

View file

@ -265,13 +265,12 @@ public class SystemViewRemoteFileAdapter
{ {
int elementType = 0; int elementType = 0;
boolean isArchive = false; boolean isArchive = false;
boolean allHaveContents = false;
boolean canEdit = true; boolean canRead = true;
boolean canWrite = true;
boolean supportsSearch = true; boolean supportsSearch = true;
boolean supportsArchiveManagement = false; boolean supportsArchiveManagement = false;
boolean isVirtual = false;
// perf improvement... phil // perf improvement... phil
Object firstSelection = selection.getFirstElement(); Object firstSelection = selection.getFirstElement();
@ -281,8 +280,8 @@ public class SystemViewRemoteFileAdapter
firstFile = (IRemoteFile) firstSelection; firstFile = (IRemoteFile) firstSelection;
elementType = firstFile.isDirectory() || firstFile.isRoot() ? 1 : 0; elementType = firstFile.isDirectory() || firstFile.isRoot() ? 1 : 0;
isArchive = firstFile.isArchive(); isArchive = firstFile.isArchive();
isVirtual = firstFile instanceof IVirtualRemoteFile; canRead = firstFile.canRead();
canEdit = firstFile.canRead(); canWrite = firstFile.canWrite();
supportsSearch = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsSearch(); supportsSearch = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsSearch();
supportsArchiveManagement = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement(); supportsArchiveManagement = firstFile.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemConfiguration().supportsArchiveManagement();
@ -290,7 +289,6 @@ public class SystemViewRemoteFileAdapter
else else
return; return;
allHaveContents = isArchive;
if (isArchive) if (isArchive)
{ {
@ -303,7 +301,6 @@ public class SystemViewRemoteFileAdapter
IRemoteFile remoteObj = (IRemoteFile) element; IRemoteFile remoteObj = (IRemoteFile) element;
if (!remoteObj.isArchive()) if (!remoteObj.isArchive())
{ {
allHaveContents = false;
break; break;
} }
} }
@ -311,7 +308,7 @@ public class SystemViewRemoteFileAdapter
if ((elementType == 1 || (isArchive && supportsArchiveManagement))) if ((elementType == 1 || (isArchive && supportsArchiveManagement)))
{ {
if (!foldersOnly && canEdit) if (!foldersOnly && canRead && canWrite)
{ {
if (addNewFile == null) if (addNewFile == null)
{ {
@ -321,7 +318,7 @@ public class SystemViewRemoteFileAdapter
} }
if (!filesOnly) if (!filesOnly)
{ {
if (canEdit) if (canRead && canWrite)
{ {
if (addNewFolder == null) if (addNewFolder == null)
{ {
@ -342,7 +339,7 @@ public class SystemViewRemoteFileAdapter
} }
else else
{ {
if (canEdit) if (canRead)
{ {
// open // open
String label = SystemResources.ACTION_CASCADING_OPEN_LABEL; String label = SystemResources.ACTION_CASCADING_OPEN_LABEL;
@ -367,22 +364,6 @@ public class SystemViewRemoteFileAdapter
} }
// add import and export actions for single selection of folder
/* if ((elementType == 1 && selection.size() == 1) && canEdit)
{
if (importAction == null) {
importAction = new SystemImportToProjectAction(shell);
}
if (exportAction == null) {
exportAction = new SystemExportFromProjectAction(shell);
}
menu.add(ISystemContextMenuConstants.GROUP_IMPORTEXPORT, importAction);
menu.add(ISystemContextMenuConstants.GROUP_IMPORTEXPORT, exportAction);
}*/
if (moveAction == null) if (moveAction == null)
moveAction = new SystemMoveRemoteFileAction(shell); moveAction = new SystemMoveRemoteFileAction(shell);
@ -415,7 +396,7 @@ public class SystemViewRemoteFileAdapter
{ {
replaceEditionAction = new SystemReplaceWithEditionAction(shell); replaceEditionAction = new SystemReplaceWithEditionAction(shell);
} }
if (canEdit && supportsSearch) if (canRead && supportsSearch)
{ {
//menu.add(ISystemContextMenuConstants.GROUP_IMPORTEXPORT, addToArchiveAction); //menu.add(ISystemContextMenuConstants.GROUP_IMPORTEXPORT, addToArchiveAction);
@ -423,7 +404,7 @@ public class SystemViewRemoteFileAdapter
menu.add(ISystemContextMenuConstants.GROUP_SEARCH, searchAction); menu.add(ISystemContextMenuConstants.GROUP_SEARCH, searchAction);
} }
if (!firstFile.isRoot() && canEdit) if (!firstFile.isRoot() && canRead)
{ {
menu.add(menuGroup, copyClipboardAction); menu.add(menuGroup, copyClipboardAction);
if (elementType == 0) if (elementType == 0)
@ -436,12 +417,12 @@ public class SystemViewRemoteFileAdapter
if (elementType == 1 || (isArchive && supportsArchiveManagement)) if (elementType == 1 || (isArchive && supportsArchiveManagement))
{ {
if (canEdit) if (canRead && canWrite)
{ {
menu.add(menuGroup, pasteClipboardAction); menu.add(menuGroup, pasteClipboardAction);
} }
} }
if (!firstFile.isRoot() && canEdit) if (!firstFile.isRoot() && canRead && canWrite)
{ {
menu.add(menuGroup, moveAction); menu.add(menuGroup, moveAction);
} }
@ -2309,7 +2290,7 @@ public class SystemViewRemoteFileAdapter
{ {
IRemoteFile file = (IRemoteFile) element; IRemoteFile file = (IRemoteFile) element;
//System.out.println("INSIDE CANDELETE FOR ADAPTER: RETURNING " + !file.isRoot()); //System.out.println("INSIDE CANDELETE FOR ADAPTER: RETURNING " + !file.isRoot());
return !file.isRoot() && file.canRead(); return !file.isRoot() && file.canRead() && file.canWrite();
} }
@ -2432,7 +2413,7 @@ public class SystemViewRemoteFileAdapter
public boolean canRename(Object element) public boolean canRename(Object element)
{ {
IRemoteFile file = (IRemoteFile) element; IRemoteFile file = (IRemoteFile) element;
return !file.isRoot() && file.canRead(); return !file.isRoot() && file.canRead() && file.canWrite();
} }
private void moveTempResource(IResource localResource, IPath newLocalPath, IRemoteFileSubSystem ss, String newRemotePath) private void moveTempResource(IResource localResource, IPath newLocalPath, IRemoteFileSubSystem ss, String newRemotePath)