From 0ab66d8025884ac7718480f8b865579aa4d11616 Mon Sep 17 00:00:00 2001 From: Erin Harris Date: Thu, 23 Jan 2020 10:47:56 -0500 Subject: [PATCH] CW Issue #1845: Add scheme to tekton url and move action to the connection --- .../internal/connection/ConnectionEnv.java | 4 ++-- .../CodewindApplicationActionProvider.java | 7 +----- .../actions/OpenTektonDashboardAction.java | 22 +++++++++---------- .../RemoteConnectionActionProvider.java | 7 +++++- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dev/org.eclipse.codewind.core/src/org/eclipse/codewind/core/internal/connection/ConnectionEnv.java b/dev/org.eclipse.codewind.core/src/org/eclipse/codewind/core/internal/connection/ConnectionEnv.java index 5168086c0..6615782b8 100644 --- a/dev/org.eclipse.codewind.core/src/org/eclipse/codewind/core/internal/connection/ConnectionEnv.java +++ b/dev/org.eclipse.codewind.core/src/org/eclipse/codewind/core/internal/connection/ConnectionEnv.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 IBM Corporation and others. + * Copyright (c) 2019, 2020 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -78,7 +78,7 @@ public URL getTektonUrl() { return null; } try { - return new URL(urlStr); + return new URL("http://" + urlStr); } catch (Exception e) { Logger.logError("The Tekton dashboard URL is not valid: " + urlStr, e); } diff --git a/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/CodewindApplicationActionProvider.java b/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/CodewindApplicationActionProvider.java index 7e766fde6..7933ee62f 100644 --- a/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/CodewindApplicationActionProvider.java +++ b/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/CodewindApplicationActionProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018, 2019 IBM Corporation and others. + * Copyright (c) 2018, 2020 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -33,7 +33,6 @@ public class CodewindApplicationActionProvider extends CommonActionProvider { private AttachDebuggerAction attachDebuggerAction; private OpenAppMonitorAction openAppMonitorAction; private OpenPerfMonitorAction openPerfMonitorAction; - private OpenTektonDashboardAction openTektonDashboardAction; private ContainerShellAction containerShellAction; private EnableDisableAutoBuildAction enableDisableAutoBuildAction; private EnableDisableInjectMetricsAction enableDisableInjectMetricsAction; @@ -51,7 +50,6 @@ public void init(ICommonActionExtensionSite aSite) { attachDebuggerAction = new AttachDebuggerAction(selProvider); openAppMonitorAction = new OpenAppMonitorAction(selProvider); openPerfMonitorAction = new OpenPerfMonitorAction(selProvider); - openTektonDashboardAction = new OpenTektonDashboardAction(selProvider); containerShellAction = new ContainerShellAction(selProvider); enableDisableAutoBuildAction = new EnableDisableAutoBuildAction(selProvider); enableDisableInjectMetricsAction = new EnableDisableInjectMetricsAction(selProvider); @@ -81,9 +79,6 @@ public void fillContextMenu(IMenuManager menu) { if (openPerfMonitorAction.showAction()) { menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, openPerfMonitorAction); } - if (openTektonDashboardAction.showAction()) { - menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, openTektonDashboardAction); - } if (containerShellAction.showAction()) { menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, containerShellAction); } diff --git a/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/OpenTektonDashboardAction.java b/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/OpenTektonDashboardAction.java index 51836c97f..c117713a6 100644 --- a/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/OpenTektonDashboardAction.java +++ b/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/OpenTektonDashboardAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 IBM Corporation and others. + * Copyright (c) 2019, 2020 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -13,10 +13,10 @@ import java.net.URL; -import org.eclipse.codewind.core.internal.CodewindApplication; import org.eclipse.codewind.core.internal.CoreUtil; import org.eclipse.codewind.core.internal.Logger; import org.eclipse.codewind.core.internal.connection.ConnectionEnv.TektonDashboard; +import org.eclipse.codewind.core.internal.connection.RemoteConnection; import org.eclipse.codewind.ui.internal.messages.Messages; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelectionProvider; @@ -34,7 +34,7 @@ */ public class OpenTektonDashboardAction extends SelectionProviderAction { - protected CodewindApplication app; + protected RemoteConnection conn; public OpenTektonDashboardAction(ISelectionProvider selectionProvider) { super(selectionProvider, Messages.ActionOpenTektonDashboard); @@ -45,9 +45,9 @@ public OpenTektonDashboardAction(ISelectionProvider selectionProvider) { public void selectionChanged(IStructuredSelection sel) { if (sel.size() == 1) { Object obj = sel.getFirstElement(); - if (obj instanceof CodewindApplication) { - app = (CodewindApplication)obj; - setEnabled(app.isAvailable()); + if (obj instanceof RemoteConnection) { + conn = (RemoteConnection)obj; + setEnabled(conn.isConnected()); return; } } @@ -56,13 +56,13 @@ public void selectionChanged(IStructuredSelection sel) { @Override public void run() { - if (app == null) { + if (conn == null) { // should not be possible - Logger.logError("OpenTektonDashboardAction ran but no application was selected"); //$NON-NLS-1$ + Logger.logError("OpenTektonDashboardAction ran but no remote connection was selected"); //$NON-NLS-1$ return; } - TektonDashboard tekton = app.connection.getTektonDashboard(); + TektonDashboard tekton = conn.getTektonDashboard(); if (tekton == null) { // Should not happen since the action should not show if there is no dashboard Logger.logError("OpenTektonDashboardAction ran but there is no tekton dashboard in the environment"); //$NON-NLS-1$ @@ -97,7 +97,7 @@ public void run() { // the browser will be re-used browser = browserSupport .createBrowser(IWorkbenchBrowserSupport.NAVIGATION_BAR | IWorkbenchBrowserSupport.LOCATION_BAR, - app.projectID + "_tektonDashboard", app.name, NLS.bind(Messages.BrowserTooltipTektonDashboard, app.name)); + conn.getConid() + "_tektonDashboard", conn.getName(), NLS.bind(Messages.BrowserTooltipTektonDashboard, conn.getName())); } browser.openURL(url); @@ -107,6 +107,6 @@ public void run() { } public boolean showAction() { - return app != null && !app.connection.isLocal() && app.connection.getTektonDashboard() != null; + return conn != null && conn.isConnected() && conn.getTektonDashboard() != null; } } diff --git a/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/RemoteConnectionActionProvider.java b/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/RemoteConnectionActionProvider.java index 34b10b66a..b9ed617f6 100644 --- a/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/RemoteConnectionActionProvider.java +++ b/dev/org.eclipse.codewind.ui/src/org/eclipse/codewind/ui/internal/actions/RemoteConnectionActionProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019 IBM Corporation and others. + * Copyright (c) 2019, 2020 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 * which accompanies this distribution, and is available at @@ -37,6 +37,7 @@ public class RemoteConnectionActionProvider extends CommonActionProvider { private EditConnectionAction editConnectionAction; private RemoveConnectionAction removeConnectionAction; private RemoteDoubleClickAction remoteDoubleClickAction; + private OpenTektonDashboardAction openTektonDashboardAction; @Override public void init(ICommonActionExtensionSite aSite) { @@ -50,6 +51,7 @@ public void init(ICommonActionExtensionSite aSite) { editConnectionAction = new EditConnectionAction(selProvider); removeConnectionAction = new RemoveConnectionAction(selProvider); remoteDoubleClickAction = new RemoteDoubleClickAction(selProvider); + openTektonDashboardAction = new OpenTektonDashboardAction(selProvider); } @Override @@ -62,6 +64,9 @@ public void fillContextMenu(IMenuManager menu) { menu.appendToGroup(ICommonMenuConstants.GROUP_ADDITIONS, connectDisconnectAction); menu.appendToGroup(ICommonMenuConstants.GROUP_ADDITIONS, editConnectionAction); menu.appendToGroup(ICommonMenuConstants.GROUP_ADDITIONS, removeConnectionAction); + if (openTektonDashboardAction.showAction()) { + menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, openTektonDashboardAction); + } } @Override