Author: xcoulon
Date: 2012-02-16 11:52:55 -0500 (Thu, 16 Feb 2012)
New Revision: 38834
Added:
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/viewer/actionDelegate/
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/OpenConnectionDialogActionDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/RefreshViewerActionDelegate.java
Removed:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/OpenConnectionDialogActionDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshUserAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshUserActionDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/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/ui/action/AbstractAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/DeleteApplicationAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/ExpressConsoleView.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/TailServerLogActionProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/Logger.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/viewer/property/UserPropertySource.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.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/NewDomainDialog.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
Log:
Fixed - JBIDE-10832 - OpenShift UseCase: Creation of app fails when user has no domain
https://issues.jboss.org/browse/JBIDE-10832
Open - JBIDE-10812 - OpenShift console: can select multiple apps but then only 1 gets
deleted. List is not refreshed.
https://issues.jboss.org/browse/JBIDE-10812
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-16
16:46:55 UTC (rev 38833)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-02-16
16:52:55 UTC (rev 38834)
@@ -485,7 +485,7 @@
id="org.jboss.tools.openshift.express.ui.viewer.expressConsoleViewContribution"
targetID="org.jboss.tools.openshift.express.ui.viewer.expressConsoleView">
<action
-
class="org.jboss.tools.openshift.express.internal.ui.action.RefreshUserActionDelegate"
+
class="org.jboss.tools.openshift.express.internal.ui.viewer.actionDelegate.RefreshViewerActionDelegate"
icon="icons/refresh.gif"
id="org.jboss.tools.openshift.express.ui.viewActions.refreshAction"
label="Refresh"
@@ -493,7 +493,7 @@
toolbarPath="openshift">
</action>
<action
-
class="org.jboss.tools.openshift.express.internal.ui.action.OpenConnectionDialogActionDelegate"
+
class="org.jboss.tools.openshift.express.internal.ui.viewer.actionDelegate.OpenConnectionDialogActionDelegate"
icon="icons/resource_obj.gif"
id="org.jboss.tools.openshift.express.ui.viewActions.openConnectionWizard"
label="Connect"
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/AbstractAction.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/AbstractAction.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/AbstractAction.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -11,6 +11,8 @@
/** The current selection in the view. */
protected ISelection selection = null;
+
+ protected CommonViewer viewer;
public AbstractAction(String text) {
super(text);
@@ -24,6 +26,7 @@
public void selectionChanged(SelectionChangedEvent event) {
Object source = event.getSource();
if (source instanceof CommonViewer) {
+ this.viewer = (CommonViewer) source;
this.selection = ((CommonViewer) source).getSelection();
}
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/DeleteApplicationAction.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/DeleteApplicationAction.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/DeleteApplicationAction.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -1,11 +1,14 @@
package org.jboss.tools.openshift.express.internal.ui.action;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
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.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.ISharedImages;
@@ -33,16 +36,30 @@
*/
@Override
public void run() {
- if (isApplication(selection)) {
- final IApplication application = (IApplication)
((ITreeSelection)selection).getFirstElement();
- final String appName = application.getName();
- final boolean confirm = MessageDialog
- .openConfirm(
- Display.getCurrent().getActiveShell(),
- "Application deletion",
- "You are about to destroy the '" + appName + "'
application.\n" +
- "This is NOT reversible, all remote data for this application will be
removed.");
- if (confirm) {
+ final List<IApplication> appsToDelete = new ArrayList<IApplication>();
+ for (@SuppressWarnings("unchecked")
+ Iterator<Object> iterator = ((ITreeSelection) selection).iterator();
iterator.hasNext();) {
+ final Object element = iterator.next();
+ if (isApplication(element)) {
+ appsToDelete.add((IApplication) element);
+ }
+ }
+ if (appsToDelete.size() == 0) {
+ return;
+ }
+ boolean confirm = false;
+ if (appsToDelete.size() == 1) {
+ confirm = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
"Application deletion",
+ "You are about to destroy the '" + appsToDelete.get(0) + "'
application.\n"
+ + "This is NOT reversible, all remote data for this application will be
removed.");
+ } else if (appsToDelete.size() > 1) {
+ confirm = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(),
"Application deletion",
+ "You are about to destroy " + appsToDelete.size() + "
applications.\n"
+ + "This is NOT reversible, all remote data for those applications will be
removed.");
+ }
+ if (confirm) {
+ for (final IApplication application : appsToDelete) {
+ final String appName = application.getName();
Job job = new Job("Deleting application '" + appName +
"'...") {
protected IStatus run(IProgressMonitor monitor) {
try {
@@ -51,6 +68,9 @@
Logger.error("Failed to delete application '" + appName +
"'", e);
} finally {
monitor.done();
+ if (viewer != null) {
+ viewer.refresh();
+ }
}
return Status.OK_STATUS;
}
@@ -59,12 +79,13 @@
job.schedule(); // start as soon as possible
}
}
+ if (viewer != null) {
+ viewer.refresh();
+ }
}
- private boolean isApplication(ISelection selection) {
- return selection != null
- && selection instanceof ITreeSelection
- && ((ITreeSelection)selection).getFirstElement() instanceof IApplication;
+ private boolean isApplication(Object selection) {
+ return selection instanceof IApplication;
}
}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/OpenConnectionDialogActionDelegate.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/OpenConnectionDialogActionDelegate.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/OpenConnectionDialogActionDelegate.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -1,48 +0,0 @@
-package org.jboss.tools.openshift.express.internal.ui.action;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-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.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.jboss.tools.common.ui.WizardUtils;
-import org.jboss.tools.openshift.express.internal.core.console.UserModel;
-import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
-import org.jboss.tools.openshift.express.internal.ui.viewer.ConnectToOpenShiftWizard;
-
-public class OpenConnectionDialogActionDelegate implements IViewActionDelegate {
-
- private CommonNavigator view;
-
- @Override
- public void run(IAction action) {
- final Display display = Display.getCurrent();
- final Shell shell = new Shell(display);
- final IWizard connectToOpenShiftWizard = new ConnectToOpenShiftWizard();
- int returnCode = WizardUtils.openWizardDialog(connectToOpenShiftWizard, shell);
- if (returnCode == Window.OK) {
- Logger.debug("OpenShift Auth succeeded.");
- if (view != null) {
- view.getCommonViewer().setInput(UserModel.getDefault());
- }
- }
-
- }
-
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
-
- }
-
- @Override
- public void init(IViewPart view) {
- if (view instanceof CommonNavigator) {
- this.view = (CommonNavigator) view;
- }
- }
-
-}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshUserAction.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshUserAction.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshUserAction.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -1,28 +0,0 @@
-package org.jboss.tools.openshift.express.internal.ui.action;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
-
-public class RefreshUserAction implements IViewActionDelegate {
-
- @Override
- public void run(IAction action) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void init(IViewPart view) {
- // TODO Auto-generated method stub
-
- }
-
-}
Deleted:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshUserActionDelegate.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshUserActionDelegate.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshUserActionDelegate.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -1,50 +0,0 @@
-package org.jboss.tools.openshift.express.internal.ui.action;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-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.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.jboss.tools.common.ui.WizardUtils;
-import org.jboss.tools.openshift.express.internal.core.console.UserModel;
-import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
-import org.jboss.tools.openshift.express.internal.ui.viewer.ConnectToOpenShiftWizard;
-
-public class RefreshUserActionDelegate implements IViewActionDelegate {
-
- private CommonNavigator view;
-
- private ISelection selection;
-
- @Override
- public void run(IAction action) {
- final Display display = Display.getCurrent();
- final Shell shell = new Shell(display);
- final IWizard connectToOpenShiftWizard = new ConnectToOpenShiftWizard();
- int returnCode = WizardUtils.openWizardDialog(connectToOpenShiftWizard, shell);
- if (returnCode == Window.OK) {
- Logger.debug("OpenShift Auth succeeded.");
- if (view != null) {
- view.getCommonViewer().setInput(UserModel.getDefault());
- }
- }
-
- }
-
- @Override
- public void selectionChanged(IAction action, ISelection selection) {
- this.selection = selection;
- }
-
- @Override
- public void init(IViewPart view) {
- if (view instanceof CommonNavigator) {
- this.view = (CommonNavigator) view;
- }
- }
-
-}
Deleted:
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/action/TailServerLogAction.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/TailServerLogAction.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -1,236 +0,0 @@
-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.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.express.client.IApplication;
-import com.openshift.express.client.OpenShiftException;
-import com.openshift.express.client.utils.Base64Encoder;
-
-/**
- * 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);
- 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(Base64Encoder.encode(options.getBytes("UTF-8")), "UTF-8");
- 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/console/ExpressConsoleView.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/ExpressConsoleView.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/ExpressConsoleView.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -23,7 +23,7 @@
super.dispose();
}
- private void refreshViewer() {
+ public void refreshViewer() {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
getCommonViewer().refresh();
Copied:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/TailServerLogAction.java
(from rev 38805,
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/console/TailServerLogAction.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/TailServerLogAction.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -0,0 +1,237 @@
+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.action.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.express.client.IApplication;
+import com.openshift.express.client.OpenShiftException;
+import com.openshift.express.client.utils.Base64Encoder;
+
+/**
+ * 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);
+ 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(Base64Encoder.encode(options.getBytes("UTF-8")), "UTF-8");
+ 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/console/TailServerLogAction.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/console/TailServerLogActionProvider.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/TailServerLogActionProvider.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/console/TailServerLogActionProvider.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -1,6 +1,5 @@
package org.jboss.tools.openshift.express.internal.ui.console;
-import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.navigator.CommonActionProvider;
@@ -10,11 +9,7 @@
import org.eclipse.wst.server.core.IServer;
import org.jboss.ide.eclipse.as.ui.views.server.extensions.CommonActionProviderUtils;
import org.jboss.tools.openshift.express.internal.core.behaviour.ExpressServerUtils;
-import org.jboss.tools.openshift.express.internal.core.console.UserModel;
-import org.jboss.tools.openshift.express.internal.ui.action.TailServerLogAction;
-import com.openshift.express.client.IUser;
-
public class TailServerLogActionProvider extends CommonActionProvider {
private TailServerLogAction action;
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -38,5 +38,6 @@
public static String SHOW_PROPERTIES_VIEW_ACTION;
+ public static String REFRESH_VIEWER_ACTION;
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties 2012-02-16
16:52:55 UTC (rev 38834)
@@ -14,3 +14,5 @@
MAKE_SNAPSHOT_ACTION=Pull down Application Snapshot
SHOW_PROPERTIES_VIEW_ACTION=Properties
+REFRESH_VIEWER_ACTION=Refresh
+
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/Logger.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/Logger.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/Logger.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -120,6 +120,9 @@
*/
public static void debug(final String message) {
String debugOption = Platform.getDebugOption(DEBUG);
+ if( OpenShiftUIActivator.getDefault() == null )
+ return;
+
if (OpenShiftUIActivator.getDefault().isDebugging() &&
"true".equalsIgnoreCase(debugOption)) {
System.out.println("[" + Thread.currentThread().getName() + "] " +
message);
}
Copied:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/OpenConnectionDialogActionDelegate.java
(from rev 38738,
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/OpenConnectionDialogActionDelegate.java)
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/OpenConnectionDialogActionDelegate.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/OpenConnectionDialogActionDelegate.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -0,0 +1,48 @@
+package org.jboss.tools.openshift.express.internal.ui.viewer.actionDelegate;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+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.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.jboss.tools.common.ui.WizardUtils;
+import org.jboss.tools.openshift.express.internal.core.console.UserModel;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
+import org.jboss.tools.openshift.express.internal.ui.viewer.ConnectToOpenShiftWizard;
+
+public class OpenConnectionDialogActionDelegate implements IViewActionDelegate {
+
+ private CommonNavigator view;
+
+ @Override
+ public void run(IAction action) {
+ final Display display = Display.getCurrent();
+ final Shell shell = new Shell(display);
+ final IWizard connectToOpenShiftWizard = new ConnectToOpenShiftWizard();
+ int returnCode = WizardUtils.openWizardDialog(connectToOpenShiftWizard, shell);
+ if (returnCode == Window.OK) {
+ Logger.debug("OpenShift Auth succeeded.");
+ if (view != null) {
+ view.getCommonViewer().setInput(UserModel.getDefault());
+ }
+ }
+
+ }
+
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+
+ }
+
+ @Override
+ public void init(IViewPart view) {
+ if (view instanceof CommonNavigator) {
+ this.view = (CommonNavigator) view;
+ }
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/OpenConnectionDialogActionDelegate.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/RefreshViewerActionDelegate.java
(from rev 38738,
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshUserActionDelegate.java)
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/RefreshViewerActionDelegate.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/RefreshViewerActionDelegate.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -0,0 +1,32 @@
+package org.jboss.tools.openshift.express.internal.ui.viewer.actionDelegate;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IViewActionDelegate;
+import org.eclipse.ui.IViewPart;
+import org.jboss.tools.openshift.express.internal.ui.console.ExpressConsoleView;
+
+public class RefreshViewerActionDelegate implements IViewActionDelegate {
+
+ private ExpressConsoleView view;
+
+ protected ISelection selection;
+
+ @Override
+ public void run(IAction action) {
+ view.refreshViewer();
+ }
+
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+ this.selection = selection;
+ }
+
+ @Override
+ public void init(IViewPart view) {
+ if (view instanceof ExpressConsoleView) {
+ this.view = (ExpressConsoleView) view;
+ }
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionDelegate/RefreshViewerActionDelegate.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-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/TailServerLogActionProvider.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider;
-import org.jboss.tools.openshift.express.internal.ui.action.TailServerLogAction;
+import org.jboss.tools.openshift.express.internal.ui.console.TailServerLogAction;
/**
* @author Xavier Coulon
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/UserPropertySource.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/UserPropertySource.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/UserPropertySource.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -46,7 +46,7 @@
if (id.equals("Username")) {
return user.getRhlogin();
}
- if (id.equals("Domain")) {
+ if (id.equals("Domain") && user.hasDomain()) {
return user.getDomain().getNamespace() + "." +
user.getDomain().getRhcDomain();
}
} catch (OpenShiftException e) {
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPage.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -40,6 +40,7 @@
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.PageChangingEvent;
import org.eclipse.jface.fieldassist.AutoCompleteField;
import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecoration;
@@ -59,6 +60,8 @@
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -77,6 +80,7 @@
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.common.ui.databinding.ValueBindingBuilder;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.UIUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.UIUtils.IWidgetVisitor;
@@ -86,6 +90,7 @@
import com.openshift.express.client.IApplication;
import com.openshift.express.client.ICartridge;
import com.openshift.express.client.IEmbeddableCartridge;
+import com.openshift.express.client.IUser;
import com.openshift.express.client.NotFoundOpenShiftException;
import com.openshift.express.client.OpenShiftException;
@@ -141,36 +146,28 @@
useExistingAppBtn.setText("Use existing application:");
useExistingAppBtn.setToolTipText("Select an existing application or uncheck to
create a new one.");
useExistingAppBtn.setFocus();
- GridDataFactory.fillDefaults()
- .span(1, 1).align(SWT.FILL, SWT.CENTER).grab(false,
false).applyTo(useExistingAppBtn);
- IObservableValue useExistingAppObservable =
- BeanProperties.value(ApplicationConfigurationWizardPageModel.PROPERTY_USE_EXISTING_APPLICATION)
- .observe(pageModel);
- final IObservableValue useExistingAppBtnSelection =
- WidgetProperties.selection().observe(useExistingAppBtn);
+ GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).grab(false,
false)
+ .applyTo(useExistingAppBtn);
+ IObservableValue useExistingAppObservable = BeanProperties.value(
+ ApplicationConfigurationWizardPageModel.PROPERTY_USE_EXISTING_APPLICATION).observe(pageModel);
+ final IObservableValue useExistingAppBtnSelection =
WidgetProperties.selection().observe(useExistingAppBtn);
dbc.bindValue(useExistingAppBtnSelection, useExistingAppObservable);
// existing app name
this.existingAppNameText = new Text(existingAppSelectionGroup, SWT.BORDER);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true,
false).applyTo(existingAppNameText);
- IObservableValue existingAppNameTextObservable =
- WidgetProperties.text(SWT.Modify).observe(existingAppNameText);
- IObservableValue existingAppNameModelObservable =
- BeanProperties.value(
- ApplicationConfigurationWizardPageModel.PROPERTY_EXISTING_APPLICATION_NAME).observe(pageModel);
- ValueBindingBuilder
- .bind(existingAppNameTextObservable)
- .to(existingAppNameModelObservable)
- .in(dbc);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true,
false)
+ .applyTo(existingAppNameText);
+ IObservableValue existingAppNameTextObservable =
WidgetProperties.text(SWT.Modify).observe(existingAppNameText);
+ IObservableValue existingAppNameModelObservable = BeanProperties.value(
+ ApplicationConfigurationWizardPageModel.PROPERTY_EXISTING_APPLICATION_NAME).observe(pageModel);
+ ValueBindingBuilder.bind(existingAppNameTextObservable).to(existingAppNameModelObservable).in(dbc);
UIUtils.focusOnSelection(useExistingAppBtn, existingAppNameText);
createContentAssist(existingAppNameText);
this.browseAppsButton = new Button(existingAppSelectionGroup, SWT.NONE);
browseAppsButton.setText("Browse...");
browseAppsButton.addSelectionListener(onBrowseApps());
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).hint(100, SWT.DEFAULT).span(1, 1).grab(false, false)
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).hint(100,
SWT.DEFAULT).span(1, 1).grab(false, false)
.applyTo(browseAppsButton);
// observe the list of application, get notified once they have been
IObservableValue existingApplicationsLoaded =
@@ -180,21 +177,21 @@
new ApplicationToSelectNameValidator(
useExistingAppBtnSelection, existingAppNameTextObservable,
existingApplicationsLoaded);
dbc.addValidationStatusProvider(existingAppValidator);
- ControlDecorationSupport.create(
- existingAppValidator, SWT.LEFT | SWT.TOP, null, new
CustomControlDecorationUpdater(false));
+ ControlDecorationSupport.create(existingAppValidator, SWT.LEFT | SWT.TOP, null,
+ new CustomControlDecorationUpdater(false));
return existingAppSelectionGroup;
}
private void createContentAssist(final Text existingAppNameText) {
ControlDecoration dec = new ControlDecoration(existingAppNameText, SWT.TOP |
SWT.LEFT);
- FieldDecoration contentProposalFieldIndicator =
- FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
+ FieldDecoration contentProposalFieldIndicator =
FieldDecorationRegistry.getDefault().getFieldDecoration(
+ FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
dec.setImage(contentProposalFieldIndicator.getImage());
dec.setDescriptionText("Auto-completion is enabled when you start typing an
application name.");
dec.setShowOnlyOnFocus(true);
- AutoCompleteField adapter =
- new AutoCompleteField(existingAppNameText, new TextContentAdapter(), new String[]
{});
+ AutoCompleteField adapter = new AutoCompleteField(existingAppNameText, new
TextContentAdapter(),
+ new String[] {});
adapter.setProposals(pageModel.getApplicationNames());
}
@@ -226,11 +223,9 @@
this.newAppConfigurationGroup = new Group(parent, SWT.NONE);
newAppConfigurationGroup.setText("New application");
GridLayoutFactory.fillDefaults().numColumns(2).margins(6,
6).applyTo(newAppConfigurationGroup);
- GridDataFactory.fillDefaults()
- .grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(newAppConfigurationGroup);
+ GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL,
SWT.FILL).applyTo(newAppConfigurationGroup);
- IObservableValue useExistingApplication =
- WidgetProperties.selection().observe(useExistingAppBtn);
+ IObservableValue useExistingApplication =
WidgetProperties.selection().observe(useExistingAppBtn);
useExistingApplication.addValueChangeListener(
onUseExistingApplication(
@@ -240,46 +235,36 @@
newAppNameLabel.setText("Name:");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(newAppNameLabel);
this.newAppNameText = new Text(newAppConfigurationGroup, SWT.BORDER);
- GridDataFactory.fillDefaults()
- .grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(newAppNameText);
+ GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL,
SWT.FILL).applyTo(newAppNameText);
UIUtils.selectAllOnFocus(newAppNameText);
- final IObservableValue applicationNameTextObservable =
- WidgetProperties.text(SWT.Modify).observe(newAppNameText);
- final IObservableValue applicationNameModelObservable =
- BeanProperties
- .value(ApplicationConfigurationWizardPageModel.PROPERTY_APPLICATION_NAME)
- .observe(pageModel);
- ValueBindingBuilder
- .bind(applicationNameTextObservable)
- .to(applicationNameModelObservable)
- .in(dbc);
+ final IObservableValue applicationNameTextObservable =
WidgetProperties.text(SWT.Modify)
+ .observe(newAppNameText);
+ final IObservableValue applicationNameModelObservable = BeanProperties.value(
+ ApplicationConfigurationWizardPageModel.PROPERTY_APPLICATION_NAME).observe(pageModel);
+ ValueBindingBuilder.bind(applicationNameTextObservable).to(applicationNameModelObservable).in(dbc);
this.newAppTypeLabel = new Label(newAppConfigurationGroup, SWT.NONE);
newAppTypeLabel.setText("Type:");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1,
1).applyTo(newAppTypeLabel);
this.newAppCartridgeCombo = new Combo(newAppConfigurationGroup, SWT.BORDER |
SWT.READ_ONLY);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true,
false).applyTo(newAppCartridgeCombo);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).span(1, 1).grab(true,
false)
+ .applyTo(newAppCartridgeCombo);
fillCartridgesCombo(dbc, newAppCartridgeCombo);
- final ISWTObservableValue selectedCartridgeComboObservable =
- WidgetProperties.selection().observe(newAppCartridgeCombo);
- final IObservableValue selectedCartridgeModelObservable =
- BeanProperties.value(NewApplicationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(pageModel);
- ValueBindingBuilder
- .bind(selectedCartridgeComboObservable).converting(new StringToCartridgeConverter())
- .to(selectedCartridgeModelObservable).converting(new CartridgeToStringConverter())
- .in(dbc);
+ final ISWTObservableValue selectedCartridgeComboObservable =
WidgetProperties.selection().observe(
+ newAppCartridgeCombo);
+ final IObservableValue selectedCartridgeModelObservable = BeanProperties.value(
+ NewApplicationWizardPageModel.PROPERTY_SELECTED_CARTRIDGE).observe(pageModel);
+ ValueBindingBuilder.bind(selectedCartridgeComboObservable).converting(new
StringToCartridgeConverter())
+ .to(selectedCartridgeModelObservable).converting(new
CartridgeToStringConverter()).in(dbc);
final ISWTObservableValue useExistingAppBtnSelection =
WidgetProperties.selection().observe(useExistingAppBtn);
- final NewApplicationNameValidator newApplicationNameValidator =
- new NewApplicationNameValidator(
- useExistingAppBtnSelection, applicationNameTextObservable);
+ final NewApplicationNameValidator newApplicationNameValidator = new
NewApplicationNameValidator(
+ useExistingAppBtnSelection, applicationNameTextObservable);
dbc.addValidationStatusProvider(newApplicationNameValidator);
ControlDecorationSupport.create(newApplicationNameValidator, SWT.LEFT | SWT.TOP, null,
new CustomControlDecorationUpdater());
- final NewApplicationTypeValidator newApplicationTypeValidator =
- new NewApplicationTypeValidator(
- useExistingAppBtnSelection, selectedCartridgeComboObservable);
+ final NewApplicationTypeValidator newApplicationTypeValidator = new
NewApplicationTypeValidator(
+ useExistingAppBtnSelection, selectedCartridgeComboObservable);
dbc.addValidationStatusProvider(newApplicationTypeValidator);
ControlDecorationSupport.create(newApplicationTypeValidator, SWT.LEFT | SWT.TOP, null,
new CustomControlDecorationUpdater());
@@ -292,30 +277,28 @@
GridLayoutFactory.fillDefaults().numColumns(2).margins(6,
6).applyTo(newAppEmbeddableCartridgesGroup);
Composite tableContainer = new Composite(newAppEmbeddableCartridgesGroup, SWT.NONE);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.FILL).grab(true, true).span(1, 2).hint(400,
250).applyTo(tableContainer);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(1,
2).hint(400, 250)
+ .applyTo(tableContainer);
this.viewer = createTable(tableContainer);
- dbc.bindSet(
- ViewerProperties.checkedElements(IEmbeddableCartridge.class).observe(viewer),
+ dbc.bindSet(ViewerProperties.checkedElements(IEmbeddableCartridge.class).observe(viewer),
BeanProperties.set(ApplicationConfigurationWizardPageModel.PROPERTY_SELECTED_EMBEDDABLE_CARTRIDGES)
.observe(pageModel));
this.checkAllButton = new Button(newAppEmbeddableCartridgesGroup, SWT.PUSH);
checkAllButton.setText("&Select All");
- GridDataFactory.fillDefaults().
- hint(110, SWT.DEFAULT).grab(false, false).align(SWT.FILL,
SWT.TOP).applyTo(checkAllButton);
+ GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).grab(false,
false).align(SWT.FILL, SWT.TOP)
+ .applyTo(checkAllButton);
checkAllButton.addSelectionListener(onCheckAll());
this.uncheckAllButton = new Button(newAppEmbeddableCartridgesGroup, SWT.PUSH);
uncheckAllButton.setText("&Deselect All");
- GridDataFactory.fillDefaults()
- .hint(110, SWT.DEFAULT).grab(false, true).align(SWT.FILL,
SWT.TOP).applyTo(uncheckAllButton);
+ GridDataFactory.fillDefaults().hint(110, SWT.DEFAULT).grab(false, true).align(SWT.FILL,
SWT.TOP)
+ .applyTo(uncheckAllButton);
uncheckAllButton.addSelectionListener(onUncheckAll());
// bottom filler
Composite spacer = new Composite(newAppConfigurationGroup, SWT.NONE);
- GridDataFactory.fillDefaults()
- .span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(spacer);
+ GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true,
true).applyTo(spacer);
}
/**
@@ -327,8 +310,7 @@
* @param applicationBrowseButton
* @return
*/
- private IValueChangeListener onUseExistingApplication(final Group
- applicationConfigurationGroup,
+ private IValueChangeListener onUseExistingApplication(final Group
applicationConfigurationGroup,
final Text applicationNameText, final Button applicationBrowseButton) {
return new IValueChangeListener() {
@@ -347,8 +329,7 @@
}
/**
- * Enables/disables the given widgets based on the flag to use an existing
- * app or create a new application.
+ * Enables/disables the given widgets based on the flag to use an existing app or create
a new application.
*
* @param useExisting
* @param applicationConfigurationGroup
@@ -621,12 +602,11 @@
}
/**
- * Viewer element comparer based on #equals(). The default implementation in
- * CheckboxTableViewer compares elements based on instance identity.
+ * Viewer element comparer based on #equals(). The default implementation in
CheckboxTableViewer compares elements
+ * based on instance identity.
* <p>
- * We need this since the available cartridges (item listed in the viewer)
- * are not the same instance as the ones in the embedded application (items
- * to check in the viewer).
+ * We need this since the available cartridges (item listed in the viewer) are not the
same instance as the ones in
+ * the embedded application (items to check in the viewer).
*/
private static class EqualityComparer implements IElementComparer {
@@ -670,6 +650,32 @@
}.start();
}
+ @Override
+ protected void onPageWillGetActivated(Direction direction, PageChangingEvent event,
DataBindingContext dbc) {
+ if (direction == Direction.BACKWARDS) {
+ return;
+ }
+ try {
+ final IUser user = this.pageModel.getUser();
+ if (user != null && !user.hasDomain()) {
+ IWizard domainDialog = new NewDomainDialog(user);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(),
domainDialog);
+ dialog.create();
+ dialog.setBlockOnOpen(true);
+ int result = dialog.open();
+ if(result != Dialog.OK) {
+ final IWizardContainer container = getWizard().getContainer();
+ if(container instanceof WizardDialog) {
+ dbc.dispose();
+ ((WizardDialog)container).close();
+ }
+ }
+ }
+ } catch (OpenShiftException e) {
+ Logger.error("Failed to refresh OpenShift account info", e);
+ }
+ }
+
protected void loadOpenshiftResources(final DataBindingContext dbc) {
try {
WizardUtils.runInWizard(new Job("Loading existing applications...") {
@@ -836,8 +842,8 @@
return ValidationStatus.ok();
}
if (StringUtils.isEmpty(cartridge)) {
- return OpenShiftUIActivator.createCancelStatus(
- "Select an alphanumerical name and a type for the application to
create.");
+ return OpenShiftUIActivator
+ .createCancelStatus("Select an alphanumerical name and a type for the
application to create.");
}
return ValidationStatus.ok();
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationConfigurationWizardPageModel.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -73,7 +73,7 @@
public List<IApplication> getApplications() throws OpenShiftException {
IUser user = getUser();
- if (user == null) {
+ if (user == null || !user.hasDomain()) {
return Collections.emptyList();
}
return user.getApplications();
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-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPage.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -30,11 +30,13 @@
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Text;
@@ -47,6 +49,9 @@
import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.UIUtils;
+import com.openshift.express.client.IUser;
+import com.openshift.express.client.OpenShiftException;
+
/**
* @author Andre Dietisheim
* @author Xavier Coulon
@@ -56,14 +61,16 @@
protected static final String OPENSHIFT_EXPRESS_SIGNUP_URL =
"https://openshift.redhat.com/app/user/new/express"; //$NON-NLS-1$
private final CredentialsWizardPageModel pageModel;
+
+ private final IUserAwareModel wizardModel;
private Text rhLoginText = null;
private Text passwordText = null;
public CredentialsWizardPage(IWizard wizard, IUserAwareModel wizardModel) {
- super("OpenShift Connection", "Please provide your OpenShift Express
credentials.", "Server Connection",
- wizard);
+ super("OpenShift Connection", "Please provide your OpenShift Express
credentials.", "Server Connection", wizard);
this.pageModel = new CredentialsWizardPageModel(wizardModel);
+ this.wizardModel = wizardModel;
}
protected void doCreateControls(Composite container, DataBindingContext dbc) {
@@ -71,45 +78,38 @@
Link signupLink = new Link(container, SWT.WRAP);
signupLink.setText("If you do not have an account on OpenShift Express, please
sign up <a>here</a>.");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).span(2, 1).applyTo(signupLink);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(2,
1).applyTo(signupLink);
signupLink.addSelectionListener(onSignupLinkClicked());
Label fillerLabel = new Label(container, SWT.NONE);
- GridDataFactory.fillDefaults()
- .span(2, 1).hint(SWT.DEFAULT, 6).applyTo(fillerLabel);
+ GridDataFactory.fillDefaults().span(2, 1).hint(SWT.DEFAULT, 6).applyTo(fillerLabel);
Label rhLoginLabel = new Label(container, SWT.NONE);
rhLoginLabel.setText("&Username");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(rhLoginLabel);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(rhLoginLabel);
rhLoginText = new Text(container, SWT.BORDER);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(rhLoginText);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1,
1).applyTo(rhLoginText);
UIUtils.selectAllOnFocus(rhLoginText);
- final IObservableValue rhLoginObservable =
- BeanProperties.value(CredentialsWizardPageModel.PROPERTY_RHLOGIN).observe(pageModel);
+ final IObservableValue rhLoginObservable =
BeanProperties.value(CredentialsWizardPageModel.PROPERTY_RHLOGIN)
+ .observe(pageModel);
dbc.bindValue(WidgetProperties.text(SWT.Modify).observe(rhLoginText),
rhLoginObservable);
Label passwordLabel = new Label(container, SWT.NONE);
passwordLabel.setText("&Password");
- GridDataFactory.fillDefaults()
- .align(SWT.LEFT, SWT.CENTER).applyTo(passwordLabel);
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(passwordLabel);
passwordText = new Text(container, SWT.BORDER | SWT.PASSWORD);
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.CENTER).grab(true, false).span(1, 1).applyTo(passwordText);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).span(1,
1).applyTo(passwordText);
UIUtils.selectAllOnFocus(passwordText);
- final IObservableValue passwordModelObservable =
- BeanProperties.value(CredentialsWizardPageModel.PROPERTY_PASSWORD).observe(pageModel);
+ final IObservableValue passwordModelObservable = BeanProperties.value(
+ CredentialsWizardPageModel.PROPERTY_PASSWORD).observe(pageModel);
final ISWTObservableValue passwordTextObservable =
WidgetProperties.text(SWT.Modify).observe(passwordText);
dbc.bindValue(passwordTextObservable, passwordModelObservable);
- IObservableValue credentialsStatusObservable =
- BeanProperties.value(CredentialsWizardPageModel.PROPERTY_CREDENTIALS_STATUS).observe(pageModel);
- dbc.addValidationStatusProvider(
- new CredentialsInputValidator(rhLoginObservable, passwordModelObservable));
- final CredentialsStatusValidator credentialsStatusValidator =
- new CredentialsStatusValidator(credentialsStatusObservable, passwordTextObservable);
+ IObservableValue credentialsStatusObservable = BeanProperties.value(
+ CredentialsWizardPageModel.PROPERTY_CREDENTIALS_STATUS).observe(pageModel);
+ dbc.addValidationStatusProvider(new CredentialsInputValidator(rhLoginObservable,
passwordModelObservable));
+ final CredentialsStatusValidator credentialsStatusValidator = new
CredentialsStatusValidator(
+ credentialsStatusObservable, passwordTextObservable);
dbc.addValidationStatusProvider(credentialsStatusValidator);
ControlDecorationSupport.create(credentialsStatusValidator, SWT.LEFT | SWT.TOP);
@@ -117,12 +117,11 @@
// the text fields
Button rememberPasswordCheckBox = new Button(container, SWT.CHECK);
rememberPasswordCheckBox.setText("Save password (could trigger secure storage
login)");
- GridDataFactory.fillDefaults()
- .align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(rememberPasswordCheckBox);
- final IObservableValue rememberPasswordModelObservable =
- BeanProperties.value(CredentialsWizardPageModel.PROPERTY_REMEMBER_PASSWORD).observe(pageModel);
- final ISWTObservableValue rememberPasswordCheckBoxObservable =
- WidgetProperties.selection().observe(rememberPasswordCheckBox);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
false).applyTo(rememberPasswordCheckBox);
+ final IObservableValue rememberPasswordModelObservable = BeanProperties.value(
+ CredentialsWizardPageModel.PROPERTY_REMEMBER_PASSWORD).observe(pageModel);
+ final ISWTObservableValue rememberPasswordCheckBoxObservable =
WidgetProperties.selection().observe(
+ rememberPasswordCheckBox);
dbc.bindValue(rememberPasswordCheckBoxObservable, rememberPasswordModelObservable);
}
@@ -192,8 +191,7 @@
private final IObservableValue passwordObservable;
- public CredentialsInputValidator(IObservableValue rhLoginObservable,
- IObservableValue passwordObservable) {
+ public CredentialsInputValidator(IObservableValue rhLoginObservable, IObservableValue
passwordObservable) {
this.rhLoginObservable = rhLoginObservable;
this.passwordObservable = passwordObservable;
}
@@ -204,8 +202,7 @@
// something..
final String rhLoginValue = (String) rhLoginObservable.getValue();
final String passwordValue = (String) passwordObservable.getValue();
- if (!StringUtils.isEmpty(rhLoginValue)
- && !StringUtils.isEmpty(passwordValue)) {
+ if (!StringUtils.isEmpty(rhLoginValue) && !StringUtils.isEmpty(passwordValue))
{
return ValidationStatus.ok();
}
return ValidationStatus.cancel("Please provide your OpenShift Express user
credentials");
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainDialog.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -26,7 +26,6 @@
*/
public class NewDomainDialog extends Wizard {
- private String namespace;
private NewDomainWizardPageModel model;
public NewDomainDialog(IUser user) {
@@ -56,6 +55,6 @@
@Override
public void addPages() {
- addPage(new NewDomainWizardPage(namespace, model, this));
+ addPage(new NewDomainWizardPage(model, this));
}
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/NewDomainWizardPage.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -63,7 +63,7 @@
private NewDomainWizardPageModel model;
- public NewDomainWizardPage(String namespace, NewDomainWizardPageModel model, IWizard
wizard) {
+ public NewDomainWizardPage(NewDomainWizardPageModel model, IWizard wizard) {
super("Domain Creation", "Create a new domain", "New
Domain", wizard);
this.model = model;
}
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-02-16
16:46:55 UTC (rev 38833)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java 2012-02-16
16:52:55 UTC (rev 38834)
@@ -41,6 +41,7 @@
import org.jboss.tools.openshift.express.internal.ui.ImportFailedException;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import org.jboss.tools.openshift.express.internal.ui.WontOverwriteException;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import com.openshift.express.client.IApplication;
import com.openshift.express.client.IEmbeddableCartridge;
@@ -73,7 +74,7 @@
void setWizardModel(OpenShiftExpressApplicationWizardModel wizardModel) {
this.wizardModel = wizardModel;
}
-
+
OpenShiftExpressApplicationWizardModel getWizardModel() {
return wizardModel;
}
@@ -92,7 +93,7 @@
protected void openError(final String title, final String message) {
getShell().getDisplay().syncExec(new Runnable() {
-
+
@Override
public void run() {
MessageDialog.openError(getShell(), title, message);
@@ -103,18 +104,16 @@
protected boolean askForConfirmation(final String message, final String applicationName)
{
final boolean[] confirmed = new boolean[1];
getShell().getDisplay().syncExec(new Runnable() {
-
+
@Override
public void run() {
- confirmed[0] = MessageDialog.openConfirm(
- getShell(),
- NLS.bind("Import OpenShift Application ", applicationName),
- message);
+ confirmed[0] = MessageDialog.openConfirm(getShell(),
+ NLS.bind("Import OpenShift Application ", applicationName), message);
}
});
return confirmed[0];
}
-
+
public void setSelectedApplication(IApplication application) {
getWizardModel().setApplication(application);
}
@@ -148,7 +147,7 @@
IWizardPage[] pages = getPages();
return initialUser == null ? pages[0] : pages[1];
}
-
+
public void setInitialUser(IUser user) {
this.initialUser = user;
}
@@ -173,13 +172,12 @@
private boolean importProject() {
try {
final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
- IStatus jobResult = WizardUtils.runInWizard(
- new ImportJob(delegatingMonitor), delegatingMonitor, getContainer());
+ IStatus jobResult = WizardUtils.runInWizard(new ImportJob(delegatingMonitor),
delegatingMonitor,
+ getContainer());
return JobUtils.isOk(jobResult);
} catch (Exception e) {
- ErrorDialog.openError(getShell(), "Error", "Could not create local git
repository.",
- OpenShiftUIActivator.createErrorStatus(
- "An exception occurred while creating local git repository.", e));
+ ErrorDialog.openError(getShell(), "Error", "Could not create local git
repository.", OpenShiftUIActivator
+ .createErrorStatus("An exception occurred while creating local git
repository.", e));
return false;
}
}
@@ -196,8 +194,8 @@
return Status.OK_STATUS;
} catch (Exception e) {
// TODO: refresh user
- return OpenShiftUIActivator.createErrorStatus(
- "Could not create application \"{0}\"", e,
applicationName);
+ return OpenShiftUIActivator.createErrorStatus("Could not create application
\"{0}\"",
+ e, applicationName);
}
}
@@ -218,16 +216,15 @@
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
- if (selectedCartridges != null
- && !selectedCartridges.isEmpty()) {
+ if (selectedCartridges != null && !selectedCartridges.isEmpty()) {
List<IEmbeddableCartridge> embeddableCartridges = new
ArrayList<IEmbeddableCartridge>();
embeddableCartridges.addAll(selectedCartridges);
application.addEmbbedCartridges(embeddableCartridges);
}
} catch (OpenShiftException e) {
- return OpenShiftUIActivator.createErrorStatus(
- NLS.bind("Could not embed cartridges to application {0}"
- , getWizardModel().getApplication().getName()), e);
+ return OpenShiftUIActivator.createErrorStatus(NLS.bind(
+ "Could not embed cartridges to application {0}", getWizardModel()
+ .getApplication().getName()), e);
}
return Status.OK_STATUS;
}
@@ -239,8 +236,7 @@
}
/**
- * A workspace job that will create a new project or enable the selected
- * project to be used with OpenShift.
+ * A workspace job that will create a new project or enable the selected project to be
used with OpenShift.
*/
class ImportJob extends WorkspaceJob {