Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-11-07 11:19:59 -0500
committerUwe Stieber2011-11-07 11:20:42 -0500
commitc00b4a5d2579c71cd41e3baa51f23c4322ef8ea8 (patch)
tree4fca3a85311fe028669fda5e0bb936f77d853b22
parent9f118ef1ed5c96796bf444ebebc6fa436eb17d72 (diff)
downloadorg.eclipse.tcf-c00b4a5d2579c71cd41e3baa51f23c4322ef8ea8.tar.gz
org.eclipse.tcf-c00b4a5d2579c71cd41e3baa51f23c4322ef8ea8.tar.xz
org.eclipse.tcf-c00b4a5d2579c71cd41e3baa51f23c4322ef8ea8.zip
Target Explorer: Add working set updater
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml3
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/events/ViewerContentChangeEvent.java84
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java92
-rw-r--r--target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementUpdater.java104
5 files changed, 292 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml
index ea4a256ab..ca842b0c3 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml
@@ -174,7 +174,8 @@
icon="icons/obj16/workingset.gif"
id="org.eclipse.tm.te.ui.views.workingset"
name="%workingset.name"
- pageClass="org.eclipse.tm.te.ui.views.workingsets.pages.TargetWorkingSetPage">
+ pageClass="org.eclipse.tm.te.ui.views.workingsets.pages.TargetWorkingSetPage"
+ updaterClass="org.eclipse.tm.te.ui.views.workingsets.WorkingSetElementUpdater">
</workingSet>
</extension>
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/events/ViewerContentChangeEvent.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/events/ViewerContentChangeEvent.java
new file mode 100644
index 000000000..f6c968273
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/events/ViewerContentChangeEvent.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.events;
+
+import java.util.EventObject;
+
+import org.eclipse.tm.te.runtime.activator.CoreBundleActivator;
+import org.eclipse.tm.te.runtime.interfaces.tracing.ITraceIds;
+
+/**
+ * Target Explorer view viewer change event implementation.
+ */
+public class ViewerContentChangeEvent extends EventObject {
+ private static final long serialVersionUID = 7168841012111347036L;
+
+ private String eventId;
+
+ /**
+ * Event id used if elements got directly added to the viewer.
+ */
+ public static final String ADD = "add"; //$NON-NLS-1$
+
+ /**
+ * Event id used if elements got directly removed the viewer.
+ */
+ public static final String REMOVE = "remove"; //$NON-NLS-1$
+
+ /**
+ * Event id used if the viewer got refreshed.
+ */
+ public static final String REFRESH = "refresh"; //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ *
+ * @param source The source object. Must not be <code>null</code>.
+ * @param eventId The event id. Must not be <code>null</code>.
+ *
+ * @exception IllegalArgumentException if eventId == null.
+ */
+ public ViewerContentChangeEvent(Object source, String eventId) {
+ super(source);
+
+ if (eventId == null) throw new IllegalArgumentException("null eventId"); //$NON-NLS-1$
+ this.eventId = eventId;
+ }
+
+ /**
+ * Returns the event id.
+ *
+ * @return The event id.
+ */
+ public final String getEventId() {
+ return eventId;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.EventObject#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder toString = new StringBuilder(getClass().getName());
+
+ String prefix = ""; //$NON-NLS-1$
+ // if tracing the event, formating them a little bit better readable.
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_EVENTS))
+ prefix = "\n\t\t"; //$NON-NLS-1$
+
+ toString.append(prefix + "{eventId="); //$NON-NLS-1$
+ toString.append(eventId);
+ toString.append("," + prefix + "source="); //$NON-NLS-1$ //$NON-NLS-2$
+ toString.append(source);
+ toString.append("}"); //$NON-NLS-1$
+
+ return toString.toString();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java
index acecd2fdd..7324152b1 100644
--- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/View.java
@@ -24,6 +24,7 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tm.te.ui.views.activator.UIPlugin;
import org.eclipse.tm.te.ui.views.interfaces.IRoot;
@@ -40,6 +41,7 @@ import org.eclipse.ui.internal.navigator.framelist.FrameList;
import org.eclipse.ui.internal.navigator.framelist.TreeFrame;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
import org.eclipse.ui.navigator.ICommonActionConstants;
@@ -116,6 +118,14 @@ public class View extends CommonNavigator {
}
/* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonNavigator#createCommonViewerObject(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected CommonViewer createCommonViewerObject(Composite parent) {
+ return new ViewViewer(getViewSite().getId(), parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.ui.navigator.CommonNavigator#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java
new file mode 100644
index 000000000..735eaf8f5
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/ViewViewer.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.internal;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tm.te.runtime.events.EventManager;
+import org.eclipse.tm.te.ui.views.events.ViewerContentChangeEvent;
+import org.eclipse.ui.navigator.CommonViewer;
+
+/**
+ * Target Explorer common viewer implementation.
+ */
+public class ViewViewer extends CommonViewer {
+
+ /**
+ * Constructor.
+ *
+ * @param viewerId
+ * An id tied to the extensions that is used to focus specific
+ * content to a particular instance of the Common Navigator
+ * @param parent
+ * A Composite parent to contain the actual SWT widget
+ * @param style
+ * A style mask that will be used to create the TreeViewer
+ * Composite.
+ */
+ public ViewViewer(String viewerId, Composite parent, int style) {
+ super(viewerId, parent, style);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#add(java.lang.Object, java.lang.Object[])
+ */
+ @Override
+ public void add(Object parentElement, Object[] childElements) {
+ super.add(parentElement, childElements);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.ADD);
+ EventManager.getInstance().fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#remove(java.lang.Object[])
+ */
+ @Override
+ public void remove(Object[] elements) {
+ super.remove(elements);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REMOVE);
+ EventManager.getInstance().fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object, java.lang.Object[])
+ */
+ @Override
+ public void remove(Object parent, Object[] elements) {
+ super.remove(parent, elements);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REMOVE);
+ EventManager.getInstance().fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#refresh(java.lang.Object)
+ */
+ @Override
+ public void refresh(Object element) {
+ super.refresh(element);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REFRESH);
+ EventManager.getInstance().fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#refresh(java.lang.Object, boolean)
+ */
+ @Override
+ public void refresh(Object element, boolean updateLabels) {
+ super.refresh(element, updateLabels);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REFRESH);
+ EventManager.getInstance().fireEvent(event);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementUpdater.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementUpdater.java
new file mode 100644
index 000000000..e8ec80b50
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/workingsets/WorkingSetElementUpdater.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. and others. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.ui.views.workingsets;
+
+import java.util.ArrayList;
+import java.util.EventObject;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.tm.te.runtime.events.EventManager;
+import org.eclipse.tm.te.ui.events.AbstractEventListener;
+import org.eclipse.tm.te.ui.views.ViewsUtil;
+import org.eclipse.tm.te.ui.views.events.ViewerContentChangeEvent;
+import org.eclipse.tm.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetUpdater;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
+
+/**
+ * Working set element updater implementation.
+ */
+public class WorkingSetElementUpdater extends AbstractEventListener implements IWorkingSetUpdater, IExecutableExtension {
+ // List of working sets managed by this updater
+ private final List<IWorkingSet> workingSets = new ArrayList<IWorkingSet>();
+ // The common viewer
+ private CommonViewer viewer = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ // Get the target explorer view instance
+ IWorkbenchPart part = ViewsUtil.getPart(IUIConstants.ID_EXPLORER);
+ if (part instanceof CommonNavigator) viewer = ((CommonNavigator)part).getCommonViewer();
+
+ // Register ourself as ViewContentChangeEvent listener
+ EventManager.getInstance().addEventListener(this, ViewerContentChangeEvent.class, viewer);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetUpdater#add(org.eclipse.ui.IWorkingSet)
+ */
+ @Override
+ public void add(IWorkingSet workingSet) {
+ synchronized (workingSets) {
+ workingSets.add(workingSet);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetUpdater#remove(org.eclipse.ui.IWorkingSet)
+ */
+ @Override
+ public boolean remove(IWorkingSet workingSet) {
+ synchronized (workingSets) {
+ return workingSets.remove(workingSet);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetUpdater#contains(org.eclipse.ui.IWorkingSet)
+ */
+ @Override
+ public boolean contains(IWorkingSet workingSet) {
+ synchronized (workingSets) {
+ return workingSets.contains(workingSet);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkingSetUpdater#dispose()
+ */
+ @Override
+ public void dispose() {
+ synchronized (workingSets) {
+ workingSets.clear();
+ }
+
+ // Remove ourself as event listener
+ EventManager.getInstance().removeEventListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.runtime.interfaces.events.IEventListener#eventFired(java.util.EventObject)
+ */
+ @Override
+ public void eventFired(EventObject event) {
+ if (!(event instanceof ViewerContentChangeEvent) && viewer.equals(((ViewerContentChangeEvent)event).getSource())) {
+ return;
+ }
+ }
+}

Back to the top