diff options
author | Eike Stepper | 2006-11-11 09:50:34 +0000 |
---|---|---|
committer | Eike Stepper | 2006-11-11 09:50:34 +0000 |
commit | 1e38486f5ebfe111397f24befecef9a10d108d3c (patch) | |
tree | 3b7a4c4ecdf3270c5693138ebbca95944bb93eab | |
parent | a329bd9fbd46e20d72b49da1fa8e1825eae0124c (diff) | |
download | cdo-1e38486f5ebfe111397f24befecef9a10d108d3c.tar.gz cdo-1e38486f5ebfe111397f24befecef9a10d108d3c.tar.xz cdo-1e38486f5ebfe111397f24befecef9a10d108d3c.zip |
Initial provisioning for v0.8.0
-rw-r--r-- | plugins/org.eclipse.net4j.debug/.classpath | 7 | ||||
-rw-r--r-- | plugins/org.eclipse.net4j.debug/.cvsignore | 2 | ||||
-rw-r--r-- | plugins/org.eclipse.net4j.debug/.project | 28 | ||||
-rw-r--r-- | plugins/org.eclipse.net4j.debug/META-INF/MANIFEST.MF | 11 | ||||
-rw-r--r-- | plugins/org.eclipse.net4j.debug/build.properties | 6 | ||||
-rw-r--r-- | plugins/org.eclipse.net4j.debug/icons/sample.gif | bin | 0 -> 983 bytes | |||
-rw-r--r-- | plugins/org.eclipse.net4j.debug/icons/text.gif | bin | 0 -> 607 bytes | |||
-rw-r--r-- | plugins/org.eclipse.net4j.debug/plugin.xml | 32 | ||||
-rw-r--r-- | plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/RemoteTraceManager.java | 71 | ||||
-rw-r--r-- | plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/Activator.java | 56 | ||||
-rw-r--r-- | plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/views/RemoteTraceView.java | 459 |
11 files changed, 672 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.debug/.classpath b/plugins/org.eclipse.net4j.debug/.classpath new file mode 100644 index 0000000000..751c8f2e50 --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.net4j.debug/.cvsignore b/plugins/org.eclipse.net4j.debug/.cvsignore new file mode 100644 index 0000000000..693869726d --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/.cvsignore @@ -0,0 +1,2 @@ +bin +doc diff --git a/plugins/org.eclipse.net4j.debug/.project b/plugins/org.eclipse.net4j.debug/.project new file mode 100644 index 0000000000..6a5e8b15db --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.net4j.debug</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.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.net4j.debug/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.debug/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..2e7e0fa0b1 --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Debug Plug-in +Bundle-SymbolicName: org.eclipse.net4j.debug; singleton:=true +Bundle-Version: 0.8.0.qualifier +Bundle-Activator: org.eclipse.net4j.internal.debug.bundle.Activator +Bundle-Localization: plugin +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.ui, + org.eclipse.net4j +Eclipse-LazyStart: true diff --git a/plugins/org.eclipse.net4j.debug/build.properties b/plugins/org.eclipse.net4j.debug/build.properties new file mode 100644 index 0000000000..0d3d3a745d --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/ diff --git a/plugins/org.eclipse.net4j.debug/icons/sample.gif b/plugins/org.eclipse.net4j.debug/icons/sample.gif Binary files differnew file mode 100644 index 0000000000..34fb3c9d8c --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/icons/sample.gif diff --git a/plugins/org.eclipse.net4j.debug/icons/text.gif b/plugins/org.eclipse.net4j.debug/icons/text.gif Binary files differnew file mode 100644 index 0000000000..c77fa1308d --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/icons/text.gif diff --git a/plugins/org.eclipse.net4j.debug/plugin.xml b/plugins/org.eclipse.net4j.debug/plugin.xml new file mode 100644 index 0000000000..23119d2b2a --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/plugin.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.2"?> +<plugin> + + <extension + point="org.eclipse.ui.views"> + <category + name="Net4j" + id="org.eclipse.net4j"> + </category> + <view + name="Remote Traces" + icon="icons/sample.gif" + category="org.eclipse.net4j" + class="org.eclipse.net4j.internal.debug.views.RemoteTraceView" + id="org.eclipse.net4j.internal.debug.views.RemoteTraceView"> + </view> + </extension> + <extension + point="org.eclipse.ui.perspectiveExtensions"> + <perspectiveExtension + targetID="org.eclipse.ui.resourcePerspective"> + <view + ratio="0.5" + relative="org.eclipse.ui.views.TaskList" + relationship="right" + id="org.eclipse.net4j.internal.debug.views.RemoteTraceView"> + </view> + </perspectiveExtension> + </extension> + +</plugin> diff --git a/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/RemoteTraceManager.java b/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/RemoteTraceManager.java new file mode 100644 index 0000000000..35215c2a82 --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/RemoteTraceManager.java @@ -0,0 +1,71 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany. + * 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: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.internal.debug; + +import org.eclipse.net4j.internal.debug.views.RemoteTraceView; +import org.eclipse.net4j.util.lifecycle.AbstractLifecycle; +import org.eclipse.net4j.util.om.trace.RemoteTraceServer; +import org.eclipse.net4j.util.om.trace.RemoteTraceServer.Event; +import org.eclipse.net4j.util.om.trace.RemoteTraceServer.Listener; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class RemoteTraceManager extends AbstractLifecycle implements Listener +{ + public static final RemoteTraceManager INSTANCE = new RemoteTraceManager(); + + private RemoteTraceServer server; + + private List<Event> events = new ArrayList(); + + public RemoteTraceManager() + { + } + + public Event[] getEvents() + { + return events.toArray(new Event[events.size()]); + } + + public void clearEvents() + { + events.clear(); + } + + public void notifyRemoteTrace(Event event) + { + events.add(event); + if (RemoteTraceView.INSTANCE != null) + { + RemoteTraceView.INSTANCE.notifyNewTrace(); + } + } + + @Override + protected void onActivate() throws Exception + { + super.onActivate(); + server = new RemoteTraceServer(); + server.addListener(this); + } + + @Override + protected void onDeactivate() throws Exception + { + server.removeListener(this); + server.close(); + super.onDeactivate(); + } +} diff --git a/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/Activator.java b/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/Activator.java new file mode 100644 index 0000000000..bf3da4c60b --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/bundle/Activator.java @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany. + * 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: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.internal.debug.bundle; + +import org.eclipse.net4j.internal.debug.RemoteTraceManager; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +import org.osgi.framework.BundleContext; + +/** + * @author Eike Stepper + */ +public class Activator extends AbstractUIPlugin +{ + public static final String PLUGIN_ID = "org.eclipse.net4j.debug"; + + private static Activator plugin; + + public Activator() + { + plugin = this; + } + + public void start(BundleContext context) throws Exception + { + super.start(context); + RemoteTraceManager.INSTANCE.activate(); + } + + public void stop(BundleContext context) throws Exception + { + RemoteTraceManager.INSTANCE.deactivate(); + plugin = null; + super.stop(context); + } + + public static Activator getDefault() + { + return plugin; + } + + public static ImageDescriptor getImageDescriptor(String path) + { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/views/RemoteTraceView.java b/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/views/RemoteTraceView.java new file mode 100644 index 0000000000..989479fd0b --- /dev/null +++ b/plugins/org.eclipse.net4j.debug/src/org/eclipse/net4j/internal/debug/views/RemoteTraceView.java @@ -0,0 +1,459 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany. + * 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: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.net4j.internal.debug.views; + +import org.eclipse.net4j.internal.debug.RemoteTraceManager; +import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.ReflectUtil; +import org.eclipse.net4j.util.om.trace.RemoteTraceServer.Event; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.ViewPart; + +/** + * @author Eike Stepper + */ +public class RemoteTraceView extends ViewPart +{ + public static RemoteTraceView INSTANCE; + + private TableViewer viewer; + + private Action clearAction; + + private Action doubleClickAction; + + public RemoteTraceView() + { + } + + @Override + public void dispose() + { + INSTANCE = null; + super.dispose(); + } + + @Override + public void createPartControl(Composite parent) + { + viewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + viewer.getTable().setHeaderVisible(true); + createColmuns(viewer); + viewer.setContentProvider(new ViewContentProvider()); + viewer.setLabelProvider(new ViewLabelProvider()); + // viewer.setSorter(new NameSorter()); + viewer.setInput(getViewSite()); + + // final ToolTipHandler tooltip = new ToolTipHandler(getSite().getShell()); + // tooltip.activateHoverHelp(viewer.getTable()); + + makeActions(); + hookContextMenu(); + hookDoubleClickAction(); + contributeToActionBars(); + INSTANCE = this; + } + + protected void createColmuns(TableViewer viewer) + { + final String[] columnNames = { "ID", "Time Stamp", "Agent ID", "Bundle ID", "Tracer Name", + "Context", "Message", "Throwable" }; + final int[] columnWidths = { 60, 170, 80, 160, 120, 120, 400, 200 }; + TableColumn[] columns = new TableColumn[columnNames.length]; + for (int i = 0; i < columns.length; i++) + { + TableColumn column = new TableColumn(viewer.getTable(), SWT.LEFT, i); + column.setText(columnNames[i]); + column.setWidth(columnWidths[i]); + column.setMoveable(true); + column.setResizable(true); + } + } + + public void notifyNewTrace() + { + refreshViewer(); + } + + public void refreshViewer() + { + if (isViewerAlive()) + { + getSite().getShell().getDisplay().asyncExec(new Runnable() + { + public void run() + { + if (isViewerAlive()) + { + viewer.refresh(); + } + } + }); + } + } + + private boolean isViewerAlive() + { + return viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed(); + } + + private void hookContextMenu() + { + MenuManager menuMgr = new MenuManager("#PopupMenu"); + menuMgr.setRemoveAllWhenShown(true); + menuMgr.addMenuListener(new IMenuListener() + { + public void menuAboutToShow(IMenuManager manager) + { + RemoteTraceView.this.fillContextMenu(manager); + } + }); + Menu menu = menuMgr.createContextMenu(viewer.getControl()); + viewer.getControl().setMenu(menu); + getSite().registerContextMenu(menuMgr, viewer); + } + + private void contributeToActionBars() + { + IActionBars bars = getViewSite().getActionBars(); + fillLocalPullDown(bars.getMenuManager()); + fillLocalToolBar(bars.getToolBarManager()); + } + + private void fillLocalPullDown(IMenuManager manager) + { + manager.add(clearAction); + } + + private void fillContextMenu(IMenuManager manager) + { + manager.add(clearAction); + // Other plug-ins can contribute there actions here + manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + } + + private void fillLocalToolBar(IToolBarManager manager) + { + manager.add(clearAction); + } + + private void makeActions() + { + clearAction = new Action() + { + @Override + public void run() + { + RemoteTraceManager.INSTANCE.clearEvents(); + refreshViewer(); + } + }; + clearAction.setText("Clear"); + clearAction.setToolTipText("Clear"); + clearAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( + ISharedImages.IMG_TOOL_DELETE)); + + doubleClickAction = new Action() + { + @Override + public void run() + { + ISelection selection = viewer.getSelection(); + Object obj = ((IStructuredSelection)selection).getFirstElement(); + showMessage("Double-click detected on " + obj.toString()); + } + }; + } + + private void hookDoubleClickAction() + { + viewer.addDoubleClickListener(new IDoubleClickListener() + { + public void doubleClick(DoubleClickEvent event) + { + doubleClickAction.run(); + } + }); + } + + private void showMessage(String message) + { + MessageDialog.openInformation(viewer.getControl().getShell(), "Remote Traces", message); + } + + /** + * Passing the focus request to the viewer's control. + */ + @Override + public void setFocus() + { + viewer.getControl().setFocus(); + } + + /** + * @author Eike Stepper + */ + class ViewContentProvider implements IStructuredContentProvider + { + public void inputChanged(Viewer v, Object oldInput, Object newInput) + { + } + + public void dispose() + { + } + + public Object[] getElements(Object parent) + { + return RemoteTraceManager.INSTANCE.getEvents(); + } + } + + /** + * @author Eike Stepper + */ + class ViewLabelProvider extends LabelProvider implements ITableLabelProvider + { + private Image info; + + private Image error; + + private Image text; + + public ViewLabelProvider() + { + ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages(); + info = sharedImages.getImage(ISharedImages.IMG_OBJS_INFO_TSK); + error = sharedImages.getImage(ISharedImages.IMG_OBJS_ERROR_TSK); + text = sharedImages.getImage(ISharedImages.IMG_OBJ_FILE); + } + + public String getColumnText(Object obj, int index) + { + if (obj instanceof Event) + { + Event event = (Event)obj; + String text = event.getText(index); + switch (index) + { + case 5: + return ReflectUtil.getSimpleClassName(text); + case 6: + int at = text.indexOf('@'); + if (at == -1) + { + return text; + } + + String context = ReflectUtil.getSimpleClassName(event.getText(5)); + String id = text.substring(at + 1); + String className = text.substring(0, at); + if (ObjectUtil.equals(context, className)) + { + return id; + } + + return id + " (" + className + ")"; + + case 7: + return getFirstLine(text); + } + + return text; + } + + return getText(obj); + } + + public Image getColumnImage(Object obj, int index) + { + if (obj instanceof Event) + { + Event event = (Event)obj; + switch (index) + { + case 0: + return event.hasError() ? error : info; + case 7: + return hasNL(event.getMessage()) ? text : null; + case 8: + return event.hasError() ? error : null; + } + } + + return null; + } + + @Override + public Image getImage(Object obj) + { + return null; + } + + private boolean hasNL(String str) + { + return str.indexOf('\n') != -1; + } + + private String getFirstLine(String str) + { + int nl = str.indexOf('\n'); + if (nl != -1) + { + str = str.substring(0, nl); + } + + return str.replaceAll("\r", ""); + } + } + + /** + * @author Eike Stepper + */ + class NameSorter extends ViewerSorter + { + } + + // static class ToolTipHandler + // { + // private Shell tipShell; + // + // private Label tipLabel; + // + // private TableItem tipItem; + // + // private Point tipPosition; + // + // public ToolTipHandler(Shell parent) + // { + // final Display display = parent.getDisplay(); + // + // tipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL); + // GridLayout gridLayout = new GridLayout(); + // gridLayout.numColumns = 2; + // gridLayout.marginWidth = 2; + // gridLayout.marginHeight = 2; + // tipShell.setLayout(gridLayout); + // + // tipShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + // + // tipLabel = new Label(tipShell, SWT.NONE); + // tipLabel.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + // tipLabel.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + // tipLabel + // .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | + // GridData.VERTICAL_ALIGN_CENTER)); + // } + // + // public void activateHoverHelp(final Control control) + // { + // control.addMouseListener(new MouseAdapter() + // { + // @Override + // public void mouseDown(MouseEvent e) + // { + // if (tipShell.isVisible()) + // { + // tipShell.setVisible(false); + // } + // } + // }); + // + // control.addMouseTrackListener(new MouseTrackAdapter() + // { + // @Override + // public void mouseExit(MouseEvent e) + // { + // if (tipShell.isVisible()) + // { + // tipShell.setVisible(false); + // } + // + // tipItem = null; + // } + // + // @Override + // public void mouseHover(MouseEvent event) + // { + // Point pt = new Point(event.x, event.y); + // Widget widget = event.widget; + // if (widget instanceof Table) + // { + // Table table = (Table)widget; + // TableItem item = table.getItem(pt); + // if (widget == null) + // { + // tipShell.setVisible(false); + // tipItem = null; + // return; + // } + // + // if (item == tipItem) + // { + // return; + // } + // + // Object data = item.getData(); + // if (data instanceof Event) + // { + // Event e = (Event)data; + // } + // + // tipItem = item; + // tipPosition = control.toDisplay(pt); + // String text = (String)item.getData("TIP_TEXT"); + // tipLabel.setText(text != null ? text : ""); + // tipShell.pack(); + // setHoverLocation(tipShell, tipPosition); + // tipShell.setVisible(true); + // } + // } + // }); + // } + // + // private void setHoverLocation(Shell shell, Point position) + // { + // Rectangle displayBounds = shell.getDisplay().getBounds(); + // Rectangle shellBounds = shell.getBounds(); + // shellBounds.x = Math.max(Math.min(position.x, displayBounds.width - + // shellBounds.width), 0); + // shellBounds.y = Math.max( + // Math.min(position.y + 16, displayBounds.height - shellBounds.height), 0); + // shell.setBounds(shellBounds); + // } + // } +}
\ No newline at end of file |