JBoss Tools SVN: r41424 - trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-05-25 10:46:57 -0400 (Fri, 25 May 2012)
New Revision: 41424
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java
Log:
removing unused imports
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java 2012-05-25 14:45:47 UTC (rev 41423)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java 2012-05-25 14:46:57 UTC (rev 41424)
@@ -10,23 +10,15 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.action;
-import java.net.SocketTimeoutException;
-
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftImages;
import org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
-import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import org.jboss.tools.openshift.express.internal.ui.wizard.NewOpenShiftExpressApplicationWizard;
import org.jboss.tools.openshift.express.internal.ui.wizard.OpenShiftExpressApplicationWizard;
-import com.openshift.client.IDomain;
-import com.openshift.client.OpenShiftException;
-
/**
* @author Xavier Coulon
*/
12 years, 7 months
JBoss Tools SVN: r41423 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core: portforward and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-05-25 10:45:47 -0400 (Fri, 25 May 2012)
New Revision: 41423
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTabGroup.java
Log:
removing unused imports
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java 2012-05-25 13:58:32 UTC (rev 41422)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java 2012-05-25 14:45:47 UTC (rev 41423)
@@ -14,7 +14,6 @@
import java.util.List;
import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.IWizard;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
Modified: 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 2012-05-25 13:58:32 UTC (rev 41422)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/RemoteOpenShiftApplicationConfigurationTabGroup.java 2012-05-25 14:45:47 UTC (rev 41423)
@@ -14,7 +14,6 @@
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
12 years, 7 months
JBoss Tools SVN: r41422 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui: wizard and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-05-25 09:58:32 -0400 (Fri, 25 May 2012)
New Revision: 41422
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/CreateApplicationJob.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/WaitForApplicationJob.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
Log:
[JBIDE-11314] fixed monitor cancelling
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/CreateApplicationJob.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/CreateApplicationJob.java 2012-05-25 13:55:35 UTC (rev 41421)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/CreateApplicationJob.java 2012-05-25 13:58:32 UTC (rev 41422)
@@ -11,7 +11,6 @@
package org.jboss.tools.openshift.express.internal.ui.job;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -38,7 +37,7 @@
*/
public class CreateApplicationJob extends AbstractDelegatingMonitorJob {
- public static final int CLOSE_WIZARD = 2;
+ public static final int TIMEOUTED_CANCELLED = 1;
private UserDelegate user;
private String name;
@@ -46,7 +45,6 @@
private ApplicationScale scale;
private IGearProfile gear;
private IApplication application;
- private ReentrantLock lock = new ReentrantLock();
public CreateApplicationJob(final String name, final ICartridge cartridge, final ApplicationScale scale,
final IGearProfile gear, UserDelegate user) {
@@ -61,7 +59,6 @@
@Override
protected IStatus doRun(IProgressMonitor monitor) {
try {
- lock.lock();
try {
this.application = user.createApplication(name, cartridge, scale, gear);
} catch (OpenShiftTimeoutException e) {
@@ -69,21 +66,23 @@
}
if (application == null) {
- int errorCode = monitor.isCanceled() ? CLOSE_WIZARD : 0;
+ int errorCode = monitor.isCanceled() ? TIMEOUTED_CANCELLED : 0;
return new Status(IStatus.CANCEL, OpenShiftUIActivator.PLUGIN_ID, errorCode,
NLS.bind("User cancelled creation of application {0}", name), null);
} else {
return Status.OK_STATUS;
}
} catch (Exception e) {
+ safeRefreshDomain();
return OpenShiftUIActivator.createErrorStatus(
OpenShiftExpressUIMessages.COULD_NOT_CREATE_APPLICATION, e, name);
- } finally {
- lock.unlock();
}
}
private IApplication refreshAndCreateApplication(IProgressMonitor monitor) throws OpenShiftException {
+ if (monitor.isCanceled()) {
+ return null;
+ }
IApplication application = null;
do {
try {
@@ -103,14 +102,18 @@
return application;
}
- public IApplication getApplication() {
+ private void safeRefreshDomain() {
try {
- lock.lock();
- return application;
- } finally {
- lock.unlock();
+ IDomain domain = user.getDefaultDomain();
+ domain.refresh();
+ } catch (OpenShiftException e) {
+ OpenShiftUIActivator.log(e);
}
}
+
+ public IApplication getApplication() {
+ return application;
+ }
protected boolean openKeepTryingDialog() {
final AtomicBoolean keepTrying = new AtomicBoolean(false);
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/WaitForApplicationJob.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/WaitForApplicationJob.java 2012-05-25 13:55:35 UTC (rev 41421)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/job/WaitForApplicationJob.java 2012-05-25 13:58:32 UTC (rev 41422)
@@ -32,6 +32,8 @@
*/
public class WaitForApplicationJob extends AbstractDelegatingMonitorJob {
+ public static final int TIMEOUTED_CANCELLED = 1;
+
private static final int APP_REACHABLE_TIMEOUT = 180 * 1000;
private IApplication application;
private Shell shell;
@@ -48,8 +50,12 @@
try {
while (!application.waitForAccessible(APP_REACHABLE_TIMEOUT)) {
if (!openKeepWaitingDialog()) {
- return OpenShiftUIActivator.createCancelStatus(NLS.bind(
- OpenShiftExpressUIMessages.APPLICATION_NOT_ANSWERING, application.getName()));
+ return new Status(
+ IStatus.CANCEL,
+ OpenShiftUIActivator.PLUGIN_ID,
+ TIMEOUTED_CANCELLED,
+ NLS.bind(OpenShiftExpressUIMessages.APPLICATION_NOT_ANSWERING, application.getName()),
+ null);
}
}
} catch (OpenShiftException e) {
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-05-25 13:55:35 UTC (rev 41421)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-05-25 13:58:32 UTC (rev 41422)
@@ -141,42 +141,50 @@
@Override
public boolean performFinish() {
- boolean success = getWizardModel().isUseExistingApplication();
- if (!success) {
+ boolean useExistingApp = getWizardModel().isUseExistingApplication();
+ if (!useExistingApp) {
IStatus status = createApplication();
if (JobUtils.isCancel(status)
- && CreateApplicationJob.CLOSE_WIZARD == status.getCode()) {
- getContainer().getShell().close();
+ && CreateApplicationJob.TIMEOUTED_CANCELLED == status.getCode()) {
+ getContainer().getShell().close();
} else if (!JobUtils.isOk(status)) {
safeRefreshUser();
return false;
}
- if (success = waitForApplication(wizardModel.getApplication())) {
- success = addRemoveCartridges(
- getWizardModel().getApplication(), getWizardModel().getSelectedEmbeddableCartridges());
- } else {
+ status = waitForApplication(wizardModel.getApplication());
+ if (JobUtils.isCancel(status)
+ && WaitForApplicationJob.TIMEOUTED_CANCELLED == status.getCode()) {
getContainer().getShell().close();
+ } else if (!JobUtils.isOk(status)) {
+ safeRefreshUser();
+ return false;
}
+
+ if (!addRemoveCartridges(
+ getWizardModel().getApplication(), getWizardModel().getSelectedEmbeddableCartridges())) {
+ return false;
+ }
}
- if (success) {
- success = importProject();
+ if (useExistingApp) {
+ useExistingApp = importProject();
}
wizardModel.addUserToModel();
- return success;
+ return useExistingApp;
}
- private boolean waitForApplication(IApplication application) {
+ private IStatus waitForApplication(IApplication application) {
try {
AbstractDelegatingMonitorJob job = new WaitForApplicationJob(application, getShell());
IStatus status = WizardUtils.runInWizard(
job, job.getDelegatingProgressMonitor(), getContainer(), APP_WAIT_TIMEOUT);
- return status.isOK();
+ return status;
} catch (Exception e) {
- return false;
+ return OpenShiftUIActivator.createErrorStatus(
+ NLS.bind("Could not wait for application {0} to become reachable", application.getName()), e);
}
}
@@ -197,7 +205,7 @@
try {
CreateApplicationJob job = new CreateApplicationJob(
wizardModel.getApplicationName()
- , wizardModel.getApplicationCartridge()
+ , wizardModel.getApplicationCartridge()
, wizardModel.getApplicationScale()
, wizardModel.getApplicationGearProfile()
, wizardModel.getUser());
@@ -211,19 +219,21 @@
}
}
- private boolean addRemoveCartridges(final IApplication application,final Set<IEmbeddableCartridge> selectedCartridges) {
- try {
- EmbedCartridgesJob job = new EmbedCartridgesJob(
- new ArrayList<IEmbeddableCartridge>(wizardModel.getSelectedEmbeddableCartridges()),
- wizardModel.getApplication());
- IStatus result = WizardUtils.runInWizard(job, job.getDelegatingProgressMonitor(), getContainer(), EMBED_CARTRIDGES_TIMEOUT);
- if (result.isOK()) {
- openLogDialog(job.getAddedCartridges());
- }
- return result.isOK();
- } catch (Exception e) {
- return false;
+ private boolean addRemoveCartridges(final IApplication application,
+ final Set<IEmbeddableCartridge> selectedCartridges) {
+ try {
+ EmbedCartridgesJob job = new EmbedCartridgesJob(
+ new ArrayList<IEmbeddableCartridge>(wizardModel.getSelectedEmbeddableCartridges()),
+ wizardModel.getApplication());
+ IStatus result = WizardUtils.runInWizard(job, job.getDelegatingProgressMonitor(), getContainer(),
+ EMBED_CARTRIDGES_TIMEOUT);
+ if (result.isOK()) {
+ openLogDialog(job.getAddedCartridges());
}
+ return result.isOK();
+ } catch (Exception e) {
+ return false;
+ }
}
private void openLogDialog(final List<IEmbeddedCartridge> embeddableCartridges) {
@@ -247,7 +257,7 @@
OpenShiftUIActivator.log(e);
}
}
-
+
/**
* A workspace job that will create a new project or enable the selected
* project to be used with OpenShift.
12 years, 7 months
JBoss Tools SVN: r41421 - trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2012-05-25 09:55:35 -0400 (Fri, 25 May 2012)
New Revision: 41421
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java
Log:
[JBIDE-11314] fixed monitor cancelling
Modified: trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java 2012-05-25 13:54:21 UTC (rev 41420)
+++ trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java 2012-05-25 13:55:35 UTC (rev 41421)
@@ -144,16 +144,21 @@
private static void waitForFuture(long timeout, JobResultFuture future, IProgressMonitor monitor)
throws InterruptedException, ExecutionException, TimeoutException {
long startTime = System.currentTimeMillis();
- while (!future.isDone()
- && (System.currentTimeMillis() - startTime) < timeout) {
- if (monitor.isCanceled()) {
+ while (!future.isDone()) {
+ if (isTimeouted(startTime, timeout)
+ || monitor.isCanceled()) {
future.cancel(true);
break;
}
+
Thread.sleep(THREAD_SLEEP);
}
}
+ private static boolean isTimeouted(long startTime, long timeout) {
+ return (System.currentTimeMillis() - startTime) > timeout;
+ }
+
private static IStatus getStatus(final Job job, final JobResultFuture future) {
if (future.isCancelled()) {
12 years, 7 months
JBoss Tools SVN: r41420 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui: src/org/jboss/tools/openshift/express/internal/core/behaviour and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: xcoulon
Date: 2012-05-25 09:54:21 -0400 (Fri, 25 May 2012)
New Revision: 41420
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/TailServerLogAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/ApplicationPortForwardingActionProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/ShowEnvironmentActionProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/ApplicationPortForwardingActionProvider.java
Removed:
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/ui/console/ConsoleRemoveAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/TailServerLogAction.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
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/ui/action/CreateApplicationAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/ShowEnvironmentAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/AbstractServerViewerActionProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/TailServerLogActionProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/TailServerLogActionProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
Log:
In progress - JBIDE-11841
Make OpenShift Explorer actions available from Server Adapter
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-05-25 13:54:21 UTC (rev 41420)
@@ -162,7 +162,7 @@
<viewerActionBinding viewerId="org.eclipse.wst.server.ui.ServersView">
<includes>
<actionExtension
- pattern="org.jboss.tools.openshift.express.internal.ui.serverviewer.actionDelegate.tailServerLogActionProvider"/>
+ pattern="org.jboss.tools.openshift.express.internal.ui.serverviewer.actionDelegate.*"/>
</includes>
</viewerActionBinding>
</extension>
@@ -174,13 +174,34 @@
id="org.jboss.tools.openshift.express.internal.ui.serverviewer.actionDelegate.tailServerLogActionProvider">
<enablement>
<and>
- <instanceof
- value="org.eclipse.wst.server.core.IServer">
- </instanceof>
- </and>
-
+ <instanceof
+ value="org.eclipse.wst.server.core.IServer">
+ </instanceof>
+ </and>
</enablement>
</actionProvider>
+ <actionProvider
+ class="org.jboss.tools.openshift.express.internal.ui.serverviewer.actionDelegate.ShowEnvironmentActionProvider"
+ id="org.jboss.tools.openshift.express.internal.ui.serverviewer.actionDelegate.showEnvironmentActionProvider">
+ <enablement>
+ <and>
+ <instanceof
+ value="org.eclipse.wst.server.core.IServer">
+ </instanceof>
+ </and>
+ </enablement>
+ </actionProvider>
+ <actionProvider
+ class="org.jboss.tools.openshift.express.internal.ui.serverviewer.actionDelegate.ApplicationPortForwardingActionProvider"
+ id="org.jboss.tools.openshift.express.internal.ui.serverviewer.actionDelegate.applicationPortForwardingActionProvider">
+ <enablement>
+ <and>
+ <instanceof
+ value="org.eclipse.wst.server.core.IServer">
+ </instanceof>
+ </and>
+ </enablement>
+ </actionProvider>
</extension>
<extension
@@ -318,8 +339,8 @@
<includes>
<actionExtension
pattern="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.*"/>
- <actionExtension
- pattern="org.jboss.tools.openshift.express.internal.core.portforward.applicationPortForwardActionProvider"/>
+ <!--actionExtension
+ pattern="org.jboss.tools.openshift.express.internal.core.portforward.applicationPortForwardActionProvider"/-->
</includes>
</viewerActionBinding>
<viewerContentBinding
@@ -422,8 +443,8 @@
</enablement>
</actionProvider>
<actionProvider
- class="org.jboss.tools.openshift.express.internal.core.portforward.ApplicationPortForwardingActionProvider"
- id="org.jboss.tools.openshift.express.internal.core.portforward.applicationPortForwardActionProvider">
+ class="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.ApplicationPortForwardingActionProvider"
+ id="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.applicationPortForwardingActionProvider">
<enablement>
<and>
<instanceof
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/behaviour/ExpressServerUtils.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -48,58 +48,62 @@
import com.openshift.client.OpenShiftException;
/**
- * This class holds the attribute names whose values will be
- * stored inside a server object, as well as the utility methods
- * used to get and set them for a server.
- *
+ * This class holds the attribute names whose values will be stored inside a
+ * server object, as well as the utility methods used to get and set them for a
+ * server.
+ *
* @author Rob Stryker
*/
@SuppressWarnings("restriction")
public class ExpressServerUtils {
/* Server Settings */
- public static final String ATTRIBUTE_DEPLOY_PROJECT = "org.jboss.tools.openshift.binary.deployProject";
- public static final String ATTRIBUTE_OVERRIDE_PROJECT_SETTINGS = "org.jboss.tools.openshift.project.override";
-
+ public static final String ATTRIBUTE_DEPLOY_PROJECT = "org.jboss.tools.openshift.binary.deployProject";
+ public static final String ATTRIBUTE_OVERRIDE_PROJECT_SETTINGS = "org.jboss.tools.openshift.project.override";
+
/* Legacy Server Settings: Please usage scan before removal */
- public static final String ATTRIBUTE_DEPLOY_PROJECT_LEGACY = "org.jboss.tools.openshift.express.internal.core.behaviour.binary.deployProject";
- public static final String ATTRIBUTE_REMOTE_NAME = "org.jboss.tools.openshift.express.internal.core.behaviour.RemoteName";
- public static final String ATTRIBUTE_APPLICATION_NAME = "org.jboss.tools.openshift.express.internal.core.behaviour.ApplicationName";
- public static final String ATTRIBUTE_APPLICATION_ID = "org.jboss.tools.openshift.express.internal.core.behaviour.ApplicationId";
- public static final String ATTRIBUTE_DOMAIN = "org.jboss.tools.openshift.express.internal.core.behaviour.Domain";
- public static final String ATTRIBUTE_USERNAME = "org.jboss.tools.openshift.express.internal.core.behaviour.Username";
+ public static final String ATTRIBUTE_DEPLOY_PROJECT_LEGACY = "org.jboss.tools.openshift.express.internal.core.behaviour.binary.deployProject";
+ public static final String ATTRIBUTE_REMOTE_NAME = "org.jboss.tools.openshift.express.internal.core.behaviour.RemoteName";
+ public static final String ATTRIBUTE_APPLICATION_NAME = "org.jboss.tools.openshift.express.internal.core.behaviour.ApplicationName";
+ public static final String ATTRIBUTE_APPLICATION_ID = "org.jboss.tools.openshift.express.internal.core.behaviour.ApplicationId";
+ public static final String ATTRIBUTE_DOMAIN = "org.jboss.tools.openshift.express.internal.core.behaviour.Domain";
+ public static final String ATTRIBUTE_USERNAME = "org.jboss.tools.openshift.express.internal.core.behaviour.Username";
public static final String ATTRIBUTE_DEPLOY_FOLDER_NAME = "org.jboss.tools.openshift.express.internal.core.behaviour.DEPLOY_FOLDER_LOC";
/* New Settings inside the project */
- public static final String SETTING_REMOTE_NAME = "org.jboss.tools.openshift.RemoteName";
- public static final String SETTING_APPLICATION_NAME = "org.jboss.tools.openshift.ApplicationName";
- public static final String SETTING_APPLICATION_ID = "org.jboss.tools.openshift.ApplicationId";
- public static final String SETTING_DOMAIN = "org.jboss.tools.openshift.Domain";
- public static final String SETTING_USERNAME = "org.jboss.tools.openshift.Username";
+ public static final String SETTING_REMOTE_NAME = "org.jboss.tools.openshift.RemoteName";
+ public static final String SETTING_APPLICATION_NAME = "org.jboss.tools.openshift.ApplicationName";
+ public static final String SETTING_APPLICATION_ID = "org.jboss.tools.openshift.ApplicationId";
+ public static final String SETTING_DOMAIN = "org.jboss.tools.openshift.Domain";
+ public static final String SETTING_USERNAME = "org.jboss.tools.openshift.Username";
public static final String SETTING_DEPLOY_FOLDER_NAME = "org.jboss.tools.openshift.DeployFolder";
// Legacy, not to be used
- //public static final String ATTRIBUTE_PASSWORD = "org.jboss.tools.openshift.express.internal.core.behaviour.Password";
- public static final String ATTRIBUTE_REMOTE_NAME_DEFAULT = "origin";
+ // public static final String ATTRIBUTE_PASSWORD =
+ // "org.jboss.tools.openshift.express.internal.core.behaviour.Password";
+ public static final String ATTRIBUTE_REMOTE_NAME_DEFAULT = "origin";
public static final String ATTRIBUTE_DEPLOY_FOLDER_DEFAULT = "deployments";
-
+
public static final String PREFERENCE_IGNORE_CONTEXT_ROOT = "org.jboss.tools.openshift.express.internal.core.behaviour.IgnoreContextRoot";
-
- /** the OpensHift Server Type as defined in the plugin.xml.*/
+
+ /** the OpensHift Server Type as defined in the plugin.xml. */
public static final String OPENSHIFT_SERVER_TYPE = "org.jboss.tools.openshift.express.openshift.server.type";
-
+
/* For use inside express wizard fragment */
public static final String TASK_WIZARD_ATTR_USER = "user";
public static final String TASK_WIZARD_ATTR_DOMAIN = "domain";
public static final String TASK_WIZARD_ATTR_APP_LIST = "appList";
public static final String TASK_WIZARD_ATTR_SELECTED_APP = "application";
-
- /* For use in finding not just the effective value, but values stored either in project or server */
+
+ /*
+ * For use in finding not just the effective value, but values stored either
+ * in project or server
+ */
public static int SETTING_FROM_PROJECT = 1;
public static int SETTING_FROM_SERVER = 2;
public static int SETTING_EFFECTIVE_VALUE = 3;
-
+
public static String getProjectAttribute(IProject project, String attributeName, String defaultVal) {
- if( project == null )
+ if (project == null)
return defaultVal;
String qualifier = OpenShiftUIActivator.getDefault().getBundle().getSymbolicName();
IScopeContext context = new ProjectScope(project);
@@ -107,77 +111,101 @@
return node.get(attributeName, defaultVal);
}
+ /**
+ * Look-up the OpenShift application associated with the given server. This
+ * operation can be time-consuming since it may need to perform a request on
+ * OpenShift if the user's applications list had not been loaded before.
+ * Callers should use this methd without blocking the UI.
+ *
+ * @param server the server
+ * @return the openshift application or null if it could not be located.
+ * @throws OpenShiftException
+ */
+ public static IApplication getApplication(IServer server) {
+ final String appName = getExpressApplicationName(server);
+ final String userName = getExpressUsername(server);
+ try {
+ final UserDelegate ud = UserModel.getDefault().findUser(userName);
+ if (ud != null) {
+ return ud.getApplicationByName(appName); // May be long running
+ }
+ } catch (OpenShiftException e) {
+ Logger.error(NLS.bind("Failed to retrieve application ''{0}'' from user ''{1}}'", appName, userName), e);
+ }
+ return null;
+ }
+
/* Settings stored only in the project */
- public static String getExpressApplicationName(IServerAttributes attributes ) {
- return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_APPLICATION_NAME,
- attributes.getAttribute(ATTRIBUTE_APPLICATION_NAME, (String)null));
+ public static String getExpressApplicationName(IServerAttributes attributes) {
+ return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_APPLICATION_NAME,
+ attributes.getAttribute(ATTRIBUTE_APPLICATION_NAME, (String) null));
}
- public static String getExpressApplicationId(IServerAttributes attributes ) {
- return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_APPLICATION_ID,
- attributes.getAttribute(ATTRIBUTE_APPLICATION_ID, (String)null));
+ public static String getExpressApplicationId(IServerAttributes attributes) {
+ return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_APPLICATION_ID,
+ attributes.getAttribute(ATTRIBUTE_APPLICATION_ID, (String) null));
}
- public static String getExpressDomain(IServerAttributes attributes ) {
- return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_DOMAIN,
- attributes.getAttribute(ATTRIBUTE_DOMAIN, (String)null));
+ public static String getExpressDomain(IServerAttributes attributes) {
+ return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_DOMAIN,
+ attributes.getAttribute(ATTRIBUTE_DOMAIN, (String) null));
}
- public static String getExpressUsername(IServerAttributes attributes ) {
- return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_USERNAME,
- attributes.getAttribute(ATTRIBUTE_USERNAME, (String)null));
+ public static String getExpressUsername(IServerAttributes attributes) {
+ return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_USERNAME,
+ attributes.getAttribute(ATTRIBUTE_USERNAME, (String) null));
}
-
/* Settings stored in the project, maybe over-ridden in the server */
- public static String getExpressDeployFolder(IServerAttributes attributes ) {
- if( getOverridesProject(attributes))
+ public static String getExpressDeployFolder(IServerAttributes attributes) {
+ if (getOverridesProject(attributes))
return attributes.getAttribute(ATTRIBUTE_DEPLOY_FOLDER_NAME, ATTRIBUTE_DEPLOY_FOLDER_DEFAULT);
return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_DEPLOY_FOLDER_NAME,
ATTRIBUTE_DEPLOY_FOLDER_DEFAULT);
}
-
- public static String getExpressRemoteName(IServerAttributes attributes ) {
- if( getOverridesProject(attributes))
+
+ public static String getExpressRemoteName(IServerAttributes attributes) {
+ if (getOverridesProject(attributes))
return attributes.getAttribute(ATTRIBUTE_REMOTE_NAME, ATTRIBUTE_REMOTE_NAME_DEFAULT);
return getProjectAttribute(getExpressDeployProject2(attributes), SETTING_REMOTE_NAME,
ATTRIBUTE_REMOTE_NAME_DEFAULT);
}
- public static String getExpressDeployFolder(IServerAttributes attributes, int fromWhere ) {
- String fromServer = attributes.getAttribute(ATTRIBUTE_DEPLOY_FOLDER_NAME,(String)null);
- if( fromWhere == SETTING_FROM_SERVER)
+ public static String getExpressDeployFolder(IServerAttributes attributes, int fromWhere) {
+ String fromServer = attributes.getAttribute(ATTRIBUTE_DEPLOY_FOLDER_NAME, (String) null);
+ if (fromWhere == SETTING_FROM_SERVER)
return fromServer;
String fromProject = getProjectAttribute(getExpressDeployProject2(attributes), SETTING_DEPLOY_FOLDER_NAME, null);
- if( fromWhere == SETTING_FROM_PROJECT)
+ if (fromWhere == SETTING_FROM_PROJECT)
return fromProject;
- if( getOverridesProject(attributes))
+ if (getOverridesProject(attributes))
return fromServer == null ? ATTRIBUTE_DEPLOY_FOLDER_DEFAULT : fromServer;
return fromProject == null ? ATTRIBUTE_DEPLOY_FOLDER_DEFAULT : fromProject;
}
-
- public static String getExpressRemoteName(IServerAttributes attributes, int fromWhere ) {
- String fromServer = attributes.getAttribute(ATTRIBUTE_REMOTE_NAME,(String)null);
- if( fromWhere == SETTING_FROM_SERVER)
+
+ public static String getExpressRemoteName(IServerAttributes attributes, int fromWhere) {
+ String fromServer = attributes.getAttribute(ATTRIBUTE_REMOTE_NAME, (String) null);
+ if (fromWhere == SETTING_FROM_SERVER)
return fromServer;
String fromProject = getProjectAttribute(getExpressDeployProject2(attributes), SETTING_REMOTE_NAME, null);
- if( fromWhere == SETTING_FROM_PROJECT)
+ if (fromWhere == SETTING_FROM_PROJECT)
return fromProject;
- if( getOverridesProject(attributes))
+ if (getOverridesProject(attributes))
return fromServer == null ? ATTRIBUTE_REMOTE_NAME_DEFAULT : fromServer;
return fromProject == null ? ATTRIBUTE_REMOTE_NAME_DEFAULT : fromProject;
}
/* Settings stored only in the server */
- public static String getExpressDeployProject(IServerAttributes attributes ) {
- return attributes.getAttribute(ATTRIBUTE_DEPLOY_PROJECT,
- attributes.getAttribute(ATTRIBUTE_DEPLOY_PROJECT_LEGACY, (String)null));
+ public static String getExpressDeployProject(IServerAttributes attributes) {
+ return attributes.getAttribute(ATTRIBUTE_DEPLOY_PROJECT,
+ attributes.getAttribute(ATTRIBUTE_DEPLOY_PROJECT_LEGACY, (String) null));
}
private static IProject getExpressDeployProject2(IServerAttributes attributes) {
String name = getExpressDeployProject(attributes);
return name == null ? null : ResourcesPlugin.getWorkspace().getRoot().getProject(name);
}
+
public static boolean getIgnoresContextRoot(IServerAttributes server) {
return server.getAttribute(PREFERENCE_IGNORE_CONTEXT_ROOT, true);
}
@@ -193,7 +221,7 @@
}
/**
- * Fills an already-created server with the proper openshift details.
+ * Fills an already-created server with the proper openshift details.
*
* @param server
* @param host
@@ -205,70 +233,72 @@
* @return
* @throws CoreException
*/
- public static IServer fillServerWithOpenShiftDetails(IServer server, String host,
+ public static IServer fillServerWithOpenShiftDetails(IServer server, String host,
String deployProject, String remote) throws CoreException {
- ServerWorkingCopy wc = (ServerWorkingCopy)server.createWorkingCopy();
- fillServerWithOpenShiftDetails((IServerWorkingCopy)wc, host, deployProject,remote);
+ ServerWorkingCopy wc = (ServerWorkingCopy) server.createWorkingCopy();
+ fillServerWithOpenShiftDetails((IServerWorkingCopy) wc, host, deployProject, remote);
IServer saved = wc.save(true, new NullProgressMonitor());
return saved;
}
-
- public static void fillServerWithOpenShiftDetails(IServerWorkingCopy wc, String host,
- String deployProject, String remote) {
- if( host != null ) {
- if( host.indexOf("://") != -1)
+ public static void fillServerWithOpenShiftDetails(IServerWorkingCopy wc, String host,
+ String deployProject, String remote) {
+
+ if (host != null) {
+ if (host.indexOf("://") != -1)
host = host.substring(host.indexOf("://") + 3);
- if( host.endsWith("/"))
- host = host.substring(0, host.length()-1);
+ if (host.endsWith("/"))
+ host = host.substring(0, host.length() - 1);
}
wc.setHost(host);
wc.setAttribute(IDeployableServer.SERVER_MODE, ExpressBehaviourDelegate.OPENSHIFT_ID);
wc.setAttribute(ATTRIBUTE_DEPLOY_PROJECT, deployProject);
-// wc.setAttribute(ATTRIBUTE_USERNAME, username);
-// wc.setAttribute(ATTRIBUTE_DOMAIN, domain);
-// wc.setAttribute(ATTRIBUTE_APPLICATION_NAME, appName);
-// wc.setAttribute(ATTRIBUTE_APPLICATION_ID, appId);
-// wc.setAttribute(ATTRIBUTE_DEPLOY_FOLDER_NAME, projectRelativeFolder);
-// wc.setAttribute(ATTRIBUTE_EXPRESS_MODE, mode);
+ // wc.setAttribute(ATTRIBUTE_USERNAME, username);
+ // wc.setAttribute(ATTRIBUTE_DOMAIN, domain);
+ // wc.setAttribute(ATTRIBUTE_APPLICATION_NAME, appName);
+ // wc.setAttribute(ATTRIBUTE_APPLICATION_ID, appId);
+ // wc.setAttribute(ATTRIBUTE_DEPLOY_FOLDER_NAME, projectRelativeFolder);
+ // wc.setAttribute(ATTRIBUTE_EXPRESS_MODE, mode);
wc.setAttribute(ATTRIBUTE_REMOTE_NAME, remote);
- ((ServerWorkingCopy)wc).setAutoPublishSetting(Server.AUTO_PUBLISH_DISABLE);
+ ((ServerWorkingCopy) wc).setAutoPublishSetting(Server.AUTO_PUBLISH_DISABLE);
wc.setAttribute(IJBossToolingConstants.IGNORE_LAUNCH_COMMANDS, "true");
wc.setAttribute(IJBossToolingConstants.WEB_PORT, 80);
wc.setAttribute(IJBossToolingConstants.WEB_PORT_DETECT, "false");
wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_CUSTOM);
wc.setAttribute(IDeployableServer.ZIP_DEPLOYMENTS_PREF, true);
}
-
-
+
public static IServer createServerAndRuntime(String runtimeID, String serverID,
String location, String configuration) throws CoreException {
IRuntime runtime = RuntimeUtils.createRuntime(runtimeID, location, configuration);
return createServer(runtime, serverID);
}
-
+
public static IServer createServer(IRuntime runtime, String serverID) throws CoreException {
return createServer2(runtime, ServerCore.findServerType(serverID), serverID);
}
-
- public static IServer createServer(IRuntime runtime, IServerType serverType, String serverName) throws CoreException {
+
+ public static IServer createServer(IRuntime runtime, IServerType serverType, String serverName)
+ throws CoreException {
return createServer2(runtime, serverType, serverName);
}
-
- public static IServer createServer2(IRuntime currentRuntime, IServerType serverType, String serverName) throws CoreException {
+
+ public static IServer createServer2(IRuntime currentRuntime, IServerType serverType, String serverName)
+ throws CoreException {
IServerWorkingCopy serverWC = serverType.createServer(null, null,
new NullProgressMonitor());
serverWC.setRuntime(currentRuntime);
serverWC.setName(serverName);
serverWC.setServerConfiguration(null);
- serverWC.setAttribute(IDeployableServer.SERVER_MODE, ExpressBehaviourDelegate.OPENSHIFT_ID);
+ serverWC.setAttribute(IDeployableServer.SERVER_MODE, ExpressBehaviourDelegate.OPENSHIFT_ID);
return serverWC.save(true, new NullProgressMonitor());
}
-
/**
* Returns true if the given server is an OpenShift one, false otherwise.
- * @param server the server to check
+ *
+ * @param server
+ * the server to check
* @return true or false
*/
public static boolean isOpenShiftRuntime(IServerAttributes server) {
@@ -278,33 +308,36 @@
/**
* Returns true if the given server is a server using an openshift behaviour
- * @param server the server to check
+ *
+ * @param server
+ * the server to check
* @return true or false
*/
public static boolean isInOpenshiftBehaviourMode(IServer server) {
IDeployableServer ds = ServerConverter.getDeployableServer(server);
- if( ds != null ) {
+ if (ds != null) {
IJBossServerPublishMethodType type = DeploymentPreferenceLoader.getCurrentDeploymentMethodType(server);
- if( type != null ) {
+ if (type != null) {
String id = type.getId();
- if( ExpressBinaryBehaviourDelegate.OPENSHIFT_BINARY_ID.equals(id) || ExpressBehaviourDelegate.OPENSHIFT_ID.equals(id))
+ if (ExpressBinaryBehaviourDelegate.OPENSHIFT_BINARY_ID.equals(id)
+ || ExpressBehaviourDelegate.OPENSHIFT_ID.equals(id))
return true;
}
}
return false;
}
- public static IApplication findApplicationForProject(IProject p, List<IApplication> applications)
+ public static IApplication findApplicationForProject(IProject p, List<IApplication> applications)
throws OpenShiftException, CoreException {
List<URIish> uris = EGitUtils.getRemoteURIs(p);
Iterator<IApplication> i = applications.iterator();
- while(i.hasNext()) {
+ while (i.hasNext()) {
IApplication a = i.next();
String gitUri = a.getGitUrl();
Iterator<URIish> j = uris.iterator();
- while(j.hasNext()) {
+ while (j.hasNext()) {
String projUri = j.next().toPrivateString();
- if( projUri.equals(gitUri)) {
+ if (projUri.equals(gitUri)) {
return a;
}
}
@@ -313,59 +346,59 @@
}
/**
- * This method will search available projects for one that has a
- * git remote URI that matches that of this IApplication
+ * This method will search available projects for one that has a git remote
+ * URI that matches that of this IApplication
*
* @param application
* @return
*/
public static IProject[] findProjectsForApplication(final IApplication application) {
final ArrayList<IProject> results = new ArrayList<IProject>();
- if( application ==null )
+ if (application == null)
return null;
final String gitUri = application.getGitUrl();
final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for( int i = 0; i < projects.length; i++ ) {
+ for (int i = 0; i < projects.length; i++) {
List<URIish> uris = null;
try {
uris = EGitUtils.getRemoteURIs(projects[i]);
Iterator<URIish> it = uris.iterator();
- while(it.hasNext()) {
+ while (it.hasNext()) {
String projURI = it.next().toPrivateString();
- if( projURI.equals(gitUri))
+ if (projURI.equals(gitUri))
results.add(projects[i]);
}
- } catch(CoreException ce) {
+ } catch (CoreException ce) {
// Log? Not 100 required, just skip this project?
}
}
return results.toArray(new IProject[results.size()]);
}
-
+
/**
- * This method will search for all projects connected to git
- * and having the proper settings file containing
- * domain, application id, app name, and username
+ * This method will search for all projects connected to git and having the
+ * proper settings file containing domain, application id, app name, and
+ * username
*
* @return
*/
public static IProject[] findAllSuitableOpenshiftProjects() {
final ArrayList<IProject> results = new ArrayList<IProject>();
final IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for( int i = 0; i < projects.length; i++ ) {
- if( EGitUtils.getRepository(projects[i]) != null ) {
+ for (int i = 0; i < projects.length; i++) {
+ if (EGitUtils.getRepository(projects[i]) != null) {
String appName = getProjectAttribute(projects[i], SETTING_APPLICATION_NAME, null);
String appId = getProjectAttribute(projects[i], SETTING_APPLICATION_ID, null);
String domain = getProjectAttribute(projects[i], SETTING_DOMAIN, null);
String username = getProjectAttribute(projects[i], SETTING_USERNAME, null);
- if( appName != null && appId != null && domain != null && username != null ) {
+ if (appName != null && appId != null && domain != null && username != null) {
results.add(projects[i]);
}
}
}
return results.toArray(new IProject[results.size()]);
}
-
+
public static IProject findProjectForApplication(IApplication application) {
IProject[] p = findProjectsForApplication(application);
return p == null ? null : p.length == 0 ? null : p[0];
@@ -386,13 +419,13 @@
String appName = ExpressServerUtils.getExpressApplicationName(server);
IApplication app = user2 == null ? null : user2.getApplicationByName(appName);
return app;
- } catch(OpenShiftException ose) {
+ } catch (OpenShiftException ose) {
Logger.error(NLS.bind("Could not find application for server {0}", server.getName()));
return null;
}
}
-
- public static void updateOpenshiftProjectSettings(IProject project, IApplication app,
+
+ public static void updateOpenshiftProjectSettings(IProject project, IApplication app,
UserDelegate user, String remoteName, String deployFolder) {
String qualifier = OpenShiftUIActivator.getDefault().getBundle().getSymbolicName();
IScopeContext context = new ProjectScope(project);
@@ -409,21 +442,22 @@
OpenShiftUIActivator.log(e);
}
}
-
+
public static IServer setExpressDeployProject(IServer server, String val) throws CoreException {
IServerWorkingCopy wc = server.createWorkingCopy();
wc.setAttribute(ATTRIBUTE_DEPLOY_PROJECT, val);
return wc.save(false, new NullProgressMonitor());
}
+
public static IServer setExpressRemoteName(IServer server, String val) throws CoreException {
IServerWorkingCopy wc = server.createWorkingCopy();
wc.setAttribute(ATTRIBUTE_REMOTE_NAME, val);
return wc.save(false, new NullProgressMonitor());
}
-
- /* Deprecated: These details cannot be changed and are no longer stored in the server
- * Delete when certain no problems will be caused.
+ /*
+ * Deprecated: These details cannot be changed and are no longer stored in
+ * the server Delete when certain no problems will be caused.
*/
@Deprecated
public static IServer setExpressApplication(IServer server, String val) throws CoreException {
@@ -431,12 +465,14 @@
wc.setAttribute(ATTRIBUTE_APPLICATION_NAME, val);
return wc.save(false, new NullProgressMonitor());
}
+
@Deprecated
public static IServer setExpressDomain(IServer server, String val) throws CoreException {
IServerWorkingCopy wc = server.createWorkingCopy();
wc.setAttribute(ATTRIBUTE_DOMAIN, val);
return wc.save(false, new NullProgressMonitor());
}
+
@Deprecated
public static IServer setExpressUsername(IServer server, String val) throws CoreException {
IServerWorkingCopy wc = server.createWorkingCopy();
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -129,6 +129,9 @@
}
public UserDelegate findUser(String username) {
+ if(username == null) {
+ return null;
+ }
return allUsers.get(username);
}
Modified: 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 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingAction.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -1,10 +1,16 @@
package org.jboss.tools.openshift.express.internal.core.portforward;
+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.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.eclipse.wst.server.core.IServer;
+import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
import org.jboss.tools.openshift.express.internal.ui.action.AbstractAction;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
@@ -15,28 +21,63 @@
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}
+ * 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 {
- ApplicationPortForwardingWizard wizard = new ApplicationPortForwardingWizard(application);
- WizardDialog dialog = new ApplicationPortForwardingWizardDialog(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);
- }
+ public void run() {
+ if (selection != null && selection instanceof ITreeSelection) {
+ Object sel = ((ITreeSelection) selection).getFirstElement();
+ IApplication application = null;
+ if (sel instanceof IApplication) {
+ application = (IApplication) sel;
+ } else if (sel instanceof IServer) {
+ openPortForwarding((IServer) sel);
}
+ if (application != null) {
+ openPortForwarding(application);
+ }
}
}
+ /**
+ * @param sel
+ * @return
+ */
+ private void openPortForwarding(final IServer server) {
+ Job job = new Job("Retrieving application's forwardable ports...") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ final IApplication application = ExpressServerUtils.getApplication(server);
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ openPortForwarding(application);
+ }
+ });
+ return Status.OK_STATUS;
+ }
+ };
+ job.setUser(true);
+ job.schedule();
+ }
+ /**
+ * @param application
+ */
+ private void openPortForwarding(IApplication application) {
+ try {
+ ApplicationPortForwardingWizard wizard = new ApplicationPortForwardingWizard(application);
+ WizardDialog dialog = new ApplicationPortForwardingWizardDialog(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);
+ }
+ }
+
}
Deleted: 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 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/portforward/ApplicationPortForwardingActionProvider.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -1,10 +0,0 @@
-package org.jboss.tools.openshift.express.internal.core.portforward;
-
-import org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.AbstractOpenShiftExplorerViewerActionProvider;
-
-public class ApplicationPortForwardingActionProvider extends AbstractOpenShiftExplorerViewerActionProvider {
-
- public ApplicationPortForwardingActionProvider() {
- super(new ApplicationPortForwardingAction(), "group.showIn");
- }
-}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -41,52 +41,42 @@
}
/**
- * 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}
+ * 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 UserDelegate) {
- UserDelegate user = (UserDelegate) sel;
- OpenShiftExpressApplicationWizard wizard = new NewOpenShiftExpressApplicationWizard(user);
- new WizardDialog(new Shell(), wizard).open();
+ final UserDelegate user = (UserDelegate) sel;
+ final OpenShiftExpressApplicationWizard wizard = new NewOpenShiftExpressApplicationWizard(user);
+ final WizardDialog wizardDialog = new WizardDialog(new Shell(), wizard);
+ wizardDialog.open();
}
}
}
/**
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- super.selectionChanged(event);
- enableWhenDomainExists();
- }
-
- @Override
- public void setSelection(ISelection selection) {
- super.setSelection(selection);
- enableWhenDomainExists();
- }
-
- * Enables the current action if the selected User has a default domain. Otherwise, the action is disabled.
- private void enableWhenDomainExists() {
- if (selection != null && selection instanceof ITreeSelection) {
- Object sel = ((ITreeSelection) selection).getFirstElement();
- if (sel instanceof UserDelegate) {
- UserDelegate user = (UserDelegate) sel;
- try {
- final IDomain defaultDomain = user.getDefaultDomain();
- setEnabled(defaultDomain != null);
- } catch (SocketTimeoutException e) {
- Logger.error("Failed to check if selected user has a domain", e);
- } catch (OpenShiftException e) {
- Logger.error("Failed to check if selected user has a domain", e);
- }
- }
- }
- }
+ * @Override public void selectionChanged(SelectionChangedEvent event) {
+ * super.selectionChanged(event); enableWhenDomainExists(); }
+ * @Override public void setSelection(ISelection selection) {
+ * super.setSelection(selection); enableWhenDomainExists(); }
+ *
+ * Enables the current action if the selected User has a default
+ * domain. Otherwise, the action is disabled. private void
+ * enableWhenDomainExists() { if (selection != null && selection
+ * instanceof ITreeSelection) { Object sel = ((ITreeSelection)
+ * selection).getFirstElement(); if (sel instanceof UserDelegate)
+ * { UserDelegate user = (UserDelegate) sel; try { final IDomain
+ * defaultDomain = user.getDefaultDomain();
+ * setEnabled(defaultDomain != null); } catch
+ * (SocketTimeoutException e) {
+ * Logger.error("Failed to check if selected user has a domain",
+ * e); } catch (OpenShiftException e) {
+ * Logger.error("Failed to check if selected user has a domain",
+ * e); } } } }
*/
-
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/ShowEnvironmentAction.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/ShowEnvironmentAction.java 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/ShowEnvironmentAction.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -20,7 +20,9 @@
import org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
import org.jboss.tools.openshift.express.internal.ui.utils.OpenShiftSshSessionFactory;
+import com.jcraft.jsch.JSchException;
import com.openshift.client.IApplication;
+import com.openshift.client.OpenShiftSSHOperationException;
/**
* @author Xavier Coulon
@@ -41,24 +43,33 @@
final ITreeSelection treeSelection = (ITreeSelection) selection;
if (selection instanceof ITreeSelection && treeSelection.getFirstElement() instanceof IApplication) {
final IApplication application = (IApplication) treeSelection.getFirstElement();
- if(!application.hasSSHSession()) {
- application.setSSHSession(OpenShiftSshSessionFactory.getInstance().createSession(application));
- }
- List<String> props = application.getEnvironmentProperties();
- final MessageConsole console = ConsoleUtils.findMessageConsole(getMessageConsoleName(application));
- console.clearConsole();
- MessageConsoleStream stream = console.newMessageStream();
- for (String prop : props) {
- stream.println(prop);
- }
- ConsoleUtils.displayConsoleView(console);
-
+ showEnvironmentProperties(application);
}
} catch (Exception e) {
OpenShiftUIActivator.createErrorStatus("Failed to display remote environment variables", e);
}
}
+
+ /**
+ * @param application
+ * @throws JSchException
+ * @throws OpenShiftSSHOperationException
+ */
+ private void showEnvironmentProperties(final IApplication application) throws JSchException,
+ OpenShiftSSHOperationException {
+ if(!application.hasSSHSession()) {
+ application.setSSHSession(OpenShiftSshSessionFactory.getInstance().createSession(application));
+ }
+ List<String> props = application.getEnvironmentProperties();
+ final MessageConsole console = ConsoleUtils.findMessageConsole(getMessageConsoleName(application));
+ console.clearConsole();
+ MessageConsoleStream stream = console.newMessageStream();
+ for (String prop : props) {
+ stream.println(prop);
+ }
+ ConsoleUtils.displayConsoleView(console);
+ }
/**
* @return
Copied: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/TailServerLogAction.java (from rev 41405, trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/TailServerLogAction.java)
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/TailServerLogAction.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/TailServerLogAction.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -0,0 +1,238 @@
+package org.jboss.tools.openshift.express.internal.ui.action;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+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.viewers.IStructuredSelection;
+import org.eclipse.jgit.transport.CredentialsProvider;
+import org.eclipse.jgit.transport.RemoteSession;
+import org.eclipse.jgit.transport.SshSessionFactory;
+import org.eclipse.jgit.transport.URIish;
+import org.eclipse.jgit.util.FS;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.console.IConsoleListener;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.views.IViewDescriptor;
+import org.eclipse.ui.views.IViewRegistry;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.IServerModule;
+import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
+import org.jboss.tools.openshift.express.internal.ui.console.ConsoleUtils;
+import org.jboss.tools.openshift.express.internal.ui.console.JschToEclipseLogger;
+import org.jboss.tools.openshift.express.internal.ui.console.TailServerLogWorker;
+import org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.openshift.client.IApplication;
+import com.openshift.client.OpenShiftException;
+import com.openshift.client.utils.Base64Coder;
+
+/**
+ * The action associated with the "Show In>Remote Console" menu item.
+ *
+ * @author Xavier Coulon
+ *
+ */
+public class TailServerLogAction extends AbstractAction implements IConsoleListener {
+
+ /**
+ * The message consoles associated with the 'tail' workers that write the output.
+ */
+ private Map<String, TailServerLogWorker> consoleWorkers = new HashMap<String, TailServerLogWorker>();
+
+ /**
+ * Constructor
+ */
+ public TailServerLogAction() {
+ super(OpenShiftExpressUIMessages.TAIL_SERVER_LOG_ACTION, true);
+ IViewRegistry reg = PlatformUI.getWorkbench().getViewRegistry();
+ IViewDescriptor desc = reg.find(IConsoleConstants.ID_CONSOLE_VIEW);
+ setImageDescriptor(desc.getImageDescriptor());
+ ConsoleUtils.registerConsoleListener(this);
+ }
+
+ /**
+ * 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() {
+ try {
+
+ if (selection instanceof IStructuredSelection) {
+ final Object selectedItem = ((IStructuredSelection) selection).getFirstElement();
+ if (selectedItem instanceof IServer) {
+ final IServer server = ((IServer) selectedItem);
+ run(server);
+ } else if (selectedItem instanceof IServerModule) {
+ final IServer server = ((IServerModule) selectedItem).getServer();
+ run(server);
+ } else if (selectedItem instanceof IApplication) {
+ final IApplication application = (IApplication) selectedItem;
+ run(application);
+ }
+ }
+ } catch (Exception e) {
+ Logger.error("Failed to open Remote Console", e);
+ }
+ }
+
+ private void run(final IApplication application) throws OpenShiftException, MalformedURLException {
+ final String host = new URL(application.getApplicationUrl()).getHost();
+ final String appId = application.getUUID();
+ final String appName = application.getName();
+ final MessageConsole console = ConsoleUtils.findMessageConsole(createConsoleId(appName, host));
+ ConsoleUtils.displayConsoleView(console);
+ console.newMessageStream().println("Loading....");
+ if (!this.consoleWorkers.containsKey(console.getName())) {
+ launchTailServerJob(host, appId, appName, console);
+ }
+ }
+
+ private static String createConsoleId(String appName, String host) {
+ return host;
+ }
+
+ private void run(final IServer server) {
+ if (ExpressServerUtils.isOpenShiftRuntime(server) || ExpressServerUtils.isInOpenshiftBehaviourMode(server)) {
+ final String host = server.getHost();
+ final String appId = ExpressServerUtils.getExpressApplicationId(server);
+ final String appName = ExpressServerUtils.getExpressApplicationName(server);
+ final MessageConsole console = ConsoleUtils.findMessageConsole(createConsoleId(appName, host));
+ ConsoleUtils.displayConsoleView(console);
+ console.newMessageStream().println("Loading....");
+ if (!this.consoleWorkers.containsKey(console.getName())) {
+ launchTailServerJob(host, appId, appName, console);
+ }
+ }
+ }
+
+ private void launchTailServerJob(final String host, final String appId, final String appName,
+ final MessageConsole console) {
+ new Job("Launching Tail Server Operation") {
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ final TailServerLogWorker tailServerLogWorker = startTailProcess(host, appId, appName, console);
+ consoleWorkers.put(console.getName(), tailServerLogWorker);
+ Thread thread = new Thread(tailServerLogWorker);
+ thread.start();
+ } catch (Exception e) {
+ Logger.error("Failed to retrieve remote server logs", e);
+ console.newMessageStream().println("Failed to retrieve remote server logs: " + e.getMessage());
+ console.newMessageStream().println("Please make sure your ssh key is added to your ssh preferences");
+ }
+ return Status.OK_STATUS;
+ }
+
+ }.schedule();
+ }
+
+ /**
+ * Starting the tail process on the remote OpenShift Platform. This method relies on the JGit SSH support (including
+ * JSch) to open a connection AND execute a command in a single invocation. The connection establishement requires
+ * an SSH key, and the passphrase is prompted to the user if necessary.
+ *
+ * @param server
+ * the server adapter on which the action is performed
+ * @param console
+ * the console into which the tail should be writtent
+ * @return the Worker that encapsulate the established RemoteSession, the tail Process and the output console
+ * @throws JSchException
+ * in case of underlying exception
+ * @throws IOException
+ * in case of underlying exception
+ */
+ private TailServerLogWorker startTailProcess(final String host, final String appId, final String appName,
+ final MessageConsole console) throws JSchException, IOException {
+ final String logFilePath = appName + "/logs/*.log";
+ final String options = "-f -n 100";
+
+ JSch.setLogger(new JschToEclipseLogger());
+ final SshSessionFactory sshSessionFactory = SshSessionFactory.getInstance();
+ final URIish uri = new URIish().setHost(host).setUser(appId);
+ RemoteSession remoteSession = sshSessionFactory.getSession(uri, CredentialsProvider.getDefault(), FS.DETECTED,
+ 0);
+
+ // the rhc-tail-files command template
+ // ssh_cmd =
+ // "ssh -t #{app_uuid}(a)#{app}-#{namespace}.#{rhc_domain} 'tail#{opt['opts'] ? ' --opts ' + Base64::encode64(opt['opts']).chomp : ''} #{file_glob}'"
+ final String command = buildCommand(logFilePath, options);
+ Process process = remoteSession.exec(command, 0);
+ return new TailServerLogWorker(console, process, remoteSession);
+
+ }
+
+ /**
+ * Builds the 'ssh tail' command that should be executed on the remote OpenShift platform.
+ *
+ * @param filePath
+ * @param options
+ * @return
+ * @throws UnsupportedEncodingException
+ */
+ private String buildCommand(final String filePath, final String options) throws UnsupportedEncodingException {
+ StringBuilder commandBuilder = new StringBuilder("tail ");
+ if (options != null && !options.isEmpty()) {
+ final String opts = new String(Base64Coder.encode(options.getBytes()));
+ commandBuilder.append("--opts ").append(opts).append(" ");
+ }
+ commandBuilder.append(filePath);
+ final String command = commandBuilder.toString();
+ Logger.debug("ssh command to execute: " + command);
+ return command;
+ }
+
+ public Object getSelection() {
+ if (selection instanceof IStructuredSelection) {
+ final Object selectedItem = ((IStructuredSelection) selection).getFirstElement();
+ if (selectedItem instanceof IServer) {
+ return ((IServer) selectedItem);
+ }
+ if (selectedItem instanceof IServerModule) {
+ return ((IServerModule) selectedItem).getServer();
+ }
+ if (selectedItem instanceof IApplication) {
+
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void consolesAdded(IConsole[] consoles) {
+ // don't do anything special
+ }
+
+ /**
+ * Operation to perform when the console is removed (through the CloseConsoleAction that was brung by the
+ * <code>TailConsolePageParticipant</code>). In the current case, the associated worker is stopped and the
+ * console/worker are removed from the map, so that further 'Show In>Remote Console' invocation will trigger a new
+ * worker process.
+ */
+ @Override
+ public void consolesRemoved(IConsole[] consoles) {
+ // if the console is associated with a 'tail' process, stop that process
+ for (IConsole console : consoles) {
+ final String consoleName = console.getName();
+ if (consoleWorkers.containsKey(consoleName)) {
+ final TailServerLogWorker worker = consoleWorkers.get(consoleName);
+ worker.stop();
+ consoleWorkers.remove(consoleName);
+ }
+ }
+
+ }
+
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/TailServerLogAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/ConsoleRemoveAction.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/ConsoleRemoveAction.java 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/ConsoleRemoveAction.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -1,13 +0,0 @@
-package org.jboss.tools.openshift.express.internal.ui.console;
-
-import org.eclipse.jface.action.Action;
-
-public class ConsoleRemoveAction extends Action {
-
- ConsoleRemoveAction() {
- }
-
- @Override
- public void run() {
- }
-}
\ No newline at end of file
Deleted: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/TailServerLogAction.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/TailServerLogAction.java 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/TailServerLogAction.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -1,236 +0,0 @@
-package org.jboss.tools.openshift.express.internal.ui.console;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-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.viewers.IStructuredSelection;
-import org.eclipse.jgit.transport.CredentialsProvider;
-import org.eclipse.jgit.transport.RemoteSession;
-import org.eclipse.jgit.transport.SshSessionFactory;
-import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.util.FS;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.IConsoleListener;
-import org.eclipse.ui.console.MessageConsole;
-import org.eclipse.ui.views.IViewDescriptor;
-import org.eclipse.ui.views.IViewRegistry;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.ui.IServerModule;
-import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
-import org.jboss.tools.openshift.express.internal.ui.action.AbstractAction;
-import org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
-import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
-
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.openshift.client.IApplication;
-import com.openshift.client.OpenShiftException;
-import com.openshift.client.utils.Base64Coder;
-
-/**
- * The action associated with the "Show In>Remote Console" menu item.
- *
- * @author Xavier Coulon
- *
- */
-public class TailServerLogAction extends AbstractAction implements IConsoleListener {
-
- /**
- * The message consoles associated with the 'tail' workers that write the output.
- */
- private Map<String, TailServerLogWorker> consoleWorkers = new HashMap<String, TailServerLogWorker>();
-
- /**
- * Constructor
- */
- public TailServerLogAction() {
- super(OpenShiftExpressUIMessages.TAIL_SERVER_LOG_ACTION, true);
- IViewRegistry reg = PlatformUI.getWorkbench().getViewRegistry();
- IViewDescriptor desc = reg.find(IConsoleConstants.ID_CONSOLE_VIEW);
- setImageDescriptor(desc.getImageDescriptor());
- ConsoleUtils.registerConsoleListener(this);
- }
-
- /**
- * 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() {
- try {
-
- if (selection instanceof IStructuredSelection) {
- final Object selectedItem = ((IStructuredSelection) selection).getFirstElement();
- if (selectedItem instanceof IServer) {
- final IServer server = ((IServer) selectedItem);
- run(server);
- } else if (selectedItem instanceof IServerModule) {
- final IServer server = ((IServerModule) selectedItem).getServer();
- run(server);
- } else if (selectedItem instanceof IApplication) {
- final IApplication application = (IApplication) selectedItem;
- run(application);
- }
- }
- } catch (Exception e) {
- Logger.error("Failed to open Remote Console", e);
- }
- }
-
- private void run(final IApplication application) throws OpenShiftException, MalformedURLException {
- final String host = new URL(application.getApplicationUrl()).getHost();
- final String appId = application.getUUID();
- final String appName = application.getName();
- final MessageConsole console = ConsoleUtils.findMessageConsole(createConsoleId(appName, host));
- ConsoleUtils.displayConsoleView(console);
- console.newMessageStream().println("Loading....");
- if (!this.consoleWorkers.containsKey(console.getName())) {
- launchTailServerJob(host, appId, appName, console);
- }
- }
-
- private static String createConsoleId(String appName, String host) {
- return host;
- }
-
- private void run(final IServer server) {
- if (ExpressServerUtils.isOpenShiftRuntime(server) || ExpressServerUtils.isInOpenshiftBehaviourMode(server)) {
- final String host = server.getHost();
- final String appId = ExpressServerUtils.getExpressApplicationId(server);
- final String appName = ExpressServerUtils.getExpressApplicationName(server);
- final MessageConsole console = ConsoleUtils.findMessageConsole(createConsoleId(appName, host));
- ConsoleUtils.displayConsoleView(console);
- console.newMessageStream().println("Loading....");
- if (!this.consoleWorkers.containsKey(console.getName())) {
- launchTailServerJob(host, appId, appName, console);
- }
- }
- }
-
- private void launchTailServerJob(final String host, final String appId, final String appName,
- final MessageConsole console) {
- new Job("Launching Tail Server Operation") {
- protected IStatus run(IProgressMonitor monitor) {
- try {
- final TailServerLogWorker tailServerLogWorker = startTailProcess(host, appId, appName, console);
- consoleWorkers.put(console.getName(), tailServerLogWorker);
- Thread thread = new Thread(tailServerLogWorker);
- thread.start();
- } catch (Exception e) {
- Logger.error("Failed to retrieve remote server logs", e);
- console.newMessageStream().println("Failed to retrieve remote server logs: " + e.getMessage());
- console.newMessageStream().println("Please make sure your ssh key is added to your ssh preferences");
- }
- return Status.OK_STATUS;
- }
-
- }.schedule();
- }
-
- /**
- * Starting the tail process on the remote OpenShift Platform. This method relies on the JGit SSH support (including
- * JSch) to open a connection AND execute a command in a single invocation. The connection establishement requires
- * an SSH key, and the passphrase is prompted to the user if necessary.
- *
- * @param server
- * the server adapter on which the action is performed
- * @param console
- * the console into which the tail should be writtent
- * @return the Worker that encapsulate the established RemoteSession, the tail Process and the output console
- * @throws JSchException
- * in case of underlying exception
- * @throws IOException
- * in case of underlying exception
- */
- private TailServerLogWorker startTailProcess(final String host, final String appId, final String appName,
- final MessageConsole console) throws JSchException, IOException {
- final String logFilePath = appName + "/logs/*.log";
- final String options = "-f -n 100";
-
- JSch.setLogger(new JschToEclipseLogger());
- final SshSessionFactory sshSessionFactory = SshSessionFactory.getInstance();
- final URIish uri = new URIish().setHost(host).setUser(appId);
- RemoteSession remoteSession = sshSessionFactory.getSession(uri, CredentialsProvider.getDefault(), FS.DETECTED,
- 0);
-
- // the rhc-tail-files command template
- // ssh_cmd =
- // "ssh -t #{app_uuid}(a)#{app}-#{namespace}.#{rhc_domain} 'tail#{opt['opts'] ? ' --opts ' + Base64::encode64(opt['opts']).chomp : ''} #{file_glob}'"
- final String command = buildCommand(logFilePath, options);
- Process process = remoteSession.exec(command, 0);
- return new TailServerLogWorker(console, process, remoteSession);
-
- }
-
- /**
- * Builds the 'ssh tail' command that should be executed on the remote OpenShift platform.
- *
- * @param filePath
- * @param options
- * @return
- * @throws UnsupportedEncodingException
- */
- private String buildCommand(final String filePath, final String options) throws UnsupportedEncodingException {
- StringBuilder commandBuilder = new StringBuilder("tail ");
- if (options != null && !options.isEmpty()) {
- final String opts = new String(Base64Coder.encode(options.getBytes()));
- commandBuilder.append("--opts ").append(opts).append(" ");
- }
- commandBuilder.append(filePath);
- final String command = commandBuilder.toString();
- Logger.debug("ssh command to execute: " + command);
- return command;
- }
-
- public Object getSelection() {
- if (selection instanceof IStructuredSelection) {
- final Object selectedItem = ((IStructuredSelection) selection).getFirstElement();
- if (selectedItem instanceof IServer) {
- return ((IServer) selectedItem);
- }
- if (selectedItem instanceof IServerModule) {
- return ((IServerModule) selectedItem).getServer();
- }
- if (selectedItem instanceof IApplication) {
-
- }
- }
- return null;
- }
-
- @Override
- public void consolesAdded(IConsole[] consoles) {
- // don't do anything special
- }
-
- /**
- * Operation to perform when the console is removed (through the CloseConsoleAction that was brung by the
- * <code>TailConsolePageParticipant</code>). In the current case, the associated worker is stopped and the
- * console/worker are removed from the map, so that further 'Show In>Remote Console' invocation will trigger a new
- * worker process.
- */
- @Override
- public void consolesRemoved(IConsole[] consoles) {
- // if the console is associated with a 'tail' process, stop that process
- for (IConsole console : consoles) {
- final String consoleName = console.getName();
- if (consoleWorkers.containsKey(consoleName)) {
- final TailServerLogWorker worker = consoleWorkers.get(consoleName);
- worker.stop();
- consoleWorkers.remove(consoleName);
- }
- }
-
- }
-
-}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/AbstractServerViewerActionProvider.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/AbstractServerViewerActionProvider.java 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/AbstractServerViewerActionProvider.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.serverviewer.actionDelegate;
+import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -18,14 +19,18 @@
import org.eclipse.ui.navigator.ICommonViewerSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.ui.internal.cnf.ServerActionProvider;
import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
import org.jboss.tools.openshift.express.internal.ui.action.AbstractAction;
/**
* @author Xavier Coulon
*/
+@SuppressWarnings("restriction")
public abstract class AbstractServerViewerActionProvider extends CommonActionProvider {
+ private static final String OPENSHIFT_SERVER_ADAPTER_MENU = "org.jboss.tools.openshift.express.serverviewer.menu";
+
protected final AbstractAction action;
protected ICommonActionExtensionSite actionExtensionSite;
@@ -52,16 +57,32 @@
IServer server = (IServer) sel;
if (ExpressServerUtils.isOpenShiftRuntime(server) || ExpressServerUtils.isInOpenshiftBehaviourMode(server)) {
action.validate();
- if (action != null/* && action.isEnabled() */) {
- MenuManager openshiftMenu = new MenuManager("Openshift...",
- "org.jboss.tools.openshift.express.serverviewer.menu");
+ if (action != null) {
+ MenuManager openshiftMenu = getOpenShiftMenuManager(menu);
openshiftMenu.add(action);
- menu.add(openshiftMenu);
}
}
}
}
+ /**
+ * @param menu
+ * @return
+ */
+ private MenuManager getOpenShiftMenuManager(IMenuManager menu) {
+ for(IContributionItem item : menu.getItems()) {
+ // make this call in this way, since item id can be null
+ if(OPENSHIFT_SERVER_ADAPTER_MENU.equals(item.getId())) {
+ return (MenuManager) item;
+ }
+ }
+ MenuManager openshiftMenu = new MenuManager("Openshift...",
+ OPENSHIFT_SERVER_ADAPTER_MENU);
+ menu.add(openshiftMenu);
+ menu.insertBefore(ServerActionProvider.TOP_SECTION_END_SEPARATOR, openshiftMenu);
+ return openshiftMenu;
+ }
+
protected Object getSelection() {
ICommonViewerSite site = actionExtensionSite.getViewSite();
IStructuredSelection selection = null;
Added: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/ApplicationPortForwardingActionProvider.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/ApplicationPortForwardingActionProvider.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/ApplicationPortForwardingActionProvider.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -0,0 +1,10 @@
+package org.jboss.tools.openshift.express.internal.ui.serverviewer.actionDelegate;
+
+import org.jboss.tools.openshift.express.internal.core.portforward.ApplicationPortForwardingAction;
+
+public class ApplicationPortForwardingActionProvider extends AbstractServerViewerActionProvider {
+
+ public ApplicationPortForwardingActionProvider() {
+ super(new ApplicationPortForwardingAction());
+ }
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/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/ui/serverviewer/actionDelegate/ShowEnvironmentActionProvider.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/ShowEnvironmentActionProvider.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/ShowEnvironmentActionProvider.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.ui.serverviewer.actionDelegate;
+
+import org.jboss.tools.openshift.express.internal.ui.action.ShowEnvironmentAction;
+
+/**
+ * @author Xavier Coulon
+ */
+public class ShowEnvironmentActionProvider extends AbstractServerViewerActionProvider {
+
+ public ShowEnvironmentActionProvider() {
+ super(new ShowEnvironmentAction());
+ }
+
+}
Property changes on: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/ShowEnvironmentActionProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/TailServerLogActionProvider.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/TailServerLogActionProvider.java 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/serverviewer/actionDelegate/TailServerLogActionProvider.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -1,6 +1,6 @@
package org.jboss.tools.openshift.express.internal.ui.serverviewer.actionDelegate;
-import org.jboss.tools.openshift.express.internal.ui.console.TailServerLogAction;
+import org.jboss.tools.openshift.express.internal.ui.action.TailServerLogAction;
public class TailServerLogActionProvider extends AbstractServerViewerActionProvider {
Copied: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/ApplicationPortForwardingActionProvider.java (from rev 41405, 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/ui/viewer/actionProvider/ApplicationPortForwardingActionProvider.java (rev 0)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/ApplicationPortForwardingActionProvider.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -0,0 +1,10 @@
+package org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider;
+
+import org.jboss.tools.openshift.express.internal.core.portforward.ApplicationPortForwardingAction;
+
+public class ApplicationPortForwardingActionProvider extends AbstractOpenShiftExplorerViewerActionProvider {
+
+ 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/ui/viewer/actionProvider/ApplicationPortForwardingActionProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/TailServerLogActionProvider.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/TailServerLogActionProvider.java 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/TailServerLogActionProvider.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider;
-import org.jboss.tools.openshift.express.internal.ui.console.TailServerLogAction;
+import org.jboss.tools.openshift.express.internal.ui.action.TailServerLogAction;
/**
* @author Xavier Coulon
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-05-25 13:42:22 UTC (rev 41419)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-05-25 13:54:21 UTC (rev 41420)
@@ -75,7 +75,7 @@
setNeedsProgressMonitor(true);
this.wizardModel = new OpenShiftExpressApplicationWizardModel(user, project, application,
useExistingApplication);
- this.skipCredentialsPage = (user != null);
+ this.skipCredentialsPage = (user != null && user.isConnected());
}
OpenShiftExpressApplicationWizardModel getWizardModel() {
12 years, 7 months
JBoss Tools SVN: r41419 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal: ui/viewer and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-05-25 09:42:22 -0400 (Fri, 25 May 2012)
New Revision: 41419
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/ConnectToOpenShiftWizard.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
Log:
JBIDE-12008
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java 2012-05-25 13:16:50 UTC (rev 41418)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java 2012-05-25 13:42:22 UTC (rev 41419)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.core.console;
+import java.net.SocketTimeoutException;
import java.util.List;
import org.eclipse.jface.window.Window;
@@ -99,31 +100,60 @@
*/
public boolean checkForPassword() {
if(delegate == null) {
- try {
- this.alreadyPromptedForPassword = true;
- Display.getDefault().syncExec(new Runnable() { public void run() {
- final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- final Shell shell = activeWorkbenchWindow != null ? activeWorkbenchWindow.getShell() : null;
- if(shell == null) {
- Logger.error("Could not open Credentials Wizard: no shell available");
- return;
- }
- final IWizard connectToOpenShiftWizard = new ConnectToOpenShiftWizard();
- int returnCode = WizardUtils.openWizardDialog(connectToOpenShiftWizard, shell);
- if (returnCode == Window.OK) {
- Logger.debug("OpenShift Auth succeeded.");
- setDelegate(UserModel.getDefault().getRecentUser().getDelegate());
+ if( username != null && password != null ) {
+ if( checkCurrentCredentials() )
+ return true;
+ }
+ return promptForCredentials();
+ }
+ return true;
+ }
+
+ private boolean checkCurrentCredentials() {
+ // First check if the current username / pw work
+ IUser user = null;
+ try {
+ user = UserModel.getDefault().createUser(username, password);
+ setDelegate(user);
+ setConnected(true);
+ return true;
+ } catch( OpenShiftException ose ) {
+ // ignore
+ } catch( SocketTimeoutException ste ) {
+ // ignore
+ }
+ return false;
+ }
+
+ private boolean promptForCredentials() {
+ // The auto-login failed. Try to prompt
+ try {
+ this.alreadyPromptedForPassword = true;
+ Display.getDefault().syncExec(new Runnable() { public void run() {
+ final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ final Shell shell = activeWorkbenchWindow != null ? activeWorkbenchWindow.getShell() : null;
+ if(shell == null) {
+ Logger.error("Could not open Credentials Wizard: no shell available");
+ return;
+ }
+ final ConnectToOpenShiftWizard connectToOpenShiftWizard = new ConnectToOpenShiftWizard();
+ int returnCode = WizardUtils.openWizardDialog(connectToOpenShiftWizard, shell);
+ if (returnCode == Window.OK) {
+ Logger.debug("OpenShift Auth succeeded.");
+ UserDelegate created = connectToOpenShiftWizard.getUser();
+ if( created != null ) {
+ setDelegate(created.getDelegate());
setConnected(true);
- setRememberPassword(UserModel.getDefault().getRecentUser().isRememberPassword());
- } else {
- setConnected(false);
+ setRememberPassword(created.isRememberPassword());
}
- }});
- } catch( Exception e ) {
- Logger.error("Failed to retrieve User's password", e);
- }
+ } else {
+ setConnected(false);
+ }
+ }});
+ } catch( Exception e ) {
+ Logger.error("Failed to retrieve User's password", e);
}
- return (delegate != null);
+ return delegate != null;
}
public IApplication createApplication(final String applicationName, final ICartridge applicationType, final ApplicationScale scale, final IGearProfile gearProfile)
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-05-25 13:16:50 UTC (rev 41418)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserModel.java 2012-05-25 13:42:22 UTC (rev 41419)
@@ -62,8 +62,11 @@
}
/**
- * Create a user for temporary external use
+ * Create a user for temporary external use.
*
+ * This method WILL be long-running and should not be called directly
+ * from the UI thread unless proper care is taken.
+ *
* @param username
* @param password
* @return
@@ -144,13 +147,7 @@
String[] users = pref.get();
for (int i = 0; i < users.length; i++) {
String password = getPasswordFromSecureStorage(users[i]);
- try {
- addUser(new UserDelegate(createUser(users[i], password), true));
- } catch (OpenShiftException e) {
- addUser(new UserDelegate(users[i], password));
- } catch (SocketTimeoutException e) {
- addUser(new UserDelegate(users[i], password));
- }
+ addUser(new UserDelegate(users[i], password));
}
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/ConnectToOpenShiftWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/ConnectToOpenShiftWizard.java 2012-05-25 13:16:50 UTC (rev 41418)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/ConnectToOpenShiftWizard.java 2012-05-25 13:42:22 UTC (rev 41419)
@@ -11,8 +11,10 @@
package org.jboss.tools.openshift.express.internal.ui.viewer;
import org.eclipse.jface.wizard.Wizard;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.ui.wizard.ConnectToOpenShiftWizardModel;
import org.jboss.tools.openshift.express.internal.ui.wizard.CredentialsWizardPage;
+import org.w3c.dom.UserDataHandler;
/**
* @author Xavier Coulon
@@ -37,4 +39,8 @@
public void addPages() {
addPage(page);
}
+
+ public UserDelegate getUser() {
+ return page.getUser();
+ }
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2012-05-25 13:16:50 UTC (rev 41418)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2012-05-25 13:42:22 UTC (rev 41419)
@@ -42,10 +42,12 @@
import org.jboss.tools.common.ui.DelegatingProgressMonitor;
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.common.ui.databinding.ParametrizableWizardPageSupport;
+import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.OpenshiftUIMessages;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
+import org.w3c.dom.UserDataHandler;
/**
* @author Andre Dietisheim
@@ -242,4 +244,8 @@
return targets;
}
}
+
+ public UserDelegate getUser() {
+ return pageModel.getUser();
+ }
}
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-05-25 13:16:50 UTC (rev 41418)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-05-25 13:42:22 UTC (rev 41419)
@@ -217,5 +217,9 @@
erasePasswordStore();
}
}
+
+ public UserDelegate getUser() {
+ return wizardModel.getUser();
+ }
}
12 years, 7 months
JBoss Tools SVN: r41416 - in trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim: resources and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2012-05-25 08:45:27 -0400 (Fri, 25 May 2012)
New Revision: 41416
Removed:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/android/
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/model/SkinMap.java
trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg
Log:
https://issues.jboss.org/browse/JBIDE-10945 : BrowserSim: create more skins
https://issues.jboss.org/browse/JBIDE-11636 : BrowserSim: Android skin
https://issues.jboss.org/browse/JBIDE-12007 : BrowserSim: disable Android skin
- disabled Android skin
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/model/SkinMap.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/model/SkinMap.java 2012-05-25 12:08:56 UTC (rev 41415)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/model/SkinMap.java 2012-05-25 12:45:27 UTC (rev 41416)
@@ -16,7 +16,6 @@
import org.jboss.tools.vpe.browsersim.ui.skin.BrowserSimSkin;
import org.jboss.tools.vpe.browsersim.ui.skin.NativeSkin;
-import org.jboss.tools.vpe.browsersim.ui.skin.android.AndroidResizableSkin;
import org.jboss.tools.vpe.browsersim.ui.skin.ios.AppleIPhone3ResizableSkin;
import org.jboss.tools.vpe.browsersim.ui.skin.ios.AppleIPhone4ResizableSkin;
@@ -30,7 +29,7 @@
map.put(AppleIPhone3ResizableSkin.IPHONE3_SKIN_ID, AppleIPhone3ResizableSkin.class);
map.put(AppleIPhone4ResizableSkin.IPHONE4_SKIN_ID, AppleIPhone4ResizableSkin.class);
- map.put(AndroidResizableSkin.ANDROID_SKIN_ID, AndroidResizableSkin.class);
+// map.put(AndroidResizableSkin.ANDROID_SKIN_ID, AndroidResizableSkin.class);
}
public static SkinMap getInstance() {
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg 2012-05-25 12:08:56 UTC (rev 41415)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.browsersim/src/org/jboss/tools/vpe/browsersim/resources/config/devices.cfg 2012-05-25 12:45:27 UTC (rev 41416)
@@ -6,8 +6,8 @@
Apple iPad 2 768 1024 1 Mozilla/5.0 (iPad; U; CPU OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8G4 Safari/6533.18.5 iPhone 4
Apple iPhone 3 320 480 1 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7 iPhone 3
Apple iPhone 4 640 960 2 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7 iPhone 4
-RIM BlackBerry Bold Touch 9900 640 480 1 Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.246 Mobile Safari/534.1+ Android
-Samsung Galaxy S 480 800 1.5 Mozilla/5.0 (Linux; U; Android 2.3.3; en-us; GT-I9000 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 Android
-Samsung Galaxy S II 480 800 1.5 Mozilla/5.0 (Linux; U; Android 2.3; en-us; GT-I9100 Build/GRH78) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 Android
-Samsung Galaxy Nexus 720 1280 2 Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML like Gecko) Version/4.0 Mobile Safari/534.30 Android
-Samsung Galaxy Tab 10.1 800 1280 1.5 Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; GT-P7100 Build/HRI83) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 MobileSafari/534.13 Android
+RIM BlackBerry Bold Touch 9900 640 480 1 Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.246 Mobile Safari/534.1+ iPhone 3
+Samsung Galaxy S 480 800 1.5 Mozilla/5.0 (Linux; U; Android 2.3.3; en-us; GT-I9000 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 iPhone 3
+Samsung Galaxy S II 480 800 1.5 Mozilla/5.0 (Linux; U; Android 2.3; en-us; GT-I9100 Build/GRH78) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 iPhone 3
+Samsung Galaxy Nexus 720 1280 2 Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML like Gecko) Version/4.0 Mobile Safari/534.30 iPhone 4
+Samsung Galaxy Tab 10.1 800 1280 1.5 Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; GT-P7100 Build/HRI83) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 MobileSafari/534.13 iPhone 4
12 years, 7 months
JBoss Tools SVN: r41415 - trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2012-05-25 08:08:56 -0400 (Fri, 25 May 2012)
New Revision: 41415
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java
Log:
https://issues.jboss.org/browse/JBIDE-11551 - SWTBot test was updated.
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java 2012-05-25 12:03:29 UTC (rev 41414)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java 2012-05-25 12:08:56 UTC (rev 41415)
@@ -33,7 +33,7 @@
public class ExternalizeStringsDialogTest extends VPEAutoTestCase {
private final String ENABLED_TEST_TEXT = "<html>Externalize Text</html>"; //$NON-NLS-1$
- private final String TOOL_TIP = (SWTJBTExt.isRunningOnMacOs() ? "Externalize selected string... (⌘7)" : "Externalize selected string... (Ctrl+7)"); //$NON-NLS-1$
+ private final String TOOL_TIP = (SWTJBTExt.isRunningOnMacOs() ? "Externalize selected string... (вЊ�7)" : "Externalize selected string... (Ctrl+7)"); //$NON-NLS-1$
private final String FOLDER_TEXT_LABEL = "Enter or select the parent folder:"; //$NON-NLS-1$
private final String INCORRECT_TABLE_VALUE = "Table value is incorrect"; //$NON-NLS-1$
private final String TOOLBAR_ICON_ENABLED = "Toolbar button should be enabled"; //$NON-NLS-1$
@@ -86,6 +86,7 @@
* Select some text
*/
editor.toTextEditor().selectRange(7, 18, 4);
+ util.waitForAll();
/*
* Get toolbar button
*/
@@ -152,6 +153,7 @@
*/
editor.toTextEditor().selectRange(7, 18, 15);
assertEquals("Replaced text is incorrect", "#{Message.User}", editor.toTextEditor().getSelection()); //$NON-NLS-1$ //$NON-NLS-2$
+ editor.close();
/*
* Check that properties file has been updated
*/
@@ -230,9 +232,8 @@
/*
* Get toolbar button
*/
- assertTrue(TOOLBAR_ICON_ENABLED, bot
- .toolbarButtonWithTooltip(TOOL_TIP)
- .isEnabled());
+ assertTrue(TOOLBAR_ICON_ENABLED,
+ bot.toolbarButtonWithTooltip(TOOL_TIP).isEnabled());
bot.toolbarButtonWithTooltip(TOOL_TIP).click();
bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
@@ -260,6 +261,7 @@
bot.button(WidgetVariables.OK_BUTTON).isEnabled());
bot.button(WidgetVariables.OK_BUTTON).click();
isUnusedDialogOpened = false;
+ editor.close();
/*
* Check that the new key has been added.
*/
@@ -271,6 +273,89 @@
assertEquals("'Messages.properties' was updated incorrectly", "User_1=User", line); //$NON-NLS-1$ //$NON-NLS-2$
}
+ public void testCompoundKeyWithDot() throws Throwable {
+ isUnusedDialogOpened = false;
+ /*
+ * Open simple html file in order to get the VPE toolbar
+ */
+ SWTBotEditor editor = SWTTestExt.packageExplorer.openFile(JBT_TEST_PROJECT_NAME,
+ "WebContent", "pages", TEST_PAGE); //$NON-NLS-1$ //$NON-NLS-2$
+ editor.setFocus();
+ /*
+ * Select some text
+ */
+ editor.toTextEditor().selectRange(7, 18, 4);
+ util.waitForAll();
+ /*
+ * Get toolbar button
+ */
+ assertTrue(TOOLBAR_ICON_ENABLED, bot
+ .toolbarButtonWithTooltip(TOOL_TIP).isEnabled());
+ bot.toolbarButtonWithTooltip(TOOL_TIP).click();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
+ isUnusedDialogOpened = true;
+ /*
+ * Check properties key and value fields
+ */
+ SWTBotText defKeyText = bot.textWithLabelInGroup(
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ assertNotNull("Cannot find 'Property Key' text field", defKeyText); //$NON-NLS-1$
+ assertText("User_1",defKeyText); //$NON-NLS-1$
+ defKeyText.setText("user.compoundKey"); //$NON-NLS-1$
+ SWTBotText defValueText = bot.textWithLabelInGroup(
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_VALUE,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ assertNotNull(CANNOT_FIND_PROPERTY_VALUE, defValueText);
+ assertText("User", defValueText); //$NON-NLS-1$
+ SWTBotCheckBox checkBox = bot.checkBox();
+ assertNotNull("Cannot find checkbox '" //$NON-NLS-1$
+ + JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_NEW_FILE + "'", //$NON-NLS-1$
+ checkBox);
+ /*
+ * Check that "Next" button is disabled
+ */
+ assertFalse("Checkbox should be unchecked.", //$NON-NLS-1$
+ checkBox.isChecked());
+ assertFalse("Next button should be disabled.", //$NON-NLS-1$
+ bot.button(WidgetVariables.NEXT_BUTTON).isEnabled());
+ /*
+ * Select existed resource bundle
+ */
+ SWTBotCombo combo = bot.comboBox();
+ combo.setSelection(0);
+ assertText("demo.Messages", combo); //$NON-NLS-1$
+ util.waitForAll();
+ /*
+ * Press OK and replace the text in the editor
+ */
+ assertTrue("(OK) button should be enabled.", //$NON-NLS-1$
+ bot.button(WidgetVariables.OK_BUTTON).isEnabled());
+ bot.button(WidgetVariables.OK_BUTTON).click();
+ isUnusedDialogOpened = false;
+ /*
+ * Check replaced text
+ */
+ editor.toTextEditor().selectRange(7, 18, 30);
+ assertEquals("Replaced text is incorrect", "#{Message['user.compoundKey']}", editor.toTextEditor().getSelection()); //$NON-NLS-1$ //$NON-NLS-2$
+ editor.close();
+ /*
+ * Check that properties file has been updated
+ */
+ SWTBotEditor editor2 = SWTTestExt.eclipse.openFile(
+ JBT_TEST_PROJECT_NAME, "JavaSource", "demo", //$NON-NLS-1$ //$NON-NLS-2$
+ "Messages.properties"); //$NON-NLS-1$
+ /*
+ * Select the 4th line.
+ * In the 3rd line should be results from the previous test "User=User".
+ * If previous test failed -- it could crash this one as well.
+ */
+ editor2.toTextEditor().selectLine(5);
+ String line = editor2.toTextEditor().getSelection();
+ assertEquals("'Messages.properties' was updated incorrectly", "user.compoundKey=User", line); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
public void testExternalizeStringsDialogInXhtml() throws Throwable {
isUnusedDialogOpened = false;
/*
@@ -397,6 +482,7 @@
* Select some text
*/
editor.toTextEditor().selectRange(13, 15, 1);
+ util.waitForAll();
/*
* There is an exception caused by the fact that
* line delimiter was selected.
@@ -421,9 +507,8 @@
/*
* Activate the dialog
*/
- assertTrue(TOOLBAR_ICON_ENABLED, bot
- .toolbarButtonWithTooltip(TOOL_TIP)
- .isEnabled());
+ assertTrue(TOOLBAR_ICON_ENABLED,
+ bot.toolbarButtonWithTooltip(TOOL_TIP).isEnabled());
bot.toolbarButtonWithTooltip(TOOL_TIP).click();
bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
@@ -479,6 +564,8 @@
* Check selection in the attribute's value
*/
editor.toTextEditor().selectRange(22, 50, 0);
+ KeyboardHelper.typeKeyCodeUsingAWT(KeyEvent.VK_RIGHT);
+ util.waitForAll();
/*
* Activate the dialog
*/
@@ -987,7 +1074,5 @@
bot.button(WidgetVariables.NEXT_BUTTON).click();
return editor;
- }
-
-
-}
+ }
+}
\ No newline at end of file
12 years, 7 months