Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-03-15 13:10:50 -0400
committerslewis2008-03-15 13:10:50 -0400
commitc6d622fde084becc5c9d4457535f18c2302b6561 (patch)
treef850bf8025167379994bdfb567eb684c18d69715
parent88ad784159fb9efe66a80e703baa5c78c91d9fe8 (diff)
downloadorg.eclipse.ecf-c6d622fde084becc5c9d4457535f18c2302b6561.tar.gz
org.eclipse.ecf-c6d622fde084becc5c9d4457535f18c2302b6561.tar.xz
org.eclipse.ecf-c6d622fde084becc5c9d4457535f18c2302b6561.zip
Added URL hyperlink detector for scp protocol.
-rw-r--r--framework/bundles/org.eclipse.ecf.filetransfer.ui/.classpath2
-rw-r--r--framework/bundles/org.eclipse.ecf.filetransfer.ui/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--framework/bundles/org.eclipse.ecf.filetransfer.ui/META-INF/MANIFEST.MF7
-rw-r--r--framework/bundles/org.eclipse.ecf.filetransfer.ui/plugin.properties2
-rw-r--r--framework/bundles/org.eclipse.ecf.filetransfer.ui/plugin.xml11
-rw-r--r--framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/GetFileHandler.java16
-rw-r--r--framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/StartFileDownloadDialog.java93
-rw-r--r--framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/hyperlink/SCPHyperlink.java63
-rw-r--r--framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/hyperlink/SCPHyperlinkDetector.java37
9 files changed, 192 insertions, 46 deletions
diff --git a/framework/bundles/org.eclipse.ecf.filetransfer.ui/.classpath b/framework/bundles/org.eclipse.ecf.filetransfer.ui/.classpath
index ce0c7a5d4..ce7393340 100644
--- a/framework/bundles/org.eclipse.ecf.filetransfer.ui/.classpath
+++ b/framework/bundles/org.eclipse.ecf.filetransfer.ui/.classpath
@@ -1,7 +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/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/CDC-1.0%Foundation-1.0"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/framework/bundles/org.eclipse.ecf.filetransfer.ui/.settings/org.eclipse.jdt.core.prefs b/framework/bundles/org.eclipse.ecf.filetransfer.ui/.settings/org.eclipse.jdt.core.prefs
index e9ff802f1..745cbb8ff 100644
--- a/framework/bundles/org.eclipse.ecf.filetransfer.ui/.settings/org.eclipse.jdt.core.prefs
+++ b/framework/bundles/org.eclipse.ecf.filetransfer.ui/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Mon Oct 15 23:38:56 PDT 2007
+#Fri Mar 14 23:29:47 PDT 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
@@ -8,9 +8,9 @@ org.eclipse.jdt.core.circularClasspath=error
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.3
+org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -143,7 +143,6 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
org.eclipse.jdt.core.formatter.indentation.size=4
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
diff --git a/framework/bundles/org.eclipse.ecf.filetransfer.ui/META-INF/MANIFEST.MF b/framework/bundles/org.eclipse.ecf.filetransfer.ui/META-INF/MANIFEST.MF
index 087c44721..359d58622 100644
--- a/framework/bundles/org.eclipse.ecf.filetransfer.ui/META-INF/MANIFEST.MF
+++ b/framework/bundles/org.eclipse.ecf.filetransfer.ui/META-INF/MANIFEST.MF
@@ -8,12 +8,13 @@ Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ecf.filetransfer,
- org.eclipse.ecf
+ org.eclipse.ecf,
+ org.eclipse.ecf.ui;bundle-version="1.3.0",
+ org.eclipse.jface.text;bundle-version="3.4.0"
Eclipse-LazyStart: true
-Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,
- J2SE-1.3
Bundle-Vendor: %providerName
Export-Package: org.eclipse.ecf.filetransfer.ui,
org.eclipse.ecf.filetransfer.ui.actions,
org.eclipse.ecf.internal.filetransfer.ui;x-internal:=true
Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
diff --git a/framework/bundles/org.eclipse.ecf.filetransfer.ui/plugin.properties b/framework/bundles/org.eclipse.ecf.filetransfer.ui/plugin.properties
index 9d781324d..0a4e4fb2e 100644
--- a/framework/bundles/org.eclipse.ecf.filetransfer.ui/plugin.properties
+++ b/framework/bundles/org.eclipse.ecf.filetransfer.ui/plugin.properties
@@ -11,3 +11,5 @@
pluginName = ECF File Transfer UI
providerName = Eclipse.org
+
+SCPHyperlinkDetector= SCP
diff --git a/framework/bundles/org.eclipse.ecf.filetransfer.ui/plugin.xml b/framework/bundles/org.eclipse.ecf.filetransfer.ui/plugin.xml
index bba16009f..07c08f49f 100644
--- a/framework/bundles/org.eclipse.ecf.filetransfer.ui/plugin.xml
+++ b/framework/bundles/org.eclipse.ecf.filetransfer.ui/plugin.xml
@@ -37,4 +37,15 @@
icon="icons/transf_download.gif"/>
</menuContribution>
</extension>
+ <extension
+ point="org.eclipse.ui.workbench.texteditor.hyperlinkDetectors">
+ <hyperlinkDetector
+ activate="true"
+ class="org.eclipse.ecf.internal.filetransfer.ui.hyperlink.SCPHyperlinkDetector"
+ id="org.eclipse.ecf.internal.filetransfer.ui.hyperlink.SCPHyperlinkDetector"
+ name="%SCPHyperlinkDetector"
+ targetId="org.eclipse.ui.DefaultTextEditor">
+ </hyperlinkDetector>
+ </extension>
+
</plugin>
diff --git a/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/GetFileHandler.java b/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/GetFileHandler.java
index ef48e0f98..a4426d3ee 100644
--- a/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/GetFileHandler.java
+++ b/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/GetFileHandler.java
@@ -54,12 +54,8 @@ public class GetFileHandler extends AbstractHandler {
updateTransferInView(shell, incoming);
}
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- public Object execute(ExecutionEvent o) throws ExecutionException {
- final Shell shell = HandlerUtil.getActiveShellChecked(o);
- StartFileDownloadDialog dialog = new StartFileDownloadDialog(shell);
+ public void openStartFileDownloadDialog(final Shell shell, String url) {
+ StartFileDownloadDialog dialog = new StartFileDownloadDialog(shell, url);
if (dialog.open() == Window.OK) {
final String scp = dialog.getValue();
final String userid = dialog.userid;
@@ -109,6 +105,14 @@ public class GetFileHandler extends AbstractHandler {
}
}.schedule();
}
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent o) throws ExecutionException {
+ openStartFileDownloadDialog(HandlerUtil.getActiveShellChecked(o), null);
return null;
}
diff --git a/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/StartFileDownloadDialog.java b/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/StartFileDownloadDialog.java
index d8323c320..19fba05b9 100644
--- a/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/StartFileDownloadDialog.java
+++ b/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/StartFileDownloadDialog.java
@@ -16,8 +16,7 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.dialogs.*;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.*;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
@@ -30,19 +29,18 @@ public class StartFileDownloadDialog extends InputDialog {
public String filename;
protected Text fileLocation;
- static private IInputValidator inputValidator = new IInputValidator() {
- public String isValid(String newText) {
- try {
- new URL(newText);
- return null;
- } catch (Exception e) {
- return ("".equals(newText)) ? null : NLS.bind(Messages.getString("StartFileDownloadDialog.MalformedURLException"), newText); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ String filePath;
+
+ public StartFileDownloadDialog(Shell parentShell, String startURL) {
+ super(parentShell, Messages.getString("StartFileDownloadDialog.FileTransfer"), Messages.getString("StartFileDownloadDialog.Source"), startURL, null); //$NON-NLS-1$ //$NON-NLS-2$
+ filePath = System.getProperty("user.home"); //$NON-NLS-1$
+ if (Platform.getOS().startsWith("win")) { //$NON-NLS-1$
+ filePath = filePath + File.separator + "Desktop"; //$NON-NLS-1$
}
- };
+ }
public StartFileDownloadDialog(Shell parentShell) {
- super(parentShell, Messages.getString("StartFileDownloadDialog.FileTransfer"), Messages.getString("StartFileDownloadDialog.Source"), null, inputValidator); //$NON-NLS-1$ //$NON-NLS-2$
+ this(parentShell, null);
}
Text getInputText() {
@@ -57,7 +55,45 @@ public class StartFileDownloadDialog extends InputDialog {
Button okButton = getButton(IDialogConstants.OK_ID);
okButton.setText(Messages.getString("StartFileDownloadDialog.DOWNLOAD_BUTTON")); //$NON-NLS-1$
okButton.setToolTipText(Messages.getString("StartFileDownloadDialog.DOWNLOAD_BUTTON_TOOLTIP")); //$NON-NLS-1$
- okButton.setEnabled(false);
+ URL url = validateURL();
+ if (url != null) {
+ String fileName = getFileNameFromURL();
+ if (!"".equals(fileName)) { //$NON-NLS-1$
+ fileLocation.setText(filePath + File.separator + fileName);
+ useridText.setFocus();
+ }
+ String user = url.getUserInfo();
+ if (user != null) {
+ useridText.setText(user);
+ passwordText.setFocus();
+ }
+ okButton.setEnabled(true);
+ } else
+ okButton.setEnabled(false);
+ }
+
+ URL validateURL() {
+ String text = getInputText().getText();
+ URL result = null;
+ try {
+ if (!"".equals(text)) { //$NON-NLS-1$
+ result = new URL(text);
+ }
+ } catch (Exception e) {
+ setErrorMessage((NLS.bind(Messages.getString("StartFileDownloadDialog.MalformedURLException"), text))); //$NON-NLS-1$
+ return null;
+ }
+ setErrorMessage(null);
+ return result;
+ }
+
+ String getFileNameFromURL() {
+ String scp = getInputText().getText();
+ String fileName = ""; //$NON-NLS-1$
+ if (scp != null && scp.length() > 0) {
+ fileName = scp.substring(scp.lastIndexOf('/') + 1);
+ }
+ return fileName;
}
protected Control createDialogArea(Composite parent) {
@@ -69,30 +105,26 @@ public class StartFileDownloadDialog extends InputDialog {
label.setLayoutData(data);
label.setFont(parent.getFont());
- String userhome = System.getProperty("user.home"); //$NON-NLS-1$
- if (Platform.getOS().startsWith("win")) { //$NON-NLS-1$
- userhome = userhome + File.separator + "Desktop"; //$NON-NLS-1$
- }
- final String path = userhome;
-
fileLocation = new Text(composite, SWT.SINGLE | SWT.BORDER);
fileLocation.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
- fileLocation.setText(path);
+ fileLocation.setText(filePath);
fileLocation.setSelection(fileLocation.getText().length());
Text text = getInputText();
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validateURL();
+ }
+ });
+
text.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
// nothing
}
public void focusLost(FocusEvent e) {
- String scp = ((Text) e.getSource()).getText();
- String fileName = ""; //$NON-NLS-1$
- if (scp != null && scp.length() > 0) {
- fileName = scp.substring(scp.lastIndexOf('/') + 1);
- }
- fileLocation.setText(path + File.separator + fileName);
+ String fileName = getFileNameFromURL();
+ fileLocation.setText(filePath + File.separator + fileName);
fileLocation.setSelection(fileLocation.getText().length());
}
});
@@ -102,15 +134,11 @@ public class StartFileDownloadDialog extends InputDialog {
fileBrowse.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
if (event.type == SWT.Selection) {
- String scp = getInputText().getText();
- String fileName = ""; //$NON-NLS-1$
- if (scp != null && scp.length() > 0) {
- fileName = scp.substring(scp.lastIndexOf('/') + 1);
- }
+ String fileName = getFileNameFromURL();
FileDialog fd = new FileDialog(fileBrowse.getShell(), SWT.SAVE);
fd.setText(Messages.getString("StartFileDownloadDialog.OutputFile")); //$NON-NLS-1$
fd.setFileName(fileName);
- fd.setFilterPath(path);
+ fd.setFilterPath(filePath);
String fname = fd.open();
if (fname != null) {
fileLocation.setText(fname);
@@ -140,6 +168,7 @@ public class StartFileDownloadDialog extends InputDialog {
passwordText = new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD);
passwordText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
applyDialogFont(composite);
+
return composite;
}
diff --git a/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/hyperlink/SCPHyperlink.java b/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/hyperlink/SCPHyperlink.java
new file mode 100644
index 000000000..0a464031f
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/hyperlink/SCPHyperlink.java
@@ -0,0 +1,63 @@
+/****************************************************************************
+ * Copyright (c) 2004 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.internal.filetransfer.ui.hyperlink;
+
+import java.net.URI;
+import org.eclipse.ecf.internal.filetransfer.ui.GetFileHandler;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ *
+ */
+public class SCPHyperlink implements IHyperlink {
+
+ Shell shell;
+ IRegion region;
+ URI uri;
+
+ public SCPHyperlink(Shell shell, IRegion region, URI uri) {
+ this.shell = shell;
+ this.region = region;
+ this.uri = uri;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.ui.hyperlink.AbstractURLHyperlink#open()
+ */
+ public void open() {
+ GetFileHandler getFileHandler = new GetFileHandler();
+ getFileHandler.openStartFileDownloadDialog(shell, uri.toString());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion()
+ */
+ public IRegion getHyperlinkRegion() {
+ return region;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
+ */
+ public String getHyperlinkText() {
+ return uri.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
+ */
+ public String getTypeLabel() {
+ return null;
+ }
+}
diff --git a/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/hyperlink/SCPHyperlinkDetector.java b/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/hyperlink/SCPHyperlinkDetector.java
new file mode 100644
index 000000000..2ab674db2
--- /dev/null
+++ b/framework/bundles/org.eclipse.ecf.filetransfer.ui/src/org/eclipse/ecf/internal/filetransfer/ui/hyperlink/SCPHyperlinkDetector.java
@@ -0,0 +1,37 @@
+package org.eclipse.ecf.internal.filetransfer.ui.hyperlink;
+
+import java.net.URI;
+import org.eclipse.ecf.ui.hyperlink.AbstractURLHyperlinkDetector;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.swt.widgets.Shell;
+
+public class SCPHyperlinkDetector extends AbstractURLHyperlinkDetector {
+
+ public static final String SCP_PROTOCOL = "scp"; //$NON-NLS-1$
+
+ public SCPHyperlinkDetector() {
+ setProtocols(new String[] {SCP_PROTOCOL});
+ }
+
+ Shell shell;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.ui.hyperlink.AbstractURLHyperlinkDetector#detectHyperlinks(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion, boolean)
+ */
+ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
+ IHyperlink[] links = super.detectHyperlinks(textViewer, region, canShowMultipleHyperlinks);
+ if (links != null)
+ shell = textViewer.getTextWidget().getShell();
+ return links;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.ui.hyperlink.AbstractURLHyperlinkDetector#createHyperLinksForURI(org.eclipse.jface.text.IRegion, java.net.URI)
+ */
+ protected IHyperlink[] createHyperLinksForURI(IRegion region, URI uri) {
+ return new IHyperlink[] {new SCPHyperlink(shell, region, uri)};
+ }
+
+}

Back to the top