Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 183463 Details for
Bug 299020
[Net] Check Button for Edit Proxy Entry
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
proposed patch
patch.txt (text/plain), 29.15 KB, created by
Wojciech Galanciak
on 2010-11-19 07:03:55 EST
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Wojciech Galanciak
Created:
2010-11-19 07:03:55 EST
Size:
29.15 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.net >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.net/plugin.xml,v >retrieving revision 1.3 >diff -u -r1.3 plugin.xml >--- plugin.xml 14 May 2009 10:31:50 -0000 1.3 >+++ plugin.xml 19 Nov 2010 12:02:28 -0000 >@@ -2,6 +2,7 @@ > <?eclipse version="3.2"?> > <plugin> > <extension-point id="authenticator" name="Authenticator" schema="schema/authenticator.exsd"/> >+ <extension-point id="proxyTester" name="Proxy Tester" schema="schema/proxyTester.exsd"/> > <extension > point="org.eclipse.equinox.preferences.preferences"> > <initializer >Index: schema/proxyTester.exsd >=================================================================== >RCS file: schema/proxyTester.exsd >diff -N schema/proxyTester.exsd >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ schema/proxyTester.exsd 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,102 @@ >+<?xml version='1.0' encoding='UTF-8'?> >+<!-- Schema file written by PDE --> >+<schema targetNamespace="org.eclipse.core.net" xmlns="http://www.w3.org/2001/XMLSchema"> >+<annotation> >+ <appInfo> >+ <meta.schema plugin="org.eclipse.core.net" id="proxyTester" name="Proxy Tester"/> >+ </appInfo> >+ <documentation> >+ [Enter description of this extension point.] >+ </documentation> >+ </annotation> >+ >+ <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element /> >+ </appInfo> >+ </annotation> >+ <complexType> >+ <choice minOccurs="1" maxOccurs="unbounded"> >+ <element ref="proxyTestProvider"/> >+ </choice> >+ <attribute name="point" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="id" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="name" type="string"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute translatable="true"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <element name="proxyTestProvider"> >+ <complexType> >+ <attribute name="class" type="string" use="required"> >+ <annotation> >+ <documentation> >+ >+ </documentation> >+ <appInfo> >+ <meta.attribute kind="java" basedOn=":org.eclipse.core.net.proxy.IProxyTestProvider"/> >+ </appInfo> >+ </annotation> >+ </attribute> >+ </complexType> >+ </element> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="since"/> >+ </appInfo> >+ <documentation> >+ [Enter the first release in which this extension point appears.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="examples"/> >+ </appInfo> >+ <documentation> >+ [Enter extension point usage example here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="apiinfo"/> >+ </appInfo> >+ <documentation> >+ [Enter API information here.] >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> >+ <meta.section type="implementation"/> >+ </appInfo> >+ <documentation> >+ [Enter information about supplied implementation of this extension point.] >+ </documentation> >+ </annotation> >+ >+ >+</schema> >Index: src/org/eclipse/core/net/proxy/IProxyTestProvider.java >=================================================================== >RCS file: src/org/eclipse/core/net/proxy/IProxyTestProvider.java >diff -N src/org/eclipse/core/net/proxy/IProxyTestProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/net/proxy/IProxyTestProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.core.net.proxy; >+ >+import org.eclipse.core.runtime.IStatus; >+ >+public interface IProxyTestProvider { >+ >+ /** >+ * This method should test connection with a given host. Implementors should >+ * test connection and returns IStatus instance in a result. If connection is >+ * established correctly, it should return >+ * org.eclipse.core.runtime.Status.Status(int, String, String) with severity >+ * IStatus.OK. If connection cannot be established, severity should be >+ * IStatus.ERROR. If any Throwable object is available as a result of any >+ * error or exception, it should return >+ * org.eclipse.core.runtime.Status.Status(int, String, int, String, >+ * Throwable). >+ * @param host for which connection is tested. >+ * @return IStatus result of a test >+ */ >+ IStatus testConnection(String host); >+ >+ /** >+ * Returns short description of a test which is provided by implementor. >+ * It is used in proxy test dialog. >+ * @return test description >+ */ >+ String getDescription(); >+ >+ /** >+ * Returns test provider. Recommended is to return plug-in's id. >+ * @return test provider >+ */ >+ String getProvider(); >+} >#P org.eclipse.ui.net >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/plugin.xml,v >retrieving revision 1.4 >diff -u -r1.4 plugin.xml >--- plugin.xml 30 Apr 2007 18:02:22 -0000 1.4 >+++ plugin.xml 19 Nov 2010 12:02:29 -0000 >@@ -25,5 +25,11 @@ > class="org.eclipse.ui.internal.net.auth.NetAuthenticator"> > </authenticator> > </extension> >+ <extension >+ point="org.eclipse.core.net.proxyTester"> >+ <proxyTestProvider >+ class="org.eclipse.ui.internal.net.test.DefaultProxyTestProvider"> >+ </proxyTestProvider> >+ </extension> > > </plugin> >Index: src/org/eclipse/ui/internal/net/NetUIMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/NetUIMessages.java,v >retrieving revision 1.7 >diff -u -r1.7 NetUIMessages.java >--- src/org/eclipse/ui/internal/net/NetUIMessages.java 17 Mar 2009 09:12:31 -0000 1.7 >+++ src/org/eclipse/ui/internal/net/NetUIMessages.java 19 Nov 2010 12:02:29 -0000 >@@ -42,6 +42,7 @@ > public static String ProxyPreferencePage_16; > public static String ProxyPreferencePage_17; > public static String ProxyPreferencePage_18; >+ public static String ProxyPreferencePage_19; > > public static String ProxyEntryDialog_0; > public static String ProxyEntryDialog_1; >@@ -66,6 +67,20 @@ > public static String UserValidationDialog_1; > public static String UserValidationDialog_2; > public static String UserValidationDialog_3; >+ >+ public static String ProxyTestDialog_0; >+ public static String ProxyTestDialog_1; >+ public static String ProxyTestDialog_2; >+ public static String ProxyTestDialog_3; >+ public static String ProxyTestDialog_4; >+ public static String ProxyTestDialog_5; >+ public static String ProxyTestDialog_6; >+ public static String ProxyTestDialog_7; >+ public static String ProxyTestDialog_8; >+ public static String ProxyTestDialog_9; >+ public static String ProxyTestDialog_10; >+ public static String ProxyTestDialog_11; >+ public static String ProxyTestDialog_12; > > static { > NLS.initializeMessages(BUNDLE_NAME, NetUIMessages.class); >Index: src/org/eclipse/ui/internal/net/ProxyPreferencePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/ProxyPreferencePage.java,v >retrieving revision 1.20 >diff -u -r1.20 ProxyPreferencePage.java >--- src/org/eclipse/ui/internal/net/ProxyPreferencePage.java 20 Sep 2010 08:02:30 -0000 1.20 >+++ src/org/eclipse/ui/internal/net/ProxyPreferencePage.java 19 Nov 2010 12:02:29 -0000 >@@ -19,19 +19,23 @@ > package org.eclipse.ui.internal.net; > > import org.eclipse.core.internal.net.ProxySelector; >+import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.preference.PreferencePage; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionAdapter; > 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.Combo; > 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.ui.IWorkbench; > import org.eclipse.ui.IWorkbenchPreferencePage; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.net.test.ProxyTestDialog; > > public class ProxyPreferencePage extends PreferencePage implements > IWorkbenchPreferencePage { >@@ -53,6 +57,7 @@ > createProviderComposite(composite); > createProxyEntriesComposite(composite); > createNonProxiedHostsComposite(composite); >+ createTestButton(composite); > > // Adding help accessible by F1 > PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), >@@ -90,6 +95,21 @@ > nonProxyHostsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, > true, true)); > } >+ >+ private void createTestButton(Composite parent) { >+ final Button test = new Button(parent, SWT.PUSH); >+ test.setText(NetUIMessages.ProxyPreferencePage_19); >+ test.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ Dialog dialog = new ProxyTestDialog(test.getShell()); >+ dialog.open(); >+ } >+ }); >+ } >+ }); >+ } > > public void init(IWorkbench workbench) { > // Nothing to do >Index: src/org/eclipse/ui/internal/net/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.net/src/org/eclipse/ui/internal/net/messages.properties,v >retrieving revision 1.8 >diff -u -r1.8 messages.properties >--- src/org/eclipse/ui/internal/net/messages.properties 17 Mar 2009 09:12:31 -0000 1.8 >+++ src/org/eclipse/ui/internal/net/messages.properties 19 Nov 2010 12:02:29 -0000 >@@ -1,5 +1,5 @@ > ############################################################################### >-# Copyright (c) 2000, 2009 IBM Corporation and others. >+# Copyright (c) 2000, 2010 IBM Corporation and others. > # All rights reserved. This program and the accompanying materials > # are made available under the terms of the Eclipse Public License v1.0 > # which accompanies this distribution, and is available at >@@ -34,6 +34,7 @@ > ProxyPreferencePage_16=Edi&t... > ProxyPreferencePage_17=Re&move > ProxyPreferencePage_18=Dynamic >+ProxyPreferencePage_19=Test > > ProxyEntryDialog_0=New Proxy Entry > ProxyEntryDialog_1=Edit Proxy Entry >@@ -58,3 +59,17 @@ > UserValidationDialog_1=Connect to: {0} > UserValidationDialog_2=&Password: > UserValidationDialog_3=&User name: >+ >+ProxyTestDialog_0=Proxy Test Results >+ProxyTestDialog_1=Provider >+ProxyTestDialog_2=Description >+ProxyTestDialog_3=Result >+ProxyTestDialog_4=Host to test: >+ProxyTestDialog_5=This dialog provides ability to test proxy settings. >+ProxyTestDialog_6=Success >+ProxyTestDialog_7=Fail >+ProxyTestDialog_8=Details >+ProxyTestDialog_9=Error Details >+ProxyTestDialog_10=Testing proxy settings... >+ProxyTestDialog_11=Run All >+ProxyTestDialog_12=Available tests: >\ No newline at end of file >Index: src/org/eclipse/ui/internal/net/test/DefaultProxyTestProvider.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/net/test/DefaultProxyTestProvider.java >diff -N src/org/eclipse/ui/internal/net/test/DefaultProxyTestProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/net/test/DefaultProxyTestProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.net.test; >+ >+import java.io.IOException; >+import java.net.HttpURLConnection; >+import java.net.URL; >+ >+import org.eclipse.core.net.proxy.IProxyTestProvider; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.ui.internal.net.Activator; >+ >+public class DefaultProxyTestProvider implements IProxyTestProvider { >+ >+ public IStatus testConnection(String host) { >+ try { >+ URL url = new URL(host); >+ int responseCode = ((HttpURLConnection) url.openConnection()) >+ .getResponseCode(); >+ if (responseCode == 200) { >+ return new Status(IStatus.OK, Activator.PLUGIN_ID, host); >+ } else { >+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, host); >+ } >+ } catch (IOException e) { >+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, host, e); >+ } >+ } >+ >+ public String getDescription() { >+ return "Default proxy connection test."; //$NON-NLS-1$ >+ } >+ >+ public String getProvider() { >+ return Activator.PLUGIN_ID; >+ } >+ >+} >Index: src/org/eclipse/ui/internal/net/test/ProxyTestContentProvider.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/net/test/ProxyTestContentProvider.java >diff -N src/org/eclipse/ui/internal/net/test/ProxyTestContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/net/test/ProxyTestContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.net.test; >+ >+import java.util.Collection; >+ >+import org.eclipse.core.net.proxy.IProxyTestProvider; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.Viewer; >+ >+public class ProxyTestContentProvider implements IStructuredContentProvider { >+ >+ public ProxyTestContentProvider() { >+ super(); >+ } >+ >+ public void dispose() { >+ // do nothing >+ } >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ // do nothing >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ Collection coll = (Collection) inputElement; >+ return coll.toArray(new IProxyTestProvider[0]); >+ } >+ >+} >Index: src/org/eclipse/ui/internal/net/test/ProxyTestDialog.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/net/test/ProxyTestDialog.java >diff -N src/org/eclipse/ui/internal/net/test/ProxyTestDialog.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/net/test/ProxyTestDialog.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,182 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.net.test; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.Iterator; >+import java.util.Set; >+ >+import org.eclipse.core.internal.net.Activator; >+import org.eclipse.core.net.proxy.IProxyTestProvider; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.dialogs.ProgressMonitorDialog; >+import org.eclipse.jface.dialogs.StatusDialog; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.viewers.ColumnWeightData; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.TableLayout; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionAdapter; >+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.Table; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.ui.internal.net.NetUIMessages; >+ >+public class ProxyTestDialog extends StatusDialog { >+ >+ private Label desc; >+ private Button detailsButton; >+ private Button runButton; >+ private Label hostLabel; >+ private Label tableDesc; >+ protected Text hostText; >+ protected TableViewer testsViewer; >+ >+ protected ProxyTester proxyTester; >+ >+ public ProxyTestDialog(Shell parent) { >+ super(parent); >+ this.proxyTester = new ProxyTester(); >+ this.setTitle(NetUIMessages.ProxyTestDialog_0); >+ this.setHelpAvailable(false); >+ } >+ >+ protected Control createDialogArea(Composite parent) { >+ Composite area = new Composite(parent, SWT.NONE); >+ area.setLayout(new GridLayout(3, false)); >+ >+ desc = new Label(area, SWT.NONE); >+ desc.setText(NetUIMessages.ProxyTestDialog_5); >+ desc.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 3, 1)); >+ >+ hostLabel = new Label(area, SWT.NONE); >+ hostLabel.setText(NetUIMessages.ProxyTestDialog_4); >+ hostLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); >+ >+ hostText = new Text(area, SWT.BORDER); >+ hostText.setText("http://www.eclipse.org"); //$NON-NLS-1$ >+ hostText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); >+ >+ tableDesc = new Label(area, SWT.NONE); >+ tableDesc.setText(NetUIMessages.ProxyTestDialog_12); >+ tableDesc.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 3, 1)); >+ >+ Table testsTable = new Table(area, SWT.BORDER | SWT.V_SCROLL >+ | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); >+ testsTable.setHeaderVisible(true); >+ testsTable.setLinesVisible(true); >+ testsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 3)); >+ >+ runButton = createButton(area, NetUIMessages.ProxyTestDialog_11); >+ detailsButton = createButton(area, NetUIMessages.ProxyTestDialog_8); >+ detailsButton.setEnabled(false); >+ >+ testsViewer = new TableViewer(testsTable); >+ proxyTester.initialize(); >+ ProxyTestLabelProvider labelProvider = new ProxyTestLabelProvider(proxyTester); >+ ProxyTestContentProvider contentProvider = new ProxyTestContentProvider(); >+ labelProvider.createColumns(testsViewer); >+ testsViewer.setContentProvider(contentProvider); >+ testsViewer.setLabelProvider(labelProvider); >+ >+ TableLayout tableLayout = new TableLayout(); >+ tableLayout.addColumnData(new ColumnWeightData(20, 120, true)); >+ tableLayout.addColumnData(new ColumnWeightData(20, 150, true)); >+ tableLayout.addColumnData(new ColumnWeightData(20, 50, true)); >+ >+ testsTable.setLayout(tableLayout); >+ testsTable.pack(); >+ >+ testsViewer.setInput(proxyTester.getTestProviders()); >+ >+ testsViewer.addSelectionChangedListener(new ISelectionChangedListener() { >+ public void selectionChanged(SelectionChangedEvent event) { >+ enableDetailsButton(); >+ } >+ }); >+ runButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent event) { >+ final String hostname = hostText.getText(); >+ ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(getShell()); >+ try { >+ progressDialog.run(true, true, new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) { >+ performTests(hostname, monitor); >+ } >+ }); >+ } catch (InvocationTargetException e) { >+ Activator.logError("Exception during proxy testing", e); //$NON-NLS-1$ >+ } catch (InterruptedException e) { >+ Activator.logError("Exception during proxy testing", e); //$NON-NLS-1$ >+ } >+ testsViewer.refresh(); >+ } >+ }); >+ detailsButton.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ IProxyTestProvider provider = getSelection(); >+ if (proxyTester.hasPerformed(provider)) { >+ MessageDialog.openInformation(getShell(), >+ NetUIMessages.ProxyTestDialog_9, >+ proxyTester.getError(provider).getMessage()); >+ } >+ } >+ }); >+ enableDetailsButton(); >+ return area; >+ } >+ >+ protected void performTests(final String hostname, IProgressMonitor monitor) { >+ Set providers = proxyTester.getTestProviders(); >+ monitor.beginTask(NetUIMessages.ProxyTestDialog_10, providers.size()); >+ Iterator it = providers.iterator(); >+ while (it.hasNext()) { >+ if (monitor.isCanceled()) { >+ return; >+ } >+ IProxyTestProvider test = (IProxyTestProvider) it.next(); >+ proxyTester.execute(test, hostname); >+ monitor.worked(1); >+ } >+ monitor.done(); >+ } >+ >+ protected IProxyTestProvider getSelection() { >+ IStructuredSelection selection = (IStructuredSelection) testsViewer.getSelection(); >+ return (IProxyTestProvider) selection.getFirstElement(); >+ } >+ >+ protected void enableDetailsButton() { >+ IProxyTestProvider provider = getSelection(); >+ if (proxyTester.hasPerformed(provider)) { >+ detailsButton.setEnabled(proxyTester.getError(provider) != null ? true : false); >+ } >+ } >+ >+ private Button createButton(Composite parent, String message) { >+ Button button = new Button(parent, SWT.PUSH); >+ button.setText(message); >+ button.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); >+ return button; >+ } >+ >+} >\ No newline at end of file >Index: src/org/eclipse/ui/internal/net/test/ProxyTestLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/net/test/ProxyTestLabelProvider.java >diff -N src/org/eclipse/ui/internal/net/test/ProxyTestLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/net/test/ProxyTestLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,78 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.net.test; >+ >+import org.eclipse.core.net.proxy.IProxyTestProvider; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.jface.viewers.BaseLabelProvider; >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.TableViewerColumn; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.TableColumn; >+import org.eclipse.ui.internal.net.NetUIMessages; >+ >+public class ProxyTestLabelProvider extends BaseLabelProvider implements >+ ITableLabelProvider { >+ >+ private ProxyTester proxyTester; >+ >+ public ProxyTestLabelProvider(ProxyTester proxyTester) { >+ this.proxyTester = proxyTester; >+ } >+ >+ public Image getColumnImage(Object element, int columnIndex) { >+ return null; >+ } >+ >+ public String getColumnText(Object element, int columnIndex) { >+ if (element == null) { >+ return null; >+ } >+ IProxyTestProvider provider = (IProxyTestProvider) element; >+ switch (columnIndex) { >+ case 0: >+ return provider.getProvider(); >+ case 1: >+ return provider.getDescription(); >+ case 2: >+ if (!proxyTester.hasPerformed(provider)) { >+ return null; >+ } >+ if (proxyTester.getResult(provider) == IStatus.OK) { >+ return NetUIMessages.ProxyTestDialog_6; >+ } else { >+ return NetUIMessages.ProxyTestDialog_7; >+ } >+ default: >+ return null; >+ } >+ } >+ >+ public boolean isLabelProperty(Object element, String property) { >+ return false; >+ } >+ >+ public void createColumns(TableViewer viewer) { >+ String[] titles = { >+ NetUIMessages.ProxyTestDialog_1, >+ NetUIMessages.ProxyTestDialog_2, >+ NetUIMessages.ProxyTestDialog_3, >+ }; >+ for (int i = 0; i < titles.length; i++) { >+ TableColumn column = new TableViewerColumn(viewer, SWT.NONE).getColumn(); >+ column.setText(titles[i]); >+ column.setResizable(true); >+ } >+ } >+ >+} >\ No newline at end of file >Index: src/org/eclipse/ui/internal/net/test/ProxyTester.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/net/test/ProxyTester.java >diff -N src/org/eclipse/ui/internal/net/test/ProxyTester.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/net/test/ProxyTester.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.net.test; >+ >+import java.util.HashMap; >+import java.util.Map; >+import java.util.Set; >+ >+import org.eclipse.core.internal.net.Activator; >+import org.eclipse.core.net.proxy.IProxyTestProvider; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Platform; >+ >+public class ProxyTester { >+ >+ private static final String EXTENSION_NAME = "org.eclipse.core.net.proxyTester"; //$NON-NLS-1$ >+ >+ private Map providers = new HashMap(); >+ >+ public void execute(IProxyTestProvider provider, String host) { >+ IStatus status = provider.testConnection(host); >+ providers.put(provider, status); >+ } >+ >+ public void initialize() { >+ providers.clear(); >+ IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(EXTENSION_NAME); >+ for (int i = 0; i < extensions.length; i++) { >+ try { >+ Object object = extensions[i].createExecutableExtension("class"); //$NON-NLS-1$ >+ if (object instanceof IProxyTestProvider) { >+ providers.put(object, null); >+ } >+ } catch (CoreException e) { >+ Activator.logError("Cannot initialize proxy tester", e); //$NON-NLS-1$ >+ } >+ } >+ } >+ >+ public Set getTestProviders() { >+ return providers.keySet(); >+ } >+ >+ public boolean hasPerformed(IProxyTestProvider provider) { >+ return providers.get(provider) != null; >+ } >+ >+ public int getResult(IProxyTestProvider provider) { >+ if (hasPerformed(provider)) { >+ IStatus status = (IStatus) providers.get(provider); >+ return status.getSeverity(); >+ } >+ return -1; >+ } >+ >+ public Throwable getError(IProxyTestProvider provider) { >+ if (hasPerformed(provider)) { >+ IStatus status = (IStatus) providers.get(provider); >+ return status.getException(); >+ } >+ return null; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 299020
:
155480
|
177936
| 183463