|
From: <caw...@us...> - 2007-07-18 21:20:04
|
Revision: 2787
http://svn.sourceforge.net/rubyeclipse/?rev=2787&view=rev
Author: cawilliams
Date: 2007-07-18 14:20:01 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
more type hierarchy stuff
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/ovr16/focus_ovr.gif
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HierarchyLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ShowQualifiedTypeNamesAction.java
Added: trunk/org.rubypeople.rdt.ui/icons/full/ovr16/focus_ovr.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/ovr16/focus_ovr.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-07-18 21:13:43 UTC (rev 2786)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-07-18 21:20:01 UTC (rev 2787)
@@ -11,6 +11,7 @@
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
import org.osgi.framework.Bundle;
public class RubyPluginImages {
@@ -128,7 +129,8 @@
public static final ImageDescriptor DESC_OVR_SYNCH_AND_IMPLEMENTS= createUnManaged(T_OVR, "sync_impl.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_CONSTRUCTOR= createUnManaged(T_OVR, "constr_ovr.gif"); //$NON-NLS-1$
public static final ImageDescriptor DESC_OVR_DEPRECATED= createUnManaged(T_OVR, "deprecated.gif");
-
+ public static final ImageDescriptor DESC_OVR_FOCUS= createUnManagedCached(T_OVR, "focus_ovr.gif"); //$NON-NLS-1$
+
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);
@@ -302,6 +304,14 @@
}
/*
+ * Creates an image descriptor for the given prefix and name in the JDT UI bundle and let tye descriptor cache the image data.
+ * If no image could be found, the 'missing image descriptor' is returned.
+ */
+ private static ImageDescriptor createUnManagedCached(String prefix, String name) {
+ return new CachedImageDescriptor(create(prefix, name, true));
+ }
+
+ /*
* 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
@@ -352,4 +362,20 @@
}
return getImageRegistry().getDescriptor(key);
}
+
+ private static final class CachedImageDescriptor extends ImageDescriptor {
+ private ImageDescriptor fDescriptor;
+ private ImageData fData;
+
+ public CachedImageDescriptor(ImageDescriptor descriptor) {
+ fDescriptor = descriptor;
+ }
+
+ public ImageData getImageData() {
+ if (fData == null) {
+ fData= fDescriptor.getImageData();
+ }
+ return fData;
+ }
+ }
}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HierarchyLabelProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HierarchyLabelProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HierarchyLabelProvider.java 2007-07-18 21:20:01 UTC (rev 2787)
@@ -0,0 +1,191 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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.ui.typehierarchy;
+
+import org.eclipse.jface.resource.CompositeImageDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Display;
+import org.rubypeople.rdt.core.Flags;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.ITypeHierarchy;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+import org.rubypeople.rdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.rubypeople.rdt.internal.ui.viewsupport.RubyElementImageProvider;
+import org.rubypeople.rdt.ui.RubyElementImageDescriptor;
+import org.rubypeople.rdt.ui.RubyElementLabels;
+
+/**
+ * Label provider for the hierarchy viewers. Types in the hierarchy that are not belonging to the
+ * input scope are rendered differntly.
+ */
+public class HierarchyLabelProvider extends AppearanceAwareLabelProvider {
+
+ private static class FocusDescriptor extends CompositeImageDescriptor {
+ private ImageDescriptor fBase;
+ public FocusDescriptor(ImageDescriptor base) {
+ fBase= base;
+ }
+ protected void drawCompositeImage(int width, int height) {
+ drawImage(getImageData(fBase), 0, 0);
+ drawImage(getImageData(RubyPluginImages.DESC_OVR_FOCUS), 0, 0);
+ }
+
+ private ImageData getImageData(ImageDescriptor descriptor) {
+ ImageData data= descriptor.getImageData(); // see bug 51965: getImageData can return null
+ if (data == null) {
+ data= DEFAULT_IMAGE_DATA;
+ RubyPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$
+ }
+ return data;
+ }
+
+ protected Point getSize() {
+ return RubyElementImageProvider.BIG_SIZE;
+ }
+ public int hashCode() {
+ return fBase.hashCode();
+ }
+ public boolean equals(Object object) {
+ return object != null && FocusDescriptor.class.equals(object.getClass()) && ((FocusDescriptor)object).fBase.equals(fBase);
+ }
+ }
+
+ private Color fGrayedColor;
+ private Color fSpecialColor;
+
+ private ViewerFilter fFilter;
+
+ private TypeHierarchyLifeCycle fHierarchy;
+
+ public HierarchyLabelProvider(TypeHierarchyLifeCycle lifeCycle) {
+ super(DEFAULT_TEXTFLAGS | RubyElementLabels.USE_RESOLVED, DEFAULT_IMAGEFLAGS);
+
+ fHierarchy= lifeCycle;
+ fFilter= null;
+ }
+
+ /**
+ * @return Returns the filter.
+ */
+ public ViewerFilter getFilter() {
+ return fFilter;
+ }
+
+ /**
+ * @param filter The filter to set.
+ */
+ public void setFilter(ViewerFilter filter) {
+ fFilter= filter;
+ }
+
+ protected boolean isDifferentScope(IType type) {
+ if (fFilter != null && !fFilter.select(null, null, type)) {
+ return true;
+ }
+
+ IRubyElement input= fHierarchy.getInputElement();
+ if (input == null || input.getElementType() == IRubyElement.TYPE) {
+ return false;
+ }
+
+ IRubyElement parent= type.getAncestor(input.getElementType());
+ if (input.getElementType() == IRubyElement.SOURCE_FOLDER) {
+ if (parent == null || parent.getElementName().equals(input.getElementName())) {
+ return false;
+ }
+ } else if (input.equals(parent)) {
+ return false;
+ }
+ return true;
+ }
+
+ /* (non-Rubydoc)
+ * @see ILabelProvider#getText
+ */
+ public String getText(Object element) {
+ String text= super.getText(element);
+ return decorateText(text, element);
+ }
+
+
+ /* (non-Rubydoc)
+ * @see ILabelProvider#getImage
+ */
+ public Image getImage(Object element) {
+ Image result= null;
+ if (element instanceof IType) {
+ ImageDescriptor desc= getTypeImageDescriptor((IType) element);
+ if (desc != null) {
+ if (element.equals(fHierarchy.getInputElement())) {
+ desc= new FocusDescriptor(desc);
+ }
+ result= RubyPlugin.getImageDescriptorRegistry().get(desc);
+ }
+ } else {
+ result= fImageLabelProvider.getImageLabel(element, evaluateImageFlags(element));
+ }
+ return decorateImage(result, element);
+ }
+
+ private ImageDescriptor getTypeImageDescriptor(IType type) {
+ ITypeHierarchy hierarchy= fHierarchy.getHierarchy();
+ if (hierarchy == null) {
+ return new RubyElementImageDescriptor(RubyPluginImages.DESC_OBJS_CLASS, 0, RubyElementImageProvider.BIG_SIZE);
+ }
+
+ int flags= hierarchy.getCachedFlags(type);
+ if (flags == -1) {
+ return new RubyElementImageDescriptor(RubyPluginImages.DESC_OBJS_CLASS, 0, RubyElementImageProvider.BIG_SIZE);
+ }
+
+ boolean isModule= Flags.isModule(flags);
+ boolean isInner= (type.getDeclaringType() != null);
+
+ ImageDescriptor desc= RubyElementImageProvider.getTypeImageDescriptor(isModule, isInner, isDifferentScope(type));
+
+ int adornmentFlags= 0;
+ if (Flags.isStatic(flags)) {
+ adornmentFlags |= RubyElementImageDescriptor.STATIC;
+ }
+
+ return new RubyElementImageDescriptor(desc, adornmentFlags, RubyElementImageProvider.BIG_SIZE);
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+ */
+ public Color getForeground(Object element) {
+ if (element instanceof IMethod) {
+ if (fSpecialColor == null) {
+ fSpecialColor= Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
+ }
+ return fSpecialColor;
+ } else if (element instanceof IType && isDifferentScope((IType) element)) {
+ if (fGrayedColor == null) {
+ fGrayedColor= Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY);
+ }
+ return fGrayedColor;
+ }
+ return null;
+ }
+
+
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HierarchyLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ShowQualifiedTypeNamesAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ShowQualifiedTypeNamesAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ShowQualifiedTypeNamesAction.java 2007-07-18 21:20:01 UTC (rev 2787)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 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.ui.typehierarchy;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+
+/**
+ * Action enable / disable showing qualified type names
+ */
+public class ShowQualifiedTypeNamesAction extends Action {
+
+ private TypeHierarchyViewPart fView;
+
+ public ShowQualifiedTypeNamesAction(TypeHierarchyViewPart v, boolean initValue) {
+ super(TypeHierarchyMessages.ShowQualifiedTypeNamesAction_label);
+ setDescription(TypeHierarchyMessages.ShowQualifiedTypeNamesAction_description);
+ setToolTipText(TypeHierarchyMessages.ShowQualifiedTypeNamesAction_tooltip);
+
+ RubyPluginImages.setLocalImageDescriptors(this, "th_showqualified.gif"); //$NON-NLS-1$
+
+ fView= v;
+ setChecked(initValue);
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.SHOW_QUALIFIED_NAMES_ACTION);
+ }
+
+ /*
+ * @see Action#actionPerformed
+ */
+ public void run() {
+ BusyIndicator.showWhile(fView.getSite().getShell().getDisplay(), new Runnable() {
+ public void run() {
+ fView.showQualifiedTypeNames(isChecked());
+ }
+ });
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ShowQualifiedTypeNamesAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|