Skip to content

Commit

Permalink
[JBIDE-19178] Simple 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 4fb317b commit 8f33efc
Show file tree
Hide file tree
Showing 17 changed files with 431 additions and 227 deletions.
Expand Up @@ -23,7 +23,8 @@ 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.apache.commons.lang;bundle-version="2.6.0",
org.jboss.tools.openshift.client;bundle-version="3.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor
Expand Down Expand Up @@ -106,3 +107,4 @@ Export-Package: org.jboss.tools.openshift.common.ui.connection;
org.jboss.tools.openshift.express.ui,
org.jboss.tools.openshift.test,
org.jboss.tools.openshift.ui"
Import-Package: org.eclipse.ui.views.properties.tabbed
Expand Up @@ -11,4 +11,7 @@ openshift.command.connection.edit = Edit Connection...
openshift.common.command.refresh.resource = Refresh
openshift.command.application.new = Application

openshift.menu.configureNewOpenShiftApplication = Deploy to OpenShift
openshift.menu.configureNewOpenShiftApplication = Deploy to OpenShift

#Labels for Explorer view tabbed properties
openshift.common.explorer.properties.tab.default=Details
42 changes: 42 additions & 0 deletions plugins/org.jboss.tools.openshift.common.ui/plugin.xml
Expand Up @@ -370,4 +370,46 @@
</extension>


<extension point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="org.jboss.tools.openshift.internal.common.ui.explorer.OpenShiftExplorerView"
class="org.jboss.tools.openshift.internal.common.ui.explorer.ExplorerViewTabbedPropertyAdapterFactory">
<adapter
type="org.eclipse.ui.views.properties.IPropertySheetPage">
</adapter>
</factory>
</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.express.ui.explorer.expressConsoleView.DefaultTab"></propertyCategory>
</propertyContributor>
</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.express.ui.explorer.expressConsoleView.DefaultTab"
id="org.jboss.tools.openshift.express.ui.explorer.expressConsoleView.DefaultTab"
label="%openshift.common.explorer.properties.tab.default">
</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.common.ui.explorer.DefaultPropertySection"
enablesFor="1"
id="org.jboss.tools.openshift.express.ui.explorer.expressConsoleView.DefaultSection"
tab="org.jboss.tools.openshift.express.ui.explorer.expressConsoleView.DefaultTab">
<input
type="java.lang.Object">
</input>
</propertySection>
</propertySections>
</extension>
</plugin>
Expand Up @@ -191,7 +191,7 @@ private void asyncViewerRefresh(final Runnable runner) {
control.getDisplay().asyncExec(runner);
}

protected void addChildrenToViewer(final Object parent, final Object [] objects) {
protected void addChildrenToViewer(final Object parent, final Object ... objects) {
asyncViewerRefresh(new Runnable() {
public void run() {
synchronized (viewer) {
Expand All @@ -201,7 +201,7 @@ public void run() {
});
}

protected void removeChildrenFromViewer(final Object parent, final Object [] objects) {
protected void removeChildrenFromViewer(final Object parent, final Object ... objects) {
asyncViewerRefresh(new Runnable() {
public void run() {
synchronized (viewer) {
Expand All @@ -211,6 +211,15 @@ public void run() {
}
});
}
protected void updateChildrenFromViewer(final Object ... objects) {
asyncViewerRefresh(new Runnable() {
public void run() {
synchronized (viewer) {
viewer.refresh(objects);
}
}
});
}

protected void refreshViewer(final Object object) {
asyncViewerRefresh(new Runnable() {
Expand Down
@@ -0,0 +1,56 @@
/*******************************************************************************
* 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.explorer;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.PropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;

public class DefaultPropertySection extends AbstractPropertySection {

private PropertySheetPage page;

public DefaultPropertySection() {
page = new PropertySheetPage();
}

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
page.createControl(parent);
}


@Override
public boolean shouldUseExtraSpace() {
return true;
}


@Override
public void dispose() {
page.dispose();
}

@Override
public void setInput(IWorkbenchPart part, ISelection selection) {
super.setInput(part, selection);
page.selectionChanged(part, selection);
}

@Override
public void refresh() {
page.refresh();
}

}
@@ -0,0 +1,64 @@
/*******************************************************************************
* 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.explorer;

import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;

/**
* An adapter factory to provide a tabbed property view in support of the
* OpenShift explorer
*
* @author jeff.cantrill
*
*/
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);
if (found != null) {
ITabbedPropertySheetPageContributor contrib = new ITabbedPropertySheetPageContributor() {
public String getContributorId() {
return VIEW_ID;
}
};
return new TabbedPropertySheetPage(contrib);
}
}
return null;
}

@Override
public Class<?>[] getAdapterList() {
return new Class[] { IPropertySheetPage.class };
}

private IWorkbenchPart findView(String id) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IWorkbenchPart part = page.findView(id);
return part;
}
}
return null;
}
}
11 changes: 7 additions & 4 deletions plugins/org.jboss.tools.openshift.ui/plugin.xml
Expand Up @@ -24,8 +24,6 @@
<or>
<instanceof
value="com.openshift.restclient.model.IResource" />
<instanceof
value="org.jboss.tools.openshift.internal.ui.explorer.ResourceGrouping" />
</or>
</possibleChildren>
<triggerPoints>
Expand All @@ -34,8 +32,6 @@
value="org.jboss.tools.openshift.core.connection.Connection" />
<instanceof
value="com.openshift.restclient.model.IProject" />
<instanceof
value="org.jboss.tools.openshift.internal.ui.explorer.ResourceGrouping" />
</or>
</triggerPoints>
</navigatorContent>
Expand Down Expand Up @@ -650,6 +646,13 @@
type="org.eclipse.wst.server.ui.IServerModule">
</adapter>
</factory>
<factory
adaptableType="org.jboss.tools.openshift.internal.ui.explorer.Deployment"
class="org.jboss.tools.openshift.internal.ui.property.OpenShiftPropertySourceAdapterFactory">
<adapter
type="org.eclipse.ui.views.properties.IPropertySource">
</adapter>
</factory>
</extension>

<!-- definitions -->
Expand Down
@@ -0,0 +1,65 @@
/*******************************************************************************
* 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.ui.explorer;

<<<<<<< HEAD
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
=======
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
>>>>>>> [JBIDE-19178] Simple deployment view

import com.openshift.restclient.model.IPod;
import com.openshift.restclient.model.IService;
import com.openshift.restclient.model.route.IRoute;

/**
* A deployment is the collection of resources
* that makes up an 'application'
*
* @author jeff.cantrill
*
*/
public class Deployment {

private IService service;
private Set<IRoute> routes;
private Set<IPod> pods;

public Deployment(IService service, Collection<IRoute> routes, Collection<IPod> pods) {
this.service = service;
this.pods = new HashSet<>(pods);
this.routes = new HashSet<>(routes);
}

public Collection<IPod> getPods() {
return Collections.unmodifiableSet(pods);
}
public Collection<IRoute> getRoutes() {
return Collections.unmodifiableSet(this.routes);
}
public IService getService() {
return this.service;
}

public void add(IPod pod) {
this.pods.add(pod);
}

public void remove(IPod pod) {
this.pods.remove(pod);
}

}

0 comments on commit 8f33efc

Please sign in to comment.