Skip to content

Commit

Permalink
[JBIDE-21359] Add build tab to explorer deployment view
Browse files Browse the repository at this point in the history
  • Loading branch information
jcantrill authored and fbricon committed Jan 20, 2016
1 parent 8f33efc commit 45c165f
Show file tree
Hide file tree
Showing 30 changed files with 1,481 additions and 271 deletions.
Expand Up @@ -27,6 +27,10 @@ public class StringUtils {
private static final String LINE_SEPARATOR_KEY = "line.separator";
private static final String SHORTENING_MARKER = "...";

public static String pluralize(String value) {
return value + "s";
}

public static String null2emptyString(String value) {
if (value != null) {
return value;
Expand Down
3 changes: 1 addition & 2 deletions plugins/org.jboss.tools.openshift.common.ui/.classpath
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Expand Up @@ -23,8 +23,7 @@ Require-Bundle: org.jboss.tools.openshift.common.core;bundle-version="[3.0.0,4.0
org.eclipse.core.resources;bundle-version="3.9.100",
org.eclipse.core.runtime,
org.eclipse.m2e.core;bundle-version="1.6.0",
org.apache.commons.lang;bundle-version="2.6.0",
org.jboss.tools.openshift.client;bundle-version="3.1.0"
org.apache.commons.lang;bundle-version="2.6.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor
Expand Down
3 changes: 0 additions & 3 deletions plugins/org.jboss.tools.openshift.common.ui/plugin.xml
Expand Up @@ -361,15 +361,12 @@
</command>
</menuContribution>
</extension>

<!-- Core UI Integration: credentials prompt -->
<extension
point="org.jboss.tools.openshift.core.credentialsPrompterUI">
<credentialsPrompterUI
class="org.jboss.tools.openshift.common.ui.connection.CredentialsPrompter" />
</extension>


<extension point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="org.jboss.tools.openshift.internal.common.ui.explorer.OpenShiftExplorerView"
Expand Down
Expand Up @@ -16,6 +16,7 @@
import org.eclipse.ui.views.properties.PropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.jboss.tools.openshift.internal.common.ui.utils.DisposeUtils;

public class DefaultPropertySection extends AbstractPropertySection {

Expand Down Expand Up @@ -50,7 +51,9 @@ public void setInput(IWorkbenchPart part, ISelection selection) {

@Override
public void refresh() {
page.refresh();
if(!DisposeUtils.isDisposed(page.getControl())){
page.refresh();
}
}

}
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.jboss.tools.openshift.internal.common.ui.utils.OpenShiftUIUtils;

/**
* An adapter factory to provide a tabbed property view in support of the
Expand All @@ -27,16 +28,15 @@
*
*/
public class ExplorerViewTabbedPropertyAdapterFactory implements IAdapterFactory {
private static final String VIEW_ID = "org.jboss.tools.openshift.express.ui.explorer.expressConsoleView";

@SuppressWarnings({ "unchecked", "rawtypes" })
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adapterType == IPropertySheetPage.class) {
IWorkbenchPart found = findView(VIEW_ID);
IWorkbenchPart found = findView(OpenShiftUIUtils.OPENSHIFT_EXPLORER_VIEW_ID);
if (found != null) {
ITabbedPropertySheetPageContributor contrib = new ITabbedPropertySheetPageContributor() {
public String getContributorId() {
return VIEW_ID;
return OpenShiftUIUtils.OPENSHIFT_EXPLORER_VIEW_ID;
}
};
return new TabbedPropertySheetPage(contrib);
Expand Down
@@ -0,0 +1,71 @@
/*******************************************************************************
* Copyright (c) 2015 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.internal.common.ui.utils;


import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

import org.apache.commons.lang.time.DurationFormatUtils;
import org.jboss.tools.openshift.internal.common.ui.OpenShiftCommonUIActivator;

public class DateTimeUtils {

private static long NANOSECONDS_PER_SEC = 1000000;

private DateTimeUtils () {
}

public static String formatDuration(long nanoseconds) {
String[] parts = DurationFormatUtils.formatDuration(nanoseconds / NANOSECONDS_PER_SEC, "H:m:s:S").split(":");
StringBuilder builder = new StringBuilder();
if(Integer.valueOf(parts[0]) > 0){
builder.append(parts[0]).append(" hrs.");
}
if(Integer.valueOf(parts[1]) > 0){
builder.append(" ").append(parts[1]).append(" min.");
}
if(Integer.valueOf(parts[2]) > 0){
builder.append(" ").append(parts[2]).append(" sec.");
}
if(builder.length() == 0) {
builder.append("Now");
}
return builder.toString().trim();
}

public static String formatSince(String value) {
return formatSince(value, null);
}
public static String formatSince(String value, TimeZone timezone) {
try {
Date date = parse(value);
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.FULL);
if(timezone != null) {
formatter.setTimeZone(timezone);
}
return formatter.format(date);
} catch (ParseException e) {
OpenShiftCommonUIActivator.getDefault().getLogger().logWarning("Unable to parse format duration value: " + value, e);
}
return value;
}
public static Date parse(String value) throws ParseException {
//ref: http://www.java2s.com/Code/Java/Data-Type/ISO8601dateparsingutility.htm
//assume date is like: '2015-11-11T20:32:37Z'
String modValue = value.substring(0, value.length()-1) + "GMT-00:00";
SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
return parser.parse(modValue);
}
}
Expand Up @@ -20,7 +20,7 @@
*/
public class OpenShiftUIUtils {

private static final String OPENSHIFT_EXPLORER_VIEW_ID = "org.jboss.tools.openshift.express.ui.explorer.expressConsoleView";
public static final String OPENSHIFT_EXPLORER_VIEW_ID = "org.jboss.tools.openshift.express.ui.explorer.expressConsoleView";

public static void showOpenShiftExplorerView() {
Display.getDefault().asyncExec(new Runnable() {
Expand Down
Expand Up @@ -18,5 +18,14 @@
*/
public interface OpenShiftAPIAnnotations {

static final String BUILD_NAME = "openshift.io/build.name";
static final String BUILD_NUMBER = "openshift.io/build.number";

static final String BUILD_CONFIG_NAME = "openshift.io/build-config.name";

static final String DEPLOYMENT_CONFIG_LATEST_VERSION = "openshift.io/deployment-config.latest-version";
static final String DEPLOYMENT_CONFIG_NAME = "openshift.io/deployment-config.name";
static final String DEPLOYMENT_NAME = "openshift.io/deployment.name";

static final String GENERATED_BY = "openshift.io/generated-by";
}
1 change: 1 addition & 0 deletions plugins/org.jboss.tools.openshift.ui/META-INF/MANIFEST.MF
Expand Up @@ -36,6 +36,7 @@ Require-Bundle: org.jboss.tools.openshift.common.ui;bundle-version="[3.0.0,4.0.0
org.eclipse.jdt.launching;bundle-version="3.8.0",
org.eclipse.linuxtools.docker.core;bundle-version="1.2.0",
org.eclipse.linuxtools.docker.ui;bundle-version="1.2.0",
org.eclipse.ui.views.properties.tabbed,
org.eclipse.ui.ide,
org.eclipse.core.variables,
org.apache.commons.io;bundle-version="2.0.1",
Expand Down
3 changes: 3 additions & 0 deletions plugins/org.jboss.tools.openshift.ui/plugin.properties
Expand Up @@ -17,3 +17,6 @@ openshift.command.project.delete = Delete Project
openshift.command.editresource=Edit...
openshift.preferences.page.title = OpenShift 3
openshift.preferences.page.certificates.title=SSL certificates

#Labels for Explorer view tabbed properties
openshift.explorer.properties.tab.builds=Builds
105 changes: 100 additions & 5 deletions plugins/org.jboss.tools.openshift.ui/plugin.xml
Expand Up @@ -507,6 +507,39 @@
</visibleWhen>
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:org.jboss.tools.openshift.ui.properties.tab.BuildsTab">
<command
commandId="org.jboss.tools.openshift.ui.command.buildlogs"
id="org.jboss.tools.openshift.ui.explorer.command.buildlogs"
tooltip="The openshift binary must be set in user preferences in order to retrieve build logs">
</command>
<separator
name="org.jboss.tools.openshift.ui.properties.tab.BuildsTab.separator1"
visible="true">
</separator>
<command
commandId="org.jboss.tools.openshift.ui.command.startbuild"
style="push">
<parameter
name="org.jboss.tools.openshift.ui.command.startbuild.source"
value="BuildConfig">
</parameter>
</command>
<command
commandId="org.jboss.tools.openshift.ui.command.clonebuild"
style="push">
</command>
<separator
name="org.jboss.tools.openshift.ui.properties.tab.BuildsTab.separator2"
visible="true">
</separator>
<command
commandId="org.jboss.tools.openshift.ui.command.resource.delete"
style="push">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
Expand Down Expand Up @@ -647,11 +680,28 @@
</adapter>
</factory>
<factory
adaptableType="org.jboss.tools.openshift.internal.ui.explorer.Deployment"
adaptableType="org.jboss.tools.openshift.internal.ui.models.Deployment"
class="org.jboss.tools.openshift.internal.ui.property.OpenShiftPropertySourceAdapterFactory">
<adapter
type="org.eclipse.ui.views.properties.IPropertySource">
</adapter>
</factory>
<factory
adaptableType="org.jboss.tools.openshift.internal.common.ui.explorer.OpenShiftExplorerView"
class="org.jboss.tools.openshift.internal.ui.property.tabbed.ExplorerViewTabbedPropertyAdapterFactory">
<adapter
type="org.eclipse.ui.views.properties.IPropertySheetPage">
</adapter>
</factory>
<factory
adaptableType="org.jboss.tools.openshift.internal.ui.models.IResourceUIModel"
class="org.jboss.tools.openshift.internal.ui.property.OpenShiftPropertySourceAdapterFactory">
<adapter
type="org.eclipse.ui.views.properties.IPropertySource">
</adapter>
<adapter
type="org.eclipse.ui.views.properties.IPropertySource">
</adapter>
</factory>
</extension>

Expand Down Expand Up @@ -714,6 +764,11 @@
<command
id="org.jboss.tools.openshift.ui.command.startbuild"
name="%openshift.command.build.startbuild">
<commandParameter
id="org.jboss.tools.openshift.ui.command.startbuild.source"
name="name"
optional="true">
</commandParameter>
</command>
<command
id="org.jboss.tools.openshift.ui.command.clonebuild"
Expand Down Expand Up @@ -793,9 +848,6 @@
</handler>
</extension>
<!-- openshift explorer: import application -->
<extension
point="org.eclipse.ui.menus">
</extension>

<!-- Open In Browser -->
<extension
Expand All @@ -816,7 +868,7 @@
point="org.eclipse.ui.menus">
<!-- openshift explorer: open in browser -->
<menuContribution
locationURI="popup:org.jboss.tools.openshift.express.ui.explorer.expressConsoleViewPopup.showIn">
locationURI="popup:org.eclipse.ui.views.PropertySheet">
<command
commandId="org.jboss.tools.openshift.ui.command.openInBrowser"
icon="icons/open-browser.gif"
Expand Down Expand Up @@ -935,4 +987,47 @@
id="org.jboss.tools.openshift.ui.text.OpenShiftResourceDocumentProvider">
</provider>
</extension>

<extension point="org.eclipse.ui.editors.documentProviders">
<provider
inputTypes="org.jboss.tools.openshift.internal.ui.property.OpenShiftResourceInput"
class="org.jboss.tools.openshift.internal.ui.property.OpenShiftResourceDocumentProvider"
id="org.jboss.tools.openshift.ui.text.OpenShiftResourceDocumentProvider">
</provider>
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
<propertyTabs
contributorId="org.jboss.tools.openshift.express.ui.explorer.expressConsoleView">
<propertyTab
category="org.jboss.tools.openshift.ui.explorer.expressConsoleView.Deployments"
id="org.jboss.tools.openshift.ui.properties.tab.BuildsTab"
label="%openshift.explorer.properties.tab.builds">
</propertyTab>
</propertyTabs>
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertySections">
<propertySections
contributorId="org.jboss.tools.openshift.express.ui.explorer.expressConsoleView">
<propertySection
class="org.jboss.tools.openshift.internal.ui.property.tabbed.BuildsPropertySection"
enablesFor="1"
id="org.jboss.tools.openshift.ui.properties.tab.builds"
tab="org.jboss.tools.openshift.ui.properties.tab.BuildsTab">
<input
type="org.jboss.tools.openshift.internal.ui.models.Deployment">
</input>
</propertySection>
</propertySections>
</extension>
<extension
point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
<propertyContributor
contributorId="org.jboss.tools.openshift.express.ui.explorer.expressConsoleView">
<propertyCategory
category="org.jboss.tools.openshift.ui.explorer.expressConsoleView.Deployments">
</propertyCategory>
</propertyContributor>
</extension>
</plugin>

0 comments on commit 45c165f

Please sign in to comment.