From 6be1f018b1b5b19f625f36746afe216f7dd7c1be Mon Sep 17 00:00:00 2001 From: eyck Date: Thu, 29 Oct 2020 07:48:35 +0100 Subject: [PATCH] add search dialog and pane --- .../ui/swt/internal/WaveformView.java | 19 +- .../eclipse/wb/swt/SWTResourceManager.java | 20 +- .../Application.e4xmi | 9 + .../icons/find.png | Bin 0 -> 659 bytes .../application/handlers/SearchHandler.java | 63 ++++++ .../e4/application/parts/SearchTxDialog.java | 185 ++++++++++++++++++ .../application/parts/TransactionDetails.java | 18 +- .../e4/application/parts/WaveformViewer.java | 32 ++- .../org/eclipse/wb/swt/ResourceManager.java | 171 +++++++++------- 9 files changed, 412 insertions(+), 105 deletions(-) create mode 100755 plugins/com.minres.scviewer.e4.application/icons/find.png create mode 100644 plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SearchHandler.java create mode 100644 plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/SearchTxDialog.java diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java index 08e8c76..aac936a 100644 --- a/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java +++ b/plugins/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/ui/swt/internal/WaveformView.java @@ -140,7 +140,8 @@ public class WaveformView implements IWaveformView { public void mouseDown(MouseEvent e) { if (e.button == 1) { Entry entry = trackVerticalOffset.floorEntry(e.y); - entry.getValue().selected=true; + if(entry!=null) + entry.getValue().selected=true; } else if (e.button == 3) { Menu topMenu= top.getMenu(); if(topMenu!=null) topMenu.setVisible(true); @@ -191,7 +192,7 @@ public class WaveformView implements IWaveformView { down=false; if(start==null) return; if((e.stateMask&SWT.MODIFIER_MASK&~SWT.SHIFT)!=0) return; //don't react on modifier except shift - if(!start.equals(end)){ + if(e.button == 1 && Math.abs(e.x-start.x)>3){ asyncUpdate(e.widget); long startTime = waveformCanvas.getTimeForOffset(start.x); long endTime = waveformCanvas.getTimeForOffset(end.x); @@ -287,9 +288,9 @@ public class WaveformView implements IWaveformView { case SWT.MouseDown: start=new Point(e.x, e.y); end=new Point(e.x, e.y); - down=true; if((e.stateMask&SWT.MODIFIER_MASK)!=0) return; //don't react on modifier if (e.button == 1) { + down=true; initialSelected = waveformCanvas.getElementsAt(start); } else if (e.button == 3) { Menu topMenu= top.getMenu(); @@ -680,15 +681,13 @@ public class WaveformView implements IWaveformView { */ @Override public ISelection getSelection() { + ArrayList sel = new ArrayList<>(); if (currentTxSelection != null) { - ArrayList sel = new ArrayList<>(); sel.add(currentTxSelection); - sel.addAll(currentWaveformSelection.stream().map(e -> e.waveform).collect(Collectors.toList())); - return new StructuredSelection(sel.toArray()); - } else if (currentWaveformSelection.size()>0) { - return new StructuredSelection(currentWaveformSelection.toArray()); - } else - return new StructuredSelection(); + } + // sel.addAll(currentWaveformSelection.stream().map(e -> e.waveform).collect(Collectors.toList())); + sel.addAll(currentWaveformSelection); + return new StructuredSelection(sel.toArray()); } /* (non-Javadoc) diff --git a/plugins/com.minres.scviewer.database.ui.swt/src/org/eclipse/wb/swt/SWTResourceManager.java b/plugins/com.minres.scviewer.database.ui.swt/src/org/eclipse/wb/swt/SWTResourceManager.java index 20a9264..d8a2858 100644 --- a/plugins/com.minres.scviewer.database.ui.swt/src/org/eclipse/wb/swt/SWTResourceManager.java +++ b/plugins/com.minres.scviewer.database.ui.swt/src/org/eclipse/wb/swt/SWTResourceManager.java @@ -1,13 +1,13 @@ -/******************************************************************************* - * Copyright (c) 2015 MINRES Technologies GmbH 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: - * MINRES Technologies GmbH - initial API and implementation - *******************************************************************************/ +/******************************************************************************* + * Copyright (c) 2011 Google, Inc. + * 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: + * Google, Inc. - initial API and implementation + *******************************************************************************/ package org.eclipse.wb.swt; import java.io.FileInputStream; diff --git a/plugins/com.minres.scviewer.e4.application/Application.e4xmi b/plugins/com.minres.scviewer.e4.application/Application.e4xmi index 0822bbe..baa15c1 100644 --- a/plugins/com.minres.scviewer.e4.application/Application.e4xmi +++ b/plugins/com.minres.scviewer.e4.application/Application.e4xmi @@ -136,6 +136,7 @@ + type:user @@ -200,6 +201,10 @@ + + + + @@ -226,6 +231,9 @@ + + + @@ -268,6 +276,7 @@ + diff --git a/plugins/com.minres.scviewer.e4.application/icons/find.png b/plugins/com.minres.scviewer.e4.application/icons/find.png new file mode 100755 index 0000000000000000000000000000000000000000..1547479646722bda4647df52cf3e8bc9b77428c6 GIT binary patch literal 659 zcmV;E0&M+>P)IO9T&v~?D!=C@G6X*U1@h2}>2WE%HrrsjTfQsh6N9%SR25A5rkWp0g zzi;-6|3HJE;58sAyX1e@^d7EwiKQLb00%dp|5+t<{|l;G!D3eSuFDma zRCxr2MVY_`ELgLXqo}ssqp5E;*r|opZT~&|!~VN?1^mw`Yxp0VmiIp*r|Ey~#AW|W zTBd;IxVd?%*x1<_!3Ip2yP9Rn!u1aqt=siKx4a3At0%7dKV|u@|9wlg|7x7R;eT!K z{QuFp&Huxb3&AdAW?^~2z`(!^HUQ{cR*=op7H|BYU0VMi3A-|5H&#ol!zs_8lnTU stream; + + private ConcurrentHashMap propNames=new ConcurrentHashMap(); + + /** + * Create the dialog. + * @param parentShell + * @param iTxStream + */ + public SearchTxDialog(Shell parentShell, ITxStream iTxStream) { + super(parentShell); + setShellStyle(SWT.BORDER | SWT.RESIZE | SWT.TITLE | SWT.APPLICATION_MODAL); + stream=iTxStream; + new Thread() { + public void run() { + stream.getEvents().values().parallelStream().forEach(evtLst -> { + evtLst.forEach(evt -> { + evt.getTransaction().getAttributes().stream().forEach(attr -> { + propNames.put(attr.getName(), attr.getDataType()); + }); + }); + }); + parentShell.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + if (propNameComboViewer!=null) { + propNameComboViewer.setInput(getEntries()); + propNameComboViewer.setSelection(new StructuredSelection(propNameComboViewer.getElementAt(0))); + } + } + }); + } + }.run(); + } + + /** + * Create contents of the dialog. + * @param parent + */ + @Override + protected Control createDialogArea(Composite parent) { + setMessage("Specify property name and value to search for"); + setTitleImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/Minres_logo.png")); + setTitle("Search Tx in stream"); + final Composite area = (Composite) super.createDialogArea(parent); + final GridLayout gridLayout = (GridLayout) area.getLayout(); + gridLayout.marginTop = 10; + gridLayout.marginBottom = 10; + final Composite container = new Composite(area, SWT.NONE); + final GridLayout gl_container = new GridLayout(2, false); + gl_container.horizontalSpacing = 2; + container.setLayout(gl_container); + container.setLayoutData(new GridData(GridData.FILL_BOTH)); + + final Label header = new Label(container, SWT.CENTER | SWT.WRAP); + GridData gd_header = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1); + gd_header.verticalIndent = 10; + header.setLayoutData(gd_header); + header.setText("Stream: "+stream.getName()); + + final Label propNameLabel = new Label(container, SWT.NONE); + propNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + propNameLabel.setText("Property Name:"); + + propNameComboViewer = new ComboViewer(container, SWT.NONE); + propNameComboViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + propNameComboViewer.setContentProvider(ArrayContentProvider.getInstance()); + propNameComboViewer.setLabelProvider(new LabelProvider() { + @SuppressWarnings("unchecked") + @Override + public String getText(Object element) { + Map.Entry e = (Map.Entry)element; + return e.getKey()+" ("+e.getValue().name()+")"; + } + + }); + propNameComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { + + @SuppressWarnings("unchecked") + @Override + public void selectionChanged(SelectionChangedEvent event) { + IStructuredSelection sel = event.getStructuredSelection(); + Map.Entry e = (Map.Entry)sel.getFirstElement(); + propName=e.getKey(); + propType=e.getValue(); + } + }); + propNameComboViewer.setInput(getEntries()); + propNameComboViewer.setSelection(new StructuredSelection(propNameComboViewer.getElementAt(0))); + + final Label propValueLabel = new Label(container, SWT.NONE); + propValueLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + propValueLabel.setText("Property Value:"); + + propValueText = new Text(container, SWT.BORDER); + propValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + + return area; + } + + private List> getEntries() { + return propNames.entrySet().stream().sorted((e1,e2)->e1.getKey().compareTo(e2.getKey())).collect(Collectors.toList()); + } + + /** + * Create contents of the button bar. + * @param parent + */ + @Override + protected void createButtonsForButtonBar(Composite parent) { + final Button okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + okButton.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/tick.png")); + final Button cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + cancelButton.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/cross.png")); + } + + protected void constrainShellSize() { + super.constrainShellSize(); + getShell().setMinimumSize(getShell().computeSize(-1, -1)); + + } + + @Override + protected void okPressed() { + //propName=propNameCombo.getItem(propNameCombo.getSelectionIndex()); + propValue=propValueText.getText(); + super.okPressed(); + } + + public String getPropName() { + return propName; + } + + public DataType getPropType() { + return propType; + } + + public String getPropValue() { + return propValue; + } +} diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java index f4d3b1c..acd8d35 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java @@ -63,6 +63,7 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; @@ -113,7 +114,8 @@ public class TransactionDetails { /** The waveform viewer part. */ private WaveformViewer waveformViewerPart; - + private Composite top; + /** * Creates the composite. * @@ -123,9 +125,10 @@ public class TransactionDetails { public void createComposite(final Composite parent, @Optional WaveformViewer waveformViewerPart) { this.waveformViewerPart=waveformViewerPart; - parent.setLayout(new GridLayout(1, false)); + top = new Composite(parent, SWT.NONE); + top.setLayout(new GridLayout(1, false)); - nameFilter = new Text(parent, SWT.BORDER); + nameFilter = new Text(top, SWT.BORDER); nameFilter.setMessage(Messages.TransactionDetails_0); nameFilter.addModifyListener(new ModifyListener() { @Override @@ -141,7 +144,7 @@ public class TransactionDetails { attributeFilter = new TxAttributeFilter(); viewSorter = new TxAttributeViewerSorter(); - treeViewer = new TreeViewer(parent); + treeViewer = new TreeViewer(top); treeViewer.setContentProvider(new TransactionTreeContentProvider()); treeViewer.setLabelProvider(new TxPropertiesLabelProvider()); treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -225,10 +228,10 @@ public class TransactionDetails { } }); - parent.addControlListener(new ControlAdapter() { + top.addControlListener(new ControlAdapter() { public void controlResized(ControlEvent e) { Tree table = treeViewer.getTree(); - Rectangle area = parent.getClientArea(); + Rectangle area = top.getClientArea(); Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT); int width = area.width - 2*table.getBorderWidth(); if (preferredSize.y > area.height + table.getHeaderHeight()) { @@ -259,6 +262,9 @@ public class TransactionDetails { }); } + public Control getControl() { + return top; + } /** * Sets the focus. */ diff --git a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index 0c42fb8..4a1efbc 100644 --- a/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/plugins/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -61,7 +61,10 @@ import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CTabFolder; +import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; @@ -287,14 +290,28 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis sashFormTop.setWeights(new int[] {25, 75}); Composite rightTop = new Composite(sashFormRight, SWT.NONE); - Composite rightBottom = new Composite(sashFormRight, SWT.NONE); - sashFormRight.setWeights(new int[] {80, 20}); - + waveformPane = factory.createPanel(rightTop); - ctx.set(Composite.class, rightBottom); - detailsView = ContextInjectionFactory.make(TransactionDetails.class, ctx); + CTabFolder tabFolder = new CTabFolder(sashFormRight, SWT.BORDER); + tabFolder.setSelectionBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT)); + CTabItem tbtmDetails = new CTabItem(tabFolder, SWT.NONE); + tbtmDetails.setText("Transaction Details"); + + ctx.set(Composite.class, tabFolder); + detailsView = ContextInjectionFactory.make(TransactionDetails.class, ctx); + tbtmDetails.setControl(detailsView.getControl()); + + CTabItem tbtmSearchResults = new CTabItem(tabFolder, SWT.NONE); + tbtmSearchResults.setText("Search Results"); + + TableViewer tableViewer = new TableViewer(tabFolder, SWT.BORDER | SWT.FULL_SELECTION); + Table table = tableViewer.getTable(); + tbtmSearchResults.setControl(table); + + sashFormRight.setWeights(new int[] {75, 25}); + tabFolder.setSelection(0); waveformPane.setMaxTime(0); setupColors(); @@ -1294,4 +1311,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis eventBroker.post(WaveStatusBarControl.MARKER_DIFF, null); } } + + public void search(String propName, DataType type, String propValue) { + // TODO Auto-generated method stub + + } } \ No newline at end of file diff --git a/plugins/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java b/plugins/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java index 98642cf..56f340d 100644 --- a/plugins/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java +++ b/plugins/com.minres.scviewer.e4.application/src/org/eclipse/wb/swt/ResourceManager.java @@ -1,13 +1,14 @@ -/******************************************************************************* - * Copyright (c) 2015 MINRES Technologies GmbH 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: - * MINRES Technologies GmbH - initial API and implementation - *******************************************************************************/ +/******************************************************************************* + * Copyright (c) 2011 Google, 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: + * Google, Inc. - initial API and implementation + * Wim Jongman - 1.8 and higher compliance + *******************************************************************************/ package org.eclipse.wb.swt; import java.io.File; @@ -24,51 +25,61 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.CompositeImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.ImageDataProvider; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; -import org.osgi.framework.Bundle; - +import org.osgi.framework.Bundle; + import com.minres.scviewer.e4.application.Messages; /** - * Utility class for managing OS resources associated with SWT/JFace controls such as colors, fonts, images, - * etc. + * Utility class for managing OS resources associated with SWT/JFace controls + * such as colors, fonts, images, etc. * - * !!! IMPORTANT !!! Application code must explicitly invoke the dispose() method to release the - * operating system resources managed by cached objects when those objects and OS resources are no longer - * needed (e.g. on application shutdown) + * This class is created automatically when you fiddle around with images and + * colors in WB. You might want to prevent your application from using this + * class and provide your own more effective means of resource caching. + * + * Even though this class can be used to manage these resources, if they are + * here for the duration of the application and not used then you still have an + * effective resource leak. + * + * Application code must explicitly invoke the dispose() method to + * release the operating system resources managed by cached objects when those + * objects and OS resources are no longer needed. * * This class may be freely distributed as part of any application or plugin. *

* * @author scheglov_ke * @author Dan Rubel + * @author Wim Jongman */ public class ResourceManager extends SWTResourceManager { - //////////////////////////////////////////////////////////////////////////// - // - // Image - // - //////////////////////////////////////////////////////////////////////////// - private static Map m_descriptorImageMap = new HashMap(); + /** - * Returns an {@link ImageDescriptor} stored in the file at the specified path relative to the specified - * class. + * The map where we store our images. + */ + private static Map m_descriptorImageMap = new HashMap(); + + /** + * Returns an {@link ImageDescriptor} stored in the file at the specified path + * relative to the specified class. * - * @param clazz - * the {@link Class} relative to which to find the image descriptor. - * @param path - * the path to the image file. + * @param clazz the {@link Class} relative to which to find the image + * descriptor. + * @param path the path to the image file. * @return the {@link ImageDescriptor} stored in the file at the specified path. */ public static ImageDescriptor getImageDescriptor(Class clazz, String path) { return ImageDescriptor.createFromFile(clazz, path); } + /** * Returns an {@link ImageDescriptor} stored in the file at the specified path. * - * @param path - * the path to the image file. + * @param path the path to the image file. * @return the {@link ImageDescriptor} stored in the file at the specified path. */ public static ImageDescriptor getImageDescriptor(String path) { @@ -78,11 +89,11 @@ public class ResourceManager extends SWTResourceManager { return null; } } + /** * Returns an {@link Image} based on the specified {@link ImageDescriptor}. * - * @param descriptor - * the {@link ImageDescriptor} for the {@link Image}. + * @param descriptor the {@link ImageDescriptor} for the {@link Image}. * @return the {@link Image} based on the specified {@link ImageDescriptor}. */ public static Image getImage(ImageDescriptor descriptor) { @@ -96,23 +107,24 @@ public class ResourceManager extends SWTResourceManager { } return image; } + /** * Maps images to decorated images. */ @SuppressWarnings("unchecked") private static Map>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY]; + /** * Returns an {@link Image} composed of a base image decorated by another image. * - * @param baseImage - * the base {@link Image} that should be decorated. - * @param decorator - * the {@link Image} to decorate the base image. + * @param baseImage the base {@link Image} that should be decorated. + * @param decorator the {@link Image} to decorate the base image. * @return {@link Image} The resulting decorated image. */ public static Image decorateImage(Image baseImage, Image decorator) { return decorateImage(baseImage, decorator, BOTTOM_RIGHT); } + /** * Returns an {@link Image} composed of a base image decorated by another image. * @@ -149,13 +161,13 @@ public class ResourceManager extends SWTResourceManager { protected void drawCompositeImage(int width, int height) { drawImage(createCachedImageDataProvider(baseImage), 0, 0); if (corner == TOP_LEFT) { - drawImage(createCachedImageDataProvider(decorator), 0, 0); + drawImage(getUnzoomedImageDataProvider(decorator.getImageData()) , 0, 0); } else if (corner == TOP_RIGHT) { - drawImage(createCachedImageDataProvider(decorator), bib.width - dib.width, 0); + drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), bib.width - dib.width, 0); } else if (corner == BOTTOM_LEFT) { - drawImage(createCachedImageDataProvider(decorator), 0, bib.height - dib.height); + drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), 0, bib.height - dib.height); } else if (corner == BOTTOM_RIGHT) { - drawImage(createCachedImageDataProvider(decorator), bib.width - dib.width, bib.height - dib.height); + drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), bib.width - dib.width, bib.height - dib.height); } } @Override @@ -169,6 +181,12 @@ public class ResourceManager extends SWTResourceManager { } return result; } + + private static ImageDataProvider getUnzoomedImageDataProvider(ImageData imageData) { + return zoom -> zoom == 100 ? imageData : null; + } + + /** * Dispose all of the cached images. */ @@ -202,6 +220,7 @@ public class ResourceManager extends SWTResourceManager { m_URLImageMap.clear(); } } + //////////////////////////////////////////////////////////////////////////// // // Plugin images support @@ -211,23 +230,25 @@ public class ResourceManager extends SWTResourceManager { * Maps URL to images. */ private static Map m_URLImageMap = new HashMap(); + /** * Provider for plugin resources, used by WindowBuilder at design time. */ public interface PluginResourceProvider { URL getEntry(String symbolicName, String path); } + /** - * Instance of {@link PluginResourceProvider}, used by WindowBuilder at design time. + * Instance of {@link PluginResourceProvider}, used by WindowBuilder at design + * time. */ private static PluginResourceProvider m_designTimePluginResourceProvider = null; + /** * Returns an {@link Image} based on a plugin and file path. * - * @param plugin - * the plugin {@link Object} containing the image - * @param name - * the path to the image within the plugin + * @param plugin the plugin {@link Object} containing the image + * @param name the path to the image within the plugin * @return the {@link Image} stored in the file at the specified path * * @deprecated Use {@link #getPluginImage(String, String)} instead. @@ -244,13 +265,12 @@ public class ResourceManager extends SWTResourceManager { } return null; } + /** * Returns an {@link Image} based on a {@link Bundle} and resource entry path. * - * @param symbolicName - * the symbolic name of the {@link Bundle}. - * @param path - * the path of the resource entry. + * @param symbolicName the symbolic name of the {@link Bundle}. + * @param path the path of the resource entry. * @return the {@link Image} stored in the file at the specified path. */ public static Image getPluginImage(String symbolicName, String path) { @@ -264,6 +284,7 @@ public class ResourceManager extends SWTResourceManager { } return null; } + /** * Returns an {@link Image} based on given {@link URL}. */ @@ -290,13 +311,12 @@ public class ResourceManager extends SWTResourceManager { } return null; } + /** * Returns an {@link ImageDescriptor} based on a plugin and file path. * - * @param plugin - * the plugin {@link Object} containing the image. - * @param name - * the path to th eimage within the plugin. + * @param plugin the plugin {@link Object} containing the image. + * @param name the path to th eimage within the plugin. * @return the {@link ImageDescriptor} stored in the file at the specified path. * * @deprecated Use {@link #getPluginImageDescriptor(String, String)} instead. @@ -315,14 +335,15 @@ public class ResourceManager extends SWTResourceManager { } return null; } + /** - * Returns an {@link ImageDescriptor} based on a {@link Bundle} and resource entry path. + * Returns an {@link ImageDescriptor} based on a {@link Bundle} and resource + * entry path. * - * @param symbolicName - * the symbolic name of the {@link Bundle}. - * @param path - * the path of the resource entry. - * @return the {@link ImageDescriptor} based on a {@link Bundle} and resource entry path. + * @param symbolicName the symbolic name of the {@link Bundle}. + * @param path the path of the resource entry. + * @return the {@link ImageDescriptor} based on a {@link Bundle} and resource + * entry path. */ public static ImageDescriptor getPluginImageDescriptor(String symbolicName, String path) { try { @@ -335,6 +356,7 @@ public class ResourceManager extends SWTResourceManager { } return null; } + /** * Returns an {@link URL} based on a {@link Bundle} and resource entry path. */ @@ -353,13 +375,12 @@ public class ResourceManager extends SWTResourceManager { // no such resource return null; } + /** * Returns an {@link URL} based on a plugin and file path. * - * @param plugin - * the plugin {@link Object} containing the file path. - * @param name - * the file path. + * @param plugin the plugin {@link Object} containing the file path. + * @param name the file path. * @return the {@link URL} representing the file at the specified path. * @throws Exception */ @@ -373,13 +394,13 @@ public class ResourceManager extends SWTResourceManager { Object bundle = getBundleMethod.invoke(plugin, new Object[0]); // Class PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$ - Constructor pathConstructor = PathClass.getConstructor(new Class[]{String.class}); - Object path = pathConstructor.newInstance(new Object[]{name}); + Constructor pathConstructor = PathClass.getConstructor(new Class[] { String.class }); + Object path = pathConstructor.newInstance(new Object[] { name }); // Class IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$ Class PlatformClass = Class.forName("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$ - Method findMethod = PlatformClass.getMethod("find", new Class[]{BundleClass, IPathClass}); //$NON-NLS-1$ - return (URL) findMethod.invoke(null, new Object[]{bundle, path}); + Method findMethod = PlatformClass.getMethod("find", new Class[] { BundleClass, IPathClass }); //$NON-NLS-1$ + return (URL) findMethod.invoke(null, new Object[] { bundle, path }); } } catch (Throwable e) { // Ignore any exceptions @@ -390,24 +411,26 @@ public class ResourceManager extends SWTResourceManager { if (PluginClass.isAssignableFrom(plugin.getClass())) { // Class PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$ - Constructor pathConstructor = PathClass.getConstructor(new Class[]{String.class}); - Object path = pathConstructor.newInstance(new Object[]{name}); + Constructor pathConstructor = PathClass.getConstructor(new Class[] { String.class }); + Object path = pathConstructor.newInstance(new Object[] { name }); // Class IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$ - Method findMethod = PluginClass.getMethod("find", new Class[]{IPathClass}); //$NON-NLS-1$ - return (URL) findMethod.invoke(plugin, new Object[]{path}); + Method findMethod = PluginClass.getMethod("find", new Class[] { IPathClass }); //$NON-NLS-1$ + return (URL) findMethod.invoke(plugin, new Object[] { path }); } } return null; } + //////////////////////////////////////////////////////////////////////////// // // General // //////////////////////////////////////////////////////////////////////////// /** - * Dispose of cached objects and their underlying OS resources. This should only be called when the cached - * objects are no longer needed (e.g. on application shutdown). + * Dispose of cached objects and their underlying OS resources. This should only + * be called when the cached objects are no longer needed (e.g. on application + * shutdown). */ public static void dispose() { disposeColors();