Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JBIDE-10939] added "New/Edit Connection" to OS Explorer context menu #199

Merged
merged 1 commit into from
Jul 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ openshift.command.managekeys=Manage SSH Keys...
openshift.command.application.restart=Restart
openshift.command.showenvironment=Environment Variables
openshift.command.configureMarkers=Configure Markers...
openshift.command.newconnection=New Connection...
openshift.command.editconnection=Edit Connection...
openshift.menu.openshift=OpenShift
137 changes: 101 additions & 36 deletions plugins/org.jboss.tools.openshift.express.ui/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</category>
<wizard
category="org.jboss.ide.eclipse.as.openshift.express.ui.wizard.category"
class="org.jboss.tools.openshift.express.internal.ui.wizard.application.NewOpenShiftExpressApplicationWizard"
class="org.jboss.tools.openshift.express.internal.ui.wizard.application.NewOpenShiftApplicationWizard"
icon="icons/openshift-logo-white-icon.png"
id="org.jboss.ide.eclipse.as.openshift.express.ui.wizard.createNewApplicationWizard"
name="OpenShift Application"
Expand Down Expand Up @@ -652,30 +652,6 @@
</actionProvider>
</extension>

<extension
point="org.eclipse.ui.viewActions">
<viewContribution
id="org.jboss.tools.openshift.express.ui.explorer.expressConsoleViewContribution"
targetID="org.jboss.tools.openshift.express.ui.explorer.expressConsoleView">
<!--action
class="org.jboss.tools.openshift.express.internal.ui.explorer.actionDelegate.RefreshViewerActionDelegate"
icon="icons/refresh.gif"
id="org.jboss.tools.openshift.express.ui.viewActions.refreshAction"
label="Refresh"
style="push"
toolbarPath="openshift">
</action-->
<action
class="org.jboss.tools.openshift.express.internal.ui.explorer.actionDelegate.OpenConnectionDialogActionDelegate"
icon="icons/resource_obj.gif"
id="org.jboss.tools.openshift.express.ui.viewActions.openConnectionWizard"
label="Connect"
style="push"
toolbarPath="openshift"
tooltip="Connect to OpenShift">
</action>
</viewContribution>
</extension>
<!-- when using the 'classic' properties view. -->
<extension
point="org.eclipse.core.runtime.adapters">
Expand Down Expand Up @@ -791,16 +767,91 @@
</view>
</perspectiveExtension>
</extension>
<!-- ssh keys -->
<!-- New Connection OpenShift Explorer -->
<extension
point="org.eclipse.ui.commands">
<command
id="org.jboss.tools.openshift.express.ui.command.manageKeys"
name="%openshift.command.managekeys">
id="org.jboss.tools.openshift.express.ui.command.newconnection"
name="%openshift.command.newconnection">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="org.jboss.tools.openshift.express.ui.command.newconnection"
class="org.jboss.tools.openshift.express.internal.ui.command.NewConnectionHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.jboss.tools.openshift.express.ui.explorer.expressConsoleView.popup?before=group.showIn">
<command
commandId="org.jboss.tools.openshift.express.ui.command.newconnection"
icon="icons/resource_obj.gif"
id="org.jboss.tools.openshift.express.ui.command.newconnection"
mnemonic="N">
<visibleWhen>
<or>
<with variable="activePartId">
<equals value="org.jboss.tools.openshift.express.ui.explorer.expressConsoleView" />
</with>
<with variable="selection">
<and>
<count value="1" />
<iterate ifEmpty="false" operator="or">
<instanceof
value="org.jboss.tools.openshift.express.internal.core.connection.Connection" />
</iterate>
</and>
</with>
</or>
</visibleWhen>
</command>
</menuContribution>
</extension>
<!-- Edit Connection -->
<extension
point="org.eclipse.ui.commands">
<command
id="org.jboss.tools.openshift.express.ui.command.showEnvironment"
name="%openshift.command.showenvironment">
id="org.jboss.tools.openshift.express.ui.command.editconnection"
name="%openshift.command.editconnection">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="org.jboss.tools.openshift.express.internal.ui.command.EditConnectionHandler"
commandId="org.jboss.tools.openshift.express.ui.command.editconnection">
</handler>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.jboss.tools.openshift.express.ui.explorer.expressConsoleView.popup?before=group.showIn">
<command
commandId="org.jboss.tools.openshift.express.ui.command.editconnection"
icon="icons/resource_obj.gif"
mnemonic="E">
<visibleWhen>
<with variable="selection">
<and>
<count value="1" />
<iterate ifEmpty="false" operator="or">
<instanceof
value="org.jboss.tools.openshift.express.internal.core.connection.Connection" />
</iterate>
</and>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="org.jboss.tools.openshift.express.ui.command.manageKeys"
name="%openshift.command.managekeys">
</command>
</extension>
<extension
Expand All @@ -809,12 +860,9 @@
class="org.jboss.tools.openshift.express.internal.ui.command.ManageSSHKeysHandler"
commandId="org.jboss.tools.openshift.express.ui.command.manageKeys">
</handler>
<handler
class="org.jboss.tools.openshift.express.internal.ui.command.ShowEnvironmentHandler"
commandId="org.jboss.tools.openshift.express.ui.command.showEnvironment">
</handler>
</extension>
<extension
<!-- manage keys OpenShift Explorer -->
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.jboss.tools.openshift.express.ui.explorer.expressConsoleView.popup?after=group.server">
Expand All @@ -836,7 +884,24 @@
</visibleWhen>
</command>
</menuContribution>
<!-- show environment OpenShift Explorer -->
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="org.jboss.tools.openshift.express.ui.command.showEnvironment"
name="%openshift.command.showenvironment">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="org.jboss.tools.openshift.express.internal.ui.command.ShowEnvironmentHandler"
commandId="org.jboss.tools.openshift.express.ui.command.showEnvironment">
</handler>
</extension>
<!-- show environment OpenShift Explorer -->
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.jboss.tools.openshift.express.ui.explorer.expressConsoleView.popup?before=group.edition">
<command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.jboss.tools.openshift.express.internal.ui.OpenShiftImages;
import org.jboss.tools.openshift.express.internal.ui.explorer.OpenShiftExplorerUtils;
import org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
import org.jboss.tools.openshift.express.internal.ui.wizard.application.NewOpenShiftExpressApplicationWizard;
import org.jboss.tools.openshift.express.internal.ui.wizard.application.NewOpenShiftApplicationWizard;
import org.jboss.tools.openshift.express.internal.ui.wizard.application.OpenShiftApplicationWizard;

/**
Expand All @@ -41,7 +41,7 @@ public void run() {

if (connection.connect()) {
try {
final OpenShiftApplicationWizard wizard = new NewOpenShiftExpressApplicationWizard(connection);
final OpenShiftApplicationWizard wizard = new NewOpenShiftApplicationWizard(connection);
new WizardDialog(new Shell(), wizard).open();
} catch(NullPointerException e) {
// swallow NPE that's caused by cancelling ssh keys / domain wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
import org.jboss.tools.openshift.express.internal.ui.viewer.ConnectionColumLabelProvider;
import org.jboss.tools.openshift.express.internal.ui.wizard.application.ImportOpenShiftApplicationWizard;
import org.jboss.tools.openshift.express.internal.ui.wizard.application.OpenShiftApplicationWizard;
import org.jboss.tools.openshift.express.internal.ui.wizard.connection.ConnectToOpenShiftWizard;
import org.jboss.tools.openshift.express.internal.ui.wizard.connection.ConnectionWizard;

import com.openshift.client.IApplication;
import com.openshift.client.NotFoundOpenShiftException;
Expand Down Expand Up @@ -263,7 +263,7 @@ private SelectionListener onNewConnection() {
@Override
public void widgetSelected(SelectionEvent e) {
Connection connection = UIUtils.getFirstElement(connectionComboViewer.getSelection(), Connection.class);
ConnectToOpenShiftWizard wizard = new ConnectToOpenShiftWizard(connection);
ConnectionWizard wizard = new ConnectionWizard(connection);
if (WizardUtils.openWizardDialog(
wizard, connectionComboViewer.getControl().getShell()) == Window.OK) {
connectionComboViewer.getControl().setEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2013 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.command;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.common.ui.WizardUtils;
import org.jboss.tools.openshift.express.internal.core.connection.Connection;
import org.jboss.tools.openshift.express.internal.ui.utils.UIUtils;
import org.jboss.tools.openshift.express.internal.ui.wizard.connection.ConnectionWizard;

/**
* @author Andre Dietisheim
*/
public class EditConnectionHandler extends AbstractHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Connection connection = UIUtils.getFirstElement(HandlerUtil.getCurrentSelection(event), Connection.class);
return openConnectionWizard(connection, event);
}

protected Object openConnectionWizard(Connection connection, ExecutionEvent event) {
final IWizard connectToOpenShiftWizard = new ConnectionWizard(connection);
WizardUtils.openWizardDialog(connectToOpenShiftWizard, HandlerUtil.getActiveShell(event));
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2013 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.command;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;

/**
* @author Andre Dietisheim
*/
public class NewConnectionHandler extends EditConnectionHandler {

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
return openConnectionWizard(null, event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@
*/
public class OpenShiftExplorerView extends CommonNavigator implements IConnectionsModelListener {

@Override
protected Object getInitialInput() {
return ConnectionsModelSingleton.getInstance();
}

@Override
protected CommonViewer createCommonViewer(Composite aParent) {
CommonViewer v = super.createCommonViewer(aParent);
ConnectionsModelSingleton.getInstance().addListener(this);
return v;
}

@Override
public void dispose() {
ConnectionsModelSingleton.getInstance().removeListener(this);
super.dispose();
Expand Down Expand Up @@ -61,14 +64,17 @@ public void run() {
});
}

@Override
public void connectionAdded(Connection user) {
refreshViewer();
}

@Override
public void connectionRemoved(Connection user) {
refreshViewer();
}

@Override
public void connectionChanged(Connection user) {
refreshViewer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.jboss.tools.openshift.express.internal.core.connection.Connection;
import org.jboss.tools.openshift.express.internal.core.connection.ConnectionsModelSingleton;
import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import org.jboss.tools.openshift.express.internal.ui.wizard.connection.ConnectToOpenShiftWizard;
import org.jboss.tools.openshift.express.internal.ui.wizard.connection.ConnectionWizard;

/**
* @author Xavier Coulon
Expand Down Expand Up @@ -76,7 +76,7 @@ private SelectionListener onLoginLinkClicked() {

@Override
public void widgetSelected(SelectionEvent e) {
final IWizard connectToOpenShiftWizard = new ConnectToOpenShiftWizard();
final IWizard connectToOpenShiftWizard = new ConnectionWizard();
int returnCode = WizardUtils.openWizardDialog(connectToOpenShiftWizard, commonViewer.getTree().getShell());
if (returnCode == Window.OK) {
Logger.debug("OpenShift Auth succeeded.");
Expand Down