You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/01/04 14:22:42 UTC
svn commit: r1227144 [13/18] - in /karaf/eik/trunk: ./ features/
features/info.evanchik.eclipse.karaf.feature/
features/info.evanchik.eclipse.karaf.jmx.feature/
features/info.evanchik.eclipse.karaf.update/
features/info.evanchik.eclipse.karaf.update/fe...
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/BundlesView.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/BundlesView.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/BundlesView.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/BundlesView.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2008 Neil Bartlett
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Neil Bartlett - initial implementation
+ * Stephen Evanchik - Updated to use data provider services
+ */
+package info.evanchik.eclipse.karaf.workbench.ui.views.bundle;
+
+import info.evanchik.eclipse.karaf.workbench.KarafWorkbenchActivator;
+import info.evanchik.eclipse.karaf.workbench.ui.views.FilteredViewPart;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PartInitException;
+import org.osgi.framework.Bundle;
+
+public class BundlesView extends FilteredViewPart {
+
+ public static final String VIEW_ID = "info.evanchik.eclipse.karaf.workbench.karafBundles";
+
+ protected static final int MAX_COLS = 5;
+
+ private static final String TAG_COLUMN_WIDTH = "columnWidth";
+
+ private Tree treeTable;
+ private TreeViewer treeTableViewer;
+ private BundlesContentProvider contentProvider;
+
+ private IAction propertiesAction;
+ private BundleSymbolicNameFilter nameFilter;
+
+ protected final int[] colWidth = new int[] { 185, 40, 100, 250, 250 };
+
+ @Override
+ public void createMainControl(final Composite parent) {
+ parent.setLayout(new FillLayout());
+
+ treeTable = new Tree(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
+ treeTable.setLinesVisible(true);
+ treeTable.setHeaderVisible(true);
+
+ TreeColumn col = new TreeColumn(treeTable, SWT.BORDER);
+ col.setWidth(colWidth[0]);
+ col.setText("Runtime");
+
+ col = new TreeColumn(treeTable, SWT.BORDER);
+ col.setWidth(colWidth[1]);
+ col.setText("Id");
+
+ col = new TreeColumn(treeTable, SWT.NONE);
+ col.setWidth(colWidth[2]);
+ col.setText("State");
+
+ col = new TreeColumn(treeTable, SWT.NONE);
+ col.setWidth(colWidth[3]);
+ col.setText("Name");
+
+ col = new TreeColumn(treeTable, SWT.NONE);
+ col.setWidth(colWidth[4]);
+ col.setText("Location");
+
+ treeTableViewer = new TreeViewer(treeTable);
+ treeTableViewer.setLabelProvider(new BundleTableLabelProvider());
+
+ nameFilter = new BundleSymbolicNameFilter();
+ treeTableViewer.addFilter(nameFilter);
+
+ contentProvider = new BundlesContentProvider();
+
+ treeTableViewer.setContentProvider(contentProvider);
+ treeTableViewer.setSorter(new BundleIdSorter());
+ treeTableViewer.setInput(KarafWorkbenchActivator.getDefault().getBundle().getBundleContext());
+
+ getViewSite().setSelectionProvider(treeTableViewer);
+
+ createActions();
+ fillMenu();
+
+ initContextMenu();
+ }
+
+ @Override
+ public void init(final IViewSite site, final IMemento memento) throws PartInitException {
+ super.init(site, memento);
+
+ for (int i = 0; i < MAX_COLS; i++) {
+
+ if (memento != null) {
+ final Integer in = memento.getInteger(TAG_COLUMN_WIDTH + i);
+ if (in != null && in.intValue() > 5) {
+ colWidth[i] = in.intValue();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void saveState(final IMemento memento) {
+ final TreeColumn[] tc = treeTable.getColumns();
+
+ for (int i = 0; i < MAX_COLS; i++) {
+ final int width = tc[i].getWidth();
+ if (width != 0) {
+ memento.putInteger(TAG_COLUMN_WIDTH + i, width);
+ }
+ }
+ }
+
+ @Override
+ public void doSetFocus() {
+ if (treeTable != null) {
+ treeTable.setFocus();
+ }
+ }
+
+ @Override
+ protected void updatedFilter(final String filterString) {
+ nameFilter.setFilterString(filterString);
+ treeTableViewer.refresh();
+ }
+
+ private void createActions() {
+ propertiesAction = new Action() {
+ @Override
+ public void run() {
+ final IStructuredSelection selection =
+ (IStructuredSelection) treeTableViewer.getSelection();
+ if (!selection.isEmpty()) {
+ /*
+ final BundleItem bundle = (BundleItem) selection.getFirstElement();
+
+ final BundlePropertiesDialog propsDialog = new BundlePropertiesDialog(getSite().getShell(), bundle);
+ propsDialog.open();
+ */
+ }
+ }
+ };
+ propertiesAction.setText("Properties...");
+ }
+
+ protected void fillMenu() {
+ final IMenuManager menuManager = getViewSite().getActionBars().getMenuManager();
+ menuManager.add(new ExcludeBundlesFilterAction("Installed", Bundle.INSTALLED, treeTableViewer));
+ menuManager.add(new ExcludeBundlesFilterAction("Resolved", Bundle.RESOLVED, treeTableViewer));
+ menuManager.add(new ExcludeBundlesFilterAction("Starting", Bundle.STARTING, treeTableViewer));
+ menuManager.add(new ExcludeBundlesFilterAction("Active", Bundle.ACTIVE, treeTableViewer));
+ menuManager.add(new ExcludeBundlesFilterAction("Stopping", Bundle.STOPPING, treeTableViewer));
+ }
+
+ protected void initContextMenu() {
+ final MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(new IMenuListener() {
+ @Override
+ public void menuAboutToShow(final IMenuManager manager) {
+ menuMgr.add(propertiesAction);
+ menuMgr.add(new Separator());
+ menuMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ }
+ });
+
+ final Menu menu = menuMgr.createContextMenu(treeTableViewer.getControl());
+ treeTableViewer.getControl().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, treeTableViewer);
+ }
+
+ @Override
+ public void dispose() {
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/BundlesViewerSorter.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/BundlesViewerSorter.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/BundlesViewerSorter.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/BundlesViewerSorter.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2008 Neil Bartlett
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Neil Bartlett - initial implementation
+ * Stephen Evanchik - Updated to use data provider services
+ */
+package info.evanchik.eclipse.karaf.workbench.ui.views.bundle;
+
+import info.evanchik.eclipse.karaf.workbench.provider.BundleItem;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ *
+ * @author Neil Bartlett
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public abstract class BundlesViewerSorter extends ViewerSorter {
+
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if (e1 instanceof BundleItem == false || e1 instanceof BundleItem == false) {
+ return 0;
+ }
+
+ final BundleItem b1 = (BundleItem) e1;
+ final BundleItem b2 = (BundleItem) e2;
+
+ return compareBundles(b1, b2);
+ }
+
+ protected abstract int compareBundles(BundleItem b1, BundleItem b2);
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/ExcludeBundlesFilterAction.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/ExcludeBundlesFilterAction.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/ExcludeBundlesFilterAction.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/ExcludeBundlesFilterAction.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2008 Neil Bartlett
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Neil Bartlett - initial implementation
+ */
+package info.evanchik.eclipse.karaf.workbench.ui.views.bundle;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.StructuredViewer;
+
+/**
+ *
+ * @author Neil Bartlett
+ *
+ */
+public class ExcludeBundlesFilterAction extends Action {
+
+ private final ExcludeBundlesViewerFilter filter;
+ private final StructuredViewer viewer;
+
+ public ExcludeBundlesFilterAction(String label, int state, StructuredViewer viewer) {
+ super(label, IAction.AS_CHECK_BOX);
+ this.viewer = viewer;
+ setChecked(true);
+ filter = new ExcludeBundlesViewerFilter(state);
+ }
+
+ @Override
+ public void run() {
+ if (!isChecked()) {
+ viewer.addFilter(filter);
+ } else {
+ viewer.removeFilter(filter);
+ }
+ }
+
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/ExcludeBundlesViewerFilter.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/ExcludeBundlesViewerFilter.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/ExcludeBundlesViewerFilter.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/bundle/ExcludeBundlesViewerFilter.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2008 Neil Bartlett
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Neil Bartlett - initial implementation
+ * Stephen Evanchik - Updated to use data provider services
+ */
+package info.evanchik.eclipse.karaf.workbench.ui.views.bundle;
+
+import info.evanchik.eclipse.karaf.workbench.provider.BundleItem;
+import info.evanchik.eclipse.karaf.workbench.provider.RuntimeDataProvider;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * @author Neil Bartlett
+ *
+ */
+public class ExcludeBundlesViewerFilter extends ViewerFilter {
+
+ private final String state;
+
+ public ExcludeBundlesViewerFilter(int state) {
+ this.state = stateName(state);
+ }
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof RuntimeDataProvider) {
+ return true;
+ }
+
+ final BundleItem bundle = (BundleItem) element;
+
+ return bundle.getState().equals(state) == false;
+ }
+
+ protected String stateName(int i) {
+ String name;
+
+ switch (i) {
+ case Bundle.ACTIVE:
+ name = "ACTIVE";
+ break;
+ case Bundle.INSTALLED:
+ name = "INSTALLED";
+ break;
+ case Bundle.RESOLVED:
+ name = "RESOLVED";
+ break;
+ case Bundle.STARTING:
+ name = "STARTING";
+ break;
+ case Bundle.STOPPING:
+ name = "STOPPING";
+ break;
+ default:
+ name = "<<unknown>>";
+ break;
+ }
+
+ return name;
+ }
+
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServiceLabelProvider.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServiceLabelProvider.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServiceLabelProvider.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServiceLabelProvider.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2008 Neil Bartlett
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Neil Bartlett - initial implementation
+ * Stephen Evanchik - Updated to use data provider services
+ */
+package info.evanchik.eclipse.karaf.workbench.ui.views.services;
+
+import info.evanchik.eclipse.karaf.workbench.KarafWorkbenchActivator;
+import info.evanchik.eclipse.karaf.workbench.provider.BundleItem;
+import info.evanchik.eclipse.karaf.workbench.provider.RuntimeDataProvider;
+import info.evanchik.eclipse.karaf.workbench.provider.ServiceItem;
+import info.evanchik.eclipse.karaf.workbench.ui.views.PropertyEntry;
+import info.evanchik.eclipse.karaf.workbench.ui.views.bundle.BundleTableLabelProvider;
+
+import java.util.Arrays;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ *
+ * @author Neil Bartlett
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class ServiceLabelProvider extends BundleTableLabelProvider {
+
+ private static final String LABEL_NULL = "<null>";
+ private static final String LABEL_ERROR = "<error>";
+
+ public ServiceLabelProvider() {
+ super();
+ }
+
+ @Override
+ public Image getColumnImage(final Object element, final int columnIndex) {
+ Image image = super.getColumnImage(element, columnIndex);
+
+ if (image != null) {
+ return image;
+ }
+
+ if (element instanceof ServiceItem && columnIndex == 0) {
+ image = KarafWorkbenchActivator.getDefault().getImageRegistry().get(KarafWorkbenchActivator.SERVICE_IMG);
+ }
+
+ return image;
+ }
+
+ @Override
+ public String getColumnText(final Object element, final int columnIndex) {
+ String label;
+ if (element instanceof RuntimeDataProvider) {
+ if (columnIndex == 0) {
+ label = ((RuntimeDataProvider) element).getName();
+ } else {
+ label = "";
+ }
+ } else if (element instanceof ServiceItem) {
+ final ServiceItem service = (ServiceItem) element;
+
+ if (columnIndex == 0) {
+ final String[] interfaces = service.getServiceInterfaces();
+ Arrays.sort(interfaces);
+ label = arrayToString(interfaces);
+ } else {
+ final BundleItem bundle = (BundleItem) service.getAdapter(BundleItem.class);
+ if (bundle != null) {
+ label = bundle.getSymbolicName();
+ } else {
+ label = LABEL_ERROR;
+ }
+ }
+ } else if (element instanceof PropertyEntry) {
+ final PropertyEntry prop = (PropertyEntry) element;
+
+ if (columnIndex == 0) {
+ label = prop.getKey();
+ } else if (columnIndex == 1) {
+ final Object value = prop.getValue();
+
+ if (value == null) {
+ label = LABEL_NULL;
+ } else if (value instanceof Object[]) {
+ label = arrayToString((Object[]) value);
+ } else {
+ label = value.toString();
+ }
+ } else {
+ label = null;
+ }
+ } else {
+ label = LABEL_ERROR;
+ }
+
+ return label;
+ }
+
+ // TODO: This is just join
+ protected static String arrayToString(final Object[] array) {
+ final StringBuffer buffer = new StringBuffer();
+
+ for (int i = 0; i < array.length; i++) {
+ if (i > 0) {
+ buffer.append(',');
+ }
+
+ buffer.append(array[i] == null ? LABEL_NULL : array[i].toString());
+ }
+
+ return buffer.toString();
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServiceNameFilter.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServiceNameFilter.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServiceNameFilter.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServiceNameFilter.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2008 Neil Bartlett
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Neil Bartlett - initial implementation
+ * Stephen Evanchik - Updated to use data provider services
+ */
+package info.evanchik.eclipse.karaf.workbench.ui.views.services;
+
+
+import info.evanchik.eclipse.karaf.workbench.provider.RuntimeDataProvider;
+import info.evanchik.eclipse.karaf.workbench.provider.ServiceItem;
+import info.evanchik.eclipse.karaf.workbench.ui.views.PropertyEntry;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ *
+ * @author Neil Bartlett
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class ServiceNameFilter extends ViewerFilter {
+
+ private String serviceName;
+
+ public ServiceNameFilter() {
+ this("");
+ }
+
+ public ServiceNameFilter(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ boolean result;
+
+ if (element instanceof RuntimeDataProvider) {
+ result = true;
+ } else if (element instanceof PropertyEntry) {
+ result = true;
+ }
+
+ else if (element instanceof ServiceItem) {
+ result = false;
+
+ final String[] interfaces = ((ServiceItem) element).getServiceInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+ if (interfaces[i].toLowerCase().indexOf(serviceName.toLowerCase()) > -1) {
+ result = true;
+ break;
+ }
+ }
+ } else {
+ result = false;
+ }
+
+ return result;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesContentProvider.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesContentProvider.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesContentProvider.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesContentProvider.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2008 Neil Bartlett
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Neil Bartlett - initial implementation
+ * Stephen Evanchik - Updated to use data provider services
+ */
+package info.evanchik.eclipse.karaf.workbench.ui.views.services;
+
+import info.evanchik.eclipse.karaf.workbench.provider.RuntimeDataProvider;
+import info.evanchik.eclipse.karaf.workbench.provider.ServiceItem;
+import info.evanchik.eclipse.karaf.workbench.ui.views.PropertyEntry;
+import info.evanchik.eclipse.karaf.workbench.ui.views.bundle.BundlesContentProvider;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ *
+ * @author Neil Bartlett
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class ServicesContentProvider extends BundlesContentProvider {
+
+ @Override
+ public Object[] getChildren(final Object parentElement) {
+ Object[] result;
+ if (parentElement instanceof RuntimeDataProvider) {
+ result = ((RuntimeDataProvider) parentElement).getServices().toArray(new Object[0]);
+ } else if (parentElement instanceof ServiceItem) {
+
+ final ServiceItem service = (ServiceItem) parentElement;
+
+ final Properties properties = (Properties) service.getAdapter(Properties.class);
+
+ final List<PropertyEntry> entries = new ArrayList<PropertyEntry>();
+
+ if (properties == null) {
+ final PropertyEntry pi = new PropertyEntry(service, "Properties unavailable", "");
+ entries.add(pi);
+ } else {
+
+ for (final Object o: properties.keySet()) {
+ final String key = (String)o;
+ final PropertyEntry pi = new PropertyEntry(service, key, properties.get(key));
+ entries.add(pi);
+ }
+ }
+
+ result = entries.toArray(new Object[0]);
+ Arrays.sort(result);
+
+ } else {
+ result = new Object[0];
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object getParent(final Object element) {
+ Object result = super.getParent(element);
+
+ if (result != null) {
+ return result;
+ }
+
+ if (element instanceof PropertyEntry) {
+ result = ((PropertyEntry) element).getOwner();
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean hasChildren(final Object element) {
+ final boolean children = super.hasChildren(element);
+
+ if (children == true) {
+ return children;
+ } else if (element instanceof ServiceItem) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesView.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesView.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesView.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesView.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2008 Neil Bartlett
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Neil Bartlett - initial implementation
+ * Stephen Evanchik - Updated to use data provider services
+ */
+package info.evanchik.eclipse.karaf.workbench.ui.views.services;
+
+import info.evanchik.eclipse.karaf.workbench.KarafWorkbenchActivator;
+import info.evanchik.eclipse.karaf.workbench.ui.views.FilteredViewPart;
+
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.PartInitException;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ * @author Neil Bartlett
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class ServicesView extends FilteredViewPart {
+
+ public static final String VIEW_ID = "info.evanchik.eclipse.karaf.workbench.karafServices";
+
+ protected static final int MAX_COLS = 2;
+
+ private static final String TAG_COLUMN_WIDTH = "columnWidth";
+
+ private Tree tree;
+
+ private TreeViewer viewer;
+
+ private ServicesContentProvider contentProvider;
+
+ private ServiceNameFilter nameFilter;
+
+ private BundleContext context;
+
+ protected final int[] colWidth = new int[] { 400, 200 };
+
+ @Override
+ public void createMainControl(final Composite parent) {
+ final GridLayout layout = new GridLayout(1, false);
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+
+ parent.setLayout(layout);
+
+ tree = new Tree(parent, SWT.FULL_SELECTION);
+ tree.setLinesVisible(true);
+ tree.setHeaderVisible(true);
+
+ TreeColumn col;
+ col = new TreeColumn(tree, SWT.NONE);
+ col.setWidth(colWidth[0]);
+ col.setText("Service Interfaces");
+
+ col = new TreeColumn(tree, SWT.NONE);
+ col.setWidth(colWidth[1]);
+ col.setText("Parent Bundle");
+
+ tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+
+ viewer = new TreeViewer(tree);
+ viewer.setLabelProvider(new ServiceLabelProvider());
+ viewer.setSorter(new ServicesViewerSorter());
+
+ nameFilter = new ServiceNameFilter();
+ viewer.addFilter(nameFilter);
+
+ context = KarafWorkbenchActivator.getDefault().getBundle().getBundleContext();
+ contentProvider = new ServicesContentProvider();
+ viewer.setContentProvider(contentProvider);
+
+ viewer.setInput(context);
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+
+ @Override
+ public void init(final IViewSite site, final IMemento memento) throws PartInitException {
+ super.init(site, memento);
+
+ for (int i = 0; i < MAX_COLS; i++) {
+
+ if (memento != null) {
+ final Integer in = memento.getInteger(TAG_COLUMN_WIDTH + i);
+ if (in != null && in.intValue() > 5) {
+ colWidth[i] = in.intValue();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void saveState(final IMemento memento) {
+ final TreeColumn[] tc = tree.getColumns();
+
+ for (int i = 0; i < MAX_COLS; i++) {
+ final int width = tc[i].getWidth();
+
+ if (width != 0) {
+ memento.putInteger(TAG_COLUMN_WIDTH + i, width);
+ }
+ }
+ }
+
+ @Override
+ protected void updatedFilter(final String filterString) {
+ nameFilter.setServiceName(filterString);
+ viewer.refresh();
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesViewerSorter.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesViewerSorter.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesViewerSorter.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/ui/views/services/ServicesViewerSorter.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2009 Stephen Evanchik
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.workbench.ui.views.services;
+
+import info.evanchik.eclipse.karaf.workbench.provider.BundleItem;
+import info.evanchik.eclipse.karaf.workbench.provider.ServiceItem;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class ServicesViewerSorter extends ViewerSorter {
+
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if (e1 instanceof ServiceItem == false || e1 instanceof ServiceItem == false) {
+ return 0;
+ }
+
+ final ServiceItem lhs = (ServiceItem) e1;
+ final ServiceItem rhs = (ServiceItem) e2;
+
+ final BundleItem lhsBundle = (BundleItem) lhs.getAdapter(BundleItem.class);
+ final BundleItem rhsBundle = (BundleItem) rhs.getAdapter(BundleItem.class);
+
+ if (lhsBundle == null && rhsBundle == null) {
+ return 0;
+ } else if (lhsBundle == null) {
+ return -1;
+ } else if (rhsBundle == null) {
+ return 1;
+ } else {
+ int value = lhsBundle.getSymbolicName().compareTo(rhsBundle.getSymbolicName());
+
+ if (value == 0) {
+ value = lhs.getServiceInterfaces()[0].compareTo(rhs.getServiceInterfaces()[0]);
+ }
+
+ return value;
+ }
+ }
+
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/.classpath
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/.classpath?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/.classpath (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/.classpath Wed Jan 4 13:22:10 2012
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/.project
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/.project?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/.project (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/.project Wed Jan 4 13:22:10 2012
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>info.evanchik.eclipse.karaf.wtp.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/META-INF/MANIFEST.MF?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/META-INF/MANIFEST.MF (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/META-INF/MANIFEST.MF Wed Jan 4 13:22:10 2012
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Eclipse WTP Core Integration
+Bundle-SymbolicName: info.evanchik.eclipse.karaf.wtp.core;singleton:=true
+Bundle-Version: 0.5.2.qualifier
+Bundle-Activator: info.evanchik.eclipse.karaf.wtp.core.KarafWtpPluginActivator
+Require-Bundle: org.eclipse.jst.server.core;bundle-version="[1.1.3,2.0.0)",
+ org.eclipse.pde.ui;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.wst.common.project.facet.core;bundle-version="[1.1.0,2.0.0)",
+ org.eclipse.wst.server.core;bundle-version="[1.0.204,2.0.0)",
+ org.eclipse.jdt.core;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.jdt.launching;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.core.runtime,
+ org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
+ org.eclipse.jst.common.project.facet.core;bundle-version="1.4.0",
+ org.osgi.jmx;bundle-version="1.0.0",
+ info.evanchik.eclipse.karaf.core;bundle-version="0.5.2",
+ info.evanchik.eclipse.karaf.ui;bundle-version="0.5.2",
+ info.evanchik.eclipse.karaf.workbench;bundle-version="0.5.2"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Export-Package: info.evanchik.eclipse.karaf.wtp.core
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/build.properties
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/build.properties?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/build.properties (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/build.properties Wed Jan 4 13:22:10 2012
@@ -0,0 +1,10 @@
+source.. = src/main/java/
+output.. = target/classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ epl-v10.html,\
+ target/classes/
+src.includes = epl-v10.html,\
+ pom.xml
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/epl-v10.html
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/epl-v10.html?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/epl-v10.html (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/epl-v10.html Wed Jan 4 13:22:10 2012
@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>Eclipse Public License - Version 1.0</title>
+<style type="text/css">
+ body {
+ size: 8.5in 11.0in;
+ margin: 0.25in 0.5in 0.25in 0.5in;
+ tab-interval: 0.5in;
+ }
+ p {
+ margin-left: auto;
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+ }
+ p.list {
+ margin-left: 0.5in;
+ margin-top: 0.05em;
+ margin-bottom: 0.05em;
+ }
+ </style>
+
+</head>
+
+<body lang="EN-US">
+
+<h2>Eclipse Public License - v 1.0</h2>
+
+<p>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
+PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
+DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS
+AGREEMENT.</p>
+
+<p><b>1. DEFINITIONS</b></p>
+
+<p>"Contribution" means:</p>
+
+<p class="list">a) in the case of the initial Contributor, the initial
+code and documentation distributed under this Agreement, and</p>
+<p class="list">b) in the case of each subsequent Contributor:</p>
+<p class="list">i) changes to the Program, and</p>
+<p class="list">ii) additions to the Program;</p>
+<p class="list">where such changes and/or additions to the Program
+originate from and are distributed by that particular Contributor. A
+Contribution 'originates' from a Contributor if it was added to the
+Program by such Contributor itself or anyone acting on such
+Contributor's behalf. Contributions do not include additions to the
+Program which: (i) are separate modules of software distributed in
+conjunction with the Program under their own license agreement, and (ii)
+are not derivative works of the Program.</p>
+
+<p>"Contributor" means any person or entity that distributes
+the Program.</p>
+
+<p>"Licensed Patents" mean patent claims licensable by a
+Contributor which are necessarily infringed by the use or sale of its
+Contribution alone or when combined with the Program.</p>
+
+<p>"Program" means the Contributions distributed in accordance
+with this Agreement.</p>
+
+<p>"Recipient" means anyone who receives the Program under
+this Agreement, including all Contributors.</p>
+
+<p><b>2. GRANT OF RIGHTS</b></p>
+
+<p class="list">a) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free copyright license to reproduce, prepare derivative works
+of, publicly display, publicly perform, distribute and sublicense the
+Contribution of such Contributor, if any, and such derivative works, in
+source code and object code form.</p>
+
+<p class="list">b) Subject to the terms of this Agreement, each
+Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free patent license under Licensed Patents to make, use, sell,
+offer to sell, import and otherwise transfer the Contribution of such
+Contributor, if any, in source code and object code form. This patent
+license shall apply to the combination of the Contribution and the
+Program if, at the time the Contribution is added by the Contributor,
+such addition of the Contribution causes such combination to be covered
+by the Licensed Patents. The patent license shall not apply to any other
+combinations which include the Contribution. No hardware per se is
+licensed hereunder.</p>
+
+<p class="list">c) Recipient understands that although each Contributor
+grants the licenses to its Contributions set forth herein, no assurances
+are provided by any Contributor that the Program does not infringe the
+patent or other intellectual property rights of any other entity. Each
+Contributor disclaims any liability to Recipient for claims brought by
+any other entity based on infringement of intellectual property rights
+or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility to
+secure any other intellectual property rights needed, if any. For
+example, if a third party patent license is required to allow Recipient
+to distribute the Program, it is Recipient's responsibility to acquire
+that license before distributing the Program.</p>
+
+<p class="list">d) Each Contributor represents that to its knowledge it
+has sufficient copyright rights in its Contribution, if any, to grant
+the copyright license set forth in this Agreement.</p>
+
+<p><b>3. REQUIREMENTS</b></p>
+
+<p>A Contributor may choose to distribute the Program in object code
+form under its own license agreement, provided that:</p>
+
+<p class="list">a) it complies with the terms and conditions of this
+Agreement; and</p>
+
+<p class="list">b) its license agreement:</p>
+
+<p class="list">i) effectively disclaims on behalf of all Contributors
+all warranties and conditions, express and implied, including warranties
+or conditions of title and non-infringement, and implied warranties or
+conditions of merchantability and fitness for a particular purpose;</p>
+
+<p class="list">ii) effectively excludes on behalf of all Contributors
+all liability for damages, including direct, indirect, special,
+incidental and consequential damages, such as lost profits;</p>
+
+<p class="list">iii) states that any provisions which differ from this
+Agreement are offered by that Contributor alone and not by any other
+party; and</p>
+
+<p class="list">iv) states that source code for the Program is available
+from such Contributor, and informs licensees how to obtain it in a
+reasonable manner on or through a medium customarily used for software
+exchange.</p>
+
+<p>When the Program is made available in source code form:</p>
+
+<p class="list">a) it must be made available under this Agreement; and</p>
+
+<p class="list">b) a copy of this Agreement must be included with each
+copy of the Program.</p>
+
+<p>Contributors may not remove or alter any copyright notices contained
+within the Program.</p>
+
+<p>Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.</p>
+
+<p><b>4. COMMERCIAL DISTRIBUTION</b></p>
+
+<p>Commercial distributors of software may accept certain
+responsibilities with respect to end users, business partners and the
+like. While this license is intended to facilitate the commercial use of
+the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create
+potential liability for other Contributors. Therefore, if a Contributor
+includes the Program in a commercial product offering, such Contributor
+("Commercial Contributor") hereby agrees to defend and
+indemnify every other Contributor ("Indemnified Contributor")
+against any losses, damages and costs (collectively "Losses")
+arising from claims, lawsuits and other legal actions brought by a third
+party against the Indemnified Contributor to the extent caused by the
+acts or omissions of such Commercial Contributor in connection with its
+distribution of the Program in a commercial product offering. The
+obligations in this section do not apply to any claims or Losses
+relating to any actual or alleged intellectual property infringement. In
+order to qualify, an Indemnified Contributor must: a) promptly notify
+the Commercial Contributor in writing of such claim, and b) allow the
+Commercial Contributor to control, and cooperate with the Commercial
+Contributor in, the defense and any related settlement negotiations. The
+Indemnified Contributor may participate in any such claim at its own
+expense.</p>
+
+<p>For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have to
+defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any other
+Contributor to pay any damages as a result, the Commercial Contributor
+must pay those damages.</p>
+
+<p><b>5. NO WARRANTY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
+PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
+ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to
+the risks and costs of program errors, compliance with applicable laws,
+damage to or loss of data, programs or equipment, and unavailability or
+interruption of operations.</p>
+
+<p><b>6. DISCLAIMER OF LIABILITY</b></p>
+
+<p>EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
+NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
+WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
+DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
+HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>
+
+<p><b>7. GENERAL</b></p>
+
+<p>If any provision of this Agreement is invalid or unenforceable under
+applicable law, it shall not affect the validity or enforceability of
+the remainder of the terms of this Agreement, and without further action
+by the parties hereto, such provision shall be reformed to the minimum
+extent necessary to make such provision valid and enforceable.</p>
+
+<p>If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging that the
+Program itself (excluding combinations of the Program with other
+software or hardware) infringes such Recipient's patent(s), then such
+Recipient's rights granted under Section 2(b) shall terminate as of the
+date such litigation is filed.</p>
+
+<p>All Recipient's rights under this Agreement shall terminate if it
+fails to comply with any of the material terms or conditions of this
+Agreement and does not cure such failure in a reasonable period of time
+after becoming aware of such noncompliance. If all Recipient's rights
+under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However,
+Recipient's obligations under this Agreement and any licenses granted by
+Recipient relating to the Program shall continue and survive.</p>
+
+<p>Everyone is permitted to copy and distribute copies of this
+Agreement, but in order to avoid inconsistency the Agreement is
+copyrighted and may only be modified in the following manner. The
+Agreement Steward reserves the right to publish new versions (including
+revisions) of this Agreement from time to time. No one other than the
+Agreement Steward has the right to modify this Agreement. The Eclipse
+Foundation is the initial Agreement Steward. The Eclipse Foundation may
+assign the responsibility to serve as the Agreement Steward to a
+suitable separate entity. Each new version of the Agreement will be
+given a distinguishing version number. The Program (including
+Contributions) may always be distributed subject to the version of the
+Agreement under which it was received. In addition, after a new version
+of the Agreement is published, Contributor may elect to distribute the
+Program (including its Contributions) under the new version. Except as
+expressly stated in Sections 2(a) and 2(b) above, Recipient receives no
+rights or licenses to the intellectual property of any Contributor under
+this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under this
+Agreement are reserved.</p>
+
+<p>This Agreement is governed by the laws of the State of New York and
+the intellectual property laws of the United States of America. No party
+to this Agreement will bring a legal action under this Agreement more
+than one year after the cause of action arose. Each party waives its
+rights to a jury trial in any resulting litigation.</p>
+
+</body>
+
+</html>
\ No newline at end of file
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj16/felixLogo16x16.gif
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj16/felixLogo16x16.gif?rev=1227144&view=auto
==============================================================================
Files karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj16/felixLogo16x16.gif (added) and karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj16/felixLogo16x16.gif Wed Jan 4 13:22:10 2012 differ
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj32/felixLogo32x32.gif
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj32/felixLogo32x32.gif?rev=1227144&view=auto
==============================================================================
Files karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj32/felixLogo32x32.gif (added) and karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj32/felixLogo32x32.gif Wed Jan 4 13:22:10 2012 differ
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj64/felixLogo64x64.gif
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj64/felixLogo64x64.gif?rev=1227144&view=auto
==============================================================================
Files karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj64/felixLogo64x64.gif (added) and karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/icons/obj64/felixLogo64x64.gif Wed Jan 4 13:22:10 2012 differ
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/plugin.xml
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/plugin.xml?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/plugin.xml (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/plugin.xml Wed Jan 4 13:22:10 2012
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.wst.server.core.runtimeTypes">
+ <runtimeType
+ class="info.evanchik.eclipse.karaf.wtp.core.runtime.KarafRuntime"
+ description="Apache Karaf OSGi Application framework"
+ id="info.evanchik.eclipse.karaf.wtp.server.runtime.2"
+ name="Apache Karaf"
+ vendor="Apache"
+ vendorId="apache"
+ version="2.x">
+ <moduleType
+ types="jst.web"
+ versions="2.2, 2.3, 2.4, 2.5">
+ </moduleType>
+ <moduleType
+ types="jst.utility"
+ versions="1.0">
+ </moduleType>
+ <moduleType
+ types="info.evanchik.eclipse.karaf.wtp.core.facets.bundle"
+ versions="1.0">
+ </moduleType>
+ </runtimeType>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.runtimeLocators">
+ <runtimeLocator
+ class="info.evanchik.eclipse.karaf.wtp.core.runtime.KarafRuntimeLocator"
+ id="info.evanchik.eclipse.karaf.wtp.core.runtimeLocator"
+ typeIds="info.evanchik.eclipse.karaf.wtp.server.runtime.*">
+ </runtimeLocator>
+ </extension>
+ <extension
+ point="org.eclipse.jst.server.core.runtimeClasspathProviders">
+ <runtimeClasspathProvider
+ class="info.evanchik.eclipse.karaf.wtp.core.runtime.KarafRuntimeClasspathProvider"
+ id="info.evanchik.eclipse.karaf.wtp.server.runtimeTarget"
+ runtimeTypeIds="info.evanchik.eclipse.karaf.wtp.server.runtime.*">
+ </runtimeClasspathProvider>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.serverTypes">
+ <serverType
+ behaviourClass="info.evanchik.eclipse.karaf.wtp.core.server.KarafServerBehavior"
+ class="info.evanchik.eclipse.karaf.wtp.core.server.KarafServer"
+ description="Apache Karaf server"
+ hasConfiguration="true"
+ id="info.evanchik.eclipse.karaf.server.2"
+ initialState="stopped"
+ launchConfigId="info.evanchik.eclipse.karaf.wtp.core.KarafServerLauncher"
+ name="Apache Karaf"
+ runtime="true"
+ runtimeTypeId="info.evanchik.eclipse.karaf.wtp.server.runtime.2"
+ startTimeout="45000"
+ stopTimeout="15000"
+ supportsRemoteHosts="false">
+ </serverType>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.serverLocators">
+ <serverLocator
+ class="info.evanchik.eclipse.karaf.wtp.core.server.KarafServerLocator"
+ id="info.evanchik.eclipse.karaf.wtp.core.server.locator"
+ supportsRemoteHosts="false"
+ typeIds="info.evanchik.eclipse.karaf.server.*">
+ </serverLocator>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.launchableAdapters">
+ <launchableAdapter
+ class="info.evanchik.eclipse.karaf.wtp.core.server.KarafLaunchableAdapterDelegate"
+ id="info.evanchik.eclipse.server.karaf.web">
+ </launchableAdapter>
+ </extension>
+ <extension
+ point="org.eclipse.debug.core.launchConfigurationTypes">
+ <launchConfigurationType
+ delegate="info.evanchik.eclipse.karaf.wtp.core.KarafServerLaunchConfiguration"
+ delegateDescription="The Karaf Server Launcher supports running and debugging Karaf Servers"
+ delegateName="Karaf Server Launcher"
+ id="info.evanchik.eclipse.karaf.wtp.core.KarafServerLauncher"
+ modes="run, debug, profile"
+ name="Apache Felix Karaf"
+ public="true"
+ sourceLocatorId="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"
+ sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer">
+ </launchConfigurationType>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.publishTasks">
+ <publishTask
+ class="info.evanchik.eclipse.karaf.wtp.core.tasks.KarafPublishTask"
+ id="info.evanchik.eclipse.karaf.ui.publishTask"
+ typeIds="info.evanchik.eclipse.server.karaf.*">
+ </publishTask>
+ </extension>
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.runtimes">
+ <runtime-component-type
+ id="info.evanchik.eclipse.server.karaf">
+ </runtime-component-type>
+ <runtime-component-version
+ type="info.evanchik.eclipse.server.karaf"
+ version="1.2">
+ </runtime-component-version>
+ <adapter>
+ <runtime-component
+ id="info.evanchik.eclipse.server.karaf">
+ </runtime-component>
+ <factory
+ class="org.eclipse.jst.server.core.internal.RuntimeClasspathProvider$Factory">
+ </factory>
+ <type
+ class="org.eclipse.jst.common.project.facet.core.IClasspathProvider">
+ </type>
+ </adapter>
+ <supported>
+ <runtime-component
+ id="info.evanchik.eclipse.server.karaf"
+ version="1.2">
+ </runtime-component>
+ <facet
+ id="jst.web"
+ version="2.2,2.3,2.4,2.5">
+ </facet>
+ <facet
+ id="jst.utility"
+ version="1.0">
+ </facet>
+ <facet
+ id="info.evanchik.eclipse.karaf.wtp.core.facets.bundle"
+ version="1.0">
+ </facet>
+ </supported>
+ </extension>
+ <extension
+ point="org.eclipse.jst.server.core.runtimeFacetMappings">
+ <runtimeFacetMapping
+ runtime-component="info.evanchik.eclipse.server.karaf"
+ runtimeTypeId="info.evanchik.eclipse.server.karaf.runtime.12"
+ version="1.2">
+ </runtimeFacetMapping>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ configTypeID="info.evanchik.eclipse.karaf.wtp.core.KarafServerLauncher"
+ icon="icons/obj16/felixLogo16x16.gif"
+ id="info.evanchik.eclipse.karaf.wtp.core.KarafLauncherImage">
+ </launchConfigurationTypeImage>
+ </extension>
+
+</plugin>
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/pom.xml
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/pom.xml?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/pom.xml (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/pom.xml Wed Jan 4 13:22:10 2012
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<!--
+ Copyright (c) 2009 Stephen Evanchik
+ All rights reserved. This program and the accompanying materials
+ are 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:
+ Stephen Evanchik - initial implementation
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>info.evanchik.eclipse.karaf</groupId>
+ <artifactId>eik-plugins-parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>info.evanchik.eclipse.karaf.wtp</groupId>
+ <artifactId>info.evanchik.eclipse.karaf.wtp.core</artifactId>
+ <version>0.5.2-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+ <name>Eclipse Integration for Karaf :: Eclipse WTP Core Integration</name>
+ <description>Provides core functionalty for WTP Integration</description>
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>${pom.basedir}/src/main/filtered-resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <!-- enable source bundle generation -->
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-source-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <executions>
+ <execution>
+ <id>plugin-source</id>
+ <goals>
+ <goal>plugin-source</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafServerLaunchConfiguration.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafServerLaunchConfiguration.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafServerLaunchConfiguration.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafServerLaunchConfiguration.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,91 @@
+/**
+ * Copyright (c) 2009 Stephen Evanchik
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.wtp.core;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModelRegistry;
+import info.evanchik.eclipse.karaf.core.model.WorkingKarafPlatformModel;
+import info.evanchik.eclipse.karaf.ui.KarafLaunchConfigurationDelegate;
+import info.evanchik.eclipse.karaf.wtp.core.server.KarafServerBehavior;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jdt.launching.IVMRunner;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerUtil;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafServerLaunchConfiguration extends KarafLaunchConfigurationDelegate {
+
+ private IServer server;
+
+ private KarafServerBehavior karafServer;
+
+ @Override
+ public IVMRunner getVMRunner(final ILaunchConfiguration configuration, final String mode) throws CoreException {
+ if(ILaunchManager.PROFILE_MODE.equals(mode)) {
+ // TODO: Figure out how to setup profiling
+ return super.getVMRunner(configuration, ILaunchManager.RUN_MODE);
+ }
+
+ return super.getVMRunner(configuration, mode);
+ }
+
+ @Override
+ public void launch(final ILaunchConfiguration configuration, final String mode, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
+ super.launch(configuration, mode, launch, monitor);
+
+ if (server.shouldPublish() && ServerCore.isAutoPublishing()) {
+
+ server.publish(IServer.PUBLISH_INCREMENTAL, monitor);
+
+ monitor.worked(10);
+ }
+
+ karafServer.configureLaunch(launch, mode, monitor);
+ }
+
+ @Override
+ protected void preLaunchCheck(
+ final ILaunchConfiguration configuration,
+ final ILaunch launch,
+ final IProgressMonitor monitor)
+ throws CoreException
+ {
+ super.preLaunchCheck(configuration, launch, monitor);
+
+ server = ServerUtil.getServer(configuration);
+
+ if (server == null) {
+ return;
+ }
+
+ monitor.worked(5);
+
+ final IPath runtimeLocation = server.getRuntime().getLocation();
+ this.karafPlatform = KarafPlatformModelRegistry.findPlatformModel(runtimeLocation);
+
+ final IPath workingArea = new Path(getConfigDir(configuration).getAbsolutePath());
+ workingKarafPlatform = new WorkingKarafPlatformModel(workingArea, karafPlatform);
+
+ karafServer = (KarafServerBehavior) server.loadAdapter(KarafServerBehavior.class, null);
+
+ monitor.worked(10);
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafServerLaunchConfigurationInitializer.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafServerLaunchConfigurationInitializer.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafServerLaunchConfigurationInitializer.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafServerLaunchConfigurationInitializer.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,46 @@
+/**
+ * Copyright (c) 2009 Stephen Evanchik
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.wtp.core;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModelRegistry;
+import info.evanchik.eclipse.karaf.core.configuration.StartupSection;
+import info.evanchik.eclipse.karaf.ui.KarafLaunchConfigurationInitializer;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerUtil;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafServerLaunchConfigurationInitializer extends KarafLaunchConfigurationInitializer {
+
+ private IServer server;
+
+ @Override
+ protected void loadKarafPlatform(final ILaunchConfigurationWorkingCopy configuration) {
+ try {
+ server = ServerUtil.getServer(configuration);
+
+ if (server == null) {
+ return;
+ }
+
+ this.karafPlatform = KarafPlatformModelRegistry.findPlatformModel(server.getRuntime().getLocation());
+
+ this.startupSection = (StartupSection) this.karafPlatform.getAdapter(StartupSection.class);
+ this.startupSection.load();
+ } catch (final CoreException e) {
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafWtpPluginActivator.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafWtpPluginActivator.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafWtpPluginActivator.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/KarafWtpPluginActivator.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2009 Stephen Evanchik
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.wtp.core;
+
+import info.evanchik.eclipse.karaf.core.LogWrapper;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class KarafWtpPluginActivator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "info.evanchik.eclipse.karaf.wtp.core";
+
+ /**
+ * The list of runtime type identifiers that this plugin defines
+ */
+ public static final String[] RUNTIME_TYPE_IDS = new String[] {
+ "info.evanchik.eclipse.karaf.wtp.server.runtime.2"
+ };
+
+ // The shared instance
+ private static KarafWtpPluginActivator plugin;
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static KarafWtpPluginActivator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Getter for the {@link LogWrapper} object that makes logging much easier
+ * on the caller.
+ *
+ * @return the {@link LogWrapper} instance
+ */
+ public static LogWrapper getLogger() {
+ return new LogWrapper(getDefault().getLog(), PLUGIN_ID);
+ }
+
+ /**
+ * The constructor
+ */
+ public KarafWtpPluginActivator() {
+ }
+
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntime.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntime.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntime.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntime.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,85 @@
+/**
+ * Copyright (c) 2009 Stephen Evanchik
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.wtp.core.runtime;
+
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.core.KarafPlatformModelRegistry;
+import info.evanchik.eclipse.karaf.wtp.core.KarafWtpPluginActivator;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.model.RuntimeDelegate;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com
+ *
+ */
+public class KarafRuntime extends RuntimeDelegate {
+
+ @Override
+ protected void initialize() {
+ super.initialize();
+ }
+
+ @Override
+ public void setDefaults(final IProgressMonitor monitor) {
+ super.setDefaults(monitor);
+ }
+
+ /**
+ * Determines whether or not this is a valid {@link IRuntime} of a Karaf
+ * installation.
+ *
+ * @return a {@link IStatus} object indicating whether or not this is a
+ * valid Karaf runtime. A valid Karaf Runtime will return
+ * {@link Status#OK_STATUS} otherwise a status based on
+ * {@link IStatus#ERROR}
+ */
+ @Override
+ public IStatus validate() {
+ final IPath location = getRuntime().getLocation();
+
+ if (location == null || location.isEmpty()) {
+ return new Status(IStatus.ERROR, KarafWtpPluginActivator.PLUGIN_ID, 0, "", null);
+ }
+
+ final IStatus status = super.validate();
+ if (!status.isOK()) {
+ return status;
+ }
+
+ KarafPlatformModel karafTargetPlatform;
+ try {
+ karafTargetPlatform = KarafPlatformModelRegistry.findPlatformModel(location);
+ if (karafTargetPlatform != null) {
+ return Status.OK_STATUS;
+ } else {
+ return new Status(
+ IStatus.ERROR,
+ KarafWtpPluginActivator.PLUGIN_ID,
+ 0,
+ "Unable to validate Karaf installation",
+ null);
+ }
+ } catch (final CoreException e) {
+ return new Status(
+ IStatus.ERROR,
+ KarafWtpPluginActivator.PLUGIN_ID,
+ 0,
+ "Unable to locate Karaf platform",
+ e);
+ }
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntimeClasspathProvider.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntimeClasspathProvider.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntimeClasspathProvider.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntimeClasspathProvider.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) 2009 Stephen Evanchik
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.wtp.core.runtime;
+
+import info.evanchik.eclipse.karaf.core.KarafCorePluginUtils;
+import info.evanchik.eclipse.karaf.core.KarafPlatformModel;
+import info.evanchik.eclipse.karaf.core.KarafPlatformModelRegistry;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate;
+import org.eclipse.wst.server.core.IRuntime;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafRuntimeClasspathProvider extends RuntimeClasspathProviderDelegate {
+
+ private static final int MAX_SEARCH_DEPTH = 50;
+
+ @Override
+ public IClasspathEntry[] resolveClasspathContainer(final IProject project, final IRuntime runtime) {
+ final IPath installPath = runtime.getLocation();
+
+ if (installPath == null) {
+ return new IClasspathEntry[0];
+ }
+
+ try {
+ final KarafPlatformModel karafPlatform = KarafPlatformModelRegistry.findPlatformModel(installPath);
+
+ final File pluginRootDirectory = karafPlatform.getPluginRootDirectory().toFile();
+ final List<File> jarFiles = new ArrayList<File>();
+
+ KarafCorePluginUtils.getJarFileList(pluginRootDirectory, jarFiles, MAX_SEARCH_DEPTH);
+
+ final List<IClasspathEntry> list = resolveLibraryEntries(jarFiles);
+
+ return list.toArray(new IClasspathEntry[0]);
+ } catch (final CoreException e) {
+ }
+
+ return new IClasspathEntry[0];
+ }
+
+ /**
+ * Converts the list of JAR files to {@link IClasspathEntry}s
+ *
+ * @param files
+ * the {@link List} of files that will be converted
+ * @return a {@link List} of {@code IClasspathEntry}s for each file in the
+ * original list of files
+ */
+ private static List<IClasspathEntry> resolveLibraryEntries(final List<File> files) {
+ final List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
+
+ for (final File f : files) {
+ final IPath path = new Path(f.getAbsolutePath());
+ classpathEntries.add(JavaCore.newLibraryEntry(path, null, null));
+ }
+
+ return classpathEntries;
+ }
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntimeLocator.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntimeLocator.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntimeLocator.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/runtime/KarafRuntimeLocator.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,154 @@
+/**
+ * Copyright (c) 2009 Stephen Evanchik
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.wtp.core.runtime;
+
+import info.evanchik.eclipse.karaf.wtp.core.KarafWtpPluginActivator;
+
+import java.io.File;
+import java.io.FileFilter;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.model.RuntimeLocatorDelegate;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafRuntimeLocator extends RuntimeLocatorDelegate {
+
+ /**
+ * Maximum depth to search for a Karaf server runtime
+ */
+ public static int MAX_DEPTH = 4;
+
+ @Override
+ public void searchForRuntimes(final IPath path, final IRuntimeSearchListener listener,
+ final IProgressMonitor monitor) {
+
+ final File[] files;
+ if (path == null) {
+ files = File.listRoots();
+ } else if (path.toFile().exists()) {
+ files = path.toFile().listFiles();
+ } else {
+ monitor.worked(100);
+ return;
+ }
+
+ final int workUnit = 100 / files.length;
+
+ for (final File f : files) {
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ if (f != null && f.isDirectory()) {
+ searchDirectory(f, MAX_DEPTH, listener, monitor);
+ monitor.worked(workUnit);
+ }
+ }
+
+ monitor.worked(100 - workUnit * files.length);
+ }
+
+ /**
+ * Searches the given directory and all directories recursively to the given
+ * depth for Karaf server runtimes.
+ *
+ * @param directory
+ * the current directory that is being searched
+ * @param depth
+ * the max depth to search
+ * @param listener
+ * the listener that will be notified if a Karaf server runtime
+ * is found
+ * @param monitor
+ * the progress monitor
+ */
+ private void searchDirectory(final File directory, final int depth,
+ final IRuntimeSearchListener listener, final IProgressMonitor monitor) {
+
+ final IRuntimeWorkingCopy runtime = resolveDirectoryToRuntime(directory, monitor);
+
+ if (runtime != null) {
+ listener.runtimeFound(runtime);
+ }
+
+ if (depth == 0 || monitor.isCanceled()) {
+ return;
+ }
+
+ final File[] files = directory.listFiles(new FileFilter() {
+ @Override
+ public boolean accept(final File file) {
+ return file.isDirectory();
+ }
+ });
+
+ if (files == null) {
+ return;
+ }
+
+ for (final File f : files) {
+ if (monitor.isCanceled()) {
+ return;
+ }
+
+ searchDirectory(f, depth - 1, listener, monitor);
+ }
+
+ }
+
+ /**
+ * Attempts to resolve the directory to a WTP server runtime according to
+ * the registered runtime type identifiers.
+ *
+ * @param directory
+ * the directory that is being examined
+ * @param monitor
+ * the progress monitor
+ * @return a valid {@link IRuntimeWorkingCopy} if a runtime has been found,
+ * or null if it has not been found
+ */
+ private IRuntimeWorkingCopy resolveDirectoryToRuntime(final File directory,
+ final IProgressMonitor monitor) {
+ for (final String runtimeId : KarafWtpPluginActivator.RUNTIME_TYPE_IDS) {
+ try {
+ final IRuntimeType runtimeType = ServerCore.findRuntimeType(runtimeId);
+
+ final String absolutePath = directory.getAbsolutePath();
+ final String id = absolutePath.replace(File.separatorChar, '_').replace(':', '-');
+
+ final IRuntimeWorkingCopy runtime = runtimeType.createRuntime(id, monitor);
+ runtime.setName(directory.getName());
+ runtime.setLocation(new Path(absolutePath));
+
+ final IStatus status = runtime.validate(monitor);
+ if (status == null || status.getSeverity() != IStatus.ERROR) {
+ return runtime;
+ }
+
+ // TODO: Log something?
+ } catch (final Exception e) {
+ // TODO : Logging
+ }
+ }
+
+ return null;
+ }
+
+}
Added: karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/server/KarafLaunchableAdapterDelegate.java
URL: http://svn.apache.org/viewvc/karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/server/KarafLaunchableAdapterDelegate.java?rev=1227144&view=auto
==============================================================================
--- karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/server/KarafLaunchableAdapterDelegate.java (added)
+++ karaf/eik/trunk/plugins/info.evanchik.eclipse.karaf.wtp.core/src/main/java/info/evanchik/eclipse/karaf/wtp/core/server/KarafLaunchableAdapterDelegate.java Wed Jan 4 13:22:10 2012
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2009 Stephen Evanchik
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * Stephen Evanchik - initial implementation
+ */
+package info.evanchik.eclipse.karaf.wtp.core.server;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.server.core.IModuleArtifact;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.model.LaunchableAdapterDelegate;
+
+/**
+ * @author Stephen Evanchik (evanchsa@gmail.com)
+ *
+ */
+public class KarafLaunchableAdapterDelegate extends LaunchableAdapterDelegate {
+
+ @Override
+ public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact)
+ throws CoreException {
+ return null;
+ }
+
+}