|
From: <caw...@us...> - 2007-01-21 18:35:39
|
Revision: 1834
http://svn.sourceforge.net/rubyeclipse/?rev=1834&view=rev
Author: cawilliams
Date: 2007-01-21 10:35:37 -0800 (Sun, 21 Jan 2007)
Log Message:
-----------
More work to get the Interpreter/VM setup done correctly - expect that system libraries are folders, not jar/zip files.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/debug/ui/RdtDebugUiConstants.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RdtDebugUiPlugin.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEnvironmentTab.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterPreferencePage.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.properties
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/ISharedImages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.ui/icons/full/ovr16/
trunk/org.rubypeople.rdt.debug.ui/icons/full/ovr16/error_co.gif
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RDTImageDescriptor.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RubyDebugImages.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryContentProvider.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryLabelProvider.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryStandin.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/VMLibraryBlock.java
trunk/org.rubypeople.rdt.ui/icons/full/obj16/jar_lsrc_obj.gif
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/SharedImages.java
Added: trunk/org.rubypeople.rdt.debug.ui/icons/full/ovr16/error_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.debug.ui/icons/full/ovr16/error_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/debug/ui/RdtDebugUiConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/debug/ui/RdtDebugUiConstants.java 2007-01-20 22:54:05 UTC (rev 1833)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/debug/ui/RdtDebugUiConstants.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -7,4 +7,5 @@
public static final String SHOW_STATIC_VARIABLES_PREFERENCE = RdtDebugUiPlugin.PLUGIN_ID + ".showStaticVariables";
public static final String SHOW_CONSTANTS_PREFERENCE = RdtDebugUiPlugin.PLUGIN_ID + ".showConstants";
public static final String EVALUATION_EXPRESSIONS_PREFERENCE = RdtDebugUiPlugin.PLUGIN_ID + ".evaluationExpressions";
+ public static final int INTERNAL_ERROR = 0;
}
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RDTImageDescriptor.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RDTImageDescriptor.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RDTImageDescriptor.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -0,0 +1,82 @@
+package org.rubypeople.rdt.internal.debug.ui;
+
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+
+public class RDTImageDescriptor extends CompositeImageDescriptor {
+
+ /** Flag to render the is out of synch adornment */
+ public final static int IS_OUT_OF_SYNCH= 0x0001;
+
+ private Point fSize;
+ private ImageDescriptor fBaseImage;
+ private int fFlags;
+
+ public RDTImageDescriptor(ImageDescriptor baseImage, int flags) {
+ setBaseImage(baseImage);
+ setFlags(flags);
+ }
+
+ @Override
+ protected void drawCompositeImage(int width, int height) {
+ ImageData bg= getBaseImage().getImageData();
+ if (bg == null) {
+ bg= DEFAULT_IMAGE_DATA;
+ }
+ drawImage(bg, 0, 0);
+ drawOverlays();
+ }
+
+ @Override
+ protected Point getSize() {
+ if (fSize == null) {
+ ImageData data= getBaseImage().getImageData();
+ setSize(new Point(data.width, data.height));
+ }
+ return fSize;
+ }
+
+ protected void setSize(Point size) {
+ fSize = size;
+ }
+
+ protected ImageDescriptor getBaseImage() {
+ return fBaseImage;
+ }
+
+ protected void setBaseImage(ImageDescriptor baseImage) {
+ fBaseImage = baseImage;
+ }
+
+ protected int getFlags() {
+ return fFlags;
+ }
+
+ protected void setFlags(int flags) {
+ fFlags = flags;
+ }
+
+ /**
+ * Add any overlays to the image as specified in the flags.
+ */
+ protected void drawOverlays() {
+ int flags= getFlags();
+ int x= 0;
+ int y= 0;
+ ImageData data= null;
+ if ((flags & IS_OUT_OF_SYNCH) != 0) {
+ x= getSize().x;
+ y= 0;
+ data= getImageData(RubyDebugImages.IMG_OVR_OUT_OF_SYNCH);
+ x -= data.width;
+ drawImage(data, x, y);
+ }
+ }
+
+ private ImageData getImageData(String imageDescriptorKey) {
+ return RubyDebugImages.getImageDescriptor(imageDescriptorKey).getImageData();
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RdtDebugUiPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RdtDebugUiPlugin.java 2007-01-20 22:54:05 UTC (rev 1833)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RdtDebugUiPlugin.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -5,6 +5,8 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.internal.ui.ImageDescriptorRegistry;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -19,7 +21,9 @@
public static final String PLUGIN_ID = "org.rubypeople.rdt.debug.ui"; //$NON-NLS-1$
protected static RdtDebugUiPlugin plugin;
- private EvaluationExpressionModel evaluationExpressionModel ;
+ private EvaluationExpressionModel evaluationExpressionModel;
+
+ private ImageDescriptorRegistry fImageDescriptorRegistry;
public RdtDebugUiPlugin() {
super();
@@ -58,6 +62,17 @@
new CodeReloader();
}
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ try {
+ if (fImageDescriptorRegistry != null) {
+ fImageDescriptorRegistry.dispose();
+ }
+ } finally {
+ super.stop(context);
+ }
+ }
+
public EvaluationExpressionModel getEvaluationExpressionModel() {
if (evaluationExpressionModel == null) {
evaluationExpressionModel = new EvaluationExpressionModel() ;
@@ -65,4 +80,31 @@
return evaluationExpressionModel ;
}
+ public static String getUniqueIdentifier() {
+ return PLUGIN_ID;
+ }
+
+ /**
+ * Returns the standard display to be used. The method first checks, if
+ * the thread calling this method has an associated display. If so, this
+ * display is returned. Otherwise the method returns the default display.
+ */
+ public static Display getStandardDisplay() {
+ Display display;
+ display= Display.getCurrent();
+ if (display == null)
+ display= Display.getDefault();
+ return display;
+ }
+
+ /**
+ * Returns the image descriptor registry used for this plugin.
+ */
+ public static ImageDescriptorRegistry getImageDescriptorRegistry() {
+ if (getDefault().fImageDescriptorRegistry == null) {
+ getDefault().fImageDescriptorRegistry = new ImageDescriptorRegistry();
+ }
+ return getDefault().fImageDescriptorRegistry;
+ }
+
}
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RubyDebugImages.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RubyDebugImages.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/RubyDebugImages.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -0,0 +1,65 @@
+package org.rubypeople.rdt.internal.debug.ui;
+
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.osgi.framework.Bundle;
+
+public class RubyDebugImages {
+ private static String ICONS_PATH = "$nl$/icons/full/"; //$NON-NLS-1$
+
+ private static ImageRegistry fgImageRegistry;
+
+ public static final String IMG_OVR_OUT_OF_SYNCH = "IMG_OVR_OUT_OF_SYNCH"; //$NON-NLS-1$
+
+ private static final String T_OVR= ICONS_PATH + "ovr16/"; //$NON-NLS-1$
+
+ /**
+ * Returns the <code>ImageDescriptor</code> identified by the given key,
+ * or <code>null</code> if it does not exist.
+ */
+ public static ImageDescriptor getImageDescriptor(String key) {
+ return getImageRegistry().getDescriptor(key);
+ }
+
+ /*
+ * Helper method to access the image registry from the JDIDebugUIPlugin
+ * class.
+ */
+ /* package */static ImageRegistry getImageRegistry() {
+ if (fgImageRegistry == null) {
+ initializeImageRegistry();
+ }
+ return fgImageRegistry;
+ }
+
+ private static void initializeImageRegistry() {
+ fgImageRegistry= new ImageRegistry(RdtDebugUiPlugin.getStandardDisplay());
+ declareImages();
+ }
+
+ private static void declareImages() {
+ declareRegistryImage(IMG_OVR_OUT_OF_SYNCH, T_OVR + "error_co.gif"); //$NON-NLS-1$
+ }
+
+ /**
+ * Declare an Image in the registry table.
+ * @param key The key to use when registering the image
+ * @param path The path where the image can be found. This path is relative to where
+ * this plugin class is found (i.e. typically the packages directory)
+ */
+ private final static void declareRegistryImage(String key, String path) {
+ ImageDescriptor desc = ImageDescriptor.getMissingImageDescriptor();
+ Bundle bundle = Platform.getBundle(RdtDebugUiPlugin.getUniqueIdentifier());
+ URL url = null;
+ if (bundle != null){
+ url = FileLocator.find(bundle, new Path(path), null);
+ desc = ImageDescriptor.createFromURL(url);
+ }
+ fgImageRegistry.put(key, desc);
+ }
+}
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEnvironmentTab.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEnvironmentTab.java 2007-01-20 22:54:05 UTC (rev 1833)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEnvironmentTab.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -33,7 +33,7 @@
import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiMessages;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
-import org.rubypeople.rdt.internal.debug.ui.preferences.AddVMDialog;
+import org.rubypeople.rdt.internal.debug.ui.rubyvms.AddVMDialog;
import org.rubypeople.rdt.internal.debug.ui.rubyvms.IAddVMDialogRequestor;
import org.rubypeople.rdt.internal.debug.ui.rubyvms.RubyVMMessages;
import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute;
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterPreferencePage.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterPreferencePage.java 2007-01-20 22:54:05 UTC (rev 1833)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterPreferencePage.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -27,6 +27,7 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiMessages;
+import org.rubypeople.rdt.internal.debug.ui.rubyvms.AddVMDialog;
import org.rubypeople.rdt.internal.debug.ui.rubyvms.IAddVMDialogRequestor;
import org.rubypeople.rdt.internal.debug.ui.rubyvms.RubyVMMessages;
import org.rubypeople.rdt.internal.debug.ui.rubyvms.RubyVMsUpdater;
@@ -40,7 +41,7 @@
/**
* VMs being displayed
*/
- private List fVMs = new ArrayList();
+ private List<IVMInstall> fVMs = new ArrayList<IVMInstall>();
protected CheckboxTableViewer fVMList;
protected Button addButton, editButton, removeButton;
@@ -72,7 +73,7 @@
private void fillWithWorkspaceRubyVMs() {
// fill with Ruby VMs
- List standins = new ArrayList();
+ List<VMStandin> standins = new ArrayList<VMStandin>();
IVMInstallType[] types = RubyRuntime.getVMInstallTypes();
for (int i = 0; i < types.length; i++) {
IVMInstallType type = types[i];
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryContentProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryContentProvider.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -0,0 +1,199 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.debug.ui.rubyvms;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+
+public class LibraryContentProvider implements ITreeContentProvider {
+
+ private Viewer fViewer;
+
+ private HashMap fChildren= new HashMap();
+
+ private LibraryStandin[] fLibraries= new LibraryStandin[0];
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ fViewer = viewer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object inputElement) {
+ return fLibraries;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof LibraryStandin) {
+ LibraryStandin standin= (LibraryStandin) parentElement;
+ Object[] children= (Object[])fChildren.get(standin);
+ return children;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ public void setLibraries(IPath[] libs) {
+ fLibraries = new LibraryStandin[libs.length];
+ for (int i = 0; i < libs.length; i++) {
+ fLibraries[i] = new LibraryStandin(libs[i]);
+ }
+ fViewer.refresh();
+ }
+
+ public IPath[] getLibraries() {
+ IPath[] locations = new IPath[fLibraries.length];
+ for (int i = 0; i < locations.length; i++) {
+ locations[i] = fLibraries[i].toLibraryLocation();
+ }
+ return locations;
+ }
+
+ /**
+ * Returns the list of libraries in the given selection. SubElements
+ * are replaced by their parent libraries.
+ */
+ private Set getSelectedLibraries(IStructuredSelection selection) {
+ Set libraries= new HashSet();
+ for (Iterator iter= selection.iterator(); iter.hasNext();) {
+ Object element= iter.next();
+ if (element instanceof LibraryStandin) {
+ libraries.add(element);
+ }
+ }
+ return libraries;
+ }
+
+ /**
+ * Move the libraries of the given selection up.
+ */
+ public void up(IStructuredSelection selection) {
+ Set libraries= getSelectedLibraries(selection);
+ for (int i= 0; i < fLibraries.length - 1; i++) {
+ if (libraries.contains(fLibraries[i + 1])) {
+ LibraryStandin temp= fLibraries[i];
+ fLibraries[i]= fLibraries[i + 1];
+ fLibraries[i + 1]= temp;
+ }
+ }
+ fViewer.refresh();
+ fViewer.setSelection(selection);
+ }
+
+ /**
+ * Move the libraries of the given selection down.
+ */
+ public void down(IStructuredSelection selection) {
+ Set libraries= getSelectedLibraries(selection);
+ for (int i= fLibraries.length - 1; i > 0; i--) {
+ if (libraries.contains(fLibraries[i - 1])) {
+ LibraryStandin temp= fLibraries[i];
+ fLibraries[i]= fLibraries[i - 1];
+ fLibraries[i - 1]= temp;
+ }
+ }
+ fViewer.refresh();
+ fViewer.setSelection(selection);
+ }
+
+ /**
+ * Remove the libraries contained in the given selection.
+ */
+ public void remove(IStructuredSelection selection) {
+ List newLibraries = new ArrayList();
+ for (int i = 0; i < fLibraries.length; i++) {
+ newLibraries.add(fLibraries[i]);
+ }
+ Iterator iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ if (element instanceof LibraryStandin) {
+ newLibraries.remove(element);
+ }
+ }
+ fLibraries= (LibraryStandin[]) newLibraries.toArray(new LibraryStandin[newLibraries.size()]);
+ fViewer.refresh();
+ }
+
+ /**
+ * Add the given libraries before the selection, or after the existing libraries
+ * if the selection is empty.
+ */
+ public void add(IPath[] libs, IStructuredSelection selection) {
+ List newLibraries = new ArrayList(fLibraries.length + libs.length);
+ for (int i = 0; i < fLibraries.length; i++) {
+ newLibraries.add(fLibraries[i]);
+ }
+ List toAdd = new ArrayList(libs.length);
+ for (int i = 0; i < libs.length; i++) {
+ toAdd.add(new LibraryStandin(libs[i]));
+ }
+ if (selection.isEmpty()) {
+ newLibraries.addAll(toAdd);
+ } else {
+ Object element= selection.getFirstElement();
+ LibraryStandin firstLib= (LibraryStandin) element;
+ int index = newLibraries.indexOf(firstLib);
+ newLibraries.addAll(index, toAdd);
+ }
+ fLibraries= (LibraryStandin[]) newLibraries.toArray(new LibraryStandin[newLibraries.size()]);
+ fViewer.refresh();
+ fViewer.setSelection(new StructuredSelection(libs), true);
+ }
+
+ /**
+ * Returns the standin libraries being edited.
+ *
+ * @return standins
+ */
+ LibraryStandin[] getStandins() {
+ return fLibraries;
+ }
+
+}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryLabelProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryLabelProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryLabelProvider.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.debug.ui.rubyvms;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.rubypeople.rdt.internal.debug.ui.RDTImageDescriptor;
+import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
+import org.rubypeople.rdt.ui.ISharedImages;
+import org.rubypeople.rdt.ui.RubyUI;
+
+/**
+ * Label provider for Ruby vM libraries.
+ *
+ * @since 0.9.0
+ */
+public class LibraryLabelProvider extends LabelProvider {
+
+ public Image getImage(Object element) {
+ if (element instanceof LibraryStandin) {
+ LibraryStandin library= (LibraryStandin) element;
+ String key = ISharedImages.IMG_OBJS_EXTERNAL_ARCHIVE;
+ IStatus status = library.validate();
+ if (!status.isOK()) {
+ ImageDescriptor base = RubyUI.getSharedImages().getImageDescriptor(key);
+ RDTImageDescriptor descriptor= new RDTImageDescriptor(base, RDTImageDescriptor.IS_OUT_OF_SYNCH);
+ return RdtDebugUiPlugin.getImageDescriptorRegistry().get(descriptor);
+ }
+ return RubyUI.getSharedImages().getImage(key);
+ }
+ return null;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof LibraryStandin) {
+ return ((LibraryStandin)element).getSystemLibraryPath().toOSString();
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryStandin.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryStandin.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/LibraryStandin.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.debug.ui.rubyvms;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.rubypeople.rdt.debug.ui.RdtDebugUiConstants;
+import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
+
+
+/**
+ * Wrapper for an original library location, to support editing.
+ *
+ */
+public final class LibraryStandin {
+ private IPath fSystemLibrary;
+
+ /**
+ * Creates a new library standin on the given library location.
+ */
+ public LibraryStandin(IPath path) {
+ fSystemLibrary= path;
+ }
+
+ /**
+ * Returns the JRE library jar location.
+ *
+ * @return The JRE library jar location.
+ */
+ public IPath getSystemLibraryPath() {
+ return fSystemLibrary;
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof LibraryStandin) {
+ LibraryStandin lib = (LibraryStandin)obj;
+ return getSystemLibraryPath().equals(lib.getSystemLibraryPath());
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return getSystemLibraryPath().hashCode();
+ }
+
+ /**
+ * Returns whether the given paths are equal - either may be <code>null</code>.
+ * @param path1 path to be compared
+ * @param path2 path to be compared
+ * @return whether the given paths are equal
+ */
+ protected boolean equals(IPath path1, IPath path2) {
+ return equalsOrNull(path1, path2);
+ }
+
+ /**
+ * Returns whether the given objects are equal - either may be <code>null</code>.
+ * @param o1 object to be compared
+ * @param o2 object to be compared
+ * @return whether the given objects are equal or both null
+ * @since 3.1
+ */
+ private boolean equalsOrNull(Object o1, Object o2) {
+ if (o1 == null) {
+ return o2 == null;
+ }
+ if (o2 == null) {
+ return false;
+ }
+ return o1.equals(o2);
+ }
+
+ /**
+ * Returns an equivalent library location.
+ *
+ * @return library location
+ */
+ IPath toLibraryLocation() {
+ return getSystemLibraryPath();
+ }
+
+ /**
+ * Returns a status for this library describing any error states
+ *
+ * @return
+ */
+ IStatus validate() {
+ if (!getSystemLibraryPath().toFile().exists()) {
+ return new Status(IStatus.ERROR, RdtDebugUiPlugin.getUniqueIdentifier(), RdtDebugUiConstants.INTERNAL_ERROR,
+ MessageFormat.format(RubyVMMessages.LibraryStandin_0, new String[]{getSystemLibraryPath().toOSString()}), null);
+ }
+ return Status.OK_STATUS;
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.java 2007-01-20 22:54:05 UTC (rev 1833)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -21,6 +21,15 @@
public static String JREsUpdater_0;
public static String addVMDialog_pickJRERootDialog_message;
+ public static String VMLibraryBlock_7;
+ public static String VMLibraryBlock_6;
+ public static String VMLibraryBlock_4;
+ public static String VMLibraryBlock_5;
+ public static String VMLibraryBlock_9;
+ public static String VMLibraryBlock_Libraries_cannot_be_empty__1;
+ public static String VMLibraryBlock_10;
+ public static String LibraryStandin_0;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, RubyVMMessages.class);
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.properties 2007-01-20 22:54:05 UTC (rev 1833)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/RubyVMMessages.properties 2007-01-21 18:35:37 UTC (rev 1834)
@@ -16,4 +16,12 @@
InstalledJREsBlock_7=Add RubyVM
InstalledJREsBlock_8=Edit RubyVM
-JREsUpdater_0=Save VM Definitions
\ No newline at end of file
+JREsUpdater_0=Save VM Definitions
+
+VMLibraryBlock_4=U&p
+VMLibraryBlock_5=&Down
+VMLibraryBlock_6=Re&move
+VMLibraryBlock_7=Add E&xternal Folders...
+VMLibraryBlock_9=&Restore Default
+
+LibraryStandin_0=System library does not exist: {0}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/VMLibraryBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/VMLibraryBlock.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/rubyvms/VMLibraryBlock.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -0,0 +1,374 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.debug.ui.rubyvms;
+
+
+import java.io.File;
+import java.util.Iterator;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Label;
+import org.rubypeople.rdt.debug.ui.RdtDebugUiConstants;
+import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
+import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMInstallType;
+import org.rubypeople.rdt.launching.RubyRuntime;
+
+/**
+ * Control used to edit the libraries associated with a VM install
+ */
+public class VMLibraryBlock implements SelectionListener, ISelectionChangedListener {
+
+ /**
+ * Attribute name for the last path used to open a file/directory chooser
+ * dialog.
+ */
+ protected static final String LAST_PATH_SETTING = "LAST_PATH_SETTING"; //$NON-NLS-1$
+
+ /**
+ * the prefix for dialog setting pertaining to this block
+ */
+ protected static final String DIALOG_SETTINGS_PREFIX = "VMLibraryBlock"; //$NON-NLS-1$
+
+ protected boolean fInCallback = false;
+ protected IVMInstall fVmInstall;
+ protected IVMInstallType fVmInstallType;
+ protected File fHome;
+
+ //widgets
+ protected LibraryContentProvider fLibraryContentProvider;
+ protected AddVMDialog fDialog = null;
+ protected TreeViewer fLibraryViewer;
+ private Button fUpButton;
+ private Button fDownButton;
+ private Button fRemoveButton;
+ private Button fAddButton;
+ protected Button fDefaultButton;
+
+ /**
+ * Constructor for VMLibraryBlock.
+ */
+ public VMLibraryBlock(AddVMDialog dialog) {
+ fDialog = dialog;
+ }
+
+ /**
+ * Creates and returns the source lookup control.
+ *
+ * @param parent the parent widget of this control
+ */
+ public Control createControl(Composite parent) {
+ Font font = parent.getFont();
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ GridLayout topLayout = new GridLayout();
+ topLayout.numColumns = 2;
+ topLayout.marginHeight = 0;
+ topLayout.marginWidth = 0;
+ comp.setLayout(topLayout);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ comp.setLayoutData(gd);
+
+ fLibraryViewer= new TreeViewer(comp);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 6;
+ fLibraryViewer.getControl().setLayoutData(gd);
+ fLibraryContentProvider= new LibraryContentProvider();
+ fLibraryViewer.setContentProvider(fLibraryContentProvider);
+ fLibraryViewer.setLabelProvider(new LibraryLabelProvider());
+ fLibraryViewer.setInput(this);
+ fLibraryViewer.addSelectionChangedListener(this);
+
+ Composite pathButtonComp = new Composite(comp, SWT.NONE);
+ GridLayout pathButtonLayout = new GridLayout();
+ pathButtonLayout.marginHeight = 0;
+ pathButtonLayout.marginWidth = 0;
+ pathButtonComp.setLayout(pathButtonLayout);
+ gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
+ pathButtonComp.setLayoutData(gd);
+ pathButtonComp.setFont(font);
+
+ fAddButton= createPushButton(pathButtonComp, RubyVMMessages.VMLibraryBlock_7);
+ fAddButton.addSelectionListener(this);
+
+ fRemoveButton= createPushButton(pathButtonComp, RubyVMMessages.VMLibraryBlock_6);
+ fRemoveButton.addSelectionListener(this);
+
+ fUpButton= createPushButton(pathButtonComp, RubyVMMessages.VMLibraryBlock_4);
+ fUpButton.addSelectionListener(this);
+
+ fDownButton= createPushButton(pathButtonComp, RubyVMMessages.VMLibraryBlock_5);
+ fDownButton.addSelectionListener(this);
+
+ fDefaultButton= createPushButton(pathButtonComp, RubyVMMessages.VMLibraryBlock_9);
+ fDefaultButton.addSelectionListener(this);
+
+ return comp;
+ }
+
+ /**
+ * The "default" button has been toggled
+ */
+ public void restoreDefaultLibraries() {
+ IPath[] libs = null;
+ File installLocation = getHomeDirectory();
+ if (installLocation == null) {
+ libs = new IPath[0];
+ } else {
+ libs = getVMInstallType().getDefaultLibraryLocations(installLocation);
+ }
+ fLibraryContentProvider.setLibraries(libs);
+ update();
+ }
+
+ /**
+ * Creates and returns a button
+ *
+ * @param parent parent widget
+ * @param label label
+ * @return Button
+ */
+ protected Button createPushButton(Composite parent, String label) {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setFont(parent.getFont());
+ button.setText(label);
+ fDialog.setButtonLayoutData(button);
+ return button;
+ }
+
+ /**
+ * Create some empty space
+ */
+ protected void createVerticalSpacer(Composite comp, int colSpan) {
+ Label label = new Label(comp, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalSpan = colSpan;
+ label.setLayoutData(gd);
+ }
+
+ /**
+ * Initializes this control based on the settings in the given
+ * vm install and type.
+ *
+ * @param vm vm or <code>null</code> if none
+ * @param type type of vm install
+ */
+ public void initializeFrom(IVMInstall vm, IVMInstallType type) {
+ fVmInstall = vm;
+ fVmInstallType = type;
+ if (vm != null) {
+ setHomeDirectory(vm.getInstallLocation());
+ fLibraryContentProvider.setLibraries(RubyRuntime.getLibraryLocations(getVMInstall()));
+ }
+ update();
+ }
+
+ /**
+ * Sets the home directory of the VM Install the user has chosen
+ */
+ public void setHomeDirectory(File file) {
+ fHome = file;
+ }
+
+ /**
+ * Returns the home directory
+ */
+ protected File getHomeDirectory() {
+ return fHome;
+ }
+
+ /**
+ * Updates buttons and status based on current libraries
+ */
+ public void update() {
+ updateButtons();
+ IStatus status = Status.OK_STATUS;
+ if (fLibraryContentProvider.getLibraries().length == 0) { // && !isDefaultSystemLibrary()) {
+ status = new Status(IStatus.ERROR, RdtDebugUiPlugin.getUniqueIdentifier(), RdtDebugUiConstants.INTERNAL_ERROR,
+ RubyVMMessages.VMLibraryBlock_Libraries_cannot_be_empty__1, null);
+ }
+ LibraryStandin[] standins = fLibraryContentProvider.getStandins();
+ for (int i = 0; i < standins.length; i++) {
+ IStatus st = standins[i].validate();
+ if (!st.isOK()) {
+ status = st;
+ break;
+ }
+ }
+ fDialog.setSystemLibraryStatus(status);
+ fDialog.updateStatusLine();
+ }
+
+ /**
+ * Saves settings in the given working copy
+ */
+ public void performApply(IVMInstall vm) {
+ if (isDefaultLocations()) {
+ vm.setLibraryLocations(null);
+ } else {
+ IPath[] libs = fLibraryContentProvider.getLibraries();
+ vm.setLibraryLocations(libs);
+ }
+ }
+
+ /**
+ * Determines if the present setup is the default location s for this JRE
+ * @return true if the current set of locations are the defaults, false otherwise
+ */
+ protected boolean isDefaultLocations() {
+ IPath[] libraryLocations = fLibraryContentProvider.getLibraries();
+ IVMInstall install = getVMInstall();
+
+ if (install == null || libraryLocations == null) {
+ return true;
+ }
+ File installLocation = install.getInstallLocation();
+ if (installLocation != null) {
+ IPath[] def = getVMInstallType().getDefaultLibraryLocations(installLocation);
+ if (def.length == libraryLocations.length) {
+ for (int i = 0; i < def.length; i++) {
+ if (!def[i].equals(libraryLocations[i])) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns the vm install associated with this library block.
+ *
+ * @return vm install
+ */
+ protected IVMInstall getVMInstall() {
+ return fVmInstall;
+ }
+
+ /**
+ * Returns the vm install type associated with this library block.
+ *
+ * @return vm install
+ */
+ protected IVMInstallType getVMInstallType() {
+ return fVmInstallType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected(SelectionEvent e) {
+ Object source= e.getSource();
+ if (source == fUpButton) {
+ fLibraryContentProvider.up((IStructuredSelection) fLibraryViewer.getSelection());
+ } else if (source == fDownButton) {
+ fLibraryContentProvider.down((IStructuredSelection) fLibraryViewer.getSelection());
+ } else if (source == fRemoveButton) {
+ fLibraryContentProvider.remove((IStructuredSelection) fLibraryViewer.getSelection());
+ } else if (source == fAddButton) {
+ add((IStructuredSelection) fLibraryViewer.getSelection());
+ }
+ else if (source == fDefaultButton) {
+ restoreDefaultLibraries();
+ }
+ update();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected(SelectionEvent e) {}
+
+ /**
+ * Open the file selection dialog, and add the return jars as libraries.
+ */
+ private void add(IStructuredSelection selection) {
+ IDialogSettings dialogSettings= RdtDebugUiPlugin.getDefault().getDialogSettings();
+ String lastUsedPath= dialogSettings.get(LAST_PATH_SETTING);
+ if (lastUsedPath == null) {
+ lastUsedPath= ""; //$NON-NLS-1$
+ }
+ DirectoryDialog dialog= new DirectoryDialog(fLibraryViewer.getControl().getShell(), SWT.MULTI);
+ dialog.setText(RubyVMMessages.VMLibraryBlock_10);
+ dialog.setFilterPath(lastUsedPath);
+ String res= dialog.open();
+ if (res == null) {
+ return;
+ }
+ String dirName = dialog.getText();
+
+
+ IPath filterPath= new Path(dialog.getFilterPath());
+ IPath[] libs= new IPath[1];
+ libs[0]= filterPath.append(dirName).makeAbsolute();
+
+ dialogSettings.put(LAST_PATH_SETTING, filterPath.toOSString());
+
+ fLibraryContentProvider.add(libs, selection);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateButtons();
+ }
+
+ /**
+ * Refresh the enable/disable state for the buttons.
+ */
+ private void updateButtons() {
+ IStructuredSelection selection = (IStructuredSelection) fLibraryViewer.getSelection();
+ fRemoveButton.setEnabled(!selection.isEmpty());
+ boolean enableUp = true,
+ enableDown = true,
+ allRoots = true;
+ Object[] libraries = fLibraryContentProvider.getElements(null);
+ if (selection.isEmpty() || libraries.length == 0) {
+ enableUp = false;
+ enableDown = false;
+ } else {
+ Object first = libraries[0];
+ Object last = libraries[libraries.length - 1];
+ for (Iterator iter= selection.iterator(); iter.hasNext();) {
+ Object element= iter.next();
+ Object lib = element;
+ if (lib == first) {
+ enableUp = false;
+ }
+ if (lib == last) {
+ enableDown = false;
+ }
+ }
+ }
+ fUpButton.setEnabled(enableUp);
+ fDownButton.setEnabled(enableDown);
+ }
+}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java 2007-01-20 22:54:05 UTC (rev 1833)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -7,9 +7,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.service.environment.Constants;
import org.rubypeople.rdt.launching.AbstractVMInstallType;
import org.rubypeople.rdt.launching.IVMInstall;
@@ -40,14 +38,11 @@
}
public IPath[] getDefaultLibraryLocations(File installLocation) {
- File rubyExecutable = findRubyExecutable(installLocation);
- // FIXME This is a big hack and is tailored to the one click installer on windows!
- String rubyPath = rubyExecutable.getParentFile().getAbsolutePath();
- String stdPath = rubyPath + fgSeparator + "lib" + fgSeparator + "ruby" + fgSeparator + "1.8";
- String sitePath = rubyPath + fgSeparator + "lib" + fgSeparator + "ruby" + fgSeparator + "site_ruby";
+ String stdPath = installLocation.getAbsolutePath() + fgSeparator + "lib" + fgSeparator + "ruby" + fgSeparator + "1.8";
+ String sitePath = installLocation.getAbsolutePath() + fgSeparator + "lib" + fgSeparator + "ruby" + fgSeparator + "site_ruby" + fgSeparator + "1.8";
IPath[] paths = new IPath[2];
paths[0] = new Path(stdPath);
- paths[0] = new Path(sitePath);
+ paths[1] = new Path(sitePath);
return paths;
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java 2007-01-20 22:54:05 UTC (rev 1833)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -699,7 +699,7 @@
IPath[] libraryPaths = new IPath[dflts.length];
for (int i = 0; i < dflts.length; i++) {
libraryPaths[i]= dflts[i];
- if (!libraryPaths[i].toFile().isFile()) {
+ if (!libraryPaths[i].toFile().isDirectory()) {
libraryPaths[i]= Path.EMPTY;
}
}
Added: trunk/org.rubypeople.rdt.ui/icons/full/obj16/jar_lsrc_obj.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/obj16/jar_lsrc_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-01-20 22:54:05 UTC (rev 1833)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -1,7 +1,8 @@
package org.rubypeople.rdt.internal.ui;
-import java.net.MalformedURLException;
import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
@@ -16,15 +17,12 @@
protected static final String NAME_PREFIX = "org.rubypeople.rdt.ui.";
protected static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();
- protected static URL iconBaseURL;
-
- static {
- iconBaseURL= RubyPlugin.getDefault().getBundle().getEntry("/icons/full/"); //$NON-NLS-1$
- }
public static final IPath ICONS_PATH= new Path("$nl$/icons/full"); //$NON-NLS-1$
- private static final ImageRegistry IMAGE_REGISTRY = new ImageRegistry();
+ // The plug-in registry
+ private static ImageRegistry fgImageRegistry= null;
+ private static HashMap fgAvoidSWTErrorMap= null;
private static final String T_OBJ = "obj16"; //$NON-NLS-1$
private static final String T_OVR= "ovr16"; //$NON-NLS-1$
@@ -40,6 +38,8 @@
public static final String IMG_MISC_PROTECTED= NAME_PREFIX + "methpro_obj.gif"; //$NON-NLS-1$
public static final String IMG_MISC_PRIVATE= NAME_PREFIX + "methpri_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_EXTJAR_WSRC= NAME_PREFIX + "jar_lsrc_obj.gif"; //$NON-NLS-1$
+
public static final String IMG_OBJS_ERROR = NAME_PREFIX + "error_obj.gif";
public static final String IMG_OBJS_WARNING = NAME_PREFIX + "warning_obj.gif";
public static final String IMG_OBJS_INFO = NAME_PREFIX + "info_obj.gif";
@@ -87,8 +87,8 @@
public static final ImageDescriptor DESC_OBJ_OVERRIDES= createUnManaged(T_OBJ, "over_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OBJ_IMPLEMENTS= createUnManaged(T_OBJ, "implm_co.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_LIBRARY= createManaged(T_OBJ, IMG_OBJS_LIBRARY);
-
+ public static final ImageDescriptor DESC_OBJS_LIBRARY= createManagedFromKey(T_OBJ, IMG_OBJS_LIBRARY);
+ public static final ImageDescriptor DESC_OBJS_EXTJAR_WSRC= createManagedFromKey(T_OBJ, IMG_OBJS_EXTJAR_WSRC);
public static final ImageDescriptor DESC_OVR_STATIC= createUnManaged(T_OVR, "static_co.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_FINAL= createUnManaged(T_OVR, "final_co.gif"); //$NON-NLS-1$
@@ -107,59 +107,59 @@
public static final ImageDescriptor DESC_ELCL_FILTER= createUnManaged(T_ELCL, "filter_ps.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_DLCL_FILTER= createUnManaged(T_DLCL, "filter_ps.gif"); //$NON-NLS-1$
- public static final ImageDescriptor DESC_OBJS_GHOST= createManaged(T_OBJ, IMG_OBJS_GHOST);
- public static final ImageDescriptor DESC_OBJS_IMPDECL= createManaged(T_OBJ, IMG_CTOOLS_RUBY_IMPORT);
- public static final ImageDescriptor DESC_OBJS_IMPCONT= createManaged(T_OBJ, IMG_CTOOLS_RUBY_IMPORT_CONTAINER);
+ public static final ImageDescriptor DESC_OBJS_GHOST= createManagedFromKey(T_OBJ, IMG_OBJS_GHOST);
+ public static final ImageDescriptor DESC_OBJS_IMPDECL= createManagedFromKey(T_OBJ, IMG_CTOOLS_RUBY_IMPORT);
+ public static final ImageDescriptor DESC_OBJS_IMPCONT= createManagedFromKey(T_OBJ, IMG_CTOOLS_RUBY_IMPORT_CONTAINER);
- public static final ImageDescriptor DESC_OBJS_RUBY_MODEL= createManaged(T_OBJ, IMG_OBJS_RUBY_MODEL);
- public static final ImageDescriptor DESC_OBJS_SOURCE_FOLDER= createManaged(T_OBJ, IMG_OBJS_SOURCE_FOLDER);
- public static final ImageDescriptor DESC_OBJS_LOCAL_VAR = createManaged(T_OBJ, IMG_CTOOLS_RUBY_LOCAL_VAR);
- public static final ImageDescriptor DESC_OBJS_GLOBAL = createManaged(T_OBJ, IMG_CTOOLS_RUBY_GLOBAL);
- public static final ImageDescriptor DESC_OBJS_MODULE = createManaged(T_OBJ, IMG_OBJS_MODULE);
- public static final ImageDescriptor DESC_OBJS_CLASS_VAR = createManaged(T_OBJ, IMG_CTOOLS_RUBY_CLASS_VAR);
- public static final ImageDescriptor DESC_OBJS_INSTANCE_VAR = createManaged(T_OBJ, IMG_CTOOLS_RUBY_INSTANCE_VAR);
- public static final ImageDescriptor DESC_OBJS_CONSTANT = createManaged(T_OBJ, IMG_CTOOLS_RUBY_CONSTANT);
+ public static final ImageDescriptor DESC_OBJS_RUBY_MODEL= createManagedFromKey(T_OBJ, IMG_OBJS_RUBY_MODEL);
+ public static final ImageDescriptor DESC_OBJS_SOURCE_FOLDER= createManagedFromKey(T_OBJ, IMG_OBJS_SOURCE_FOLDER);
+ public static final ImageDescriptor DESC_OBJS_LOCAL_VAR = createManagedFromKey(T_OBJ, IMG_CTOOLS_RUBY_LOCAL_VAR);
+ public static final ImageDescriptor DESC_OBJS_GLOBAL = createManagedFromKey(T_OBJ, IMG_CTOOLS_RUBY_GLOBAL);
+ public static final ImageDescriptor DESC_OBJS_MODULE = createManagedFromKey(T_OBJ, IMG_OBJS_MODULE);
+ public static final ImageDescriptor DESC_OBJS_CLASS_VAR = createManagedFromKey(T_OBJ, IMG_CTOOLS_RUBY_CLASS_VAR);
+ public static final ImageDescriptor DESC_OBJS_INSTANCE_VAR = createManagedFromKey(T_OBJ, IMG_CTOOLS_RUBY_INSTANCE_VAR);
+ public static final ImageDescriptor DESC_OBJS_CONSTANT = createManagedFromKey(T_OBJ, IMG_CTOOLS_RUBY_CONSTANT);
- public static final ImageDescriptor DESC_OBJS_CLASS= createManaged(T_OBJ, IMG_OBJS_CLASS);
- public static final ImageDescriptor DESC_OBJS_CLASSALT= createManaged(T_OBJ, IMG_OBJS_CLASSALT);
- public static final ImageDescriptor DESC_OBJS_INNER_CLASS= createManaged(T_OBJ, IMG_OBJS_INNER_CLASS);
- public static final ImageDescriptor DESC_OBJS_MODULEALT = createManaged(T_OBJ, IMG_OBJS_MODULEALT);
+ public static final ImageDescriptor DESC_OBJS_CLASS= createManagedFromKey(T_OBJ, IMG_OBJS_CLASS);
+ public static final ImageDescriptor DESC_OBJS_CLASSALT= createManagedFromKey(T_OBJ, IMG_OBJS_CLASSALT);
+ public static final ImageDescriptor DESC_OBJS_INNER_CLASS= createManagedFromKey(T_OBJ, IMG_OBJS_INNER_CLASS);
+ public static final ImageDescriptor DESC_OBJS_MODULEALT = createManagedFromKey(T_OBJ, IMG_OBJS_MODULEALT);
- public static final ImageDescriptor DESC_OBJS_SCRIPT= createManaged(T_OBJ, IMG_OBJS_SCRIPT);
- public static final ImageDescriptor DESC_OBJS_RUBY_RESOURCE= createManaged(T_OBJ, IMG_OBJS_RUBY_RESOURCE);
+ public static final ImageDescriptor DESC_OBJS_SCRIPT= createManagedFromKey(T_OBJ, IMG_OBJS_SCRIPT);
+ public static final ImageDescriptor DESC_OBJS_RUBY_RESOURCE= createManagedFromKey(T_OBJ, IMG_OBJS_RUBY_RESOURCE);
- public static final ImageDescriptor DESC_MISC_PUBLIC= createManaged(T_OBJ, IMG_MISC_PUBLIC);
- public static final ImageDescriptor DESC_MISC_PROTECTED= createManaged(T_OBJ, IMG_MISC_PROTECTED);
- public static final ImageDescriptor DESC_MISC_PRIVATE= createManaged(T_OBJ, IMG_MISC_PRIVATE);
+ public static final ImageDescriptor DESC_MISC_PUBLIC= createManagedFromKey(T_OBJ, IMG_MISC_PUBLIC);
+ public static final ImageDescriptor DESC_MISC_PROTECTED= createManagedFromKey(T_OBJ, IMG_MISC_PROTECTED);
+ public static final ImageDescriptor DESC_MISC_PRIVATE= createManagedFromKey(T_OBJ, IMG_MISC_PRIVATE);
- public static final ImageDescriptor DESC_OBJS_UNKNOWN= createManaged(T_OBJ, IMG_OBJS_UNKNOWN);
+ public static final ImageDescriptor DESC_OBJS_UNKNOWN= createManagedFromKey(T_OBJ, IMG_OBJS_UNKNOWN);
static {
- createManaged(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
- createManaged(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
- createManaged(T_OBJ, IMG_OBJS_ERROR);
- createManaged(T_OBJ, IMG_OBJS_WARNING);
- createManaged(T_OBJ, IMG_OBJS_INFO);
- createManaged(T_OBJ, IMG_OBJS_TEMPLATE);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_IMPORT_CONTAINER);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_IMPORT);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_PAGE);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_GLOBAL);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_CLASS);
- createManaged(T_CTOOL, IMG_OBJS_MODULE);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_METHOD);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBYMETHOD_PRO);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBYMETHOD_PUB);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_SINGLETONMETHOD );
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_SINGLETONMETHOD_PUB );
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_SINGLETONMETHOD_PRO );
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_CLASS_VAR);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_CONSTANT);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_LOCAL_VAR);
- createManaged(T_CTOOL, IMG_CTOOLS_RUBY_INSTANCE_VAR);
+ createManagedFromKey(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
+ createManagedFromKey(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
+ createManagedFromKey(T_OBJ, IMG_OBJS_ERROR);
+ createManagedFromKey(T_OBJ, IMG_OBJS_WARNING);
+ createManagedFromKey(T_OBJ, IMG_OBJS_INFO);
+ createManagedFromKey(T_OBJ, IMG_OBJS_TEMPLATE);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_IMPORT_CONTAINER);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_IMPORT);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_PAGE);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_GLOBAL);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_CLASS);
+ createManagedFromKey(T_CTOOL, IMG_OBJS_MODULE);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_METHOD);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBYMETHOD_PRO);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBYMETHOD_PUB);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_SINGLETONMETHOD );
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_SINGLETONMETHOD_PUB );
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_SINGLETONMETHOD_PRO );
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_CLASS_VAR);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_CONSTANT);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_LOCAL_VAR);
+ createManagedFromKey(T_CTOOL, IMG_CTOOLS_RUBY_INSTANCE_VAR);
}
@@ -168,9 +168,9 @@
*
* @param key the image's key
* @return the image managed under the given key
- */
+ */
public static Image get(String key) {
- return IMAGE_REGISTRY.get(key);
+ return getImageRegistry().get(key);
}
/**
@@ -188,55 +188,77 @@
public static void setLocalImageDescriptors(IAction action, String iconName) {
setImageDescriptors(action, "lcl16", iconName);
}
-
- public static ImageRegistry getImageRegistry() {
- return IMAGE_REGISTRY;
+
+ /*
+ * Helper method to access the image registry from the JavaPlugin class.
+ */
+ /* package */ static ImageRegistry getImageRegistry() {
+ if (fgImageRegistry == null) {
+ fgImageRegistry= new ImageRegistry();
+ for (Iterator iter= fgAvoidSWTErrorMap.keySet().iterator(); iter.hasNext();) {
+ String key= (String) iter.next();
+ fgImageRegistry.put(key, (ImageDescriptor) fgAvoidSWTErrorMap.get(key));
+ }
+ fgAvoidSWTErrorMap= null;
+ }
+ return fgImageRegistry;
}
+
+ private static ImageDescriptor createManagedFromKey(String prefix, String key) {
+ return createManaged(prefix, key.substring(NAME_PREFIX_LENGTH), key);
+ }
//---- Helper methods to access icons on the file system --------------------------------------
- protected static void setImageDescriptors(IAction action, String type, String relPath) {
-
- try {
- ImageDescriptor id = ImageDescriptor.createFromURL(makeIconFileURL("d" + type, relPath));
- if (id != null)
- action.setDisabledImageDescriptor(id);
- } catch (MalformedURLException e) {}
-
- // we don't use hover images. If we set it nonetheless it would be preferred to the "normal" image descriptor
- // see ActionContributionItem.updateImages
- // ImageDescriptor.createFromURL(makeIconFileURL("c" + type, relPath));
-
- action.setImageDescriptor(createUnManaged("e" + type, relPath));
+ private static void setImageDescriptors(IAction action, String type, String relPath) {
+ ImageDescriptor id= create("d" + type, relPath, false); //$NON-NLS-1$
+ if (id != null)
+ action.setDisabledImageDescriptor(id);
+
+ /*
+ * id= create("c" + type, relPath, false); //$NON-NLS-1$
+ * if (id != null)
+ * action.setHoverImageDescriptor(id);
+ */
+
+ ImageDescriptor descriptor= create("e" + type, relPath, true); //$NON-NLS-1$
+ action.setHoverImageDescriptor(descriptor);
+ action.setImageDescriptor(descriptor);
}
-
- protected static ImageDescriptor createManaged(String prefix, String name) {
- try {
- ImageDescriptor result = ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
- IMAGE_REGISTRY.put(name, result);
- return result;
- } catch (MalformedURLException e) {
- return ImageDescriptor.getMissingImageDescriptor();
+
+ private static ImageDescriptor createManaged(String prefix, String name, String key) {
+ ImageDescriptor result= create(prefix, name, true);
+
+ if (fgAvoidSWTErrorMap == null) {
+ fgAvoidSWTErrorMap= new HashMap();
}
- }
-
- protected static ImageDescriptor createUnManaged(String prefix, String name) {
- try {
- return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
- } catch (MalformedURLException e) {
- return ImageDescriptor.getMissingImageDescriptor();
+ fgAvoidSWTErrorMap.put(key, result);
+ if (fgImageRegistry != null) {
+ RubyPlugin.logErrorMessage("Image registry already defined"); //$NON-NLS-1$
}
+ return result;
}
-
- protected static URL makeIconFileURL(String prefix, String name) throws MalformedURLException {
- if (iconBaseURL == null)
- throw new MalformedURLException();
-
- StringBuffer buffer = new StringBuffer(prefix);
- buffer.append('/');
- buffer.append(name);
- return new URL(iconBaseURL, buffer.toString());
+
+ /*
+ * Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can
+ * contain variables like $NL$.
+ * If no image could be found, <code>useMissingImageDescriptor</code> decides if either
+ * the 'missing image descriptor' is returned or <code>null</code>.
+ * or <code>null</code>.
+ */
+ private static ImageDescriptor create(String prefix, String name, boolean useMissingImageDescriptor) {
+ IPath path= ICONS_PATH.append(prefix).append(name);
+ return createImageDescriptor(RubyPlugin.getDefault().getBundle(), path, useMissingImageDescriptor);
}
+
+ /*
+ * Creates an image descriptor for the given prefix and name in the JDT UI bundle. The path can
+ * contain variables like $NL$.
+ * If no image could be found, the 'missing image descriptor' is returned.
+ */
+ private static ImageDescriptor createUnManaged(String prefix, String name) {
+ return create(prefix, name, true);
+ }
/*
* Creates an image descriptor for the given path in a bundle. The path can contain variables
@@ -255,4 +277,17 @@
}
return null;
}
+
+ /**
+ * Returns the image descriptor for the given key in this registry. Might be called in a non-UI thread.
+ *
+ * @param key the image's key
+ * @return the image descriptor for the given key
+ */
+ public static ImageDescriptor getDescriptor(String key) {
+ if (fgImageRegistry == null) {
+ return (ImageDescriptor) fgAvoidSWTErrorMap.get(key);
+ }
+ return getImageRegistry().getDescriptor(key);
+ }
}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/SharedImages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/SharedImages.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/SharedImages.java 2007-01-21 18:35:37 UTC (rev 1834)
@@ -0,0 +1,23 @@
+package org.rubypeople.rdt.internal.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.rubypeople.rdt.ui.ISharedImages;
+
+public class SharedImages implements ISharedImages {
+ public SharedImages() {}
+
+ /*
+ * (Non-Javadoc) Method declared in ISharedImages
+ */
+ public Image getImage(String key) {
+ return RubyPluginImages.get(key);
+ }
+
+ /*
+ * (Non-Javadoc) Method declared in ISharedImages
+ */
+ public ImageDescriptor getImageDescriptor(String key) {
+ return RubyPluginImages.getDescriptor(key);
+ }
+}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/ISharedImages.java
===================================================================
---...
[truncated message content] |