initial population
1
rse/plugins/org.eclipse.rse.core/.cvsignore
Normal file
|
@ -0,0 +1 @@
|
|||
bin
|
7
rse/plugins/org.eclipse.rse.files.ui/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
1
rse/plugins/org.eclipse.rse.files.ui/.cvsignore
Normal file
|
@ -0,0 +1 @@
|
|||
bin
|
28
rse/plugins/org.eclipse.rse.files.ui/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.rse.files.ui</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
34
rse/plugins/org.eclipse.rse.files.ui/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,34 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %plugin.name
|
||||
Bundle-SymbolicName: org.eclipse.rse.files.ui;singleton:=true
|
||||
Bundle-Version: 1.0.0
|
||||
Bundle-Activator: org.eclipse.rse.files.ui.Activator
|
||||
Bundle-Localization: plugin
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.rse.services,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.ui.ide,
|
||||
org.eclipse.ui.views,
|
||||
org.eclipse.debug.core,
|
||||
org.eclipse.ui.workbench.texteditor,
|
||||
org.eclipse.jface.text,
|
||||
org.eclipse.search,
|
||||
org.eclipse.compare,
|
||||
org.eclipse.rse.subsystems.shells.core,
|
||||
org.eclipse.rse.subsystems.files.core,
|
||||
org.eclipse.rse.ui
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: org.eclipse.rse.files.ui,
|
||||
org.eclipse.rse.files.ui.actions,
|
||||
org.eclipse.rse.files.ui.compare,
|
||||
org.eclipse.rse.files.ui.dialogs,
|
||||
org.eclipse.rse.files.ui.propertypages,
|
||||
org.eclipse.rse.files.ui.resources,
|
||||
org.eclipse.rse.files.ui.search,
|
||||
org.eclipse.rse.files.ui.view,
|
||||
org.eclipse.rse.files.ui.widgets,
|
||||
org.eclipse.rse.files.ui.wizards
|
||||
Bundle-Vendor: Eclipse.org
|
||||
Bundle-ClassPath: files_ui.jar
|
22
rse/plugins/org.eclipse.rse.files.ui/about.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>About</title>
|
||||
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
|
||||
</head>
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>February 24, 2005</p>
|
||||
<h3>License</h3>
|
||||
|
||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
||||
|
||||
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may
|
||||
apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
||||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
14
rse/plugins/org.eclipse.rse.files.ui/build.properties
Normal file
|
@ -0,0 +1,14 @@
|
|||
bin.includes = META-INF/,\
|
||||
plugin.xml,\
|
||||
about.html,\
|
||||
icons/,\
|
||||
plugin.properties,\
|
||||
files_ui.jar
|
||||
src.includes = icons/,\
|
||||
plugin.properties,\
|
||||
plugin.xml,\
|
||||
META-INF/,\
|
||||
about.html
|
||||
source.files_ui.jar = src/
|
||||
jars.compile.order = files_ui.jar
|
||||
output.files_ui.jar = bin/
|
After Width: | Height: | Size: 587 B |
After Width: | Height: | Size: 354 B |
After Width: | Height: | Size: 317 B |
After Width: | Height: | Size: 339 B |
After Width: | Height: | Size: 216 B |
After Width: | Height: | Size: 120 B |
After Width: | Height: | Size: 580 B |
After Width: | Height: | Size: 592 B |
After Width: | Height: | Size: 336 B |
After Width: | Height: | Size: 339 B |
After Width: | Height: | Size: 586 B |
After Width: | Height: | Size: 164 B |
After Width: | Height: | Size: 63 B |
After Width: | Height: | Size: 111 B |
After Width: | Height: | Size: 79 B |
After Width: | Height: | Size: 169 B |
After Width: | Height: | Size: 169 B |
After Width: | Height: | Size: 113 B |
After Width: | Height: | Size: 117 B |
After Width: | Height: | Size: 114 B |
44
rse/plugins/org.eclipse.rse.files.ui/plugin.properties
Normal file
|
@ -0,0 +1,44 @@
|
|||
################################################################################
|
||||
# Copyright (c) 2006 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, Kushal Munir,
|
||||
# Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
#
|
||||
# Contributors:
|
||||
# {Name} (company) - description of contribution.
|
||||
################################################################################
|
||||
|
||||
plugin.name = RSE Files UI
|
||||
|
||||
PreferencePage.UniversalFiles = Files
|
||||
PreferencePage.Cache = File Cache
|
||||
|
||||
|
||||
RemotePropertyPage.File.Info = Info
|
||||
PropertyPage.EnvVariables = Environment Variables
|
||||
|
||||
PropertyPage.ServerLauncherSettings = Server Launcher Settings
|
||||
PropertyPage.ServerConnectionSecurity = Server Connection Security
|
||||
PropertyPage.Service = Service
|
||||
|
||||
# Decorators
|
||||
LinkDecorator.label=Link Decorator
|
||||
LibraryDecorator.label=Library Decorator
|
||||
JavaExecutableDecorator.label=Java Executable Decorator
|
||||
BinaryExecutableDecorator.label=Binary Executable Decorator
|
||||
VirtualObjectDecorator.label=Virtual Object Decorator
|
||||
ScriptExecutableDecorator.label=Script Executable Decorator
|
||||
VirtualObjectDecorator.label=Virtual Object Decorator
|
||||
SubSystemErrorDecorator.label=SubSystem Error Decorator
|
||||
|
||||
|
||||
Search.Page = Remote Search
|
||||
searchMenu.label = Se&arch
|
||||
Remote.Search = &Remote...
|
||||
Remote.Search.tooltip = Opens Remote Search dialog page for text and file searching on remote systems
|
320
rse/plugins/org.eclipse.rse.files.ui/plugin.xml
Normal file
|
@ -0,0 +1,320 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (c) 2006 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, Kushal Munir,
|
||||
Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
|
||||
Contributors:
|
||||
{Name} (company) - description of contribution.
|
||||
-->
|
||||
<?eclipse version="3.0"?>
|
||||
<plugin>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.preferencePages">
|
||||
<page
|
||||
name="%PreferencePage.UniversalFiles"
|
||||
category="org.eclipse.rse.ui.preferences.RemoteSystemsPreferencePage"
|
||||
class="org.eclipse.rse.files.ui.propertypages.UniversalPreferencePage"
|
||||
id="org.eclipse.rse.files.ui.UniversalFilesPreferences">
|
||||
</page>
|
||||
|
||||
<page
|
||||
name="%PreferencePage.Cache"
|
||||
category="org.eclipse.rse.ui.preferences.RemoteSystemsPreferencePage"
|
||||
class="org.eclipse.rse.files.ui.propertypages.SystemCachePreferencePage"
|
||||
id="org.eclipse.rse.core.ui.preferences.SystemCachePreferencePage">
|
||||
</page>
|
||||
</extension>
|
||||
|
||||
|
||||
|
||||
<!-- ============================================ -->
|
||||
<!-- Define Remote Object Properties Pages -->
|
||||
<!-- ============================================ -->
|
||||
<extension
|
||||
point="org.eclipse.rse.ui.propertyPages">
|
||||
<page
|
||||
name="%RemotePropertyPage.File.Info"
|
||||
typecategoryfilter="files"
|
||||
class="org.eclipse.rse.files.ui.propertypages.SystemFilePropertyPage"
|
||||
id="org.eclipse.rse.files.PropertyPage">
|
||||
</page>
|
||||
</extension>
|
||||
|
||||
|
||||
|
||||
<!-- ============================================ -->
|
||||
<!-- Define Workbench Properties Pages -->
|
||||
<!-- ============================================ -->
|
||||
<extension
|
||||
point="org.eclipse.ui.propertyPages">
|
||||
<!--
|
||||
<page
|
||||
objectClass="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem"
|
||||
name="%PropertyPage.EnvVariables"
|
||||
class="org.eclipse.rse.core.ui.propertypages.EnvironmentVariablesPropertyPage"
|
||||
id="org.eclipse.rse.EnvironmentVariablesPropertyPage">
|
||||
<filter name="envVarPP" value="true"/>
|
||||
</page>
|
||||
-->
|
||||
<page
|
||||
objectClass="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem"
|
||||
name="%PropertyPage.ServerLauncherSettings"
|
||||
class="org.eclipse.rse.ui.propertypages.ServerLauncherPropertyPage"
|
||||
id="com.ibm.etools.universal.core.serverlauncher.PropertyPage">
|
||||
<filter name="serverLaunchPP" value="true"/>
|
||||
</page>
|
||||
|
||||
|
||||
<page
|
||||
objectClass="org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem"
|
||||
name="%PropertyPage.Service"
|
||||
class="org.eclipse.rse.files.ui.propertypages.FileServicesPropertyPage"
|
||||
id="org.eclipse.rse.files.ui.propertypages.FileServicesPropertyPage">
|
||||
</page>
|
||||
|
||||
</extension>
|
||||
|
||||
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Flag file types used by the RemoteSystemsConnection project for -->
|
||||
<!-- more intelligent team sync support -->
|
||||
<!-- ================================================================= -->
|
||||
<extension point="org.eclipse.team.core.fileTypes">
|
||||
<fileTypes extension="xmi" type="text"/>
|
||||
</extension>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Hide RemoteSystemsConnections and RemoteSystemsTempFiles -->
|
||||
<!-- in the Navigator view -->
|
||||
<!-- ================================================================= -->
|
||||
<extension
|
||||
point="org.eclipse.ui.ide.resourceFilters">
|
||||
<filter
|
||||
selected="true"
|
||||
pattern="RemoteSystemsConnections">
|
||||
</filter>
|
||||
<filter
|
||||
selected="true"
|
||||
pattern="RemoteSystemsTempFiles">
|
||||
</filter>
|
||||
</extension>
|
||||
|
||||
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Hide RemoteSystemsConnections and RemoteSystemsTempFiles -->
|
||||
<!-- in the JDT view -->
|
||||
<!-- ================================================================= -->
|
||||
<extension
|
||||
point="org.eclipse.jdt.ui.javaElementFilters">
|
||||
<filter
|
||||
targetId="org.eclipse.jdt.ui.PackageExplorer"
|
||||
name="%ViewFilter.RSEConnections"
|
||||
enabled="true"
|
||||
description=""
|
||||
pattern="RemoteSystemsConnections">
|
||||
</filter>
|
||||
<filter
|
||||
targetId="org.eclipse.jdt.ui.PackageExplorer"
|
||||
name="%ViewFilter.RSETempFiles"
|
||||
enabled="true"
|
||||
description=""
|
||||
pattern="RemoteSystemsTempFiles">
|
||||
</filter>
|
||||
</extension>
|
||||
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Add a search page for universal, i.e. Linux, Windows and Local == -->
|
||||
<!-- ================================================================= -->
|
||||
<extension
|
||||
point="org.eclipse.search.searchPages">
|
||||
<page
|
||||
tabPosition="0"
|
||||
label="%Search.Page"
|
||||
enabled="true"
|
||||
icon="icons/full/obj16/system_search.gif"
|
||||
class="org.eclipse.rse.files.ui.search.SystemSearchPage"
|
||||
sizeHint="250,160"
|
||||
id="org.eclipse.rse.core.search.searchPage">
|
||||
</page>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.actionSets">
|
||||
<actionSet
|
||||
label="%Remote.Search"
|
||||
visible="true"
|
||||
id="org.eclipse.rse.core.search.searchActionSet">
|
||||
<menu
|
||||
label="%searchMenu.label"
|
||||
path="navigate"
|
||||
id="org.eclipse.search.menu">
|
||||
<groupMarker
|
||||
name="internalDialogGroup">
|
||||
</groupMarker>
|
||||
<groupMarker
|
||||
name="dialogGroup">
|
||||
</groupMarker>
|
||||
<separator
|
||||
name="contextMenuActionsGroup">
|
||||
</separator>
|
||||
</menu>
|
||||
<action
|
||||
label="%Remote.Search"
|
||||
tooltip="%Remote.Search.tooltip"
|
||||
helpContextId="org.eclipse.rse.core.rsac0000"
|
||||
icon="icons/full/obj16/system_search.gif"
|
||||
class="org.eclipse.rse.files.ui.search.SystemOpenSearchPageAction"
|
||||
menubarPath="org.eclipse.search.menu/dialogGroup"
|
||||
id="org.eclipse.rse.core.search.searchAction">
|
||||
</action>
|
||||
</actionSet>
|
||||
</extension>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Add handlers for ZIP, TAR, and JAR archive files == -->
|
||||
<!-- ================================================================= -->
|
||||
<extension
|
||||
point="org.eclipse.rse.ui.archivehandlers">
|
||||
<archivehandler
|
||||
fileNameExtension="zip"
|
||||
name="SystemZipHandler"
|
||||
class="org.eclipse.rse.services.clientserver.archiveutils.SystemZipHandler"
|
||||
id="org.eclipse.rse.services.clientserver.archiveutils.systemziphandler">
|
||||
</archivehandler>
|
||||
<archivehandler
|
||||
fileNameExtension="jar"
|
||||
name="SystemJarHandler"
|
||||
class="org.eclipse.rse.services.clientserver.archiveutils.SystemJarHandler"
|
||||
id="org.eclipse.rse.services.clientserver.archiveutils.systemjarhandler">
|
||||
</archivehandler>
|
||||
<archivehandler
|
||||
fileNameExtension="tar"
|
||||
name="SystemTarHandler"
|
||||
class="org.eclipse.rse.services.clientserver.archiveutils.SystemTarHandler"
|
||||
id="org.eclipse.rse.services.clientserver.archiveutils.systemtarhandler">
|
||||
</archivehandler>
|
||||
</extension>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Add default mount path mapper == -->
|
||||
<!-- ================================================================= -->
|
||||
<extension
|
||||
point="org.eclipse.rse.ui.mountPathMappers">
|
||||
<mountPathMapper
|
||||
name="DefaultMountPathMapper"
|
||||
class="org.eclipse.rse.files.ui.resources.DefaultMountPathMapper"
|
||||
id="org.eclipse.rse.core.resources.defaultmountpathmapper">
|
||||
</mountPathMapper>
|
||||
</extension>
|
||||
|
||||
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Add decorator for virtual, executable and link files -->
|
||||
<!-- ================================================================= -->
|
||||
<extension point="org.eclipse.ui.decorators">
|
||||
<decorator
|
||||
id="org.eclipse.rse.core.virtualobject.decorator"
|
||||
label="%VirtualObjectDecorator.label"
|
||||
state="true"
|
||||
lightweight="true"
|
||||
icon="icons/full/ovr16/virtual_tsk.gif"
|
||||
location="BOTTOM_RIGHT">
|
||||
<enablement>
|
||||
<and>
|
||||
<objectClass name="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"/>
|
||||
<objectState name="isVirtual" value="true"/>
|
||||
</and>
|
||||
</enablement>
|
||||
</decorator>
|
||||
<decorator
|
||||
id="org.eclipse.rse.core.binary.executable.decorator"
|
||||
label="%BinaryExecutableDecorator.label"
|
||||
state="true"
|
||||
lightweight="true"
|
||||
icon="icons/full/ovr16/exec_binary_ovr.gif"
|
||||
location="BOTTOM_LEFT">
|
||||
<enablement>
|
||||
<and>
|
||||
<objectClass name="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"/>
|
||||
<objectState name="classification" value="*executable(binary)*"/>
|
||||
</and>
|
||||
</enablement>
|
||||
</decorator>
|
||||
<decorator
|
||||
id="org.eclipse.rse.core.script.executable.decorator"
|
||||
label="%ScriptExecutableDecorator.label"
|
||||
state="true"
|
||||
lightweight="true"
|
||||
icon="icons/full/ovr16/exscript_ovr.gif"
|
||||
location="BOTTOM_LEFT">
|
||||
<enablement>
|
||||
<and>
|
||||
<objectClass name="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"/>
|
||||
<or>
|
||||
<objectState name="classification" value="*executable(script)*"/>
|
||||
<objectState name="classification" value="script"/>
|
||||
<objectState name="classification" value="symbolic link(script)*"/>
|
||||
</or>
|
||||
</and>
|
||||
</enablement>
|
||||
</decorator>
|
||||
<decorator
|
||||
id="org.eclipse.rse.core.java.executable.decorator"
|
||||
label="%JavaExecutableDecorator.label"
|
||||
state="true"
|
||||
lightweight="true"
|
||||
icon="icons/full/ovr16/exec_ovr.gif"
|
||||
location="BOTTOM_LEFT">
|
||||
<enablement>
|
||||
<and>
|
||||
<objectClass name="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"/>
|
||||
<objectState name="classification" value="*executable(java:*)*"/>
|
||||
</and>
|
||||
</enablement>
|
||||
</decorator>
|
||||
<decorator
|
||||
id="org.eclipse.rse.core.library.decorator"
|
||||
label="%LibraryDecorator.label"
|
||||
state="true"
|
||||
lightweight="true"
|
||||
icon="icons/full/ovr16/sharedlib_ovr.gif"
|
||||
location="BOTTOM_LEFT">
|
||||
<enablement>
|
||||
<and>
|
||||
<objectClass name="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"/>
|
||||
<objectState name="classification" value="*module*"/>
|
||||
</and>
|
||||
</enablement>
|
||||
</decorator>
|
||||
<decorator
|
||||
id="org.eclipse.rse.core.link.decorator"
|
||||
label="%LinkDecorator.label"
|
||||
state="true"
|
||||
lightweight="true"
|
||||
icon="icons/full/ovr16/symblclnk_ovr.gif"
|
||||
location="TOP_LEFT">
|
||||
<enablement>
|
||||
<and>
|
||||
<objectClass name="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"/>
|
||||
<objectState name="classification" value="symbolic link*"/>
|
||||
</and>
|
||||
</enablement>
|
||||
</decorator>
|
||||
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui;
|
||||
|
||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.runtime.IAdapterManager;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.files.ui.resources.SystemRemoteEditManager;
|
||||
import org.eclipse.rse.files.ui.resources.SystemUniversalTempFileListener;
|
||||
import org.eclipse.rse.files.ui.view.RemoteFileSubsystemFactoryAdapterFactory;
|
||||
import org.eclipse.rse.files.ui.view.SystemViewFileAdapterFactory;
|
||||
import org.eclipse.rse.files.ui.view.SystemViewSearchResultAdapterFactory;
|
||||
import org.eclipse.rse.files.ui.view.SystemViewSearchResultSetAdapterFactory;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
|
||||
/**
|
||||
* The main plugin class to be used in the desktop.
|
||||
*/
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
//The shared instance.
|
||||
private static Activator plugin;
|
||||
|
||||
private static SystemUniversalTempFileListener _tempFileListener;
|
||||
|
||||
private SystemViewFileAdapterFactory svfaf; // for fastpath
|
||||
private SystemViewSearchResultSetAdapterFactory svsaf; // for fastpath
|
||||
private SystemViewSearchResultAdapterFactory svsraf; // for fastpath
|
||||
|
||||
/**
|
||||
* The constructor.
|
||||
*/
|
||||
public Activator() {
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called upon plug-in activation
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
|
||||
// refresh the remote edit project at plugin startup, to ensure
|
||||
// it's never closed
|
||||
SystemRemoteEditManager.getDefault().refreshRemoteEditProject();
|
||||
|
||||
|
||||
int eventMask = IResourceChangeEvent.POST_CHANGE;
|
||||
IWorkspace ws = SystemBasePlugin.getWorkspace();
|
||||
|
||||
|
||||
|
||||
|
||||
IAdapterManager manager = Platform.getAdapterManager();
|
||||
|
||||
svfaf = new SystemViewFileAdapterFactory();
|
||||
svfaf.registerWithManager(manager);
|
||||
|
||||
|
||||
|
||||
svsaf = new SystemViewSearchResultSetAdapterFactory();
|
||||
svsaf.registerWithManager(manager);
|
||||
|
||||
svsraf = new SystemViewSearchResultAdapterFactory();
|
||||
svsraf.registerWithManager(manager);
|
||||
|
||||
RemoteFileSubsystemFactoryAdapterFactory rfssfaf = new RemoteFileSubsystemFactoryAdapterFactory();
|
||||
rfssfaf.registerWithManager(manager);
|
||||
|
||||
// universal temp file listener
|
||||
_tempFileListener = SystemUniversalTempFileListener.getListener();
|
||||
// add listener for temp files
|
||||
ws.addResourceChangeListener(_tempFileListener, eventMask);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when the plug-in is stopped
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception
|
||||
{
|
||||
super.stop(context);
|
||||
|
||||
IWorkspace ws = SystemBasePlugin.getWorkspace();
|
||||
ws.removeResourceChangeListener(_tempFileListener);
|
||||
_tempFileListener = null;
|
||||
plugin = null;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shared instance.
|
||||
*/
|
||||
public static Activator getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an image descriptor for the image file at the given
|
||||
* plug-in relative path.
|
||||
*
|
||||
* @param path the path
|
||||
* @return the image descriptor
|
||||
*/
|
||||
public static ImageDescriptor getImageDescriptor(String path) {
|
||||
return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.rse.files.ui", path);
|
||||
}
|
||||
|
||||
/**
|
||||
* For pathpath access to our adapters for remote universal file objects. Exploits the knowledge we use singleton adapters.
|
||||
*/
|
||||
public SystemViewFileAdapterFactory getSystemViewFileAdapterFactory()
|
||||
{
|
||||
return svfaf;
|
||||
}
|
||||
|
||||
/**
|
||||
* For pathpath access to our adapters for searchable result output objects. Exploits the knowledge we use singleton adapters.
|
||||
*/
|
||||
public SystemViewSearchResultSetAdapterFactory getSystemViewSearchResultSetAdapterFactory()
|
||||
{
|
||||
return svsaf;
|
||||
}
|
||||
|
||||
/**
|
||||
* For pathpath access to our adapters for searchable result output objects. Exploits the knowledge we use singleton adapters.
|
||||
*/
|
||||
public SystemViewSearchResultAdapterFactory getSystemViewSearchResultAdapterFactory()
|
||||
{
|
||||
return svsraf;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,291 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class FileResources extends NLS
|
||||
{
|
||||
private static String BUNDLE_NAME = "org.eclipse.rse.files.ui.FileResources";
|
||||
|
||||
public static String RESID_FILES_PREFERENCES_BUFFER;
|
||||
public static String RESID_FILES_PREFERENCES_DOWNLOAD_BUFFER_SIZE_LABEL;
|
||||
public static String RESID_FILES_PREFERENCES_UPLOAD_BUFFER_SIZE_LABEL;
|
||||
public static String RESID_FILES_PREFERENCES_DOWNLOAD_BUFFER_SIZE_TOOLTIP;
|
||||
public static String RESID_FILES_PREFERENCES_UPLOAD_BUFFER_SIZE_TOOLTIP;
|
||||
|
||||
public static String ResourceNavigator_openWith;
|
||||
public static String RSEOperation_message;
|
||||
|
||||
// --- File Editors ---
|
||||
public static String FileEditorPreference_fileTypes;
|
||||
public static String FileEditorPreference_add;
|
||||
public static String FileEditorPreference_remove;
|
||||
public static String FileEditorPreference_associatedEditors;
|
||||
public static String FileEditorPreference_addEditor;
|
||||
public static String FileEditorPreference_removeEditor;
|
||||
public static String FileEditorPreference_default;
|
||||
public static String FileEditorPreference_existsTitle;
|
||||
public static String FileEditorPreference_existsMessage;
|
||||
public static String FileEditorPreference_defaultLabel;
|
||||
public static String FileEditorPreference_contentTypesRelatedLink;
|
||||
public static String FileEditorPreference_isLocked;
|
||||
|
||||
public static String FileExtension_fileTypeMessage;
|
||||
public static String FileExtension_fileTypeLabel;
|
||||
public static String FileExtension_shellTitle;
|
||||
public static String FileExtension_dialogTitle;
|
||||
|
||||
public static String DefaultEditorDescription_name;
|
||||
|
||||
// EXTRACT ARCHIVE TO DIALOG...
|
||||
public static String RESID_EXTRACTTO_TITLE;
|
||||
public static String RESID_EXTRACTTO_PROMPT;
|
||||
|
||||
// COMBINE ARCHIVES DIALOG...
|
||||
public static String RESID_COMBINE_TITLE;
|
||||
public static String RESID_COMBINE_PROMPT;
|
||||
public static String RESID_COMBINE_NAME_LABEL;
|
||||
public static String RESID_COMBINE_NAME_TOOLTIP;
|
||||
public static String RESID_COMBINE_TYPE_LABEL;
|
||||
public static String RESID_COMBINE_TYPE_TOOLTIP;
|
||||
|
||||
// CONVERT ARCHIVE DIALOG...
|
||||
public static String RESID_CONVERT_TITLE;
|
||||
public static String RESID_CONVERT_PROMPT;
|
||||
public static String RESID_CONVERT_LOCATION;
|
||||
public static String RESID_CONVERT_NAMEANDTYPE;
|
||||
|
||||
// ADD TO ARCHIVE DIALOG...
|
||||
public static String RESID_ADDTOARCHIVE_TITLE;
|
||||
public static String RESID_ADDTOARCHIVE_PROMPT;
|
||||
public static String RESID_ADDTOARCHIVE_LOCATION;
|
||||
public static String RESID_ADDTOARCHIVE_NAMEANDTYPE;
|
||||
public static String RESID_ADDTOARCHIVE_SAVEPATH_LABEL;
|
||||
public static String RESID_ADDTOARCHIVE_SAVEPATH_TOOLTIP;
|
||||
public static String RESID_ADDTOARCHIVE_RELATIVETO_LABEL;
|
||||
public static String RESID_ADDTOARCHIVE_RELATIVETO_TOOLTIP;
|
||||
|
||||
// NEW FILE WIZARD...
|
||||
public static String RESID_NEWFILE_TITLE;
|
||||
public static String RESID_NEWFILE_PAGE1_TITLE;
|
||||
public static String RESID_NEWFILE_PAGE1_DESCRIPTION;
|
||||
public static String RESID_NEWFILE_NAME_LABEL;
|
||||
public static String RESID_NEWFILE_NAME_TOOLTIP;
|
||||
public static String RESID_NEWFILE_FOLDER_LABEL;
|
||||
public static String RESID_NEWFILE_FOLDER_TIP;
|
||||
public static String RESID_NEWFILE_CONNECTIONNAME_LABEL;
|
||||
public static String RESID_NEWFILE_CONNECTIONNAME_TIP;
|
||||
|
||||
// NEW FOLDER WIZARD...
|
||||
public static String RESID_NEWFOLDER_TITLE;
|
||||
public static String RESID_NEWFOLDER_PAGE1_TITLE;
|
||||
public static String RESID_NEWFOLDER_PAGE1_DESCRIPTION;
|
||||
public static String RESID_NEWFOLDER_NAME_LABEL;
|
||||
public static String RESID_NEWFOLDER_NAME_TOOLTIP;
|
||||
public static String RESID_NEWFOLDER_FOLDER_LABEL;
|
||||
public static String RESID_NEWFOLDER_FOLDER_TIP;
|
||||
public static String RESID_NEWFOLDER_CONNECTIONNAME_LABEL;
|
||||
public static String RESID_NEWFOLDER_CONNECTIONNAME_TIP;
|
||||
|
||||
// ---------------------------------------------------
|
||||
// PREFERENCES FOR UNIVERSAL FILE SYSTEM ...
|
||||
// ---------------------------------------------------
|
||||
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_TITLE;
|
||||
public static String RESID_PREF_UNIVERSAL_SHOWHIDDEN_LABEL;
|
||||
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_TYPE_LABEL;
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_TYPE_TOOLTIP;
|
||||
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_LABEL;
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_TOOLTIP;
|
||||
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_ADDBUTTON_LABEL;
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_ADDBUTTON_TOOLTIP;
|
||||
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_REMOVEBUTTON_LABEL;
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_REMOVEBUTTON_TOOLTIP;
|
||||
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_LABEL;
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TOOLTIP;
|
||||
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL;
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_TOOLTIP;
|
||||
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL;
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_TOOLTIP;
|
||||
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_LABEL;
|
||||
public static String RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_TOOLTIP;
|
||||
|
||||
// Search constants
|
||||
// Search dialog constants
|
||||
// search string controls
|
||||
public static String RESID_SEARCH_STRING_LABEL_LABEL;
|
||||
public static String RESID_SEARCH_STRING_LABEL_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_STRING_COMBO_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_CASE_BUTTON_LABEL;
|
||||
public static String RESID_SEARCH_CASE_BUTTON_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_STRING_HINT_LABEL;
|
||||
public static String RESID_SEARCH_STRING_HINT_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_STRING_REGEX_LABEL;
|
||||
public static String RESID_SEARCH_STRING_REGEX_TOOLTIP;
|
||||
|
||||
// file name controls
|
||||
public static String RESID_SEARCH_FILENAME_LABEL_LABEL;
|
||||
public static String RESID_SEARCH_FILENAME_LABEL_TOOLTIP;
|
||||
public static String RESID_SEARCH_FILENAME_COMBO_TOOLTIP;
|
||||
public static String RESID_SEARCH_FILENAME_BROWSE_LABEL;
|
||||
public static String RESID_SEARCH_FILENAME_BROWSE_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_FILENAME_HINT_LABEL;
|
||||
public static String RESID_SEARCH_FILENAME_HINT_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_FILENAME_REGEX_LABEL;
|
||||
public static String RESID_SEARCH_FILENAME_REGEX_TOOLTIP;
|
||||
|
||||
// folder name controls
|
||||
public static String RESID_SEARCH_FOLDERNAME_LABEL_LABEL;
|
||||
public static String RESID_SEARCH_FOLDERNAME_LABEL_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_FOLDERNAME_COMBO_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_FOLDERNAME_BROWSE_LABEL;
|
||||
public static String RESID_SEARCH_FOLDERNAME_BROWSE_TOOLTIP;
|
||||
|
||||
// advanced search controls
|
||||
public static String RESID_SEARCH_INCLUDE_ARCHIVES_LABEL;
|
||||
public static String RESID_SEARCH_INCLUDE_ARCHIVES_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_INCLUDE_SUBFOLDERS_LABEL;
|
||||
public static String RESID_SEARCH_INCLUDE_SUBFOLDERS_TOOLTIP;
|
||||
|
||||
// advanced search filters
|
||||
public static String RESID_SEARCH_CONNECTIONNAMELABEL_LABEL;
|
||||
public static String RESID_SEARCH_CONNECTIONNAMELABEL_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_TARGETGROUP_LABEL;
|
||||
public static String RESID_SEARCH_TARGETGROUP_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_COLUMNSGROUP_LABEL;
|
||||
public static String RESID_SEARCH_COLUMNSGROUP_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_ALLCOLUMNSLABEL_LABEL;
|
||||
public static String RESID_SEARCH_ALLCOLUMNSLABEL_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_BETWEENLABEL_LABEL;
|
||||
public static String RESID_SEARCH_ANDLABEL_LABEL;
|
||||
public static String RESID_SEARCH_EOLLABEL_LABEL;
|
||||
public static String RESID_SEARCH_FIRSTCOLUMN_TOOLTIP;
|
||||
public static String RESID_SEARCH_SECONDCOLUMN_TOOLTIP;
|
||||
public static String RESID_SEARCH_BOTHCOLUMNSLABEL_TOOLTIP;
|
||||
public static String RESID_SEARCH_STARTCOLUMNLABEL_TOOLTIP;
|
||||
|
||||
public static String RESID_SEARCH_MESSAGE_SEARCHING;
|
||||
public static String RESID_SEARCH_MESSAGE_ONEMATCH;
|
||||
public static String RESID_SEARCH_MESSAGE_MULTIPLEMATCHES;
|
||||
|
||||
// Resource conflict dlg constants
|
||||
public static String RESID_CONFLICT_SAVE_TITLE;
|
||||
public static String RESID_CONFLICT_SAVE_MESSAGE;
|
||||
public static String RESID_CONFLICT_SAVE_OVERWRITEREMOTE;
|
||||
public static String RESID_CONFLICT_SAVE_REPLACELOCAL;
|
||||
public static String RESID_CONFLICT_SAVE_SAVETODIFFERENT;
|
||||
|
||||
public static String RESID_CONFLICT_DOWNLOAD_TITLE;
|
||||
public static String RESID_CONFLICT_DOWNLOAD_MESSAGE_LOCALCHANGED;
|
||||
public static String RESID_CONFLICT_DOWNLOAD_MESSAGE_REMOTECHANGED;
|
||||
public static String RESID_CONFLICT_DOWNLOAD_REPLACELOCAL;
|
||||
public static String RESID_CONFLICT_DOWNLOAD_OPENWITHLOCAL;
|
||||
|
||||
// RSE Cache Preferences
|
||||
public static String RESID_PREF_CACHE_DESCRIPTION;
|
||||
public static String RESID_PREF_CACHE_CLEAR;
|
||||
public static String RESID_PREF_CACHE_CLEAR_LABEL;
|
||||
public static String RESID_PREF_CACHE_CLEAR_TOOLTIP;
|
||||
public static String RESID_PREF_CACHE_MAX_CACHE_SIZE_LABEL;
|
||||
public static String RESID_PREF_CACHE_MAX_CACHE_SIZE_DESCRIPTION;
|
||||
public static String RESID_PREF_CACHE_MAX_CACHE_SIZE_TOOLTIP;
|
||||
public static String RESID_PREF_CACHE_CLEAR_WARNING_LABEL;
|
||||
public static String RESID_PREF_CACHE_CLEAR_WARNING_DESCRIPTION;
|
||||
|
||||
// SUPERTRANSFER PROGRESS MONITOR CONSTANTS
|
||||
public static String RESID_SUPERTRANSFER_PROGMON_MAIN;
|
||||
public static String RESID_SUPERTRANSFER_PROGMON_SUBTASK_CREATE;
|
||||
public static String RESID_SUPERTRANSFER_PROGMON_SUBTASK_POPULATE;
|
||||
|
||||
public static String RESID_SUPERTRANSFER_PROGMON_SUBTASK_TRANSFER;
|
||||
public static String RESID_SUPERTRANSFER_PROGMON_SUBTASK_EXTRACT;
|
||||
public static String RESID_SUPERTRANSFER_PROGMON_ARCHIVE;
|
||||
|
||||
// SUPERTRANSFER PREFERENCES PAGE CONSTANTS
|
||||
public static String RESID_SUPERTRANSFER_PREFS_ENABLE;
|
||||
public static String RESID_SUPERTRANSFER_PREFS_TYPE_LABEL;
|
||||
public static String RESID_SUPERTRANSFER_PREFS_TYPE_TOOLTIP;
|
||||
|
||||
// Compare with menu item
|
||||
public static String ACTION_COMPAREWITH_EACH_LABEL;
|
||||
public static String ACTION_COMPAREWITH_EACH_TOOLTIP;
|
||||
|
||||
public static String ACTION_COMPAREWITH_HISTORY_LABEL;
|
||||
public static String ACTION_COMPAREWITH_HISTORY_TOOLTIP;
|
||||
|
||||
// Replace with menu item
|
||||
public static String ACTION_REPLACEWITH_HISTORY_LABEL;
|
||||
public static String ACTION_REPLACEWITH_HISTORY_TOOLTIP;
|
||||
|
||||
// Archive Menu Items
|
||||
public static String ACTION_EXTRACT_LABEL;
|
||||
public static String ACTION_EXTRACT_SUB_LABEL;
|
||||
public static String ACTION_EXTRACT_TOOLTIP;
|
||||
public static String ACTION_EXTRACT_TO_LABEL;
|
||||
public static String ACTION_EXTRACT_TO_TOOLTIP;
|
||||
|
||||
public static String ACTION_COMBINE_LABEL;
|
||||
public static String ACTION_COMBINE_TOOLTIP;
|
||||
|
||||
public static String ACTION_CONVERT_LABEL;
|
||||
public static String ACTION_CONVERT_TOOLTIP;
|
||||
|
||||
public static String ACTION_ADDTOARCHIVE_LABEL;
|
||||
public static String ACTION_ADDTOARCHIVE_TOOLTIP;
|
||||
|
||||
// Project menu item
|
||||
public static String RESID_OPEN_FROM_ASSOCIATED_PROJECT;
|
||||
|
||||
// Other Actions
|
||||
public static String ACTION_NEWFOLDER_LABEL;
|
||||
public static String ACTION_NEWFOLDER_TOOLTIP;
|
||||
|
||||
public static String ACTION_SELECT_DIRECTORY_LABEL;
|
||||
public static String ACTION_SELECT_DIRECTORY_TOOLTIP;
|
||||
|
||||
public static String ACTION_SELECT_FILE_LABEL;
|
||||
public static String ACTION_SELECT_FILE_TOOLTIP;
|
||||
|
||||
static
|
||||
{
|
||||
// load message values from bundle file
|
||||
NLS.initializeMessages(BUNDLE_NAME, FileResources.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,282 @@
|
|||
################################################################################
|
||||
# Copyright (c) 2006 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, Kushal Munir,
|
||||
# Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
#
|
||||
# Contributors:
|
||||
# {Name} (company) - description of contribution.
|
||||
################################################################################
|
||||
|
||||
# NLS_MESSAGEFORMAT_NONE
|
||||
|
||||
RESID_FILES_PREFERENCES_BUFFER=File Transfer Buffer Size
|
||||
RESID_FILES_PREFERENCES_DOWNLOAD_BUFFER_SIZE_LABEL=Download (KB)
|
||||
RESID_FILES_PREFERENCES_UPLOAD_BUFFER_SIZE_LABEL=Upload (KB)
|
||||
RESID_FILES_PREFERENCES_DOWNLOAD_BUFFER_SIZE_TOOLTIP=Maximum size of buffer to use while sending files from the host to the client
|
||||
RESID_FILES_PREFERENCES_UPLOAD_BUFFER_SIZE_TOOLTIP=Maximum size of the buffer to use while sending files from the client to the host
|
||||
|
||||
ResourceNavigator_openWith = Open Wit&h
|
||||
RSEOperation_message = Remote Systems Explorer Operation
|
||||
|
||||
# --- File Editors ---
|
||||
FileEditorPreference_fileTypes = File &types:
|
||||
FileEditorPreference_add = &Add...
|
||||
FileEditorPreference_remove = &Remove
|
||||
FileEditorPreference_associatedEditors = Associated &editors:
|
||||
FileEditorPreference_addEditor = A&dd...
|
||||
FileEditorPreference_removeEditor = Re&move
|
||||
FileEditorPreference_default = De&fault
|
||||
FileEditorPreference_existsTitle = File Type Exists
|
||||
FileEditorPreference_existsMessage = An entry already exists for that file type
|
||||
FileEditorPreference_defaultLabel = (default)
|
||||
FileEditorPreference_contentTypesRelatedLink = See <a>''{0}''</a> for content-type based file associations.
|
||||
FileEditorPreference_isLocked = {0} (locked by ''{1}'' content type)
|
||||
|
||||
FileExtension_fileTypeMessage = Enter file type to add: (*.doc or report.doc for example)
|
||||
FileExtension_fileTypeLabel = File &type:
|
||||
FileExtension_shellTitle = New File Type
|
||||
FileExtension_dialogTitle = Define a New File Type
|
||||
|
||||
DefaultEditorDescription_name = &Default Editor
|
||||
|
||||
#=============================================================
|
||||
# NEW FILE WIZARD...
|
||||
#=============================================================
|
||||
RESID_NEWFILE_TITLE=New File
|
||||
RESID_NEWFILE_PAGE1_TITLE=Remote File
|
||||
RESID_NEWFILE_PAGE1_DESCRIPTION=Create a New File
|
||||
RESID_NEWFILE_FOLDER_LABEL=Folder name
|
||||
RESID_NEWFILE_FOLDER_TIP=Folder in which the new file will be created
|
||||
RESID_NEWFILE_CONNECTIONNAME_LABEL=Connection name
|
||||
RESID_NEWFILE_CONNECTIONNAME_TIP=Connection name where the new file will be created
|
||||
RESID_NEWFILE_NAME_LABEL=File name
|
||||
RESID_NEWFILE_NAME_TOOLTIP=Enter a file name for the new file
|
||||
|
||||
#=============================================================
|
||||
# NEW FOLDER WIZARD...
|
||||
#=============================================================
|
||||
RESID_NEWFOLDER_TITLE=New Folder
|
||||
RESID_NEWFOLDER_PAGE1_TITLE=Remote Folder
|
||||
RESID_NEWFOLDER_PAGE1_DESCRIPTION=Create a New Folder
|
||||
RESID_NEWFOLDER_CONNECTIONNAME_LABEL=Connection name
|
||||
RESID_NEWFOLDER_CONNECTIONNAME_TIP=Connection name where the new folder will be created
|
||||
RESID_NEWFOLDER_NAME_LABEL=Folder name
|
||||
RESID_NEWFOLDER_NAME_TOOLTIP=Enter a folder name for the new folder
|
||||
RESID_NEWFOLDER_FOLDER_LABEL=Folder name
|
||||
RESID_NEWFOLDER_FOLDER_TIP=Folder in which the new folder will be created
|
||||
|
||||
##############################################################
|
||||
# Preference pages for universal file system
|
||||
##############################################################
|
||||
RESID_PREF_UNIVERSAL_FILES_TITLE=File System Preferences
|
||||
RESID_PREF_UNIVERSAL_SHOWHIDDEN_LABEL=Show hidden files
|
||||
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_TYPE_LABEL=File types:
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_TYPE_TOOLTIP=List of file types
|
||||
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_LABEL=Type
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_TOOLTIP=Type
|
||||
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_ADDBUTTON_LABEL=Add...
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_ADDBUTTON_TOOLTIP=Add a file type
|
||||
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_REMOVEBUTTON_LABEL=Remove
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_REMOVEBUTTON_TOOLTIP=Remove selected file type
|
||||
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_LABEL=File Transfer Mode
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TOOLTIP=Mode of file transfer for selected file type
|
||||
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL=Binary
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_TOOLTIP=Transfer as binary file
|
||||
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL=Text
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_TOOLTIP=Transfer as text file
|
||||
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_LABEL=Default File Transfer Mode
|
||||
RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_TOOLTIP=Default mode of file transfer for unspecified file types
|
||||
|
||||
###################################################################################
|
||||
############################ Remote Search ##############################
|
||||
###################################################################################
|
||||
RESID_SEARCH_STRING_LABEL_LABEL= Search string (leave empty for file search):
|
||||
RESID_SEARCH_STRING_LABEL_TOOLTIP= String to be searched
|
||||
RESID_SEARCH_STRING_COMBO_TOOLTIP= Enter or select search string
|
||||
RESID_SEARCH_CASE_BUTTON_LABEL= Case sensitive
|
||||
RESID_SEARCH_CASE_BUTTON_TOOLTIP= Specify whether case should be considered during search
|
||||
RESID_SEARCH_STRING_HINT_LABEL= (* = any string, ? = any character, \\ = escape for literals: * ? \\)
|
||||
RESID_SEARCH_STRING_HINT_TOOLTIP= Special characters allowed in search string
|
||||
RESID_SEARCH_STRING_REGEX_LABEL= Regular expression
|
||||
RESID_SEARCH_STRING_REGEX_TOOLTIP= Specify whether search string is a regular expression
|
||||
RESID_SEARCH_FILENAME_LABEL_LABEL= File name patterns:
|
||||
RESID_SEARCH_FILENAME_LABEL_TOOLTIP= File name patterns
|
||||
RESID_SEARCH_FILENAME_COMBO_TOOLTIP= Enter or select file name patterns
|
||||
RESID_SEARCH_FILENAME_BROWSE_LABEL= Browse...
|
||||
RESID_SEARCH_FILENAME_BROWSE_TOOLTIP= Opens a dialog to select or enter file types
|
||||
RESID_SEARCH_FILENAME_HINT_LABEL= Patterns are separated by comma (* = any string, ? = any character)
|
||||
RESID_SEARCH_FILENAME_HINT_TOOLTIP= Special characters allowed in file name patterns
|
||||
RESID_SEARCH_FILENAME_REGEX_LABEL= Regular expression
|
||||
RESID_SEARCH_FILENAME_REGEX_TOOLTIP= Specify whether file name pattern is a regular expression
|
||||
RESID_SEARCH_FOLDERNAME_LABEL_LABEL= Folder:
|
||||
RESID_SEARCH_FOLDERNAME_LABEL_TOOLTIP= Folder path
|
||||
RESID_SEARCH_FOLDERNAME_COMBO_TOOLTIP= Identifies the folder in which to search. It is fully qualified including the connection name, as in connection:/path/folder
|
||||
RESID_SEARCH_FOLDERNAME_BROWSE_LABEL= Browse...
|
||||
RESID_SEARCH_FOLDERNAME_BROWSE_TOOLTIP= Opens a dialog to select a folder
|
||||
RESID_SEARCH_INCLUDE_ARCHIVES_LABEL= Search archive files
|
||||
RESID_SEARCH_INCLUDE_ARCHIVES_TOOLTIP= Specify whether archive files such as zip, jar and tar files should also be searched
|
||||
RESID_SEARCH_INCLUDE_SUBFOLDERS_LABEL= Search subfolders
|
||||
RESID_SEARCH_INCLUDE_SUBFOLDERS_TOOLTIP= Specify whether subfolders should also be searched
|
||||
RESID_SEARCH_CONNECTIONNAMELABEL_LABEL= Connection name:
|
||||
RESID_SEARCH_CONNECTIONNAMELABEL_TOOLTIP= Connection name
|
||||
RESID_SEARCH_TARGETGROUP_LABEL= Target
|
||||
RESID_SEARCH_TARGETGROUP_TOOLTIP= Specify search target
|
||||
RESID_SEARCH_COLUMNSGROUP_LABEL= Columns
|
||||
RESID_SEARCH_COLUMNSGROUP_TOOLTIP= Specify columns
|
||||
RESID_SEARCH_ALLCOLUMNSLABEL_LABEL= All columns
|
||||
RESID_SEARCH_ALLCOLUMNSLABEL_TOOLTIP= Search all columns
|
||||
RESID_SEARCH_BETWEENLABEL_LABEL= Between
|
||||
RESID_SEARCH_ANDLABEL_LABEL= and
|
||||
RESID_SEARCH_EOLLABEL_LABEL= and end of line
|
||||
RESID_SEARCH_FIRSTCOLUMN_TOOLTIP= Specify start column
|
||||
RESID_SEARCH_SECONDCOLUMN_TOOLTIP= Specify end column
|
||||
RESID_SEARCH_BOTHCOLUMNSLABEL_TOOLTIP= Search between specified columns
|
||||
RESID_SEARCH_STARTCOLUMNLABEL_TOOLTIP= Search between specified column and end of line
|
||||
|
||||
# Search dialog
|
||||
RESID_SEARCH_MESSAGE_SEARCHING= Searching...
|
||||
RESID_SEARCH_MESSAGE_ONEMATCH= %1 match
|
||||
RESID_SEARCH_MESSAGE_MULTIPLEMATCHES= %1 matches
|
||||
|
||||
##################################################################################
|
||||
############################ Resource Conflict Dlgs #########################
|
||||
##################################################################################
|
||||
RESID_CONFLICT_SAVE_TITLE= Save Conflict
|
||||
RESID_CONFLICT_SAVE_MESSAGE= This file has changed on the remote system since it was opened.
|
||||
RESID_CONFLICT_SAVE_OVERWRITEREMOTE= Overwrite the remote file.
|
||||
RESID_CONFLICT_SAVE_REPLACELOCAL= Replace contents of editor with remote file. Pending changes will be lost.
|
||||
RESID_CONFLICT_SAVE_SAVETODIFFERENT= Save the contents of the editor to a different remote file.
|
||||
|
||||
RESID_CONFLICT_DOWNLOAD_TITLE= Local Changes Pending
|
||||
RESID_CONFLICT_DOWNLOAD_MESSAGE_LOCALCHANGED= This file has pending changes that have not been saved to the remote system.
|
||||
RESID_CONFLICT_DOWNLOAD_MESSAGE_REMOTECHANGED= This file has pending changes that have not been saved to the remote system and the file has changed on the remote system.
|
||||
RESID_CONFLICT_DOWNLOAD_REPLACELOCAL= Replace pending changes with remote file
|
||||
RESID_CONFLICT_DOWNLOAD_OPENWITHLOCAL= Open editor with pending changes
|
||||
|
||||
#==============================================================
|
||||
# REMOTE FILE SYSTEM CACHE PREFERENCE PAGE
|
||||
#=============================================================
|
||||
RESID_PREF_CACHE_DESCRIPTION=When RSE is used for editing, the remote files are cached. Use this page to clear or limit the size of the file cache.
|
||||
RESID_PREF_CACHE_CLEAR=Clear
|
||||
RESID_PREF_CACHE_CLEAR_LABEL=Clear cached files
|
||||
RESID_PREF_CACHE_CLEAR_TOOLTIP=Delete remote files that have been cached in the local workspace
|
||||
RESID_PREF_CACHE_MAX_CACHE_SIZE_LABEL=Maximum cache size (MB)
|
||||
RESID_PREF_CACHE_MAX_CACHE_SIZE_DESCRIPTION=Enter the maxium size space that can be used by the cache
|
||||
RESID_PREF_CACHE_MAX_CACHE_SIZE_TOOLTIP=Enter the maxium size space that can be used by the cache
|
||||
RESID_PREF_CACHE_CLEAR_WARNING_LABEL=Note:
|
||||
RESID_PREF_CACHE_CLEAR_WARNING_DESCRIPTION=Clearing the cache closes all open remote files
|
||||
|
||||
#=============================================================
|
||||
# SUPERTRANSFER PROGRESS MONITOR
|
||||
#=============================================================
|
||||
RESID_SUPERTRANSFER_PROGMON_MAIN=Compressed copy...
|
||||
RESID_SUPERTRANSFER_PROGMON_SUBTASK_CREATE=Creating temp archive
|
||||
RESID_SUPERTRANSFER_PROGMON_SUBTASK_POPULATE=Populating temp archive
|
||||
RESID_SUPERTRANSFER_PROGMON_SUBTASK_TRANSFER=Transferring temp archive
|
||||
RESID_SUPERTRANSFER_PROGMON_SUBTASK_EXTRACT=Extracting temp archive
|
||||
RESID_SUPERTRANSFER_PROGMON_ARCHIVE=archive
|
||||
|
||||
#=============================================================
|
||||
# SUPERTRANSFER PREFERENCE PAGE
|
||||
#=============================================================
|
||||
RESID_SUPERTRANSFER_PREFS_ENABLE=Enable fast folder transfer using data compression
|
||||
RESID_SUPERTRANSFER_PREFS_TYPE_LABEL=Archive type
|
||||
RESID_SUPERTRANSFER_PREFS_TYPE_TOOLTIP=Select an archive type to use for the transfer
|
||||
|
||||
##################################################################################
|
||||
############################ Compare menu item #############################
|
||||
##################################################################################
|
||||
ACTION_COMPAREWITH_EACH_LABEL= Each Other
|
||||
ACTION_COMPAREWITH_EACH_TOOLTIP= Compare remote resources to each other
|
||||
ACTION_COMPAREWITH_HISTORY_LABEL= Local History...
|
||||
ACTION_COMPAREWITH_HISTORY_TOOLTIP= Compare the local edition history of this resource
|
||||
|
||||
##################################################################################
|
||||
############################ Replace menu item #############################
|
||||
##################################################################################
|
||||
ACTION_REPLACEWITH_HISTORY_LABEL= Local History...
|
||||
ACTION_REPLACEWITH_HISTORY_TOOLTIP= Replace the remote file with a previous edition from it's local history
|
||||
|
||||
##################################################################################
|
||||
############################ Archive menu items #############################
|
||||
##################################################################################
|
||||
ACTION_EXTRACT_LABEL=Extract
|
||||
ACTION_EXTRACT_SUB_LABEL=Extract to %1
|
||||
ACTION_EXTRACT_TOOLTIP=Extract archive to current directory
|
||||
ACTION_EXTRACT_TO_LABEL=Extract to...
|
||||
ACTION_EXTRACT_TO_TOOLTIP=Extract archive to a specified directory
|
||||
|
||||
ACTION_COMBINE_LABEL=Combine...
|
||||
ACTION_COMBINE_TOOLTIP=Combine archives into a single archive
|
||||
|
||||
ACTION_CONVERT_LABEL=Convert...
|
||||
ACTION_CONVERT_TOOLTIP=Convert archives into another archive type
|
||||
|
||||
ACTION_ADDTOARCHIVE_LABEL=Add To Archive...
|
||||
ACTION_ADDTOARCHIVE_TOOLTIP=Add files to a new or existing archive
|
||||
|
||||
##################################################################################
|
||||
############################ Project menu item #############################
|
||||
##################################################################################
|
||||
RESID_OPEN_FROM_ASSOCIATED_PROJECT=Open from Associated Project (&1)
|
||||
|
||||
#=============================================================
|
||||
# EXTRACT ARCHIVE TO DIALOG...
|
||||
#=============================================================
|
||||
RESID_EXTRACTTO_TITLE=Extract To
|
||||
RESID_EXTRACTTO_PROMPT=Choose the destination for the contents of archive &1
|
||||
|
||||
#=============================================================
|
||||
# COMBINE ARCHIVES DIALOG...
|
||||
#=============================================================
|
||||
RESID_COMBINE_TITLE=Combine Archives
|
||||
RESID_COMBINE_PROMPT=Choose the destination for the combined archives
|
||||
RESID_COMBINE_NAME_LABEL=Archive name
|
||||
RESID_COMBINE_NAME_TOOLTIP=Enter a file name for the combined/converted archive
|
||||
RESID_COMBINE_TYPE_LABEL=Archive type
|
||||
RESID_COMBINE_TYPE_TOOLTIP=Select an archive type for the combined/converted archive
|
||||
|
||||
#=============================================================
|
||||
# CONVERT ARCHIVE DIALOG...
|
||||
#=============================================================
|
||||
RESID_CONVERT_TITLE=Convert Archive
|
||||
RESID_CONVERT_PROMPT=Source archive: &1
|
||||
RESID_CONVERT_LOCATION=Select a destination folder for the converted copy of the archive:
|
||||
RESID_CONVERT_NAMEANDTYPE=Select a new name and type for the converted copy of the archive:
|
||||
|
||||
#=============================================================
|
||||
# ADD TO ARCHIVE DIALOG...
|
||||
#=============================================================
|
||||
RESID_ADDTOARCHIVE_TITLE=Add to Archive
|
||||
RESID_ADDTOARCHIVE_PROMPT=Choose a destination archive for the selected files, or create a new archive
|
||||
RESID_ADDTOARCHIVE_LOCATION=Select a destination folder for the new archive, or the location of an existing archive:
|
||||
RESID_ADDTOARCHIVE_NAMEANDTYPE=Select a name and type for the new archive, or enter an existing archive's name and type:
|
||||
RESID_ADDTOARCHIVE_SAVEPATH_LABEL=Save full path info
|
||||
RESID_ADDTOARCHIVE_SAVEPATH_TOOLTIP=Choose whether or not to preserve the full path of the selected files relative to each other when they are added to the archive.
|
||||
RESID_ADDTOARCHIVE_RELATIVETO_LABEL=Save full path info relative to:
|
||||
RESID_ADDTOARCHIVE_RELATIVETO_TOOLTIP=Choose the common directory from which relative paths will be determined.
|
||||
|
||||
#=============================================================
|
||||
# ACTIONS...
|
||||
#=============================================================
|
||||
ACTION_NEWFOLDER_LABEL=Folder
|
||||
ACTION_NEWFOLDER_TOOLTIP=Create a new Folder
|
||||
ACTION_SELECT_DIRECTORY_LABEL=Browse...
|
||||
ACTION_SELECT_DIRECTORY_TOOLTIP=Select folder from remote system
|
||||
ACTION_SELECT_FILE_LABEL=Browse...
|
||||
ACTION_SELECT_FILE_TOOLTIP=Select file from remote system
|
|
@ -0,0 +1,53 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui;
|
||||
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
|
||||
/**
|
||||
* This is an interface used by the actions SystemSelectRemoteFileAction and SystemSelectRemoteFolderAction
|
||||
* actions classes (and the dialog and form used by these) and enable the dialog's OK button to
|
||||
* be replaced with an Add button. When the user selects and object or presses Add, the caller
|
||||
* is informed and able to display a resulting message in the dialog's message line,and affect
|
||||
* the enabled state of the Add button.
|
||||
* <p>
|
||||
* If you call the enableAddButton method you must pass an object that implements this interface.
|
||||
* The dialog will call you back when the user presses the Add button, so you can take
|
||||
* appropriate action.
|
||||
*/
|
||||
public interface ISystemAddFileListener
|
||||
{
|
||||
|
||||
/**
|
||||
* The user has pressed the Add button.
|
||||
* Do something appropriate with the request.
|
||||
* <p>
|
||||
* If this action fails for some reason, or you wish to display a completion
|
||||
* message, return message text that will be displayed in the dialog's message
|
||||
* line. Else, return null.
|
||||
*/
|
||||
public Object addButtonPressed(IHost selectedConnection, IRemoteFile[] selectedObjects);
|
||||
/**
|
||||
* The user has selected a file or folder. Is this valid to be added?
|
||||
* <p>
|
||||
* If so, return null. If not, return a string to display on the
|
||||
* message line indicating why it is not valid, such as it already has
|
||||
* been added.
|
||||
*/
|
||||
public Object okToEnableAddButton(IHost selectedConnection, IRemoteFile[] selectedObjects);
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2000, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui;
|
||||
|
||||
// TODO is this file still used or necessary?
|
||||
|
||||
/**
|
||||
* Constants used throughout the System plugin
|
||||
*/
|
||||
public interface ISystemFileConstants
|
||||
{
|
||||
// public static final String PLUGIN_ID ="com.ibm.etools.systems";
|
||||
public static final String PLUGIN_ID ="org.eclipse.rse.files.ui";
|
||||
public static final String PREFIX = PLUGIN_ID+".files.";
|
||||
// Icons
|
||||
public static final String ICON_DIR = "icons";
|
||||
public static final String ICON_PATH = java.io.File.separator + ICON_DIR + java.io.File.separator;
|
||||
public static final String ICON_SUFFIX = "Icon";
|
||||
public static final String ICON_EXT = ".gif";
|
||||
|
||||
// Resource Bundle ids
|
||||
public static final String RESID_PREFIX = PREFIX+"ui.";
|
||||
|
||||
// -------------------
|
||||
// DEFAULT FILTERS...
|
||||
// -------------------
|
||||
public static final String RESID_FILTER_ROOTS = RESID_PREFIX + "RootsFileFilter.label";
|
||||
public static final String RESID_FILTER_ROOTFILES = RESID_PREFIX + "RootFileFilter.label";
|
||||
public static final String RESID_FILTER_ROOTFOLDERS= RESID_PREFIX + "RootFolderFilter.label";
|
||||
public static final String RESID_FILTER_DRIVES = RESID_PREFIX + "DrivesFileFilter.label";
|
||||
public static final String RESID_FILTER_HOME = RESID_PREFIX + "HomeFileFilter.label";
|
||||
public static final String RESID_FILTER_USERHOME = RESID_PREFIX + "UserHomeFileFilter.label";
|
||||
public static final String RESID_FILTER_MYHOME = RESID_PREFIX + "MyHomeFileFilter.label";
|
||||
// -------------------------
|
||||
// MISCELLANEOUS...
|
||||
// -------------------------
|
||||
public static final String RESID_PROPERTY_FILE_FILTER_VALUE = RESID_PREFIX + "FileFilterProperty.value";
|
||||
|
||||
// -------------------------
|
||||
// WIZARDS...
|
||||
// -------------------------
|
||||
|
||||
// New System File Filter wizard...
|
||||
public static final String RESID_NEWFILEFILTER_PAGE1_TITLE = RESID_PREFIX+"NewFileFilter.page1.title";
|
||||
public static final String RESID_NEWFILEFILTER_PAGE1_DESCRIPTION = RESID_PREFIX+"NewFileFilter.page1.description";
|
||||
public static final String RESID_FILEFILTER_ROOT = RESID_PREFIX+"filefilter.";
|
||||
public static final String RESID_FILEFILTER_NAME_ROOT = RESID_FILEFILTER_ROOT+"name.";
|
||||
public static final String RESID_FILEFILTER_FOLDER_ROOT = RESID_FILEFILTER_ROOT+"folder.";
|
||||
public static final String RESID_FILEFILTER_FILE_ROOT = RESID_FILEFILTER_ROOT+"file.";
|
||||
public static final String RESID_FILEFILTER_STRING_ROOT = RESID_FILEFILTER_ROOT+"strings.";
|
||||
|
||||
// New Filter String wizard...
|
||||
public static final String RESID_NEWFILTERSTRING_TITLE = RESID_PREFIX+"NewFilterString.title";
|
||||
public static final String RESID_NEWFILTERSTRING_PAGE1_TITLE = RESID_PREFIX+"NewFilterString.page1.title";
|
||||
public static final String RESID_NEWFILTERSTRING_PAGE1_DESCRIPTION = RESID_PREFIX+"NewFilterString.page1.description";
|
||||
|
||||
// File Filter String Re-Usable form (used in dialog and wizard)
|
||||
public static final String RESID_FILEFILTERSTRING_ROOT = RESID_PREFIX+"filefilterstring.";
|
||||
public static final String RESID_FILEFILTERSTRING_FOLDER_ROOT = RESID_FILEFILTERSTRING_ROOT+"folder.";
|
||||
public static final String RESID_FILEFILTERSTRING_FILE_ROOT = RESID_FILEFILTERSTRING_ROOT+"file.";
|
||||
public static final String RESID_FILEFILTERSTRING_INCFOLDERS_ROOT = RESID_FILEFILTERSTRING_ROOT+"include.folders.";
|
||||
public static final String RESID_FILEFILTERSTRING_INCFILES_ROOT = RESID_FILEFILTERSTRING_ROOT+"include.files.";
|
||||
public static final String RESID_FILEFILTERSTRING_INCFILESONLY_ROOT = RESID_FILEFILTERSTRING_ROOT+"include.filesonly.";
|
||||
public static final String RESID_FILEFILTERSTRING_BYFILENAME_ROOT = RESID_FILEFILTERSTRING_ROOT+"include.byfilename.";
|
||||
public static final String RESID_FILEFILTERSTRING_BYFILETYPES_ROOT= RESID_FILEFILTERSTRING_ROOT+"include.byfiletypes.";
|
||||
public static final String RESID_FILEFILTERSTRING_TYPES_ROOT = RESID_FILEFILTERSTRING_ROOT+"types.";
|
||||
public static final String RESID_FILEFILTERSTRING_SELECTTYPES_ROOT= RESID_FILEFILTERSTRING_ROOT+"selectTypes.";
|
||||
public static final String RESID_FILEFILTERSTRING_TEST_ROOT = RESID_FILEFILTERSTRING_ROOT+"test.";
|
||||
// -------------------------
|
||||
// DIALOGS...
|
||||
// -------------------------
|
||||
// Change System File Filter dialog...
|
||||
public static final String RESID_CHGFILEFILTER_TITLE = RESID_PREFIX+"ChgFileFilter.title";
|
||||
// Change System File Filter String dialog...
|
||||
public static final String RESID_CHGFILEFILTERSTRING_TITLE = RESID_PREFIX+"ChgFileFilterString.title";
|
||||
|
||||
// Select Directory dialog...
|
||||
public static final String RESID_SELECTDIRECTORY_TITLE = RESID_PREFIX+"SelectDirectory.title";
|
||||
public static final String RESID_SELECTDIRECTORY_VERBAGE = RESID_PREFIX+"SelectDirectory.verbage.";
|
||||
public static final String RESID_SELECTDIRECTORY_SELECT = RESID_PREFIX+"SelectDirectory.select.";
|
||||
// Select File dialog...
|
||||
public static final String RESID_SELECTFILE_TITLE = RESID_PREFIX+"SelectFile.title";
|
||||
public static final String RESID_SELECTFILE_VERBAGE = RESID_PREFIX+"SelectFile.verbage.";
|
||||
public static final String RESID_SELECTFILE_SELECT = RESID_PREFIX+"SelectFile.select.";
|
||||
|
||||
// Prompt for home folder dialog...
|
||||
public static final String RESID_HOMEPROMPT_TITLE = RESID_PREFIX+"HomePrompt.title";
|
||||
public static final String RESID_HOMEPROMPT_VERBAGE = RESID_PREFIX+"HomePrompt.verbage.";
|
||||
public static final String RESID_HOMEPROMPT_PROMPT_ROOT = RESID_PREFIX+"HomePrompt.prompt.";
|
||||
|
||||
// -------------------------
|
||||
// ACTIONS...
|
||||
// -------------------------
|
||||
public static final String ACTION_ID = RESID_PREFIX + "action.";
|
||||
|
||||
public static final String ACTION_NEWFILEFILTER = ACTION_ID + "NewFilter";
|
||||
public static final String ACTION_NEWNESTEDFILEFILTER= ACTION_ID + "NewNestedFilter";
|
||||
public static final String ACTION_UPDATEFILEFILTER = ACTION_ID + "UpdateFilter";
|
||||
|
||||
public static final String ACTION_NEWFILEFILTERSTRING = ACTION_ID + "NewFilterString";
|
||||
public static final String ACTION_ADDFILEFILTERSTRING = ACTION_ID + "AddFilterString";
|
||||
public static final String ACTION_UPDATEFILEFILTERSTRING = ACTION_ID + "UpdateFilterString";
|
||||
public static final String ACTION_SELECTFILETYPES = ACTION_ID + "SelectFileTypes";
|
||||
|
||||
// -------------------------
|
||||
// WIDGETS...
|
||||
// -------------------------
|
||||
public static final String WIDGET_ID = RESID_PREFIX + "widget.";
|
||||
|
||||
public static final String WIDGET_FOLDER_ROOT = WIDGET_ID + "directory.";
|
||||
public static final String WIDGET_BROWSE_ROOT = WIDGET_ID + "browse.";
|
||||
|
||||
|
||||
// -------------------------
|
||||
// PROPERTY PAGES...
|
||||
// -------------------------
|
||||
public static final String RESID_PP_FILE_ROOT = RESID_PREFIX+"pp.file.";
|
||||
public static final String RESID_PP_FILE_TITLE = RESID_PP_FILE_ROOT+"title";
|
||||
public static final String RESID_PP_FILE_TYPE_ROOT = RESID_PP_FILE_ROOT+"type.";
|
||||
public static final String RESID_PP_FILE_TYPE_FILE_VALUE = RESID_PP_FILE_ROOT+"type.file.value";
|
||||
public static final String RESID_PP_FILE_TYPE_FOLDER_VALUE = RESID_PP_FILE_ROOT+"type.folder.value";
|
||||
public static final String RESID_PP_FILE_TYPE_ROOT_VALUE = RESID_PP_FILE_ROOT+"type.root.value";
|
||||
public static final String RESID_PP_FILE_NAME_ROOT = RESID_PP_FILE_ROOT+"name.";
|
||||
public static final String RESID_PP_FILE_PATH_ROOT = RESID_PP_FILE_ROOT+"path.";
|
||||
public static final String RESID_PP_FILE_SIZE_ROOT = RESID_PP_FILE_ROOT+"size.";
|
||||
public static final String RESID_PP_FILE_SIZE_VALUE = RESID_PP_FILE_ROOT+"size.value";
|
||||
public static final String RESID_PP_FILE_MODIFIED_ROOT = RESID_PP_FILE_ROOT+"modified.";
|
||||
public static final String RESID_PP_FILE_READONLY_ROOT = RESID_PP_FILE_ROOT+"readonly.";
|
||||
public static final String RESID_PP_FILE_READABLE_ROOT = RESID_PP_FILE_ROOT+"readable.";
|
||||
public static final String RESID_PP_FILE_WRITABLE_ROOT = RESID_PP_FILE_ROOT+"writable.";
|
||||
public static final String RESID_PP_FILE_HIDDEN_ROOT = RESID_PP_FILE_ROOT+"hidden.";
|
||||
|
||||
|
||||
// -------------------------------
|
||||
// Enter or select file form
|
||||
// -------------------------------
|
||||
public static final String RESID_ENTER_OR_SELECT_FILE_PREFIX = RESID_PREFIX + "EnterOrSelectFile.";
|
||||
public static final String RESID_ENTER_OR_SELECT_FILE_TITLE = RESID_ENTER_OR_SELECT_FILE_PREFIX + "title";
|
||||
public static final String RESID_ENTER_OR_SELECT_FILE_VERBAGE_LABEL = RESID_ENTER_OR_SELECT_FILE_PREFIX + "verbage.label";
|
||||
public static final String RESID_ENTER_OR_SELECT_FILE_ENTER_LABEL = RESID_ENTER_OR_SELECT_FILE_PREFIX + "enter.label";
|
||||
public static final String RESID_ENTER_OR_SELECT_FILE_ENTER_TOOLTIP = RESID_ENTER_OR_SELECT_FILE_PREFIX + "enter.tooltip";
|
||||
public static final String RESID_ENTER_OR_SELECT_FILE_SELECT_TOOLTIP = RESID_ENTER_OR_SELECT_FILE_PREFIX + "select.tooltip";
|
||||
public static final String RESID_ENTER_OR_SELECT_FILE_FILE_LABEL = RESID_ENTER_OR_SELECT_FILE_PREFIX + "file.label";
|
||||
public static final String RESID_ENTER_OR_SELECT_FILE_FILE_TOOLTIP = RESID_ENTER_OR_SELECT_FILE_PREFIX + "file.tooltip";
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2000, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui;
|
||||
/**
|
||||
* Keys into the core plugin's resource bundle for error messages related
|
||||
* to the remote file system framework.
|
||||
*/
|
||||
public interface ISystemFileMessages
|
||||
{
|
||||
//public static final String PLUGIN_ID ="org.eclipse.rse.ui";
|
||||
//public static final String PLUGIN_ID =ISystemMessages.PLUGIN_ID;
|
||||
// Message prefix
|
||||
//public static final String FILEMSG_PREFIX = PLUGIN_ID+".ui.filemsg.";
|
||||
|
||||
// Messages
|
||||
//public static final String FILEMSG_VALIDATE_PREFIX = FILEMSG_PREFIX + "Validate.";
|
||||
|
||||
public static final String FILEMSG_VALIDATE_FILEFILTERSTRING_EMPTY = "RSEF1006";
|
||||
public static final String FILEMSG_VALIDATE_FILEFILTERSTRING_NOTUNIQUE= "RSEF1007";
|
||||
public static final String FILEMSG_VALIDATE_FILEFILTERSTRING_NOTVALID = "RSEF1008";
|
||||
public static final String FILEMSG_VALIDATE_FILEFILTERSTRING_NOINCLUDES = "RSEF1009";
|
||||
}
|
|
@ -0,0 +1,823 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
import org.eclipse.rse.files.ui.actions.SystemSelectFileTypesAction;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemFileWidgetHelpers;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemRemoteFolderCombo;
|
||||
import org.eclipse.rse.filters.ISystemFilter;
|
||||
import org.eclipse.rse.filters.ISystemFilterPoolManagerProvider;
|
||||
import org.eclipse.rse.filters.ISystemFilterPoolReferenceManagerProvider;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystemConfiguration;
|
||||
import org.eclipse.rse.subsystems.files.core.util.ValidatorFileFilterString;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||
import org.eclipse.rse.ui.actions.SystemTestFilterStringAction;
|
||||
import org.eclipse.rse.ui.filters.SystemFilterStringEditPane;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.validators.ISystemValidator;
|
||||
import org.eclipse.rse.ui.validators.ValidatorPathName;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
|
||||
/**
|
||||
* The edit pane for page 1 of the New File Filter wizard.
|
||||
* Prompts for the details of a single file filter string.
|
||||
*/
|
||||
public class SystemFileFilterStringEditPane
|
||||
extends SystemFilterStringEditPane implements ISystemMessages
|
||||
{
|
||||
// GUI widgets
|
||||
protected Button filesOnlyCheckBox;
|
||||
//protected Button testButton;
|
||||
protected Button subsetByFileNameRadioButton, subsetByFileTypesRadioButton;
|
||||
protected Button selectTypesButton;
|
||||
protected Label labelFile, labelTypes;
|
||||
protected Text textFile, textTypes;
|
||||
protected SystemRemoteFolderCombo folderCombo;
|
||||
// limits
|
||||
protected int filterFileLength = 256;
|
||||
protected int filterPathLength = 256;
|
||||
// validators
|
||||
protected ISystemValidator pathValidator = new ValidatorPathName();
|
||||
protected ISystemValidator fileValidator;
|
||||
// inputs
|
||||
protected boolean caseSensitive = false;
|
||||
//protected boolean showTestButton = true;
|
||||
protected String[] inputFilterStrings;
|
||||
// state
|
||||
protected boolean noValidation = false;
|
||||
protected boolean callerInstanceOfWizardPage, callerInstanceOfSystemPromptDialog;
|
||||
protected boolean skipUniquenessChecking;
|
||||
protected boolean calledFromVerify;
|
||||
protected boolean dontStealFocus;
|
||||
protected RemoteFileSubSystemConfiguration inputSubsystemFactory = null;
|
||||
|
||||
// actions
|
||||
protected SystemTestFilterStringAction testAction = null;
|
||||
protected SystemSelectFileTypesAction typesAction = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for SystemFileFilterStringEditPane.
|
||||
* @param shell
|
||||
*/
|
||||
public SystemFileFilterStringEditPane(Shell shell)
|
||||
{
|
||||
super(shell);
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// INPUT/CONFIGURATION METHODS...
|
||||
// ------------------------------
|
||||
/**
|
||||
* Set the contextual system filter pool reference manager provider. Will be non-null if the
|
||||
* current selection is a reference to a filter pool or filter, or a reference manager
|
||||
* provider (eg subsystem).
|
||||
* <p>
|
||||
* Intercept of parent so we can extract the isCaseSensitive() value.
|
||||
*/
|
||||
public void setSystemFilterPoolReferenceManagerProvider(ISystemFilterPoolReferenceManagerProvider provider)
|
||||
{
|
||||
super.setSystemFilterPoolReferenceManagerProvider(provider);
|
||||
if (provider != null)
|
||||
caseSensitive = ((ISubSystem)provider).getSubSystemConfiguration().isCaseSensitive();
|
||||
}
|
||||
/**
|
||||
* Set the contextual system filter pool manager provider. Will be non-null if the
|
||||
* current selection is a filter pool or filter or reference to either, or a manager
|
||||
* provider itself (eg, subsystem factory).
|
||||
* <p>
|
||||
* Intercept of parent so we can extract the isCaseSensitive() value.
|
||||
*/
|
||||
public void setSystemFilterPoolManagerProvider(ISystemFilterPoolManagerProvider provider)
|
||||
{
|
||||
super.setSystemFilterPoolManagerProvider(provider);
|
||||
if (provider != null)
|
||||
caseSensitive = ((ISubSystemConfiguration)provider).isCaseSensitive();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this to override the text limit for the filter name, from the default of 40.
|
||||
*/
|
||||
public void setFilterFileLength(int max)
|
||||
{
|
||||
filterFileLength = max;
|
||||
if (textFile != null)
|
||||
textFile.setTextLimit(max);
|
||||
}
|
||||
/**
|
||||
* Call this to override the text limit for the filter name, from the default of 40.
|
||||
*/
|
||||
public void setFilterPathLength(int max)
|
||||
{
|
||||
filterPathLength = max;
|
||||
if (folderCombo != null)
|
||||
folderCombo.setTextLimit(max);
|
||||
}
|
||||
/**
|
||||
* Existing strings are used to aid in uniqueness validation.
|
||||
*/
|
||||
public void setExistingStrings(String[] existingStrings, boolean caseSensitive)
|
||||
{
|
||||
this.inputFilterStrings = existingStrings;
|
||||
this.caseSensitive = caseSensitive;
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// LIFECYCLE METHODS...
|
||||
// ------------------------------
|
||||
|
||||
/**
|
||||
* Populate the pane with the GUI widgets
|
||||
* @param parent
|
||||
* @return Control
|
||||
*/
|
||||
public Control createContents(Composite parent)
|
||||
{
|
||||
int gridColumns = 2;
|
||||
Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, gridColumns);
|
||||
|
||||
// directory prompt
|
||||
String historyKey = null;
|
||||
if (refProvider != null)
|
||||
historyKey = ((ISubSystem)refProvider).getSubSystemConfiguration().getId()+".filterStringDialog"; // unique to us
|
||||
else
|
||||
historyKey = "files.filterStringDialog"; // unique to us
|
||||
|
||||
boolean readonly = false;
|
||||
folderCombo = SystemFileWidgetHelpers.createFolderCombo(composite_prompts, null, gridColumns, historyKey, readonly);
|
||||
folderCombo.setShowNewConnectionPrompt(false);
|
||||
SystemWidgetHelpers.setHelp(folderCombo, SystemPlugin.HELPPREFIX+"ffsd0001");
|
||||
SystemWidgetHelpers.createLabel(composite_prompts," ",gridColumns); // FILLER
|
||||
|
||||
// parent folder prompt
|
||||
//textFolder = SystemWidgetHelpers.createLabeledTextField(composite_prompts, null, rb, RESID_FILEFILTERSTRING_FOLDER_ROOT);
|
||||
|
||||
// "Subset by file name filter" radiobutton
|
||||
subsetByFileNameRadioButton = SystemWidgetHelpers.createRadioButton(composite_prompts, null, SystemFileResources.RESID_FILEFILTERSTRING_BYFILENAME_LABEL, SystemFileResources.RESID_FILEFILTERSTRING_BYFILENAME_TOOLTIP);
|
||||
//SystemWidgetHelpers.setHelp(subsetByFileNameRadioButton, SystemPlugin.HELPPREFIX+"ffsd0002", SystemPlugin.HELPPREFIX+"ffsd0003");
|
||||
SystemWidgetHelpers.setHelp(subsetByFileNameRadioButton, SystemPlugin.HELPPREFIX+"ffsd0002");
|
||||
updateGridData(subsetByFileNameRadioButton, gridColumns);
|
||||
|
||||
// File name prompt
|
||||
//textFile = SystemWidgetHelpers.createLabeledTextField(composite_prompts, null, rb, RESID_FILEFILTERSTRING_FILE_ROOT);
|
||||
String indent = " ";
|
||||
String temp = SystemWidgetHelpers.appendColon(SystemFileResources.RESID_FILEFILTERSTRING_FILE_LABEL);
|
||||
labelFile = SystemWidgetHelpers.createLabel(composite_prompts, indent+temp);
|
||||
labelFile.setToolTipText(SystemFileResources.RESID_FILEFILTERSTRING_FILE_TOOLTIP);
|
||||
textFile = SystemWidgetHelpers.createTextField(composite_prompts, null);
|
||||
textFile.setToolTipText(SystemFileResources.RESID_FILEFILTERSTRING_FILE_TOOLTIP);
|
||||
//SystemWidgetHelpers.setHelp(textFile, SystemPlugin.HELPPREFIX+"ffsd0003",SystemPlugin.HELPPREFIX+"ffsd0002");
|
||||
SystemWidgetHelpers.setHelp(textFile, SystemPlugin.HELPPREFIX+"ffsd0003");
|
||||
updateGridData(textFile, gridColumns-1);
|
||||
textFile.setText("*");
|
||||
|
||||
|
||||
// "Subset by file types filter" radiobutton
|
||||
subsetByFileTypesRadioButton = SystemWidgetHelpers.createRadioButton(composite_prompts, null, SystemFileResources.RESID_FILEFILTERSTRING_BYFILETYPES_LABEL, SystemFileResources.RESID_FILEFILTERSTRING_BYFILETYPES_TOOLTIP);
|
||||
//SystemWidgetHelpers.setHelp(subsetByFileTypesRadioButton, SystemPlugin.HELPPREFIX+"ffsd0004", SystemPlugin.HELPPREFIX+"ffsd0005");
|
||||
SystemWidgetHelpers.setHelp(subsetByFileTypesRadioButton, SystemPlugin.HELPPREFIX+"ffsd0004");
|
||||
updateGridData(subsetByFileTypesRadioButton, gridColumns);
|
||||
|
||||
// File types prompt
|
||||
Composite typesGroup = SystemWidgetHelpers.createComposite(composite_prompts, 3);
|
||||
//SystemWidgetHelpers.setHelp(typesGroup, SystemPlugin.HELPPREFIX+"ffsd0005",SystemPlugin.HELPPREFIX+"ffsd0004");
|
||||
SystemWidgetHelpers.setHelp(typesGroup, SystemPlugin.HELPPREFIX+"ffsd0005");
|
||||
GridLayout layout = (GridLayout)typesGroup.getLayout();
|
||||
layout.marginWidth = 0;
|
||||
layout.marginHeight = 0;
|
||||
updateGridData(typesGroup, gridColumns);
|
||||
temp = SystemWidgetHelpers.appendColon(SystemFileResources.RESID_FILEFILTERSTRING_TYPES_LABEL);
|
||||
labelTypes = SystemWidgetHelpers.createLabel(typesGroup, indent+temp);
|
||||
labelTypes.setToolTipText(SystemFileResources.RESID_FILEFILTERSTRING_TYPES_TOOLTIP);
|
||||
textTypes = SystemWidgetHelpers.createReadonlyTextField(typesGroup);
|
||||
textTypes.setToolTipText(SystemFileResources.RESID_FILEFILTERSTRING_TYPES_TOOLTIP);
|
||||
updateGridData(textTypes, 1);
|
||||
selectTypesButton = SystemWidgetHelpers.createPushButton(typesGroup, null, SystemFileResources.RESID_FILEFILTERSTRING_SELECTTYPES_LABEL, SystemFileResources.RESID_FILEFILTERSTRING_SELECTTYPES_TOOLTIP);
|
||||
GridData data = (GridData)selectTypesButton.getLayoutData();
|
||||
data.grabExcessHorizontalSpace = false;
|
||||
data.horizontalAlignment = GridData.FILL;
|
||||
|
||||
|
||||
/*
|
||||
// Include Folders check box
|
||||
subdirCheckBox = SystemWidgetHelpers.createCheckBox(composite_prompts, gridColumns, null,
|
||||
rb, RESID_FILEFILTERSTRING_INCFOLDERS_ROOT);
|
||||
subdirCheckBox.addSelectionListener(this);
|
||||
|
||||
// Include Files check box
|
||||
fileCheckBox = SystemWidgetHelpers.createCheckBox(composite_prompts, gridColumns, null,
|
||||
rb, RESID_FILEFILTERSTRING_INCFILES_ROOT);
|
||||
fileCheckBox.addSelectionListener(this);
|
||||
*/
|
||||
|
||||
// Show Files Only check box
|
||||
SystemWidgetHelpers.createLabel(composite_prompts," ",gridColumns); // FILLER
|
||||
filesOnlyCheckBox = SystemWidgetHelpers.createCheckBox(composite_prompts, gridColumns, null,
|
||||
SystemFileResources.RESID_FILEFILTERSTRING_INCFILESONLY_LABEL, SystemFileResources.RESID_FILEFILTERSTRING_INCFILESONLY_TOOLTIP);
|
||||
SystemWidgetHelpers.setHelp(filesOnlyCheckBox, SystemPlugin.HELPPREFIX+"ffsd0006");
|
||||
|
||||
// Test button
|
||||
/*
|
||||
if (showTestButton)
|
||||
{
|
||||
SystemWidgetHelpers.createLabel(composite_prompts," ",gridColumns); // FILLER
|
||||
SystemWidgetHelpers.createLabel(composite_prompts," ",gridColumns); // FILLER
|
||||
createTestButton(composite_prompts, RESID_FILEFILTERSTRING_TEST_ROOT);
|
||||
SystemWidgetHelpers.setHelp(testButton, SystemPlugin.HELPPREFIX+"ffsd0007");
|
||||
updateGridData(testButton, gridColumns);
|
||||
}
|
||||
*/
|
||||
|
||||
folderCombo.setFocus();
|
||||
|
||||
if (refProvider != null)
|
||||
inputSubsystemFactory = (RemoteFileSubSystemConfiguration)((ISubSystem)refProvider).getSubSystemConfiguration();
|
||||
else if (provider != null)
|
||||
inputSubsystemFactory = (RemoteFileSubSystemConfiguration)provider;
|
||||
pathValidator = inputSubsystemFactory.getPathValidator();
|
||||
fileValidator = inputSubsystemFactory.getFileFilterStringValidator();
|
||||
if (refProvider != null)
|
||||
folderCombo.setSystemConnection(((ISubSystem)refProvider).getHost());
|
||||
else if (inputSubsystemFactory != null)
|
||||
folderCombo.setSystemTypes(inputSubsystemFactory.getSystemTypes());
|
||||
folderCombo.setSubSystem((IRemoteFileSubSystem)refProvider);
|
||||
folderCombo.setTextLimit(filterPathLength);
|
||||
textFile.setTextLimit(filterFileLength);
|
||||
|
||||
resetFields();
|
||||
doInitializeFields();
|
||||
|
||||
folderCombo.addModifyListener(
|
||||
new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
validateFolderInput();
|
||||
}
|
||||
}
|
||||
);
|
||||
textFile.addModifyListener(
|
||||
new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
validateFileInput();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
subsetByFileNameRadioButton.addSelectionListener(this);
|
||||
subsetByFileTypesRadioButton.addSelectionListener(this);
|
||||
selectTypesButton.addSelectionListener(this);
|
||||
filesOnlyCheckBox.addSelectionListener(this);
|
||||
|
||||
return composite_prompts;
|
||||
}
|
||||
private void updateGridData(Control widget, int gridColumns)
|
||||
{
|
||||
GridData data = (GridData)widget.getLayoutData();
|
||||
data.horizontalSpan = gridColumns;
|
||||
data.grabExcessHorizontalSpace = true;
|
||||
data.horizontalAlignment = GridData.FILL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the control to recieve initial focus. Should be overridden if you override createContents
|
||||
*/
|
||||
public Control getInitialFocusControl()
|
||||
{
|
||||
return folderCombo.getCombo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override of parent.
|
||||
* Called after reset fields, at first create time or when input is reset to a non-null value.
|
||||
*/
|
||||
protected void doInitializeFields()
|
||||
{
|
||||
if (folderCombo == null)
|
||||
return;
|
||||
//if (refProvider == null)
|
||||
//SystemPlugin.logError("Programming Error: input subsystem is not set for SystemFileFilterStringEditPane",null);
|
||||
|
||||
if (inputFilterString != null)
|
||||
{
|
||||
RemoteFileFilterString rffs = new RemoteFileFilterString(inputSubsystemFactory, inputFilterString);
|
||||
String defaultPath = rffs.getPath();
|
||||
folderCombo.setText((defaultPath==null) ? "" : defaultPath);
|
||||
String defaultFile = rffs.getFile();
|
||||
textFile.setText((defaultFile==null) ? "" : defaultFile);
|
||||
String defaultTypes = rffs.getTypesAsString();
|
||||
textTypes.setText((defaultTypes==null) ? "" : defaultTypes);
|
||||
boolean defaultIncludeFilesOnly = rffs.getShowFiles() && !rffs.getShowSubDirs();
|
||||
boolean defaultSubsetByFileName = !rffs.getFilterByTypes();
|
||||
// set appropriate radio button for subset type
|
||||
subsetByFileNameRadioButton.setSelection(defaultSubsetByFileName);
|
||||
subsetByFileTypesRadioButton.setSelection(!defaultSubsetByFileName);
|
||||
filesOnlyCheckBox.setSelection(defaultIncludeFilesOnly);
|
||||
enableFields(defaultSubsetByFileName);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This is called in the change filter dialog when the user selects "new", or selects another string.
|
||||
* You must override this if you override createContents. Be sure to test if the contents have even been created yet!
|
||||
*/
|
||||
protected void resetFields()
|
||||
{
|
||||
if (folderCombo == null)
|
||||
return;
|
||||
folderCombo.setText("");
|
||||
textFile.setText("*");
|
||||
textTypes.setText("");
|
||||
subsetByFileNameRadioButton.setSelection(true);
|
||||
subsetByFileTypesRadioButton.setSelection(false);
|
||||
filesOnlyCheckBox.setSelection(false);
|
||||
enableFields(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Must be overridden if createContents is overridden.
|
||||
* <p>
|
||||
* This is called by the isComplete, to decide if the default information
|
||||
* is complete enough to enable finish. It doesn't do validation, that will be done when
|
||||
* finish is pressed.
|
||||
*/
|
||||
protected boolean areFieldsComplete()
|
||||
{
|
||||
if (folderCombo == null)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
boolean filterGiven = false;
|
||||
boolean subsetByFileName = false;
|
||||
String fileNameText = null;
|
||||
|
||||
if (subsetByFileNameRadioButton.getSelection()) {
|
||||
fileNameText = textFile.getText().trim();
|
||||
filterGiven = fileNameText.length() > 0;
|
||||
subsetByFileName = true;
|
||||
}
|
||||
else {
|
||||
filterGiven = textTypes.getText().trim().length() > 0;
|
||||
subsetByFileName = false;
|
||||
}
|
||||
|
||||
String folderText = folderCombo.getText().trim();
|
||||
|
||||
if (inputSubsystemFactory != null) {
|
||||
|
||||
// KM: defect 53009.
|
||||
// if input subsystem factory is Unix, then we can not allow empty path
|
||||
if (inputSubsystemFactory.isUnixStyle()) {
|
||||
return folderText.length() > 0 && filterGiven;
|
||||
}
|
||||
// otherwise, if it is Windows
|
||||
else {
|
||||
|
||||
// check if folder path is empty
|
||||
if (folderText.length() == 0) {
|
||||
|
||||
// KM: defect 53210
|
||||
// if folder path empty, only valid filter is subset by file name and it
|
||||
// must be wild card
|
||||
if (subsetByFileName) {
|
||||
return fileNameText.equals("*");
|
||||
}
|
||||
// if we are not subsetting by file name, it is not valid
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// if folder path is not empty, we just make sure a subset is given
|
||||
else {
|
||||
return filterGiven;
|
||||
}
|
||||
}
|
||||
}
|
||||
// otherwise don't care about folder path
|
||||
else {
|
||||
return filterGiven;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Enable/disable fields dependent on radiobuttons
|
||||
*/
|
||||
private void enableFields(boolean byFileName)
|
||||
{
|
||||
labelTypes.setEnabled(!byFileName);
|
||||
//textTypes.setEnabled(!byFileName);
|
||||
selectTypesButton.setEnabled(!byFileName);
|
||||
labelFile.setEnabled(byFileName);
|
||||
textFile.setEnabled(byFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action to run when "Select Types..." is pressed by the user
|
||||
*/
|
||||
protected SystemSelectFileTypesAction getSelectTypesAction()
|
||||
{
|
||||
if (typesAction == null)
|
||||
typesAction = new SystemSelectFileTypesAction(selectTypesButton.getShell());
|
||||
return typesAction;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Completes processing of the wizard page or dialog. If this
|
||||
* method returns true, the wizard/dialog will close;
|
||||
* otherwise, it will stay active.
|
||||
*
|
||||
* @return error, if there is one
|
||||
*/
|
||||
public SystemMessage verify()
|
||||
{
|
||||
errorMessage = null;
|
||||
Control controlInError = null;
|
||||
calledFromVerify = true;
|
||||
skipEventFiring = true;
|
||||
|
||||
errorMessage = validateFolderInput();
|
||||
if (errorMessage != null)
|
||||
controlInError = folderCombo;
|
||||
|
||||
if (errorMessage == null)
|
||||
{
|
||||
if (subsetByFileNameRadioButton.getSelection())
|
||||
errorMessage = validateFileInput();
|
||||
else
|
||||
{
|
||||
if (textTypes.getText().trim().length() == 0)
|
||||
{
|
||||
errorMessage = SystemPlugin.getPluginMessage(FILEMSG_ERROR_NOFILETYPES);
|
||||
}
|
||||
}
|
||||
controlInError = textFile;
|
||||
}
|
||||
if ((errorMessage == null) && (inputFilterStrings!=null) && !skipUniquenessChecking)
|
||||
{
|
||||
boolean notUnique = false;
|
||||
String currFilterString = getFilterString();
|
||||
if (containsFilterString(currFilterString))
|
||||
notUnique = true;
|
||||
if (notUnique)
|
||||
{
|
||||
errorMessage = SystemPlugin.getPluginMessage(FILEMSG_VALIDATE_FILEFILTERSTRING_NOTUNIQUE).makeSubstitution(currFilterString);
|
||||
}
|
||||
controlInError = textFile;
|
||||
}
|
||||
|
||||
if (errorMessage != null)
|
||||
{
|
||||
if (!dontStealFocus)
|
||||
controlInError.setFocus();
|
||||
}
|
||||
else
|
||||
folderCombo.updateHistory(true);
|
||||
|
||||
calledFromVerify = false;
|
||||
skipEventFiring = false;
|
||||
fireChangeEvent(errorMessage);
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
private boolean containsFilterString(String newString)
|
||||
{
|
||||
if (inputFilterStrings == null)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
for (int idx=0; idx<inputFilterStrings.length; idx++)
|
||||
{
|
||||
if (caseSensitive)
|
||||
{
|
||||
if (inputFilterStrings[idx].equals(newString))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inputFilterStrings[idx].equalsIgnoreCase(newString))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------
|
||||
// METHODS FOR VERIFYING INPUT PER KEYSTROKE ...
|
||||
// ---------------------------------------------
|
||||
/**
|
||||
* This hook method is called whenever the text changes in the input field.
|
||||
* The default implementation delegates the request to an <code>ISystemValidator</code> object.
|
||||
* If the <code>ISystemValidator</code> reports an error the error message is displayed
|
||||
* in the Dialog's message line.
|
||||
*/
|
||||
protected SystemMessage validateFileInput()
|
||||
{
|
||||
if (noValidation || ignoreChanges)
|
||||
return null;
|
||||
|
||||
errorMessage = null;
|
||||
|
||||
// first validate file name
|
||||
if (fileValidator != null)
|
||||
{
|
||||
if (fileValidator instanceof ValidatorFileFilterString)
|
||||
{
|
||||
ValidatorFileFilterString fv = (ValidatorFileFilterString)fileValidator;
|
||||
fv.setIsFileName(true);
|
||||
}
|
||||
|
||||
errorMessage = fileValidator.validate(textFile.getText().trim());
|
||||
}
|
||||
|
||||
// if there is no error message, then validate that folder name is correct
|
||||
// this fires a change event
|
||||
if (errorMessage == null) {
|
||||
errorMessage = validateFolderInput();
|
||||
}
|
||||
// otherwise, simply fire change event
|
||||
else {
|
||||
fireChangeEvent(errorMessage);
|
||||
}
|
||||
|
||||
return errorMessage;
|
||||
}
|
||||
/**
|
||||
* This hook method is called whenever the text changes in the input field.
|
||||
* The default implementation delegates the request to an <code>ISystemValidator</code> object.
|
||||
* If the <code>ISystemValidator</code> reports an error the error message is displayed
|
||||
* in the Dialog's message line.
|
||||
*/
|
||||
protected SystemMessage validateFolderInput()
|
||||
{
|
||||
if (noValidation || ignoreChanges)
|
||||
return null;
|
||||
errorMessage= null;
|
||||
|
||||
String folderComboText = folderCombo.getText().trim();
|
||||
|
||||
// first check if folder path is empty
|
||||
if (folderComboText.length() == 0) {
|
||||
|
||||
// KM: defect 53009.
|
||||
// If the input subsystem factory is Unix, we do not allow empty folder path.
|
||||
// Note that for Windows, it is perfectly valid to have an empty folder path,
|
||||
// which indicates that the filter will resolve to show all the drives
|
||||
if (inputSubsystemFactory != null) {
|
||||
|
||||
if (inputSubsystemFactory.isUnixStyle()) {
|
||||
|
||||
// let error message come from path validator
|
||||
if (pathValidator != null) {
|
||||
errorMessage = pathValidator.validate(folderComboText);
|
||||
}
|
||||
// no path validator, so just use default path empty message
|
||||
else {
|
||||
errorMessage = SystemPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PATH_EMPTY);
|
||||
}
|
||||
}
|
||||
// KM: defect 53210
|
||||
// for Windows, check that subset by file name is selected
|
||||
// and that it is wild card character
|
||||
else {
|
||||
|
||||
if (!subsetByFileNameRadioButton.getSelection() || !textFile.getText().trim().equals("*")) {
|
||||
|
||||
// let error message come from path validator
|
||||
if (pathValidator != null) {
|
||||
errorMessage = pathValidator.validate(folderComboText);
|
||||
}
|
||||
// no path validator, so just use default path empty message
|
||||
else {
|
||||
errorMessage = SystemPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PATH_EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// otherwise go through path validator
|
||||
else if (pathValidator != null) {
|
||||
errorMessage = pathValidator.validate(folderComboText);
|
||||
}
|
||||
|
||||
fireChangeEvent(errorMessage);
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// DATA EXTRACTION METHODS
|
||||
// ------------------------------
|
||||
|
||||
/**
|
||||
* Get the filter string in its current form.
|
||||
* This should be overridden if createContents is overridden.
|
||||
*/
|
||||
public String getFilterString()
|
||||
{
|
||||
if (folderCombo == null)
|
||||
return inputFilterString;
|
||||
String folder = folderCombo.getText().trim();
|
||||
boolean subsetByFileName = subsetByFileNameRadioButton.getSelection();
|
||||
String file = null;
|
||||
if (subsetByFileName)
|
||||
file = textFile.getText().trim();
|
||||
else
|
||||
file = textTypes.getText().trim();
|
||||
boolean showFilesOnly = filesOnlyCheckBox.getSelection();
|
||||
boolean showSubDirs = !showFilesOnly; //subdirCheckBox.getSelection();
|
||||
boolean showFiles = true; //fileCheckBox.getSelection();
|
||||
RemoteFileFilterString rffs = new RemoteFileFilterString(inputSubsystemFactory, folder, file);
|
||||
rffs.setShowSubDirs(showSubDirs);
|
||||
rffs.setShowFiles(showFiles);
|
||||
//System.out.println("internalGetFilterString: showSubDirs = " + showSubDirs + ", showFiles = " + showFiles);
|
||||
//System.out.println("... resulting string: " + rffs.toString());
|
||||
return rffs.toString();
|
||||
}
|
||||
|
||||
// ------------------
|
||||
// EVENT LISTENERS...
|
||||
// ------------------
|
||||
|
||||
/**
|
||||
* User has selected something
|
||||
*/
|
||||
public void widgetSelected(SelectionEvent event)
|
||||
{
|
||||
Object src = event.getSource();
|
||||
dontStealFocus = true;
|
||||
/*
|
||||
else if (src == subdirCheckBox)
|
||||
validateFileInput();
|
||||
else if (src == fileCheckBox)
|
||||
validateFileInput();
|
||||
*/
|
||||
if (src == filesOnlyCheckBox)
|
||||
{
|
||||
verify();
|
||||
}
|
||||
else if (src == subsetByFileNameRadioButton)
|
||||
{
|
||||
verify();
|
||||
enableFields(true);
|
||||
textFile.setFocus();
|
||||
}
|
||||
else if (src == subsetByFileTypesRadioButton)
|
||||
{
|
||||
verify();
|
||||
enableFields(false);
|
||||
selectTypesButton.setFocus();
|
||||
}
|
||||
else if (src == selectTypesButton)
|
||||
{
|
||||
SystemSelectFileTypesAction typesAction = getSelectTypesAction();
|
||||
String typesString = textTypes.getText().trim();
|
||||
typesAction.setTypes(typesString);
|
||||
typesAction.run();
|
||||
if (!typesAction.wasCancelled())
|
||||
{
|
||||
typesString = typesAction.getTypesString();
|
||||
textTypes.setText(typesString);
|
||||
dontStealFocus = false;
|
||||
verify();
|
||||
}
|
||||
}
|
||||
dontStealFocus = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by us or by owning dialog when common Test button is pressed
|
||||
*/
|
||||
public void processTest(Shell shell)
|
||||
{
|
||||
if (refProvider == null)
|
||||
{
|
||||
SystemBasePlugin.logWarning("Programming Error: input subsystem is not set");
|
||||
return;
|
||||
}
|
||||
skipUniquenessChecking = true;
|
||||
if (verify() == null)
|
||||
{
|
||||
SystemTestFilterStringAction testAction = new SystemTestFilterStringAction(getShell());
|
||||
testAction.setSubSystem((ISubSystem)refProvider);
|
||||
testAction.setFilterString(getFilterString());
|
||||
try
|
||||
{
|
||||
testAction.run();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
|
||||
SystemMessage msg = SystemMessageDialog.getExceptionMessage(getShell(), exc);
|
||||
fireChangeEvent(msg);
|
||||
}
|
||||
}
|
||||
skipUniquenessChecking = false;
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// STATIC HELPER METHODS...
|
||||
// ------------------------
|
||||
|
||||
/**
|
||||
* Reusable method to return a name validator for creating/update a file system filter string
|
||||
* @param filter The system filter to which we are adding/updating a filter string.
|
||||
* @param filterString The current filter object on updates. Can be null for new string. Used
|
||||
* to remove from the existing string list the current filter string.
|
||||
*/
|
||||
public static ValidatorFileFilterString getFileFilterStringValidator(ISystemFilter filter, String filterString)
|
||||
{
|
||||
Vector v = filter.getFilterStringsVector();
|
||||
if (filterString != null)
|
||||
v.removeElement(filterString);
|
||||
IRemoteFileSubSystemConfiguration ssFactory = (IRemoteFileSubSystemConfiguration)filter.getProvider();
|
||||
ValidatorFileFilterString validator = new ValidatorFileFilterString(ssFactory,v);
|
||||
return validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reusable method to return a name validator for creating/update a file system filter string.
|
||||
* No unique checking.
|
||||
*/
|
||||
public static ValidatorFileFilterString getFileFilterStringValidator(IRemoteFileSubSystemConfiguration ssFactory)
|
||||
{
|
||||
return new ValidatorFileFilterString(ssFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the file filter string is in new mode, and we have a non-Unix system, then if
|
||||
* the folder name is empty and other fields are at default, we do not allow an implicit
|
||||
* save through changing of filter string or pressing Ok button in the change filter pane.
|
||||
* If in new mode for non-Unix system, and the user hasn't changed the other fields,
|
||||
* we force user to use the Create button to create the filter string explicitly.
|
||||
* @see org.eclipse.rse.ui.filters.SystemFilterStringEditPane#canSaveImplicitly()
|
||||
*/
|
||||
public boolean canSaveImplicitly() {
|
||||
|
||||
// KM: defect 53009.
|
||||
// check if subsystem factory is non Unix and we're in new mode
|
||||
if (newMode && inputSubsystemFactory != null && !inputSubsystemFactory.isUnixStyle()) {
|
||||
|
||||
// check that folder combo is empty
|
||||
String folderComboText = folderCombo.getText().trim();
|
||||
|
||||
// if so, return false if other fields haven't changed
|
||||
// So a user is not able to save with an empty folder path without
|
||||
// explicitly pressing Create.
|
||||
// Note that if we're changing an existing filter string, a user can save
|
||||
// implicitly (i.e. without pressing Apply), by changing the filter
|
||||
// string selection in the filter string list in SystemChangeFilterPane
|
||||
// or by pressing Ok with pending changes. Same goes for a new filter
|
||||
// string for which the user has changed the subset by file name
|
||||
// or subset by file type fields. KM: defect 53210
|
||||
if (folderComboText.length() == 0 &&
|
||||
subsetByFileNameRadioButton.getSelection() &&
|
||||
textFile.getText().trim().equals("*")) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return super.canSaveImplicitly();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return super.canSaveImplicitly();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2000, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui;
|
||||
import org.eclipse.jface.viewers.ILabelProvider;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileEmpty;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is a private-use subclass of the internal Eclipse ResourceTreeAndListGroup
|
||||
* composite widget. This is for selecting multiple local or remote files. It contains
|
||||
* a checkbox tree on the left for selecting the folder, and a checkbox list on the
|
||||
* right for selecting the files.
|
||||
* <p>
|
||||
* We subclass this to add some slight additional functionality, including support for
|
||||
* refreshing the contents.
|
||||
*/
|
||||
public class SystemFileTreeAndListGroup extends org.eclipse.ui.internal.ide.dialogs.ResourceTreeAndListGroup
|
||||
{
|
||||
private Object rootObject = null;
|
||||
private Object lastSelectedElement = null;
|
||||
private ISelectionProvider selectionProvider = null;
|
||||
// CONSTANTS
|
||||
private static final RemoteFileEmpty EMPTYROOT = new RemoteFileEmpty();
|
||||
|
||||
/**
|
||||
* Constructor when there is initial content
|
||||
* @param parent org.eclipse.swt.widgets.Composite
|
||||
* @param rootObject java.lang.Object
|
||||
* @param treeContentProvider supplies the folders for the tree
|
||||
* @param treeLabelProvider supplies the names and icons of the folders for the tree
|
||||
* @param listContentProvider supplies the files for the tree
|
||||
* @param listLabelProvider supplies the names and icons for the files for the list
|
||||
* @param style int
|
||||
* @param width int
|
||||
* @param height int
|
||||
*/
|
||||
public SystemFileTreeAndListGroup(Composite parent,Object rootObject,
|
||||
ITreeContentProvider treeContentProvider, ILabelProvider treeLabelProvider,
|
||||
IStructuredContentProvider listContentProvider, ILabelProvider listLabelProvider,
|
||||
int style,int width,int height)
|
||||
{
|
||||
// DKM - API change
|
||||
//super(parent, rootObject, treeContentProvider, treeLabelProvider,
|
||||
// listContentProvider, listLabelProvider, style, width, height);
|
||||
super(parent, rootObject, treeContentProvider, treeLabelProvider,
|
||||
listContentProvider, listLabelProvider, style, true);
|
||||
|
||||
this.rootObject = rootObject;
|
||||
}
|
||||
/**
|
||||
* Constructor when there is no initial content
|
||||
* @param parent org.eclipse.swt.widgets.Composite
|
||||
* @param treeContentProvider supplies the folders for the tree
|
||||
* @param treeLabelProvider supplies the names and icons of the folders for the tree
|
||||
* @param listContentProvider supplies the files for the tree
|
||||
* @param listLabelProvider supplies the names and icons for the files for the list
|
||||
* @param style int
|
||||
* @param width int
|
||||
* @param height int
|
||||
*/
|
||||
public SystemFileTreeAndListGroup(Composite parent,
|
||||
ITreeContentProvider treeContentProvider, ILabelProvider treeLabelProvider,
|
||||
IStructuredContentProvider listContentProvider, ILabelProvider listLabelProvider,
|
||||
int style,int width,int height)
|
||||
{
|
||||
this(parent, EMPTYROOT, treeContentProvider, treeLabelProvider,
|
||||
listContentProvider, listLabelProvider, style, width, height);
|
||||
}
|
||||
|
||||
|
||||
// does not work! The viewers are private, and the create methods don't return them!!
|
||||
/**
|
||||
* Create this group's list viewer.
|
||||
* Override of parent so we can record locally the list viewer widget.
|
||||
*
|
||||
protected void createListViewer(Composite parent, int width, int height)
|
||||
{
|
||||
listViewer = super.createListViewer(parent, width, height);
|
||||
return listViewer;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Refesh all the contents of the checkbox viewers
|
||||
*/
|
||||
public void refresh()
|
||||
{
|
||||
if (! (rootObject instanceof RemoteFileEmpty) )
|
||||
{
|
||||
Object oldRoot = rootObject;
|
||||
setRoot(EMPTYROOT);
|
||||
setRoot(oldRoot);
|
||||
/*
|
||||
if ((selectionProvider!=null) && (oldRoot instanceof RemoteFileRootImpl))
|
||||
{
|
||||
RemoteFileRootImpl root = (RemoteFileRootImpl)oldRoot;
|
||||
IRemoteFile rootFile = root.getRootFile();
|
||||
if (rootFile != null)
|
||||
super.selectionChanged(new SelectionChangedEvent(selectionProvider,
|
||||
new StructuredSelection(oldRoot)));
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refesh the contents of the file-selection checkbox viewer.
|
||||
*/
|
||||
public void refreshFiles()
|
||||
{
|
||||
if (lastSelectedElement != null)
|
||||
populateListViewer(lastSelectedElement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the selection of an item in the tree viewer.
|
||||
* Intercept of parent so we can record the last selected tree node.
|
||||
* @param selection ISelection
|
||||
*/
|
||||
public void selectionChanged(SelectionChangedEvent event)
|
||||
{
|
||||
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
|
||||
lastSelectedElement = selection.getFirstElement();
|
||||
selectionProvider = event.getSelectionProvider();
|
||||
super.selectionChanged(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root of the widget to be new Root. Regenerate all of the tables and lists from this
|
||||
* value.
|
||||
* Intercept of parent so we can refresh internal variables.
|
||||
* @param newRoot
|
||||
*/
|
||||
public void setRoot(Object newRoot)
|
||||
{
|
||||
lastSelectedElement = null;
|
||||
rootObject = newRoot;
|
||||
super.setRoot(newRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the contents
|
||||
*/
|
||||
public void clearAll()
|
||||
{
|
||||
setRoot(EMPTYROOT);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2000, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration;
|
||||
import org.eclipse.rse.ui.actions.SystemAbstractPopupMenuExtensionAction;
|
||||
import org.eclipse.ui.IObjectActionDelegate;
|
||||
|
||||
|
||||
/**
|
||||
* This is a base class to simplify the creation of actions supplied via the
|
||||
* com.ibm.etools.systems.core.popupMenus extension point, targeting remote files
|
||||
* and/or remote folders.
|
||||
* <p>
|
||||
* The only method you must implement is {@link #run()}.
|
||||
* You may optionally override {@link #getEnabled(Object[])}
|
||||
* <p>
|
||||
* Convenience methods available in this class:
|
||||
* <ul>
|
||||
* <li>{@link #getSelectedRemoteFiles()}
|
||||
* <li>{@link #getFirstSelectedRemoteFile()}
|
||||
* <li>{@link #getRemoteFileSubSystem()}
|
||||
* <li>{@link #getRemoteFileSubSystemFactory()}
|
||||
* </ul>
|
||||
* <p>
|
||||
* See also the convenience methods available in the parent class {@link SystemAbstractPopupMenuExtensionAction}
|
||||
*
|
||||
* @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter
|
||||
* @see org.eclipse.rse.ui.dialogs.SystemPromptDialog
|
||||
*/
|
||||
public abstract class SystemAbstractRemoteFilePopupMenuExtensionAction
|
||||
extends SystemAbstractPopupMenuExtensionAction
|
||||
implements IObjectActionDelegate
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SystemAbstractRemoteFilePopupMenuExtensionAction()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// OVERRIDABLE METHODS FROM PARENT...
|
||||
// ----------------------------------
|
||||
|
||||
/**
|
||||
* The user has selected this action. This is where the actual code for the action goes.
|
||||
*/
|
||||
public abstract void run();
|
||||
|
||||
/**
|
||||
* The user has selected one or more objects. This is an opportunity to enable/disable
|
||||
* this action based on the current selection.
|
||||
* <p>
|
||||
* The default implementation of this method returns false if all the objects are not of
|
||||
* type IRemoteFile.
|
||||
*/
|
||||
public boolean getEnabled(Object[] currentlySelected)
|
||||
{
|
||||
for (int idx=0; idx<currentlySelected.length; idx++)
|
||||
if (!(currentlySelected[idx] instanceof IRemoteFile))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// CONVENIENCE METHODS WE ADD SPECIFICALLY FOR REMOTE FILE ACTIONS...
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Retrieve the currently selected objects as an array of IRemoteFile objects.
|
||||
* Array may be length 0, but will never be null, for convenience.
|
||||
*/
|
||||
public IRemoteFile[] getSelectedRemoteFiles()
|
||||
{
|
||||
IRemoteFile[] seld = new IRemoteFile[(sel!=null) ? sel.size() : 0];
|
||||
if (sel == null)
|
||||
return seld;
|
||||
Iterator i = sel.iterator();
|
||||
int idx=0;
|
||||
while (i.hasNext())
|
||||
seld[idx++] = (IRemoteFile)i.next();
|
||||
return seld;
|
||||
}
|
||||
/**
|
||||
* Retrieve the first selected object, as an IRemoteFile, for convenience.
|
||||
* Will be null if there is nothing selected
|
||||
*/
|
||||
public IRemoteFile getFirstSelectedRemoteFile()
|
||||
{
|
||||
//System.out.println("Sel = " + sel);
|
||||
if (sel == null)
|
||||
return null;
|
||||
Object obj = sel.getFirstElement();
|
||||
//System.out.println("obj = " + obj);
|
||||
if (obj instanceof IRemoteFile)
|
||||
return (IRemoteFile)obj;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remote file subsystem from which the selected objects were resolved.
|
||||
* This has many useful methods in it, including support to transfer files to and
|
||||
* from the local and remote systems.
|
||||
*/
|
||||
public IRemoteFileSubSystem getRemoteFileSubSystem()
|
||||
{
|
||||
return (IRemoteFileSubSystem)getSubSystem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remote file subsystem factory which owns the subsystem from which the
|
||||
* selected remote objects were resolved. This has some useful methods in it,
|
||||
* including isUnixStyle() indicating if this remote file system is unix or windows.
|
||||
*/
|
||||
public IRemoteFileSubSystemConfiguration getRemoteFileSubSystemFactory()
|
||||
{
|
||||
return (IRemoteFileSubSystemConfiguration)getSubSystemFactory();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,413 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2003, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.resources.AddToArchiveDialog;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.model.ISystemRegistry;
|
||||
import org.eclipse.rse.model.ISystemRemoteChangeEvents;
|
||||
import org.eclipse.rse.model.ISystemResourceChangeEvents;
|
||||
import org.eclipse.rse.model.SystemResourceChangeEvent;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IVirtualRemoteFile;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.view.ISystemDragDropAdapter;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* @author mjberger
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class SystemAddToArchiveAction extends SystemBaseAction
|
||||
{
|
||||
|
||||
protected List _selected;
|
||||
protected Shell _parent;
|
||||
|
||||
public SystemAddToArchiveAction(Shell parent)
|
||||
{
|
||||
super(FileResources.ACTION_ADDTOARCHIVE_LABEL, parent);
|
||||
setToolTipText(FileResources.ACTION_ADDTOARCHIVE_TOOLTIP);
|
||||
_selected = new ArrayList();
|
||||
_parent = parent;
|
||||
allowOnMultipleSelection(true);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "actn0122");
|
||||
}
|
||||
|
||||
public SystemAddToArchiveAction(Shell parent, String label, String tooltip)
|
||||
{
|
||||
super(label, tooltip, parent);
|
||||
_selected = new ArrayList();
|
||||
_parent = parent;
|
||||
allowOnMultipleSelection(true);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "actn0122");
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
boolean repeat = true;
|
||||
while (repeat)
|
||||
{
|
||||
IRemoteFile firstSelection = (IRemoteFile) _selected.get(0);
|
||||
String title = FileResources.RESID_ADDTOARCHIVE_TITLE;
|
||||
|
||||
String[] relativePaths = getRelativePaths();
|
||||
|
||||
AddToArchiveDialog dialog = new AddToArchiveDialog(getShell(), title, relativePaths);
|
||||
if (dialog == null)
|
||||
return;
|
||||
dialog.setNeedsProgressMonitor(false);
|
||||
|
||||
dialog.setMessage(FileResources.RESID_ADDTOARCHIVE_PROMPT);
|
||||
dialog.setShowNewConnectionPrompt(true);
|
||||
dialog.setShowPropertySheet(true, false);
|
||||
|
||||
dialog.setPreSelection(firstSelection);
|
||||
|
||||
dialog.setBlockOnOpen(true);
|
||||
dialog.setShowLocationPrompt(true);
|
||||
dialog.setLocationPrompt(FileResources.RESID_ADDTOARCHIVE_LOCATION);
|
||||
dialog.setNameAndTypePrompt(FileResources.RESID_ADDTOARCHIVE_NAMEANDTYPE);
|
||||
//dialog.setSelectionValidator(this);
|
||||
|
||||
int rc = dialog.open();
|
||||
|
||||
// if (rc != 0) NOT RELIABLE!
|
||||
boolean cancelled = false;
|
||||
if (dialog.wasCancelled()) cancelled = true;
|
||||
|
||||
IRemoteFile destinationArchive = null;
|
||||
IRemoteFileSubSystem destSS = null;
|
||||
boolean saveFullPathInfo;
|
||||
String relativeTo = "";
|
||||
|
||||
if (!cancelled)
|
||||
{
|
||||
destinationArchive = (IRemoteFile) dialog.getOutputObject();
|
||||
saveFullPathInfo = dialog.getSaveFullPathInfo();
|
||||
if (saveFullPathInfo) relativeTo = dialog.getRelativePath();
|
||||
destSS = destinationArchive.getParentRemoteFileSubSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (destinationArchive == null)
|
||||
{
|
||||
System.out.println("blah");
|
||||
}
|
||||
|
||||
if (ArchiveHandlerManager.isVirtual(destinationArchive.getAbsolutePath()))
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_ADDTO_VIRTUAL_DEST);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (destinationInSource(destinationArchive))
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_DEST_NOT_IN_SOURCE);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!destinationArchive.exists()) destSS.createFile(destinationArchive);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage());
|
||||
dlg.open();
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < _selected.size(); i++)
|
||||
{
|
||||
IRemoteFile selection = (IRemoteFile) _selected.get(i);
|
||||
addToArchive(selection, destinationArchive, saveFullPathInfo, relativeTo);
|
||||
}
|
||||
ISystemRegistry registry = SystemPlugin.getTheSystemRegistry();
|
||||
registry.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, destinationArchive, destinationArchive.getParentPath(), destSS, null, null);
|
||||
registry.fireEvent(new SystemResourceChangeEvent(destinationArchive, ISystemResourceChangeEvents.EVENT_REFRESH, destinationArchive.getParentPath()));
|
||||
repeat = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public void addToArchive(IRemoteFile source, IRemoteFile destinationArchive, boolean saveFullPathInfo, String relativeTo)
|
||||
{
|
||||
IRemoteFile destination = null;
|
||||
|
||||
if (destinationArchive == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!destinationArchive.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemFactory().supportsArchiveManagement())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ArchiveHandlerManager.isVirtual(destinationArchive.getAbsolutePath()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (destinationInSource(destinationArchive))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!destinationArchive.isArchive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
if (!destinationArchive.exists()) destinationArchive.getParentRemoteFileSubSystem().createFile(destinationArchive);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage());
|
||||
dlg.open();
|
||||
return;
|
||||
}
|
||||
if (saveFullPathInfo)
|
||||
{
|
||||
String selectionPath = source.getAbsolutePath();
|
||||
String destinationVirtualDirectory = selectionPath.substring(relativeTo.length());
|
||||
int lastSlash = destinationVirtualDirectory.lastIndexOf(source.getSeparatorChar());
|
||||
if (lastSlash != -1)
|
||||
{
|
||||
destinationVirtualDirectory = destinationVirtualDirectory.substring(0, lastSlash);
|
||||
destinationVirtualDirectory = ArchiveHandlerManager.cleanUpVirtualPath(destinationVirtualDirectory);
|
||||
String newDestinationPath = destinationArchive.getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + destinationVirtualDirectory;
|
||||
try
|
||||
{
|
||||
destination = destinationArchive.getParentRemoteFileSubSystem().getRemoteFileObject(newDestinationPath);
|
||||
if (!destination.exists())
|
||||
{
|
||||
destinationArchive.getParentRemoteFileSubSystem().createFolders(destination);
|
||||
}
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage());
|
||||
dlg.open();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
IRemoteFileSubSystem sourceSS = source.getParentRemoteFileSubSystem();
|
||||
|
||||
IRunnableContext runnableContext = getRunnableContext(_parent);
|
||||
|
||||
CopyRunnable runnable = new CopyRunnable(source, destination);
|
||||
try
|
||||
{
|
||||
// currently we don't run this in a thread because
|
||||
// in some cases dialogs are launched in the operation
|
||||
// (widgets can only be legally used on the main thread)
|
||||
runnableContext.run(false, true, runnable); // inthread, cancellable, IRunnableWithProgress
|
||||
}
|
||||
catch (java.lang.reflect.InvocationTargetException exc)
|
||||
{
|
||||
}
|
||||
catch (java.lang.InterruptedException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
protected class CopyRunnable implements IRunnableWithProgress
|
||||
{
|
||||
private IRemoteFileSubSystem destSS;
|
||||
private IRemoteFileSubSystem sourceSS;
|
||||
private IRemoteFile selection;
|
||||
private IRemoteFile destination;
|
||||
|
||||
public CopyRunnable(IRemoteFile source, IRemoteFile dest)
|
||||
{
|
||||
destSS = dest.getParentRemoteFileSubSystem();
|
||||
sourceSS = source.getParentRemoteFileSubSystem();
|
||||
selection = source;
|
||||
destination = dest;
|
||||
}
|
||||
|
||||
public void run(IProgressMonitor monitor)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISystemDragDropAdapter srcAdapter = (ISystemDragDropAdapter) ((IAdaptable) selection).getAdapter(ISystemDragDropAdapter.class);
|
||||
boolean sameSysType = sourceSS.getClass().equals(destSS.getClass());
|
||||
srcAdapter.doDrag(selection, sameSysType, monitor);
|
||||
boolean sameSys = (sourceSS == destSS);
|
||||
srcAdapter.doDrop(selection, destination, sameSysType, sameSys, 0, monitor);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println(e.getMessage());
|
||||
System.out.println("SystemAddToArchiveAction: Could not drag and drop " + selection.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the selection changes in the systems view. This determines
|
||||
* the input object for the command and whether to enable or disable
|
||||
* the action.
|
||||
*
|
||||
* @param selection the current seleciton
|
||||
* @return whether to enable or disable the action
|
||||
*/
|
||||
public boolean updateSelection(IStructuredSelection selection)
|
||||
{
|
||||
_selected.clear();
|
||||
boolean enable = false;
|
||||
|
||||
Iterator e = ((IStructuredSelection) selection).iterator();
|
||||
while (e.hasNext())
|
||||
{
|
||||
Object selected = e.next();
|
||||
|
||||
if (selected != null && selected instanceof IRemoteFile)
|
||||
{
|
||||
IRemoteFile file = (IRemoteFile) selected;
|
||||
_selected.add(file);
|
||||
enable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return enable;
|
||||
}
|
||||
|
||||
protected IRunnableContext getRunnableContext(Shell shell)
|
||||
{
|
||||
IRunnableContext irc = SystemPlugin.getTheSystemRegistry().getRunnableContext();
|
||||
if (irc != null)
|
||||
{
|
||||
return irc;
|
||||
}
|
||||
|
||||
return new ProgressMonitorDialog(shell);
|
||||
}
|
||||
|
||||
protected boolean destinationInSource(IRemoteFile destination)
|
||||
{
|
||||
boolean insource = false;
|
||||
for (int i = 0; i < _selected.size(); i++)
|
||||
{
|
||||
if (isAncestorOf((IRemoteFile)_selected.get(i), destination))
|
||||
{
|
||||
insource = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return insource;
|
||||
}
|
||||
|
||||
protected boolean isAncestorOf(IRemoteFile ancestor, IRemoteFile descendant)
|
||||
{
|
||||
return ancestor.isAncestorOf(descendant);
|
||||
}
|
||||
|
||||
protected String[] getRelativePaths()
|
||||
{
|
||||
IRemoteFile file = (IRemoteFile) _selected.get(0);
|
||||
if (file instanceof IVirtualRemoteFile) return null;
|
||||
IHost con = file.getSystemConnection();
|
||||
String host = con.getHostName();
|
||||
String root = file.getRoot();
|
||||
String lowestCommonPath = file.getAbsolutePath();
|
||||
boolean caseSensitive = file.getParentRemoteFileSubSystem().isCaseSensitive();
|
||||
char separator = file.getSeparatorChar();
|
||||
|
||||
for (int i = 1; i < _selected.size(); i++)
|
||||
{
|
||||
file = (IRemoteFile) _selected.get(i);
|
||||
if (file instanceof IVirtualRemoteFile) return null;
|
||||
IHost nextCon = file.getSystemConnection();
|
||||
String nextHost = nextCon.getHostName();
|
||||
String nextRoot = file.getRoot();
|
||||
String nextPath = file.getAbsolutePath();
|
||||
if (nextHost.equals(host) && nextRoot.equals(root))
|
||||
{
|
||||
lowestCommonPath = getLowestCommonPath(lowestCommonPath, nextPath, caseSensitive);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return getRelativePaths(lowestCommonPath, separator);
|
||||
}
|
||||
|
||||
protected String[] getRelativePaths(String lcp, char separator)
|
||||
{
|
||||
Vector relpaths = new Vector();
|
||||
for (int i = lcp.length() - 1; i >= 0; i--)
|
||||
{
|
||||
if (lcp.charAt(i) == separator)
|
||||
{
|
||||
relpaths.add(lcp.substring(0, i+1));
|
||||
}
|
||||
}
|
||||
String[] results = new String[relpaths.size()];
|
||||
for (int i = 0; i < relpaths.size(); i++)
|
||||
{
|
||||
results[i] = (String) relpaths.get(i);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
protected String getLowestCommonPath(String str1, String str2, boolean caseSensitive)
|
||||
{
|
||||
int maxLength = Math.min(str1.length(), str2.length());
|
||||
|
||||
for (int i = maxLength; i >= 0; i--)
|
||||
{
|
||||
if (str1.regionMatches(!caseSensitive, 0, str2, 0, i))
|
||||
{
|
||||
return str1.substring(0, i);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* Open a remote file as read-only
|
||||
*/
|
||||
public class SystemBrowseFileAction extends SystemEditFileAction {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for SystemBrowseFileAction.
|
||||
* @param text
|
||||
* @param tooltip
|
||||
* @param image
|
||||
* @param parent
|
||||
* @param editorId
|
||||
*/
|
||||
public SystemBrowseFileAction(String text, String tooltip, ImageDescriptor image, Shell parent, String editorId) {
|
||||
super(text, tooltip, image, parent, editorId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.rse.files.ui.actions.SystemEditFileAction#process(IRemoteFile)
|
||||
*/
|
||||
protected void process(IRemoteFile remoteFile) {
|
||||
SystemEditableRemoteFile editableFile = new SystemEditableRemoteFile(remoteFile, _editorId);
|
||||
editableFile.open(SystemBasePlugin.getActiveWorkbenchShell(), true);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* Open a remote file as read-only
|
||||
*/
|
||||
public class SystemBrowseFileLineAction extends SystemEditFileLineAction {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for SystemBrowseFileAction.
|
||||
* @param text
|
||||
* @param tooltip
|
||||
* @param image
|
||||
* @param parent
|
||||
* @param editorId
|
||||
* @param line
|
||||
*/
|
||||
public SystemBrowseFileLineAction(String text, String tooltip, ImageDescriptor image, Shell parent, String editorId,
|
||||
IRemoteFile remoteFile, int line, int charStart, int charEnd) {
|
||||
super(text, tooltip, image, parent, editorId, remoteFile, line, charStart, charEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.rse.files.ui.actions.SystemEditFileAction#process(IRemoteFile)
|
||||
*/
|
||||
protected void process(IRemoteFile remoteFile) {
|
||||
SystemEditableRemoteFile editableFile = new SystemEditableRemoteFile(remoteFile, _editorId);
|
||||
editableFile.open(SystemBasePlugin.getActiveWorkbenchShell(), true);
|
||||
handleGotoLine();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2003, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.resources.CombineDialog;
|
||||
import org.eclipse.rse.model.ISystemRegistry;
|
||||
import org.eclipse.rse.model.ISystemRemoteChangeEvents;
|
||||
import org.eclipse.rse.model.ISystemResourceChangeEvents;
|
||||
import org.eclipse.rse.model.SystemResourceChangeEvent;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* @author mjberger
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class SystemCombineAction extends SystemExtractToAction {
|
||||
|
||||
public SystemCombineAction(Shell parent)
|
||||
{
|
||||
super(parent, FileResources.ACTION_COMBINE_LABEL, FileResources.ACTION_COMBINE_TOOLTIP);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "actn0120");
|
||||
setImageDescriptor(SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_COMBINE_ID));
|
||||
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
boolean repeat = true;
|
||||
while (repeat)
|
||||
{
|
||||
IRemoteFile firstSelection = (IRemoteFile) _selected.get(0);
|
||||
String title = FileResources.RESID_COMBINE_TITLE;
|
||||
CombineDialog dialog = new CombineDialog(getShell(), title);
|
||||
if (dialog == null)
|
||||
return;
|
||||
dialog.setNeedsProgressMonitor(false);
|
||||
|
||||
dialog.setMessage(FileResources.RESID_COMBINE_PROMPT);
|
||||
dialog.setShowNewConnectionPrompt(true);
|
||||
dialog.setShowPropertySheet(true, false);
|
||||
dialog.setSystemTypes(systemTypes);
|
||||
|
||||
dialog.setPreSelection(firstSelection);
|
||||
|
||||
dialog.setBlockOnOpen(true);
|
||||
|
||||
int rc = dialog.open();
|
||||
|
||||
// if (rc != 0) NOT RELIABLE!
|
||||
boolean cancelled = false;
|
||||
if (dialog.wasCancelled()) cancelled = true;
|
||||
|
||||
IRemoteFile destination = null;
|
||||
IRemoteFileSubSystem destSS = null;
|
||||
if (!cancelled)
|
||||
{
|
||||
destination = (IRemoteFile) dialog.getOutputObject();
|
||||
destSS = destination.getParentRemoteFileSubSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (destination == null)
|
||||
{
|
||||
System.out.println("blah");
|
||||
}
|
||||
|
||||
if (ArchiveHandlerManager.isVirtual(destination.getAbsolutePath()))
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_COMBINETO_VIRTUAL_DEST);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (destinationInSource(destination))
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_DEST_NOT_IN_SOURCE);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!destination.exists()) destSS.createFile(destination);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
for (int i = 0; i < _selected.size(); i++)
|
||||
{
|
||||
IRemoteFile selection = (IRemoteFile) _selected.get(i);
|
||||
IRemoteFileSubSystem sourceSS = selection.getParentRemoteFileSubSystem();
|
||||
|
||||
IRunnableContext runnableContext = getRunnableContext(_parent);
|
||||
String nextName = selection.getName();
|
||||
int j = nextName.lastIndexOf(".");
|
||||
if (j != -1)
|
||||
{
|
||||
nextName = nextName.substring(0, j);
|
||||
}
|
||||
String nextDest = destination.getAbsolutePath() + ArchiveHandlerManager.VIRTUAL_SEPARATOR + nextName;
|
||||
IRemoteFile nextDestination = null;
|
||||
try
|
||||
{
|
||||
while (destSS.getRemoteFileObject(nextDest).exists())
|
||||
{
|
||||
nextDest = nextDest + "1";
|
||||
}
|
||||
nextDestination = destSS.getRemoteFileObject(nextDest);
|
||||
destSS.createFolder(nextDestination);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage());
|
||||
dlg.open();
|
||||
return;
|
||||
}
|
||||
|
||||
ExtractRunnable runnable = new ExtractRunnable(selection, nextDestination);
|
||||
try
|
||||
{
|
||||
// currently we don't run this in a thread because
|
||||
// in some cases dialogs are launched in the operation
|
||||
// (widgets can only be legally used on the main thread)
|
||||
runnableContext.run(false, true, runnable); // inthread, cancellable, IRunnableWithProgress
|
||||
}
|
||||
catch (java.lang.reflect.InvocationTargetException exc)
|
||||
{
|
||||
}
|
||||
catch (java.lang.InterruptedException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
ISystemRegistry registry = SystemPlugin.getTheSystemRegistry();
|
||||
registry.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, destination, destination.getParentPath(), destSS, null, null);
|
||||
registry.fireEvent(new SystemResourceChangeEvent(destination, ISystemResourceChangeEvents.EVENT_REFRESH, destination.getParentPath()));
|
||||
repeat = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.compare.CompareConfiguration;
|
||||
import org.eclipse.compare.CompareUI;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.compare.SystemCompareInput;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Compare two remote files
|
||||
*/
|
||||
public class SystemCompareFilesAction extends SystemBaseAction
|
||||
{
|
||||
|
||||
|
||||
private List _selected;
|
||||
|
||||
/**
|
||||
* Constructor for SystemCompareFilesAction
|
||||
* @param parent
|
||||
*/
|
||||
public SystemCompareFilesAction(Shell parent)
|
||||
{
|
||||
super(FileResources.ACTION_COMPAREWITH_EACH_LABEL, parent);
|
||||
setToolTipText(FileResources.ACTION_COMPAREWITH_EACH_TOOLTIP);
|
||||
_selected = new ArrayList();
|
||||
allowOnMultipleSelection(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two remote files
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
CompareConfiguration cc = new CompareConfiguration();
|
||||
cc.setProperty("org.eclipse.compare.internal.CONFIRM_SAVE_PROPERTY", new Boolean(false));
|
||||
SystemCompareInput fInput = new SystemCompareInput(cc);
|
||||
|
||||
for (int i = 0; i < _selected.size(); i++)
|
||||
{
|
||||
IRemoteFile file = (IRemoteFile) _selected.get(i);
|
||||
SystemEditableRemoteFile ef = new SystemEditableRemoteFile(file);
|
||||
fInput.addRemoteEditable(ef);
|
||||
}
|
||||
|
||||
CompareUI.openCompareEditor(fInput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the selection changes in the systems view. This determines
|
||||
* the input object for the command and whether to enable or disable
|
||||
* the action.
|
||||
*
|
||||
* @param selection the current seleciton
|
||||
* @return whether to enable or disable the action
|
||||
*/
|
||||
public boolean updateSelection(IStructuredSelection selection)
|
||||
{
|
||||
_selected.clear();
|
||||
boolean enable = false;
|
||||
|
||||
Iterator e = ((IStructuredSelection) selection).iterator();
|
||||
while (e.hasNext())
|
||||
{
|
||||
Object selected = e.next();
|
||||
|
||||
if (selected != null && selected instanceof IRemoteFile)
|
||||
{
|
||||
IRemoteFile file = (IRemoteFile) selected;
|
||||
if (file.isFile())
|
||||
{
|
||||
_selected.add(file);
|
||||
if (_selected.size() == 2)
|
||||
{
|
||||
enable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
enable = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return enable;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.compare.internal.ICompareContextIds;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
public class SystemCompareWithEditionAction extends SystemEditionAction
|
||||
{
|
||||
|
||||
public SystemCompareWithEditionAction(Shell parent)
|
||||
{
|
||||
super(parent,
|
||||
FileResources.ACTION_COMPAREWITH_HISTORY_LABEL,
|
||||
FileResources.ACTION_COMPAREWITH_HISTORY_TOOLTIP,
|
||||
"org.eclipse.compare.internal.CompareWithEditionAction",
|
||||
false);
|
||||
|
||||
this.fHelpContextId= ICompareContextIds.COMPARE_WITH_EDITION_DIALOG;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2003, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.resources.CombineDialog;
|
||||
import org.eclipse.rse.model.ISystemRegistry;
|
||||
import org.eclipse.rse.model.ISystemRemoteChangeEvents;
|
||||
import org.eclipse.rse.model.ISystemResourceChangeEvents;
|
||||
import org.eclipse.rse.model.SystemResourceChangeEvent;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author mjberger
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class SystemConvertAction extends SystemExtractToAction {
|
||||
|
||||
public SystemConvertAction(Shell parent)
|
||||
{
|
||||
super(parent, FileResources.ACTION_CONVERT_LABEL, FileResources.ACTION_CONVERT_TOOLTIP);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "actn0121");
|
||||
setImageDescriptor(SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CONVERT_ID));
|
||||
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
for (int i = 0; i < _selected.size(); i++)
|
||||
{
|
||||
IRemoteFile selection = (IRemoteFile) _selected.get(i);
|
||||
String title = FileResources.RESID_CONVERT_TITLE;
|
||||
CombineDialog dialog = new CombineDialog(getShell(), title, true);
|
||||
if (dialog == null)
|
||||
return;
|
||||
dialog.setNeedsProgressMonitor(false);
|
||||
String message = SystemMessage.sub(FileResources.RESID_CONVERT_PROMPT, "&1", selection.getAbsolutePath());
|
||||
dialog.setMessage(message);
|
||||
dialog.setShowNewConnectionPrompt(true);
|
||||
dialog.setShowPropertySheet(true, false);
|
||||
dialog.setSystemTypes(systemTypes);
|
||||
|
||||
dialog.setPreSelection(selection);
|
||||
|
||||
dialog.setBlockOnOpen(true);
|
||||
dialog.setHelp(SystemPlugin.HELPPREFIX + "cnvd0000");
|
||||
dialog.setShowLocationPrompt(true);
|
||||
dialog.setLocationPrompt(FileResources.RESID_CONVERT_LOCATION);
|
||||
dialog.setNameAndTypePrompt(FileResources.RESID_CONVERT_NAMEANDTYPE);
|
||||
dialog.setSelectionValidator(this);
|
||||
|
||||
int rc = dialog.open();
|
||||
|
||||
// if (rc != 0) NOT RELIABLE!
|
||||
boolean cancelled = false;
|
||||
if (dialog.wasCancelled()) cancelled = true;
|
||||
|
||||
IRemoteFile destination = null;
|
||||
IRemoteFileSubSystem destSS = null;
|
||||
if (!cancelled)
|
||||
{
|
||||
destination = (IRemoteFile) dialog.getOutputObject();
|
||||
destSS = destination.getParentRemoteFileSubSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (destination == null)
|
||||
{
|
||||
System.out.println("blah");
|
||||
}
|
||||
|
||||
if (ArchiveHandlerManager.isVirtual(destination.getAbsolutePath()))
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_CONVERTTO_VIRTUAL_DEST);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
if (!destination.canWrite())
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_DEST_TARGET_READONLY);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
if (selection.isAncestorOf(destination))
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_DEST_NOT_IN_SOURCE);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (destination.exists())
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_UPLOAD_FILE_EXISTS);
|
||||
msg.makeSubstitution(destination.getName());
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
boolean ok = dlg.openQuestionNoException();
|
||||
if (ok)
|
||||
{
|
||||
if (destination.getAbsolutePath().equals(selection.getAbsolutePath()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
destSS.delete(destination, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
destSS.createFile(destination);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage());
|
||||
dlg.open();
|
||||
continue;
|
||||
}
|
||||
IRemoteFileSubSystem sourceSS = selection.getParentRemoteFileSubSystem();
|
||||
|
||||
IRunnableContext runnableContext = getRunnableContext(_parent);
|
||||
|
||||
ExtractRunnable runnable = new ExtractRunnable(selection, destination);
|
||||
try
|
||||
{
|
||||
// currently we don't run this in a thread because
|
||||
// in some cases dialogs are launched in the operation
|
||||
// (widgets can only be legally used on the main thread)
|
||||
runnableContext.run(false, true, runnable); // inthread, cancellable, IRunnableWithProgress
|
||||
}
|
||||
catch (java.lang.reflect.InvocationTargetException exc)
|
||||
{
|
||||
}
|
||||
catch (java.lang.InterruptedException e)
|
||||
{
|
||||
}
|
||||
ISystemRegistry registry = SystemPlugin.getTheSystemRegistry();
|
||||
registry.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, destination, destination.getParentPath(), destSS, null, null);
|
||||
registry.fireEvent(new SystemResourceChangeEvent(destination, ISystemResourceChangeEvents.EVENT_REFRESH, destination.getParentPath()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,493 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog;
|
||||
import org.eclipse.rse.files.ui.resources.SystemRemoteEditManager;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.model.ISystemRemoteChangeEvents;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.util.ValidatorFileUniqueName;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.SystemResources;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseCopyAction;
|
||||
import org.eclipse.rse.ui.dialogs.SystemRenameSingleDialog;
|
||||
import org.eclipse.rse.ui.dialogs.SystemSimpleContentElement;
|
||||
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.rse.ui.view.SystemView;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* Copy selected files and folders action.
|
||||
*/
|
||||
public class SystemCopyRemoteFileAction extends SystemBaseCopyAction
|
||||
implements ISystemMessages, IValidatorRemoteSelection
|
||||
{
|
||||
protected IRemoteFile targetFolder, targetFileOrFolder = null;
|
||||
protected IRemoteFile firstSelection = null;
|
||||
protected IRemoteFile firstSelectionParent = null;
|
||||
protected IRemoteFile[] files;
|
||||
protected Vector copiedFiles = new Vector();
|
||||
protected IHost sourceConnection;
|
||||
protected IRemoteFileSubSystem ss;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SystemCopyRemoteFileAction(Shell shell)
|
||||
{
|
||||
this(shell, MODE_COPY);
|
||||
}
|
||||
/**
|
||||
* Constructor for subclass
|
||||
*/
|
||||
SystemCopyRemoteFileAction(Shell shell, int mode)
|
||||
{
|
||||
super(shell, mode);
|
||||
setHelp(SystemPlugin.HELPPREFIX+"actn0110");
|
||||
setDialogHelp(SystemPlugin.HELPPREFIX+"dcrf0000");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset. This is a re-run of this action
|
||||
*/
|
||||
protected void reset()
|
||||
{
|
||||
//System.out.println("inside remote file copy reset()");
|
||||
super.reset();
|
||||
targetFolder = null;
|
||||
targetFileOrFolder = null;
|
||||
firstSelection = null;
|
||||
firstSelectionParent = null;
|
||||
files = null;
|
||||
copiedFiles = new Vector();
|
||||
sourceConnection = null;
|
||||
ss = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* We override from parent to do unique checking...
|
||||
* <p>
|
||||
* We simply ensure every selected object is an IRemoteFile
|
||||
* <p>
|
||||
* @see SystemBaseAction#updateSelection(IStructuredSelection)
|
||||
*/
|
||||
public boolean updateSelection(IStructuredSelection selection)
|
||||
{
|
||||
boolean enable = true;
|
||||
Iterator e= ((IStructuredSelection) selection).iterator();
|
||||
while (enable && e.hasNext())
|
||||
{
|
||||
Object selectedObject = e.next();
|
||||
if (!(selectedObject instanceof IRemoteFile))
|
||||
enable = false;
|
||||
}
|
||||
return enable;
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
// PARENT METHOD OVERRIDES...
|
||||
// --------------------------
|
||||
|
||||
/**
|
||||
* @see SystemBaseCopyAction#checkForCollision(Shell, IProgressMonitor, Object, Object, String)
|
||||
* @param shell Window to host dialog
|
||||
* @param monitor Usually not needed
|
||||
* @param targetContainer will be the IRemoteFile folder selected to copy into
|
||||
* @param oldObject will be the IRemoteFile object currently being copied
|
||||
* @param oldName will be the name of the IRemoteFile object currently being copied
|
||||
*/
|
||||
protected String checkForCollision(Shell shell, IProgressMonitor monitor,
|
||||
Object targetContainer, Object oldObject, String oldName)
|
||||
{
|
||||
String newName = oldName;
|
||||
|
||||
try {
|
||||
targetFolder = (IRemoteFile)targetContainer;
|
||||
ss = targetFolder.getParentRemoteFileSubSystem();
|
||||
targetFileOrFolder = ss.getRemoteFileObject(targetFolder, oldName);
|
||||
|
||||
|
||||
//SystemPlugin.logInfo("CHECKING FOR COLLISION ON '"+srcFileOrFolder.getAbsolutePath() + "' IN '" +targetFolder.getAbsolutePath()+"'");
|
||||
//SystemPlugin.logInfo("...TARGET FILE: '"+tgtFileOrFolder.getAbsolutePath()+"'");
|
||||
//SystemPlugin.logInfo("...target.exists()? "+tgtFileOrFolder.exists());
|
||||
if (targetFileOrFolder.exists())
|
||||
{
|
||||
//monitor.setVisible(false); wish we could!
|
||||
|
||||
// we no longer have to set the validator here... the common rename dialog we all now use queries the input
|
||||
// object's system view adaptor for its name validator. See getNameValidator in SystemViewRemoteFileAdapter. phil
|
||||
ValidatorFileUniqueName validator = null; // new ValidatorFileUniqueName(shell, targetFolder, srcFileOrFolder.isDirectory());
|
||||
//SystemCollisionRenameDialog dlg = new SystemCollisionRenameDialog(shell, validator, oldName);
|
||||
SystemRenameSingleDialog dlg = new SystemRenameSingleDialog(shell, true, targetFileOrFolder, validator); // true => copy-collision-mode
|
||||
dlg.open();
|
||||
if (!dlg.wasCancelled())
|
||||
newName = dlg.getNewName();
|
||||
else
|
||||
newName = null;
|
||||
}
|
||||
} catch (SystemMessageException e) {
|
||||
SystemBasePlugin.logError("SystemCopyRemoteFileAction.checkForCollision()", e);
|
||||
}
|
||||
|
||||
return newName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see SystemBaseCopyAction#doCopy(IProgressMonitor, Object, Object, String)
|
||||
* @param monitor Usually not needed
|
||||
* @param targetContainer will be the IRemoteFile folder selected to copy into
|
||||
* @param oldObject will be the IRemoteFile object currently being copied
|
||||
* @param newName will be the new name to give the oldObject on copy
|
||||
*/
|
||||
protected boolean doCopy(IProgressMonitor monitor, Object targetContainer, Object oldObject, String newName)
|
||||
throws Exception
|
||||
{
|
||||
targetFolder = (IRemoteFile)targetContainer;
|
||||
IRemoteFile srcFileOrFolder = (IRemoteFile)oldObject;
|
||||
|
||||
IHost targetConnection = targetFolder.getSystemConnection();
|
||||
IHost srcConnection = srcFileOrFolder.getSystemConnection();
|
||||
|
||||
boolean ok = false;
|
||||
if (targetConnection == srcConnection)
|
||||
{
|
||||
ss = targetFolder.getParentRemoteFileSubSystem();
|
||||
|
||||
|
||||
ok = ss.copy(srcFileOrFolder, targetFolder, newName, null);
|
||||
if (!ok)
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(FILEMSG_COPY_FILE_FAILED);
|
||||
msg.makeSubstitution(srcFileOrFolder.getName());
|
||||
throw new SystemMessageException(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
String sep = targetFolder.getSeparator();
|
||||
String targetFolderName = targetFolder.getAbsolutePath();
|
||||
if (!targetFolderName.endsWith(sep))
|
||||
copiedFiles.addElement(targetFolderName+sep+newName);
|
||||
else
|
||||
copiedFiles.addElement(targetFolderName+newName);
|
||||
}
|
||||
}
|
||||
// DKM - for cross system copy
|
||||
else
|
||||
{
|
||||
IRemoteFileSubSystem targetFS = targetFolder.getParentRemoteFileSubSystem();
|
||||
IRemoteFileSubSystem srcFS = srcFileOrFolder.getParentRemoteFileSubSystem();
|
||||
String newPath = targetFolder.getAbsolutePath() + "/" + newName;
|
||||
if (srcFileOrFolder.isFile())
|
||||
{
|
||||
SystemRemoteEditManager mgr = SystemRemoteEditManager.getDefault();
|
||||
// if remote edit project doesn't exist, create it
|
||||
if (!mgr.doesRemoteEditProjectExist())
|
||||
mgr.getRemoteEditProject();
|
||||
|
||||
StringBuffer path = new StringBuffer(mgr.getRemoteEditProjectLocation().makeAbsolute().toOSString());
|
||||
path = path.append("/" + srcFS.getSystemProfileName() + "/" + srcFS.getHostAliasName() + "/");
|
||||
|
||||
String absolutePath = srcFileOrFolder.getAbsolutePath();
|
||||
|
||||
|
||||
int colonIndex = absolutePath.indexOf(IPath.DEVICE_SEPARATOR);
|
||||
|
||||
if (colonIndex != -1)
|
||||
{
|
||||
if (colonIndex == 0)
|
||||
{
|
||||
absolutePath = absolutePath.substring(1);
|
||||
}
|
||||
else if (colonIndex == (absolutePath.length() - 1))
|
||||
{
|
||||
absolutePath = absolutePath.substring(0, colonIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
absolutePath = absolutePath.substring(0, colonIndex) + absolutePath.substring(colonIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
path = path.append(absolutePath);
|
||||
|
||||
String tempFile = path.toString();
|
||||
|
||||
srcFS.download(srcFileOrFolder, tempFile, null);
|
||||
targetFS.upload(tempFile, newPath, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
IRemoteFile newTargetFolder = targetFS.getRemoteFileObject(newPath);
|
||||
targetFS.createFolder(newTargetFolder);
|
||||
IRemoteFile[] children = srcFS.listFoldersAndFiles(srcFileOrFolder);
|
||||
if (children != null)
|
||||
{
|
||||
for (int i = 0; i < children.length; i++)
|
||||
{
|
||||
IRemoteFile child = children[i];
|
||||
monitor.subTask("copying " + child.getName());
|
||||
doCopy(monitor, newTargetFolder, child, child.getName());
|
||||
monitor.worked(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Required parent class abstract method.
|
||||
* Does not apply to us as we supply our own dialog for the copy-target
|
||||
*/
|
||||
protected SystemSimpleContentElement getTreeModel()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Required parent class abstract method.
|
||||
* Does not apply to us as we supply our own dialog for the copy-target
|
||||
*/
|
||||
protected SystemSimpleContentElement getTreeInitialSelection()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SystemBaseCopyAction#getOldObjects()
|
||||
* Returns an array of IRemoteFile objects
|
||||
*/
|
||||
protected Object[] getOldObjects()
|
||||
{
|
||||
return getSelectedFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SystemBaseCopyAction#getOldNames()
|
||||
*/
|
||||
protected String[] getOldNames()
|
||||
{
|
||||
IRemoteFile[] files = getSelectedFiles();
|
||||
String[] names = new String[files.length];
|
||||
for (int idx=0; idx<files.length; idx++)
|
||||
names[idx] = files[idx].getName();
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Override of parent.
|
||||
* Return the dialog that will be used to prompt for the copy/move target location.
|
||||
*/
|
||||
protected Dialog createDialog(Shell shell)
|
||||
{
|
||||
++runCount;
|
||||
if (runCount > 1)
|
||||
reset();
|
||||
//return new SystemSimpleCopyDialog(parent, getPromptString(), mode, this, getTreeModel(), getTreeInitialSelection());
|
||||
String dlgTitle = (mode==MODE_COPY ? SystemResources.RESID_COPY_TITLE : SystemResources.RESID_MOVE_TITLE);
|
||||
SystemSelectRemoteFileOrFolderDialog dlg = new SystemSelectRemoteFileOrFolderDialog(shell,dlgTitle,SystemSelectRemoteFileOrFolderDialog.FOLDER_MODE);
|
||||
dlg.setNeedsProgressMonitor(true);
|
||||
dlg.setMessage(getPromptString());
|
||||
dlg.setShowNewConnectionPrompt(false);
|
||||
dlg.setShowPropertySheet(true, false);
|
||||
firstSelection = getFirstSelectedFile();
|
||||
sourceConnection = firstSelection.getSystemConnection();
|
||||
dlg.setSystemConnection(sourceConnection);
|
||||
if (mode==MODE_MOVE)
|
||||
dlg.setSelectionValidator(this);
|
||||
//SystemPlugin.logInfo("Calling getParentRemoteFile for '"+firstSelection.getAbsolutePath()+"'");
|
||||
firstSelectionParent = firstSelection.getParentRemoteFile();
|
||||
/*
|
||||
if (firstSelectionParent != null)
|
||||
SystemPlugin.logInfo("Result of getParentRemoteFile: '"+firstSelectionParent.getAbsolutePath()+"'");
|
||||
else
|
||||
SystemPlugin.logInfo("Result of getParentRemoteFile: null");
|
||||
*/
|
||||
dlg.setPreSelection(firstSelectionParent);
|
||||
|
||||
// our title now reflects multiple selection. If single change it.
|
||||
IStructuredSelection sel = getSelection();
|
||||
//System.out.println("size = "+sel.size());
|
||||
if (sel.size() == 1)
|
||||
{
|
||||
String singleTitle = null;
|
||||
if (mode == MODE_COPY)
|
||||
singleTitle = SystemResources.RESID_COPY_SINGLE_TITLE;
|
||||
else
|
||||
singleTitle = SystemResources.RESID_MOVE_SINGLE_TITLE;
|
||||
//System.out.println("..."+singleTitle);
|
||||
if (!singleTitle.startsWith("Missing")) // TODO: remove test after next mri rev
|
||||
dlg.setTitle(singleTitle);
|
||||
}
|
||||
return dlg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method if you supply your own copy/move target dialog.
|
||||
* Return the user-selected target or null if cancelled
|
||||
*/
|
||||
protected Object getTargetContainer(Dialog dlg)
|
||||
{
|
||||
SystemSelectRemoteFileOrFolderDialog cpyDlg = (SystemSelectRemoteFileOrFolderDialog)dlg;
|
||||
Object targetContainer = null;
|
||||
if (!cpyDlg.wasCancelled())
|
||||
targetContainer = cpyDlg.getSelectedObject();
|
||||
return targetContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after all the copy/move operations end, be it successfully or not.
|
||||
* Your opportunity to display completion or do post-copy selections/refreshes
|
||||
*/
|
||||
public void copyComplete()
|
||||
{
|
||||
if (copiedFiles.size() == 0)
|
||||
return;
|
||||
|
||||
// refresh all instances of this parent, and all affected filters...
|
||||
ISubSystem fileSS = targetFolder.getParentRemoteFileSubSystem();
|
||||
Viewer originatingViewer = null;
|
||||
if (getViewer() instanceof Viewer)
|
||||
{
|
||||
originatingViewer = (Viewer)getViewer();
|
||||
if (!targetFolder.getAbsolutePath().equals(firstSelectionParent.getAbsolutePath()))
|
||||
{
|
||||
// we select the first instance of the target folder now so that the copied members will be selected in it
|
||||
// after it is refreshed via the remote_resource_created event.
|
||||
if (originatingViewer instanceof SystemView)
|
||||
{
|
||||
boolean selectedOk = ((SystemView)originatingViewer).selectRemoteObjects(targetFolder.getAbsolutePath(), fileSS, null);
|
||||
//System.out.println(targetFolder.getAbsolutePath()+" selectedOK? " + selectedOk);
|
||||
//if (selectedOk)
|
||||
// return;
|
||||
}
|
||||
}
|
||||
}
|
||||
SystemPlugin.getTheSystemRegistry().fireRemoteResourceChangeEvent(
|
||||
ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, copiedFiles, targetFolder.getAbsolutePath(), fileSS, null, originatingViewer);
|
||||
|
||||
/* Old release 1.0 way...
|
||||
// did they copy to the same parent? Just refresh that parent, whatever it is...
|
||||
if (targetFolder.getAbsolutePath().equals(firstSelectionParent.getAbsolutePath()))
|
||||
{
|
||||
Viewer v = getViewer();
|
||||
if (v instanceof ISystemTree)
|
||||
{
|
||||
SystemRegistry sr = SystemPlugin.getTheSystemRegistry();
|
||||
ISystemTree tree = (ISystemTree)v;
|
||||
Object parent = tree.getSelectedParent();
|
||||
if (parent == null)
|
||||
return;
|
||||
if (parent instanceof IRemoteFile)
|
||||
// refresh parent in all views...
|
||||
sr.fireEvent(
|
||||
new org.eclipse.rse.model.SystemResourceChangeEvent(
|
||||
parent,ISystemResourceChangeEvent.EVENT_REFRESH_REMOTE, null)
|
||||
);
|
||||
else
|
||||
// refresh parent in all views...
|
||||
sr.fireEvent(
|
||||
new org.eclipse.rse.model.SystemResourceChangeEvent(
|
||||
parent,ISystemResourceChangeEvent.EVENT_REFRESH, null)
|
||||
);
|
||||
// select new files in this view only
|
||||
sr.fireEvent((ISystemResourceChangeListener)v,
|
||||
new org.eclipse.rse.model.SystemResourceChangeEvent(
|
||||
copiedFiles,ISystemResourceChangeEvent.EVENT_SELECT_REMOTE, targetFolder)
|
||||
);
|
||||
}
|
||||
}
|
||||
// they copied somewhere else... a little more work...
|
||||
else
|
||||
{
|
||||
// refresh target folder in all views, but only select new files in this view...
|
||||
org.eclipse.rse.model.SystemResourceChangeEvent event =
|
||||
new org.eclipse.rse.model.SystemResourceChangeEvent(
|
||||
targetFolder,ISystemResourceChangeEvent.EVENT_REFRESH_REMOTE, copiedFiles);
|
||||
event.setOriginatingViewer(getViewer());
|
||||
sr.fireEvent(event);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// ------------------
|
||||
// PRIVATE METHODS...
|
||||
// ------------------
|
||||
|
||||
/**
|
||||
* Get the currently selected IRemoteFile objects
|
||||
*/
|
||||
protected IRemoteFile[] getSelectedFiles()
|
||||
{
|
||||
if (files == null)
|
||||
{
|
||||
IStructuredSelection selection = (IStructuredSelection)getSelection();
|
||||
files = new IRemoteFile[selection.size()];
|
||||
Iterator i = selection.iterator();
|
||||
int idx=0;
|
||||
while (i.hasNext())
|
||||
{
|
||||
files[idx++] = (IRemoteFile)i.next();
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
/**
|
||||
* Get the first selected file or folder
|
||||
*/
|
||||
protected IRemoteFile getFirstSelectedFile()
|
||||
{
|
||||
if (files == null)
|
||||
getSelectedFiles();
|
||||
if (files.length > 0)
|
||||
return files[0];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The user has selected a remote object. Return null if OK is to be enabled, or a SystemMessage
|
||||
* if it is not to be enabled. The message will be displayed on the message line.
|
||||
* <p>
|
||||
* This is overridden in SystemMoveRemoteFileAction
|
||||
*/
|
||||
public SystemMessage isValid(IHost selectedConnection, Object[] selectedObjects, ISystemRemoteElementAdapter[] remoteAdaptersForSelectedObjects)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,271 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
||||
import org.eclipse.rse.ui.SystemMenuManager;
|
||||
import org.eclipse.rse.ui.SystemResources;
|
||||
import org.eclipse.rse.ui.actions.SystemSeparatorAction;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorDescriptor;
|
||||
import org.eclipse.ui.IEditorRegistry;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
|
||||
/**
|
||||
* Class for creating edit actions
|
||||
* @deprecated - use <code>SystemRemoteFileOpenWithMenu</code> now
|
||||
*
|
||||
*/
|
||||
public class SystemCreateEditActions
|
||||
{
|
||||
|
||||
|
||||
protected IEditorRegistry registry;
|
||||
|
||||
/*
|
||||
* Compares the labels from two IEditorDescriptor objects
|
||||
*/
|
||||
private static final Comparator comparer = new Comparator() {
|
||||
private Collator collator = Collator.getInstance();
|
||||
|
||||
public int compare(Object arg0, Object arg1) {
|
||||
String s1 = ((IEditorDescriptor)arg0).getLabel();
|
||||
String s2 = ((IEditorDescriptor)arg1).getLabel();
|
||||
return collator.compare(s1, s2);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor for CreateEditActions
|
||||
*/
|
||||
public SystemCreateEditActions() {
|
||||
super();
|
||||
registry = PlatformUI.getWorkbench().getEditorRegistry();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create edit actions
|
||||
*/
|
||||
public void create(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
|
||||
{
|
||||
|
||||
if (selection.size() <= 0)
|
||||
return;
|
||||
|
||||
// create basic open
|
||||
createForAnySelection(menu, selection, shell, menuGroup);
|
||||
|
||||
|
||||
// create open with->
|
||||
if (selection.size() == 1)
|
||||
{
|
||||
createForSingleSelection(menu, selection.getFirstElement(), shell, menuGroup);
|
||||
}
|
||||
else
|
||||
{ // editing is only allowed when there is only one selection
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void createForAnySelection(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup)
|
||||
{
|
||||
String label = SystemResources.ACTION_CASCADING_OPEN_LABEL;
|
||||
String tooltip = SystemResources.ACTION_CASCADING_OPEN_TOOLTIP;
|
||||
SystemEditFilesAction action = new SystemEditFilesAction(label, tooltip, shell);
|
||||
|
||||
// add action
|
||||
menu.add(ISystemContextMenuConstants.GROUP_OPEN, action);
|
||||
}
|
||||
|
||||
|
||||
protected IEditorRegistry getEditorRegistry()
|
||||
{
|
||||
return SystemPlugin.getDefault().getWorkbench().getEditorRegistry();
|
||||
}
|
||||
|
||||
protected IEditorDescriptor getDefaultTextEditor()
|
||||
{
|
||||
IEditorRegistry registry = getEditorRegistry();
|
||||
return registry.findEditor("org.eclipse.ui.DefaultTextEditor");
|
||||
}
|
||||
/**
|
||||
* Create actions when one file has been selected.
|
||||
*/
|
||||
public void createForSingleSelection(SystemMenuManager menu, Object element, Shell shell, String menuGroup) {
|
||||
IRemoteFile remoteFile = null;
|
||||
|
||||
if ((element == null) || !(element instanceof IRemoteFile)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
remoteFile = (IRemoteFile)element;
|
||||
}
|
||||
|
||||
IEditorDescriptor defaultEditor = getDefaultTextEditor();
|
||||
|
||||
IEditorDescriptor preferredEditor = getPreferredEditor(remoteFile); // may be null
|
||||
|
||||
Object[] editors = registry.getEditors(remoteFile.getName());
|
||||
Collections.sort(Arrays.asList(editors), comparer);
|
||||
|
||||
boolean defaultFound = false;
|
||||
|
||||
//Check that we don't add it twice. This is possible
|
||||
//if the same editor goes to two mappings.
|
||||
ArrayList alreadyMapped = new ArrayList();
|
||||
|
||||
for (int i = 0; i < editors.length; i++) {
|
||||
|
||||
IEditorDescriptor editor = (IEditorDescriptor) editors[i];
|
||||
|
||||
if (!alreadyMapped.contains(editor)) {
|
||||
|
||||
createEditAction(menu, shell, remoteFile, editor, preferredEditor);
|
||||
|
||||
// remember if we find default text editor
|
||||
if (defaultEditor != null && editor.getId().equals(defaultEditor.getId())) {
|
||||
defaultFound = true;
|
||||
}
|
||||
|
||||
alreadyMapped.add(editor);
|
||||
}
|
||||
}
|
||||
|
||||
// only add a separator if there are associated editors
|
||||
if (editors.length > 0) {
|
||||
SystemSeparatorAction sep = new SystemSeparatorAction(shell);
|
||||
menu.add(ISystemContextMenuConstants.GROUP_OPENWITH, sep);
|
||||
}
|
||||
|
||||
// add default text editor if it was not already associated
|
||||
if (!defaultFound && defaultEditor != null) {
|
||||
createEditAction(menu, shell, remoteFile, defaultEditor, preferredEditor);
|
||||
}
|
||||
|
||||
// add system editor (should never be null)
|
||||
IEditorDescriptor descriptor = registry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
|
||||
createEditAction(menu, shell, remoteFile, descriptor, preferredEditor);
|
||||
|
||||
/* DKM - 56067
|
||||
// add system in-place editor (can be null)
|
||||
descriptor = registry.findEditor(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID);
|
||||
|
||||
if (descriptor != null) {
|
||||
createEditAction(menu, shell, remoteFile, descriptor, preferredEditor);
|
||||
}
|
||||
*/
|
||||
|
||||
// TODO: default action
|
||||
// createDefaultEditAction(menu, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an edit action for a specific editor. If the editor is the preferred editor, then it is selected.
|
||||
* @param menu the menu manager.
|
||||
* @param shell the shell.
|
||||
* @param remoteFile the remote file.
|
||||
* @param descriptor the editor descriptor.
|
||||
* @param preferredEditor the descriptor of the preferred editor, or <code>null</code>.
|
||||
*/
|
||||
private void createEditAction(SystemMenuManager menu, Shell shell, IRemoteFile remoteFile, IEditorDescriptor descriptor, final IEditorDescriptor preferredEditor) {
|
||||
String editorId = descriptor.getId();
|
||||
|
||||
String label = descriptor.getLabel();
|
||||
ImageDescriptor image = getImageDescriptor(remoteFile, descriptor);
|
||||
|
||||
// create action
|
||||
SystemEditFileAction action = new SystemEditFileAction(label, label, image, IAction.AS_RADIO_BUTTON, shell, editorId);
|
||||
|
||||
// check if editor is the preferred editor
|
||||
boolean isPreferred = preferredEditor != null && editorId.equals(preferredEditor.getId());
|
||||
|
||||
// mark action as checked or not
|
||||
action.setChecked(isPreferred);
|
||||
|
||||
// add action
|
||||
menu.add(ISystemContextMenuConstants.GROUP_OPENWITH, action);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the preferred editor for the remote file. If the remote file has a cached local resource,
|
||||
* then returns the default editor associated with that resource, by calling <code>IDE.getDefaultEditor(IFile)</code>.
|
||||
* Otherwise, get the default editor associated with that remote file name from the editor registry.
|
||||
* @param remoteFile the remote file.
|
||||
* @return the preferred editor for the remote file, or <code>null</code> if none.
|
||||
*/
|
||||
private IEditorDescriptor getPreferredEditor(IRemoteFile remoteFile) {
|
||||
|
||||
IFile localFile = getLocalResource(remoteFile);
|
||||
|
||||
if (localFile == null) {
|
||||
return registry.getDefaultEditor(remoteFile.getName());
|
||||
}
|
||||
else {
|
||||
return IDE.getDefaultEditor(localFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the local cache of the remote file, or <code>null</code> if none.
|
||||
* @param remoteFile the remote file.
|
||||
* @return the local cached resource, or <code>null</code> if none.
|
||||
*/
|
||||
private IFile getLocalResource(IRemoteFile remoteFile)
|
||||
{
|
||||
return (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image descriptor for the given editor descriptor. If the editor descriptor is
|
||||
* <code>null</code>, returns the image descriptor for the remote file name.
|
||||
* @param remoteFile the remote file.
|
||||
*/
|
||||
private ImageDescriptor getImageDescriptor(IRemoteFile remoteFile, IEditorDescriptor editorDesc) {
|
||||
ImageDescriptor imageDesc = null;
|
||||
|
||||
if (editorDesc == null) {
|
||||
imageDesc = registry.getImageDescriptor(remoteFile.getName());
|
||||
}
|
||||
else {
|
||||
imageDesc = editorDesc.getImageDescriptor();
|
||||
}
|
||||
|
||||
if (imageDesc == null) {
|
||||
|
||||
if (editorDesc.getId().equals(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID))
|
||||
imageDesc = registry.getSystemExternalEditorImageDescriptor(remoteFile.getName());
|
||||
}
|
||||
|
||||
return imageDesc;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.ui.IEditorDescriptor;
|
||||
import org.eclipse.ui.IEditorRegistry;
|
||||
|
||||
|
||||
public class SystemDoubleClickEditAction extends SystemBaseAction
|
||||
{
|
||||
|
||||
|
||||
|
||||
private Object element;
|
||||
|
||||
/**
|
||||
* Constructor for SystemDoubleClickEditAction
|
||||
*/
|
||||
public SystemDoubleClickEditAction(Object element)
|
||||
{
|
||||
super(null, null);
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
protected IEditorRegistry getEditorRegistry()
|
||||
{
|
||||
return SystemPlugin.getDefault().getWorkbench().getEditorRegistry();
|
||||
}
|
||||
|
||||
protected IEditorDescriptor getDefaultTextEditor()
|
||||
{
|
||||
IEditorRegistry registry = getEditorRegistry();
|
||||
return registry.findEditor("org.eclipse.ui.DefaultTextEditor");
|
||||
}
|
||||
/**
|
||||
* @see SystemBaseAction#run()
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
|
||||
IRemoteFile remoteFile = null;
|
||||
|
||||
if ((element == null) || !(element instanceof IRemoteFile))
|
||||
return;
|
||||
else
|
||||
remoteFile = (IRemoteFile) element;
|
||||
|
||||
/* DKM - use Eclipse default, instead
|
||||
// open LPEX editor on double click if remote file is a text file
|
||||
if (remoteFile.isText()) {
|
||||
IEditorRegistry registry = WorkbenchPlugin.getDefault().getEditorRegistry();
|
||||
IEditorDescriptor descriptor = registry.findEditor(ISystemTextEditorConstants.SYSTEM_TEXT_EDITOR_ID);
|
||||
String id = descriptor.getId();
|
||||
SystemEditFileAction editAction = new SystemEditFileAction(null, null, null, null, id);
|
||||
editAction.setSelection(new StructuredSelection(element));
|
||||
editAction.run();
|
||||
}
|
||||
else { // open the system editor on double click if remote file is a text file
|
||||
SystemEditFilePlatformAction platformEditAction = new SystemEditFilePlatformAction(null, null, null, null);
|
||||
platformEditAction.setSelection(new StructuredSelection(element));
|
||||
platformEditAction.run();
|
||||
}
|
||||
*/
|
||||
|
||||
// DKM, use Eclipse default
|
||||
String fileName = remoteFile.getName();
|
||||
IEditorRegistry registry = getEditorRegistry();
|
||||
IEditorDescriptor descriptor = registry.getDefaultEditor(fileName);
|
||||
if (descriptor == null)
|
||||
{
|
||||
descriptor = registry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
|
||||
|
||||
}
|
||||
String id = descriptor.getId();
|
||||
SystemEditFileAction editAction = new SystemEditFileAction(null, null, null, null, id);
|
||||
editAction.setSelection(new StructuredSelection(element));
|
||||
editAction.run();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,293 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.resources.SystemIFileProperties;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
|
||||
/**
|
||||
* This is the default action used to handle download conflicts
|
||||
*/
|
||||
public class SystemDownloadConflictAction extends SystemBaseAction implements Runnable
|
||||
{
|
||||
|
||||
/**
|
||||
* This is the default dialog used to handle download conflicts
|
||||
*/
|
||||
protected class DownloadConflictDialog extends SystemPromptDialog implements ISystemMessages
|
||||
{
|
||||
private Button _keepLocalButton;
|
||||
private Button _replaceLocalButton;
|
||||
|
||||
private boolean _keepLocal;
|
||||
private String _openLocalText;
|
||||
private String _replaceText;
|
||||
private String _dialogText;
|
||||
private String _helpId;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param shell the parent shell of the dialog
|
||||
* @param remoteNewer indicates whether the remote file has changed since it was last downloaded
|
||||
*/
|
||||
public DownloadConflictDialog(Shell shell, boolean remoteNewer)
|
||||
{
|
||||
super(shell, FileResources.RESID_CONFLICT_DOWNLOAD_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether the user decided to keep the local cached file
|
||||
* @returns the whether the user decided to keep the local cached file
|
||||
*/
|
||||
public boolean keepLocal()
|
||||
{
|
||||
return _keepLocal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a button is pressed in the dialog
|
||||
*/
|
||||
protected void buttonPressed(int buttonId)
|
||||
{
|
||||
setReturnCode(buttonId);
|
||||
_keepLocal = _keepLocalButton.getSelection();
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the dialog content
|
||||
*/
|
||||
public Control createInner(Composite parent)
|
||||
{
|
||||
Image image = getShell().getDisplay().getSystemImage(SWT.ICON_QUESTION);
|
||||
|
||||
Composite c = new Composite(parent, SWT.NONE);
|
||||
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 1;
|
||||
c.setLayout(layout);
|
||||
c.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
Composite m = new Composite(c, SWT.NONE);
|
||||
|
||||
GridLayout mlayout = new GridLayout();
|
||||
mlayout.numColumns = 2;
|
||||
m.setLayout(mlayout);
|
||||
m.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
Label label = new Label(m, 0);
|
||||
image.setBackground(label.getBackground());
|
||||
label.setImage(image);
|
||||
label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING));
|
||||
|
||||
Text text = new Text(m, SWT.WRAP | SWT.MULTI);
|
||||
text.setEditable(false);
|
||||
text.setText(_dialogText);
|
||||
|
||||
Composite options = new Composite(c, SWT.NONE);
|
||||
GridLayout olayout = new GridLayout();
|
||||
olayout.numColumns = 1;
|
||||
options.setLayout(olayout);
|
||||
options.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
_replaceLocalButton = new Button(options, SWT.RADIO);
|
||||
_replaceLocalButton.setText(_replaceText);
|
||||
_replaceLocalButton.setSelection(true);
|
||||
|
||||
_keepLocalButton = new Button(options, SWT.RADIO);
|
||||
_keepLocalButton.setText(_openLocalText);
|
||||
|
||||
setHelp();
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the initial focus control
|
||||
* @return the initial focus control
|
||||
*/
|
||||
protected Control getInitialFocusControl()
|
||||
{
|
||||
enableOkButton(true);
|
||||
return _replaceLocalButton;
|
||||
}
|
||||
|
||||
private void setHelp()
|
||||
{
|
||||
setHelp(_helpId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the help id for this dialog
|
||||
* @param id the help id
|
||||
*/
|
||||
public void setHelpId(String id)
|
||||
{
|
||||
_helpId= id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dialog message
|
||||
* @param dialogText the dialog message
|
||||
*/
|
||||
public void setDialogText(String dialogText)
|
||||
{
|
||||
_dialogText = dialogText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dialog action message for replacing the local file with the remote file
|
||||
* @param replaceText the dialog action message for replacing the local file
|
||||
*/
|
||||
public void setReplaceText(String replaceText)
|
||||
{
|
||||
_replaceText = replaceText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dialog action message for keeping the local file
|
||||
* @param openLocalText the dialog action message for keeping the local file
|
||||
*/
|
||||
public void setOpenLocalText(String openLocalText)
|
||||
{
|
||||
_openLocalText = openLocalText;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected IFile _tempFile;
|
||||
protected boolean _remoteNewer;
|
||||
protected int _state;
|
||||
|
||||
public static final int REPLACE_WITH_REMOTE = 0;
|
||||
public static final int OPEN_WITH_LOCAL = 1;
|
||||
public static final int CANCELLED = 2;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param tempFile the cached local file that is in conflict with the remote file
|
||||
* @param remoteNewer indicates whether the remote file has changed since it was last downloaded
|
||||
*/
|
||||
public SystemDownloadConflictAction(IFile tempFile, boolean remoteNewer)
|
||||
{
|
||||
super(FileResources.RESID_CONFLICT_DOWNLOAD_TITLE, null);
|
||||
_tempFile = tempFile;
|
||||
_remoteNewer = remoteNewer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param title the title for the action
|
||||
* @param tempFile the cached local file that is in conflict with the remote file
|
||||
* @param remoteNewer indicates whether the remote file has changed since it was last downloaded
|
||||
*/
|
||||
public SystemDownloadConflictAction(String title, IFile tempFile, boolean remoteNewer)
|
||||
{
|
||||
super(title, null);
|
||||
_tempFile = tempFile;
|
||||
_remoteNewer = remoteNewer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the action taken in response to the conflict. The state may be one of the following:
|
||||
* <ul>
|
||||
* <li> REPLACE_WITH_REMOTE
|
||||
* <li> OPEN_WITH_LOCAL
|
||||
* <li> CANCELLED
|
||||
* </ul>
|
||||
* @return the response to the conflict
|
||||
*/
|
||||
public int getState()
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dialog used to prompt a user on how to resolve a conflict.
|
||||
* @returns the dialog
|
||||
*/
|
||||
protected DownloadConflictDialog getConflictDialog()
|
||||
{
|
||||
DownloadConflictDialog dlg = new DownloadConflictDialog(SystemBasePlugin.getActiveWorkbenchShell(), _remoteNewer);
|
||||
|
||||
if (_remoteNewer)
|
||||
{
|
||||
dlg.setDialogText(FileResources.RESID_CONFLICT_DOWNLOAD_MESSAGE_REMOTECHANGED);
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg.setDialogText(FileResources.RESID_CONFLICT_DOWNLOAD_MESSAGE_LOCALCHANGED);
|
||||
}
|
||||
|
||||
dlg.setReplaceText(FileResources.RESID_CONFLICT_DOWNLOAD_REPLACELOCAL);
|
||||
dlg.setOpenLocalText(FileResources.RESID_CONFLICT_DOWNLOAD_OPENWITHLOCAL);
|
||||
dlg.setHelpId(SystemPlugin.HELPPREFIX + "lcdl0000");
|
||||
return dlg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this action is invoked
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
setShell(SystemPlugin.getTheSystemRegistry().getShell());
|
||||
SystemIFileProperties properties = new SystemIFileProperties(_tempFile);
|
||||
|
||||
DownloadConflictDialog cnfDialog = getConflictDialog();
|
||||
if (cnfDialog.open() == Window.OK)
|
||||
{
|
||||
// does user want to open local or replace local with remote?
|
||||
if (cnfDialog.keepLocal())
|
||||
{
|
||||
// user wants to keep the local version
|
||||
// don't synchronize with server, save that for the save operation
|
||||
_state = OPEN_WITH_LOCAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// user wants to replace local copy with the remote version
|
||||
_state = REPLACE_WITH_REMOTE;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_state = CANCELLED;
|
||||
|
||||
// cancelled dialog, so no remote synchronization
|
||||
// set dirty flag!
|
||||
properties.setDirty(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.files.ui.resources.ISystemRemoteEditConstants;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
public class SystemEditFileAction extends SystemBaseAction implements ISystemRemoteEditConstants {
|
||||
|
||||
|
||||
protected String _editorId;
|
||||
|
||||
/**
|
||||
* Constructor for SystemEditFileAction
|
||||
*/
|
||||
public SystemEditFileAction(String text, String tooltip, ImageDescriptor image, Shell parent, String editorId) {
|
||||
super(text, tooltip, null, image, parent);
|
||||
init();
|
||||
_editorId = editorId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for SystemEditFileAction
|
||||
*/
|
||||
public SystemEditFileAction(String text, String tooltip, ImageDescriptor image, int style, Shell parent, String editorId) {
|
||||
super(text, tooltip, null, image, style, parent);
|
||||
init();
|
||||
_editorId = editorId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the action
|
||||
*/
|
||||
private void init() {
|
||||
allowOnMultipleSelection(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see SystemBaseAction#run
|
||||
*/
|
||||
public void run() {
|
||||
IStructuredSelection selection = getSelection();
|
||||
|
||||
if (selection.size() != 1)
|
||||
return;
|
||||
|
||||
Object element = getFirstSelection();
|
||||
|
||||
if (element == null)
|
||||
return;
|
||||
else if (!(element instanceof IRemoteFile))
|
||||
return;
|
||||
|
||||
process((IRemoteFile)element);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process the object: download file, open in editor, etc.
|
||||
*/
|
||||
protected void process(IRemoteFile remoteFile) {
|
||||
|
||||
SystemEditableRemoteFile editableFile = new SystemEditableRemoteFile(remoteFile, _editorId);
|
||||
editableFile.open(SystemBasePlugin.getActiveWorkbenchShell());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.resources.ISystemRemoteEditConstants;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
public class SystemEditFileInPlaceAction extends SystemBaseAction implements ISystemRemoteEditConstants {
|
||||
|
||||
|
||||
|
||||
private SystemPlugin plugin;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for SystemEditFileAction
|
||||
*/
|
||||
public SystemEditFileInPlaceAction(String text, String tooltip, ImageDescriptor image, Shell parent) {
|
||||
super(text, tooltip, image, parent);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the action
|
||||
*/
|
||||
private void init() {
|
||||
allowOnMultipleSelection(false);
|
||||
|
||||
// set the context menu group here seems to have no affect
|
||||
// had to add it in the group in the adapter
|
||||
// setContextMenuGroup(ISystemContextMenuConstants.GROUP_OPENWITH);
|
||||
|
||||
plugin = SystemPlugin.getDefault();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see SystemBaseAction#run
|
||||
*/
|
||||
public void run() {
|
||||
|
||||
IStructuredSelection selection = getSelection();
|
||||
|
||||
if (selection.size() != 1)
|
||||
return;
|
||||
|
||||
Object element = getFirstSelection();
|
||||
|
||||
if (element == null)
|
||||
return;
|
||||
else if (!(element instanceof IRemoteFile))
|
||||
return;
|
||||
|
||||
process((IRemoteFile)element);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process the object: download file, open in editor, etc.
|
||||
*/
|
||||
private void process(IRemoteFile remoteFile) {
|
||||
|
||||
SystemEditableRemoteFile editableFile = new SystemEditableRemoteFile(remoteFile);
|
||||
editableFile.openInSystemEditor(SystemBasePlugin.getActiveWorkbenchShell());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.files.ui.resources.SystemIFileProperties;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
|
||||
|
||||
|
||||
public class SystemEditFileLineAction extends SystemEditFileAction {
|
||||
|
||||
|
||||
protected IRemoteFile _remoteFile;
|
||||
protected int _line, _charStart, _charEnd;
|
||||
|
||||
/**
|
||||
* Constructor for SystemEditFileAction.
|
||||
*/
|
||||
public SystemEditFileLineAction(String text, String tooltip, ImageDescriptor image, Shell parent, String editorId, IRemoteFile remoteFile, int line, int charStart, int charEnd) {
|
||||
super(text, tooltip, image, parent, editorId);
|
||||
_line = line;
|
||||
_remoteFile = remoteFile;
|
||||
_charStart = charStart;
|
||||
_charEnd = charEnd;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
process(_remoteFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the object: download file, open in editor, etc.
|
||||
*/
|
||||
protected void process(IRemoteFile remoteFile) {
|
||||
super.process(remoteFile);
|
||||
handleGotoLine();
|
||||
}
|
||||
|
||||
protected void handleGotoLine() {
|
||||
handleGotoLine(_remoteFile, _line, _charStart, _charEnd);
|
||||
}
|
||||
|
||||
public static void handleGotoLine(IRemoteFile remoteFile, int line, int charStart, int charEnd) {
|
||||
|
||||
if (line > 0) {
|
||||
|
||||
IWorkbench desktop = PlatformUI.getWorkbench();
|
||||
IWorkbenchPage persp = desktop.getActiveWorkbenchWindow().getActivePage();
|
||||
IEditorPart editor = null;
|
||||
String fileName = remoteFile.getAbsolutePath();
|
||||
IEditorReference[] editors = persp.getEditorReferences();
|
||||
|
||||
for (int i = 0; i < editors.length; i++) {
|
||||
|
||||
IEditorReference ref = editors[i];
|
||||
IEditorPart editorp = ref.getEditor(false);
|
||||
|
||||
if (editorp != null) {
|
||||
|
||||
IEditorInput einput = editorp.getEditorInput();
|
||||
|
||||
if (einput instanceof IFileEditorInput) {
|
||||
|
||||
IFileEditorInput input = (IFileEditorInput) einput;
|
||||
IFile efile = input.getFile();
|
||||
|
||||
SystemIFileProperties properties = new SystemIFileProperties(efile);
|
||||
String comparePath = properties.getRemoteFilePath();
|
||||
|
||||
if (comparePath != null && (comparePath.replace('\\','/').equals(fileName.replace('\\','/')))) {
|
||||
|
||||
editor = editorp;
|
||||
persp.bringToTop(editor);
|
||||
|
||||
try {
|
||||
IMarker marker = createMarker(efile, line, charStart, charEnd);
|
||||
IDE.gotoMarker(editor, marker);
|
||||
}
|
||||
catch (CoreException e) {
|
||||
SystemBasePlugin.logError("Error occured in handleGotoLine", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static IMarker createMarker(IFile file, int line, int charStart, int charEnd) throws CoreException {
|
||||
IMarker marker = file.createMarker(IMarker.TEXT);
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, line);
|
||||
marker.setAttribute(IMarker.CHAR_START, charStart);
|
||||
marker.setAttribute(IMarker.CHAR_END, charEnd);
|
||||
|
||||
return marker;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.resources.ISystemRemoteEditConstants;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
public class SystemEditFilePlatformAction extends SystemBaseAction implements ISystemRemoteEditConstants {
|
||||
|
||||
|
||||
|
||||
private SystemPlugin plugin;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for SystemEditFileAction
|
||||
*/
|
||||
public SystemEditFilePlatformAction(String text, String tooltip, ImageDescriptor image, Shell parent) {
|
||||
super(text, tooltip, image, parent);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the action
|
||||
*/
|
||||
private void init() {
|
||||
allowOnMultipleSelection(false);
|
||||
|
||||
// set the context menu group here seems to have no affect
|
||||
// had to add it in the group in the adapter
|
||||
// setContextMenuGroup(ISystemContextMenuConstants.GROUP_OPENWITH);
|
||||
|
||||
plugin = SystemPlugin.getDefault();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see SystemBaseAction#run
|
||||
*/
|
||||
public void run() {
|
||||
|
||||
IStructuredSelection selection = getSelection();
|
||||
|
||||
if (selection.size() != 1)
|
||||
return;
|
||||
|
||||
Object element = getFirstSelection();
|
||||
|
||||
if (element == null)
|
||||
return;
|
||||
else if (!(element instanceof IRemoteFile))
|
||||
return;
|
||||
|
||||
process((IRemoteFile)element);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process the object: download file, open in editor, etc.
|
||||
*/
|
||||
private void process(IRemoteFile remoteFile) {
|
||||
|
||||
SystemEditableRemoteFile editableFile = new SystemEditableRemoteFile(remoteFile);
|
||||
editableFile.openInSystemEditor(SystemBasePlugin.getActiveWorkbenchShell());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.files.ui.resources.ISystemRemoteEditConstants;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorDescriptor;
|
||||
import org.eclipse.ui.IEditorRegistry;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
|
||||
|
||||
public class SystemEditFilesAction extends SystemBaseAction implements ISystemRemoteEditConstants {
|
||||
|
||||
|
||||
private IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
|
||||
|
||||
/**
|
||||
* Constructor for SystemEditFilesAction
|
||||
*/
|
||||
public SystemEditFilesAction(String text, String tooltip, Shell parent)
|
||||
{
|
||||
super(text, tooltip, parent);
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the action
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
allowOnMultipleSelection(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the local cache of the remote file, or <code>null</code> if none.
|
||||
* @param remoteFile the remote file.
|
||||
* @return the local cached resource, or <code>null</code> if none.
|
||||
*/
|
||||
private IFile getLocalResource(IRemoteFile remoteFile)
|
||||
{
|
||||
return (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile);
|
||||
}
|
||||
|
||||
protected IEditorDescriptor getDefaultEditor(IRemoteFile remoteFile)
|
||||
{
|
||||
IFile localFile = getLocalResource(remoteFile);
|
||||
|
||||
if (localFile == null) {
|
||||
return registry.getDefaultEditor(remoteFile.getName());
|
||||
}
|
||||
else {
|
||||
return IDE.getDefaultEditor(localFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SystemBaseAction#run
|
||||
*/
|
||||
public void run() {
|
||||
|
||||
IStructuredSelection selection = getSelection();
|
||||
|
||||
Iterator iterator = selection.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Object obj = iterator.next();
|
||||
if (obj instanceof IRemoteFile)
|
||||
{
|
||||
process((IRemoteFile)obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Process the object: download file, open in editor, etc.
|
||||
*/
|
||||
protected void process(IRemoteFile remoteFile)
|
||||
{
|
||||
String editorId = null;
|
||||
IEditorDescriptor des = getDefaultEditor(remoteFile);
|
||||
if (des != null)
|
||||
{
|
||||
editorId = des.getId();
|
||||
}
|
||||
|
||||
SystemEditableRemoteFile editableFile = new SystemEditableRemoteFile(remoteFile, editorId);
|
||||
editableFile.open(SystemBasePlugin.getActiveWorkbenchShell());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,194 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.resources.RemoteSourceLookupDirector;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell;
|
||||
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteError;
|
||||
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteOutput;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorDescriptor;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorRegistry;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
|
||||
|
||||
|
||||
|
||||
public class SystemEditProjectFileLineAction extends SystemEditFileAction {
|
||||
|
||||
|
||||
protected IRemoteFile _remoteFile;
|
||||
protected IRemoteOutput _output;
|
||||
|
||||
/**
|
||||
* Constructor for SystemEditFileAction
|
||||
*/
|
||||
public SystemEditProjectFileLineAction(String text, String tooltip, ImageDescriptor image, Shell parent, String editorId,
|
||||
IRemoteFile remoteFile, IRemoteOutput output)
|
||||
{
|
||||
super(text, tooltip, image, parent, editorId);
|
||||
|
||||
_output = output;
|
||||
_remoteFile = remoteFile;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
process();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Process the object: download file, open in editor, etc.
|
||||
*/
|
||||
protected void process()
|
||||
{
|
||||
openWorkspaceFile(_remoteFile, _output);
|
||||
}
|
||||
|
||||
|
||||
protected IEditorRegistry getEditorRegistry()
|
||||
{
|
||||
return SystemPlugin.getDefault().getWorkbench().getEditorRegistry();
|
||||
}
|
||||
|
||||
protected IEditorDescriptor getDefaultTextEditor()
|
||||
{
|
||||
IEditorRegistry registry = getEditorRegistry();
|
||||
return registry.findEditor("org.eclipse.ui.DefaultTextEditor");
|
||||
}
|
||||
/**
|
||||
* Open workspace file associated with IRemoteCommandShell. If there is no associated project
|
||||
* return.
|
||||
* @param remoteFile
|
||||
* @param output
|
||||
* @return
|
||||
*/
|
||||
protected boolean openWorkspaceFile(IRemoteFile remoteFile, IRemoteOutput output)
|
||||
{
|
||||
IRemoteCommandShell cmd = (IRemoteCommandShell)(output.getParent());
|
||||
IProject associatedProject = cmd.getAssociatedProject();
|
||||
if (associatedProject != null)
|
||||
{
|
||||
ProjectSourceContainer container = new ProjectSourceContainer(associatedProject, false);
|
||||
ISourceLookupDirector director = new RemoteSourceLookupDirector();
|
||||
container.init(director);
|
||||
try
|
||||
{
|
||||
Object[] matches = container.findSourceElements(remoteFile.getName());
|
||||
for (int i = 0; i < matches.length; i++)
|
||||
{
|
||||
//System.out.println("match="+matches[i]);
|
||||
}
|
||||
|
||||
if (matches.length == 1)
|
||||
{
|
||||
IFile localMatch = (IFile)matches[0];
|
||||
|
||||
|
||||
|
||||
IWorkbenchPage activePage = SystemBasePlugin.getActiveWorkbenchWindow().getActivePage();
|
||||
|
||||
FileEditorInput finput = new FileEditorInput(localMatch);
|
||||
|
||||
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(remoteFile.getName());
|
||||
if (desc == null)
|
||||
{
|
||||
desc = getDefaultTextEditor();
|
||||
}
|
||||
String editorid = desc.getId();
|
||||
|
||||
IEditorPart editor = activePage.openEditor(finput, editorid);
|
||||
|
||||
int line = output.getLine();
|
||||
int charStart = output.getCharStart();
|
||||
int charEnd = output.getCharEnd();
|
||||
|
||||
try
|
||||
{
|
||||
IMarker marker = null;
|
||||
|
||||
// DKM - should we? this will populate the Problems view..but resources are actually remote
|
||||
if (output instanceof IRemoteError)
|
||||
{
|
||||
IRemoteError error = (IRemoteError)output;
|
||||
String type = error.getType();
|
||||
|
||||
marker = localMatch.createMarker(IMarker.TEXT);
|
||||
|
||||
if (type.equals("error"))
|
||||
{
|
||||
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
|
||||
}
|
||||
else if (type.equals("warning"))
|
||||
{
|
||||
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
|
||||
}
|
||||
else if (type.equals("informational"))
|
||||
{
|
||||
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
|
||||
}
|
||||
|
||||
marker.setAttribute(IMarker.MESSAGE, output.getText());
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, line);
|
||||
marker.setAttribute(IMarker.CHAR_START, charStart);
|
||||
marker.setAttribute(IMarker.CHAR_END, charEnd);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
marker = localMatch.createMarker(IMarker.TEXT);
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, line);
|
||||
marker.setAttribute(IMarker.CHAR_START, charStart);
|
||||
marker.setAttribute(IMarker.CHAR_END, charEnd);
|
||||
}
|
||||
IDE.gotoMarker(editor, marker);
|
||||
|
||||
|
||||
}
|
||||
catch (CoreException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,380 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.eclipse.compare.EditionSelectionDialog;
|
||||
import org.eclipse.compare.HistoryItem;
|
||||
import org.eclipse.compare.IStreamContentAccessor;
|
||||
import org.eclipse.compare.ITypedElement;
|
||||
import org.eclipse.compare.ResourceNode;
|
||||
import org.eclipse.compare.internal.CompareUIPlugin;
|
||||
import org.eclipse.compare.internal.Utilities;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFileState;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.services.clientserver.SystemEncodingUtil;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
|
||||
public class SystemEditionAction extends SystemBaseAction
|
||||
{
|
||||
|
||||
/**
|
||||
* Implements the IStreamContentAccessor and ITypedElement protocols
|
||||
* for a Document.
|
||||
*/
|
||||
class DocumentBufferNode implements ITypedElement, IStreamContentAccessor
|
||||
{
|
||||
|
||||
private IDocument fDocument;
|
||||
private IFile fFile;
|
||||
|
||||
DocumentBufferNode(IDocument document, IFile file)
|
||||
{
|
||||
fDocument = document;
|
||||
fFile = file;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return fFile.getName();
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return fFile.getFileExtension();
|
||||
}
|
||||
|
||||
public Image getImage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public InputStream getContents()
|
||||
{
|
||||
return new ByteArrayInputStream(fDocument.get().getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
private List _selected;
|
||||
private boolean fReplaceMode;
|
||||
private String fBundleName;
|
||||
protected boolean fPrevious = false;
|
||||
protected String fHelpContextId;
|
||||
|
||||
SystemEditionAction(Shell parent, String title, String tooltip, String bundleName, boolean replaceMode)
|
||||
{
|
||||
super(title, parent);
|
||||
setToolTipText(tooltip);
|
||||
|
||||
fReplaceMode = replaceMode;
|
||||
fBundleName = bundleName;
|
||||
_selected = new ArrayList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when the selection changes in the systems view. This determines
|
||||
* the input object for the command and whether to enable or disable
|
||||
* the action.
|
||||
*
|
||||
* @param selection the current seleciton
|
||||
* @return whether to enable or disable the action
|
||||
*/
|
||||
public boolean updateSelection(IStructuredSelection selection)
|
||||
{
|
||||
boolean enable = false;
|
||||
_selected.clear();
|
||||
Iterator e = ((IStructuredSelection) selection).iterator();
|
||||
if (e.hasNext())
|
||||
{
|
||||
Object selected = e.next();
|
||||
|
||||
if (selected != null && selected instanceof IRemoteFile)
|
||||
{
|
||||
RemoteFile file = (RemoteFile) selected;
|
||||
if (file.isFile())
|
||||
{
|
||||
ISystemRemoteElementAdapter adapter = (ISystemRemoteElementAdapter)file.getAdapter(ISystemRemoteElementAdapter.class);
|
||||
if (adapter != null)
|
||||
{
|
||||
ISystemEditableRemoteObject editable = adapter.getEditableRemoteObject(file);
|
||||
if (editable != null)
|
||||
{
|
||||
if (editable.getLocalResource().exists())
|
||||
{
|
||||
_selected.add(file);
|
||||
enable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** FIXME - no longer have a getCachedCopy() method
|
||||
try
|
||||
{
|
||||
if (file.getCachedCopy() != null)
|
||||
{
|
||||
_selected.add(file);
|
||||
enable = true;
|
||||
}
|
||||
}
|
||||
catch (SystemMessageException ex)
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return enable;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
// get cached file
|
||||
IFile[] files = getFiles(_selected, fReplaceMode);
|
||||
for (int i = 0; i < files.length; i++)
|
||||
doFromHistory(files[i]);
|
||||
}
|
||||
|
||||
private void doFromHistory(final IFile file)
|
||||
{
|
||||
//DKM - hack - needed to use compare class loader to load bundle for current locale
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(fBundleName, Locale.getDefault(), CompareUIPlugin.class.getClassLoader());
|
||||
|
||||
String title = Utilities.getString(bundle, "title"); //$NON-NLS-1$
|
||||
|
||||
Shell parentShell = CompareUIPlugin.getShell();
|
||||
|
||||
IFileState states[] = null;
|
||||
try
|
||||
{
|
||||
states = file.getHistory(null);
|
||||
}
|
||||
catch (CoreException ex)
|
||||
{
|
||||
MessageDialog.openError(parentShell, title, ex.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (states == null || states.length <= 0)
|
||||
{
|
||||
String msg = Utilities.getString(bundle, "noLocalHistoryError"); //$NON-NLS-1$
|
||||
MessageDialog.openInformation(parentShell, title, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
ITypedElement base = new ResourceNode(file);
|
||||
|
||||
IDocument document = getDocument(file);
|
||||
ITypedElement target = base;
|
||||
if (document != null)
|
||||
target = new DocumentBufferNode(document, file);
|
||||
|
||||
ITypedElement[] editions = new ITypedElement[states.length + 1];
|
||||
editions[0] = base;
|
||||
for (int i = 0; i < states.length; i++)
|
||||
editions[i + 1] = new HistoryItem(base, states[i]);
|
||||
|
||||
EditionSelectionDialog d = new EditionSelectionDialog(parentShell, bundle);
|
||||
d.setEditionTitleArgument(file.getName());
|
||||
d.setEditionTitleImage(CompareUIPlugin.getImage(file));
|
||||
//d.setHideIdenticalEntries(false);
|
||||
if (fHelpContextId != null)
|
||||
d.setHelpContextId(fHelpContextId);
|
||||
|
||||
if (fReplaceMode)
|
||||
{
|
||||
|
||||
ITypedElement ti = null;
|
||||
if (fPrevious)
|
||||
ti = d.selectPreviousEdition(target, editions, null);
|
||||
else
|
||||
ti = d.selectEdition(target, editions, null);
|
||||
|
||||
if (ti instanceof IStreamContentAccessor)
|
||||
{
|
||||
IStreamContentAccessor sa = (IStreamContentAccessor) ti;
|
||||
try
|
||||
{
|
||||
|
||||
if (document != null)
|
||||
updateDocument(document, sa);
|
||||
else
|
||||
updateWorkspace(bundle, parentShell, sa, file);
|
||||
|
||||
}
|
||||
catch (InterruptedException x)
|
||||
{
|
||||
// Do nothing. Operation has been canceled by user.
|
||||
|
||||
}
|
||||
catch (InvocationTargetException x)
|
||||
{
|
||||
String reason = x.getTargetException().getMessage();
|
||||
MessageDialog.openError(parentShell, title, Utilities.getFormattedString(bundle, "replaceError", reason)); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d.setCompareMode(true);
|
||||
|
||||
d.selectEdition(target, editions, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateWorkspace(final ResourceBundle bundle, Shell shell, final IStreamContentAccessor sa, final IFile file) throws InvocationTargetException, InterruptedException
|
||||
{
|
||||
|
||||
WorkspaceModifyOperation operation = new WorkspaceModifyOperation()
|
||||
{
|
||||
public void execute(IProgressMonitor pm) throws InvocationTargetException
|
||||
{
|
||||
try
|
||||
{
|
||||
String taskName = Utilities.getString(bundle, "taskName"); //$NON-NLS-1$
|
||||
pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
|
||||
file.setContents(sa.getContents(), false, true, pm);
|
||||
}
|
||||
catch (CoreException e)
|
||||
{
|
||||
throw new InvocationTargetException(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
pm.done();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ProgressMonitorDialog pmdialog = new ProgressMonitorDialog(shell);
|
||||
pmdialog.run(false, true, operation);
|
||||
}
|
||||
|
||||
private void updateDocument(IDocument document, IStreamContentAccessor sa) throws InvocationTargetException
|
||||
{
|
||||
try
|
||||
{
|
||||
InputStream is = sa.getContents();
|
||||
String text = Utilities.readString(is, SystemEncodingUtil.ENCODING_UTF_8);
|
||||
document.replace(0, document.getLength(), text);
|
||||
}
|
||||
catch (CoreException e)
|
||||
{
|
||||
throw new InvocationTargetException(e);
|
||||
}
|
||||
catch (BadLocationException e)
|
||||
{
|
||||
throw new InvocationTargetException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private IDocument getDocument(IFile file)
|
||||
{
|
||||
IWorkbench wb = PlatformUI.getWorkbench();
|
||||
if (wb == null)
|
||||
return null;
|
||||
IWorkbenchWindow[] ws = wb.getWorkbenchWindows();
|
||||
if (ws == null)
|
||||
return null;
|
||||
|
||||
FileEditorInput test = new FileEditorInput(file);
|
||||
|
||||
for (int i = 0; i < ws.length; i++)
|
||||
{
|
||||
IWorkbenchWindow w = ws[i];
|
||||
IWorkbenchPage[] wps = w.getPages();
|
||||
if (wps != null)
|
||||
{
|
||||
for (int j = 0; j < wps.length; j++)
|
||||
{
|
||||
IWorkbenchPage wp = wps[j];
|
||||
IEditorPart ep = wp.findEditor(test);
|
||||
if (ep instanceof ITextEditor)
|
||||
{
|
||||
ITextEditor te = (ITextEditor) ep;
|
||||
IDocumentProvider dp = te.getDocumentProvider();
|
||||
if (dp != null)
|
||||
{
|
||||
IDocument doc = dp.getDocument(ep);
|
||||
if (doc != null)
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private IFile[] getFiles(List remoteFiles, boolean modifiable)
|
||||
{
|
||||
IFile[] result = new IFile[remoteFiles.size()];
|
||||
for (int i = 0; i < remoteFiles.size(); i++)
|
||||
{
|
||||
IRemoteFile remotefile = (IRemoteFile)remoteFiles.get(i);
|
||||
SystemEditableRemoteFile eFile = new SystemEditableRemoteFile(remotefile);
|
||||
try
|
||||
{
|
||||
eFile.download(getShell());
|
||||
eFile.addAsListener();
|
||||
eFile.setLocalResourceProperties();
|
||||
IFile localFile = eFile.getLocalResource();
|
||||
result[i] = localFile;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,258 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2003, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.model.ISystemRegistry;
|
||||
import org.eclipse.rse.model.ISystemRemoteChangeEvents;
|
||||
import org.eclipse.rse.model.ISystemResourceChangeEvents;
|
||||
import org.eclipse.rse.model.SystemResourceChangeEvent;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.view.ISystemDragDropAdapter;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* @author mjberger
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class SystemExtractAction extends SystemBaseAction
|
||||
{
|
||||
protected List _selected;
|
||||
protected Shell _parent;
|
||||
protected String _label;
|
||||
|
||||
public SystemExtractAction(Shell parent)
|
||||
{
|
||||
super(FileResources.ACTION_EXTRACT_LABEL, parent);
|
||||
_label = FileResources.ACTION_EXTRACT_LABEL;
|
||||
setToolTipText(FileResources.ACTION_EXTRACT_TOOLTIP);
|
||||
_selected = new ArrayList();
|
||||
_parent = parent;
|
||||
allowOnMultipleSelection(true);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "actn0118");
|
||||
setImageDescriptor(SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_EXTRACT_ID));
|
||||
}
|
||||
|
||||
public SystemExtractAction(Shell parent, String label, String tooltip)
|
||||
{
|
||||
super(label, tooltip, parent);
|
||||
_label = label;
|
||||
setToolTipText(tooltip);
|
||||
_selected = new ArrayList();
|
||||
_parent = parent;
|
||||
allowOnMultipleSelection(true);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "actn0118");
|
||||
setImageDescriptor(SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_EXTRACT_ID));
|
||||
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
for (int i = 0; i < _selected.size(); i++)
|
||||
{
|
||||
IRemoteFile selection = (IRemoteFile) _selected.get(i);
|
||||
IRemoteFile destinationParent = selection.getParentRemoteFile();
|
||||
IRemoteFileSubSystem ss = selection.getParentRemoteFileSubSystem();
|
||||
String newName = getExtractedName(selection);
|
||||
IRemoteFile destination = null;
|
||||
try
|
||||
{
|
||||
destination = ss.getRemoteFileObject(destinationParent.getAbsolutePath() + destinationParent.getSeparator() + newName);
|
||||
ss.createFolder(destination);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), e.getSystemMessage());
|
||||
dlg.open();
|
||||
continue;
|
||||
}
|
||||
IRunnableContext runnableContext = getRunnableContext(_parent);
|
||||
|
||||
ExtractRunnable runnable = new ExtractRunnable(selection, destination);
|
||||
try
|
||||
{
|
||||
// currently we don't run this in a thread because
|
||||
// in some cases dialogs are launched in the operation
|
||||
// (widgets can only be legally used on the main thread)
|
||||
runnableContext.run(false, true, runnable); // inthread, cancellable, IRunnableWithProgress
|
||||
}
|
||||
catch (java.lang.reflect.InvocationTargetException exc)
|
||||
{
|
||||
}
|
||||
catch (java.lang.InterruptedException e)
|
||||
{
|
||||
}
|
||||
// always refresh
|
||||
ISystemRegistry registry = SystemPlugin.getTheSystemRegistry();
|
||||
registry.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, destination, destinationParent, ss, null, null);
|
||||
registry.fireEvent(new SystemResourceChangeEvent(destination, ISystemResourceChangeEvents.EVENT_REFRESH, destinationParent));
|
||||
}
|
||||
}
|
||||
|
||||
protected class ExtractRunnable implements IRunnableWithProgress
|
||||
{
|
||||
private IRemoteFileSubSystem destSS;
|
||||
private IRemoteFileSubSystem sourceSS;
|
||||
private IRemoteFile selection;
|
||||
private IRemoteFile destination;
|
||||
|
||||
public ExtractRunnable(IRemoteFile source, IRemoteFile dest)
|
||||
{
|
||||
destSS = dest.getParentRemoteFileSubSystem();
|
||||
sourceSS = source.getParentRemoteFileSubSystem();
|
||||
selection = source;
|
||||
destination = dest;
|
||||
}
|
||||
|
||||
public void run(IProgressMonitor monitor)
|
||||
{
|
||||
IRemoteFile[] sources = sourceSS.listFoldersAndFiles(selection);
|
||||
for (int j = 0; j < sources.length && !monitor.isCanceled(); j++)
|
||||
{
|
||||
try
|
||||
{
|
||||
ISystemDragDropAdapter srcAdapter = (ISystemDragDropAdapter) ((IAdaptable) selection).getAdapter(ISystemDragDropAdapter.class);
|
||||
boolean sameSysType = sourceSS.getClass().equals(destSS.getClass());
|
||||
boolean sameSys = (sourceSS == destSS);
|
||||
if (!sameSys)
|
||||
{
|
||||
Object source = srcAdapter.doDrag(sources[j], sameSysType, monitor);
|
||||
srcAdapter.doDrop(source, destination, sameSysType, sameSys, 0, monitor);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcAdapter.doDrop(sources[j], destination, sameSysType, sameSys, 0, monitor);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_FAILED);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
System.out.println(e.getMessage());
|
||||
System.out.println("Could not extract " + sources[j].getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the selection changes in the systems view. This determines
|
||||
* the input object for the command and whether to enable or disable
|
||||
* the action.
|
||||
*
|
||||
* @param selection the current seleciton
|
||||
* @return whether to enable or disable the action
|
||||
*/
|
||||
public boolean updateSelection(IStructuredSelection selection)
|
||||
{
|
||||
_selected.clear();
|
||||
boolean enable = false;
|
||||
|
||||
Iterator e = ((IStructuredSelection) selection).iterator();
|
||||
while (e.hasNext())
|
||||
{
|
||||
Object selected = e.next();
|
||||
|
||||
if (selected != null && selected instanceof IRemoteFile)
|
||||
{
|
||||
IRemoteFile file = (IRemoteFile) selected;
|
||||
if (file.isArchive() && file.getParentRemoteFileSubSystem().getParentRemoteFileSubSystemFactory().supportsArchiveManagement())
|
||||
{
|
||||
_selected.add(file);
|
||||
enable = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (_selected.size() == 1)
|
||||
{
|
||||
this.setText(getActionLabelForSingleSelection());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setText(_label);
|
||||
}
|
||||
return enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extending classes must override this method, otherwise
|
||||
* when there is one selection, the action label will be
|
||||
* "Extract to xxxx", where xxxx is a dynamically created directory
|
||||
* name. Note: you can also eliminate this behaviour by overriding
|
||||
* the updateSelection method.
|
||||
* @return Set this to return the normal action label if you don't want
|
||||
* the name dynamically created.
|
||||
*/
|
||||
protected String getActionLabelForSingleSelection()
|
||||
{
|
||||
String msg = FileResources.ACTION_EXTRACT_SUB_LABEL;
|
||||
return SystemMessage.sub(msg, "%1", getExtractedName((IRemoteFile)_selected.get(0)));
|
||||
}
|
||||
|
||||
protected String getExtractedName(IRemoteFile selection)
|
||||
{
|
||||
String newName = selection.getName();
|
||||
int k = newName.lastIndexOf(".");
|
||||
if (k == -1)
|
||||
{
|
||||
newName = newName + "_contents";
|
||||
}
|
||||
else
|
||||
{
|
||||
newName = newName.substring(0, k);
|
||||
}
|
||||
return newName;
|
||||
}
|
||||
|
||||
protected IRunnableContext getRunnableContext(Shell shell)
|
||||
{
|
||||
IRunnableContext irc = SystemPlugin.getTheSystemRegistry().getRunnableContext();
|
||||
if (irc != null)
|
||||
{
|
||||
return irc;
|
||||
}
|
||||
|
||||
return new ProgressMonitorDialog(shell);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2003, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.rse.core.ISystemTypes;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.resources.ExtractToDialog;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.model.ISystemRegistry;
|
||||
import org.eclipse.rse.model.ISystemRemoteChangeEvents;
|
||||
import org.eclipse.rse.model.ISystemResourceChangeEvents;
|
||||
import org.eclipse.rse.model.SystemResourceChangeEvent;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* @author mjberger
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class SystemExtractToAction extends SystemExtractAction implements IValidatorRemoteSelection, ISystemMessages
|
||||
{
|
||||
protected static final String[] systemTypes = { ISystemTypes.SYSTEMTYPE_LOCAL,
|
||||
ISystemTypes.SYSTEMTYPE_WINDOWS,
|
||||
ISystemTypes.SYSTEMTYPE_LINUX,
|
||||
ISystemTypes.SYSTEMTYPE_POWER_LINUX,
|
||||
ISystemTypes.SYSTEMTYPE_UNIX,
|
||||
ISystemTypes.SYSTEMTYPE_AIX,
|
||||
ISystemTypes.SYSTEMTYPE_ISERIES
|
||||
};
|
||||
protected SystemMessage targetDescendsFromSrcMsg = null;
|
||||
protected int currentlyProcessingSelection = 0;
|
||||
|
||||
public SystemExtractToAction(Shell parent)
|
||||
{
|
||||
super(parent,FileResources.ACTION_EXTRACT_TO_LABEL, FileResources.ACTION_EXTRACT_TO_TOOLTIP);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "actn0119");
|
||||
setImageDescriptor(SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_EXTRACTTO_ID));
|
||||
|
||||
}
|
||||
|
||||
public SystemExtractToAction(Shell parent, String label, String tooltip)
|
||||
{
|
||||
super(parent, label, tooltip);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "actn0119");
|
||||
setImageDescriptor(SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_EXTRACTTO_ID));
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
for (int i = 0; i < _selected.size(); i++)
|
||||
{
|
||||
currentlyProcessingSelection = i;
|
||||
IRemoteFile selection = (IRemoteFile) _selected.get(i);
|
||||
IRemoteFileSubSystem sourceSS = selection.getParentRemoteFileSubSystem();
|
||||
String title = FileResources.RESID_EXTRACTTO_TITLE;
|
||||
ExtractToDialog dialog = new ExtractToDialog(getShell(), title);
|
||||
if (dialog == null)
|
||||
return;
|
||||
dialog.setNeedsProgressMonitor(true);
|
||||
|
||||
String message = SystemMessage.sub(FileResources.RESID_EXTRACTTO_PROMPT, "&1", selection.getAbsolutePath());
|
||||
dialog.setMessage(message);
|
||||
dialog.setShowNewConnectionPrompt(true);
|
||||
dialog.setShowPropertySheet(true, false);
|
||||
dialog.setSystemTypes(systemTypes);
|
||||
|
||||
dialog.setPreSelection(selection);
|
||||
|
||||
dialog.setBlockOnOpen(true);
|
||||
dialog.setSelectionValidator(this);
|
||||
|
||||
/*if (dlgHelpId!=null)
|
||||
{
|
||||
dialog.setHelp(dlgHelpId);
|
||||
}*/
|
||||
|
||||
int rc = dialog.open();
|
||||
|
||||
// if (rc != 0) NOT RELIABLE!
|
||||
boolean cancelled = false;
|
||||
if (dialog.wasCancelled()) cancelled = true;
|
||||
|
||||
IRemoteFile destination = null;
|
||||
IRemoteFileSubSystem destSS = null;
|
||||
if (!cancelled)
|
||||
{
|
||||
destination = (IRemoteFile) dialog.getOutputObject();
|
||||
destSS = destination.getParentRemoteFileSubSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (destination == null)
|
||||
{
|
||||
System.out.println("blah");
|
||||
}
|
||||
if (selection.isAncestorOf(destination))
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_DEST_NOT_IN_SOURCE);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
if (!destination.canWrite())
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_DEST_TARGET_READONLY);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
IRunnableContext runnableContext = getRunnableContext(_parent);
|
||||
|
||||
ExtractRunnable runnable = new ExtractRunnable(selection, destination);
|
||||
try
|
||||
{
|
||||
// currently we don't run this in a thread because
|
||||
// in some cases dialogs are launched in the operation
|
||||
// (widgets can only be legally used on the main thread)
|
||||
runnableContext.run(false, true, runnable); // inthread, cancellable, IRunnableWithProgress
|
||||
}
|
||||
catch (java.lang.reflect.InvocationTargetException exc)
|
||||
{
|
||||
}
|
||||
catch (java.lang.InterruptedException e)
|
||||
{
|
||||
}
|
||||
// always refresh
|
||||
ISystemRegistry registry = SystemPlugin.getTheSystemRegistry();
|
||||
registry.fireRemoteResourceChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_CREATED, destination, destination.getParentPath(), destSS, null, null);
|
||||
registry.fireEvent(new SystemResourceChangeEvent(destination, ISystemResourceChangeEvents.EVENT_REFRESH, destination.getParentPath()));
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean destinationInSource(IRemoteFile destination)
|
||||
{
|
||||
boolean insource = false;
|
||||
for (int i = 0; i < _selected.size(); i++)
|
||||
{
|
||||
if (destination.isDescendantOf((IRemoteFile) _selected.get(i)))
|
||||
{
|
||||
insource = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return insource;
|
||||
}
|
||||
|
||||
protected String getActionLabelForSingleSelection()
|
||||
{
|
||||
return _label;
|
||||
}
|
||||
|
||||
public SystemMessage isValid(IHost selectedConnection, Object[] selectedObjects, ISystemRemoteElementAdapter[] remoteAdaptersForSelectedObjects)
|
||||
{
|
||||
//if (selectedConnection != sourceConnection) {} // someday, but can't happen today.
|
||||
Object selectedObject = selectedObjects[0];
|
||||
IRemoteFile currentSelection = (IRemoteFile) _selected.get(currentlyProcessingSelection);
|
||||
if (!(selectedObject instanceof IRemoteFile))
|
||||
return null;
|
||||
IRemoteFile selectedFolder = (IRemoteFile)selectedObject;
|
||||
if (selectedFolder.isDescendantOf(currentSelection))
|
||||
{
|
||||
if (targetDescendsFromSrcMsg == null)
|
||||
targetDescendsFromSrcMsg = SystemPlugin.getPluginMessage(FILEMSG_MOVE_TARGET_DESCENDS_FROM_SOUCE);
|
||||
return targetDescendsFromSrcMsg;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import org.eclipse.rse.files.ui.SystemFileFilterStringEditPane;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.ui.SystemResources;
|
||||
import org.eclipse.rse.ui.filters.actions.SystemChangeFilterAction;
|
||||
import org.eclipse.rse.ui.filters.dialogs.SystemChangeFilterDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* The action that displays the Change File Filter dialog.
|
||||
* Note that the input filter is deduced from the current selection, which must be a filter reference.
|
||||
*/
|
||||
public class SystemFileUpdateFilterAction
|
||||
extends SystemChangeFilterAction
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SystemFileUpdateFilterAction(Shell parent)
|
||||
{
|
||||
super(parent, SystemResources.ACTION_UPDATEFILTER_LABEL, SystemResources.ACTION_UPDATEFILTER_TOOLTIP);
|
||||
setDialogTitle(SystemFileResources.RESID_CHGFILEFILTER_TITLE);
|
||||
}
|
||||
/**
|
||||
* Overridable extension point to configure the filter dialog. Typically you don't need
|
||||
* to subclass our default dialog.
|
||||
*/
|
||||
protected void configureFilterDialog(SystemChangeFilterDialog dlg)
|
||||
{
|
||||
// it is cheaper to do this here, as it defers instantiation of the edit pane until the
|
||||
// user actually runs the action!
|
||||
Shell shell = dlg.getShell();
|
||||
if (shell == null)
|
||||
shell = dlg.getParentShell();
|
||||
|
||||
dlg.setFilterStringEditPane(new SystemFileFilterStringEditPane(shell));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.model.ISystemRemoteChangeEvents;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseCopyAction;
|
||||
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* Move selected files and folders action.
|
||||
*/
|
||||
public class SystemMoveRemoteFileAction extends SystemCopyRemoteFileAction
|
||||
implements ISystemMessages, IValidatorRemoteSelection
|
||||
{
|
||||
private SystemMessage targetEqualsSrcMsg = null;
|
||||
private SystemMessage targetDescendsFromSrcMsg = null;
|
||||
protected Vector movedFiles = new Vector();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SystemMoveRemoteFileAction(Shell shell)
|
||||
{
|
||||
super(shell, MODE_MOVE);
|
||||
setHelp(SystemPlugin.HELPPREFIX+"actn0111");
|
||||
setDialogHelp(SystemPlugin.HELPPREFIX+"dmrf0000");
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
// PARENT METHOD OVERRIDES...
|
||||
// --------------------------
|
||||
/**
|
||||
* Reset. This is a re-run of this action
|
||||
*/
|
||||
protected void reset()
|
||||
{
|
||||
movedFiles.clear();
|
||||
super.reset();
|
||||
|
||||
//targetEqualsSrcMsg = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SystemBaseCopyAction#doCopy(IProgressMonitor, Object, Object, String)
|
||||
* @param monitor Usually not needed
|
||||
* @param targetContainer will be the IRemoteFile folder selected to move into
|
||||
* @param oldObject will be the IRemoteFile object currently being moved
|
||||
* @param newName will be the new name to give the oldObject on move
|
||||
*/
|
||||
protected boolean doCopy(IProgressMonitor monitor, Object targetContainer, Object oldObject, String newName)
|
||||
throws Exception
|
||||
{
|
||||
IRemoteFile targetFolder = (IRemoteFile)targetContainer;
|
||||
IRemoteFile srcFileOrFolder = (IRemoteFile)oldObject;
|
||||
|
||||
IRemoteFileSubSystem ss = targetFolder.getParentRemoteFileSubSystem();
|
||||
|
||||
boolean ok = false;
|
||||
|
||||
ok = ss.move(srcFileOrFolder, targetFolder, newName, monitor);
|
||||
if (!ok)
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(FILEMSG_MOVE_FILE_FAILED);
|
||||
msg.makeSubstitution(srcFileOrFolder.getName());
|
||||
throw new SystemMessageException(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
String sep = targetFolder.getSeparator();
|
||||
String targetFolderName = targetFolder.getAbsolutePath();
|
||||
if (!targetFolderName.endsWith(sep))
|
||||
copiedFiles.addElement(targetFolderName+sep+newName);
|
||||
else
|
||||
copiedFiles.addElement(targetFolderName+newName);
|
||||
|
||||
movedFiles.addElement(srcFileOrFolder);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* The user has selected a remote object. Return null if OK is to be enabled, or a SystemMessage
|
||||
* if it is not to be enabled. The message will be displayed on the message line.
|
||||
*/
|
||||
public SystemMessage isValid(IHost selectedConnection, Object[] selectedObjects, ISystemRemoteElementAdapter[] remoteAdaptersForSelectedObjects)
|
||||
{
|
||||
//if (selectedConnection != sourceConnection) {} // someday, but can't happen today.
|
||||
Object selectedObject = selectedObjects[0];
|
||||
if (!(selectedObject instanceof IRemoteFile))
|
||||
return null;
|
||||
IRemoteFile selectedFolder = (IRemoteFile)selectedObject;
|
||||
if (selectedFolder.getAbsolutePath().equals(firstSelectionParent.getAbsolutePath()))
|
||||
{
|
||||
if (targetEqualsSrcMsg == null)
|
||||
targetEqualsSrcMsg = SystemPlugin.getPluginMessage(FILEMSG_MOVE_TARGET_EQUALS_SOURCE);
|
||||
return targetEqualsSrcMsg;
|
||||
}
|
||||
else if (selectedFolder.getAbsolutePath().equals(firstSelection.getAbsolutePath()))
|
||||
{
|
||||
if (targetEqualsSrcMsg == null)
|
||||
targetEqualsSrcMsg = SystemPlugin.getPluginMessage(FILEMSG_MOVE_TARGET_EQUALS_SOURCE); // todo: different msg
|
||||
return targetEqualsSrcMsg;
|
||||
}
|
||||
else if (selectedFolder.isDescendantOf(firstSelection))
|
||||
{
|
||||
if (targetDescendsFromSrcMsg == null)
|
||||
targetDescendsFromSrcMsg = SystemPlugin.getPluginMessage(FILEMSG_MOVE_TARGET_DESCENDS_FROM_SOUCE);
|
||||
return targetDescendsFromSrcMsg;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after all the copy/move operations end, be it successfully or not.
|
||||
* Your opportunity to display completion or do post-copy selections/refreshes
|
||||
*/
|
||||
public void copyComplete()
|
||||
{
|
||||
// we want to do the super.copyComplete() to refresh the target, but first we must do refresh the
|
||||
// source to reflect the deletion...
|
||||
|
||||
// refresh all instances of the source parent, and all affected filters...
|
||||
ISubSystem fileSS = targetFolder.getParentRemoteFileSubSystem();
|
||||
//SystemPlugin.getTheSystemRegistry().fireRemoteResourceChangeEvent(
|
||||
// ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED, copiedFiles, firstSelectionParent.getAbsolutePath(), fileSS, null, null);
|
||||
SystemPlugin.getTheSystemRegistry().fireRemoteResourceChangeEvent(
|
||||
ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_DELETED, movedFiles, firstSelectionParent.getAbsolutePath(), fileSS, null, null);
|
||||
|
||||
/* old release 1.0 way of doing it...
|
||||
Viewer v = getViewer();
|
||||
if (v instanceof ISystemTree)
|
||||
{
|
||||
SystemRegistry sr = SystemPlugin.getTheSystemRegistry();
|
||||
ISystemTree tree = (ISystemTree)v;
|
||||
Object parent = tree.getSelectedParent();
|
||||
if (parent != null)
|
||||
{
|
||||
if (parent instanceof IRemoteFile)
|
||||
{
|
||||
//System.out.println("Firing REFRESH_REMOTE");
|
||||
sr.fireEvent(
|
||||
new com.ibm.etools.systems.model.impl.SystemResourceChangeEvent(
|
||||
parent,ISystemResourceChangeEvent.EVENT_REFRESH_REMOTE, null) );
|
||||
}
|
||||
else
|
||||
{
|
||||
//System.out.println("MOVE OPERATION: Firing REFRESH");
|
||||
// FIRST REFRESH EXPANDED FILTER
|
||||
sr.fireEvent(
|
||||
new com.ibm.etools.systems.model.impl.SystemResourceChangeEvent(
|
||||
parent,ISystemResourceChangeEvent.EVENT_REFRESH, null) );
|
||||
// NEXT REFRESH ALL OTHER PLACES THAT MIGHT BE SHOWING THE SOURCE FOLDER
|
||||
sr.fireEvent(
|
||||
new com.ibm.etools.systems.model.impl.SystemResourceChangeEvent(
|
||||
firstSelectionParent,ISystemResourceChangeEvent.EVENT_REFRESH_REMOTE, null) );
|
||||
}
|
||||
}
|
||||
else
|
||||
SystemPlugin.logWarning("Hmm, selected parent is null on a move operation!");
|
||||
}*/
|
||||
super.copyComplete();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.wizard.IWizard;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.wizards.SystemNewFileWizard;
|
||||
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
||||
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||
import org.eclipse.rse.ui.SystemResources;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseWizardAction;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* An action for prompting the user with a wizard, for creating a new file
|
||||
*/
|
||||
public class SystemNewFileAction extends SystemBaseWizardAction
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor when you want to use the default label, tooltip and image
|
||||
*/
|
||||
public SystemNewFileAction(Shell parent)
|
||||
{
|
||||
this(SystemResources.ACTION_NEWFILE_LABEL,
|
||||
SystemResources.ACTION_NEWFILE_TOOLTIP,
|
||||
//PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE),
|
||||
SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWFILE_ID),
|
||||
parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor when you want to supply your own label, tooltip and image
|
||||
*/
|
||||
public SystemNewFileAction(String text,String tooltip,ImageDescriptor image,Shell parent)
|
||||
{
|
||||
super(text, tooltip, image, parent);
|
||||
setContextMenuGroup(ISystemContextMenuConstants.GROUP_NEW);
|
||||
allowOnMultipleSelection(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override of parent to create the wizard
|
||||
*/
|
||||
protected IWizard createWizard()
|
||||
{
|
||||
SystemNewFileWizard newFileWizard = new SystemNewFileWizard();
|
||||
// newFileWizard.setInputObject(getValue());
|
||||
return newFileWizard;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.SystemFileFilterStringEditPane;
|
||||
import org.eclipse.rse.filters.ISystemFilterPool;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration;
|
||||
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||
import org.eclipse.rse.ui.filters.actions.SystemNewFilterAction;
|
||||
import org.eclipse.rse.ui.filters.dialogs.SystemNewFilterWizard;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The action that displays the New File Filter wizard.
|
||||
* File Filters are typed filters that allow users to get a list of files meeting the filtering criteria.
|
||||
*/
|
||||
public class SystemNewFileFilterAction
|
||||
extends SystemNewFilterAction
|
||||
{
|
||||
//private RemoteFileSubSystemFactory inputSubsystemFactory;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SystemNewFileFilterAction(IRemoteFileSubSystemConfiguration subsystemFactory, ISystemFilterPool parentPool, Shell shell)
|
||||
|
||||
{
|
||||
super(shell, parentPool, SystemFileResources.ACTION_NEWFILTER_LABEL, SystemFileResources.ACTION_NEWFILTER_TOOLTIP,
|
||||
SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWFILTER_ID));
|
||||
|
||||
//setHelp(SystemPlugin.HELPPREFIX+"anff0000");
|
||||
//setDialogHelp(SystemPlugin.HELPPREFIX+"wnff0000");
|
||||
setHelp(SystemPlugin.HELPPREFIX+"actn0042");
|
||||
setDialogHelp(SystemPlugin.HELPPREFIX+"wnfr0000");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent filter pool that the new-filter actions need.
|
||||
*/
|
||||
public void setParentFilterPool(ISystemFilterPool parentPool)
|
||||
{
|
||||
this.parentPool = parentPool;
|
||||
}
|
||||
/**
|
||||
* Parent intercept.
|
||||
* <p>
|
||||
* Overridable extension. For those cases when you don't want to create your
|
||||
* own wizard subclass, but prefer to simply configure the default wizard.
|
||||
* <p>
|
||||
* Note, at the point this is called, all the base configuration, based on the
|
||||
* setters for this action, have been called.
|
||||
* <p>
|
||||
* We do it here versus via setters as it defers some work until the user actually
|
||||
* selects this action.
|
||||
*/
|
||||
protected void configureNewFilterWizard(SystemNewFilterWizard wizard)
|
||||
{
|
||||
// configuration that used to only be possible via subclasses...
|
||||
wizard.setWizardPageTitle(SystemFileResources.RESID_NEWFILEFILTER_PAGE1_TITLE);
|
||||
wizard.setWizardImage(SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWFILTERWIZARD_ID));
|
||||
wizard.setPage1Description(SystemFileResources.RESID_NEWFILEFILTER_PAGE1_DESCRIPTION);
|
||||
wizard.setFilterStringEditPane(new SystemFileFilterStringEditPane(wizard.getShell()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
import org.eclipse.rse.filters.ISystemFilterPool;
|
||||
import org.eclipse.rse.filters.ISystemFilterPoolReferenceManagerProvider;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile;
|
||||
import org.eclipse.rse.ui.filters.dialogs.SystemNewFilterWizard;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* Class for defining a new filter from a preselected folder
|
||||
*/
|
||||
public class SystemNewFileFilterFromFolderAction extends SystemNewFileFilterAction
|
||||
{
|
||||
private RemoteFile _selected;
|
||||
|
||||
/**
|
||||
* Constructor for SystemNewFileFilterFromFolderAction
|
||||
* @param parent
|
||||
*/
|
||||
public SystemNewFileFilterFromFolderAction(Shell parent)
|
||||
{
|
||||
// initially use null, but update based on selection
|
||||
super(null, null, parent);
|
||||
setHelp(SystemPlugin.HELPPREFIX+"actn0112");
|
||||
}
|
||||
|
||||
|
||||
public void run()
|
||||
{
|
||||
IRemoteFileSubSystem fileSubsystem = _selected.getParentRemoteFileSubSystem();
|
||||
ISubSystemConfiguration factory = fileSubsystem.getSubSystemConfiguration();
|
||||
ISystemFilterPool filterPool = fileSubsystem.getFilterPoolReferenceManager().getDefaultSystemFilterPoolManager().getFirstDefaultSystemFilterPool();
|
||||
setParentFilterPool(filterPool);
|
||||
setAllowFilterPoolSelection(fileSubsystem.getFilterPoolReferenceManager().getReferencedSystemFilterPools());
|
||||
super.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the selection changes in the systems view. This determines
|
||||
* the input object for the command and whether to enable or disable
|
||||
* the action.
|
||||
*
|
||||
* @param selection the current seleciton
|
||||
* @return whether to enable or disable the action
|
||||
*/
|
||||
public boolean updateSelection(IStructuredSelection selection)
|
||||
{
|
||||
boolean enable = false;
|
||||
|
||||
Iterator e = ((IStructuredSelection) selection).iterator();
|
||||
Object selected = e.next();
|
||||
|
||||
if (selected != null && selected instanceof IRemoteFile)
|
||||
{
|
||||
_selected = (RemoteFile) selected;
|
||||
//if (!_selected.isFile())
|
||||
{
|
||||
enable = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return enable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <i>Output method. Do not override.</i><br>
|
||||
* Get the contextual system filter pool reference manager provider. Will return non-null if the
|
||||
* current selection is a reference to a filter pool or filter, or a reference manager
|
||||
* provider.
|
||||
*/
|
||||
public ISystemFilterPoolReferenceManagerProvider getSystemFilterPoolReferenceManagerProvider()
|
||||
{
|
||||
return _selected.getParentRemoteFileSubSystem().getFilterPoolReferenceManager().getProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent intercept.
|
||||
* <p>
|
||||
* Overridable extension. For those cases when you don't want to create your
|
||||
* own wizard subclass, but prefer to simply configure the default wizard.
|
||||
* <p>
|
||||
* Note, at the point this is called, all the base configuration, based on the
|
||||
* setters for this action, have been called.
|
||||
* <p>
|
||||
* We do it here versus via setters as it defers some work until the user actually
|
||||
* selects this action.
|
||||
*/
|
||||
protected void configureNewFilterWizard(SystemNewFilterWizard wizard)
|
||||
{
|
||||
super.configureNewFilterWizard(wizard);
|
||||
String[] filters = new String[1];
|
||||
ISystemRemoteElementAdapter adapter = (ISystemRemoteElementAdapter)_selected.getAdapter(ISystemRemoteElementAdapter.class);
|
||||
filters[0] = adapter.getFilterStringFor(_selected);
|
||||
wizard.setDefaultFilterStrings(filters);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.wizard.IWizard;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.wizards.SystemNewFolderWizard;
|
||||
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
||||
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseWizardAction;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* An action for prompting the user with a wizard, for creating a new folder
|
||||
*/
|
||||
public class SystemNewFolderAction extends SystemBaseWizardAction
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor when you want to use the default label, tooltip and image
|
||||
*/
|
||||
public SystemNewFolderAction(Shell parent)
|
||||
{
|
||||
this(FileResources.ACTION_NEWFOLDER_LABEL,
|
||||
FileResources.ACTION_NEWFOLDER_TOOLTIP,
|
||||
SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_NEWFOLDER_ID),
|
||||
parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor when you want to supply your own label, tooltip and image
|
||||
*/
|
||||
public SystemNewFolderAction(String text, String tooltip, ImageDescriptor image, Shell parent)
|
||||
{
|
||||
super(text, tooltip, image, parent);
|
||||
setContextMenuGroup(ISystemContextMenuConstants.GROUP_NEW);
|
||||
allowOnMultipleSelection(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override of parent to create the wizard
|
||||
*/
|
||||
protected IWizard createWizard()
|
||||
{
|
||||
SystemNewFolderWizard newFolderWizard = new SystemNewFolderWizard();
|
||||
return newFolderWizard;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.rse.files.ui.dialogs.SystemRemoteArchiveDialog;
|
||||
import org.eclipse.rse.ui.dialogs.SystemRemoteResourceDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
public class SystemRemoteArchiveSelectAction extends
|
||||
SystemRemoteFileSelectAction
|
||||
{
|
||||
public SystemRemoteArchiveSelectAction(Shell shell)
|
||||
{
|
||||
super(shell);
|
||||
}
|
||||
|
||||
public SystemRemoteArchiveSelectAction(Shell shell, String label, String tooltip)
|
||||
{
|
||||
super(shell, label, tooltip);
|
||||
}
|
||||
|
||||
protected SystemRemoteResourceDialog createRemoteResourceDialog(Shell shell, String title)
|
||||
{
|
||||
return new SystemRemoteArchiveDialog(shell, title);
|
||||
}
|
||||
|
||||
protected SystemRemoteResourceDialog createRemoteResourceDialog(Shell shell)
|
||||
{
|
||||
return new SystemRemoteArchiveDialog(shell);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,377 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2005, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
|
||||
import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.core.subsystems.IRemoteLineReference;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.resources.ISystemTextEditor;
|
||||
import org.eclipse.rse.files.ui.resources.RemoteSourceLookupDirector;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.files.ui.resources.SystemIFileProperties;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell;
|
||||
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteError;
|
||||
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteOutput;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.ui.IEditorDescriptor;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.IEditorRegistry;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
|
||||
|
||||
/**
|
||||
* Open With menu class for openning remote files to a certain line number
|
||||
*/
|
||||
public class SystemRemoteFileLineOpenWithMenu extends SystemRemoteFileOpenWithMenu
|
||||
{
|
||||
protected IRemoteLineReference _remoteLine;
|
||||
protected IProject _associatedProject;
|
||||
|
||||
public void updateSelection(IStructuredSelection selection)
|
||||
{
|
||||
if (selection.size() == 1)
|
||||
{
|
||||
Object element = selection.getFirstElement();
|
||||
if (element instanceof IRemoteLineReference)
|
||||
{
|
||||
|
||||
_remoteLine = (IRemoteLineReference)element;
|
||||
_remoteFile = outputToFile(_remoteLine);
|
||||
if (_remoteFile == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_remoteLine instanceof IRemoteOutput)
|
||||
{
|
||||
IRemoteOutput output = (IRemoteOutput)_remoteLine;
|
||||
_associatedProject = ((IRemoteCommandShell)output.getParent()).getAssociatedProject();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fill(Menu menu, int index)
|
||||
{
|
||||
if (_associatedProject != null)
|
||||
{
|
||||
IEditorDescriptor defaultEditor = getDefaultTextEditor();
|
||||
// project file edit action if there's an associated project
|
||||
IEditorDescriptor projectEditDescriptor = getPreferredEditor(_remoteFile);
|
||||
createProjectFileMenuItem(menu, defaultEditor, projectEditDescriptor);
|
||||
}
|
||||
|
||||
super.fill(menu, index);
|
||||
}
|
||||
|
||||
|
||||
protected IEditorRegistry getEditorRegistry()
|
||||
{
|
||||
return SystemPlugin.getDefault().getWorkbench().getEditorRegistry();
|
||||
}
|
||||
|
||||
protected IEditorDescriptor getDefaultTextEditor()
|
||||
{
|
||||
IEditorRegistry registry = getEditorRegistry();
|
||||
return registry.findEditor("org.eclipse.ui.DefaultTextEditor");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the menu item for the editor descriptor.
|
||||
*
|
||||
* @param menu the menu to add the item to
|
||||
* @param descriptor the editor descriptor, or null for the system editor
|
||||
* @param preferredEditor the descriptor of the preferred editor, or <code>null</code>
|
||||
*/
|
||||
protected void createProjectFileMenuItem(Menu menu, final IEditorDescriptor descriptor, final IEditorDescriptor preferredEditor)
|
||||
{
|
||||
// XXX: Would be better to use bold here, but SWT does not support it.
|
||||
final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
|
||||
menuItem.setSelection(true);
|
||||
String pLabel = SystemMessage.sub(FileResources.RESID_OPEN_FROM_ASSOCIATED_PROJECT, "&1", _associatedProject.getName());
|
||||
menuItem.setText(pLabel);
|
||||
Image image = getImage(descriptor);
|
||||
if (image != null)
|
||||
{
|
||||
menuItem.setImage(image);
|
||||
}
|
||||
Listener listener = new Listener()
|
||||
{
|
||||
public void handleEvent(Event event)
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SWT.Selection:
|
||||
if(menuItem.getSelection())
|
||||
{
|
||||
openWorkspaceFile(_remoteFile, (IRemoteOutput)_remoteLine, descriptor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
menuItem.addListener(SWT.Selection, listener);
|
||||
}
|
||||
|
||||
|
||||
public static IRemoteFile outputToFile(IRemoteLineReference output)
|
||||
{
|
||||
IRemoteFile file = null;
|
||||
Object parent = output.getParent();
|
||||
IRemoteFileSubSystem fs = null;
|
||||
if (parent instanceof IRemoteCommandShell)
|
||||
{
|
||||
fs = RemoteFileUtility.getFileSubSystem(((IRemoteCommandShell)parent).getCommandSubSystem().getHost());
|
||||
}
|
||||
else if (parent instanceof IRemoteFile)
|
||||
{
|
||||
return (IRemoteFile) parent;
|
||||
}
|
||||
|
||||
if (fs != null)
|
||||
{
|
||||
String path = output.getAbsolutePath();
|
||||
if (path != null && path.length() > 0)
|
||||
{
|
||||
Object obj = null;
|
||||
try
|
||||
{
|
||||
obj = fs.getObjectWithAbsoluteName(path);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (obj != null && obj instanceof IRemoteFile)
|
||||
{
|
||||
file = (IRemoteFile) obj;
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void openEditor(IRemoteFile file, IEditorDescriptor descriptor)
|
||||
{
|
||||
SystemEditableRemoteFile editableFile = new SystemEditableRemoteFile(file, descriptor.getId());
|
||||
editableFile.open(SystemBasePlugin.getActiveWorkbenchShell());
|
||||
handleGotoLine();
|
||||
}
|
||||
|
||||
|
||||
protected void handleGotoLine()
|
||||
{
|
||||
handleGotoLine(_remoteFile, _remoteLine.getLine(), _remoteLine.getCharStart(), _remoteLine.getCharEnd());
|
||||
}
|
||||
|
||||
|
||||
public static void handleGotoLine(IRemoteFile remoteFile, int line, int charStart, int charEnd)
|
||||
{
|
||||
if (line > 0)
|
||||
{
|
||||
IWorkbench desktop = PlatformUI.getWorkbench();
|
||||
IWorkbenchPage persp = desktop.getActiveWorkbenchWindow().getActivePage();
|
||||
IEditorPart editor = null;
|
||||
String fileName = remoteFile.getAbsolutePath();
|
||||
IEditorReference[] editors = persp.getEditorReferences();
|
||||
for (int i = 0; i < editors.length; i++)
|
||||
{
|
||||
IEditorReference ref = editors[i];
|
||||
IEditorPart editorp = ref.getEditor(false);
|
||||
if (editorp != null)
|
||||
{
|
||||
IEditorInput einput = editorp.getEditorInput();
|
||||
if (einput instanceof IFileEditorInput)
|
||||
{
|
||||
IFileEditorInput input = (IFileEditorInput) einput;
|
||||
IFile efile = input.getFile();
|
||||
|
||||
SystemIFileProperties properties = new SystemIFileProperties(efile);
|
||||
String comparePath = properties.getRemoteFilePath();
|
||||
|
||||
if (comparePath != null && (comparePath.replace('\\','/').equals(fileName.replace('\\','/'))))
|
||||
{
|
||||
editor = editorp;
|
||||
persp.bringToTop(editor);
|
||||
if (editor instanceof ISystemTextEditor)
|
||||
{
|
||||
ISystemTextEditor lpex = (ISystemTextEditor)editor;
|
||||
lpex.gotoLine(line);
|
||||
lpex.selectText(charStart, charEnd);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
IMarker marker = efile.createMarker(IMarker.TEXT);
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, line);
|
||||
marker.setAttribute(IMarker.CHAR_START, charStart);
|
||||
marker.setAttribute(IMarker.CHAR_END, charEnd);
|
||||
|
||||
IDE.gotoMarker(editor, marker);
|
||||
|
||||
|
||||
}
|
||||
catch (CoreException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open workspace file associated with IRemoteCommandShell. If there is no associated project
|
||||
* return.
|
||||
* @param remoteFile
|
||||
* @param output
|
||||
* @return
|
||||
*/
|
||||
protected boolean openWorkspaceFile(IRemoteFile remoteFile, IRemoteOutput output, IEditorDescriptor desc)
|
||||
{
|
||||
IRemoteCommandShell cmd = (IRemoteCommandShell)(output.getParent());
|
||||
IProject associatedProject = cmd.getAssociatedProject();
|
||||
if (associatedProject != null)
|
||||
{
|
||||
ProjectSourceContainer container = new ProjectSourceContainer(associatedProject, false);
|
||||
ISourceLookupDirector director = new RemoteSourceLookupDirector();
|
||||
container.init(director);
|
||||
try
|
||||
{
|
||||
Object[] matches = container.findSourceElements(remoteFile.getName());
|
||||
for (int i = 0; i < matches.length; i++)
|
||||
{
|
||||
//System.out.println("match="+matches[i]);
|
||||
}
|
||||
|
||||
if (matches.length == 1)
|
||||
{
|
||||
IFile localMatch = (IFile)matches[0];
|
||||
|
||||
|
||||
|
||||
IWorkbenchPage activePage = SystemBasePlugin.getActiveWorkbenchWindow().getActivePage();
|
||||
|
||||
FileEditorInput finput = new FileEditorInput(localMatch);
|
||||
|
||||
if (desc == null)
|
||||
{
|
||||
desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(remoteFile.getName());
|
||||
}
|
||||
if (desc == null)
|
||||
{
|
||||
desc = getDefaultTextEditor();
|
||||
}
|
||||
String editorid = desc.getId();
|
||||
|
||||
IEditorPart editor = activePage.openEditor(finput, editorid);
|
||||
|
||||
int line = output.getLine();
|
||||
int charStart = output.getCharStart();
|
||||
int charEnd = output.getCharEnd();
|
||||
|
||||
try
|
||||
{
|
||||
IMarker marker = null;
|
||||
|
||||
// DKM - should we? this will populate the Problems view..but resources are actually remote
|
||||
if (output instanceof IRemoteError)
|
||||
{
|
||||
IRemoteError error = (IRemoteError)output;
|
||||
String type = error.getType();
|
||||
|
||||
marker = localMatch.createMarker(IMarker.TEXT);
|
||||
|
||||
if (type.equals("error"))
|
||||
{
|
||||
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
|
||||
}
|
||||
else if (type.equals("warning"))
|
||||
{
|
||||
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
|
||||
}
|
||||
else if (type.equals("informational"))
|
||||
{
|
||||
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
|
||||
}
|
||||
|
||||
marker.setAttribute(IMarker.MESSAGE, output.getText());
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, line);
|
||||
marker.setAttribute(IMarker.CHAR_START, charStart);
|
||||
marker.setAttribute(IMarker.CHAR_END, charEnd);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
marker = localMatch.createMarker(IMarker.TEXT);
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, line);
|
||||
marker.setAttribute(IMarker.CHAR_START, charStart);
|
||||
marker.setAttribute(IMarker.CHAR_END, charEnd);
|
||||
}
|
||||
IDE.gotoMarker(editor, marker);
|
||||
|
||||
|
||||
}
|
||||
catch (CoreException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,358 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2005, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import java.text.Collator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.jface.action.ContributionItem;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.files.ui.resources.UniversalFileTransferUtility;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.ui.IEditorDescriptor;
|
||||
import org.eclipse.ui.IEditorRegistry;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
|
||||
/**
|
||||
* Open with menu class for remote files
|
||||
*/
|
||||
public class SystemRemoteFileOpenWithMenu extends ContributionItem
|
||||
{
|
||||
protected IWorkbenchPage page;
|
||||
protected IRemoteFile _remoteFile;
|
||||
protected IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
|
||||
|
||||
private static Hashtable imageCache = new Hashtable(11);
|
||||
|
||||
/**
|
||||
* The id of this action.
|
||||
*/
|
||||
public static final String ID = PlatformUI.PLUGIN_ID + ".OpenWithMenu";//$NON-NLS-1$
|
||||
|
||||
/*
|
||||
* Compares the labels from two IEditorDescriptor objects
|
||||
*/
|
||||
private static final Comparator comparer = new Comparator()
|
||||
{
|
||||
private Collator collator = Collator.getInstance();
|
||||
|
||||
public int compare(Object arg0, Object arg1) {
|
||||
String s1 = ((IEditorDescriptor)arg0).getLabel();
|
||||
String s2 = ((IEditorDescriptor)arg1).getLabel();
|
||||
return collator.compare(s1, s2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new instance of <code>SystemOpenWithMenu</code>.
|
||||
*/
|
||||
public SystemRemoteFileOpenWithMenu()
|
||||
{
|
||||
super(ID);
|
||||
this.page = null;
|
||||
_remoteFile = null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes the IRemoteFile
|
||||
*/
|
||||
public void updateSelection(IStructuredSelection selection)
|
||||
{
|
||||
if (selection.size() == 1)
|
||||
{
|
||||
_remoteFile = (IRemoteFile)selection.getFirstElement();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an image to show for the corresponding editor descriptor.
|
||||
*
|
||||
* @param editorDesc the editor descriptor, or null for the system editor
|
||||
* @return the image or null
|
||||
*/
|
||||
protected Image getImage(IEditorDescriptor editorDesc) {
|
||||
ImageDescriptor imageDesc = getImageDescriptor(editorDesc);
|
||||
if (imageDesc == null) {
|
||||
return null;
|
||||
}
|
||||
Image image = (Image) imageCache.get(imageDesc);
|
||||
if (image == null) {
|
||||
image = imageDesc.createImage();
|
||||
imageCache.put(imageDesc, image);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
private String getFileName()
|
||||
{
|
||||
return _remoteFile.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the image descriptor for the given editor descriptor,
|
||||
* or null if it has no image.
|
||||
*/
|
||||
private ImageDescriptor getImageDescriptor(IEditorDescriptor editorDesc) {
|
||||
ImageDescriptor imageDesc = null;
|
||||
if (editorDesc == null) {
|
||||
imageDesc = registry.getImageDescriptor(getFileName());
|
||||
}
|
||||
else {
|
||||
imageDesc = editorDesc.getImageDescriptor();
|
||||
}
|
||||
if (imageDesc == null) {
|
||||
if (editorDesc.getId().equals(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID))
|
||||
imageDesc = registry.getSystemExternalEditorImageDescriptor(getFileName());
|
||||
}
|
||||
return imageDesc;
|
||||
}
|
||||
/**
|
||||
* Creates the menu item for the editor descriptor.
|
||||
*
|
||||
* @param menu the menu to add the item to
|
||||
* @param descriptor the editor descriptor, or null for the system editor
|
||||
* @param preferredEditor the descriptor of the preferred editor, or <code>null</code>
|
||||
*/
|
||||
protected void createMenuItem(Menu menu, final IEditorDescriptor descriptor, final IEditorDescriptor preferredEditor)
|
||||
{
|
||||
// XXX: Would be better to use bold here, but SWT does not support it.
|
||||
final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
|
||||
boolean isPreferred = preferredEditor != null && descriptor.getId().equals(preferredEditor.getId());
|
||||
menuItem.setSelection(isPreferred);
|
||||
menuItem.setText(descriptor.getLabel());
|
||||
Image image = getImage(descriptor);
|
||||
if (image != null) {
|
||||
menuItem.setImage(image);
|
||||
}
|
||||
Listener listener = new Listener() {
|
||||
public void handleEvent(Event event) {
|
||||
switch (event.type) {
|
||||
case SWT.Selection:
|
||||
if(menuItem.getSelection())
|
||||
{
|
||||
openEditor(_remoteFile, descriptor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
menuItem.addListener(SWT.Selection, listener);
|
||||
}
|
||||
|
||||
|
||||
protected void openEditor(IRemoteFile file, IEditorDescriptor descriptor)
|
||||
{
|
||||
SystemEditableRemoteFile editableFile = new SystemEditableRemoteFile(file, descriptor.getId());
|
||||
if (descriptor.getId().equals(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID))
|
||||
{
|
||||
editableFile.openInSystemEditor(SystemBasePlugin.getActiveWorkbenchShell());
|
||||
}
|
||||
else
|
||||
{
|
||||
editableFile.open(SystemBasePlugin.getActiveWorkbenchShell());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the local cache of the remote file, or <code>null</code> if none.
|
||||
* @param remoteFile the remote file.
|
||||
* @return the local cached resource, or <code>null</code> if none.
|
||||
*/
|
||||
private IFile getLocalResource(IRemoteFile remoteFile)
|
||||
{
|
||||
return (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred editor for the remote file. If the remote file has a cached local resource,
|
||||
* then returns the default editor associated with that resource, by calling <code>IDE.getDefaultEditor(IFile)</code>.
|
||||
* Otherwise, get the default editor associated with that remote file name from the editor registry.
|
||||
* @param remoteFile the remote file.
|
||||
* @return the preferred editor for the remote file, or <code>null</code> if none.
|
||||
*/
|
||||
protected IEditorDescriptor getPreferredEditor(IRemoteFile remoteFile) {
|
||||
|
||||
IFile localFile = getLocalResource(remoteFile);
|
||||
|
||||
if (localFile == null) {
|
||||
return registry.getDefaultEditor(remoteFile.getName());
|
||||
}
|
||||
else {
|
||||
return IDE.getDefaultEditor(localFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected IEditorDescriptor getDefaultEditor(IRemoteFile remoteFile)
|
||||
{
|
||||
IFile localFile = getLocalResource(remoteFile);
|
||||
|
||||
if (localFile == null) {
|
||||
return registry.getDefaultEditor(remoteFile.getName());
|
||||
}
|
||||
else {
|
||||
return IDE.getDefaultEditor(localFile);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setDefaultEditor(IRemoteFile remoteFile, String editorId)
|
||||
{
|
||||
IFile localFile = getLocalResource(remoteFile);
|
||||
|
||||
if (localFile == null) {
|
||||
registry.setDefaultEditor(remoteFile.getName(), editorId);
|
||||
}
|
||||
else {
|
||||
IDE.setDefaultEditor(localFile, editorId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected IEditorRegistry getEditorRegistry()
|
||||
{
|
||||
return SystemPlugin.getDefault().getWorkbench().getEditorRegistry();
|
||||
}
|
||||
|
||||
protected IEditorDescriptor getDefaultTextEditor()
|
||||
{
|
||||
IEditorRegistry registry = getEditorRegistry();
|
||||
return registry.findEditor("org.eclipse.ui.DefaultTextEditor");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Fills the menu with perspective items.
|
||||
*/
|
||||
public void fill(Menu menu, int index)
|
||||
{
|
||||
if (_remoteFile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IEditorDescriptor defaultEditor = registry.findEditor("org.eclipse.ui.DefaultTextEditor"); // may be null
|
||||
IEditorDescriptor preferredEditor = getPreferredEditor(_remoteFile); // may be null
|
||||
|
||||
Object[] editors = registry.getEditors(getFileName());
|
||||
Collections.sort(Arrays.asList(editors), comparer);
|
||||
|
||||
boolean defaultFound = false;
|
||||
|
||||
//Check that we don't add it twice. This is possible
|
||||
//if the same editor goes to two mappings.
|
||||
ArrayList alreadyMapped= new ArrayList();
|
||||
|
||||
for (int i = 0; i < editors.length; i++) {
|
||||
IEditorDescriptor editor = (IEditorDescriptor) editors[i];
|
||||
if(!alreadyMapped.contains(editor)){
|
||||
createMenuItem(menu, editor, preferredEditor);
|
||||
if (defaultEditor != null && editor.getId().equals(defaultEditor.getId()))
|
||||
defaultFound = true;
|
||||
alreadyMapped.add(editor);
|
||||
}
|
||||
}
|
||||
|
||||
// Only add a separator if there is something to separate
|
||||
if (editors.length > 0)
|
||||
new MenuItem(menu, SWT.SEPARATOR);
|
||||
|
||||
// Add default editor. Check it if it is saved as the preference.
|
||||
if (!defaultFound && defaultEditor != null) {
|
||||
createMenuItem(menu, defaultEditor, preferredEditor);
|
||||
}
|
||||
|
||||
// Add system editor (should never be null)
|
||||
IEditorDescriptor descriptor = registry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
|
||||
createMenuItem(menu, descriptor, preferredEditor);
|
||||
|
||||
//DKM- disable inplace editor for now
|
||||
/*
|
||||
// Add system in-place editor (can be null)
|
||||
descriptor = registry.findEditor(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID);
|
||||
if (descriptor != null) {
|
||||
createMenuItem(menu, descriptor, preferredEditor);
|
||||
}
|
||||
*/
|
||||
createDefaultMenuItem(menu, _remoteFile);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* Returns whether this menu is dynamic.
|
||||
*/
|
||||
public boolean isDynamic()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the menu item for clearing the current selection.
|
||||
*
|
||||
* @param menu the menu to add the item to
|
||||
* @param file the file bing edited
|
||||
* @param registry the editor registry
|
||||
*/
|
||||
protected void createDefaultMenuItem(Menu menu, final IRemoteFile file)
|
||||
{
|
||||
final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
|
||||
IEditorDescriptor defaultEditor = getDefaultEditor(file);
|
||||
menuItem.setSelection(defaultEditor == null);
|
||||
menuItem.setText(FileResources.DefaultEditorDescription_name);
|
||||
|
||||
Listener listener = new Listener()
|
||||
{
|
||||
public void handleEvent(Event event)
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SWT.Selection:
|
||||
if(menuItem.getSelection())
|
||||
{
|
||||
setDefaultEditor(file, null);
|
||||
|
||||
IEditorDescriptor defaultEditor = getDefaultEditor(file);
|
||||
openEditor(file, defaultEditor);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
menuItem.addListener(SWT.Selection, listener);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2005, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.files.ui.resources.SystemIFileProperties;
|
||||
import org.eclipse.rse.services.search.IHostSearchResult;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteSearchResult;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
|
||||
/**
|
||||
* Open with menu for remote search result openning
|
||||
*
|
||||
*/
|
||||
public class SystemRemoteFileSearchOpenWithMenu extends
|
||||
SystemRemoteFileLineOpenWithMenu
|
||||
{
|
||||
protected IRemoteSearchResult _searchResult;
|
||||
public void updateSelection(IStructuredSelection selection)
|
||||
{
|
||||
if (selection.size() == 1)
|
||||
{
|
||||
Object element = selection.getFirstElement();
|
||||
if (element instanceof IRemoteSearchResult)
|
||||
{
|
||||
_searchResult = (IRemoteSearchResult)element;
|
||||
_remoteFile = outputToFile(_searchResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleGotoLine()
|
||||
{
|
||||
handleGotoLine(_remoteFile, _searchResult);
|
||||
}
|
||||
|
||||
public static void handleGotoLine(IRemoteFile remoteFile, IHostSearchResult searchResult) {
|
||||
|
||||
int line = searchResult.getLine();
|
||||
|
||||
if (line > 0) {
|
||||
|
||||
IWorkbench desktop = PlatformUI.getWorkbench();
|
||||
IWorkbenchPage persp = desktop.getActiveWorkbenchWindow().getActivePage();
|
||||
IEditorPart editor = null;
|
||||
String fileName = remoteFile.getAbsolutePath();
|
||||
IEditorReference[] editors = persp.getEditorReferences();
|
||||
|
||||
for (int i = 0; i < editors.length; i++) {
|
||||
IEditorReference ref = editors[i];
|
||||
IEditorPart editorp = ref.getEditor(false);
|
||||
|
||||
if (editorp != null) {
|
||||
|
||||
IEditorInput einput = editorp.getEditorInput();
|
||||
|
||||
if (einput instanceof IFileEditorInput) {
|
||||
IFileEditorInput input = (IFileEditorInput)einput;
|
||||
IFile efile = input.getFile();
|
||||
|
||||
SystemIFileProperties properties = new SystemIFileProperties(efile);
|
||||
String comparePath = properties.getRemoteFilePath();
|
||||
|
||||
if (comparePath != null && (comparePath.replace('\\','/').equals(fileName.replace('\\','/')))) {
|
||||
editor = editorp;
|
||||
persp.bringToTop(editor);
|
||||
|
||||
int firstStartOffset = -1;
|
||||
int firstEndOffset = -1;
|
||||
|
||||
int matchSize = searchResult.numOfMatches();
|
||||
|
||||
if (matchSize > 0) {
|
||||
firstStartOffset = searchResult.getCharStart(0);
|
||||
firstEndOffset = searchResult.getCharEnd(0);
|
||||
}
|
||||
/* DKM- always use markers now
|
||||
if (editor instanceof ISystemTextEditor) {
|
||||
ISystemTextEditor lpex = (ISystemTextEditor)editor;
|
||||
lpex.gotoLine(line);
|
||||
lpex.selectText(firstStartOffset, firstEndOffset);
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
// create a marker for the first match
|
||||
IMarker firstMarker = createMarker(efile, line, firstStartOffset, firstEndOffset);
|
||||
|
||||
int charStart = -1;
|
||||
int charEnd = -1;
|
||||
|
||||
for (int idx = 1; idx < matchSize; idx++) {
|
||||
charStart = searchResult.getCharStart(idx);
|
||||
charEnd = searchResult.getCharEnd(idx);
|
||||
createMarker(efile, line, charStart, charEnd);
|
||||
}
|
||||
|
||||
// highlight the first marker (first match)
|
||||
IDE.gotoMarker(editor, firstMarker);
|
||||
}
|
||||
catch (CoreException e) {
|
||||
SystemBasePlugin.logError("Error occured trying to create a marker", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static IMarker createMarker(IFile file, int line, int charStart, int charEnd) throws CoreException {
|
||||
IMarker marker = file.createMarker(IMarker.TEXT);
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, line);
|
||||
marker.setAttribute(IMarker.CHAR_START, charStart);
|
||||
marker.setAttribute(IMarker.CHAR_END, charEnd);
|
||||
return marker;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,504 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.ISystemAddFileListener;
|
||||
import org.eclipse.rse.files.ui.dialogs.SystemRemoteFileDialog;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseDialogAction;
|
||||
import org.eclipse.rse.ui.dialogs.SystemRemoteResourceDialog;
|
||||
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
||||
import org.eclipse.rse.ui.view.SystemActionViewerFilter;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The action for allowing the user to select a remote folder.
|
||||
* <p>
|
||||
* To configure the functionality, call these methods:
|
||||
* <ul>
|
||||
* <li>{@link #setShowNewConnectionPrompt(boolean)}
|
||||
* <li>{@link #setHost(IHost) or #setDefaultConnection(SystemConnection)}
|
||||
* <li>{@link #setSystemType(String)} or {@link #setSystemTypes(String[])}
|
||||
* <li>{@link #setRootFolder(IHost, String)} or {@link #setRootFolder(IRemoteFile)} or {@link #setPreSelection(IRemoteFile)}
|
||||
* <li>{@link #setAutoExpandDepth(int)}
|
||||
* <li>{@link #setShowPropertySheet(boolean)}
|
||||
* <li>{@link #enableAddMode(ISystemAddFileListener)}
|
||||
* <li>{@link #setMultipleSelectionMode(boolean)}
|
||||
* <li>{@link #setSelectionValidator(IValidatorRemoteSelection)}
|
||||
* </ul>
|
||||
* <p>
|
||||
* To configure the text on the dialog, call these methods:
|
||||
* <ul>
|
||||
* <li>{@link #setDialogTitle(String)}
|
||||
* <li>{@link #setMessage(String)}
|
||||
* <li>{@link #setSelectionTreeToolTipText(String)}
|
||||
* </ul>
|
||||
* <p>
|
||||
* After running, call these methods to get the output:
|
||||
* <ul>
|
||||
* <li>{@link #getSelectedFolder()} or {@link #getSelectedFolders()}
|
||||
* <li>{@link #getSelectedConnection()}
|
||||
* </ul>
|
||||
*/
|
||||
public class SystemRemoteFileSelectAction extends SystemBaseDialogAction
|
||||
{
|
||||
private String[] systemTypes;
|
||||
private IHost systemConnection, outputConnection;
|
||||
private IRemoteFile preSelection;
|
||||
private String rootFolderAbsPath;
|
||||
private String message, treeTip, dlgTitle;
|
||||
private boolean showPropertySheet = false;
|
||||
private boolean showPropertySheetDetailsButtonInitialState;
|
||||
private boolean showPropertySheetDetailsButton = false;
|
||||
private boolean multipleSelectionMode = false;
|
||||
private boolean onlyConnection = false;
|
||||
private IValidatorRemoteSelection selectionValidator;
|
||||
private SystemActionViewerFilter customViewerFilter = null;
|
||||
|
||||
/**
|
||||
* Constructor that uses default action label and tooltip
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
*/
|
||||
public SystemRemoteFileSelectAction(Shell shell)
|
||||
{
|
||||
this(shell, FileResources.ACTION_SELECT_DIRECTORY_LABEL, FileResources.ACTION_SELECT_DIRECTORY_TOOLTIP);
|
||||
}
|
||||
/**
|
||||
* Constructor when you have your own action label and tooltip
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param label
|
||||
* @param tooltip
|
||||
*/
|
||||
public SystemRemoteFileSelectAction(Shell shell, String label, String tooltip)
|
||||
{
|
||||
super(label, tooltip, null, shell);
|
||||
super.setNeedsProgressMonitor(true); // the default is to include a monitor. Caller can override
|
||||
}
|
||||
|
||||
|
||||
// ------------------------
|
||||
// CONFIGURATION METHODS...
|
||||
// ------------------------
|
||||
/**
|
||||
* Set the title for the dialog. The default is "Browse for Folder"
|
||||
*/
|
||||
public void setDialogTitle(String title)
|
||||
{
|
||||
this.dlgTitle = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message shown at the top of the form
|
||||
*/
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
/**
|
||||
* Set the tooltip text for the remote systems tree from which an item is selected.
|
||||
*/
|
||||
public void setSelectionTreeToolTipText(String tip)
|
||||
{
|
||||
this.treeTip = tip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the system connection to restrict the user to seeing in the tree.
|
||||
*
|
||||
* @see #setRootFolder(IHost, String)
|
||||
*/
|
||||
public void setHost(IHost conn)
|
||||
{
|
||||
systemConnection = conn;
|
||||
onlyConnection = true;
|
||||
}
|
||||
/**
|
||||
* Set the connection to default the selection to
|
||||
*/
|
||||
public void setDefaultConnection(IHost conn)
|
||||
{
|
||||
systemConnection = conn;
|
||||
onlyConnection = false;
|
||||
}
|
||||
/**
|
||||
* Set the system types to restrict what connections the user sees, and what types of
|
||||
* connections they can create.
|
||||
* @param systemTypes An array of system type names
|
||||
*
|
||||
* @see org.eclipse.rse.core.ISystemTypes
|
||||
*/
|
||||
public void setSystemTypes(String[] systemTypes)
|
||||
{
|
||||
this.systemTypes = systemTypes;
|
||||
}
|
||||
/**
|
||||
* Convenience method to restrict to a single system type.
|
||||
* Same as setSystemTypes(new String[] {systemType})
|
||||
*
|
||||
* @param systemType The name of the system type to restrict to
|
||||
*
|
||||
* @see org.eclipse.rse.core.ISystemTypes
|
||||
*/
|
||||
public void setSystemType(String systemType)
|
||||
{
|
||||
if (systemType == null)
|
||||
setSystemTypes(null);
|
||||
else
|
||||
setSystemTypes(new String[] {systemType});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true if a "New Connection..." special connection is to be shown for creating new connections
|
||||
*/
|
||||
public void setShowNewConnectionPrompt(boolean show)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the root folder from which to start listing files.
|
||||
* This version identifies the folder via a connection object and absolute path.
|
||||
* There is another overload that identifies the folder via a single IRemoteFile object.
|
||||
* <p>
|
||||
* This call effectively transforms the select dialog by:
|
||||
* <ul>
|
||||
* <li>Preventing the user from selecting other connections
|
||||
* <li>Preventing the user from selecting other filter strings
|
||||
* </ul>
|
||||
*
|
||||
* @param connection The connection to the remote system containing the root folder
|
||||
* @param folderAbsolutePath The fully qualified folder to start listing from (eg: "\folder1\folder2")
|
||||
*
|
||||
* @see org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString
|
||||
*/
|
||||
public void setRootFolder(IHost connection, String folderAbsolutePath)
|
||||
{
|
||||
systemConnection = connection;
|
||||
rootFolderAbsPath = folderAbsolutePath;
|
||||
IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(connection);
|
||||
|
||||
if (ss != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
IRemoteFile rootFolder = ss.getRemoteFileObject(rootFolderAbsPath);
|
||||
if (rootFolder != null)
|
||||
{
|
||||
setPreSelection(rootFolder);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
onlyConnection = true;
|
||||
}
|
||||
/**
|
||||
* Set the root folder from which to start listing folders.
|
||||
* This version identifies the folder via an IRemoteFile object.
|
||||
* There is another overload that identifies the folder via a connection and folder path.
|
||||
* <p>
|
||||
* This call effectively transforms the select dialog by:
|
||||
* <ul>
|
||||
* <li>Preventing the user from selecting other connections
|
||||
* <li>Preventing the user from selecting other filter strings
|
||||
* </ul>
|
||||
*
|
||||
* @param rootFolder The IRemoteFile object representing the remote folder to start the list from
|
||||
*
|
||||
* @see org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString
|
||||
*/
|
||||
public void setRootFolder(IRemoteFile rootFolder)
|
||||
{
|
||||
setRootFolder(rootFolder.getSystemConnection(),rootFolder.getAbsolutePath());
|
||||
}
|
||||
/**
|
||||
* Set a file or folder to preselect. This will:
|
||||
* <ul>
|
||||
* <li>Set the parent folder as the root folder
|
||||
* <li>Pre-expand the parent folder
|
||||
* <li>Pre-select the given file or folder after expansion
|
||||
* </ul>
|
||||
* If there is no parent, then we were given a root. In which case we will
|
||||
* <ul>
|
||||
* <li>Force setRestrictFolders to false
|
||||
* <li>Pre-expand the root drives (Windows) or root files (Unix)
|
||||
* <li>Pre-select the given root drive (Windows only)
|
||||
* </ul>
|
||||
*/
|
||||
public void setPreSelection(IRemoteFile selection)
|
||||
{
|
||||
preSelection = selection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Enable Add mode. This means the OK button is replaced with an Add button, and
|
||||
* the Cancel with a Close button. When Add is pressed, the caller is called back.
|
||||
* The dialog is not exited until Close is pressed.
|
||||
* <p>
|
||||
* When a library is selected, the caller is called back to decide to enable the Add
|
||||
* button or not.
|
||||
*/
|
||||
public void enableAddMode(ISystemAddFileListener caller)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Overloaded method that allows setting the label and tooltip text of the Add button.
|
||||
* If you pass null for the label, the default is used ("Add").
|
||||
*/
|
||||
public void enableAddMode(ISystemAddFileListener caller, String addLabel, String addToolTipText)
|
||||
{
|
||||
enableAddMode(caller);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the property sheet on the right hand side, to show the properties of the
|
||||
* selected object.
|
||||
* <p>
|
||||
* Default is false
|
||||
*/
|
||||
public void setShowPropertySheet(boolean show)
|
||||
{
|
||||
this.showPropertySheet = show;
|
||||
}
|
||||
/**
|
||||
* Show the property sheet on the right hand side, to show the properties of the
|
||||
* selected object.
|
||||
* <p>
|
||||
* This overload shows a Details>>> button so the user can decide if they want to see the
|
||||
* property sheet.
|
||||
* <p>
|
||||
* @param show True if to show the property sheet within the dialog
|
||||
* @param initialState True if the property is to be initially displayed, false if it is not
|
||||
* to be displayed until the user presses the Details button.
|
||||
*/
|
||||
public void setShowPropertySheet(boolean show, boolean initialState)
|
||||
{
|
||||
setShowPropertySheet(show);
|
||||
if (show)
|
||||
{
|
||||
this.showPropertySheetDetailsButton = true;
|
||||
this.showPropertySheetDetailsButtonInitialState = initialState;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set multiple selection mode. Default is single selection mode
|
||||
* <p>
|
||||
* If you turn on multiple selection mode, you must use the getSelectedObjects()
|
||||
* method to retrieve the list of selected objects.
|
||||
*
|
||||
* @see #getSelectedObjects()
|
||||
*/
|
||||
public void setMultipleSelectionMode(boolean multiple)
|
||||
{
|
||||
this.multipleSelectionMode = multiple;
|
||||
}
|
||||
|
||||
/*
|
||||
* Indicates whether to allow selection of objects from differnet parents
|
||||
*/
|
||||
public void setAllowForMultipleParents(boolean multiple)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a validator to use when the user selects a remote file or folder.
|
||||
* This allows you to decide if OK should be enabled or not for that remote file or folder.
|
||||
*/
|
||||
public void setSelectionValidator(IValidatorRemoteSelection selectionValidator)
|
||||
{
|
||||
this.selectionValidator = selectionValidator;
|
||||
}
|
||||
|
||||
// -----------------
|
||||
// OUTPUT METHODS...
|
||||
// -----------------
|
||||
/**
|
||||
* Retrieve selected file object. If multiple files selected, returns the first.
|
||||
*/
|
||||
public IRemoteFile getSelectedFile()
|
||||
{
|
||||
Object o = getValue();
|
||||
if (o instanceof IRemoteFile[])
|
||||
return ((IRemoteFile[])o)[0];
|
||||
else if (o instanceof IRemoteFile)
|
||||
return (IRemoteFile)o;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Retrieve selected file objects. If no files selected, returns an array of zero.
|
||||
* If one file selected returns an array of one.
|
||||
*/
|
||||
public IRemoteFile[] getSelectedFiles()
|
||||
{
|
||||
Object o = getValue();
|
||||
if (o instanceof IRemoteFile[])
|
||||
return (IRemoteFile[])o;
|
||||
else if (o instanceof IRemoteFile)
|
||||
return new IRemoteFile[] {(IRemoteFile)o};
|
||||
else if (o instanceof Object[])
|
||||
{
|
||||
Object[] objs= (Object[])o;
|
||||
IRemoteFile[] files = new IRemoteFile[objs.length];
|
||||
for (int i = 0; i < objs.length; i++)
|
||||
{
|
||||
files[i]= (IRemoteFile)objs[i];
|
||||
}
|
||||
return files;
|
||||
}
|
||||
else
|
||||
return new IRemoteFile[0];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return all selected objects. This method will return an array of one
|
||||
* unless you have called setMultipleSelectionMode(true)!
|
||||
* <p>
|
||||
* It will always return null if the user cancelled the dialog.
|
||||
*
|
||||
* @see #setMultipleSelectionMode(boolean)
|
||||
*/
|
||||
public Object[] getSelectedObjects()
|
||||
{
|
||||
Object remoteObject = getValue();
|
||||
if (remoteObject == null)
|
||||
return null;
|
||||
else if (remoteObject instanceof Object[])
|
||||
return (Object[])remoteObject;
|
||||
else if (remoteObject instanceof IRemoteFile[])
|
||||
return (Object[])remoteObject;
|
||||
else if (remoteObject instanceof Object)
|
||||
return new Object[] {remoteObject};
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return selected connection
|
||||
*/
|
||||
public IHost getSelectedConnection()
|
||||
{
|
||||
return outputConnection;
|
||||
}
|
||||
|
||||
// -------------------
|
||||
// INTERNAL METHODS...
|
||||
// -------------------
|
||||
|
||||
protected SystemRemoteResourceDialog createRemoteResourceDialog(Shell shell, String title)
|
||||
{
|
||||
return new SystemRemoteFileDialog(shell, title);
|
||||
}
|
||||
|
||||
protected SystemRemoteResourceDialog createRemoteResourceDialog(Shell shell)
|
||||
{
|
||||
return new SystemRemoteFileDialog(shell);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by eclipse when user selects this action
|
||||
*/
|
||||
protected Dialog createDialog(Shell shell)
|
||||
{
|
||||
SystemRemoteResourceDialog dlg = null;
|
||||
if (dlgTitle == null)
|
||||
{
|
||||
dlg = createRemoteResourceDialog(shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg = createRemoteResourceDialog(shell, dlgTitle);
|
||||
}
|
||||
|
||||
if (customViewerFilter != null)
|
||||
{
|
||||
dlg.setCustomViewerFilter(customViewerFilter);
|
||||
}
|
||||
dlg.setMultipleSelectionMode(multipleSelectionMode);
|
||||
|
||||
if (message != null)
|
||||
dlg.setMessage(message);
|
||||
if (treeTip != null)
|
||||
dlg.setSelectionTreeToolTipText(treeTip);
|
||||
|
||||
if (systemConnection != null)
|
||||
{
|
||||
dlg.setDefaultSystemConnection(systemConnection, onlyConnection);
|
||||
}
|
||||
|
||||
if (systemTypes != null)
|
||||
{
|
||||
dlg.setSystemTypes(systemTypes);
|
||||
}
|
||||
|
||||
if (preSelection != null)
|
||||
{
|
||||
dlg.setPreSelection(preSelection);
|
||||
}
|
||||
|
||||
if (showPropertySheet)
|
||||
{
|
||||
if (showPropertySheetDetailsButton)
|
||||
dlg.setShowPropertySheet(true, showPropertySheetDetailsButtonInitialState);
|
||||
else
|
||||
dlg.setShowPropertySheet(true);
|
||||
}
|
||||
if (selectionValidator != null)
|
||||
dlg.setSelectionValidator(selectionValidator);
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by parent. We return the selected object
|
||||
*/
|
||||
protected Object getDialogValue(Dialog dlg)
|
||||
{
|
||||
SystemRemoteResourceDialog ourDlg = (SystemRemoteResourceDialog)dlg;
|
||||
Object outputObject = null;
|
||||
outputConnection = null;
|
||||
if (!ourDlg.wasCancelled())
|
||||
{
|
||||
if (multipleSelectionMode)
|
||||
outputObject = ourDlg.getSelectedObjects();
|
||||
else
|
||||
outputObject = ourDlg.getSelectedObject();
|
||||
outputConnection = ourDlg.getSelectedConnection();
|
||||
}
|
||||
return outputObject; // parent class calls setValue on what we return
|
||||
}
|
||||
|
||||
public void setCustomViewerFilter(SystemActionViewerFilter filter)
|
||||
{
|
||||
customViewerFilter = filter;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.rse.files.ui.dialogs.SystemRemoteFolderDialog;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.dialogs.SystemRemoteResourceDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
public class SystemRemoteFolderSelectAction extends
|
||||
SystemRemoteFileSelectAction
|
||||
{
|
||||
public SystemRemoteFolderSelectAction(Shell shell)
|
||||
{
|
||||
super(shell);
|
||||
}
|
||||
|
||||
public SystemRemoteFolderSelectAction(Shell shell, String label, String tooltip)
|
||||
{
|
||||
super(shell, label, tooltip);
|
||||
}
|
||||
|
||||
protected SystemRemoteResourceDialog createRemoteResourceDialog(Shell shell, String title)
|
||||
{
|
||||
return new SystemRemoteFolderDialog(shell, title);
|
||||
}
|
||||
|
||||
protected SystemRemoteResourceDialog createRemoteResourceDialog(Shell shell)
|
||||
{
|
||||
return new SystemRemoteFolderDialog(shell);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected folder object. If multiple folders selected, returns the first.
|
||||
*/
|
||||
public IRemoteFile getSelectedFolder()
|
||||
{
|
||||
Object o = getValue();
|
||||
if (o instanceof IRemoteFile[])
|
||||
return ((IRemoteFile[])o)[0];
|
||||
else if (o instanceof IRemoteFile)
|
||||
return (IRemoteFile)o;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Retrieve selected folder objects. If no folders selected, returns an array of zero.
|
||||
* If one folder selected returns an array of one.
|
||||
*/
|
||||
public IRemoteFile[] getSelectedFolders()
|
||||
{
|
||||
Object o = getValue();
|
||||
if (o instanceof Object[]) {
|
||||
|
||||
Object[] temp = (Object[])o;
|
||||
|
||||
IRemoteFile[] files = new IRemoteFile[temp.length];
|
||||
|
||||
// ensure all objects are IRemoteFiles
|
||||
for (int i = 0; i < temp.length; i++) {
|
||||
|
||||
if (temp[i] instanceof IRemoteFile) {
|
||||
files[i] = (IRemoteFile)temp[i];
|
||||
}
|
||||
// should never happen
|
||||
else {
|
||||
return new IRemoteFile[0];
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
if (o instanceof IRemoteFile[])
|
||||
return (IRemoteFile[])o;
|
||||
else if (o instanceof IRemoteFile)
|
||||
return new IRemoteFile[] {(IRemoteFile)o};
|
||||
else
|
||||
return new IRemoteFile[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.compare.internal.ICompareContextIds;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
public class SystemReplaceWithEditionAction extends SystemEditionAction
|
||||
{
|
||||
|
||||
public SystemReplaceWithEditionAction(Shell parent)
|
||||
{
|
||||
super(parent,
|
||||
FileResources.ACTION_REPLACEWITH_HISTORY_LABEL,
|
||||
FileResources.ACTION_REPLACEWITH_HISTORY_TOOLTIP,
|
||||
"org.eclipse.compare.internal.ReplaceWithEditionAction", //$NON-NLS-1$
|
||||
true);
|
||||
|
||||
this.fHelpContextId= ICompareContextIds.REPLACE_WITH_EDITION_DIALOG;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.search.SystemSearchPage;
|
||||
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||
import org.eclipse.rse.ui.SystemResources;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.search.ui.NewSearchUI;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
public class SystemSearchAction extends SystemBaseAction {
|
||||
|
||||
|
||||
public SystemSearchAction(Shell parent) {
|
||||
super(SystemResources.ACTION_SEARCH_LABEL,
|
||||
SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_SEARCH_ID), parent);
|
||||
setToolTipText(SystemResources.ACTION_SEARCH_TOOLTIP);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "rsdi0000");
|
||||
|
||||
allowOnMultipleSelection(false);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
NewSearchUI.openSearchDialog(SystemBasePlugin.getActiveWorkbenchWindow(), SystemSearchPage.SYSTEM_SEARCH_PAGE_ID);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteSearchResult;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
public class SystemSearchBrowseFileLineAction extends SystemSearchEditFileLineAction {
|
||||
|
||||
/**
|
||||
* Constructor to create an edit action that jumps to a file line.
|
||||
* @param text the label for the action.
|
||||
* @param tooltip the tooltip for the action.
|
||||
* @param image the image for the action.
|
||||
* @param parent the parent shell.
|
||||
* @param editorId the editor id.
|
||||
* @param remoteFile the remote file that is to be opened.
|
||||
* @param line the line number.
|
||||
*/
|
||||
public SystemSearchBrowseFileLineAction(String text, String tooltip, ImageDescriptor image, Shell parent, String editorId, IRemoteFile remoteFile, IRemoteSearchResult searchResult) {
|
||||
super(text, tooltip, image, parent, editorId, remoteFile, searchResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.rse.files.ui.actions.SystemSearchEditFileAction#process(IRemoteFile)
|
||||
*/
|
||||
protected void process(IRemoteFile remoteFile) {
|
||||
SystemEditableRemoteFile editableFile = new SystemEditableRemoteFile(remoteFile, _editorId);
|
||||
editableFile.open(SystemBasePlugin.getActiveWorkbenchShell(), true);
|
||||
handleGotoLine(_remoteFile, _searchResult);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.files.ui.resources.SystemIFileProperties;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteSearchResult;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
|
||||
|
||||
/**
|
||||
* Edit action used by search to create markers for all matches in a line and highlight the first match.
|
||||
*/
|
||||
public class SystemSearchEditFileLineAction extends SystemEditFileAction {
|
||||
|
||||
protected IRemoteFile _remoteFile;
|
||||
protected IRemoteSearchResult _searchResult;
|
||||
|
||||
/**
|
||||
* Constructor to create an edit action that jumps to a file line.
|
||||
* @param text the label for the action.
|
||||
* @param tooltip the tooltip for the action.
|
||||
* @param image the image for the action.
|
||||
* @param parent the parent shell.
|
||||
* @param editorId the editor id.
|
||||
* @param remoteFile the remote file that is to be opened.
|
||||
* @param line the line number.
|
||||
*/
|
||||
public SystemSearchEditFileLineAction(String text, String tooltip, ImageDescriptor image, Shell parent, String editorId, IRemoteFile remoteFile, IRemoteSearchResult searchResult) {
|
||||
super(text, tooltip, image, parent, editorId);
|
||||
this._remoteFile = remoteFile;
|
||||
this._searchResult = searchResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls process().
|
||||
*/
|
||||
public void run() {
|
||||
process(_remoteFile, _searchResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the remote file selection.
|
||||
*/
|
||||
public void process(IRemoteFile remoteFile, IRemoteSearchResult searchResult) {
|
||||
super.process(remoteFile);
|
||||
handleGotoLine(remoteFile, searchResult);
|
||||
}
|
||||
|
||||
public static void handleGotoLine(IRemoteFile remoteFile, IRemoteSearchResult searchResult) {
|
||||
|
||||
int line = searchResult.getLine();
|
||||
|
||||
if (line > 0) {
|
||||
|
||||
IWorkbench desktop = PlatformUI.getWorkbench();
|
||||
IWorkbenchPage persp = desktop.getActiveWorkbenchWindow().getActivePage();
|
||||
IEditorPart editor = null;
|
||||
String fileName = remoteFile.getAbsolutePath();
|
||||
IEditorReference[] editors = persp.getEditorReferences();
|
||||
|
||||
for (int i = 0; i < editors.length; i++) {
|
||||
IEditorReference ref = editors[i];
|
||||
IEditorPart editorp = ref.getEditor(false);
|
||||
|
||||
if (editorp != null) {
|
||||
|
||||
IEditorInput einput = editorp.getEditorInput();
|
||||
|
||||
if (einput instanceof IFileEditorInput) {
|
||||
IFileEditorInput input = (IFileEditorInput)einput;
|
||||
IFile efile = input.getFile();
|
||||
|
||||
SystemIFileProperties properties = new SystemIFileProperties(efile);
|
||||
String comparePath = properties.getRemoteFilePath();
|
||||
|
||||
if (comparePath != null && (comparePath.replace('\\','/').equals(fileName.replace('\\','/')))) {
|
||||
editor = editorp;
|
||||
persp.bringToTop(editor);
|
||||
|
||||
int firstStartOffset = -1;
|
||||
int firstEndOffset = -1;
|
||||
|
||||
int matchSize = searchResult.numOfMatches();
|
||||
|
||||
if (matchSize > 0) {
|
||||
firstStartOffset = searchResult.getCharStart(0);
|
||||
firstEndOffset = searchResult.getCharEnd(0);
|
||||
}
|
||||
/* DKM- always use markers now
|
||||
if (editor instanceof ISystemTextEditor) {
|
||||
ISystemTextEditor lpex = (ISystemTextEditor)editor;
|
||||
lpex.gotoLine(line);
|
||||
lpex.selectText(firstStartOffset, firstEndOffset);
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
|
||||
try {
|
||||
|
||||
// create a marker for the first match
|
||||
IMarker firstMarker = createMarker(efile, line, firstStartOffset, firstEndOffset);
|
||||
|
||||
int charStart = -1;
|
||||
int charEnd = -1;
|
||||
|
||||
for (int idx = 1; idx < matchSize; idx++) {
|
||||
charStart = searchResult.getCharStart(idx);
|
||||
charEnd = searchResult.getCharEnd(idx);
|
||||
createMarker(efile, line, charStart, charEnd);
|
||||
}
|
||||
|
||||
// highlight the first marker (first match)
|
||||
IDE.gotoMarker(editor, firstMarker);
|
||||
}
|
||||
catch (CoreException e) {
|
||||
SystemBasePlugin.logError("Error occured trying to create a marker", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static IMarker createMarker(IFile file, int line, int charStart, int charEnd) throws CoreException {
|
||||
IMarker marker = file.createMarker(IMarker.TEXT);
|
||||
marker.setAttribute(IMarker.LINE_NUMBER, line);
|
||||
marker.setAttribute(IMarker.CHAR_START, charStart);
|
||||
marker.setAttribute(IMarker.CHAR_END, charEnd);
|
||||
return marker;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseDialogAction;
|
||||
import org.eclipse.rse.ui.dialogs.SystemSelectFileTypesDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* The action for allowing the user to select one or more file types, using the Eclipse
|
||||
* dialog for this. The types are from the file editor registry, as specified in the
|
||||
* Workbench preferences.
|
||||
* <p>
|
||||
* To set preselected types, use {@link #setTypes(List)} or {@link #setTypes(String[])}.
|
||||
* Or, if you have single string of comma-separated types, call {@link #setTypes(String)}.
|
||||
* <p>
|
||||
* After running, and checking wasCancelled(), you can query the selected types
|
||||
* using one of:
|
||||
* <ol>
|
||||
* <li>{@link #getTypes()} to retrieve the selected types as a List
|
||||
* <li>{@link #getTypesArray()} to retrieve the selected types as a String array
|
||||
* <li>{@link #getTypesString()} to retrieve the selected types as a single String of comma-delimited selections
|
||||
* <p>
|
||||
* Note the types are remembered after running, so a subsequent run will result in the previous types
|
||||
* being preselected, assuming you re-use the same instance of this class.
|
||||
*
|
||||
* @see org.eclipse.rse.ui.dialogs.SystemSelectFileTypesDialog
|
||||
*/
|
||||
public class SystemSelectFileTypesAction extends SystemBaseDialogAction
|
||||
{
|
||||
protected List types = new ArrayList();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* To set preselected types, use {@link #setTypes(List)} or {@link #setTypes(String[])}.
|
||||
* Note the types are remember after running, so a subsequent run will result in the previous types
|
||||
* being preselected.
|
||||
*/
|
||||
public SystemSelectFileTypesAction(Shell shell)
|
||||
{
|
||||
super(SystemFileResources.ACTION_SELECTFILETYPES_LABEL, SystemFileResources.ACTION_SELECTFILETYPES_TOOLTIP, null, shell);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current input types as a String array.
|
||||
* Each type is a file name extension, without the dot, as in "java" or "class"
|
||||
*/
|
||||
public void setTypes(String[] types)
|
||||
{
|
||||
this.types = Arrays.asList(types);
|
||||
}
|
||||
/**
|
||||
* Set the current input types as a java.util List, such as ArrayList
|
||||
* Each type is a file name extension, without the dot, as in "java" or "class"
|
||||
*/
|
||||
public void setTypes(List types)
|
||||
{
|
||||
this.types = types;
|
||||
}
|
||||
/**
|
||||
* Set the current input types given a comma-separated list as a single String.
|
||||
*/
|
||||
public void setTypes(String typeString)
|
||||
{
|
||||
setTypes(RemoteFileFilterString.parseTypes(typeString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the selected file types after running the action. Returns an ArrayList
|
||||
*/
|
||||
public List getTypes()
|
||||
{
|
||||
return types;
|
||||
}
|
||||
/**
|
||||
* Get the selected file types after running the action. Returns a String array
|
||||
*/
|
||||
public String[] getTypesArray()
|
||||
{
|
||||
String[] typesArray = new String[types.size()];
|
||||
Iterator i = types.iterator();
|
||||
int idx=0;
|
||||
while (i.hasNext())
|
||||
typesArray[idx++] = (String)i.next();
|
||||
return typesArray;
|
||||
}
|
||||
/**
|
||||
* Get the selected file types as a concatenated list of strings, comma-separated
|
||||
*/
|
||||
public String getTypesString()
|
||||
{
|
||||
return RemoteFileFilterString.getTypesString(getTypesArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the dialog was cancelled by the user.
|
||||
* Only valid after calling run().
|
||||
*/
|
||||
public boolean wasCancelled()
|
||||
{
|
||||
return (getValue() == null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create and return the dialog
|
||||
*/
|
||||
public Dialog createDialog(Shell parent)
|
||||
{
|
||||
SystemSelectFileTypesDialog dialog =
|
||||
new SystemSelectFileTypesDialog(getShell(), types);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent abstract method.
|
||||
* Called after dialog runs, to retrieve the value from the dialog.
|
||||
* Will return null if dialog cancelled.
|
||||
*/
|
||||
public Object getDialogValue(Dialog dlg)
|
||||
{
|
||||
Object[] result = ((SystemSelectFileTypesDialog)dlg).getResult();
|
||||
if (result != null)
|
||||
{
|
||||
types = new ArrayList(result.length);
|
||||
for (int idx = 0; idx < result.length; idx++)
|
||||
types.add(result[idx]);
|
||||
return types;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,524 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.ISystemAddFileListener;
|
||||
import org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseDialogAction;
|
||||
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* The action for allowing the user to select a remote file.
|
||||
* <p>
|
||||
* To configure, call these methods:
|
||||
* <ul>
|
||||
* <li>{@link #setShowNewConnectionPrompt(boolean)}
|
||||
* <li>{@link #setHost(IHost) or #setDefaultConnection(SystemConnection)}
|
||||
* <li>{@link #setSystemType(String)} or {@link #setSystemTypes(String[])}
|
||||
* <li>{@link #setRootFolder(IHost, String)} or {@link #setRootFolder(IRemoteFile)} or {@link #setPreSelection(IRemoteFile)}
|
||||
* <li>{@link #setFileTypes(String[])} or {@link #setFileTypes(String)}
|
||||
* <li>{@link #setAutoExpandDepth(int)}
|
||||
* <li>{@link #setShowPropertySheet(boolean)} or {@link #setShowPropertySheet(boolean,boolean)}
|
||||
* <li>{@link #enableAddMode(ISystemAddFileListener)}
|
||||
* <li>{@link #setMultipleSelectionMode(boolean)}
|
||||
* <li>{@link #setSelectionValidator(IValidatorRemoteSelection)}
|
||||
* </ul>
|
||||
* <p>
|
||||
* Call these methods to configure the text on the dialog
|
||||
* <ul>
|
||||
* <li>{@link #setDialogTitle(String)}
|
||||
* <li>{@link #setMessage(String)}
|
||||
* <li>{@link #setSelectionTreeToolTipText(String)}
|
||||
* </ul>
|
||||
* <p>
|
||||
* After running, call these methods to get the output:
|
||||
* <ul>
|
||||
* <li>{@link #getSelectedFile()} or {@link #getSelectedFiles()}
|
||||
* <li>{@link #getSelectedConnection()}
|
||||
* </ul>
|
||||
*/
|
||||
public class SystemSelectRemoteFileAction extends SystemBaseDialogAction
|
||||
{
|
||||
private String[] systemTypes;
|
||||
private IHost systemConnection, outputConnection;
|
||||
private IHost rootFolderConnection;
|
||||
private IRemoteFile preSelection;
|
||||
private String rootFolderAbsPath, fileTypes;
|
||||
private String message, treeTip, dlgTitle;
|
||||
private String addLabel, addToolTipText;
|
||||
private int expandDepth = 0;
|
||||
private boolean showNewConnectionPrompt = true;
|
||||
private boolean restrictFolders = false;
|
||||
private boolean showPropertySheet = false;
|
||||
private boolean showPropertySheetDetailsButtonInitialState;
|
||||
private boolean showPropertySheetDetailsButton = false;
|
||||
private boolean multipleSelectionMode = false;
|
||||
private boolean onlyConnection = false;
|
||||
private boolean allowFolderSelection = true;
|
||||
private ISystemAddFileListener addButtonCallback = null;
|
||||
private IValidatorRemoteSelection selectionValidator;
|
||||
private List viewerFilters = new ArrayList();
|
||||
|
||||
/**
|
||||
* Constructor that uses default action label and tooltip
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
*/
|
||||
public SystemSelectRemoteFileAction(Shell shell)
|
||||
{
|
||||
this(shell, FileResources.ACTION_SELECT_FILE_LABEL, FileResources.ACTION_SELECT_FILE_TOOLTIP);
|
||||
}
|
||||
/**
|
||||
* Constructor when you have your own action label and tooltip
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param label
|
||||
* @param tooltip
|
||||
*/
|
||||
public SystemSelectRemoteFileAction(Shell shell, String label, String tooltip)
|
||||
{
|
||||
super(label, tooltip, null, shell);
|
||||
super.setNeedsProgressMonitor(true); // the default is to include a monitor. Caller can override
|
||||
}
|
||||
|
||||
|
||||
// ------------------------
|
||||
// CONFIGURATION METHODS...
|
||||
// ------------------------
|
||||
/**
|
||||
* Set the system connection to restrict the user to seeing in the tree.
|
||||
*
|
||||
* @see #setRootFolder(IHost, String)
|
||||
*/
|
||||
public void setHost(IHost conn)
|
||||
{
|
||||
systemConnection = conn;
|
||||
onlyConnection = true;
|
||||
}
|
||||
/**
|
||||
* Set the connection to default the selection to
|
||||
*/
|
||||
public void setDefaultConnection(IHost conn)
|
||||
{
|
||||
systemConnection = conn;
|
||||
onlyConnection = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the system types to restrict what connections the user sees, and what types of
|
||||
* connections they can create.
|
||||
* @param systemTypes An array of system type names
|
||||
*
|
||||
* @see org.eclipse.rse.core.ISystemTypes
|
||||
*/
|
||||
public void setSystemTypes(String[] systemTypes)
|
||||
{
|
||||
this.systemTypes = systemTypes;
|
||||
}
|
||||
/**
|
||||
* Convenience method to restrict to a single system type.
|
||||
* Same as setSystemTypes(new String[] {systemType})
|
||||
*
|
||||
* @param systemType The name of the system type to restrict to
|
||||
*
|
||||
* @see org.eclipse.rse.core.ISystemTypes
|
||||
*/
|
||||
public void setSystemType(String systemType)
|
||||
{
|
||||
if (systemType == null)
|
||||
setSystemTypes(null);
|
||||
else
|
||||
setSystemTypes(new String[] {systemType});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true if a "New Connection..." special connection is to be shown for creating new connections
|
||||
*/
|
||||
public void setShowNewConnectionPrompt(boolean show)
|
||||
{
|
||||
this.showNewConnectionPrompt = show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the zero-based auto-expand level for the tree. The default is zero, meaning
|
||||
* only show the connections.
|
||||
*/
|
||||
public void setAutoExpandDepth(int depth)
|
||||
{
|
||||
this.expandDepth = depth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root folder from which to start listing files.
|
||||
* This version identifies the folder via a connection object and absolute path.
|
||||
* There is another overload that identifies the folder via a single IRemoteFile object.
|
||||
*
|
||||
* @param connection The connection to the remote system containing the root folder
|
||||
* @param folderAbsolutePath The fully qualified folder to start listing from (eg: "\folder1\folder2")
|
||||
*/
|
||||
public void setRootFolder(IHost connection, String folderAbsolutePath)
|
||||
{
|
||||
rootFolderConnection = connection;
|
||||
rootFolderAbsPath = folderAbsolutePath;
|
||||
}
|
||||
/**
|
||||
* Set the root folder from which to start listing files.
|
||||
* This version identifies the folder via an IRemoteFile object.
|
||||
* There is another overload that identifies the folder via a connection and folder path.
|
||||
*
|
||||
* @param rootFolder The IRemoteFile object representing the remote folder to start the list from
|
||||
*/
|
||||
public void setRootFolder(IRemoteFile rootFolder)
|
||||
{
|
||||
setRootFolder(rootFolder.getSystemConnection(),rootFolder.getAbsolutePath());
|
||||
}
|
||||
/**
|
||||
* Set a file or folder to preselect. This will:
|
||||
* <ul>
|
||||
* <li>Set the parent folder as the root folder
|
||||
* <li>Pre-expand the parent folder
|
||||
* <li>Pre-select the given file or folder after expansion
|
||||
* </ul>
|
||||
* If there is no parent, then we were given a root. In which case we will
|
||||
* <ul>
|
||||
* <li>Force setRestrictFolders to false
|
||||
* <li>Pre-expand the root drives (Windows) or root files (Unix)
|
||||
* <li>Pre-select the given root drive (Windows only)
|
||||
* </ul>
|
||||
*/
|
||||
public void setPreSelection(IRemoteFile selection)
|
||||
{
|
||||
preSelection = selection;
|
||||
}
|
||||
|
||||
/**
|
||||
* For files mode, restrict the files list by an array of file types
|
||||
*/
|
||||
public void setFileTypes(String[] fileTypes)
|
||||
{
|
||||
if (fileTypes != null)
|
||||
this.fileTypes = RemoteFileFilterString.getTypesString(fileTypes);
|
||||
else
|
||||
this.fileTypes = null;
|
||||
}
|
||||
/**
|
||||
* For files mode, restrict the files list by a comman-delimited array of file types.
|
||||
* The last type must also end in a comma. Eg "java, class," or "class,".
|
||||
*/
|
||||
public void setFileTypes(String fileTypes)
|
||||
{
|
||||
this.fileTypes = fileTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether setRootFolder should prevent the user from being able to see or select
|
||||
* any other folder. This causes two effects:
|
||||
* <ol>
|
||||
* <li>The special filter for root/drives is not shown
|
||||
* <li>No subfolders are listed in the root folder
|
||||
* </ol>
|
||||
*/
|
||||
public void setRestrictFolders(boolean restrict)
|
||||
{
|
||||
this.restrictFolders = restrict;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable Add mode. This means the OK button is replaced with an Add button, and
|
||||
* the Cancel with a Close button. When Add is pressed, the caller is called back.
|
||||
* The dialog is not exited until Close is pressed.
|
||||
* <p>
|
||||
* When a library is selected, the caller is called back to decide to enable the Add
|
||||
* button or not.
|
||||
*/
|
||||
public void enableAddMode(ISystemAddFileListener caller)
|
||||
{
|
||||
this.addButtonCallback = caller;
|
||||
}
|
||||
/**
|
||||
* Overloaded method that allows setting the label and tooltip text of the Add button.
|
||||
* If you pass null for the label, the default is used ("Add").
|
||||
*/
|
||||
public void enableAddMode(ISystemAddFileListener caller, String addLabel, String addToolTipText)
|
||||
{
|
||||
enableAddMode(caller);
|
||||
this.addLabel = addLabel;
|
||||
this.addToolTipText = addToolTipText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the property sheet on the right hand side, to show the properties of the
|
||||
* selected object.
|
||||
* <p>
|
||||
* Default is false
|
||||
*/
|
||||
public void setShowPropertySheet(boolean show)
|
||||
{
|
||||
this.showPropertySheet = show;
|
||||
}
|
||||
/**
|
||||
* Show the property sheet on the right hand side, to show the properties of the
|
||||
* selected object.
|
||||
* <p>
|
||||
* This overload shows a Details>>> button so the user can decide if they want to see the
|
||||
* property sheet.
|
||||
* <p>
|
||||
* @param show True if to show the property sheet within the dialog
|
||||
* @param initialState True if the property is to be initially displayed, false if it is not
|
||||
* to be displayed until the user presses the Details button.
|
||||
*/
|
||||
public void setShowPropertySheet(boolean show, boolean initialState)
|
||||
{
|
||||
setShowPropertySheet(show);
|
||||
if (show)
|
||||
{
|
||||
this.showPropertySheetDetailsButton = true;
|
||||
this.showPropertySheetDetailsButtonInitialState = initialState;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set multiple selection mode. Default is single selection mode
|
||||
* <p>
|
||||
* If you turn on multiple selection mode, you must use the getSelectedObjects()
|
||||
* method to retrieve the list of selected objects.
|
||||
* <p>
|
||||
* Further, if you turn this on, it has the side effect of allowing the user
|
||||
* to select any remote object. The assumption being if you are prompting for
|
||||
* files, you also want to allow the user to select a folder, with the meaning
|
||||
* being that all files within the folder are implicitly selected.
|
||||
*
|
||||
* @see #getSelectedObjects()
|
||||
*/
|
||||
public void setMultipleSelectionMode(boolean multiple)
|
||||
{
|
||||
this.multipleSelectionMode = multiple;
|
||||
}
|
||||
/**
|
||||
* Specify a validator to use when the user selects a remote file or folder.
|
||||
* This allows you to decide if OK should be enabled or not for that remote file or folder.
|
||||
*/
|
||||
public void setSelectionValidator(IValidatorRemoteSelection selectionValidator)
|
||||
{
|
||||
this.selectionValidator = selectionValidator;
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------
|
||||
// MRI METHODS. THESE ONLY NEED BE
|
||||
// CALLED IF YOU WISH TO CHANGE THE DEFAULT MRI...
|
||||
// -----------------------------------------------
|
||||
/**
|
||||
* Set the title for the dialog. The default is "Browse for Folder"
|
||||
*/
|
||||
public void setDialogTitle(String title)
|
||||
{
|
||||
this.dlgTitle = title;
|
||||
}
|
||||
/**
|
||||
* Set the message shown at the top of the form
|
||||
*/
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
/**
|
||||
* Set the tooltip text for the remote systems tree from which an item is selected.
|
||||
*/
|
||||
public void setSelectionTreeToolTipText(String tip)
|
||||
{
|
||||
this.treeTip = tip;
|
||||
}
|
||||
|
||||
|
||||
// -----------------
|
||||
// OUTPUT METHODS...
|
||||
// -----------------
|
||||
|
||||
/**
|
||||
* Retrieve selected file object. If multiple files selected, returns the first.
|
||||
*/
|
||||
public IRemoteFile getSelectedFile()
|
||||
{
|
||||
Object o = getValue();
|
||||
if (o instanceof IRemoteFile[])
|
||||
return ((IRemoteFile[])o)[0];
|
||||
else if (o instanceof IRemoteFile)
|
||||
return (IRemoteFile)o;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Retrieve selected file objects. If no files selected, returns an array of zero.
|
||||
* If one file selected returns an array of one.
|
||||
*/
|
||||
public IRemoteFile[] getSelectedFiles()
|
||||
{
|
||||
Object o = getValue();
|
||||
if (o instanceof IRemoteFile[])
|
||||
return (IRemoteFile[])o;
|
||||
else if (o instanceof IRemoteFile)
|
||||
return new IRemoteFile[] {(IRemoteFile)o};
|
||||
else
|
||||
return new IRemoteFile[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all selected objects. This method will return an array of one
|
||||
* unless you have called setMultipleSelectionMode(true)!
|
||||
* @see #setMultipleSelectionMode(boolean)
|
||||
*/
|
||||
public Object[] getSelectedObjects()
|
||||
{
|
||||
Object remoteObject = getValue();
|
||||
if (remoteObject == null)
|
||||
return null;
|
||||
else if (remoteObject instanceof Object[])
|
||||
return (Object[])remoteObject;
|
||||
else if (remoteObject instanceof IRemoteFile[])
|
||||
return (Object[])remoteObject;
|
||||
else if (remoteObject instanceof Object)
|
||||
return new Object[] {remoteObject};
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return selected connection
|
||||
*/
|
||||
public IHost getSelectedConnection()
|
||||
{
|
||||
return outputConnection;
|
||||
}
|
||||
|
||||
// -------------------
|
||||
// INTERNAL METHODS...
|
||||
// -------------------
|
||||
|
||||
/**
|
||||
* Called by eclipse when user selects this action
|
||||
*/
|
||||
protected Dialog createDialog(Shell shell)
|
||||
{
|
||||
SystemSelectRemoteFileOrFolderDialog dlg = null;
|
||||
if (dlgTitle == null)
|
||||
dlg = new SystemSelectRemoteFileOrFolderDialog(shell, true); // true => file vs folder mode
|
||||
else
|
||||
dlg = new SystemSelectRemoteFileOrFolderDialog(shell, dlgTitle, true); // true => file vs folder mode
|
||||
dlg.setShowNewConnectionPrompt(showNewConnectionPrompt);
|
||||
dlg.setMultipleSelectionMode(multipleSelectionMode);
|
||||
if (restrictFolders)
|
||||
dlg.setRestrictFolders(true);
|
||||
if (message != null)
|
||||
dlg.setMessage(message);
|
||||
if (treeTip != null)
|
||||
dlg.setSelectionTreeToolTipText(treeTip);
|
||||
if (systemConnection != null)
|
||||
{
|
||||
if (onlyConnection)
|
||||
dlg.setSystemConnection(systemConnection);
|
||||
else
|
||||
dlg.setDefaultConnection(systemConnection);
|
||||
}
|
||||
if (systemTypes != null)
|
||||
dlg.setSystemTypes(systemTypes);
|
||||
if (expandDepth != 0)
|
||||
dlg.setAutoExpandDepth(expandDepth);
|
||||
if (fileTypes != null)
|
||||
dlg.setFileTypes((String)fileTypes); // must be called before setRootFolder!
|
||||
if (preSelection != null)
|
||||
dlg.setPreSelection(preSelection);
|
||||
else if (rootFolderConnection != null)
|
||||
dlg.setRootFolder(rootFolderConnection, rootFolderAbsPath);
|
||||
if (showPropertySheet)
|
||||
if (showPropertySheetDetailsButton)
|
||||
dlg.setShowPropertySheet(true, showPropertySheetDetailsButtonInitialState);
|
||||
else
|
||||
dlg.setShowPropertySheet(true);
|
||||
if (addButtonCallback != null)
|
||||
if ((addLabel!=null) || (addToolTipText!=null))
|
||||
dlg.enableAddMode(addButtonCallback, addLabel, addToolTipText);
|
||||
else
|
||||
dlg.enableAddMode(addButtonCallback);
|
||||
if (selectionValidator != null)
|
||||
dlg.setSelectionValidator(selectionValidator);
|
||||
|
||||
if (!allowFolderSelection) {
|
||||
dlg.setAllowFolderSelection(allowFolderSelection);
|
||||
}
|
||||
|
||||
// add viewer filters if any
|
||||
if (viewerFilters != null) {
|
||||
Iterator iter = viewerFilters.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
ViewerFilter filter = (ViewerFilter)(iter.next());
|
||||
dlg.addViewerFilter(filter);
|
||||
}
|
||||
}
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by parent. We return the selected object
|
||||
*/
|
||||
protected Object getDialogValue(Dialog dlg)
|
||||
{
|
||||
SystemSelectRemoteFileOrFolderDialog ourDlg = (SystemSelectRemoteFileOrFolderDialog)dlg;
|
||||
Object outputObject = null;
|
||||
outputConnection = null;
|
||||
if (!ourDlg.wasCancelled())
|
||||
{
|
||||
outputConnection = ourDlg.getSelectedConnection();
|
||||
if (multipleSelectionMode)
|
||||
outputObject = ourDlg.getSelectedObjects();
|
||||
else
|
||||
outputObject = ourDlg.getSelectedObject();
|
||||
}
|
||||
return outputObject; // parent class calls setValue on what we return
|
||||
}
|
||||
|
||||
/**
|
||||
* Add viewer filter.
|
||||
* @param filter a viewer filter.
|
||||
*/
|
||||
public void addViewerFilter(ViewerFilter filter) {
|
||||
viewerFilters.add(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to allow folder selection. The default selection validator will use this to
|
||||
* determine whether the OK button will be enabled when a folder is selected. The default
|
||||
* is <code>true</code>.
|
||||
* @param allow <code>true</code> to allow folder selection, <code>false</code> otherwise.
|
||||
*/
|
||||
public void setAllowFolderSelection(boolean allow) {
|
||||
allowFolderSelection = allow;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,502 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.ISystemAddFileListener;
|
||||
import org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseDialogAction;
|
||||
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The action for allowing the user to select a remote folder.
|
||||
* <p>
|
||||
* To configure the functionality, call these methods:
|
||||
* <ul>
|
||||
* <li>{@link #setShowNewConnectionPrompt(boolean)}
|
||||
* <li>{@link #setHost(IHost) or #setDefaultConnection(SystemConnection)}
|
||||
* <li>{@link #setSystemType(String)} or {@link #setSystemTypes(String[])}
|
||||
* <li>{@link #setRootFolder(IHost, String)} or {@link #setRootFolder(IRemoteFile)} or {@link #setPreSelection(IRemoteFile)}
|
||||
* <li>{@link #setAutoExpandDepth(int)}
|
||||
* <li>{@link #setShowPropertySheet(boolean)}
|
||||
* <li>{@link #enableAddMode(ISystemAddFileListener)}
|
||||
* <li>{@link #setMultipleSelectionMode(boolean)}
|
||||
* <li>{@link #setSelectionValidator(IValidatorRemoteSelection)}
|
||||
* </ul>
|
||||
* <p>
|
||||
* To configure the text on the dialog, call these methods:
|
||||
* <ul>
|
||||
* <li>{@link #setDialogTitle(String)}
|
||||
* <li>{@link #setMessage(String)}
|
||||
* <li>{@link #setSelectionTreeToolTipText(String)}
|
||||
* </ul>
|
||||
* <p>
|
||||
* After running, call these methods to get the output:
|
||||
* <ul>
|
||||
* <li>{@link #getSelectedFolder()} or {@link #getSelectedFolders()}
|
||||
* <li>{@link #getSelectedConnection()}
|
||||
* </ul>
|
||||
*/
|
||||
public class SystemSelectRemoteFolderAction extends SystemBaseDialogAction
|
||||
{
|
||||
private String[] systemTypes;
|
||||
private IHost systemConnection, outputConnection;
|
||||
private IHost rootFolderConnection;
|
||||
private IRemoteFile preSelection;
|
||||
private String rootFolderAbsPath;
|
||||
private String message, treeTip, dlgTitle;
|
||||
private String addLabel, addToolTipText;
|
||||
private int expandDepth = 0;
|
||||
private boolean showNewConnectionPrompt = true;
|
||||
private boolean restrictFolders = false;
|
||||
private boolean showPropertySheet = false;
|
||||
private boolean showPropertySheetDetailsButtonInitialState;
|
||||
private boolean showPropertySheetDetailsButton = false;
|
||||
private boolean multipleSelectionMode = false;
|
||||
private boolean allowForMultipleParents = false;
|
||||
private boolean onlyConnection = false;
|
||||
private ISystemAddFileListener addButtonCallback = null;
|
||||
private IValidatorRemoteSelection selectionValidator;
|
||||
|
||||
/**
|
||||
* Constructor that uses default action label and tooltip
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
*/
|
||||
public SystemSelectRemoteFolderAction(Shell shell)
|
||||
{
|
||||
this(shell, FileResources.ACTION_SELECT_DIRECTORY_LABEL, FileResources.ACTION_SELECT_DIRECTORY_TOOLTIP);
|
||||
}
|
||||
/**
|
||||
* Constructor when you have your own action label and tooltip
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param label
|
||||
* @param tooltip
|
||||
*/
|
||||
public SystemSelectRemoteFolderAction(Shell shell, String label, String tooltip)
|
||||
{
|
||||
super(label, tooltip, null, shell);
|
||||
super.setNeedsProgressMonitor(true); // the default is to include a monitor. Caller can override
|
||||
}
|
||||
|
||||
|
||||
// ------------------------
|
||||
// CONFIGURATION METHODS...
|
||||
// ------------------------
|
||||
/**
|
||||
* Set the title for the dialog. The default is "Browse for Folder"
|
||||
*/
|
||||
public void setDialogTitle(String title)
|
||||
{
|
||||
this.dlgTitle = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message shown at the top of the form
|
||||
*/
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
/**
|
||||
* Set the tooltip text for the remote systems tree from which an item is selected.
|
||||
*/
|
||||
public void setSelectionTreeToolTipText(String tip)
|
||||
{
|
||||
this.treeTip = tip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the system connection to restrict the user to seeing in the tree.
|
||||
*
|
||||
* @see #setRootFolder(IHost, String)
|
||||
*/
|
||||
public void setHost(IHost conn)
|
||||
{
|
||||
systemConnection = conn;
|
||||
onlyConnection = true;
|
||||
}
|
||||
/**
|
||||
* Set the connection to default the selection to
|
||||
*/
|
||||
public void setDefaultConnection(IHost conn)
|
||||
{
|
||||
systemConnection = conn;
|
||||
onlyConnection = false;
|
||||
}
|
||||
/**
|
||||
* Set the system types to restrict what connections the user sees, and what types of
|
||||
* connections they can create.
|
||||
* @param systemTypes An array of system type names
|
||||
*
|
||||
* @see org.eclipse.rse.core.ISystemTypes
|
||||
*/
|
||||
public void setSystemTypes(String[] systemTypes)
|
||||
{
|
||||
this.systemTypes = systemTypes;
|
||||
}
|
||||
/**
|
||||
* Convenience method to restrict to a single system type.
|
||||
* Same as setSystemTypes(new String[] {systemType})
|
||||
*
|
||||
* @param systemType The name of the system type to restrict to
|
||||
*
|
||||
* @see org.eclipse.rse.core.ISystemTypes
|
||||
*/
|
||||
public void setSystemType(String systemType)
|
||||
{
|
||||
if (systemType == null)
|
||||
setSystemTypes(null);
|
||||
else
|
||||
setSystemTypes(new String[] {systemType});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true if a "New Connection..." special connection is to be shown for creating new connections
|
||||
*/
|
||||
public void setShowNewConnectionPrompt(boolean show)
|
||||
{
|
||||
this.showNewConnectionPrompt = show;
|
||||
}
|
||||
/**
|
||||
* Specify the zero-based auto-expand level for the tree. The default is zero, meaning
|
||||
* only show the connections.
|
||||
*/
|
||||
public void setAutoExpandDepth(int depth)
|
||||
{
|
||||
this.expandDepth = depth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root folder from which to start listing files.
|
||||
* This version identifies the folder via a connection object and absolute path.
|
||||
* There is another overload that identifies the folder via a single IRemoteFile object.
|
||||
* <p>
|
||||
* This call effectively transforms the select dialog by:
|
||||
* <ul>
|
||||
* <li>Preventing the user from selecting other connections
|
||||
* <li>Preventing the user from selecting other filter strings
|
||||
* </ul>
|
||||
*
|
||||
* @param connection The connection to the remote system containing the root folder
|
||||
* @param folderAbsolutePath The fully qualified folder to start listing from (eg: "\folder1\folder2")
|
||||
*
|
||||
* @see org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString
|
||||
*/
|
||||
public void setRootFolder(IHost connection, String folderAbsolutePath)
|
||||
{
|
||||
rootFolderConnection = connection;
|
||||
rootFolderAbsPath = folderAbsolutePath;
|
||||
}
|
||||
/**
|
||||
* Set the root folder from which to start listing folders.
|
||||
* This version identifies the folder via an IRemoteFile object.
|
||||
* There is another overload that identifies the folder via a connection and folder path.
|
||||
* <p>
|
||||
* This call effectively transforms the select dialog by:
|
||||
* <ul>
|
||||
* <li>Preventing the user from selecting other connections
|
||||
* <li>Preventing the user from selecting other filter strings
|
||||
* </ul>
|
||||
*
|
||||
* @param rootFolder The IRemoteFile object representing the remote folder to start the list from
|
||||
*
|
||||
* @see org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString
|
||||
*/
|
||||
public void setRootFolder(IRemoteFile rootFolder)
|
||||
{
|
||||
setRootFolder(rootFolder.getSystemConnection(),rootFolder.getAbsolutePath());
|
||||
}
|
||||
/**
|
||||
* Set a file or folder to preselect. This will:
|
||||
* <ul>
|
||||
* <li>Set the parent folder as the root folder
|
||||
* <li>Pre-expand the parent folder
|
||||
* <li>Pre-select the given file or folder after expansion
|
||||
* </ul>
|
||||
* If there is no parent, then we were given a root. In which case we will
|
||||
* <ul>
|
||||
* <li>Force setRestrictFolders to false
|
||||
* <li>Pre-expand the root drives (Windows) or root files (Unix)
|
||||
* <li>Pre-select the given root drive (Windows only)
|
||||
* </ul>
|
||||
*/
|
||||
public void setPreSelection(IRemoteFile selection)
|
||||
{
|
||||
preSelection = selection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether setRootFolder should prevent the user from being able to see or select
|
||||
* any other folder. This causes this effect:
|
||||
* <ol>
|
||||
* <li>The special filter for root/drives is not shown
|
||||
* </ol>
|
||||
*/
|
||||
public void setRestrictFolders(boolean restrict)
|
||||
{
|
||||
restrictFolders = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable Add mode. This means the OK button is replaced with an Add button, and
|
||||
* the Cancel with a Close button. When Add is pressed, the caller is called back.
|
||||
* The dialog is not exited until Close is pressed.
|
||||
* <p>
|
||||
* When a library is selected, the caller is called back to decide to enable the Add
|
||||
* button or not.
|
||||
*/
|
||||
public void enableAddMode(ISystemAddFileListener caller)
|
||||
{
|
||||
this.addButtonCallback = caller;
|
||||
}
|
||||
/**
|
||||
* Overloaded method that allows setting the label and tooltip text of the Add button.
|
||||
* If you pass null for the label, the default is used ("Add").
|
||||
*/
|
||||
public void enableAddMode(ISystemAddFileListener caller, String addLabel, String addToolTipText)
|
||||
{
|
||||
enableAddMode(caller);
|
||||
this.addLabel = addLabel;
|
||||
this.addToolTipText = addToolTipText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the property sheet on the right hand side, to show the properties of the
|
||||
* selected object.
|
||||
* <p>
|
||||
* Default is false
|
||||
*/
|
||||
public void setShowPropertySheet(boolean show)
|
||||
{
|
||||
this.showPropertySheet = show;
|
||||
}
|
||||
/**
|
||||
* Show the property sheet on the right hand side, to show the properties of the
|
||||
* selected object.
|
||||
* <p>
|
||||
* This overload shows a Details>>> button so the user can decide if they want to see the
|
||||
* property sheet.
|
||||
* <p>
|
||||
* @param show True if to show the property sheet within the dialog
|
||||
* @param initialState True if the property is to be initially displayed, false if it is not
|
||||
* to be displayed until the user presses the Details button.
|
||||
*/
|
||||
public void setShowPropertySheet(boolean show, boolean initialState)
|
||||
{
|
||||
setShowPropertySheet(show);
|
||||
if (show)
|
||||
{
|
||||
this.showPropertySheetDetailsButton = true;
|
||||
this.showPropertySheetDetailsButtonInitialState = initialState;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set multiple selection mode. Default is single selection mode
|
||||
* <p>
|
||||
* If you turn on multiple selection mode, you must use the getSelectedObjects()
|
||||
* method to retrieve the list of selected objects.
|
||||
*
|
||||
* @see #getSelectedObjects()
|
||||
*/
|
||||
public void setMultipleSelectionMode(boolean multiple)
|
||||
{
|
||||
this.multipleSelectionMode = multiple;
|
||||
}
|
||||
|
||||
/*
|
||||
* Indicates whether to allow selection of objects from differnet parents
|
||||
*/
|
||||
public void setAllowForMultipleParents(boolean multiple)
|
||||
{
|
||||
this.allowForMultipleParents = multiple;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a validator to use when the user selects a remote file or folder.
|
||||
* This allows you to decide if OK should be enabled or not for that remote file or folder.
|
||||
*/
|
||||
public void setSelectionValidator(IValidatorRemoteSelection selectionValidator)
|
||||
{
|
||||
this.selectionValidator = selectionValidator;
|
||||
}
|
||||
|
||||
// -----------------
|
||||
// OUTPUT METHODS...
|
||||
// -----------------
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve selected folder object. If multiple folders selected, returns the first.
|
||||
*/
|
||||
public IRemoteFile getSelectedFolder()
|
||||
{
|
||||
Object o = getValue();
|
||||
if (o instanceof IRemoteFile[])
|
||||
return ((IRemoteFile[])o)[0];
|
||||
else if (o instanceof IRemoteFile)
|
||||
return (IRemoteFile)o;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Retrieve selected folder objects. If no folders selected, returns an array of zero.
|
||||
* If one folder selected returns an array of one.
|
||||
*/
|
||||
public IRemoteFile[] getSelectedFolders()
|
||||
{
|
||||
Object o = getValue();
|
||||
if (o instanceof Object[]) {
|
||||
|
||||
Object[] temp = (Object[])o;
|
||||
|
||||
IRemoteFile[] files = new IRemoteFile[temp.length];
|
||||
|
||||
// ensure all objects are IRemoteFiles
|
||||
for (int i = 0; i < temp.length; i++) {
|
||||
|
||||
if (temp[i] instanceof IRemoteFile) {
|
||||
files[i] = (IRemoteFile)temp[i];
|
||||
}
|
||||
// should never happen
|
||||
else {
|
||||
return new IRemoteFile[0];
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
if (o instanceof IRemoteFile[])
|
||||
return (IRemoteFile[])o;
|
||||
else if (o instanceof IRemoteFile)
|
||||
return new IRemoteFile[] {(IRemoteFile)o};
|
||||
else
|
||||
return new IRemoteFile[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all selected objects. This method will return an array of one
|
||||
* unless you have called setMultipleSelectionMode(true)!
|
||||
* <p>
|
||||
* It will always return null if the user cancelled the dialog.
|
||||
*
|
||||
* @see #setMultipleSelectionMode(boolean)
|
||||
*/
|
||||
public Object[] getSelectedObjects()
|
||||
{
|
||||
Object remoteObject = getValue();
|
||||
if (remoteObject == null)
|
||||
return null;
|
||||
else if (remoteObject instanceof Object[])
|
||||
return (Object[])remoteObject;
|
||||
else if (remoteObject instanceof IRemoteFile[])
|
||||
return (Object[])remoteObject;
|
||||
else if (remoteObject instanceof Object)
|
||||
return new Object[] {remoteObject};
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return selected connection
|
||||
*/
|
||||
public IHost getSelectedConnection()
|
||||
{
|
||||
return outputConnection;
|
||||
}
|
||||
|
||||
// -------------------
|
||||
// INTERNAL METHODS...
|
||||
// -------------------
|
||||
|
||||
/**
|
||||
* Called by eclipse when user selects this action
|
||||
*/
|
||||
protected Dialog createDialog(Shell shell)
|
||||
{
|
||||
SystemSelectRemoteFileOrFolderDialog dlg = null;
|
||||
if (dlgTitle == null)
|
||||
dlg = new SystemSelectRemoteFileOrFolderDialog(shell, false); // false => folder vs file mode
|
||||
else
|
||||
dlg = new SystemSelectRemoteFileOrFolderDialog(shell, dlgTitle, false); // false => folder vs file mode
|
||||
dlg.setShowNewConnectionPrompt(showNewConnectionPrompt);
|
||||
dlg.setMultipleSelectionMode(multipleSelectionMode);
|
||||
dlg.setAllowForMultipleParents(allowForMultipleParents);
|
||||
if (restrictFolders)
|
||||
dlg.setRestrictFolders(true);
|
||||
if (message != null)
|
||||
dlg.setMessage(message);
|
||||
if (treeTip != null)
|
||||
dlg.setSelectionTreeToolTipText(treeTip);
|
||||
if (systemConnection != null)
|
||||
{
|
||||
if (onlyConnection)
|
||||
dlg.setSystemConnection(systemConnection);
|
||||
else
|
||||
dlg.setDefaultConnection(systemConnection);
|
||||
}
|
||||
if (systemTypes != null)
|
||||
dlg.setSystemTypes(systemTypes);
|
||||
if (expandDepth != 0)
|
||||
dlg.setAutoExpandDepth(expandDepth);
|
||||
if (preSelection != null)
|
||||
dlg.setPreSelection(preSelection);
|
||||
else if (rootFolderConnection != null)
|
||||
dlg.setRootFolder(rootFolderConnection, rootFolderAbsPath);
|
||||
if (showPropertySheet)
|
||||
if (showPropertySheetDetailsButton)
|
||||
dlg.setShowPropertySheet(true, showPropertySheetDetailsButtonInitialState);
|
||||
else
|
||||
dlg.setShowPropertySheet(true);
|
||||
if (addButtonCallback != null)
|
||||
if ((addLabel!=null) || (addToolTipText!=null))
|
||||
dlg.enableAddMode(addButtonCallback, addLabel, addToolTipText);
|
||||
else
|
||||
dlg.enableAddMode(addButtonCallback);
|
||||
if (selectionValidator != null)
|
||||
dlg.setSelectionValidator(selectionValidator);
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by parent. We return the selected object
|
||||
*/
|
||||
protected Object getDialogValue(Dialog dlg)
|
||||
{
|
||||
SystemSelectRemoteFileOrFolderDialog ourDlg = (SystemSelectRemoteFileOrFolderDialog)dlg;
|
||||
Object outputObject = null;
|
||||
outputConnection = null;
|
||||
if (!ourDlg.wasCancelled())
|
||||
{
|
||||
if (multipleSelectionMode)
|
||||
outputObject = ourDlg.getSelectedObjects();
|
||||
else
|
||||
outputObject = ourDlg.getSelectedObject();
|
||||
outputConnection = ourDlg.getSelectedConnection();
|
||||
}
|
||||
return outputObject; // parent class calls setValue on what we return
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,538 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.actions;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.resources.ISaveAsDialog;
|
||||
import org.eclipse.rse.files.ui.resources.SaveAsDialog;
|
||||
import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile;
|
||||
import org.eclipse.rse.files.ui.resources.SystemIFileProperties;
|
||||
import org.eclipse.rse.model.ISystemResourceChangeEvents;
|
||||
import org.eclipse.rse.model.SystemResourceChangeEvent;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileIOException;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSecurityException;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.SystemResources;
|
||||
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
|
||||
|
||||
/**
|
||||
* This is the default action used to handle upload conflicts
|
||||
*/
|
||||
public class SystemUploadConflictAction extends SystemBaseAction implements Runnable
|
||||
{
|
||||
|
||||
/**
|
||||
* This is the default dialog used to handle upload conflicts
|
||||
*/
|
||||
private class UploadConflictDialog extends SystemPromptDialog implements ISystemMessages, SelectionListener
|
||||
{
|
||||
private Button _overwriteLocalButton;
|
||||
private Button _overwriteRemoteButton;
|
||||
private Button _saveasButton;
|
||||
private Button _browseButton;
|
||||
private Text _saveasFileEntry;
|
||||
|
||||
private boolean _overwriteLocal;
|
||||
private boolean _overwriteRemote;
|
||||
private boolean _saveas;
|
||||
|
||||
private SystemMessage _errorMessage;
|
||||
|
||||
private IRemoteFile _saveasLocation;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param shell the parent shell of the dialog
|
||||
*/
|
||||
public UploadConflictDialog(Shell shell)
|
||||
{
|
||||
super(shell, FileResources.RESID_CONFLICT_SAVE_TITLE);
|
||||
//pack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a button is pressed in the dialog
|
||||
*/
|
||||
protected void buttonPressed(int buttonId)
|
||||
{
|
||||
setReturnCode(buttonId);
|
||||
_overwriteLocal = _overwriteLocalButton.getSelection();
|
||||
_overwriteRemote = _overwriteRemoteButton.getSelection();
|
||||
_saveas = _saveasButton.getSelection();
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the user decided to overwrite the local file
|
||||
* @return whether the user decided to overwrite the local file
|
||||
*/
|
||||
public boolean getOverwriteLocal()
|
||||
{
|
||||
return _overwriteLocal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the user decided to overwrite the remote file
|
||||
* @return whether the user decided to overwrite the remote file
|
||||
*/
|
||||
public boolean getOverwriteRemote()
|
||||
{
|
||||
return _overwriteRemote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the user decided to save to a different location
|
||||
* @return whether the user decided to save to a different location
|
||||
*/
|
||||
public boolean getSaveas()
|
||||
{
|
||||
return _saveas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location where the cached file should be saved to
|
||||
* @return the location where the cached file should be saved to
|
||||
*/
|
||||
public IRemoteFile getSaveasLocation()
|
||||
{
|
||||
return _saveasLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the dialog contents.
|
||||
*/
|
||||
public Control createInner(Composite parent)
|
||||
{
|
||||
Image image = getShell().getDisplay().getSystemImage(SWT.ICON_QUESTION);
|
||||
|
||||
Composite c = new Composite(parent, SWT.NONE);
|
||||
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 1;
|
||||
c.setLayout(layout);
|
||||
c.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
Composite m = new Composite(c, SWT.NONE);
|
||||
|
||||
GridLayout mlayout = new GridLayout();
|
||||
mlayout.numColumns = 2;
|
||||
m.setLayout(mlayout);
|
||||
m.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
Label label = new Label(m, 0);
|
||||
image.setBackground(label.getBackground());
|
||||
label.setImage(image);
|
||||
label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_BEGINNING));
|
||||
|
||||
Text text = new Text(m, SWT.WRAP | SWT.MULTI);
|
||||
text.setEditable(false);
|
||||
text.setText(FileResources.RESID_CONFLICT_SAVE_MESSAGE);
|
||||
|
||||
GridData textData = new GridData(GridData.FILL_BOTH);
|
||||
textData.widthHint = 100;
|
||||
textData.horizontalSpan = 2;
|
||||
textData.verticalSpan = 5;
|
||||
|
||||
Composite options = new Composite(c, SWT.NONE);
|
||||
GridLayout olayout = new GridLayout();
|
||||
olayout.numColumns = 1;
|
||||
options.setLayout(olayout);
|
||||
options.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
_overwriteLocalButton = new Button(options, SWT.RADIO);
|
||||
_overwriteLocalButton.setText(FileResources.RESID_CONFLICT_SAVE_REPLACELOCAL);
|
||||
_overwriteLocalButton.addSelectionListener(this);
|
||||
_overwriteLocalButton.setSelection(true);
|
||||
|
||||
_overwriteRemoteButton = new Button(options, SWT.RADIO);
|
||||
_overwriteRemoteButton.setText(FileResources.RESID_CONFLICT_SAVE_OVERWRITEREMOTE);
|
||||
_overwriteRemoteButton.addSelectionListener(this);
|
||||
|
||||
_saveasButton = new Button(options, SWT.RADIO);
|
||||
_saveasButton.setText(FileResources.RESID_CONFLICT_SAVE_SAVETODIFFERENT);
|
||||
_saveasButton.addSelectionListener(this);
|
||||
|
||||
Composite s = new Composite(options, SWT.NONE);
|
||||
GridLayout slayout = new GridLayout();
|
||||
slayout.numColumns = 2;
|
||||
s.setLayout(slayout);
|
||||
s.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
_saveasFileEntry = new Text(s, SWT.BORDER);
|
||||
_saveasFileEntry.setEnabled(false);
|
||||
|
||||
GridData fileEntryData = new GridData(GridData.FILL_BOTH);
|
||||
fileEntryData.widthHint = 100;
|
||||
_saveasFileEntry.setLayoutData(fileEntryData);
|
||||
_saveasFileEntry.setEditable(false);
|
||||
|
||||
_browseButton = new Button(s, SWT.PUSH);
|
||||
_browseButton.setText(SystemResources.BUTTON_BROWSE);
|
||||
_browseButton.addSelectionListener(this);
|
||||
_browseButton.setEnabled(false);
|
||||
|
||||
setHelp();
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a widget is selected
|
||||
*/
|
||||
public void widgetSelected(SelectionEvent e)
|
||||
{
|
||||
if (_saveasButton.getSelection())
|
||||
{
|
||||
_browseButton.setEnabled(true);
|
||||
_saveasFileEntry.setEnabled(true);
|
||||
if (_saveasLocation != null)
|
||||
{
|
||||
_errorMessage = null;
|
||||
setErrorMessage(_errorMessage);
|
||||
enableOkButton(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
enableOkButton(false);
|
||||
_errorMessage = SystemPlugin.getPluginMessage(MSG_VALIDATE_PATH_EMPTY);
|
||||
setErrorMessage(_errorMessage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_browseButton.setEnabled(false);
|
||||
_saveasFileEntry.setEnabled(false);
|
||||
enableOkButton(true);
|
||||
_errorMessage = null;
|
||||
setErrorMessage(_errorMessage);
|
||||
}
|
||||
|
||||
if (e.getSource() == _browseButton)
|
||||
{
|
||||
|
||||
ISaveAsDialog dlg = SaveAsDialog.getSaveAsDialog(getShell());
|
||||
dlg.setMultipleSelectionMode(false);
|
||||
|
||||
if (_remoteFile != null)
|
||||
{
|
||||
dlg.setPreSelection(_remoteFile);
|
||||
|
||||
if (dlg.open() == OK)
|
||||
{
|
||||
Object output = dlg.getOutputObject();
|
||||
if (output instanceof IRemoteFile)
|
||||
{
|
||||
IRemoteFile toCreate = (IRemoteFile) output;
|
||||
// validate
|
||||
try
|
||||
{
|
||||
_errorMessage = null;
|
||||
_saveasLocation = toCreate;
|
||||
_saveasFileEntry.setText(toCreate.getAbsolutePath());
|
||||
|
||||
enableOkButton(_errorMessage == null);
|
||||
|
||||
setErrorMessage(_errorMessage);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void widgetDefaultSelected(SelectionEvent e)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the initial focus control
|
||||
* @return the initial focus control
|
||||
*/
|
||||
protected Control getInitialFocusControl()
|
||||
{
|
||||
enableOkButton(true);
|
||||
return _overwriteLocalButton;
|
||||
}
|
||||
|
||||
private void setHelp()
|
||||
{
|
||||
setHelp(SystemPlugin.HELPPREFIX + "scdl0000");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action used to close a specified editor
|
||||
*/
|
||||
public class CloseEditorAction implements Runnable
|
||||
{
|
||||
public IEditorPart _editor;
|
||||
|
||||
public CloseEditorAction(IEditorPart editor)
|
||||
{
|
||||
_editor = editor;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
// close old editor
|
||||
SystemBasePlugin.getActiveWorkbenchWindow().getActivePage().closeEditor(_editor, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action used to reopen the editor for a cached file with a remote file from a different location
|
||||
*/
|
||||
public class ReopenAction implements Runnable
|
||||
{
|
||||
private IFile _tempFile;
|
||||
private IRemoteFile _saveasFile;
|
||||
|
||||
public ReopenAction(IFile tempFile, IRemoteFile saveasFile)
|
||||
{
|
||||
_tempFile = tempFile;
|
||||
_saveasFile = saveasFile;
|
||||
}
|
||||
|
||||
private IEditorPart getEditorFor(IFile tempFile)
|
||||
{
|
||||
|
||||
IWorkbenchWindow window = SystemBasePlugin.getActiveWorkbenchWindow();
|
||||
if (window != null)
|
||||
{
|
||||
IWorkbenchPage page = window.getActivePage();
|
||||
if (page != null)
|
||||
{
|
||||
IEditorPart editor = page.getActiveEditor();
|
||||
IEditorInput input = editor.getEditorInput();
|
||||
if (input instanceof FileEditorInput)
|
||||
{
|
||||
FileEditorInput finput = (FileEditorInput) input;
|
||||
if (finput.getFile().getFullPath().equals(tempFile.getFullPath()))
|
||||
{
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
_saveasFile = _saveasFile.getParentRemoteFileSubSystem().getRemoteFileObject(_saveasFile.getAbsolutePath());
|
||||
SystemPlugin.getTheSystemRegistry().fireEvent(new SystemResourceChangeEvent(_saveasFile.getParentRemoteFile(), ISystemResourceChangeEvents.EVENT_REFRESH, null));
|
||||
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// close editor
|
||||
IEditorPart editor = getEditorFor(_tempFile);
|
||||
if (editor != null)
|
||||
{
|
||||
String id = editor.getEditorSite().getId();
|
||||
|
||||
// open editor on new file
|
||||
SystemEditableRemoteFile edit = new SystemEditableRemoteFile(_saveasFile, id);
|
||||
try
|
||||
{
|
||||
edit.download(getShell());
|
||||
edit.addAsListener();
|
||||
edit.setLocalResourceProperties();
|
||||
|
||||
// open new editor
|
||||
edit.openEditor();
|
||||
|
||||
// close old editor
|
||||
CloseEditorAction closeAction = new CloseEditorAction(editor);
|
||||
Display.getDefault().asyncExec(closeAction);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IFile _tempFile;
|
||||
private IRemoteFile _remoteFile;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param shell the parent shell of the action
|
||||
* @param tempFile the cached local file that is in conflict with the remote file
|
||||
* @param remoteFile the remote file
|
||||
* @param remoteNewer indicates whether the remote file has changed since it was last downloaded
|
||||
*/
|
||||
public SystemUploadConflictAction(Shell shell, IFile tempFile, IRemoteFile remoteFile, boolean remoteNewer)
|
||||
{
|
||||
super(FileResources.RESID_CONFLICT_SAVE_TITLE, shell);
|
||||
_tempFile = tempFile;
|
||||
_remoteFile = remoteFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this action is invoked
|
||||
*/
|
||||
public void run()
|
||||
{
|
||||
SystemIFileProperties properties = new SystemIFileProperties(_tempFile);
|
||||
|
||||
UploadConflictDialog cnfDialog = new UploadConflictDialog(SystemBasePlugin.getActiveWorkbenchShell());
|
||||
if (cnfDialog.open() == Window.OK)
|
||||
{
|
||||
IRemoteFileSubSystem fs = _remoteFile.getParentRemoteFileSubSystem();
|
||||
|
||||
// does user want to open local or replace local with remote?
|
||||
if (cnfDialog.getOverwriteRemote())
|
||||
{
|
||||
// user wants to keep the local version
|
||||
// and user wants to overwrite the remote file with pending changes
|
||||
try
|
||||
{
|
||||
fs.uploadUTF8(_tempFile, _remoteFile, null);
|
||||
_remoteFile.markStale(true);
|
||||
_remoteFile = fs.getRemoteFileObject(_remoteFile.getAbsolutePath());
|
||||
properties.setRemoteFileTimeStamp(_remoteFile.getLastModified());
|
||||
properties.setDirty(false);
|
||||
}
|
||||
catch (RemoteFileSecurityException e)
|
||||
{
|
||||
}
|
||||
catch (RemoteFileIOException e)
|
||||
{
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (cnfDialog.getOverwriteLocal())
|
||||
{
|
||||
// user wants to replace local copy with the remote version
|
||||
try
|
||||
{
|
||||
// download remote version
|
||||
fs.downloadUTF8(_remoteFile, _tempFile, null);
|
||||
|
||||
properties.setRemoteFileTimeStamp(_remoteFile.getLastModified());
|
||||
//properties.setRemoteFileTimeStamp(-1);
|
||||
|
||||
properties.setDirty(false);
|
||||
properties.setUsedBinaryTransfer(_remoteFile.isBinary());
|
||||
}
|
||||
catch (RemoteFileSecurityException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (RemoteFileIOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if (cnfDialog.getSaveas())
|
||||
{
|
||||
IRemoteFile remoteFile = cnfDialog.getSaveasLocation();
|
||||
if (remoteFile != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fs = remoteFile.getParentRemoteFileSubSystem();
|
||||
if (!remoteFile.exists())
|
||||
{
|
||||
fs.createFile(remoteFile);
|
||||
}
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
SystemBasePlugin.logError("Error in performSaveAs", e);
|
||||
SystemMessage message = SystemPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_UNEXPECTED);
|
||||
SystemMessageDialog dialog = new SystemMessageDialog(SystemBasePlugin.getActiveWorkbenchShell(), message);
|
||||
dialog.open();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// copy temp file to remote system
|
||||
fs.uploadUTF8(_tempFile, remoteFile, null);
|
||||
|
||||
// set original time stamp to 0 so that file will be overwritten next download
|
||||
properties.setRemoteFileTimeStamp(0);
|
||||
properties.setDirty(false);
|
||||
}
|
||||
catch (SystemMessageException e)
|
||||
{
|
||||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
ReopenAction reopen = new ReopenAction(_tempFile, remoteFile);
|
||||
|
||||
Display.getDefault().asyncExec(reopen);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// cancelled dialog, so no remote synchronization
|
||||
// set dirty flag!
|
||||
properties.setDirty(true);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,250 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.compare;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.compare.CompareConfiguration;
|
||||
import org.eclipse.compare.CompareEditorInput;
|
||||
import org.eclipse.compare.ITypedElement;
|
||||
import org.eclipse.compare.ZipFileStructureCreator;
|
||||
import org.eclipse.compare.internal.BufferedResourceNode;
|
||||
import org.eclipse.compare.internal.Utilities;
|
||||
import org.eclipse.compare.structuremergeviewer.DiffNode;
|
||||
import org.eclipse.compare.structuremergeviewer.DiffTreeViewer;
|
||||
import org.eclipse.compare.structuremergeviewer.Differencer;
|
||||
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
|
||||
import org.eclipse.compare.structuremergeviewer.IDiffElement;
|
||||
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
|
||||
|
||||
public class SystemCompareInput extends CompareEditorInput
|
||||
{
|
||||
|
||||
private static final boolean NORMALIZE_CASE = true;
|
||||
private Object fRoot;
|
||||
|
||||
class MyDiffNode extends DiffNode
|
||||
{
|
||||
private boolean fDirty = false;
|
||||
private ITypedElement fLastId;
|
||||
private String fLastName;
|
||||
|
||||
public MyDiffNode(IDiffContainer parent, int description, ITypedElement ancestor, ITypedElement left, ITypedElement right)
|
||||
{
|
||||
super(parent, description, ancestor, left, right);
|
||||
}
|
||||
|
||||
public void fireChange()
|
||||
{
|
||||
super.fireChange();
|
||||
setDirty(true);
|
||||
fDirty = true;
|
||||
if (_diffViewer != null)
|
||||
_diffViewer.refresh(this);
|
||||
}
|
||||
|
||||
void clearDirty()
|
||||
{
|
||||
fDirty = false;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
if (fLastName == null)
|
||||
fLastName = super.getName();
|
||||
if (fDirty)
|
||||
return '<' + fLastName + '>';
|
||||
return fLastName;
|
||||
}
|
||||
|
||||
public ITypedElement getId()
|
||||
{
|
||||
ITypedElement id = super.getId();
|
||||
if (id == null)
|
||||
return fLastId;
|
||||
fLastId = id;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
private List _remoteEditables;
|
||||
private DiffTreeViewer _diffViewer;
|
||||
private IResource _leftResource;
|
||||
private IResource _rightResource;
|
||||
|
||||
public SystemCompareInput(CompareConfiguration configuration)
|
||||
{
|
||||
super(configuration);
|
||||
_remoteEditables = new ArrayList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>IStructureComparator</code> for the given input.
|
||||
* Returns <code>null</code> if no <code>IStructureComparator</code>
|
||||
* can be found for the <code>IResource</code>.
|
||||
*/
|
||||
private IStructureComparator getStructure(IResource input)
|
||||
{
|
||||
if (input instanceof IContainer)
|
||||
return new BufferedResourceNode(input);
|
||||
|
||||
if (input instanceof IFile)
|
||||
{
|
||||
IStructureComparator rn = new BufferedResourceNode(input);
|
||||
IFile file = (IFile) input;
|
||||
String type = normalizeCase(file.getFileExtension());
|
||||
if ("JAR".equals(type) || "ZIP".equals(type)) //$NON-NLS-2$ //$NON-NLS-1$
|
||||
return new ZipFileStructureCreator().getStructure(rn);
|
||||
return rn;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String normalizeCase(String s)
|
||||
{
|
||||
if (NORMALIZE_CASE && s != null)
|
||||
return s.toUpperCase();
|
||||
return s;
|
||||
}
|
||||
|
||||
public IResource getLeftResource()
|
||||
{
|
||||
return _leftResource;
|
||||
}
|
||||
|
||||
public IResource getRightResource()
|
||||
{
|
||||
return _rightResource;
|
||||
}
|
||||
|
||||
public Object prepareInput(IProgressMonitor monitor)
|
||||
{
|
||||
ISystemEditableRemoteObject ef1 = (ISystemEditableRemoteObject)_remoteEditables.get(0);
|
||||
ISystemEditableRemoteObject ef2 = (ISystemEditableRemoteObject)_remoteEditables.get(1);
|
||||
|
||||
try
|
||||
{
|
||||
ef1.download(monitor);
|
||||
ef2.download(monitor);
|
||||
ef1.addAsListener();
|
||||
ef2.addAsListener();
|
||||
ef1.setLocalResourceProperties();
|
||||
ef2.setLocalResourceProperties();
|
||||
|
||||
_leftResource = ef1.getLocalResource();
|
||||
_rightResource = ef2.getLocalResource();
|
||||
|
||||
String title;
|
||||
String format = Utilities.getString("ResourceCompare.twoWay.title"); //$NON-NLS-1$
|
||||
title = MessageFormat.format(format, new String[] {_leftResource.getName(), _rightResource.getName()});
|
||||
setTitle(title);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
IStructureComparator c1 = getStructure(_leftResource);
|
||||
IStructureComparator c2 = getStructure(_rightResource);
|
||||
|
||||
Differencer d = new Differencer()
|
||||
{
|
||||
protected Object visit(Object parent, int description, Object ancestor, Object left, Object right)
|
||||
{
|
||||
return new MyDiffNode((IDiffContainer) parent, description, (ITypedElement) ancestor, (ITypedElement) left, (ITypedElement) right);
|
||||
}
|
||||
};
|
||||
|
||||
fRoot = d.findDifferences(false, monitor, null, null, c1, c2);
|
||||
return fRoot;
|
||||
}
|
||||
|
||||
public Viewer createDiffViewer(Composite parent)
|
||||
{
|
||||
_diffViewer = new DiffTreeViewer(parent, getCompareConfiguration())
|
||||
{
|
||||
protected void fillContextMenu(IMenuManager manager)
|
||||
{
|
||||
super.fillContextMenu(manager);
|
||||
}
|
||||
};
|
||||
return _diffViewer;
|
||||
}
|
||||
|
||||
public void addRemoteEditable(ISystemEditableRemoteObject file)
|
||||
{
|
||||
_remoteEditables.add(file);
|
||||
}
|
||||
|
||||
public void saveChanges(IProgressMonitor pm) throws CoreException
|
||||
{
|
||||
super.saveChanges(pm);
|
||||
if (fRoot instanceof DiffNode)
|
||||
{
|
||||
try
|
||||
{
|
||||
commit(pm, (DiffNode) fRoot);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_diffViewer != null)
|
||||
_diffViewer.refresh();
|
||||
setDirty(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Recursively walks the diff tree and commits all changes.
|
||||
*/
|
||||
private void commit(IProgressMonitor pm, DiffNode node) throws CoreException
|
||||
{
|
||||
if (node instanceof MyDiffNode)
|
||||
((MyDiffNode) node).clearDirty();
|
||||
|
||||
ITypedElement left = node.getLeft();
|
||||
if (left instanceof BufferedResourceNode)
|
||||
((BufferedResourceNode) left).commit(pm);
|
||||
|
||||
ITypedElement right = node.getRight();
|
||||
if (right instanceof BufferedResourceNode)
|
||||
((BufferedResourceNode) right).commit(pm);
|
||||
|
||||
IDiffElement[] children = node.getChildren();
|
||||
if (children != null)
|
||||
{
|
||||
for (int i = 0; i < children.length; i++)
|
||||
{
|
||||
IDiffElement element = children[i];
|
||||
if (element instanceof DiffNode)
|
||||
commit(pm, (DiffNode) element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.dialogs;
|
||||
|
||||
import org.eclipse.rse.files.ui.widgets.SystemEnterOrSelectRemoteFileForm;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemSelectRemoteFileOrFolderForm;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* A dialog for either selecting or entering a file name.
|
||||
* Use {@link #getRemotePath()} to get the absolute remote path of what the user selected or entered.
|
||||
* Note that if the user enters a file name, then the output object will be its parent folder, since
|
||||
* the file with that name may not exist.
|
||||
*/
|
||||
public class SystemEnterOrSelectRemoteFileDialog extends SystemSelectRemoteFileOrFolderDialog {
|
||||
|
||||
private SystemEnterOrSelectRemoteFileForm form;
|
||||
|
||||
/**
|
||||
* Creates the dialog with the parent shell.
|
||||
* @param shell the parent shell.
|
||||
*/
|
||||
public SystemEnterOrSelectRemoteFileDialog(Shell shell) {
|
||||
super(shell, true);
|
||||
setMultipleSelectionMode(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a dialog under the parent shell with the given title.
|
||||
* @param shell the parent shell.
|
||||
* @param title the title for the dialog.
|
||||
*/
|
||||
public SystemEnterOrSelectRemoteFileDialog(Shell shell, String title) {
|
||||
super(shell, title, true);
|
||||
setMultipleSelectionMode(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns false.
|
||||
* @see org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog#getMultipleSelectionMode()
|
||||
*/
|
||||
public boolean getMultipleSelectionMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has no effect. Multiple selection mode is not allowed.
|
||||
* @see org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog#setMultipleSelectionMode(boolean)
|
||||
*/
|
||||
public void setMultipleSelectionMode(boolean multiple) {
|
||||
super.setMultipleSelectionMode(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the select or enter file form. Sets the verbage of the form.
|
||||
* @see org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog#getForm(boolean)
|
||||
*/
|
||||
protected SystemSelectRemoteFileOrFolderForm getForm(boolean fileMode) {
|
||||
form = new SystemEnterOrSelectRemoteFileForm(getMessageLine(), this, fileMode);
|
||||
form.setMessage(SystemFileResources.RESID_ENTER_OR_SELECT_FILE_VERBAGE_LABEL);
|
||||
setOutputObject(null);
|
||||
return form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remote path.
|
||||
* @return the remote path.
|
||||
*/
|
||||
public String getRemotePath() {
|
||||
IRemoteFile file = (IRemoteFile)getOutputObject();
|
||||
|
||||
String absPath = file.getAbsolutePath();
|
||||
|
||||
// if the output is a file, then return the absolute path.
|
||||
if (file.isFile()) {
|
||||
return absPath;
|
||||
}
|
||||
// if the output is a folder, then file name is available in the text field
|
||||
// of the form, so append the file name to the folder path
|
||||
else {
|
||||
String fileName = form.getFileName();
|
||||
String sep = file.getSeparator();
|
||||
|
||||
// add separator if necessary
|
||||
if (!absPath.endsWith(sep)) {
|
||||
absPath += sep;
|
||||
}
|
||||
|
||||
// add file name if necessary
|
||||
absPath += fileName;
|
||||
|
||||
return absPath;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.dialogs;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemRemoteFolderCombo;
|
||||
import org.eclipse.rse.filters.ISystemFilter;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
/**
|
||||
* Dialog for prompting the user for his home folder. This is called once when
|
||||
* the user first expands his default "/home/username" filter string.
|
||||
* <p>NOT USED YET</p>
|
||||
*/
|
||||
public class SystemPromptForHomeFolderDialog
|
||||
extends SystemPromptDialog
|
||||
implements SelectionListener
|
||||
{
|
||||
private IHost connection;
|
||||
private ISubSystem subsystem;
|
||||
private SystemRemoteFolderCombo folderCombo = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SystemPromptForHomeFolderDialog(Shell shell, ISystemFilter filter)
|
||||
{
|
||||
super(shell, SystemFileResources.RESID_HOMEPROMPT_TITLE);
|
||||
setBlockOnOpen(true); // always modal
|
||||
subsystem = (ISubSystem)filter.getProvider();
|
||||
connection = subsystem.getHost();
|
||||
//pack();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return initial control to be given focus
|
||||
*/
|
||||
protected Control getInitialFocusControl()
|
||||
{
|
||||
return folderCombo.getFolderCombo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and populate dialog area
|
||||
* @see SystemPromptDialog#createInner(Composite)
|
||||
*/
|
||||
protected Control createInner(Composite parent)
|
||||
{
|
||||
// Inner composite
|
||||
int gridColumns = 1;
|
||||
Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, gridColumns);
|
||||
|
||||
// verbage
|
||||
boolean wantBorder = false;
|
||||
int span = 1;
|
||||
int widthHint = 200;
|
||||
SystemWidgetHelpers.createVerbage(composite_prompts, SystemFileResources.RESID_HOMEPROMPT_TITLE, span, wantBorder, widthHint);
|
||||
|
||||
// connection\folder prompt
|
||||
boolean readOnly = false;
|
||||
folderCombo = new SystemRemoteFolderCombo(composite_prompts, SWT.BORDER, null, readOnly);
|
||||
folderCombo.setSystemConnection(connection);
|
||||
folderCombo.setText("/home/"+SystemPlugin.getLocalMachineName());
|
||||
|
||||
// listen for selections
|
||||
//folderCombo.addSelectionListener(this);
|
||||
|
||||
return composite_prompts;
|
||||
}
|
||||
|
||||
/**
|
||||
* From SelectionListener interface
|
||||
*/
|
||||
public void widgetDefaultSelected(SelectionEvent event)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* From SelectionListener interface.
|
||||
* Called when user selects new item in dropdown
|
||||
*/
|
||||
public void widgetSelected(SelectionEvent event)
|
||||
{
|
||||
Object src = event.getSource();
|
||||
Combo comboWidget = folderCombo.getCombo();
|
||||
if (src == comboWidget)
|
||||
{
|
||||
//clearErrorMessage();
|
||||
//clearMessage();
|
||||
//String selectedFolder = folderCombo.getText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when user presses OK button.
|
||||
* Return true to close dialog.
|
||||
* Return false to not close dialog.
|
||||
*/
|
||||
protected boolean processOK()
|
||||
{
|
||||
boolean ok = true;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.dialogs;
|
||||
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.view.SystemActionViewerFilter;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
public class SystemRemoteArchiveDialog extends SystemRemoteFileDialog
|
||||
{
|
||||
private SystemActionViewerFilter _filter;
|
||||
|
||||
public SystemRemoteArchiveDialog(Shell shell, String title, IHost defaultConnection)
|
||||
{
|
||||
super(shell, title, defaultConnection);
|
||||
}
|
||||
|
||||
public SystemRemoteArchiveDialog(Shell shell, String title)
|
||||
{
|
||||
super(shell, title);
|
||||
|
||||
}
|
||||
|
||||
public SystemRemoteArchiveDialog(Shell shell)
|
||||
{
|
||||
super(shell, SystemFileResources.RESID_SELECTFILE_TITLE);
|
||||
|
||||
}
|
||||
|
||||
public SystemActionViewerFilter getViewerFilter()
|
||||
{
|
||||
if (_filter== null)
|
||||
{
|
||||
_filter = new SystemActionViewerFilter();
|
||||
Class[] types = {IRemoteFile.class};
|
||||
_filter.addFilterCriterion(types, "isDirectory", "true");
|
||||
_filter.addFilterCriterion(types, "isArchive", "true");
|
||||
}
|
||||
return _filter;
|
||||
}
|
||||
|
||||
|
||||
public String getVerbage()
|
||||
{
|
||||
return SystemFileResources.RESID_SELECTFILE_VERBAGE;
|
||||
}
|
||||
|
||||
public String getTreeTip()
|
||||
{
|
||||
return SystemFileResources.RESID_SELECTFILE_SELECT_TOOLTIP;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.dialogs;
|
||||
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.ui.dialogs.SystemRemoteResourceDialog;
|
||||
import org.eclipse.rse.ui.view.SystemActionViewerFilter;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
public class SystemRemoteFileDialog extends SystemRemoteResourceDialog
|
||||
{
|
||||
public SystemRemoteFileDialog(Shell shell, String title, IHost defaultConnection)
|
||||
{
|
||||
super(shell, title, new SystemRemoteFileSelectionInputProvider(defaultConnection));
|
||||
}
|
||||
|
||||
public SystemRemoteFileDialog(Shell shell, String title)
|
||||
{
|
||||
super(shell, title, new SystemRemoteFileSelectionInputProvider());
|
||||
}
|
||||
|
||||
public SystemRemoteFileDialog(Shell shell)
|
||||
{
|
||||
super(shell, SystemFileResources.RESID_SELECTFILE_TITLE, new SystemRemoteFileSelectionInputProvider());
|
||||
}
|
||||
|
||||
|
||||
public String getVerbage()
|
||||
{
|
||||
return SystemFileResources.RESID_SELECTFILE_VERBAGE;
|
||||
}
|
||||
|
||||
public String getTreeTip()
|
||||
{
|
||||
return SystemFileResources.RESID_SELECTFILE_SELECT_TOOLTIP;
|
||||
}
|
||||
|
||||
public SystemActionViewerFilter getViewerFilter()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.dialogs;
|
||||
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
|
||||
import org.eclipse.rse.ui.view.SystemResourceSelectionInputProvider;
|
||||
|
||||
|
||||
public class SystemRemoteFileSelectionInputProvider extends
|
||||
SystemResourceSelectionInputProvider
|
||||
{
|
||||
|
||||
public SystemRemoteFileSelectionInputProvider(IHost connection)
|
||||
{
|
||||
super(connection);
|
||||
}
|
||||
|
||||
public SystemRemoteFileSelectionInputProvider()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
protected ISubSystem getSubSystem(IHost selectedConnection)
|
||||
{
|
||||
return RemoteFileUtility.getFileSubSystem(selectedConnection);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.dialogs;
|
||||
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.view.SystemActionViewerFilter;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
public class SystemRemoteFolderDialog extends SystemRemoteFileDialog
|
||||
{
|
||||
private SystemActionViewerFilter _filter;
|
||||
|
||||
public SystemRemoteFolderDialog(Shell shell, String title, IHost defaultConnection)
|
||||
{
|
||||
super(shell, title, defaultConnection);
|
||||
}
|
||||
|
||||
public SystemRemoteFolderDialog(Shell shell, String title)
|
||||
{
|
||||
super(shell, title);
|
||||
|
||||
}
|
||||
|
||||
public SystemRemoteFolderDialog(Shell shell)
|
||||
{
|
||||
super(shell, SystemFileResources.RESID_SELECTDIRECTORY_TITLE);
|
||||
|
||||
}
|
||||
|
||||
public SystemActionViewerFilter getViewerFilter()
|
||||
{
|
||||
if (_filter== null)
|
||||
{
|
||||
_filter = new SystemActionViewerFilter();
|
||||
Class[] types = {IRemoteFile.class};
|
||||
_filter.addFilterCriterion(types, "isDirectory", "true");
|
||||
}
|
||||
return _filter;
|
||||
}
|
||||
|
||||
|
||||
public String getVerbage()
|
||||
{
|
||||
return SystemFileResources.RESID_SELECTDIRECTORY_VERBAGE;
|
||||
}
|
||||
|
||||
public String getTreeTip()
|
||||
{
|
||||
return SystemFileResources.RESID_SELECTDIRECTORY_SELECT_TOOLTIP;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,561 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.dialogs;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.rse.files.ui.ISystemAddFileListener;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemSelectRemoteFileOrFolderForm;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.ui.SystemResources;
|
||||
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
|
||||
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
||||
import org.eclipse.rse.ui.validators.IValidatorRemoteSelection;
|
||||
import org.eclipse.rse.ui.view.SystemViewForm;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
/**
|
||||
* Dialog for allowing users to select a remote file or folder. This is a thin dialog wrapper on top of
|
||||
* the SystemSelectRemoteFileOrFolderForm widget, which you could optionally imbed directly into your own
|
||||
* dialog or wizard page.
|
||||
* <p>
|
||||
* Call these methods to configure the functionality of the dialog
|
||||
* <ul>
|
||||
* <li>{@link #setSystemConnection(IHost) or #setDefaultConnection(SystemConnection)}
|
||||
* <li>{@link #setShowNewConnectionPrompt(boolean)}
|
||||
* <li>{@link #setSystemTypes(String[])}
|
||||
* <li>{@link #setAutoExpandDepth(int)}
|
||||
* <li>{@link #setRootFolder(IHost, String)} or {@link #setRootFolder(IRemoteFile)} or {@link #setPreSelection(IRemoteFile)}
|
||||
* <li>{@link #setFileTypes(String[])} or {@link #setFileTypes(String)}
|
||||
* <li>{@link #setShowPropertySheet(boolean)}
|
||||
* <li>{@link #enableAddMode(ISystemAddFileListener)}
|
||||
* <li>{@link #setMultipleSelectionMode(boolean)}
|
||||
* <li>{@link #setSelectionValidator(IValidatorRemoteSelection)}
|
||||
* </ul>
|
||||
* <p>
|
||||
* Call these methods to configure the text on the dialog
|
||||
* <ul>
|
||||
* <li>{@link #setMessage(String)}
|
||||
* <li>{@link #setSelectionTreeToolTipText(String)}
|
||||
* </ul>
|
||||
* <p>
|
||||
* After running, call these methods to get the output:
|
||||
* <ul>
|
||||
* <li>{@link #getSelectedObject()} or {@link #getSelectedObjects()}
|
||||
* <li>{@link #getSelectedConnection()}
|
||||
* </ul>
|
||||
*
|
||||
* @see org.eclipse.rse.files.ui.actions.SystemSelectRemoteFileAction
|
||||
* @see org.eclipse.rse.files.ui.actions.SystemSelectRemoteFolderAction
|
||||
*/
|
||||
public class SystemSelectRemoteFileOrFolderDialog
|
||||
extends SystemPromptDialog
|
||||
//implements ISystemFileConstants
|
||||
{
|
||||
public static final boolean FILE_MODE = true;
|
||||
public static final boolean FOLDER_MODE = false;
|
||||
protected SystemSelectRemoteFileOrFolderForm form;
|
||||
private boolean multipleSelectionMode;
|
||||
protected IHost outputConnection;
|
||||
private ISystemAddFileListener addButtonCallback = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param fileMode True if selecting files, false if selecting folders
|
||||
*
|
||||
*/
|
||||
public SystemSelectRemoteFileOrFolderDialog(Shell shell, boolean fileMode)
|
||||
{
|
||||
this(shell,
|
||||
fileMode ? SystemFileResources.RESID_SELECTFILE_TITLE : SystemFileResources.RESID_SELECTDIRECTORY_TITLE,
|
||||
fileMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor when you want to supply your own title.
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param title The title to give the dialog
|
||||
* @param fileMode True if selecting files, false if selecting folders
|
||||
*/
|
||||
public SystemSelectRemoteFileOrFolderDialog(Shell shell, String title, boolean fileMode)
|
||||
{
|
||||
super(shell, title);
|
||||
super.setBlockOnOpen(true); // always modal
|
||||
form = getForm(fileMode);
|
||||
//pack();
|
||||
}
|
||||
|
||||
// ------------------
|
||||
// PUBLIC METHODS...
|
||||
// ------------------
|
||||
/**
|
||||
* indicate whether selections from different parents are allowed
|
||||
*/
|
||||
public void setAllowForMultipleParents(boolean flag)
|
||||
{
|
||||
form.setAllowForMultipleParents(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the system connection to restrict the user to selecting files or folders from
|
||||
*/
|
||||
public void setSystemConnection(IHost conn)
|
||||
{
|
||||
form.setSystemConnection(conn);
|
||||
}
|
||||
/**
|
||||
* Set the connection to default the selection to
|
||||
*/
|
||||
public void setDefaultConnection(IHost conn)
|
||||
{
|
||||
form.setDefaultConnection(conn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restrict to certain system types
|
||||
* @param systemTypes the system types to restrict what connections are shown and what types of connections
|
||||
* the user can create
|
||||
* @see org.eclipse.rse.core.ISystemTypes
|
||||
*/
|
||||
public void setSystemTypes(String[] systemTypes)
|
||||
{
|
||||
form.setSystemTypes(systemTypes);
|
||||
}
|
||||
/**
|
||||
* Set to true if a "New Connection..." special connection is to be shown for creating new connections
|
||||
*/
|
||||
public void setShowNewConnectionPrompt(boolean show)
|
||||
{
|
||||
form.setShowNewConnectionPrompt(show);
|
||||
}
|
||||
/**
|
||||
* Set the message shown at the top of the form
|
||||
*/
|
||||
public void setMessage(String message)
|
||||
{
|
||||
form.setMessage(message);
|
||||
}
|
||||
/**
|
||||
* Set the tooltip text for the remote systems tree from which an item is selected.
|
||||
*/
|
||||
public void setSelectionTreeToolTipText(String tip)
|
||||
{
|
||||
form.setSelectionTreeToolTipText(tip);
|
||||
}
|
||||
/**
|
||||
* Specify the zero-based auto-expand level for the tree. The default is zero, meaning
|
||||
* only show the connections.
|
||||
*/
|
||||
public void setAutoExpandDepth(int depth)
|
||||
{
|
||||
form.setAutoExpandDepth(depth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root folder from which to start listing folders or files.
|
||||
* This version identifies the folder via a connection object and absolute path.
|
||||
* There is another overload that identifies the folder via a single IRemoteFile object.
|
||||
*
|
||||
* @param connection The connection to the remote system containing the root folder
|
||||
* @param folderAbsolutePath The fully qualified folder to start listing from (eg: "\folder1\folder2")
|
||||
*
|
||||
* @see org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString
|
||||
*/
|
||||
public void setRootFolder(IHost connection, String folderAbsolutePath)
|
||||
{
|
||||
form.setRootFolder(connection, folderAbsolutePath);
|
||||
}
|
||||
/**
|
||||
* Set the root folder from which to start listing folders.
|
||||
* This version identifies the folder via an IRemoteFile object.
|
||||
* There is another overload that identifies the folder via a connection and folder path.
|
||||
* <p>
|
||||
* This call effectively transforms the select dialog by:
|
||||
* <ul>
|
||||
* <li>Preventing the user from selecting other connections
|
||||
* <li>Preventing the user from selecting other filter strings
|
||||
* </ul>
|
||||
*
|
||||
* @param rootFolder The IRemoteFile object representing the remote folder to start the list from
|
||||
*
|
||||
* @see org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString
|
||||
*/
|
||||
public void setRootFolder(IRemoteFile rootFolder)
|
||||
{
|
||||
form.setRootFolder(rootFolder);
|
||||
}
|
||||
/**
|
||||
* Set a file or folder to preselect. This will:
|
||||
* <ul>
|
||||
* <li>Set the parent folder as the root folder
|
||||
* <li>Pre-expand the parent folder
|
||||
* <li>Pre-select the given file or folder after expansion
|
||||
* </ul>
|
||||
* If there is no parent, then we were given a root. In which case we will
|
||||
* <ul>
|
||||
* <li>Force setRestrictFolders to false
|
||||
* <li>Pre-expand the root drives (Windows) or root files (Unix)
|
||||
* <li>Pre-select the given root drive (Windows only)
|
||||
* </ul>
|
||||
*/
|
||||
public void setPreSelection(IRemoteFile selection)
|
||||
{
|
||||
form.setPreSelection(selection);
|
||||
}
|
||||
|
||||
/**
|
||||
* For files mode, restrict the files list by an array of file types
|
||||
* <p>
|
||||
* This must be called BEFORE setRootFolder!
|
||||
*/
|
||||
public void setFileTypes(String[] fileTypes)
|
||||
{
|
||||
form.setFileTypes(fileTypes);
|
||||
}
|
||||
/**
|
||||
* For files mode, restrict the files list by a comman-delimited array of file types.
|
||||
* The last type must also end in a comma. Eg "java, class," or "class,".
|
||||
* <p>
|
||||
* This must be called BEFORE setRootFolder!
|
||||
*/
|
||||
public void setFileTypes(String fileTypes)
|
||||
{
|
||||
form.setFileTypes(fileTypes);
|
||||
}
|
||||
/**
|
||||
* Specify whether setRootFolder should prevent the user from being able to see or select
|
||||
* any other folder. This causes two effects:
|
||||
* <ol>
|
||||
* <li>The special filter for root/drives is not shown
|
||||
* <li>No subfolders are listed in the target folder, if we are listing files. Of course, they are shown
|
||||
* if we are listing folders, else it would be an empty list!
|
||||
* </ol>
|
||||
*/
|
||||
public void setRestrictFolders(boolean restrict)
|
||||
{
|
||||
form.setRestrictFolders(restrict);
|
||||
}
|
||||
/**
|
||||
* Enable Add mode. This means the OK button is replaced with an Add button, and
|
||||
* the Cancel with a Close button. When Add is pressed, the caller is called back.
|
||||
* The dialog is not exited until Close is pressed.
|
||||
* <p>
|
||||
* When a library is selected, the caller is called back to decide to enable the Add
|
||||
* button or not.
|
||||
*/
|
||||
public void enableAddMode(ISystemAddFileListener caller)
|
||||
{
|
||||
this.addButtonCallback = caller;
|
||||
form.enableAddMode(caller);
|
||||
setShowAddButton(true);
|
||||
enableAddButton(false);
|
||||
setShowOkButton(false);
|
||||
setCancelButtonLabel(SystemResources.BUTTON_CLOSE);
|
||||
}
|
||||
/**
|
||||
* Overloaded method that allows setting the label and tooltip text of the Add button.
|
||||
* If you pass null for the label, the default is used ("Add").
|
||||
*/
|
||||
public void enableAddMode(ISystemAddFileListener caller, String addLabel, String addToolTipText)
|
||||
{
|
||||
enableAddMode(caller);
|
||||
if (addLabel != null)
|
||||
setAddButtonLabel(addLabel);
|
||||
if (addToolTipText != null)
|
||||
setAddButtonToolTipText(addToolTipText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the property sheet on the right hand side, to show the properties of the
|
||||
* selected object.
|
||||
* <p>
|
||||
* This overload always shows the property sheet
|
||||
* <p>
|
||||
* Default is false
|
||||
*/
|
||||
public void setShowPropertySheet(boolean show)
|
||||
{
|
||||
form.setShowPropertySheet(show);
|
||||
}
|
||||
/**
|
||||
* Show the property sheet on the right hand side, to show the properties of the
|
||||
* selected object.
|
||||
* <p>
|
||||
* This overload shows a Details>>> button so the user can decide if they want to see the
|
||||
* property sheet.
|
||||
* <p>
|
||||
* @param show True if show the property sheet within the dialog
|
||||
* @param initialState True if the property is to be initially displayed, false if it is not
|
||||
* to be displayed until the user presses the Details button.
|
||||
*/
|
||||
public void setShowPropertySheet(boolean show, boolean initialState)
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
form.setShowPropertySheet(initialState);
|
||||
setShowDetailsButton(true, !initialState);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set multiple selection mode. Default is single selection mode
|
||||
* <p>
|
||||
* If you turn on multiple selection mode, you must use the getSelectedObjects()
|
||||
* method to retrieve the list of selected objects.
|
||||
* <p>
|
||||
* Further, if you turn this on, it has the side effect of allowing the user
|
||||
* to select any remote object. The assumption being if you are prompting for
|
||||
* files, you also want to allow the user to select a folder, with the meaning
|
||||
* being that all files within the folder are implicitly selected.
|
||||
*
|
||||
* @see #getSelectedObjects()
|
||||
*/
|
||||
public void setMultipleSelectionMode(boolean multiple)
|
||||
{
|
||||
this.multipleSelectionMode = multiple;
|
||||
form.setMultipleSelectionMode(multiple);
|
||||
}
|
||||
/**
|
||||
* Specify a validator to use when the user selects a remote file or folder.
|
||||
* This allows you to decide if OK should be enabled or not for that remote file or folder.
|
||||
*/
|
||||
public void setSelectionValidator(IValidatorRemoteSelection selectionValidator)
|
||||
{
|
||||
form.setSelectionValidator(selectionValidator);
|
||||
}
|
||||
|
||||
// ------------------
|
||||
// OUTPUT METHODS...
|
||||
// ------------------
|
||||
|
||||
/**
|
||||
* Return selected file or folder
|
||||
*/
|
||||
public Object getSelectedObject()
|
||||
{
|
||||
if (getOutputObject() instanceof Object[])
|
||||
return ((Object[])getOutputObject())[0];
|
||||
else
|
||||
return getOutputObject();
|
||||
}
|
||||
/**
|
||||
* Return all selected objects. This method will return an array of one
|
||||
* unless you have called setMultipleSelectionMode(true)!
|
||||
* @see #setMultipleSelectionMode(boolean)
|
||||
*/
|
||||
public Object[] getSelectedObjects()
|
||||
{
|
||||
if (getOutputObject() instanceof Object[])
|
||||
return (Object[])getOutputObject();
|
||||
else if (getOutputObject() instanceof Object)
|
||||
return new Object[] {getOutputObject()};
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return selected connection
|
||||
*/
|
||||
public IHost getSelectedConnection()
|
||||
{
|
||||
return outputConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the multiple selection mode as set by setMultipleSelectionMode(boolean)
|
||||
*/
|
||||
public boolean getMultipleSelectionMode()
|
||||
{
|
||||
return multipleSelectionMode;
|
||||
}
|
||||
/**
|
||||
* Return the embedded System Tree object.
|
||||
* Will be null until createContents is called.
|
||||
*/
|
||||
public SystemViewForm getSystemViewForm()
|
||||
{
|
||||
return form.getSystemViewForm();
|
||||
}
|
||||
|
||||
// ------------------
|
||||
// PRIVATE METHODS...
|
||||
// ------------------
|
||||
/**
|
||||
* Private method.
|
||||
* @see SystemPromptDialog#getInitialFocusControl()
|
||||
*/
|
||||
protected Control getInitialFocusControl()
|
||||
{
|
||||
return form.getInitialFocusControl();
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method.
|
||||
* @see SystemPromptDialog#createInner(Composite)
|
||||
*/
|
||||
protected Control createInner(Composite parent)
|
||||
{
|
||||
return form.createContents(getShell(), parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method.
|
||||
* Get the contents.
|
||||
*/
|
||||
protected SystemSelectRemoteFileOrFolderForm getForm(boolean fileMode)
|
||||
{
|
||||
//System.out.println("INSIDE GETFORM");
|
||||
//if (form == null)
|
||||
//{
|
||||
form = new SystemSelectRemoteFileOrFolderForm(getMessageLine(), this, fileMode);
|
||||
// reset output variables just to be safe
|
||||
setOutputObject(null);
|
||||
outputConnection = null;
|
||||
//}
|
||||
return form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create message line. Intercept so we can set msg line of form.
|
||||
*/
|
||||
protected ISystemMessageLine createMessageLine(Composite c)
|
||||
{
|
||||
ISystemMessageLine msgLine = super.createMessageLine(c);
|
||||
if (form != null)
|
||||
form.setMessageLine(msgLine);
|
||||
return msgLine;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Private method.
|
||||
* <p>
|
||||
* Called when user presses OK button.
|
||||
* Return true to close dialog.
|
||||
* Return false to not close dialog.
|
||||
*/
|
||||
protected boolean processOK()
|
||||
{
|
||||
boolean closeDialog = form.verify();
|
||||
if (closeDialog)
|
||||
{
|
||||
outputConnection = form.getSelectedConnection();
|
||||
if (multipleSelectionMode)
|
||||
setOutputObject(form.getSelectedObjects());
|
||||
else
|
||||
setOutputObject(form.getSelectedObject());
|
||||
}
|
||||
else
|
||||
setOutputObject(null);
|
||||
return closeDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method.
|
||||
* <p>
|
||||
* Called when user presses Add button.
|
||||
*/
|
||||
protected boolean processAdd()
|
||||
{
|
||||
Object errMsg = addButtonCallback.addButtonPressed(form.getSelectedConnection(), (IRemoteFile[])form.getSelectedObjects());
|
||||
if (errMsg != null)
|
||||
{
|
||||
if (errMsg instanceof String)
|
||||
setErrorMessage((String)errMsg);
|
||||
else
|
||||
setErrorMessage((SystemMessage)errMsg);
|
||||
}
|
||||
else
|
||||
clearErrorMessage();
|
||||
enableAddButton(false); // presumably you won't add the same thing twice!
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Private method.
|
||||
* <p>
|
||||
* Called when user presses DETAILS button.
|
||||
* <p>
|
||||
* Note the text is automatically toggled for us! We need only
|
||||
* do whatever the functionality is that we desire
|
||||
*
|
||||
* @param hideMode the current state of the details toggle, prior to this request. If we return true from
|
||||
* this method, this state and the button text will be toggled.
|
||||
*
|
||||
* @return true if the details state toggle was successful, false if it failed.
|
||||
*/
|
||||
protected boolean processDetails(boolean hideMode)
|
||||
{
|
||||
form.toggleShowPropertySheet(getShell(), getContents());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void setPageComplete(boolean complete)
|
||||
{
|
||||
if (addButtonCallback != null)
|
||||
enableAddButton(complete);
|
||||
else
|
||||
super.setPageComplete(complete);
|
||||
}
|
||||
|
||||
/**
|
||||
* We have to override close to ensure that we reset the form to null
|
||||
*/
|
||||
public boolean close()
|
||||
{
|
||||
if (super.close())
|
||||
{
|
||||
if (form != null)
|
||||
{
|
||||
form.dispose();
|
||||
}
|
||||
form = null;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add viewer filter.
|
||||
* @param filter a viewer filter.
|
||||
*/
|
||||
public void addViewerFilter(ViewerFilter filter) {
|
||||
|
||||
if (form != null) {
|
||||
form.addViewerFilter(filter);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether to allow folder selection. The default selection validator will use this to
|
||||
* determine whether the OK button will be enabled when a folder is selected. The default
|
||||
* is <code>true</code>. This call only makes sense if the dialog is in file selection mode.
|
||||
* @param allow <code>true</code> to allow folder selection, <code>false</code> otherwise.
|
||||
*/
|
||||
public void setAllowFolderSelection(boolean allow) {
|
||||
|
||||
if (form != null) {
|
||||
form.setAllowFolderSelection(allow);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.propertypages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.core.servicesubsystem.IServiceSubSystemConfiguration;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.model.ISystemRegistry;
|
||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystemConfiguration;
|
||||
import org.eclipse.rse.ui.propertypages.ServicesPropertyPage;
|
||||
import org.eclipse.rse.ui.widgets.services.FactoryServiceElement;
|
||||
import org.eclipse.rse.ui.widgets.services.ServiceElement;
|
||||
|
||||
|
||||
public class FileServicesPropertyPage extends ServicesPropertyPage
|
||||
{
|
||||
|
||||
private IFileServiceSubSystemConfiguration _currentFactory;
|
||||
|
||||
protected FileServiceSubSystem getFileServiceSubSystem()
|
||||
{
|
||||
return (FileServiceSubSystem)getElement();
|
||||
}
|
||||
|
||||
protected ServiceElement[] getServiceElements()
|
||||
{
|
||||
FileServiceSubSystem subSystem = getFileServiceSubSystem();
|
||||
|
||||
IHost host = subSystem.getHost();
|
||||
_currentFactory = (IFileServiceSubSystemConfiguration)subSystem.getParentRemoteFileSubSystemFactory();
|
||||
IFileServiceSubSystemConfiguration[] factories = getFileServiceSubSystemFactories(host.getSystemType());
|
||||
|
||||
|
||||
// create elements for each
|
||||
ServiceElement[] elements = new ServiceElement[factories.length];
|
||||
for (int i = 0; i < factories.length; i++)
|
||||
{
|
||||
IFileServiceSubSystemConfiguration factory = factories[i];
|
||||
elements[i] = new FactoryServiceElement(host, factory);
|
||||
if (factory == _currentFactory)
|
||||
{
|
||||
elements[i].setSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
protected IFileServiceSubSystemConfiguration[] getFileServiceSubSystemFactories(String systemType)
|
||||
{
|
||||
List results = new ArrayList();
|
||||
ISystemRegistry sr = SystemPlugin.getTheSystemRegistry();
|
||||
ISubSystemConfiguration[] factories = sr.getSubSystemConfigurationsBySystemType(systemType);
|
||||
|
||||
for (int i = 0; i < factories.length; i++)
|
||||
{
|
||||
ISubSystemConfiguration factory = factories[i];
|
||||
if (factory instanceof IFileServiceSubSystemConfiguration)
|
||||
{
|
||||
results.add(factory);
|
||||
}
|
||||
}
|
||||
|
||||
return (IFileServiceSubSystemConfiguration[])results.toArray(new IFileServiceSubSystemConfiguration[results.size()]);
|
||||
}
|
||||
|
||||
|
||||
protected IServiceSubSystemConfiguration getCurrentServiceSubSystemFactory()
|
||||
{
|
||||
return _currentFactory;
|
||||
}
|
||||
|
||||
public void setSubSystemFactory(ISubSystemConfiguration factory)
|
||||
{
|
||||
_currentFactory = (IFileServiceSubSystemConfiguration)factory;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2000, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.propertypages;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration;
|
||||
import org.eclipse.rse.ui.propertypages.SystemAbstractPropertyPageExtensionAction;
|
||||
import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.ui.IWorkbenchPropertyPage;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is a base class to simplify the creation of property pages supplied via the
|
||||
* com.ibm.etools.systems.core.propertyPages extension point, targeting remote files
|
||||
* and/or remote folders.
|
||||
* <p>
|
||||
* The only method you must implement is {@link #createContentArea(Composite)}.
|
||||
* <p>
|
||||
* The benefits of this class are:</p>
|
||||
* <ul>
|
||||
* <li>From {@link SystemBasePropertyPage}: Adds a message line and {@link org.eclipse.rse.ui.messages.ISystemMessageLine} message methods.
|
||||
* <li>From {@link SystemBasePropertyPage}: Automatically assigns mnemonics to controls on this page, simplifying this common task. See {#wantMnemonics()}.
|
||||
* <li>From {@link SystemBasePropertyPage}: For pages with input controls, simplifies the page validation burden: only one method need be overridden: {@link #verifyPageContents()}
|
||||
* <li>From {@link SystemBasePropertyPage}: If no Default and Apply buttons wanted, the area reserved for this is removed, removing extra white space.
|
||||
* <li>Supplies helper method {@link #getRemoteFile()} for querying the selected remote file/folder.
|
||||
* <li>Supplies helper methods to query the {@link #getRemoteFileSubSystem() file-subsystem} and {@link #getSystemConnection() connection} containing the selected remote file.
|
||||
* </ul>
|
||||
*/
|
||||
public abstract class SystemAbstractRemoteFilePropertyPageExtensionAction
|
||||
extends SystemAbstractPropertyPageExtensionAction implements IWorkbenchPropertyPage
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SystemAbstractRemoteFilePropertyPageExtensionAction()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
// ----------------------------------
|
||||
// OVERRIDABLE METHODS FROM PARENT...
|
||||
// ----------------------------------
|
||||
/**
|
||||
* <i><b>Abstract</b>. You must override.</i><br>
|
||||
* This is where child classes create their content area versus createContent,
|
||||
* in order to have the message line configured for them and mnemonics assigned.
|
||||
*/
|
||||
protected abstract Control createContentArea(Composite parent);
|
||||
|
||||
/**
|
||||
* <i>You may override if your page has input fields. By default returns true.</i><br>
|
||||
* Validate all the widgets on the page. Based on this, the Eclipse framework will know whether
|
||||
* to veto any user attempt to select another property page from the list on the left in the
|
||||
* Properties dialog.
|
||||
* <p>
|
||||
* Subclasses should override to do full error checking on all the widgets on the page. Recommendation:<br>
|
||||
* <ul>
|
||||
* <li>If an error is detected, issue a {@link org.eclipse.rse.ui.messages.SystemMessage} via {@link #setErrorMessage(SystemMessage)} or text message via {@link #setErrorMessage(String)}.
|
||||
* <li>If no errors detected, clear the message line via {@link #clearErrorMessage()}
|
||||
* </ul>
|
||||
*
|
||||
* @return true if there are no errors, false if any errors were found.
|
||||
*/
|
||||
protected boolean verifyPageContents()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// CONVENIENCE METHODS WE ADD SPECIFICALLY FOR REMOTE FILE ACTIONS...
|
||||
// ------------------------------------------------------------------
|
||||
/**
|
||||
* Retrieve the input selected object, as an IRemoteFile, for convenience.
|
||||
*/
|
||||
public IRemoteFile getRemoteFile()
|
||||
{
|
||||
return (IRemoteFile)super.getRemoteObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remote file subsystem from which the selected objects were resolved.
|
||||
* This has many useful methods in it, including support to transfer files to and
|
||||
* from the local and remote systems.
|
||||
*/
|
||||
public IRemoteFileSubSystem getRemoteFileSubSystem()
|
||||
{
|
||||
return (IRemoteFileSubSystem)getSubSystem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remote file subsystem factory which owns the subsystem from which the
|
||||
* selected remote objects were resolved. This has some useful methods in it,
|
||||
* including isUnixStyle() indicating if this remote file system is unix or windows.
|
||||
*/
|
||||
public IRemoteFileSubSystemConfiguration getRemoteFileSubSystemFactory()
|
||||
{
|
||||
return (IRemoteFileSubSystemConfiguration)getSubSystemFactory();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,649 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.propertypages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferencePage;
|
||||
import org.eclipse.rse.core.SystemBasePlugin;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.resources.SystemIFileProperties;
|
||||
import org.eclipse.rse.files.ui.resources.SystemRemoteEditManager;
|
||||
import org.eclipse.rse.model.ISystemRegistry;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.ui.GenericMessages;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.ISystemPreferencesConstants;
|
||||
import org.eclipse.rse.ui.Mnemonics;
|
||||
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.rse.ui.view.SystemTableViewProvider;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.VerifyEvent;
|
||||
import org.eclipse.swt.events.VerifyListener;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.graphics.FontData;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IEditorReference;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.dialogs.ListSelectionDialog;
|
||||
import org.eclipse.ui.model.AdaptableList;
|
||||
import org.eclipse.ui.model.WorkbenchContentProvider;
|
||||
|
||||
|
||||
/**
|
||||
* Preference page for generic Remote System cache preferences
|
||||
*/
|
||||
public class SystemCachePreferencePage extends PreferencePage implements IWorkbenchPreferencePage, Listener
|
||||
{
|
||||
|
||||
private Button _clearButton;
|
||||
private Button _maxCacheCheckbox;
|
||||
private Text _maxCacheSize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public SystemCachePreferencePage()
|
||||
{
|
||||
super();
|
||||
setPreferenceStore(SystemPlugin.getDefault().getPreferenceStore());
|
||||
setDescription(FileResources.RESID_PREF_CACHE_DESCRIPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the composite. We intercept to set the help.
|
||||
*/
|
||||
public void createControl(Composite parent)
|
||||
{
|
||||
super.createControl(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected Control createContents(Composite gparent)
|
||||
{
|
||||
Composite parent = SystemWidgetHelpers.createComposite(gparent, 1);
|
||||
|
||||
Composite maxComp = SystemWidgetHelpers.createComposite(parent, 2);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 2;
|
||||
maxComp.setLayout(layout);
|
||||
maxComp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
|
||||
|
||||
_maxCacheCheckbox =
|
||||
SystemWidgetHelpers.createCheckBox(
|
||||
maxComp,
|
||||
FileResources.RESID_PREF_CACHE_MAX_CACHE_SIZE_LABEL,
|
||||
this);
|
||||
_maxCacheCheckbox.setToolTipText(
|
||||
FileResources.RESID_PREF_CACHE_MAX_CACHE_SIZE_TOOLTIP);
|
||||
|
||||
_maxCacheSize = SystemWidgetHelpers.createTextField(maxComp, this);
|
||||
GridData gd = new GridData();
|
||||
gd.widthHint = 75;
|
||||
_maxCacheSize.setLayoutData(gd);
|
||||
|
||||
_maxCacheSize.setTextLimit(5);
|
||||
_maxCacheSize.addVerifyListener(new VerifyListener()
|
||||
{
|
||||
public void verifyText(VerifyEvent e)
|
||||
{
|
||||
e.doit = true;
|
||||
for (int loop = 0; loop < e.text.length(); loop++)
|
||||
{
|
||||
if (!Character.isDigit(e.text.charAt(loop)))
|
||||
e.doit = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Composite clearComp = SystemWidgetHelpers.createComposite(parent, 2);
|
||||
layout = new GridLayout();
|
||||
layout.numColumns = 2;
|
||||
clearComp.setLayout(layout);
|
||||
clearComp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
|
||||
|
||||
SystemWidgetHelpers.createLabel(
|
||||
clearComp,
|
||||
FileResources.RESID_PREF_CACHE_CLEAR_LABEL);
|
||||
_clearButton =
|
||||
SystemWidgetHelpers.createPushButton(
|
||||
clearComp,
|
||||
FileResources.RESID_PREF_CACHE_CLEAR,
|
||||
this);
|
||||
_clearButton.setToolTipText(FileResources.RESID_PREF_CACHE_CLEAR_TOOLTIP);
|
||||
gd = new GridData();
|
||||
gd.widthHint = 75;
|
||||
_clearButton.setLayoutData(gd);
|
||||
|
||||
Composite warningComp = SystemWidgetHelpers.createComposite(clearComp, 2);
|
||||
gd = new GridData();
|
||||
gd.horizontalSpan = 2;
|
||||
warningComp.setLayoutData(gd);
|
||||
|
||||
Display display = getControl().getDisplay();
|
||||
Label warningLabel =
|
||||
SystemWidgetHelpers.createLabel(
|
||||
warningComp,
|
||||
FileResources.RESID_PREF_CACHE_CLEAR_WARNING_LABEL);
|
||||
FontData oldData = warningLabel.getFont().getFontData()[0];
|
||||
FontData data = new FontData(oldData.getName(), oldData.getHeight(), SWT.BOLD);
|
||||
Font fFont = new Font(display, data);
|
||||
|
||||
warningLabel.setFont(fFont);
|
||||
SystemWidgetHelpers.createLabel(
|
||||
warningComp,
|
||||
FileResources.RESID_PREF_CACHE_CLEAR_WARNING_DESCRIPTION);
|
||||
|
||||
(new Mnemonics()).setOnPreferencePage(true).setMnemonics(parent);
|
||||
SystemWidgetHelpers.setCompositeHelp(parent, SystemPlugin.HELPPREFIX + "fchp0000");
|
||||
|
||||
initControls();
|
||||
return parent;
|
||||
}
|
||||
|
||||
private void initControls()
|
||||
{
|
||||
IPreferenceStore store = SystemPlugin.getDefault().getPreferenceStore();
|
||||
boolean enableMaxSize = store.getBoolean(ISystemPreferencesConstants.LIMIT_CACHE);
|
||||
_maxCacheSize.setEnabled(enableMaxSize);
|
||||
|
||||
String maxCacheSizeStr = store.getString(ISystemPreferencesConstants.MAX_CACHE_SIZE);
|
||||
|
||||
if (maxCacheSizeStr == null || maxCacheSizeStr.equals("")) {
|
||||
maxCacheSizeStr = ISystemPreferencesConstants.DEFAULT_MAX_CACHE_SIZE;
|
||||
}
|
||||
|
||||
_maxCacheSize.setText(maxCacheSizeStr);
|
||||
_maxCacheCheckbox.setSelection(enableMaxSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherited method.
|
||||
*/
|
||||
public void init(IWorkbench workbench)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FieldEditorPreferencePage#performDefaults()
|
||||
*/
|
||||
protected void performDefaults()
|
||||
{
|
||||
super.performDefaults();
|
||||
|
||||
IPreferenceStore store = SystemPlugin.getDefault().getPreferenceStore();
|
||||
|
||||
boolean enableMaxSize = store.getDefaultBoolean(ISystemPreferencesConstants.LIMIT_CACHE);
|
||||
_maxCacheCheckbox.setSelection(enableMaxSize);
|
||||
|
||||
_maxCacheSize.setEnabled(enableMaxSize);
|
||||
_maxCacheSize.setText(store.getDefaultString(ISystemPreferencesConstants.MAX_CACHE_SIZE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default preferences for the communications preference page.
|
||||
*
|
||||
* @param store PreferenceStore used for this preference page.
|
||||
*/
|
||||
public static void initDefaults(IPreferenceStore store)
|
||||
{
|
||||
store.setDefault(ISystemPreferencesConstants.LIMIT_CACHE, ISystemPreferencesConstants.DEFAULT_LIMIT_CACHE);
|
||||
store.setDefault(ISystemPreferencesConstants.MAX_CACHE_SIZE, ISystemPreferencesConstants.DEFAULT_MAX_CACHE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FieldEditorPreferencePage#performOk()
|
||||
*/
|
||||
public boolean performOk()
|
||||
{
|
||||
IPreferenceStore store = SystemPlugin.getDefault().getPreferenceStore();
|
||||
String size = _maxCacheSize.getText();
|
||||
|
||||
if (size == null || size.trim().equals("")) {
|
||||
size = ISystemPreferencesConstants.DEFAULT_MAX_CACHE_SIZE;
|
||||
}
|
||||
|
||||
store.setValue(ISystemPreferencesConstants.MAX_CACHE_SIZE, size);
|
||||
store.setValue(ISystemPreferencesConstants.LIMIT_CACHE, _maxCacheCheckbox.getSelection());
|
||||
|
||||
return super.performOk();
|
||||
}
|
||||
|
||||
public class ClearTempFilesRunnable implements IRunnableWithProgress
|
||||
{
|
||||
public void run(IProgressMonitor monitor)
|
||||
{
|
||||
SystemRemoteEditManager mgr = SystemRemoteEditManager.getDefault();
|
||||
// if no temp file project, nothing to do
|
||||
if (!mgr.doesRemoteEditProjectExist())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IProject tempFiles = mgr.getRemoteEditProject();
|
||||
if (tempFiles != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
IWorkspace workspace = SystemBasePlugin.getWorkspace();
|
||||
IResource[] members = tempFiles.members();
|
||||
if (members != null)
|
||||
{
|
||||
for (int i = 0; i < members.length; i++)
|
||||
{
|
||||
IResource member = members[i];
|
||||
if ((member instanceof IFile) &&
|
||||
member.getName().equals(".project"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
// DKM - passing true now so that out-of-synch temp files are deleted too (i.e. generated .evt files)
|
||||
// this solves the worse part of 58951
|
||||
member.delete(true, monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
finally
|
||||
{
|
||||
mgr.getRemoteEditProject();
|
||||
/*
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
// recreate .project
|
||||
IProjectDescription description = tempFiles.getDescription();
|
||||
String[] natures = description.getNatureIds();
|
||||
String[] newNatures = new String[natures.length + 1];
|
||||
|
||||
// copy all previous natures
|
||||
for (int i = 0; i < natures.length; i++)
|
||||
{
|
||||
newNatures[i] = natures[i];
|
||||
}
|
||||
|
||||
newNatures[newNatures.length - 1] = SystemRemoteEditManager.REMOTE_EDIT_PROJECT_NATURE_ID;
|
||||
description.setNatureIds(newNatures);
|
||||
tempFiles.setDescription(description, null);
|
||||
|
||||
mgr.addCSupport(tempFiles);
|
||||
mgr.addJavaSupport(tempFiles);
|
||||
|
||||
|
||||
}
|
||||
catch (CoreException e)
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IRunnableContext getRunnableContext(Shell shell)
|
||||
{
|
||||
IRunnableContext irc = SystemPlugin.getTheSystemRegistry().getRunnableContext();
|
||||
if (irc != null)
|
||||
{
|
||||
return irc;
|
||||
}
|
||||
else
|
||||
{
|
||||
// for other cases, use statusbar
|
||||
IWorkbenchWindow win = SystemBasePlugin.getActiveWorkbenchWindow();
|
||||
if (win != null)
|
||||
{
|
||||
Shell winShell = SystemBasePlugin.getActiveWorkbenchShell();
|
||||
if (winShell != null && winShell.isVisible() && !winShell.isDisposed())
|
||||
{
|
||||
shell = winShell;
|
||||
return win;
|
||||
}
|
||||
else
|
||||
{
|
||||
win = null;
|
||||
}
|
||||
}
|
||||
|
||||
return new ProgressMonitorDialog(shell);
|
||||
}
|
||||
}
|
||||
public void handleEvent(Event e)
|
||||
{
|
||||
if (e.widget == _clearButton)
|
||||
{
|
||||
|
||||
if (checkDirtyEditors())
|
||||
{
|
||||
IRunnableContext runnableContext = getRunnableContext(SystemBasePlugin.getActiveWorkbenchShell());
|
||||
try
|
||||
{
|
||||
// currently we don't run this in a thread because
|
||||
// in some cases dialogs are launched in the operation
|
||||
// (widgets can only be legally used on the main thread)
|
||||
runnableContext.run(false, true, new ClearTempFilesRunnable());
|
||||
// inthread, cancellable, IRunnableWithProgress
|
||||
}
|
||||
catch (java.lang.reflect.InvocationTargetException exc)
|
||||
{
|
||||
}
|
||||
catch (java.lang.InterruptedException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (e.widget == _maxCacheCheckbox)
|
||||
{
|
||||
_maxCacheSize.setEnabled(_maxCacheCheckbox.getSelection());
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean getDirtyReplicas(IContainer parent, List dirtyReplicas)
|
||||
{
|
||||
try
|
||||
{
|
||||
IResource[] children = parent.members();
|
||||
for (int i = 0; i < children.length; i++)
|
||||
{
|
||||
IResource child = children[i];
|
||||
if (child instanceof IFile)
|
||||
{
|
||||
SystemIFileProperties properties = new SystemIFileProperties(child);
|
||||
if (properties.getDirty())
|
||||
{
|
||||
if (properties.getRemoteFileObject() != null)
|
||||
{
|
||||
ISystemEditableRemoteObject editable =
|
||||
(ISystemEditableRemoteObject) properties.getRemoteFileObject();
|
||||
dirtyReplicas.add(editable);
|
||||
}
|
||||
else if (properties.getDownloadFileTimeStamp() != child.getLocalTimeStamp())
|
||||
{
|
||||
String ssString = properties.getRemoteFileSubSystem();
|
||||
ISystemRegistry registry = SystemPlugin.getTheSystemRegistry();
|
||||
ISubSystem subsystem = registry.getSubSystem(ssString);
|
||||
if (subsystem != null)
|
||||
{
|
||||
String path = properties.getRemoteFilePath();
|
||||
try
|
||||
{
|
||||
IAdaptable remoteFile = (IAdaptable) subsystem.getObjectWithAbsoluteName(path);
|
||||
if (remoteFile != null)
|
||||
{
|
||||
ISystemRemoteElementAdapter adapter =
|
||||
(ISystemRemoteElementAdapter) remoteFile.getAdapter(
|
||||
ISystemRemoteElementAdapter.class);
|
||||
ISystemEditableRemoteObject editable =
|
||||
adapter.getEditableRemoteObject(remoteFile);
|
||||
editable.openEditor();
|
||||
// need this to get a reference back to the object
|
||||
properties.setRemoteFileObject(editable);
|
||||
dirtyReplicas.add(editable);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (child instanceof IContainer)
|
||||
{
|
||||
if (!getDirtyReplicas((IContainer) child, dirtyReplicas))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean getDirtyReplicas(List results)
|
||||
{
|
||||
SystemRemoteEditManager mgr = SystemRemoteEditManager.getDefault();
|
||||
IProject tempFilesProject = mgr.getRemoteEditProject();
|
||||
if (!getDirtyReplicas(tempFilesProject, results))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!getDirtyEditors(results))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean getDirtyEditors(List results)
|
||||
{
|
||||
SystemRemoteEditManager editMgr = SystemRemoteEditManager.getDefault();
|
||||
|
||||
// if there's no temp file project, there's no dirty editors
|
||||
if (!editMgr.doesRemoteEditProjectExist())
|
||||
return false;
|
||||
|
||||
IProject tempFilesProject = editMgr.getRemoteEditProject();
|
||||
IWorkbenchWindow activeWindow = SystemBasePlugin.getActiveWorkbenchWindow();
|
||||
IWorkbenchPage activePage = activeWindow.getActivePage();
|
||||
|
||||
IEditorReference[] activeReferences = activePage.getEditorReferences();
|
||||
|
||||
IEditorPart part;
|
||||
|
||||
for (int k = 0; k < activeReferences.length; k++)
|
||||
{
|
||||
part = activeReferences[k].getEditor(false);
|
||||
|
||||
if (part != null)
|
||||
{
|
||||
IEditorInput editorInput = part.getEditorInput();
|
||||
|
||||
if (editorInput instanceof IFileEditorInput)
|
||||
{
|
||||
IFile file = ((IFileEditorInput) editorInput).getFile();
|
||||
if (file.getProject() == tempFilesProject)
|
||||
{
|
||||
if (part.isDirty())
|
||||
{
|
||||
SystemIFileProperties properties = new SystemIFileProperties(file);
|
||||
if (properties.getDirty())
|
||||
{
|
||||
// then this is already added via getDirtyReplicas()
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (properties.getRemoteFileObject() != null)
|
||||
{
|
||||
ISystemEditableRemoteObject editable =
|
||||
(ISystemEditableRemoteObject) properties.getRemoteFileObject();
|
||||
results.add(editable);
|
||||
}
|
||||
else
|
||||
{
|
||||
String ssString = properties.getRemoteFileSubSystem();
|
||||
ISystemRegistry registry = SystemPlugin.getTheSystemRegistry();
|
||||
ISubSystem subsystem = registry.getSubSystem(ssString);
|
||||
if (subsystem != null)
|
||||
{
|
||||
String path = properties.getRemoteFilePath();
|
||||
try
|
||||
{
|
||||
|
||||
IAdaptable remoteFile =
|
||||
(IAdaptable) subsystem.getObjectWithAbsoluteName(path);
|
||||
if (remoteFile != null)
|
||||
{
|
||||
ISystemRemoteElementAdapter adapter =
|
||||
(ISystemRemoteElementAdapter) remoteFile.getAdapter(
|
||||
ISystemRemoteElementAdapter.class);
|
||||
ISystemEditableRemoteObject editable =
|
||||
adapter.getEditableRemoteObject(remoteFile);
|
||||
editable.openEditor();
|
||||
// need this to get a reference back to the object
|
||||
properties.setRemoteFileObject(editable);
|
||||
results.add(editable);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ISystemEditableRemoteObject getEditableFor(IAdaptable selected)
|
||||
{
|
||||
ISystemRemoteElementAdapter adapter =
|
||||
(ISystemRemoteElementAdapter) ((IAdaptable) selected).getAdapter(ISystemRemoteElementAdapter.class);
|
||||
if (adapter.canEdit(selected))
|
||||
{
|
||||
ISystemEditableRemoteObject editable = adapter.getEditableRemoteObject(selected);
|
||||
try
|
||||
{
|
||||
editable.setLocalResourceProperties();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return editable;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean checkDirtyEditors()
|
||||
{
|
||||
SystemRemoteEditManager mgr = SystemRemoteEditManager.getDefault();
|
||||
if (!mgr.doesRemoteEditProjectExist())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
List dirtyEditors = new ArrayList();
|
||||
if (!getDirtyReplicas(dirtyEditors))
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_CACHE_UNABLE_TO_SYNCH);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
dlg.open();
|
||||
|
||||
return false;
|
||||
}
|
||||
if (dirtyEditors.size() > 0)
|
||||
{
|
||||
AdaptableList input = new AdaptableList();
|
||||
for (int i = 0; i < dirtyEditors.size(); i++)
|
||||
{
|
||||
ISystemEditableRemoteObject rmtObj = (ISystemEditableRemoteObject) dirtyEditors.get(i);
|
||||
input.add(rmtObj.getRemoteObject());
|
||||
}
|
||||
|
||||
WorkbenchContentProvider cprovider = new WorkbenchContentProvider();
|
||||
SystemTableViewProvider lprovider = new SystemTableViewProvider();
|
||||
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_CACHE_UPLOAD_BEFORE_DELETE);
|
||||
|
||||
ListSelectionDialog dlg =
|
||||
new ListSelectionDialog(getShell(), input, cprovider, lprovider, msg.getLevelOneText());
|
||||
|
||||
dlg.setInitialSelections(input.getChildren());
|
||||
// TODO: Cannot use WorkbenchMessages -- it's internal
|
||||
dlg.setTitle(GenericMessages.EditorManager_saveResourcesTitle);
|
||||
|
||||
int result = dlg.open();
|
||||
|
||||
//Just return false to prevent the operation continuing
|
||||
if (result == IDialogConstants.CANCEL_ID)
|
||||
return false;
|
||||
|
||||
Object[] filesToSave = dlg.getResult();
|
||||
for (int s = 0; s < filesToSave.length; s++)
|
||||
{
|
||||
IAdaptable rmtObj = (IAdaptable) filesToSave[s];
|
||||
ISystemEditableRemoteObject editable = getEditableFor(rmtObj);
|
||||
if (!editable.doImmediateSaveAndUpload())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,298 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.propertypages;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.model.ISystemResourceChangeEvents;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IVirtualRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileIOException;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSecurityException;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||
import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
|
||||
|
||||
/**
|
||||
* The remote property page for remote file properties.
|
||||
* This is an output-only page.
|
||||
* The plugin.xml file registers this for remote file system objects.
|
||||
*/
|
||||
public class SystemFilePropertyPage extends SystemBasePropertyPage
|
||||
implements ISystemMessages, SelectionListener
|
||||
{
|
||||
|
||||
protected Label labelNamePrompt, labelTypePrompt, labelPathPrompt, labelSizePrompt,
|
||||
labelModifiedPrompt;
|
||||
//protected Button cbReadablePrompt, cbWritablePrompt;
|
||||
protected Button cbReadonlyPrompt, cbHiddenPrompt;
|
||||
protected Label labelName, labelType, labelPath, labelSize, labelModified, labelReadable, labelWritable, labelHidden;
|
||||
protected String errorMessage;
|
||||
protected boolean initDone = false;
|
||||
protected boolean wasReadOnly = false;
|
||||
|
||||
/**
|
||||
* Constructor for SystemFilterPropertyPage
|
||||
*/
|
||||
public SystemFilePropertyPage()
|
||||
{
|
||||
super();
|
||||
SystemPlugin sp = SystemPlugin.getDefault();
|
||||
}
|
||||
/**
|
||||
* Create the page's GUI contents.
|
||||
*/
|
||||
protected Control createContentArea(Composite parent)
|
||||
{
|
||||
IRemoteFile file = getRemoteFile();
|
||||
|
||||
// Inner composite
|
||||
int nbrColumns = 2;
|
||||
Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, nbrColumns);
|
||||
|
||||
// Name display
|
||||
labelNamePrompt = SystemWidgetHelpers.createLabel(
|
||||
composite_prompts, SystemFileResources.RESID_PP_FILE_NAME_LABEL, SystemFileResources.RESID_PP_FILE_NAME_TOOLTIP);
|
||||
labelName = SystemWidgetHelpers.createLabel(
|
||||
composite_prompts, "");
|
||||
labelName.setToolTipText(SystemFileResources.RESID_PP_FILE_NAME_TOOLTIP);
|
||||
|
||||
// Type display
|
||||
labelTypePrompt = SystemWidgetHelpers.createLabel(
|
||||
composite_prompts, SystemFileResources.RESID_PP_FILE_TYPE_LABEL, SystemFileResources.RESID_PP_FILE_TYPE_TOOLTIP);
|
||||
labelType = SystemWidgetHelpers.createLabel(
|
||||
composite_prompts, "");
|
||||
labelType.setToolTipText(SystemFileResources.RESID_PP_FILE_TYPE_TOOLTIP);
|
||||
|
||||
// Path display
|
||||
if (!file.isRoot())
|
||||
{
|
||||
labelPathPrompt = SystemWidgetHelpers.createLabel(
|
||||
composite_prompts, SystemFileResources.RESID_PP_FILE_PATH_LABEL, SystemFileResources.RESID_PP_FILE_PATH_TOOLTIP);
|
||||
labelPath = SystemWidgetHelpers.createLabel(
|
||||
composite_prompts, "");
|
||||
labelPath.setToolTipText(SystemFileResources.RESID_PP_FILE_PATH_TOOLTIP);
|
||||
}
|
||||
|
||||
// Size display
|
||||
if (!file.isDirectory())
|
||||
{
|
||||
labelSizePrompt = SystemWidgetHelpers.createLabel(
|
||||
composite_prompts, SystemFileResources.RESID_PP_FILE_SIZE_LABEL, SystemFileResources.RESID_PP_FILE_SIZE_TOOLTIP);
|
||||
labelSize = SystemWidgetHelpers.createLabel(
|
||||
composite_prompts, "");
|
||||
labelSize.setToolTipText(SystemFileResources.RESID_PP_FILE_SIZE_TOOLTIP);
|
||||
}
|
||||
|
||||
// Modified display
|
||||
if (!file.isRoot())
|
||||
{
|
||||
labelModifiedPrompt = SystemWidgetHelpers.createLabel(
|
||||
composite_prompts, SystemFileResources.RESID_PP_FILE_MODIFIED_LABEL, SystemFileResources.RESID_PP_FILE_MODIFIED_TOOLTIP);
|
||||
labelModified = SystemWidgetHelpers.createLabel(
|
||||
composite_prompts, "");
|
||||
labelModified.setToolTipText(SystemFileResources.RESID_PP_FILE_MODIFIED_TOOLTIP);
|
||||
}
|
||||
|
||||
// Readonly display
|
||||
if (!file.isRoot())
|
||||
{
|
||||
if (file.showReadOnlyProperty())
|
||||
{
|
||||
cbReadonlyPrompt = SystemWidgetHelpers.createCheckBox(
|
||||
composite_prompts, null, SystemFileResources.RESID_PP_FILE_READONLY_LABEL, SystemFileResources.RESID_PP_FILE_READONLY_TOOLTIP);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Readable display
|
||||
if (!file.isRoot())
|
||||
{
|
||||
cbReadablePrompt = SystemWidgetHelpers.createCheckBox(
|
||||
composite_prompts, null, SystemFileResources.RESID_PP_FILE_READABLE_ROOT);
|
||||
}
|
||||
|
||||
// Writable display
|
||||
if (!file.isRoot())
|
||||
{
|
||||
cbWritablePrompt = SystemWidgetHelpers.createCheckBox(
|
||||
composite_prompts, null, SystemFileResources.RESID_PP_FILE_WRITABLE_ROOT);
|
||||
}
|
||||
*/
|
||||
|
||||
// Hidden display
|
||||
if (!file.isRoot())
|
||||
{
|
||||
cbHiddenPrompt = SystemWidgetHelpers.createCheckBox(
|
||||
composite_prompts, null, SystemFileResources.RESID_PP_FILE_HIDDEN_LABEL, SystemFileResources.RESID_PP_FILE_HIDDEN_TOOLTIP);
|
||||
//((GridData)cbHiddenPrompt.getLayoutData()).horizontalSpan = nbrColumns;
|
||||
}
|
||||
|
||||
if (!initDone)
|
||||
doInitializeFields();
|
||||
|
||||
if (!file.isRoot() && file.showReadOnlyProperty())
|
||||
cbReadonlyPrompt.addSelectionListener(this);
|
||||
|
||||
return composite_prompts;
|
||||
}
|
||||
/**
|
||||
* Get the input remote file object
|
||||
*/
|
||||
protected IRemoteFile getRemoteFile()
|
||||
{
|
||||
Object element = getElement();
|
||||
return ((IRemoteFile)element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize values of input fields based on input
|
||||
*/
|
||||
protected void doInitializeFields()
|
||||
{
|
||||
initDone = true;
|
||||
IRemoteFile file = getRemoteFile();
|
||||
// name
|
||||
String name = file.getName();
|
||||
if (name.length() > 100)
|
||||
{
|
||||
String shortName = name.substring(0, 97).concat("...");
|
||||
labelName.setText(shortName);
|
||||
}
|
||||
else
|
||||
{
|
||||
labelName.setText(name);
|
||||
}
|
||||
|
||||
// type
|
||||
if (file.isRoot())
|
||||
labelType.setText(SystemFileResources.RESID_PP_FILE_TYPE_ROOT_VALUE);
|
||||
else if (file.isDirectory())
|
||||
labelType.setText(SystemFileResources.RESID_PP_FILE_TYPE_FOLDER_VALUE);
|
||||
else
|
||||
labelType.setText(SystemFileResources.RESID_PP_FILE_TYPE_FILE_VALUE);
|
||||
// path
|
||||
if (labelPath != null)
|
||||
{
|
||||
String path = file.getParentPath();
|
||||
if (path != null)
|
||||
labelPath.setText(file.getParentPath());
|
||||
}
|
||||
// size
|
||||
if (labelSize != null)
|
||||
labelSize.setText(Long.toString(file.getLength()));
|
||||
// modified
|
||||
if (labelModified != null)
|
||||
{
|
||||
Date date = file.getLastModifiedDate();
|
||||
if (date != null)
|
||||
{
|
||||
SimpleDateFormat datefmt = (SimpleDateFormat)DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
|
||||
labelModified.setText(datefmt.format(date));
|
||||
}
|
||||
}
|
||||
// readonly
|
||||
if (file.showReadOnlyProperty()) {
|
||||
if (cbReadonlyPrompt != null)
|
||||
{
|
||||
cbReadonlyPrompt.setSelection(!file.canWrite());
|
||||
wasReadOnly = !file.canWrite();
|
||||
if (wasReadOnly || file instanceof IVirtualRemoteFile)
|
||||
cbReadonlyPrompt.setEnabled(false);
|
||||
}
|
||||
}
|
||||
/*
|
||||
// readable
|
||||
if (cbReadablePrompt != null)
|
||||
{
|
||||
cbReadablePrompt.setSelection(file.canRead());
|
||||
cbReadablePrompt.setEnabled(false);
|
||||
}
|
||||
// writable
|
||||
if (cbWritablePrompt != null)
|
||||
{
|
||||
cbWritablePrompt.setSelection(file.canWrite());
|
||||
cbWritablePrompt.setEnabled(false);
|
||||
}
|
||||
*/
|
||||
// hidden
|
||||
if (cbHiddenPrompt != null)
|
||||
{
|
||||
cbHiddenPrompt.setSelection(file.isHidden());
|
||||
cbHiddenPrompt.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by parent when user presses OK
|
||||
*/
|
||||
public boolean performOk()
|
||||
{
|
||||
boolean ok = super.performOk();
|
||||
if (ok && (cbReadonlyPrompt!=null) && cbReadonlyPrompt.getSelection() && !wasReadOnly)
|
||||
{
|
||||
try
|
||||
{
|
||||
getRemoteFile().getParentRemoteFileSubSystem().setReadOnly(getRemoteFile());
|
||||
SystemPlugin.getTheSystemRegistry().fireEvent(
|
||||
new org.eclipse.rse.model.SystemResourceChangeEvent(
|
||||
getRemoteFile(),ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE,null));
|
||||
|
||||
} catch (RemoteFileIOException exc)
|
||||
{
|
||||
setMessage(SystemPlugin.getPluginMessage(ISystemMessages.FILEMSG_IO_ERROR));
|
||||
} catch (RemoteFileSecurityException exc)
|
||||
{
|
||||
setMessage(SystemPlugin.getPluginMessage(ISystemMessages.FILEMSG_SECURITY_ERROR));
|
||||
}
|
||||
//catch (RemoteFileException e)
|
||||
//{
|
||||
//}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
/**
|
||||
* Validate all the widgets on the page
|
||||
* <p>
|
||||
* Subclasses should override to do full error checking on all
|
||||
* the widgets on the page.
|
||||
*/
|
||||
protected boolean verifyPageContents()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void widgetDefaultSelected(SelectionEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
public void widgetSelected(SelectionEvent event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,962 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.propertypages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.viewers.ColumnLayoutData;
|
||||
import org.eclipse.jface.viewers.ColumnPixelData;
|
||||
import org.eclipse.jface.viewers.ColumnWeightData;
|
||||
import org.eclipse.jface.viewers.TableLayout;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
|
||||
import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeMapping;
|
||||
import org.eclipse.rse.subsystems.files.core.model.SystemFileTransferModeRegistry;
|
||||
import org.eclipse.rse.ui.ISystemMessages;
|
||||
import org.eclipse.rse.ui.ISystemPreferencesConstants;
|
||||
import org.eclipse.rse.ui.Mnemonics;
|
||||
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.VerifyEvent;
|
||||
import org.eclipse.swt.events.VerifyListener;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.eclipse.swt.widgets.TableItem;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.IEditorRegistry;
|
||||
import org.eclipse.ui.IFileEditorMapping;
|
||||
import org.eclipse.ui.IPropertyListener;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.eclipse.ui.internal.dialogs.FileExtensionDialog;
|
||||
import org.eclipse.ui.internal.registry.EditorRegistry;
|
||||
import org.eclipse.ui.internal.registry.FileEditorMapping;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* "Files" Preference page within the Remote Systems preference node.
|
||||
* This allows users to specify, per file extension, whether files are
|
||||
* source or binary.
|
||||
*/
|
||||
public class UniversalPreferencePage
|
||||
extends FieldEditorPreferencePage
|
||||
implements IWorkbenchPreferencePage, Listener, IPropertyListener
|
||||
{
|
||||
|
||||
|
||||
|
||||
protected Label resourceTypeLabel;
|
||||
protected Table resourceTypeTable;
|
||||
protected Button addResourceTypeButton;
|
||||
protected Button removeResourceTypeButton;
|
||||
protected Button binaryButton;
|
||||
protected Button textButton;
|
||||
protected Button doSuperTransferButton;
|
||||
|
||||
protected Button defaultBinaryButton;
|
||||
protected Button defaultTextButton;
|
||||
|
||||
protected SystemFileTransferModeRegistry modeRegistry;
|
||||
protected IEditorRegistry editorRegistry;
|
||||
|
||||
protected ArrayList modeMappings;
|
||||
protected ArrayList editorMappings;
|
||||
protected ArrayList imagesToDispose;
|
||||
|
||||
protected Combo archiveTypeCombo;
|
||||
protected Combo defaultArchiveTypeCombo;
|
||||
|
||||
protected Text downloadBufferSize;
|
||||
protected Text uploadBufferSize;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public UniversalPreferencePage() {
|
||||
super(GRID);
|
||||
setPreferenceStore(SystemPlugin.getDefault().getPreferenceStore());
|
||||
setDescription(FileResources.RESID_PREF_UNIVERSAL_FILES_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jface.preference.PreferencePage#createControl(Composite)
|
||||
*/
|
||||
public void createControl(Composite parent) {
|
||||
// added for 1GEUGE6: ITPJUI:WIN2000 - Help is the same on all preference pages
|
||||
super.createControl(parent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void createFieldEditors() {
|
||||
|
||||
modeRegistry = (SystemFileTransferModeRegistry)(SystemFileTransferModeRegistry.getDefault());
|
||||
editorRegistry = (IEditorRegistry)(SystemPlugin.getDefault().getWorkbench().getEditorRegistry());
|
||||
|
||||
modeMappings = new ArrayList();
|
||||
editorMappings = new ArrayList();
|
||||
imagesToDispose = new ArrayList();
|
||||
|
||||
Composite parent = getFieldEditorParent();
|
||||
|
||||
|
||||
|
||||
// define container and its layout
|
||||
Composite pageComponent = new Composite(parent, SWT.NULL);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 2;
|
||||
pageComponent.setLayout(layout);
|
||||
GridData data = new GridData();
|
||||
data.verticalAlignment = GridData.FILL;
|
||||
data.horizontalAlignment = GridData.FILL;
|
||||
pageComponent.setLayoutData(data);
|
||||
|
||||
// file types label
|
||||
resourceTypeLabel = new Label(pageComponent, SWT.LEFT);
|
||||
resourceTypeLabel.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_TYPE_LABEL);
|
||||
resourceTypeLabel.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_TYPE_TOOLTIP);
|
||||
data = new GridData();
|
||||
data.horizontalAlignment = GridData.FILL;
|
||||
data.horizontalSpan = 2;
|
||||
resourceTypeLabel.setLayoutData(data);
|
||||
|
||||
// file types table
|
||||
resourceTypeTable = new Table(pageComponent, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION);
|
||||
resourceTypeTable.addListener(SWT.Selection, this);
|
||||
resourceTypeTable.addListener(SWT.DefaultSelection, this);
|
||||
data = new GridData(GridData.FILL_BOTH);
|
||||
data.heightHint = resourceTypeTable.getItemHeight() * 12;
|
||||
data.widthHint = 200;
|
||||
data.grabExcessHorizontalSpace = true;
|
||||
resourceTypeTable.setLayoutData(data);
|
||||
|
||||
// container for buttons
|
||||
Composite groupComponent= new Composite(pageComponent, SWT.NULL);
|
||||
groupComponent.setLayout(new GridLayout());
|
||||
data = new GridData();
|
||||
data.verticalAlignment = GridData.FILL;
|
||||
data.horizontalAlignment = GridData.FILL;
|
||||
groupComponent.setLayoutData(data);
|
||||
|
||||
// add button
|
||||
addResourceTypeButton = new Button(groupComponent, SWT.PUSH);
|
||||
addResourceTypeButton.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_ADDBUTTON_LABEL);
|
||||
addResourceTypeButton.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_ADDBUTTON_TOOLTIP);
|
||||
addResourceTypeButton.addListener(SWT.Selection, this);
|
||||
data = new GridData();
|
||||
data.horizontalAlignment = GridData.FILL;
|
||||
data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
|
||||
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
|
||||
data.widthHint = Math.max(widthHint, addResourceTypeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
|
||||
addResourceTypeButton.setLayoutData(data);
|
||||
|
||||
// remove button
|
||||
removeResourceTypeButton = new Button(groupComponent, SWT.PUSH);
|
||||
removeResourceTypeButton.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_REMOVEBUTTON_LABEL);
|
||||
removeResourceTypeButton.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_REMOVEBUTTON_TOOLTIP);
|
||||
removeResourceTypeButton.addListener(SWT.Selection, this);
|
||||
data = new GridData();
|
||||
data.horizontalAlignment = GridData.FILL;
|
||||
data.heightHint = convertVerticalDLUsToPixels(IDialogConstants.BUTTON_HEIGHT);
|
||||
widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
|
||||
data.widthHint = Math.max(widthHint, removeResourceTypeButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
|
||||
removeResourceTypeButton.setLayoutData(data);
|
||||
|
||||
|
||||
// transfer mode
|
||||
Group modeGroup = new Group(groupComponent, SWT.SHADOW_ETCHED_IN);
|
||||
modeGroup.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_LABEL);
|
||||
modeGroup.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TOOLTIP);
|
||||
|
||||
layout = new GridLayout();
|
||||
layout.numColumns = 1;
|
||||
//layout.verticalSpacing = 10;
|
||||
layout.horizontalSpacing = 10;
|
||||
modeGroup.setLayout(layout);
|
||||
data = new GridData(GridData.FILL_BOTH);
|
||||
data.horizontalSpan = 2;
|
||||
data.widthHint = 100;
|
||||
data.grabExcessHorizontalSpace = true;
|
||||
modeGroup.setLayoutData(data);
|
||||
|
||||
// add the binary radio button
|
||||
binaryButton = new Button(modeGroup, SWT.RADIO);
|
||||
binaryButton.addListener(SWT.Selection, this);
|
||||
binaryButton.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL);
|
||||
binaryButton.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_TOOLTIP);
|
||||
|
||||
// add the text radio button
|
||||
textButton = new Button(modeGroup, SWT.RADIO);
|
||||
textButton.addListener(SWT.Selection, this);
|
||||
textButton.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL);
|
||||
textButton.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_TOOLTIP);
|
||||
|
||||
|
||||
// default file transfer mode
|
||||
Group defaultModeGroup = new Group(groupComponent, SWT.SHADOW_ETCHED_IN);
|
||||
defaultModeGroup.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_LABEL);
|
||||
defaultModeGroup.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_DEFAULT_MODE_TOOLTIP);
|
||||
|
||||
layout = new GridLayout();
|
||||
layout.numColumns = 1;
|
||||
//layout.verticalSpacing = 10;
|
||||
layout.horizontalSpacing = 10;
|
||||
defaultModeGroup.setLayout(layout);
|
||||
data = new GridData(GridData.FILL_BOTH);
|
||||
data.horizontalSpan = 2;
|
||||
data.widthHint = 100;
|
||||
data.grabExcessHorizontalSpace = true;
|
||||
defaultModeGroup.setLayoutData(data);
|
||||
|
||||
// add the binary radio button
|
||||
defaultBinaryButton = new Button(defaultModeGroup, SWT.RADIO);
|
||||
defaultBinaryButton.addListener(SWT.Selection, this);
|
||||
defaultBinaryButton.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_LABEL);
|
||||
defaultBinaryButton.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_BINARY_TOOLTIP);
|
||||
|
||||
// add the text radio button
|
||||
defaultTextButton = new Button(defaultModeGroup, SWT.RADIO);
|
||||
defaultTextButton.addListener(SWT.Selection, this);
|
||||
defaultTextButton.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_LABEL);
|
||||
defaultTextButton.setToolTipText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_MODE_TEXT_TOOLTIP);
|
||||
|
||||
|
||||
|
||||
// Add the boolean field editor for users to choose whether
|
||||
// hidden files should be displayed
|
||||
BooleanFieldEditor showHiddenEditor = new BooleanFieldEditor(
|
||||
ISystemPreferencesConstants.SHOWHIDDEN,
|
||||
FileResources.RESID_PREF_UNIVERSAL_SHOWHIDDEN_LABEL,
|
||||
groupComponent);
|
||||
|
||||
addField(showHiddenEditor);
|
||||
|
||||
IPreferenceStore store= SystemPlugin.getDefault().getPreferenceStore();
|
||||
|
||||
// download and upload buffer size
|
||||
|
||||
Group transferGroup = new Group(parent, SWT.NULL);
|
||||
transferGroup.setText(FileResources.RESID_FILES_PREFERENCES_BUFFER);
|
||||
|
||||
GridLayout tlayout = new GridLayout();
|
||||
tlayout.numColumns = 4;
|
||||
transferGroup.setLayout(tlayout);
|
||||
transferGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
Label downloadBufferLabel = new Label(transferGroup, SWT.NULL);
|
||||
downloadBufferLabel.setText(FileResources.RESID_FILES_PREFERENCES_DOWNLOAD_BUFFER_SIZE_LABEL);
|
||||
downloadBufferLabel.setToolTipText(FileResources.RESID_FILES_PREFERENCES_DOWNLOAD_BUFFER_SIZE_TOOLTIP);
|
||||
|
||||
downloadBufferSize = SystemWidgetHelpers.createTextField(transferGroup, this);
|
||||
GridData tgd = new GridData();
|
||||
tgd.widthHint = 75;
|
||||
downloadBufferSize.setLayoutData(tgd);
|
||||
downloadBufferSize.setTextLimit(10);
|
||||
downloadBufferSize.setText(getDownloadBufferSize() + "");
|
||||
downloadBufferSize.addVerifyListener(new VerifyListener()
|
||||
{
|
||||
public void verifyText(VerifyEvent e)
|
||||
{
|
||||
e.doit = true;
|
||||
for (int loop = 0; loop < e.text.length(); loop++)
|
||||
{
|
||||
if (!Character.isDigit(e.text.charAt(loop)))
|
||||
e.doit = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Label uploadBufferLabel = new Label(transferGroup, SWT.NULL);
|
||||
uploadBufferLabel.setText(FileResources.RESID_FILES_PREFERENCES_UPLOAD_BUFFER_SIZE_LABEL);
|
||||
uploadBufferLabel.setToolTipText(FileResources.RESID_FILES_PREFERENCES_UPLOAD_BUFFER_SIZE_TOOLTIP);
|
||||
uploadBufferSize = SystemWidgetHelpers.createTextField(transferGroup, this);
|
||||
tgd = new GridData();
|
||||
tgd.widthHint = 75;
|
||||
uploadBufferSize.setLayoutData(tgd);
|
||||
uploadBufferSize.setTextLimit(10);
|
||||
uploadBufferSize.setText(getUploadBufferSize() +"");
|
||||
uploadBufferSize.addVerifyListener(new VerifyListener()
|
||||
{
|
||||
public void verifyText(VerifyEvent e)
|
||||
{
|
||||
e.doit = true;
|
||||
for (int loop = 0; loop < e.text.length(); loop++)
|
||||
{
|
||||
if (!Character.isDigit(e.text.charAt(loop)))
|
||||
{
|
||||
e.doit = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// archive transfer
|
||||
Composite archiveGroup = new Composite(parent, SWT.NULL);
|
||||
GridLayout alayout = new GridLayout();
|
||||
alayout.numColumns = 2;
|
||||
archiveGroup.setLayout(alayout);
|
||||
archiveGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
|
||||
|
||||
|
||||
doSuperTransferButton = SystemWidgetHelpers.createCheckBox(archiveGroup, FileResources.RESID_SUPERTRANSFER_PREFS_ENABLE, this);
|
||||
GridData cdata = new GridData();
|
||||
cdata.horizontalSpan = 2;
|
||||
doSuperTransferButton.setLayoutData(cdata);
|
||||
|
||||
archiveTypeCombo = SystemWidgetHelpers.createLabeledReadonlyCombo(archiveGroup, null, FileResources.RESID_SUPERTRANSFER_PREFS_TYPE_LABEL, FileResources.RESID_SUPERTRANSFER_PREFS_TYPE_TOOLTIP);
|
||||
archiveTypeCombo.setItems(ArchiveHandlerManager.getInstance().getRegisteredExtensions());
|
||||
|
||||
boolean doSuperTransfer = getDoSuperTransfer();
|
||||
doSuperTransferButton.setSelection(doSuperTransfer);
|
||||
|
||||
String initialArchiveType = store.getString(ISystemPreferencesConstants.SUPERTRANSFER_ARC_TYPE);
|
||||
if (initialArchiveType == null ||
|
||||
!ArchiveHandlerManager.getInstance().isRegisteredArchive("test." + initialArchiveType))
|
||||
{
|
||||
initialArchiveType = ISystemPreferencesConstants.DEFAULT_SUPERTRANSFER_ARCHIVE_TYPE;
|
||||
}
|
||||
archiveTypeCombo.setText(initialArchiveType);
|
||||
archiveTypeCombo.setTextLimit(6);
|
||||
archiveTypeCombo.addModifyListener(new ModifyListener() {
|
||||
|
||||
public void modifyText(ModifyEvent e)
|
||||
{
|
||||
setSuperTransferTypePreference(archiveTypeCombo.getText());
|
||||
}
|
||||
});
|
||||
|
||||
archiveTypeCombo.setEnabled(doSuperTransfer);
|
||||
|
||||
|
||||
|
||||
|
||||
fillResourceTypeTable();
|
||||
|
||||
if (resourceTypeTable.getItemCount() > 0) {
|
||||
resourceTypeTable.setSelection(0);
|
||||
resourceTypeTable.setFocus();
|
||||
}
|
||||
|
||||
fillMode();
|
||||
updateEnabledState();
|
||||
|
||||
(new Mnemonics()).setOnPreferencePage(true).setMnemonics(parent);
|
||||
SystemWidgetHelpers.setCompositeHelp(parent, SystemPlugin.HELPPREFIX+"ufpf0000");
|
||||
|
||||
}
|
||||
|
||||
public void init(IWorkbench workbench)
|
||||
{
|
||||
}
|
||||
|
||||
public static void initDefaults(IPreferenceStore store)
|
||||
{
|
||||
store.setDefault(ISystemPreferencesConstants.SHOWHIDDEN, false);
|
||||
store.setDefault(ISystemPreferencesConstants.DOSUPERTRANSFER, ISystemPreferencesConstants.DEFAULT_DOSUPERTRANSFER);
|
||||
store.setDefault(ISystemPreferencesConstants.SUPERTRANSFER_ARC_TYPE, ISystemPreferencesConstants.DEFAULT_SUPERTRANSFER_ARCHIVE_TYPE);
|
||||
store.setDefault(ISystemPreferencesConstants.DOWNLOAD_BUFFER_SIZE, ISystemPreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE);
|
||||
store.setDefault(ISystemPreferencesConstants.UPLOAD_BUFFER_SIZE, ISystemPreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fill the resource type table
|
||||
*/
|
||||
protected void fillResourceTypeTable() {
|
||||
|
||||
// Setup the columns (icon, type)
|
||||
TableLayout tableLayout = new TableLayout();
|
||||
resourceTypeTable.setLayout(tableLayout);
|
||||
resourceTypeTable.setHeaderVisible(true);
|
||||
|
||||
ColumnLayoutData layoutData = new ColumnPixelData(20, false);
|
||||
tableLayout.addColumnData(layoutData);
|
||||
TableColumn tableCol = new TableColumn(resourceTypeTable, SWT.NONE);
|
||||
tableCol.setResizable(false);
|
||||
tableCol.setText("");
|
||||
|
||||
layoutData = new ColumnWeightData(40, false);
|
||||
tableLayout.addColumnData(layoutData);
|
||||
tableCol = new TableColumn(resourceTypeTable, SWT.NONE);
|
||||
tableCol.setResizable(false);
|
||||
tableCol.setText(FileResources.RESID_PREF_UNIVERSAL_FILES_FILETYPES_TABLECOL_LABEL);
|
||||
|
||||
IFileEditorMapping[] mappingArray = editorRegistry.getFileEditorMappings();
|
||||
|
||||
for (int i = 0; i < mappingArray.length; i++) {
|
||||
newResourceTableItem(mappingArray[i], i, false);
|
||||
}
|
||||
|
||||
int defaultFileTransferMode = getFileTransferModeDefaultPreference();
|
||||
if (defaultFileTransferMode == ISystemPreferencesConstants.FILETRANSFERMODE_BINARY)
|
||||
{
|
||||
defaultBinaryButton.setSelection(true);
|
||||
}
|
||||
else if (defaultFileTransferMode == ISystemPreferencesConstants.FILETRANSFERMODE_TEXT)
|
||||
{
|
||||
defaultTextButton.setSelection(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used during reset defaults
|
||||
*/
|
||||
protected void resetResourceTypeTable()
|
||||
{
|
||||
//clear table and reload defaults
|
||||
editorMappings.clear();
|
||||
modeMappings.clear();
|
||||
resourceTypeTable.setRedraw(false);
|
||||
resourceTypeTable.removeAll();
|
||||
|
||||
|
||||
IFileEditorMapping[] mappingArray = editorRegistry.getFileEditorMappings();
|
||||
for (int i = 0; i < mappingArray.length; i++)
|
||||
{
|
||||
newResourceTableItem(mappingArray[i], i, false);
|
||||
}
|
||||
resourceTypeTable.setRedraw(true);
|
||||
|
||||
int defaultFileTransferMode = getFileTransferModeDefaultPreference();
|
||||
defaultBinaryButton.setSelection(defaultFileTransferMode == ISystemPreferencesConstants.FILETRANSFERMODE_BINARY);
|
||||
defaultTextButton.setSelection(defaultFileTransferMode == ISystemPreferencesConstants.FILETRANSFERMODE_TEXT);
|
||||
|
||||
if (resourceTypeTable.getItemCount() > 0)
|
||||
{
|
||||
resourceTypeTable.setSelection(0);
|
||||
resourceTypeTable.setFocus();
|
||||
}
|
||||
|
||||
fillMode();
|
||||
updateEnabledState();
|
||||
}
|
||||
|
||||
protected void resetSuperTransferPrefs()
|
||||
{
|
||||
archiveTypeCombo.setText(ISystemPreferencesConstants.DEFAULT_SUPERTRANSFER_ARCHIVE_TYPE);
|
||||
setSuperTransferTypePreference(ISystemPreferencesConstants.DEFAULT_SUPERTRANSFER_ARCHIVE_TYPE);
|
||||
doSuperTransferButton.setSelection(ISystemPreferencesConstants.DEFAULT_DOSUPERTRANSFER);
|
||||
setDoSuperTransfer(ISystemPreferencesConstants.DEFAULT_DOSUPERTRANSFER);
|
||||
}
|
||||
|
||||
protected void resetBufferSizePrefs()
|
||||
{
|
||||
downloadBufferSize.setText(ISystemPreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE + "");
|
||||
uploadBufferSize.setText(ISystemPreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE + "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new <code>TableItem</code> to represent the resource
|
||||
* type editor description supplied.
|
||||
*/
|
||||
protected TableItem newResourceTableItem(IFileEditorMapping mapping, int index, boolean selected) {
|
||||
|
||||
editorMappings.add(index, ((FileEditorMapping)mapping).clone());
|
||||
modeMappings.add(index, modeRegistry.getMapping(mapping).clone());
|
||||
|
||||
Image image = mapping.getImageDescriptor().createImage(false);
|
||||
|
||||
if (image != null)
|
||||
imagesToDispose.add(image);
|
||||
|
||||
TableItem item = new TableItem(resourceTypeTable, SWT.NULL, index);
|
||||
item.setImage(0, image);
|
||||
item.setText(1, mapping.getLabel());
|
||||
|
||||
if (selected)
|
||||
resourceTypeTable.setSelection(index);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The preference page is going to be disposed. So deallocate all allocated
|
||||
* SWT resources that aren't disposed automatically by disposing the page
|
||||
* (i.e. fonts, cursors, etc). Subclasses should reimplement this method to
|
||||
* release their own allocated SWT resources.
|
||||
*/
|
||||
public void dispose() {
|
||||
|
||||
super.dispose();
|
||||
|
||||
if(imagesToDispose != null) {
|
||||
|
||||
for (Iterator e = imagesToDispose.iterator(); e.hasNext();) {
|
||||
((Image)e.next()).dispose();
|
||||
}
|
||||
|
||||
imagesToDispose = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see Listener#handleEvent(Event)
|
||||
*/
|
||||
public void handleEvent(Event event) {
|
||||
|
||||
if ((event.widget == resourceTypeTable) && ((event.type == SWT.Selection) || (event.type == SWT.DefaultSelection))) {
|
||||
fillMode();
|
||||
}
|
||||
if ((event.widget == addResourceTypeButton) && (event.type == SWT.Selection)) {
|
||||
promptForResourceType();
|
||||
}
|
||||
else if ((event.widget == removeResourceTypeButton) && (event.type == SWT.Selection)) {
|
||||
removeSelectedResourceType();
|
||||
}
|
||||
else if ((event.widget == binaryButton) && (event.type == SWT.Selection)) {
|
||||
binaryButtonSelected();
|
||||
}
|
||||
else if ((event.widget == textButton) && (event.type == SWT.Selection)) {
|
||||
textButtonSelected();
|
||||
}
|
||||
else if ((event.widget == doSuperTransferButton) && (event.type == SWT.Selection))
|
||||
{
|
||||
doSuperTransferButtonSelected();
|
||||
}
|
||||
updateEnabledState();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fill the mode widgets
|
||||
*/
|
||||
public void fillMode() {
|
||||
|
||||
int index = resourceTypeTable.getSelectionIndex();
|
||||
SystemFileTransferModeMapping modeMapping = getModeMapping(index);
|
||||
|
||||
if (modeMapping !=null)
|
||||
{
|
||||
if (modeMapping.isBinary()) {
|
||||
binaryButton.setSelection(true);
|
||||
textButton.setSelection(false);
|
||||
}
|
||||
else {
|
||||
binaryButton.setSelection(false);
|
||||
textButton.setSelection(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prompt for file type
|
||||
*/
|
||||
public void promptForResourceType() {
|
||||
|
||||
FileExtensionDialog dialog = new FileExtensionDialog(getControl().getShell());
|
||||
|
||||
if (dialog.open() == Window.OK) {
|
||||
|
||||
String name = dialog.getName();
|
||||
String extension = dialog.getExtension();
|
||||
|
||||
if (extension.length() > 0) {
|
||||
addResourceType(name, extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the type from the table
|
||||
*/
|
||||
public void removeSelectedResourceType() {
|
||||
|
||||
int index = resourceTypeTable.getSelectionIndex();
|
||||
|
||||
editorMappings.remove(index);
|
||||
modeMappings.remove(index);
|
||||
|
||||
TableItem[] items = resourceTypeTable.getSelection();
|
||||
|
||||
if (items.length > 0) {
|
||||
items[0].dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new resource type to the collection shown in the top of the page.
|
||||
* This is typically called after the extension dialog is shown to the user.
|
||||
*/
|
||||
public void addResourceType(String newName, String newExtension) {
|
||||
|
||||
// no extension is provided
|
||||
if (newExtension == null || newExtension.length() < 1) {
|
||||
// Note by DWD - this path is never taken because the dialog that gathers resource types checks for this condition
|
||||
SystemMessageFile mf = SystemPlugin.getPluginMessageFile();
|
||||
Shell shell = getControl().getShell();
|
||||
SystemMessage message = mf.getMessage(ISystemMessages.MSG_ERROR_EXTENSION_EMPTY);
|
||||
SystemMessageDialog.displayErrorMessage(shell, message);
|
||||
// Removed by DWD - 2004-07-28 - these two messages don't exist
|
||||
// MessageDialog.openInformation(getControl().getShell(),
|
||||
// GenericMessages.getString("FileEditorPreference.extensionEmptyTitle"),
|
||||
// GenericMessages.getString("FileEditorPreference.extensionEmptyMessage"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newName == null || newName.length() < 1)
|
||||
newName = "*";
|
||||
else {
|
||||
|
||||
int index = newName.indexOf('*');
|
||||
|
||||
if (index > -1) {
|
||||
|
||||
// if the name is more than one character, and it has a '*' in it
|
||||
if (!(index == 0 && newName.length() == 1)) {
|
||||
// Note by DWD - this path is never taken because the dialog that gathers resource types checks for this condition.
|
||||
SystemMessageFile mf = SystemPlugin.getPluginMessageFile();
|
||||
Shell shell = getControl().getShell();
|
||||
SystemMessage message = mf.getMessage(ISystemMessages.MSG_ERROR_FILENAME_INVALID);
|
||||
SystemMessageDialog.displayErrorMessage(shell, message);
|
||||
// removed by DWD - 2004-07-28 - these two messages don't exist
|
||||
// MessageDialog.openInformation(getControl().getShell(),
|
||||
// GenericMessages.getString("FileEditorPreference.fileNameInvalidTitle"),
|
||||
// GenericMessages.getString("FileEditorPreference.fileNameInvalidMessage"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Find the index at which to insert the new entry.
|
||||
String newFilename = (newName + "." + newExtension).toUpperCase();
|
||||
IFileEditorMapping resourceType;
|
||||
boolean found = false;
|
||||
int i = 0;
|
||||
|
||||
while (i < editorMappings.size() && !found) {
|
||||
|
||||
resourceType = (FileEditorMapping)(editorMappings.get(i));
|
||||
|
||||
int result = newFilename.compareTo(resourceType.getLabel().toUpperCase());
|
||||
|
||||
// if the type already exists
|
||||
if (result == 0) {
|
||||
|
||||
MessageDialog.openInformation(getControl().getShell(),
|
||||
// TODO: Cannot use WorkbenchMessages -- it's internal
|
||||
FileResources.FileEditorPreference_existsTitle,
|
||||
// TODO: Cannot use WorkbenchMessages -- it's internal
|
||||
FileResources.FileEditorPreference_existsMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result < 0)
|
||||
found = true;
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
||||
// Create the new type and insert it
|
||||
resourceType = new FileEditorMapping(newName, newExtension);
|
||||
newResourceTableItem(resourceType, i, true);
|
||||
resourceTypeTable.setFocus();
|
||||
fillMode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to configure things when binary mode radio button
|
||||
* is selected
|
||||
*/
|
||||
private void binaryButtonSelected() {
|
||||
//binaryButton.setSelection(true); // causes hang on linux
|
||||
//textButton.setSelection(false);
|
||||
|
||||
int index = resourceTypeTable.getSelectionIndex();
|
||||
SystemFileTransferModeMapping modeMapping = getModeMapping(index);
|
||||
if (modeMapping != null)
|
||||
modeMapping.setAsBinary();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to configure things when text mode is selected
|
||||
*/
|
||||
private void textButtonSelected() {
|
||||
// textButton.setSelection(true); // causes hang on linux
|
||||
// binaryButton.setSelection(false);
|
||||
|
||||
int index = resourceTypeTable.getSelectionIndex();
|
||||
SystemFileTransferModeMapping modeMapping = getModeMapping(index);
|
||||
if (modeMapping != null)
|
||||
modeMapping.setAsText();
|
||||
}
|
||||
|
||||
private void doSuperTransferButtonSelected()
|
||||
{
|
||||
if (doSuperTransferButton.getSelection())
|
||||
{
|
||||
archiveTypeCombo.setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
archiveTypeCombo.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mode mapping given the editor mapping selected
|
||||
*/
|
||||
private SystemFileTransferModeMapping getModeMapping(int index) {
|
||||
|
||||
if (index >=0 && index < modeMappings.size())
|
||||
return (SystemFileTransferModeMapping)(modeMappings.get(index));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update enabled state of buttons
|
||||
*/
|
||||
public void updateEnabledState() {
|
||||
|
||||
boolean resourceTypeSelected = resourceTypeTable.getSelectionIndex() != -1;
|
||||
removeResourceTypeButton.setEnabled(resourceTypeSelected);
|
||||
}
|
||||
|
||||
|
||||
protected void performDefaults()
|
||||
{
|
||||
super.performDefaults();
|
||||
resetResourceTypeTable();
|
||||
|
||||
resetSuperTransferPrefs();
|
||||
resetBufferSizePrefs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stuff to do when ok is pressed
|
||||
*/
|
||||
public boolean performOk() {
|
||||
|
||||
super.performOk();
|
||||
|
||||
// first save the transfer mode registry
|
||||
Object[] array1 = modeMappings.toArray();
|
||||
SystemFileTransferModeMapping[] mappingArray1 = new SystemFileTransferModeMapping[array1.length];
|
||||
|
||||
for (int i = 0; i < array1.length; i++) {
|
||||
mappingArray1[i] = (SystemFileTransferModeMapping)(array1[i]);
|
||||
}
|
||||
|
||||
modeRegistry.setModeMappings(mappingArray1);
|
||||
modeRegistry.saveAssociations();
|
||||
|
||||
// then save the editor registry
|
||||
Object[] array2 = editorMappings.toArray();
|
||||
FileEditorMapping[] mappingArray2 = new FileEditorMapping[array2.length];
|
||||
|
||||
for (int j = 0; j < array2.length; j++) {
|
||||
mappingArray2[j] = (FileEditorMapping)(array2[j]);
|
||||
}
|
||||
|
||||
((EditorRegistry)editorRegistry).setFileEditorMappings(mappingArray2);
|
||||
((EditorRegistry)editorRegistry).saveAssociations();
|
||||
|
||||
// editorRegistry.removePropertyListener(this);
|
||||
int defaultFileTransferMode = ISystemPreferencesConstants.FILETRANSFERMODE_BINARY;
|
||||
if (defaultBinaryButton.getSelection())
|
||||
{
|
||||
defaultFileTransferMode = ISystemPreferencesConstants.FILETRANSFERMODE_BINARY;
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultFileTransferMode = ISystemPreferencesConstants.FILETRANSFERMODE_TEXT;
|
||||
}
|
||||
setFileTransferModeDefaultPreference(defaultFileTransferMode);
|
||||
setDoSuperTransfer(doSuperTransferButton.getSelection());
|
||||
setSuperTransferTypePreference(archiveTypeCombo.getText());
|
||||
setDownloadBufferSize(downloadBufferSize.getText());
|
||||
setUploadBufferSize(uploadBufferSize.getText());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether to automatically detect, use binary or text during file transfer
|
||||
* for unspecified file types
|
||||
*/
|
||||
public static int getFileTransferModeDefaultPreference()
|
||||
{
|
||||
IPreferenceStore store= SystemPlugin.getDefault().getPreferenceStore();
|
||||
return store.getInt(ISystemPreferencesConstants.FILETRANSFERMODEDEFAULT);
|
||||
}
|
||||
/**
|
||||
* Set the default file transfer mode to use for unspecified file types
|
||||
*/
|
||||
public static void setFileTransferModeDefaultPreference(int defaultMode)
|
||||
{
|
||||
IPreferenceStore store= SystemPlugin.getDefault().getPreferenceStore();
|
||||
store.setValue(ISystemPreferencesConstants.FILETRANSFERMODEDEFAULT,defaultMode);
|
||||
savePreferenceStore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether to compress directories before transferring them over the network
|
||||
*/
|
||||
public static String getSuperTransferTypePreference()
|
||||
{
|
||||
IPreferenceStore store= SystemPlugin.getDefault().getPreferenceStore();
|
||||
return store.getString(ISystemPreferencesConstants.SUPERTRANSFER_ARC_TYPE);
|
||||
}
|
||||
/**
|
||||
* Set the default as to whether or not to compress directories before remote transfer
|
||||
*/
|
||||
public static void setSuperTransferTypePreference(String type)
|
||||
{
|
||||
IPreferenceStore store= SystemPlugin.getDefault().getPreferenceStore();
|
||||
store.setValue(ISystemPreferencesConstants.SUPERTRANSFER_ARC_TYPE,type);
|
||||
savePreferenceStore();
|
||||
}
|
||||
|
||||
public static boolean getDoSuperTransfer()
|
||||
{
|
||||
IPreferenceStore store= SystemPlugin.getDefault().getPreferenceStore();
|
||||
return store.getBoolean(ISystemPreferencesConstants.DOSUPERTRANSFER);
|
||||
}
|
||||
|
||||
public static int getDownloadBufferSize()
|
||||
{
|
||||
IPreferenceStore store= SystemPlugin.getDefault().getPreferenceStore();
|
||||
int result = store.getInt(ISystemPreferencesConstants.DOWNLOAD_BUFFER_SIZE);
|
||||
if (result == 0)
|
||||
{
|
||||
result = ISystemPreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int getUploadBufferSize()
|
||||
{
|
||||
IPreferenceStore store= SystemPlugin.getDefault().getPreferenceStore();
|
||||
int result = store.getInt(ISystemPreferencesConstants.UPLOAD_BUFFER_SIZE);
|
||||
if (result == 0)
|
||||
{
|
||||
result = ISystemPreferencesConstants.DEFAULT_DOWNLOAD_BUFFER_SIZE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void setDoSuperTransfer(boolean flag)
|
||||
{
|
||||
IPreferenceStore store= SystemPlugin.getDefault().getPreferenceStore();
|
||||
store.setValue(ISystemPreferencesConstants.DOSUPERTRANSFER,flag);
|
||||
savePreferenceStore();
|
||||
}
|
||||
|
||||
public static void setDownloadBufferSize(String size)
|
||||
{
|
||||
setDownloadBufferSize(Integer.parseInt(size));
|
||||
}
|
||||
|
||||
public static void setUploadBufferSize(String size)
|
||||
{
|
||||
setUploadBufferSize(Integer.parseInt(size));
|
||||
}
|
||||
|
||||
public static void setDownloadBufferSize(int size)
|
||||
{
|
||||
if (size > 0)
|
||||
{
|
||||
IPreferenceStore store = SystemPlugin.getDefault().getPreferenceStore();
|
||||
store.setValue(ISystemPreferencesConstants.DOWNLOAD_BUFFER_SIZE, size);
|
||||
savePreferenceStore();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setUploadBufferSize(int size)
|
||||
{
|
||||
if (size > 0)
|
||||
{
|
||||
IPreferenceStore store = SystemPlugin.getDefault().getPreferenceStore();
|
||||
store.setValue(ISystemPreferencesConstants.UPLOAD_BUFFER_SIZE, size);
|
||||
savePreferenceStore();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the preference store
|
||||
*/
|
||||
private static void savePreferenceStore()
|
||||
{
|
||||
/* DY: This was causing ClassCastException in 2.0
|
||||
* getPreferenceStore retutrns CompatibilityPreferenceStore now
|
||||
PreferenceStore store = (PreferenceStore)SystemPlugin.getDefault().getPreferenceStore();
|
||||
try {
|
||||
store.save();
|
||||
} catch (Exception exc)
|
||||
{
|
||||
System.out.println("Error saving preferences: " + exc.getMessage() + ": " + exc.getClass().getName());
|
||||
}
|
||||
*/
|
||||
// ok, a couple hours of research leads me to believe this is now the new
|
||||
// thing to do... phil
|
||||
SystemPlugin.getDefault().savePluginPreferences();
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen for changes to the Editor Registry content.
|
||||
* Update our registry by changing the hashmap and saving the new
|
||||
* mappings on disk.
|
||||
* @see IPropertyListener#propertyChanged(Object, int)
|
||||
*/
|
||||
public void propertyChanged(Object source, int propId) {
|
||||
|
||||
if ((source instanceof IEditorRegistry) && (propId == IEditorRegistry.PROP_CONTENTS)) {
|
||||
|
||||
// the OK button was pressed, and we need to incorporate changes from the File Editors preference page
|
||||
IEditorRegistry registry = (IEditorRegistry)source;
|
||||
|
||||
IFileEditorMapping[] editorMappingArray = registry.getFileEditorMappings();
|
||||
|
||||
for (int i = 0; i < editorMappingArray.length; i++) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2004, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemSelectRemoteFileOrFolderForm;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* @author mjberger
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class AddToArchiveDialog extends CombineDialog {
|
||||
|
||||
private String[] _relativePaths;
|
||||
|
||||
public AddToArchiveDialog(Shell shell)
|
||||
{
|
||||
super(shell);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "atad0000");
|
||||
}
|
||||
|
||||
public AddToArchiveDialog(Shell shell, String title) {
|
||||
super(shell, title);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "atad0000");
|
||||
}
|
||||
|
||||
public AddToArchiveDialog(Shell shell, String title, String[] relativePaths)
|
||||
{
|
||||
super(shell, title);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "atad0000");
|
||||
_relativePaths = relativePaths;
|
||||
((AddToArchiveForm)form).setRelativePathList(_relativePaths);
|
||||
}
|
||||
|
||||
public AddToArchiveDialog(
|
||||
Shell shell,
|
||||
String title,
|
||||
boolean prePopSelection)
|
||||
{
|
||||
super(shell, title, prePopSelection);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "atad0000");
|
||||
}
|
||||
|
||||
public AddToArchiveDialog(
|
||||
Shell shell,
|
||||
String title,
|
||||
boolean prePopSelection,
|
||||
String[] relativePaths)
|
||||
{
|
||||
super(shell, title, prePopSelection);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "atad0000");
|
||||
_relativePaths = relativePaths;
|
||||
((AddToArchiveForm)form).setRelativePathList(_relativePaths);
|
||||
}
|
||||
|
||||
|
||||
protected SystemSelectRemoteFileOrFolderForm getForm(boolean fileMode)
|
||||
{
|
||||
super.getForm(fileMode);
|
||||
form = new AddToArchiveForm(getMessageLine(), this, fileMode, prePop, _relativePaths);
|
||||
return form;
|
||||
}
|
||||
|
||||
public boolean getSaveFullPathInfo()
|
||||
{
|
||||
return ((AddToArchiveForm)form).getSaveFullPathInfo();
|
||||
}
|
||||
|
||||
public String getRelativePath()
|
||||
{
|
||||
return ((AddToArchiveForm)form).getRelativePath();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2004, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* @author mjberger
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class AddToArchiveForm extends CombineForm
|
||||
{
|
||||
|
||||
protected Button savePathInfoCheckBox;
|
||||
protected Combo relativeToCombo;
|
||||
protected String[] _relativePathList = null;
|
||||
protected String relativePath = "";
|
||||
protected boolean saveFullPathInfo = false;
|
||||
|
||||
public AddToArchiveForm(
|
||||
ISystemMessageLine msgLine,
|
||||
Object caller,
|
||||
boolean fileMode)
|
||||
{
|
||||
super(msgLine, caller, fileMode);
|
||||
}
|
||||
|
||||
public AddToArchiveForm(
|
||||
ISystemMessageLine msgLine,
|
||||
Object caller,
|
||||
boolean fileMode,
|
||||
boolean prePopSelection)
|
||||
{
|
||||
super(msgLine, caller, fileMode, prePopSelection);
|
||||
}
|
||||
|
||||
public AddToArchiveForm(
|
||||
ISystemMessageLine msgLine,
|
||||
Object caller,
|
||||
boolean fileMode,
|
||||
boolean prePopSelection,
|
||||
String[] relativePaths)
|
||||
{
|
||||
super(msgLine, caller, fileMode, prePopSelection);
|
||||
_relativePathList = relativePaths;
|
||||
enableRelativePathFeature(relativePaths != null);
|
||||
}
|
||||
|
||||
public void setRelativePathList(String[] relativePathList)
|
||||
{
|
||||
if (relativePathList != null)
|
||||
{
|
||||
_relativePathList = relativePathList;
|
||||
if (relativeToCombo != null) relativeToCombo.setItems(relativePathList);
|
||||
enableRelativePathFeature(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
enableRelativePathFeature(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void enableRelativePathFeature(boolean enable)
|
||||
{
|
||||
if (relativeToCombo != null) relativeToCombo.setEnabled(enable);
|
||||
if (savePathInfoCheckBox != null) savePathInfoCheckBox.setEnabled(enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* In this method, we populate the given SWT container with widgets and return the container
|
||||
* to the caller.
|
||||
* @param parent The parent composite
|
||||
*/
|
||||
public Control createContents(Shell shell, Composite parent)
|
||||
{
|
||||
Control control = super.createContents(shell, parent);
|
||||
|
||||
Composite composite = SystemWidgetHelpers.createComposite(parent, 1);
|
||||
|
||||
savePathInfoCheckBox = SystemWidgetHelpers.createCheckBox(composite, null, FileResources.RESID_ADDTOARCHIVE_SAVEPATH_LABEL, FileResources.RESID_ADDTOARCHIVE_SAVEPATH_TOOLTIP);
|
||||
relativeToCombo = SystemWidgetHelpers.createLabeledReadonlyCombo(composite, null, FileResources.RESID_ADDTOARCHIVE_RELATIVETO_LABEL, FileResources.RESID_ADDTOARCHIVE_RELATIVETO_LABEL);
|
||||
|
||||
enableRelativePathFeature(_relativePathList != null);
|
||||
|
||||
if (_relativePathList != null)
|
||||
{
|
||||
relativeToCombo.setItems(_relativePathList);
|
||||
relativeToCombo.setEnabled(false);
|
||||
}
|
||||
|
||||
savePathInfoCheckBox.addSelectionListener(new SelectionListener() {
|
||||
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
setPageComplete();
|
||||
relativeToCombo.setEnabled(savePathInfoCheckBox.getSelection());
|
||||
if (!savePathInfoCheckBox.getSelection()) relativePath = "";
|
||||
setSaveFullPathInfo();
|
||||
}
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
setPageComplete();
|
||||
relativeToCombo.setEnabled(savePathInfoCheckBox.getSelection());
|
||||
if (!savePathInfoCheckBox.getSelection()) relativePath = "";
|
||||
setSaveFullPathInfo();
|
||||
}
|
||||
});
|
||||
|
||||
relativeToCombo.addModifyListener(new ModifyListener() {
|
||||
|
||||
public void modifyText(ModifyEvent e) {
|
||||
relativePath = relativeToCombo.getText();
|
||||
setPageComplete();
|
||||
}
|
||||
});
|
||||
|
||||
return control;
|
||||
}
|
||||
|
||||
public boolean isPageComplete()
|
||||
{
|
||||
boolean pathInfoChecked = (savePathInfoCheckBox != null && savePathInfoCheckBox.getSelection());
|
||||
boolean relPathSelectionMade = relativePath != null && !relativePath.equals("");
|
||||
boolean relPathComplete = savePathInfoCheckBox == null || !savePathInfoCheckBox.getEnabled();
|
||||
if (!relPathComplete)
|
||||
{
|
||||
if (pathInfoChecked)
|
||||
{
|
||||
relPathComplete = relPathSelectionMade;
|
||||
}
|
||||
else relPathComplete = true;
|
||||
}
|
||||
return super.isPageComplete() && relPathComplete;
|
||||
}
|
||||
|
||||
protected void setSaveFullPathInfo()
|
||||
{
|
||||
saveFullPathInfo = savePathInfoCheckBox != null &&
|
||||
savePathInfoCheckBox.getEnabled() &&
|
||||
savePathInfoCheckBox.getSelection();
|
||||
}
|
||||
|
||||
public String getRelativePath()
|
||||
{
|
||||
return relativePath;
|
||||
}
|
||||
|
||||
public boolean getSaveFullPathInfo()
|
||||
{
|
||||
return saveFullPathInfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2003, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemSelectRemoteFileOrFolderForm;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* A dialog to select or enter archive files.
|
||||
*/
|
||||
public class CombineDialog extends SystemSelectRemoteFileOrFolderDialog {
|
||||
|
||||
protected CombineForm form;
|
||||
protected boolean prePop = false;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param shell the parent shell.
|
||||
*/
|
||||
public CombineDialog(Shell shell)
|
||||
{
|
||||
super(shell, false);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "cmbd0000");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor when you want to supply your own title.
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param title The title to give the dialog
|
||||
*/
|
||||
public CombineDialog(Shell shell, String title)
|
||||
{
|
||||
super(shell, title, false);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "cmbd0000");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor when you want to supply your own title.
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param title The title to give the dialog
|
||||
* @param prePopSelection Whether or not the destination name
|
||||
* and type will be prepopulated with the selection, or given
|
||||
* a generic name and type.
|
||||
*/
|
||||
public CombineDialog(Shell shell, String title, boolean prePopSelection)
|
||||
{
|
||||
super(shell, title, false);
|
||||
prePop = prePopSelection;
|
||||
if (form != null) form.setPrePopSelection(prePop);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "cmbd0000");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor when you want to supply your own title.
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param title The title to give the dialog
|
||||
* @param prePopSelection Whether or not the destination name
|
||||
* and type will be prepopulated with the selection, or given
|
||||
* a generic name and type.
|
||||
* @param relativePaths The relative paths to be inserted as choices
|
||||
* in the relative path combo box. Null if you wish to disable this feature.
|
||||
*/
|
||||
public CombineDialog(Shell shell, String title, boolean prePopSelection, String[] relativePaths)
|
||||
{
|
||||
super(shell, title, false);
|
||||
prePop = prePopSelection;
|
||||
if (form != null) form.setPrePopSelection(prePop);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "cmbd0000");
|
||||
}
|
||||
|
||||
|
||||
protected SystemSelectRemoteFileOrFolderForm getForm(boolean fileMode)
|
||||
{
|
||||
form = new CombineForm(getMessageLine(), this, fileMode, prePop);
|
||||
super.getForm(fileMode);
|
||||
return form;
|
||||
}
|
||||
|
||||
public Object getOutputObject()
|
||||
{
|
||||
String fileName = form.getFileName();
|
||||
|
||||
IRemoteFile file = (IRemoteFile) super.getOutputObject();
|
||||
|
||||
// if a file was selected, get reference to its parent
|
||||
if (file.isFile()) {
|
||||
file = file.getParentRemoteFile();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// return a remote file that is the child of the parent folder
|
||||
return file.getParentRemoteFileSubSystem().getRemoteFileObject(file, fileName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setShowLocationPrompt(boolean show)
|
||||
{
|
||||
form.setShowLocationPrompt(show);
|
||||
}
|
||||
|
||||
public void setLocationPrompt(String prompt)
|
||||
{
|
||||
form.setLocationPrompt(prompt);
|
||||
}
|
||||
|
||||
public void setNameAndTypePrompt(String prompt)
|
||||
{
|
||||
form.setNameAndTypePrompt(prompt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the extensions to disallow.
|
||||
* @param extensions the archive extensions that will not be allowed.
|
||||
*/
|
||||
public void setDisallowedArchiveExtensions(String[] extensions) {
|
||||
form.setDisallowedArchiveExtensions(extensions);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,451 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2003, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.rse.core.SystemAdapterHelpers;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.FileResources;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemSelectRemoteFileOrFolderForm;
|
||||
import org.eclipse.rse.filters.ISystemFilter;
|
||||
import org.eclipse.rse.filters.SystemFilterSimple;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.model.ISystemRegistry;
|
||||
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration;
|
||||
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
||||
import org.eclipse.rse.ui.validators.ValidatorArchiveName;
|
||||
import org.eclipse.rse.ui.validators.ValidatorFileName;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
|
||||
/**
|
||||
* A dialog to select or enter archive files.
|
||||
*/
|
||||
public class CombineForm extends SystemSelectRemoteFileOrFolderForm
|
||||
{
|
||||
|
||||
protected Text fileNameText;
|
||||
protected Combo fileTypeCombo;
|
||||
protected Label nameAndTypeLabel;
|
||||
protected String fileName, fileType, initialFileName;
|
||||
protected ValidatorFileName validator;
|
||||
protected ValidatorArchiveName arcvalidator;
|
||||
protected boolean prePop;
|
||||
protected String nameAndTypePrompt = "";
|
||||
protected String[] disallowedExtensions;
|
||||
|
||||
/**
|
||||
* Constructor for ExtractToForm
|
||||
*/
|
||||
public CombineForm(ISystemMessageLine msgLine, Object caller, boolean fileMode)
|
||||
{
|
||||
super(msgLine, caller, fileMode);
|
||||
validator = new ValidatorFileName();
|
||||
arcvalidator = new ValidatorArchiveName();
|
||||
prePop = false;
|
||||
}
|
||||
|
||||
public CombineForm(ISystemMessageLine msgLine, Object caller, boolean fileMode, boolean prePopSelection)
|
||||
{
|
||||
super(msgLine, caller, fileMode);
|
||||
|
||||
validator = new ValidatorFileName();
|
||||
arcvalidator = new ValidatorArchiveName();
|
||||
prePop = prePopSelection;
|
||||
}
|
||||
|
||||
/**
|
||||
* In this method, we populate the given SWT container with widgets and return the container
|
||||
* to the caller.
|
||||
* @param parent The parent composite
|
||||
*/
|
||||
public Control createContents(Shell shell, Composite parent)
|
||||
{
|
||||
Control control = super.createContents(shell, parent);
|
||||
|
||||
Composite composite = SystemWidgetHelpers.createComposite(parent, 1);
|
||||
|
||||
nameAndTypeLabel = SystemWidgetHelpers.createLabel(composite, nameAndTypePrompt);
|
||||
Composite subcomp1 = SystemWidgetHelpers.createComposite(composite, 2);
|
||||
fileNameText = SystemWidgetHelpers.createLabeledTextField(
|
||||
subcomp1, null, FileResources.RESID_COMBINE_NAME_LABEL, FileResources.RESID_COMBINE_NAME_TOOLTIP);
|
||||
fileTypeCombo = SystemWidgetHelpers.createLabeledReadonlyCombo(subcomp1, null, FileResources.RESID_COMBINE_TYPE_LABEL, FileResources.RESID_COMBINE_TYPE_TOOLTIP);
|
||||
|
||||
String[] allowedExtensions = getAllowedArchiveExtensions();
|
||||
|
||||
if (allowedExtensions != null && allowedExtensions.length != 0) {
|
||||
fileTypeCombo.setItems(allowedExtensions);
|
||||
fileTypeCombo.select(0);
|
||||
fileType = fileTypeCombo.getText();
|
||||
}
|
||||
|
||||
fileNameText.addModifyListener(new ModifyListener() {
|
||||
|
||||
public void modifyText(ModifyEvent e) {
|
||||
fileName = fileNameText.getText();
|
||||
setPageComplete();
|
||||
if (fileName.indexOf(".") != -1)
|
||||
{
|
||||
SystemMessage isValidMsg = arcvalidator.validate(fileName);
|
||||
if (isValidMsg == null)
|
||||
{
|
||||
int i = fileName.lastIndexOf(".");
|
||||
fileType = fileName.substring(i+1);
|
||||
fileTypeCombo.setText(fileType);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
fileTypeCombo.addModifyListener(new ModifyListener() {
|
||||
|
||||
public void modifyText(ModifyEvent e) {
|
||||
fileType = fileTypeCombo.getText();
|
||||
setPageComplete();
|
||||
}
|
||||
});
|
||||
|
||||
if (fileName != null)
|
||||
{
|
||||
fileNameText.setText(fileName);
|
||||
}
|
||||
|
||||
return control;
|
||||
}
|
||||
|
||||
protected String[] getAllowedArchiveExtensions() {
|
||||
|
||||
String[] allExtensions = ArchiveHandlerManager.getInstance().getRegisteredExtensions();
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
for (int i = 0; i < allExtensions.length; i++) {
|
||||
|
||||
String extension = allExtensions[i];
|
||||
|
||||
boolean keep = true;
|
||||
|
||||
for (int j = 0; j < disallowedExtensions.length; j++) {
|
||||
|
||||
if (disallowedExtensions[j].toLowerCase().equals(extension)) {
|
||||
|
||||
keep = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (keep) {
|
||||
list.add(extension);
|
||||
}
|
||||
}
|
||||
|
||||
String[] allowedExtensions = new String[list.size()];
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
allowedExtensions[i] = (String)(list.get(i));
|
||||
}
|
||||
|
||||
return allowedExtensions;
|
||||
}
|
||||
|
||||
public String[] getDisallowedArchiveExtensions() {
|
||||
return disallowedExtensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the extensions to disallow.
|
||||
* @param extensions the archive extensions that will not be allowed.
|
||||
*/
|
||||
public void setDisallowedArchiveExtensions(String[] extensions) {
|
||||
this.disallowedExtensions = extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completes processing of the dialog.
|
||||
* Intercept of parent method.
|
||||
*
|
||||
* @return true if no errors
|
||||
*/
|
||||
public boolean verify()
|
||||
{
|
||||
// This method added by Phil to issue warning msg for existing member
|
||||
boolean ok = super.verify();
|
||||
|
||||
if (ok)
|
||||
{
|
||||
IRemoteFile file = (IRemoteFile)getSelectedObject();
|
||||
IRemoteFile saveasFile = null;
|
||||
|
||||
try
|
||||
{
|
||||
saveasFile = file.getParentRemoteFileSubSystem().getRemoteFileObject(file, getFileName());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
public boolean isPageComplete()
|
||||
{
|
||||
String nameToCheck = null;
|
||||
|
||||
if (fileName == null) {
|
||||
nameToCheck = "";
|
||||
}
|
||||
else {
|
||||
nameToCheck = fileName;
|
||||
}
|
||||
|
||||
SystemMessage errMsg = validator.validate(nameToCheck);
|
||||
|
||||
if (errMsg != null)
|
||||
{
|
||||
setErrorMessage(errMsg);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
clearErrorMessage();
|
||||
}
|
||||
|
||||
return fileTypeCombo != null &&
|
||||
fileTypeCombo.getText().length() > 0 &&
|
||||
fileNameText != null &&
|
||||
fileNameText.getText().length() > 0 &&
|
||||
super.isPageComplete();
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
|
||||
if (fileName.endsWith("." + fileType)) {
|
||||
return fileName;
|
||||
}
|
||||
else {
|
||||
return fileName + "." + fileType;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the implementation of ISystemViewElement for the given
|
||||
* object. Returns null if the adapter is not defined or the
|
||||
* object is not adaptable.
|
||||
*/
|
||||
protected ISystemViewElementAdapter getAdapter(Object o)
|
||||
{
|
||||
return SystemAdapterHelpers.getAdapter(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the implementation of ISystemRemoteElement for the given
|
||||
* object. Returns null if this object does not adaptable to this.
|
||||
*/
|
||||
protected ISystemRemoteElementAdapter getRemoteAdapter(Object o)
|
||||
{
|
||||
return SystemAdapterHelpers.getRemoteAdapter(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* User selected something in the tree.
|
||||
* This is an intercept of the parent's method so we can process a member selection, and
|
||||
* copy the selected member's name to the entry field.
|
||||
*/
|
||||
public void selectionChanged(SelectionChangedEvent e)
|
||||
{
|
||||
super.selectionChanged(e);
|
||||
clearErrorMessage();
|
||||
ISelection selection = e.getSelection();
|
||||
Object selectedObject = getFirstSelection(e.getSelection());
|
||||
if (selectedObject != null && selectedObject instanceof IRemoteFile)
|
||||
{
|
||||
IRemoteFile remoteFile = (IRemoteFile)selectedObject;
|
||||
|
||||
ISystemRemoteElementAdapter remoteAdapter = getRemoteAdapter(selectedObject);
|
||||
if ((remoteAdapter != null))
|
||||
{
|
||||
Object parentFile = remoteFile;
|
||||
|
||||
remoteAdapter = getRemoteAdapter(parentFile);
|
||||
if (remoteAdapter != null)
|
||||
{
|
||||
String fullPath = remoteAdapter.getAbsoluteName(parentFile);
|
||||
setNameText(fullPath);
|
||||
outputObjects = new Object[] {parentFile};
|
||||
setPageComplete();
|
||||
SystemMessage selectionMsg = null;
|
||||
if (selectionValidator != null)
|
||||
selectionMsg = selectionValidator.isValid(outputConnection, getSelections(selection), getRemoteAdapters(selection));
|
||||
|
||||
if (selectionMsg != null)
|
||||
{
|
||||
valid = false;
|
||||
setErrorMessage(selectionMsg);
|
||||
setPageComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPreSelection(IRemoteFile selection)
|
||||
{
|
||||
if (selection.isDirectory())
|
||||
{
|
||||
super.setPreSelection(selection);
|
||||
}
|
||||
else if (selection.isFile())
|
||||
{
|
||||
IRemoteFile parentFile = selection.getParentRemoteFile();
|
||||
|
||||
if (parentFile.isDirectory())
|
||||
{
|
||||
super.setPreSelection(parentFile);
|
||||
}
|
||||
}
|
||||
if (prePop)
|
||||
{
|
||||
String file = selection.getName();
|
||||
int i = file.lastIndexOf(".");
|
||||
if (i == -1)
|
||||
{
|
||||
fileName = file;
|
||||
fileType = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = file.substring(0,i);
|
||||
fileType = selection.getExtension();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileName = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root folder from which to start listing folders or files.
|
||||
* This version identifies the folder via a connection object and absolute path.
|
||||
* There is another overload that identifies the folder via a single IRemoteFile object.
|
||||
*
|
||||
* @param connection The connection to the remote system containing the root folder
|
||||
* @param folderAbsolutePath The fully qualified folder to start listing from (eg: "\folder1\folder2")
|
||||
*
|
||||
* @see org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString
|
||||
*/
|
||||
public void setRootFolder(IHost connection, String folderAbsolutePath)
|
||||
{
|
||||
setDefaultConnection(connection);
|
||||
setShowNewConnectionPrompt(true);
|
||||
setAutoExpandDepth(0);
|
||||
ISystemRegistry sr = SystemPlugin.getTheSystemRegistry();
|
||||
IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(connection);
|
||||
IRemoteFileSubSystemConfiguration ssf = ss.getParentRemoteFileSubSystemFactory();
|
||||
RemoteFileFilterString rffs = new RemoteFileFilterString(ssf);
|
||||
rffs.setShowFiles(fileMode); // no files if in folders mode
|
||||
rffs.setShowSubDirs(!fileMode || !filesOnlyMode); // yes folders, always, for now
|
||||
if (fileTypes != null)
|
||||
rffs.setFile(fileTypes);
|
||||
|
||||
// set the default filters we will show when the user expands a connection...
|
||||
String filterName = null;
|
||||
SystemFilterSimple filter = null;
|
||||
int filterCount = showRootFilter ? 2 : 1;
|
||||
if (preSelectRoot)
|
||||
filterCount = 1;
|
||||
ISystemFilter[] filters = new ISystemFilter[filterCount];
|
||||
int idx = 0;
|
||||
|
||||
// filter one: "Root files"/"Root folders" or "Drives"
|
||||
if (showRootFilter)
|
||||
{
|
||||
if (ssf.isUnixStyle())
|
||||
{
|
||||
if (!preSelectRoot)
|
||||
{
|
||||
// "Root files" or "Folders"
|
||||
filterName = fileMode ? SystemFileResources.RESID_FILTER_ROOTFILES : SystemFileResources.RESID_FILTER_ROOTFOLDERS;
|
||||
//rffs.setPath(ssf.getSeparator()); // defect 43492. Show the root not the contents of the root
|
||||
}
|
||||
else
|
||||
{
|
||||
filterName = SystemFileResources.RESID_FILTER_ROOTS; // "Roots"
|
||||
}
|
||||
}
|
||||
else
|
||||
filterName = fileMode ? SystemFileResources.RESID_FILTER_DRIVES : SystemFileResources.RESID_FILTER_DRIVES;
|
||||
filter = new SystemFilterSimple(filterName);
|
||||
filter.setParent(ss);
|
||||
filter.setFilterString(rffs.toString());
|
||||
filters[idx++] = filter;
|
||||
//System.out.println("FILTER 1: " + filter.getFilterString());
|
||||
if (preSelectRoot)
|
||||
{
|
||||
preSelectFilter = filter;
|
||||
preSelectFilterChild = folderAbsolutePath;
|
||||
//SystemPlugin.logInfo("in setRootFolder. Given: " + folderAbsolutePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!preSelectRoot)
|
||||
{
|
||||
|
||||
// filter two: "\folder1\folder2"
|
||||
rffs.setPath(folderAbsolutePath);
|
||||
|
||||
filter = new SystemFilterSimple(rffs.toStringNoSwitches());
|
||||
filter.setParent(ss);
|
||||
filter.setFilterString(rffs.toString());
|
||||
filters[idx] = filter;
|
||||
|
||||
preSelectFilter = filter;
|
||||
//SystemPlugin.logInfo("FILTER 2: " + filter.getFilterString());
|
||||
}
|
||||
inputProvider.setFilterString(null); // undo what ctor did
|
||||
inputProvider.setQuickFilters(filters);
|
||||
}
|
||||
|
||||
public void setPrePopSelection(boolean prePopSelection)
|
||||
{
|
||||
prePop = prePopSelection;
|
||||
}
|
||||
|
||||
public void setNameAndTypePrompt(String prompt)
|
||||
{
|
||||
nameAndTypePrompt = prompt;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
|
||||
public class DefaultMountPathMapper implements ISystemMountPathMapper
|
||||
{
|
||||
|
||||
public boolean handlesMappingFor(String hostname, String remotePath)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getActualHostFor(String hostname, String remotePath)
|
||||
{
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public String getWorkspaceMappingFor(String hostname, String remotePath)
|
||||
{
|
||||
return remotePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the remote path.
|
||||
*/
|
||||
public String getMountedMappingFor(String hostname, String remotePath)
|
||||
{
|
||||
return remotePath;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2003, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemSelectRemoteFileOrFolderForm;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
public class ExtractToDialog extends SystemSelectRemoteFileOrFolderDialog {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param fileMode True if selecting files, false if selecting folders
|
||||
*
|
||||
*/
|
||||
|
||||
private ExtractToForm form;
|
||||
|
||||
|
||||
public ExtractToDialog(Shell shell)
|
||||
{
|
||||
super(shell, false);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "exdi0000");
|
||||
}
|
||||
/**
|
||||
* Constructor when you want to supply your own title.
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param title The title to give the dialog
|
||||
* @param fileMode True if selecting files, false if selecting folders
|
||||
*/
|
||||
public ExtractToDialog(Shell shell, String title)
|
||||
{
|
||||
super(shell, title, false);
|
||||
setHelp(SystemPlugin.HELPPREFIX + "exdi0000");
|
||||
}
|
||||
|
||||
protected SystemSelectRemoteFileOrFolderForm getForm(boolean fileMode)
|
||||
{
|
||||
form = new ExtractToForm(getMessageLine(), this, fileMode);
|
||||
super.getForm(fileMode);
|
||||
return form;
|
||||
}
|
||||
|
||||
public Object getOutputObject()
|
||||
{
|
||||
IRemoteFile file = (IRemoteFile) super.getOutputObject();
|
||||
if (file.exists())
|
||||
{
|
||||
return file;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,328 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2003, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.rse.core.SystemAdapterHelpers;
|
||||
import org.eclipse.rse.core.SystemPlugin;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemSelectRemoteFileOrFolderForm;
|
||||
import org.eclipse.rse.filters.ISystemFilter;
|
||||
import org.eclipse.rse.filters.SystemFilterSimple;
|
||||
import org.eclipse.rse.model.IHost;
|
||||
import org.eclipse.rse.model.ISystemRegistry;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration;
|
||||
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
||||
import org.eclipse.rse.ui.validators.ValidatorFolderName;
|
||||
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* @author mjberger
|
||||
*
|
||||
* To change the template for this generated type comment go to
|
||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
||||
*/
|
||||
public class ExtractToForm extends SystemSelectRemoteFileOrFolderForm
|
||||
{
|
||||
|
||||
private String fileName;
|
||||
private ValidatorFolderName validator;
|
||||
|
||||
/**
|
||||
* Constructor for ExtractToForm
|
||||
*/
|
||||
public ExtractToForm(ISystemMessageLine msgLine, Object caller, boolean fileMode)
|
||||
{
|
||||
super(msgLine, caller, fileMode);
|
||||
|
||||
validator = new ValidatorFolderName();
|
||||
}
|
||||
|
||||
/**
|
||||
* In this method, we populate the given SWT container with widgets and return the container
|
||||
* to the caller.
|
||||
* @param parent The parent composite
|
||||
*/
|
||||
public Control createContents(Shell shell, Composite parent)
|
||||
{
|
||||
Control control = super.createContents(shell, parent);
|
||||
|
||||
// Composite composite = SystemWidgetHelpers.createComposite(parent, 2);
|
||||
// SystemWidgetHelpers.createLabel(composite, SystemResources.RESID_NEWFILE_NAME_ROOT_LABEL);
|
||||
// fileNameText = SystemWidgetHelpers.createTextField(composite, null);
|
||||
|
||||
// fileNameText = SystemWidgetHelpers.createLabeledTextField(
|
||||
// composite, null, SystemPlugin.getResourceBundle(), ISystemConstants.RESID_EXTRACTTO_NAME_ROOT);
|
||||
|
||||
|
||||
// fileNameText.addModifyListener(new ModifyListener() {
|
||||
// public void modifyText(ModifyEvent e) {
|
||||
// fileName = fileNameText.getText();
|
||||
// setPageComplete();
|
||||
// }
|
||||
// });
|
||||
|
||||
// if (fileName != null)
|
||||
// {
|
||||
// fileNameText.setText(fileName);
|
||||
// }
|
||||
|
||||
return control;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completes processing of the dialog.
|
||||
* Intercept of parent method.
|
||||
*
|
||||
* @return true if no errors
|
||||
*/
|
||||
public boolean verify()
|
||||
{
|
||||
// This method added by Phil to issue warning msg for existing member
|
||||
//System.out.println("Inside verify");
|
||||
boolean ok = super.verify();
|
||||
/* if (ok)
|
||||
{
|
||||
IRemoteFile file = (IRemoteFile) getSelectedObject();
|
||||
IRemoteFile saveasFile = null;
|
||||
try
|
||||
{
|
||||
saveasFile = file.getParentRemoteFileSubSystem().getRemoteFileObject(file, fileName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
//System.out.println("...saveasMbr null? "+ (saveasMbr==null));
|
||||
if (saveasFile != null && saveasFile.exists())
|
||||
{
|
||||
SystemMessage msg = SystemPlugin.getPluginMessage(ISystemMessages.MSG_UPLOAD_FILE_EXISTS);
|
||||
msg.makeSubstitution(fileName);
|
||||
SystemMessageDialog dlg = new SystemMessageDialog(getShell(), msg);
|
||||
ok = dlg.openQuestionNoException();
|
||||
}
|
||||
|
||||
}*/
|
||||
return ok;
|
||||
}
|
||||
|
||||
public boolean isPageComplete()
|
||||
{
|
||||
String errMsg = null; //validator.isValid(fileName);
|
||||
|
||||
if (errMsg != null)
|
||||
{
|
||||
setErrorMessage(errMsg);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (valid) clearErrorMessage();
|
||||
return valid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getFileName()
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the implementation of ISystemViewElement for the given
|
||||
* object. Returns null if the adapter is not defined or the
|
||||
* object is not adaptable.
|
||||
*/
|
||||
protected ISystemViewElementAdapter getAdapter(Object o)
|
||||
{
|
||||
return SystemAdapterHelpers.getAdapter(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the implementation of ISystemRemoteElement for the given
|
||||
* object. Returns null if this object does not adaptable to this.
|
||||
*/
|
||||
protected ISystemRemoteElementAdapter getRemoteAdapter(Object o)
|
||||
{
|
||||
return SystemAdapterHelpers.getRemoteAdapter(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* User selected something in the tree.
|
||||
* This is an intercept of the parent's method so we can process a member selection, and
|
||||
* copy the selected member's name to the entry field.
|
||||
*/
|
||||
public void selectionChanged(SelectionChangedEvent e)
|
||||
{
|
||||
super.selectionChanged(e);
|
||||
valid = true;
|
||||
ISelection selection = e.getSelection();
|
||||
Object selectedObject = getFirstSelection(selection);
|
||||
if (selectedObject != null && selectedObject instanceof IRemoteFile)
|
||||
{
|
||||
IRemoteFile remoteFile = (IRemoteFile)selectedObject;
|
||||
fileName = remoteFile.getName();
|
||||
if (remoteFile.isRoot())
|
||||
{
|
||||
if (fileName.endsWith("\\")) fileName = fileName.substring(0,2);
|
||||
}
|
||||
ISystemRemoteElementAdapter remoteAdapter = getRemoteAdapter(selectedObject);
|
||||
if ((remoteAdapter != null))
|
||||
{
|
||||
|
||||
Object parentFile = remoteFile;
|
||||
|
||||
remoteAdapter = getRemoteAdapter(parentFile);
|
||||
if (remoteAdapter != null)
|
||||
{
|
||||
String fullPath = remoteAdapter.getAbsoluteName(parentFile);
|
||||
setNameText(fullPath);
|
||||
outputObjects = new Object[] {parentFile};
|
||||
|
||||
SystemMessage selectionMsg = null;
|
||||
|
||||
if (selectionValidator != null)
|
||||
selectionMsg = selectionValidator.isValid(outputConnection, getSelections(selection), getRemoteAdapters(selection));
|
||||
|
||||
if (selectionMsg != null)
|
||||
{
|
||||
valid = false;
|
||||
setErrorMessage(selectionMsg);
|
||||
}
|
||||
setPageComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (selectedObject != null)
|
||||
{
|
||||
valid = false;
|
||||
setPageComplete();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPreSelection(IRemoteFile selection)
|
||||
{
|
||||
if (selection.isDirectory())
|
||||
{
|
||||
super.setPreSelection(selection);
|
||||
}
|
||||
else if (selection.isFile())
|
||||
{
|
||||
IRemoteFile parentFile = selection.getParentRemoteFile();
|
||||
|
||||
if (parentFile.isDirectory())
|
||||
{
|
||||
super.setPreSelection(parentFile);
|
||||
}
|
||||
|
||||
fileName = parentFile.getName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the root folder from which to start listing folders or files.
|
||||
* This version identifies the folder via a connection object and absolute path.
|
||||
* There is another overload that identifies the folder via a single IRemoteFile object.
|
||||
*
|
||||
* @param connection The connection to the remote system containing the root folder
|
||||
* @param folderAbsolutePath The fully qualified folder to start listing from (eg: "\folder1\folder2")
|
||||
*
|
||||
* @see org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString
|
||||
*/
|
||||
public void setRootFolder(IHost connection, String folderAbsolutePath)
|
||||
{
|
||||
setDefaultConnection(connection);
|
||||
setShowNewConnectionPrompt(true);
|
||||
setAutoExpandDepth(0);
|
||||
ISystemRegistry sr = SystemPlugin.getTheSystemRegistry();
|
||||
IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(connection);
|
||||
IRemoteFileSubSystemConfiguration ssf = ss.getParentRemoteFileSubSystemFactory();
|
||||
RemoteFileFilterString rffs = new RemoteFileFilterString(ssf);
|
||||
rffs.setShowFiles(fileMode); // no files if in folders mode
|
||||
rffs.setShowSubDirs(!fileMode || !filesOnlyMode); // yes folders, always, for now
|
||||
if (fileTypes != null)
|
||||
rffs.setFile(fileTypes);
|
||||
|
||||
// set the default filters we will show when the user expands a connection...
|
||||
String filterName = null;
|
||||
SystemFilterSimple filter = null;
|
||||
int filterCount = showRootFilter ? 2 : 1;
|
||||
if (preSelectRoot)
|
||||
filterCount = 1;
|
||||
ISystemFilter[] filters = new ISystemFilter[filterCount];
|
||||
int idx = 0;
|
||||
|
||||
// filter one: "Root files"/"Root folders" or "Drives"
|
||||
if (showRootFilter)
|
||||
{
|
||||
if (ssf.isUnixStyle())
|
||||
{
|
||||
if (!preSelectRoot)
|
||||
{
|
||||
// "Root files" or "Folders"
|
||||
filterName = fileMode ? SystemFileResources.RESID_FILTER_ROOTFILES : SystemFileResources.RESID_FILTER_ROOTFOLDERS;
|
||||
//rffs.setPath(ssf.getSeparator()); // defect 43492. Show the root not the contents of the root
|
||||
}
|
||||
else
|
||||
{
|
||||
filterName = SystemFileResources.RESID_FILTER_ROOTS; // "Roots"
|
||||
}
|
||||
}
|
||||
else
|
||||
filterName = fileMode ? SystemFileResources.RESID_FILTER_DRIVES : SystemFileResources.RESID_FILTER_DRIVES;
|
||||
filter = new SystemFilterSimple(filterName);
|
||||
filter.setParent(ss);
|
||||
filter.setFilterString(rffs.toString());
|
||||
filters[idx++] = filter;
|
||||
//System.out.println("FILTER 1: " + filter.getFilterString());
|
||||
if (preSelectRoot)
|
||||
{
|
||||
preSelectFilter = filter;
|
||||
preSelectFilterChild = folderAbsolutePath;
|
||||
//SystemPlugin.logInfo("in setRootFolder. Given: " + folderAbsolutePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (!preSelectRoot)
|
||||
{
|
||||
|
||||
// filter two: "\folder1\folder2"
|
||||
rffs.setPath(folderAbsolutePath);
|
||||
|
||||
filter = new SystemFilterSimple(rffs.toStringNoSwitches());
|
||||
filter.setParent(ss);
|
||||
filter.setFilterString(rffs.toString());
|
||||
filters[idx] = filter;
|
||||
|
||||
preSelectFilter = filter;
|
||||
//SystemPlugin.logInfo("FILTER 2: " + filter.getFilterString());
|
||||
}
|
||||
inputProvider.setFilterString(null); // undo what ctor did
|
||||
inputProvider.setQuickFilters(filters);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
import org.eclipse.rse.files.ui.dialogs.SystemSelectRemoteFileOrFolderDialog;
|
||||
import org.eclipse.rse.files.ui.widgets.SystemSelectRemoteFileOrFolderForm;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
|
||||
/**
|
||||
* Dialog used to select a file based on a dialog similar to the SaveAs
|
||||
*/
|
||||
public class FileSelectionDialog
|
||||
extends SystemSelectRemoteFileOrFolderDialog
|
||||
implements ISaveAsDialog
|
||||
{
|
||||
|
||||
public static final String Copyright =
|
||||
"(C) Copyright IBM Corp. 2003 All Rights Reserved.";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param fileMode True if selecting files, false if selecting folders
|
||||
*
|
||||
*/
|
||||
|
||||
private FileSelectionForm form;
|
||||
|
||||
protected FileSelectionDialog(Shell shell)
|
||||
{
|
||||
super(shell, false);
|
||||
}
|
||||
/**
|
||||
* Constructor when you want to supply your own title.
|
||||
*
|
||||
* @param shell The shell to hang the dialog off of
|
||||
* @param title The title to give the dialog
|
||||
* @param fileMode True if selecting files, false if selecting folders
|
||||
*/
|
||||
protected FileSelectionDialog(Shell shell, String title)
|
||||
{
|
||||
super(shell, title, true);
|
||||
}
|
||||
|
||||
public static FileSelectionDialog getFileSelectionDialog(
|
||||
Shell shell,
|
||||
String title)
|
||||
{
|
||||
return new FileSelectionDialog(shell, title);
|
||||
}
|
||||
|
||||
public static FileSelectionDialog getFileSelectionDialog(Shell shell)
|
||||
{
|
||||
return new FileSelectionDialog(shell);
|
||||
}
|
||||
|
||||
protected SystemSelectRemoteFileOrFolderForm getForm(boolean fileMode)
|
||||
{
|
||||
form = new FileSelectionForm(getMessageLine(), this, fileMode);
|
||||
super.getForm(fileMode);
|
||||
return form;
|
||||
}
|
||||
/**
|
||||
* Return file name specified
|
||||
* @return File name
|
||||
*/
|
||||
public String getFileName()
|
||||
{
|
||||
return form.getFileName();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2002, 2006 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, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.files.ui.resources;
|
||||
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
||||
|
||||
/**
|
||||
* Form class for selecting a file based on the SaveAS
|
||||
*/
|
||||
public class FileSelectionForm extends SaveAsForm
|
||||
{
|
||||
public static final String Copyright =
|
||||
"(C) Copyright IBM Corp. 2003 All Rights Reserved.";
|
||||
|
||||
/**
|
||||
* Constructor for FileSelectionForm
|
||||
*/
|
||||
public FileSelectionForm(
|
||||
ISystemMessageLine msgLine,
|
||||
Object caller,
|
||||
boolean fileMode)
|
||||
{
|
||||
super(msgLine, caller, fileMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Completes processing of the dialog.
|
||||
* Intercept of parent method.
|
||||
*
|
||||
* @return true if no errors
|
||||
*/
|
||||
public boolean verify()
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isPageComplete()
|
||||
{
|
||||
//String errMsg = validator.isValid(fileName);
|
||||
|
||||
//if (errMsg != null)
|
||||
//{
|
||||
// setErrorMessage(errMsg);
|
||||
// return false;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// clearErrorMessage();
|
||||
//}
|
||||
|
||||
return fileNameText != null
|
||||
&& fileNameText.getText().length() > 0;
|
||||
//&& super.isPageComplete();
|
||||
}
|
||||
public String getFileName()
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
|
||||
}
|