Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #546 from eharris369/CW1845-addSchemeToTektonURL_080
Browse files Browse the repository at this point in the history
CW Issue #1845: Add scheme to tekton url and move action to the connection
  • Loading branch information
eharris369 authored Jan 23, 2020
2 parents eda24f8 + 0ab66d8 commit 57119e4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -34,7 +34,7 @@
*/
public class OpenTektonDashboardAction extends SelectionProviderAction {

protected CodewindApplication app;
protected RemoteConnection conn;

public OpenTektonDashboardAction(ISelectionProvider selectionProvider) {
super(selectionProvider, Messages.ActionOpenTektonDashboard);
Expand All @@ -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;
}
}
Expand All @@ -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$
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 57119e4

Please sign in to comment.