Author: xcoulon
Date: 2012-04-26 05:53:37 -0400 (Thu, 26 Apr 2012)
New Revision: 40512
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingActionProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/OpenShiftSshSessionFactory.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTab.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTabGroup.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationDebuggingLaunchConfigurationDelegate.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/openshift-java-client-2.0.0-SNAPSHOT-sources.jar
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/openshift-java-client-2.0.0-SNAPSHOT.jar
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
Log:
Fixed - JBIDE-11073
OpenShift Express Tool: Create a way to invoke rhc-port-forward functionality which
enables users to debug their cloud environments with their local tools
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath 2012-04-26
09:38:03 UTC (rev 40511)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath 2012-04-26
09:53:37 UTC (rev 40512)
@@ -3,7 +3,7 @@
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry exported="true" kind="lib"
path="openshift-java-client-2.0.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib"
path="openshift-java-client-2.0.0-SNAPSHOT.jar"
sourcepath="/openshift-java-client"/>
<classpathentry kind="lib" path="jboss-dmr-1.0.0.Final.jar"/>
<classpathentry kind="lib" path="log4j-1.2.16.jar"/>
<classpathentry kind="lib" path="slf4j-api-1.6.1.jar"/>
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/openshift-java-client-2.0.0-SNAPSHOT-sources.jar
===================================================================
(Binary files differ)
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/openshift-java-client-2.0.0-SNAPSHOT.jar
===================================================================
(Binary files differ)
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2012-04-26
09:38:03 UTC (rev 40511)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/META-INF/MANIFEST.MF 2012-04-26
09:53:37 UTC (rev 40512)
@@ -42,7 +42,9 @@
org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.200",
org.jboss.ide.eclipse.archives.webtools;bundle-version="2.3.0",
org.eclipse.equinox.security;bundle-version="1.1.1",
- org.jboss.ide.eclipse.as.dmr;bundle-version="2.3.0"
+ org.jboss.ide.eclipse.as.dmr;bundle-version="2.3.0",
+ org.eclipse.jsch.ui;bundle-version="1.1.300",
+ org.eclipse.jdt.debug.ui;bundle-version="3.6.1"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.jboss.tools.common.databinding,
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-04-26
09:38:03 UTC (rev 40511)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-04-26
09:53:37 UTC (rev 40512)
@@ -162,7 +162,7 @@
<viewerActionBinding
viewerId="org.eclipse.wst.server.ui.ServersView">
<includes>
<actionExtension
-
pattern="org.jboss.tools.openshift.express.ui.internal.ui.console.tailServerLogActionProvider"/>
+
pattern="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.tailServerLogActionProvider"/>
</includes>
</viewerActionBinding>
</extension>
@@ -329,6 +329,8 @@
<includes>
<actionExtension
pattern="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.*"/>
+ <actionExtension
+
pattern="org.jboss.tools.openshift.express.internal.core.portforward.applicationPortForwardActionProvider"/>
</includes>
</viewerActionBinding>
<viewerContentBinding
@@ -347,7 +349,7 @@
contentProvider="org.jboss.tools.openshift.express.internal.ui.viewer.OpenShiftExpressConsoleContentProvider"
id="org.jboss.tools.openshift.express.ui.viewer.expressConsoleContent"
labelProvider="org.jboss.tools.openshift.express.internal.ui.viewer.OpenShiftExpressConsoleLabelProvider"
- name="OpenShift Express Console Content">
+ name="OpenShift Explorer Content">
<triggerPoints></triggerPoints>
</navigatorContent>
<actionProvider
@@ -402,7 +404,7 @@
<instanceof
value="com.openshift.client.IApplication">
</instanceof>
- </and>
+ </and>
</enablement>
</actionProvider>
<actionProvider
@@ -417,6 +419,18 @@
</enablement>
</actionProvider>
<actionProvider
+
class="org.jboss.tools.openshift.express.internal.core.portforward.ApplicationPortForwardingActionProvider"
+
id="org.jboss.tools.openshift.express.internal.core.portforward.applicationPortForwardActionProvider">
+ <enablement>
+ <and>
+ <instanceof
+ value="com.openshift.client.IApplication">
+ </instanceof>
+ </and>
+ </enablement>
+ </actionProvider>
+
+ <actionProvider
class="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.EditCartridgesActionProvider"
id="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.editCartridgesActionProvider">
<enablement>
@@ -529,6 +543,45 @@
</adapter>
</factory>
</extension>
+ <!-- Launch configuration type to debug remote openshift applications. Not fully
implemented yet... -->
+ <!--extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+
delegate="org.jboss.tools.openshift.express.internal.core.portforward.RemoteOpenShiftApplicationDebuggingLaunchConfigurationDelegate"
+ delegateName="Remote OpenShift Application "
+ id="org.jboss.tools.openshift.launchDebugConfigurationType"
+ modes="debug"
+ name="Remote OpenShift Application "
+ public="true">
+ </launchConfigurationType>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+
configTypeID="org.jboss.tools.openshift.launchDebugConfigurationType"
+ icon="icons/openshift-logo-white-icon.png"
+
id="org.jboss.tools.openshift.launchDebugConfigurationTypeImage">
+ </launchConfigurationTypeImage>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+
class="org.jboss.tools.openshift.express.internal.core.portforward.RemoteOpenShiftApplicationConfigurationTabGroup"
+ id="org.jboss.tools.openshift.launchDebugConfigurationTabGroup"
+
type="org.jboss.tools.openshift.launchDebugConfigurationType">
+ </launchConfigurationTabGroup>
+ </extension -->
+
+ <!--extension
+ point="org.eclipse.debug.core.launchDelegates">
+ <launchDelegate
+
delegate="org.jboss.tools.openshift.express.internal.core.portforward.RemoteOpenShiftApplicationDebuggingLaunchConfigurationDelegate"
+ id="org.jboss.tools.openshift.express.ui.launchDelegate2"
+ modes="debug"
+ name="Remote OpenShift application"
+
type="org.jboss.tools.openshift.launchDebugConfigurationType">
+ </launchDelegate>
+ </extension-->
<!-- when using the new 'tabbed' properties view. -->
<!--extension
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingAction.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingAction.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingAction.java 2012-04-26
09:53:37 UTC (rev 40512)
@@ -0,0 +1,43 @@
+package org.jboss.tools.openshift.express.internal.core.portforward;
+
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.openshift.express.internal.ui.action.AbstractAction;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+
+import com.openshift.client.IApplication;
+
+public class ApplicationPortForwardingAction extends AbstractAction {
+
+ public ApplicationPortForwardingAction() {
+ super("Port forwarding...",
DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_LCL_DISCONNECT));
+ }
+ /**
+ * Operation called when the user clicks on 'Show In>Remote Console'. If no
Console/Worker existed, a new one is
+ * created, otherwise, it is displayed. {@inheritDoc}
+ */
+ @Override
+ public void run() {
+ if (selection != null && selection instanceof ITreeSelection ) {
+ Object sel = ((ITreeSelection)selection).getFirstElement();
+ if( sel instanceof IApplication) {
+ IApplication application = (IApplication)sel;
+ try {
+ //TitleD
+ ApplicationPortForwardingWizard wizard = new
ApplicationPortForwardingWizard(application);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(),
wizard);
+ dialog.setMinimumPageSize(700, 300);
+ dialog.create();
+ dialog.open();
+ } catch (Exception e) {
+ Logger.error("Failed to perform 'port-forwarding' for application
'" + application.getName() + "'", e);
+ }
+ }
+ }
+ }
+
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingActionProvider.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingActionProvider.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingActionProvider.java 2012-04-26
09:53:37 UTC (rev 40512)
@@ -0,0 +1,10 @@
+package org.jboss.tools.openshift.express.internal.core.portforward;
+
+import
org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.AbstractActionProvider;
+
+public class ApplicationPortForwardingActionProvider extends AbstractActionProvider {
+
+ public ApplicationPortForwardingActionProvider() {
+ super(new ApplicationPortForwardingAction(), "group.showIn");
+ }
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingActionProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizard.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizard.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizard.java 2012-04-26
09:53:37 UTC (rev 40512)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core.portforward;
+
+import org.eclipse.jface.wizard.Wizard;
+
+import com.openshift.client.IApplication;
+
+
+/**
+ * @author Xavier Coulon
+ *
+ */
+public class ApplicationPortForwardingWizard extends Wizard {
+
+ private ApplicationPortForwardingWizardModel wizardModel;
+
+ public ApplicationPortForwardingWizard(IApplication application) {
+ this.wizardModel = new ApplicationPortForwardingWizardModel(application);
+ setNeedsProgressMonitor(true);
+ }
+
+ @Override
+ public boolean performFinish() {
+ return false;
+ }
+
+ @Override
+ public void addPages() {
+ addPage(new ApplicationPortForwardingWizardPage(wizardModel, this));
+ }
+
+ public IApplication getApplication() {
+ return wizardModel.getApplication();
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizard.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardModel.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardModel.java 2012-04-26
09:53:37 UTC (rev 40512)
@@ -0,0 +1,79 @@
+package org.jboss.tools.openshift.express.internal.core.portforward;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.jboss.tools.common.databinding.ObservablePojo;
+
+import com.jcraft.jsch.JSchException;
+import com.openshift.client.IApplication;
+import com.openshift.client.IApplicationPortForwarding;
+import com.openshift.client.OpenShiftSSHOperationException;
+
+public class ApplicationPortForwardingWizardModel extends ObservablePojo {
+
+ public static final String PROPERTY_USE_DEFAULT_LOCAL_IP_ADDRESS =
"useDefaultLocalIpAddress";
+
+ public static final String PROPERTY_FORWARDABLE_PORTS = "forwardablePorts";
+
+ private Boolean useDefaultLocalIpAddress = Boolean.TRUE;
+
+ private final IApplication application;
+
+ public ApplicationPortForwardingWizardModel(final IApplication application) {
+ this.application = application;
+ }
+
+ /**
+ * @return the application
+ */
+ public final IApplication getApplication() {
+ return application;
+ }
+
+ /**
+ * @return the useDefaultLocalIpAddress
+ */
+ public final Boolean getUseDefaultLocalIpAddress() {
+ return useDefaultLocalIpAddress;
+ }
+
+
+ public List<IApplicationPortForwarding> getForwardablePorts() throws
OpenShiftSSHOperationException {
+ return application.getForwardablePorts();
+ }
+
+ /**
+ * @param useDefaultLocalIpAddress the useDefaultLocalIpAddress to set
+ * @throws IOException
+ * @throws JSchException
+ */
+ public final void setUseDefaultLocalIpAddress(final Boolean useDefaultLocalIpAddress)
throws OpenShiftSSHOperationException {
+ updateLocalBindingValues(useDefaultLocalIpAddress);
+ firePropertyChange(PROPERTY_USE_DEFAULT_LOCAL_IP_ADDRESS,
this.useDefaultLocalIpAddress,
+ this.useDefaultLocalIpAddress = useDefaultLocalIpAddress);
+ }
+
+ private void updateLocalBindingValues(final boolean useLocalIpAddress) throws
OpenShiftSSHOperationException {
+ for (IApplicationPortForwarding port : application.getForwardablePorts()) {
+ port.setLocalAddress(useLocalIpAddress ? "127.0.0.1" :
port.getRemoteAddress());
+ if (port.getLocalPort() == null) {
+ port.setLocalPort(port.getRemotePort());
+ }
+ }
+ }
+
+ public void loadForwardablePorts() throws OpenShiftSSHOperationException {
+ getApplication().getForwardablePorts();
+ refreshForwardablePorts();
+ }
+
+ public void refreshForwardablePorts() throws OpenShiftSSHOperationException {
+ application.refreshForwardablePorts();
+ updateLocalBindingValues(this.useDefaultLocalIpAddress);
+ }
+
+
+
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardModel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardPage.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardPage.java 2012-04-26
09:53:37 UTC (rev 40512)
@@ -0,0 +1,337 @@
+package org.jboss.tools.openshift.express.internal.core.portforward;
+
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.BeanProperties;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.databinding.observable.value.IValueChangeListener;
+import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jgit.transport.URIish;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+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.Table;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+import org.jboss.tools.openshift.express.internal.ui.wizard.AbstractOpenShiftWizardPage;
+
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Session;
+import com.openshift.client.IApplication;
+import com.openshift.client.IApplicationPortForwarding;
+import com.openshift.client.OpenShiftSSHOperationException;
+
+public class ApplicationPortForwardingWizardPage extends AbstractOpenShiftWizardPage {
+
+ private final ApplicationPortForwardingWizardModel wizardModel;
+
+ private TableViewer viewer;
+
+ private Button refreshButton;
+
+ private Button startButton;
+
+ private Button stopButton;
+
+ public ApplicationPortForwardingWizardPage(final ApplicationPortForwardingWizardModel
wizardModel,
+ final ApplicationPortForwardingWizard applicationPortForwardingWizard) {
+ super("Application port forward", "Please configure port forwarding for
your application",
+ "IApplicationPortForwardingingPage", applicationPortForwardingWizard);
+ this.wizardModel = wizardModel;
+ }
+
+ @Override
+ protected void doCreateControls(Composite parent, DataBindingContext dbc) {
+ GridLayoutFactory.fillDefaults().margins(6, 6).applyTo(parent);
+ Composite container = new Composite(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
true).applyTo(container);
+ GridLayoutFactory.fillDefaults().numColumns(2).applyTo(container);
+
+ Composite tableContainer = new Composite(container, SWT.NONE);
+ this.viewer = createTable(tableContainer);
+ GridDataFactory.fillDefaults().span(1, 3).align(SWT.FILL, SWT.FILL).grab(true,
true).applyTo(tableContainer);
+ // viewer.addSelectionChangedListener(onTableSelectionChanged());
+
+ refreshButton = new Button(container, SWT.PUSH);
+ refreshButton.setText("Refresh");
+ GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).align(SWT.FILL,
SWT.TOP).applyTo(refreshButton);
+ refreshButton.addSelectionListener(onRefreshPorts());
+
+ /*
+ * Button editButton = new Button(container, SWT.PUSH);
editButton.setText("Edit...");
+ * GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).align(SWT.FILL,
SWT.TOP).applyTo(editButton); //
+ * checkAllButton.addSelectionListener(onCheckAll());
+ */
+
+ startButton = new Button(container, SWT.PUSH);
+ startButton.setText("Start All");
+ startButton.setEnabled(true);
+ GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).align(SWT.FILL,
SWT.TOP).applyTo(startButton);
+ startButton.addSelectionListener(onStartPortForwarding());
+
+ stopButton = new Button(container, SWT.PUSH);
+ stopButton.setText("Stop All");
+ stopButton.setEnabled(true);
+ GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).align(SWT.FILL,
SWT.TOP).applyTo(stopButton);
+ stopButton.addSelectionListener(onStopPortForwarding());
+
+ // checkbox to use the default "127.0.0.1" local IP address
+ Button useLocalIpAddressButton = new Button(container, SWT.CHECK);
+ useLocalIpAddressButton.setText("Use '127.0.0.1' as the local address for
all ports");
+ GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(false,
false)
+ .applyTo(useLocalIpAddressButton);
+ IObservableValue useLocalIpAddressObservable = BeanProperties.value(
+ ApplicationPortForwardingWizardModel.PROPERTY_USE_DEFAULT_LOCAL_IP_ADDRESS).observe(wizardModel);
+ final IObservableValue useLocalIpAddressButtonSelection =
WidgetProperties.selection().observe(
+ useLocalIpAddressButton);
+ dbc.bindValue(useLocalIpAddressButtonSelection, useLocalIpAddressObservable);
+ useLocalIpAddressObservable.addValueChangeListener(new IValueChangeListener() {
+ @Override
+ public void handleValueChange(ValueChangeEvent event) {
+ refreshViewerInput();
+ }
+ });
+ }
+
+ /*
+ * private ISelectionChangedListener onTableSelectionChanged() { return new
ISelectionChangedListener() {
+ * @Override public void selectionChanged(SelectionChangedEvent event) { final
IStructuredSelection selection =
+ * (IStructuredSelection) event.getSelection(); IApplicationPortForwarding portForward
=
+ * (IApplicationPortForwarding) selection.getFirstElement(); if
(portForward.isStarted()) {
+ * enableButton.setEnabled(false); disableButton.setEnabled(true); } else {
enableButton.setEnabled(true);
+ * disableButton.setEnabled(false); } } }; }
+ */
+
+ private SelectionListener onRefreshPorts() {
+ return new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ WizardUtils.runInWizard(new Job("Refresh lis of ports...") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ wizardModel.refreshForwardablePorts();
+ refreshViewerInput();
+ } catch (Exception e) {
+ Logger.error("Failed to refresh list of ports", e);
+ }
+ return Status.OK_STATUS;
+ }
+ }, getContainer(), getDataBindingContext());
+ } catch (Exception exception) {
+ // ignore
+ }
+ }
+ };
+ }
+
+ private SelectionListener onStartPortForwarding() {
+ return new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ WizardUtils.runInWizard(new Job("Starting Port-forwarding...") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ verifyApplicationSSHSession();
+ wizardModel.getApplication().startPortForwarding();
+ wizardModel.getApplication().getForwardablePorts();
+ refreshViewerInput();
+ } catch (Exception e) {
+ Logger.error("Failed to start port-forwarding", e);
+ }
+ return Status.OK_STATUS;
+ }
+ }, getContainer(), getDataBindingContext());
+ } catch (Exception exception) {
+ // ignore
+ }
+ }
+ };
+ }
+
+ static URIish getSshUri(IApplication application) {
+ final String host = application.getName() + "-" +
application.getDomain().getId() + "."
+ + application.getDomain().getSuffix();
+ final String user = application.getUUID();
+ final URIish uri = new URIish().setHost(host).setPort(22).setUser(user);
+ return uri;
+ }
+
+ private SelectionListener onStopPortForwarding() {
+ return new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ WizardUtils.runInWizard(new Job("Stoppping Port-forwarding...") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ verifyApplicationSSHSession();
+ wizardModel.getApplication().stopPortForwarding();
+ refreshViewerInput();
+ } catch (Exception e) {
+ Logger.error("Failed to stop Port-forwarding", e);
+ }
+ return Status.OK_STATUS;
+ }
+ }, getContainer(), getDataBindingContext());
+ } catch (Exception exception) {
+ // ignore
+ }
+ }
+ };
+ }
+
+ protected TableViewer createTable(Composite tableContainer) {
+ Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL
| SWT.H_SCROLL);
+ table.setLinesVisible(true);
+ table.setHeaderVisible(true);
+ TableColumnLayout tableLayout = new TableColumnLayout();
+ tableContainer.setLayout(tableLayout);
+ TableViewer viewer = new TableViewer(table);
+ // viewer.setComparer(new EqualityComparer());
+ viewer.setContentProvider(new ArrayContentProvider());
+
+ createTableColumn("Service", 1, new CellLabelProvider() {
+ @Override
+ public void update(ViewerCell cell) {
+ IApplicationPortForwarding port = (IApplicationPortForwarding) cell.getElement();
+ cell.setText(port.getName());
+ }
+
+ }, viewer, tableLayout);
+
+ createTableColumn("Local Address", 2, new CellLabelProvider() {
+ @Override
+ public void update(ViewerCell cell) {
+ IApplicationPortForwarding port = (IApplicationPortForwarding) cell.getElement();
+ cell.setText(port.getLocalAddress());
+ }
+ }, viewer, tableLayout);
+
+ createTableColumn("Local Port", 2, new CellLabelProvider() {
+ @Override
+ public void update(ViewerCell cell) {
+ IApplicationPortForwarding port = (IApplicationPortForwarding) cell.getElement();
+ cell.setText(port.getLocalPort());
+ }
+ }, viewer, tableLayout);
+
+ createTableColumn("Remote Address", 2, new CellLabelProvider() {
+ @Override
+ public void update(ViewerCell cell) {
+ IApplicationPortForwarding port = (IApplicationPortForwarding) cell.getElement();
+ cell.setText(port.getRemoteAddress());
+ }
+ }, viewer, tableLayout);
+
+ createTableColumn("Remote Port", 2, new CellLabelProvider() {
+ @Override
+ public void update(ViewerCell cell) {
+ IApplicationPortForwarding port = (IApplicationPortForwarding) cell.getElement();
+ cell.setText(port.getRemotePort());
+ }
+ }, viewer, tableLayout);
+
+ createTableColumn("Status", 1, new CellLabelProvider() {
+
+ @Override
+ public void update(ViewerCell cell) {
+ IApplicationPortForwarding port = (IApplicationPortForwarding) cell.getElement();
+ try {
+ final boolean started =
port.isStarted(wizardModel.getApplication().getSSHSession());
+ cell.setText(started ? "Enabled" : "Disabled");
+ } catch (OpenShiftSSHOperationException e) {
+ cell.setText("Unknown");
+ }
+ }
+ }, viewer, tableLayout);
+
+ return viewer;
+ }
+
+ private void createTableColumn(String name, int weight, CellLabelProvider
cellLabelProvider, TableViewer viewer,
+ TableColumnLayout layout) {
+ TableViewerColumn column = new TableViewerColumn(viewer, SWT.LEFT);
+ column.getColumn().setText(name);
+ column.setLabelProvider(cellLabelProvider);
+ layout.setColumnData(column.getColumn(), new ColumnWeightData(weight, true));
+ }
+
+ @Override
+ protected void onPageActivated(DataBindingContext dbc) {
+ try {
+ WizardUtils.runInWizard(new Job("Retrieving application's forwardable
ports...") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ monitor.beginTask("Checking Application SSH session...", 1);
+ verifyApplicationSSHSession();
+ monitor.worked(1);
+ monitor.beginTask("Retrieving ports...", 1);
+ wizardModel.loadForwardablePorts();
+ refreshViewerInput();
+ monitor.worked(1);
+ return Status.OK_STATUS;
+ } catch (Exception e) {
+ return OpenShiftUIActivator.createErrorStatus("Could not load forwardable
ports for application", e);
+ }
+ }
+
+
+ }, getContainer(), getDataBindingContext());
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ /**
+ * @param monitor
+ * @throws JSchException
+ */
+ private void verifyApplicationSSHSession() throws JSchException {
+ final boolean hasSSHSession = wizardModel.getApplication().hasSSHSession();
+ if(!hasSSHSession) {
+ Logger.info("Opening a new SSH Session for application '" +
wizardModel.getApplication().getName() + "'");
+ final Session session = OpenShiftSshSessionFactory.getInstance().createSession(
+ getSshUri(wizardModel.getApplication()));
+ wizardModel.getApplication().setSSHSession(session);
+ }
+ }
+
+ private void refreshViewerInput() {
+ getShell().getDisplay().syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ viewer.setInput(wizardModel.getForwardablePorts());
+ } catch (Exception e) {
+ Logger.error("Failed to refresh table content with list of ports for selected
application", e);
+ }
+ }
+ });
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingWizardPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/OpenShiftSshSessionFactory.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/OpenShiftSshSessionFactory.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/OpenShiftSshSessionFactory.java 2012-04-26
09:53:37 UTC (rev 40512)
@@ -0,0 +1,131 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core.portforward;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider;
+import org.eclipse.jgit.transport.CredentialsProviderUserInfo;
+import org.eclipse.jgit.transport.JschConfigSessionFactory;
+import org.eclipse.jgit.transport.OpenSshConfig;
+import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.util.FS;
+import org.eclipse.jsch.core.IJSchService;
+import org.eclipse.jsch.ui.UserInfoPrompter;
+import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.console.JschToEclipseLogger;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Session;
+import com.jcraft.jsch.UserInfo;
+
+/**
+ * Same as EclipseSshSessinFactory, but provides a mean to retrieve the pure Jsch
Session, not a RemoteSession.
+ *
+ * @author Xavier Coulon
+ *
+ */
+public class OpenShiftSshSessionFactory extends JschConfigSessionFactory {
+
+ private static OpenShiftSshSessionFactory INSTANCE = new OpenShiftSshSessionFactory();
+
+ /**
+ * Get the currently configured JVM-wide factory.
+ * <p>
+ * A factory is always available. By default the factory will read from the user's
<code>$HOME/.ssh</code> and
+ * assume OpenSSH compatibility.
+ *
+ * @return factory the current factory for this JVM.
+ */
+ public static OpenShiftSshSessionFactory getInstance() {
+ return INSTANCE;
+ }
+
+ private final IJSchService provider;
+
+ private OpenSshConfig config;
+
+ private final Map<URIish, Session> cache = new HashMap<URIish, Session>();
+
+ OpenShiftSshSessionFactory() {
+ final BundleContext context =
OpenShiftUIActivator.getDefault().getBundle().getBundleContext();
+ final ServiceReference<?> ssh =
context.getServiceReference(IJSchService.class.getName());
+ this.provider = (IJSchService) context.getService(ssh);
+ }
+
+ public Session createSession(final URIish uri) throws JSchException {
+ final Session session = cache.get(uri);
+ if (session == null || !session.isConnected()) {
+ final FS fs = FS.DETECTED;
+ if (config == null) {
+ config = OpenSshConfig.get(fs);
+ }
+ String user = uri.getUser();
+ String host = uri.getHost();
+ int port = uri.getPort();
+ JSch.setLogger(new JschToEclipseLogger());
+ final OpenSshConfig.Host hc = config.lookup(host);
+ cache.put(uri, createSession(hc, user, host, port, fs));
+ }
+ return cache.get(uri);
+ }
+
+ @Override
+ protected Session createSession(final OpenSshConfig.Host hc, final String user, final
String host, final int port,
+ FS fs) throws JSchException {
+ final JSch jsch = getJSch(hc, FS.DETECTED);
+ if (jsch == provider.getJSch()) {
+ // If its the default JSch desired, let the provider
+ // manage the session creation for us.
+ //
+ final Session session = provider.createSession(host, port, user);
+ configure(hc, session);
+ session.connect();
+ return session;
+ } else {
+ // This host configuration is using a different IdentityFile,
+ // one that is not available through the default JSch.
+ //
+ final Session session = jsch.getSession(user, host, port);
+ configure(hc, session);
+ session.connect(0);
+ return session;
+ }
+ }
+
+ @Override
+ protected JSch createDefaultJSch(FS fs) throws JSchException {
+ // Forcing a dummy session to be created will cause the known hosts
+ // and configured private keys to be initialized. This is needed by
+ // our parent class in case non-default JSch instances need to be made.
+ //
+ provider.createSession("127.0.0.1", 0, "eclipse"); //$NON-NLS-1$
//$NON-NLS-2$
+ return provider.getJSch();
+ }
+
+ @Override
+ protected void configure(final OpenSshConfig.Host hc, final Session session) {
+ final EGitCredentialsProvider credentialsProvider = new EGitCredentialsProvider();
+ if ((!hc.isBatchMode() || !credentialsProvider.isInteractive())) {
+ session.setUserInfo(new CredentialsProviderUserInfo(session, credentialsProvider));
+ } else {
+ UserInfo userInfo = session.getUserInfo();
+
+ if (!hc.isBatchMode() && userInfo == null)
+ new UserInfoPrompter(session);
+ }
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/OpenShiftSshSessionFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTab.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTab.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTab.java 2012-04-26
09:53:37 UTC (rev 40512)
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core.portforward;
+
+import java.net.SocketTimeoutException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab;
+import org.eclipse.jdt.internal.debug.ui.launcher.AbstractJavaMainTab;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+import org.jboss.tools.openshift.express.internal.core.console.UserModel;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+
+import com.openshift.client.IApplication;
+import com.openshift.client.OpenShiftException;
+
+/**
+ * @author Xavier Coulon
+ *
+ */
+public class RemoteOpenShiftApplicationConfigurationTab extends
AbstractLaunchConfigurationTab {
+
+ public static final String LAUNCH_CONFIG_PROJECT = "project";
+
+ public static final String LAUNCH_CONFIG_APPLICATION = "application";
+
+ private Text projectNameText;
+
+ private Text applicationNameText;
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NONE);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
true).applyTo(container);
+ setControl(container);
+ GridLayoutFactory.fillDefaults().margins(10, 10).applyTo(container);
+ GridLayoutFactory.fillDefaults().numColumns(1).applyTo(container);
+ createApplicationSelector(container);
+ createProjectSelector(container);
+ }
+
+ private void createProjectSelector(Composite container) {
+ Group projectGroup = new Group(container, SWT.NONE);
+ projectGroup.setText("Project");
+ GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 10).applyTo(projectGroup);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(projectGroup);
+ this.projectNameText = new Text(projectGroup, SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true,
true).applyTo(projectNameText);
+ projectNameText.addModifyListener(new ModifyListener() {
+
+ @Override
+ public void modifyText(ModifyEvent e) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+
+ }
+
+ /**
+ * Updates the buttons and message in this page's launch configuration dialog.
+ */
+ protected void updateLaunchConfigurationDialog() {
+ if (getLaunchConfigurationDialog() != null) {
+ // order is important here due to the call to
+ // refresh the tab viewer in updateButtons()
+ // which ensures that the messages are up to date
+ getLaunchConfigurationDialog().updateButtons();
+ getLaunchConfigurationDialog().updateMessage();
+ }
+ }
+
+ private void createApplicationSelector(Composite container) {
+ Group projectGroup = new Group(container, SWT.NONE);
+ projectGroup.setText("Application");
+ GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 10).applyTo(projectGroup);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true,
false).applyTo(projectGroup);
+ this.applicationNameText = new Text(projectGroup, SWT.BORDER);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true,
true).applyTo(applicationNameText);
+
+ }
+
+ @Override
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ projectNameText.setText(configuration.getAttribute(LAUNCH_CONFIG_PROJECT,
""));
+ applicationNameText.setText(configuration.getAttribute(LAUNCH_CONFIG_APPLICATION,
""));
+ } catch (CoreException e) {
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#canSave()
+ */
+ @Override
+ public boolean canSave() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.debug.ui.AbstractLaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ @Override
+ public boolean isValid(ILaunchConfiguration launchConfig) {
+ return isValidProject() && isValidApplication();
+ }
+
+ /**
+ * @return true is the projectNameText value is an existing & opened Eclipse project
in the workspace, false
+ * otherwise.
+ */
+ private boolean isValidProject() {
+ final String projectName = projectNameText.getText();
+ if (projectName == null || projectName.isEmpty()) {
+ return false;
+ }
+ final IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ return project != null && project.exists() && project.isOpen();
+ }
+
+ /**
+ * @return true is the projectNameText value is an existing & opened Eclipse project
in the workspace, false
+ * otherwise.
+ */
+ private boolean isValidApplication() {
+ final String applicationName = applicationNameText.getText();
+ if (applicationName == null || applicationName.isEmpty()) {
+ return false;
+ }
+ try {
+ for (UserDelegate user : UserModel.getDefault().getUsers()) {
+ final IApplication application = user.getApplicationByName(applicationName);
+ if (application != null) {
+ return true;
+ }
+ }
+ } catch (OpenShiftException e) {
+ Logger.error("Failed to retrieve applications from user", e);
+ } catch (SocketTimeoutException e) {
+ Logger.error("Failed to retrieve applications from user", e);
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#isDirty()
+ */
+ @Override
+ protected boolean isDirty() {
+ return true;
+ }
+
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy config) {
+ config.setAttribute(LAUNCH_CONFIG_PROJECT, projectNameText.getText());
+ config.setAttribute(LAUNCH_CONFIG_APPLICATION, applicationNameText.getText());
+
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME,
projectNameText.getText().trim());
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, false);
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR,
JavaRuntime.getVMConnector("org.eclipse.jdt.launching.socketAttachConnector").getIdentifier());
// see org.eclipse.jdt.launching plugin.xml for values
+ //mapResources(config);
+ Map attrMap = new HashMap();
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, attrMap);
+
+ }
+
+ @Override
+ public String getName() {
+ return "Connect";
+ }
+
+ @Override
+ public Image getImage() {
+ return DebugUITools.getImage(IDebugUIConstants.IMG_LCL_DISCONNECT);
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTab.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTabGroup.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTabGroup.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTabGroup.java 2012-04-26
09:53:37 UTC (rev 40512)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core.portforward;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
+
+/**
+ * @author Xavier Coulon
+ *
+ */
+public class RemoteOpenShiftApplicationConfigurationTabGroup extends
AbstractLaunchConfigurationTabGroup {
+
+ @Override
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new RemoteOpenShiftApplicationConfigurationTab(),
+ new CommonTab()
+ };
+ setTabs(tabs);
+
+ }
+
+
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTabGroup.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationDebuggingLaunchConfigurationDelegate.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationDebuggingLaunchConfigurationDelegate.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationDebuggingLaunchConfigurationDelegate.java 2012-04-26
09:53:37 UTC (rev 40512)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.core.portforward;
+
+import java.io.IOException;
+import java.net.SocketTimeoutException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import
org.eclipse.jdt.internal.launching.JavaRemoteApplicationLaunchConfigurationDelegate;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
+import org.jboss.tools.openshift.express.internal.core.console.UserModel;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+
+import com.openshift.client.IApplication;
+import com.openshift.client.OpenShiftException;
+
+/**
+ * @author Xavier Coulon
+ *
+ */
+public class RemoteOpenShiftApplicationDebuggingLaunchConfigurationDelegate extends
+ JavaRemoteApplicationLaunchConfigurationDelegate {
+
+ public final static String ATTR_CONNECT_HOSTNAME = "hostname"; // see usage in
SocketAttachConnector
+ public final static String ATTR_CONNECT_PORT = "port"; // see usage in
SocketAttachConnector
+
+ /*
+ * (non-Javadoc)
+ * @see
+ *
org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
+ * java.lang.String, org.eclipse.debug.core.ILaunch,
org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch,
IProgressMonitor monitor)
+ throws CoreException {
+ try {
+ monitor.beginTask("Preparing for debugging remote OpenShift application",
1);
+ Map<String, String> argMap =
configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP,
+ (Map) null);
+ if (argMap != null) {
+ final String applicationName = configuration.getAttribute(
+ RemoteOpenShiftApplicationConfigurationTab.LAUNCH_CONFIG_APPLICATION,
"");
+ final IApplication application = lookupApplication(applicationName);
+ /*
+ final ApplicationPortForwardUtil applicationPortsForwarder = new
ApplicationPortForwardUtil();
+ for (ApplicationPortForward port : applicationPortsForwarder.listPorts(application))
{
+ if (port.getRemotePort() == "8787") {
+ final ApplicationPortForward forwardedPort = null;
//applicationPortsForwarder.forwardPort(application, port);
+ argMap.put(ATTR_CONNECT_HOSTNAME, forwardedPort.getLocalAddress());
+ argMap.put(ATTR_CONNECT_PORT, forwardedPort.getLocalPort());
+ }
+ }*/
+
+ }
+ monitor.worked(1);
+ super.launch(configuration, mode, launch, monitor);
+ } catch (Exception e) {
+ Logger.error("Failed to launch debugger for Remote OpenShift Application",
e);
+ }
+ }
+
+ private IApplication lookupApplication(String applicationName) {
+ try {
+ for (UserDelegate user : UserModel.getDefault().getUsers()) {
+ final IApplication application = user.getApplicationByName(applicationName);
+ if (application != null) {
+ return application;
+ }
+ }
+ } catch (OpenShiftException e) {
+ Logger.error("Failed to retrieve applications from user", e);
+ } catch (SocketTimeoutException e) {
+ Logger.error("Failed to retrieve applications from user", e);
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationDebuggingLaunchConfigurationDelegate.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain