|
From: <caw...@us...> - 2007-07-18 21:09:05
|
Revision: 2784
http://svn.sourceforge.net/rubyeclipse/?rev=2784&view=rev
Author: cawilliams
Date: 2007-07-18 14:09:04 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
yup! more type hierarchy classes
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsLabelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ShowInheritedMembersAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SortByDefiningTypeAction.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsLabelProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsLabelProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsLabelProvider.java 2007-07-18 21:09:04 UTC (rev 2784)
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * 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.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+import org.rubypeople.rdt.core.IMember;
+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.core.RubyModelException;
+import org.rubypeople.rdt.internal.corext.util.MethodOverrideTester;
+import org.rubypeople.rdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
+import org.rubypeople.rdt.ui.RubyElementLabels;
+
+/**
+ * Label provider for the hierarchy method viewers.
+ */
+public class MethodsLabelProvider extends AppearanceAwareLabelProvider {
+
+ private Color fResolvedBackground;
+
+ private boolean fShowDefiningType;
+ private TypeHierarchyLifeCycle fHierarchy;
+ private MethodsViewer fMethodsViewer;
+
+ public MethodsLabelProvider(TypeHierarchyLifeCycle lifeCycle, MethodsViewer methodsViewer) {
+ super(DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS);
+ fHierarchy= lifeCycle;
+ fShowDefiningType= false;
+ fMethodsViewer= methodsViewer;
+ fResolvedBackground= null;
+ }
+
+ public void setShowDefiningType(boolean showDefiningType) {
+ fShowDefiningType= showDefiningType;
+ }
+
+ public boolean isShowDefiningType() {
+ return fShowDefiningType;
+ }
+
+
+ private IType getDefiningType(Object element) throws RubyModelException {
+ int kind= ((IRubyElement) element).getElementType();
+
+ if (kind != IRubyElement.METHOD && kind != IRubyElement.FIELD && kind != IRubyElement.CONSTANT
+ && kind != IRubyElement.INSTANCE_VAR && kind != IRubyElement.CLASS_VAR) {
+ return null;
+ }
+ IType declaringType= ((IMember) element).getDeclaringType();
+ if (kind != IRubyElement.METHOD) {
+ return declaringType;
+ }
+ ITypeHierarchy hierarchy= fHierarchy.getHierarchy();
+ if (hierarchy == null) {
+ return declaringType;
+ }
+ IMethod method= (IMethod) element;
+ MethodOverrideTester tester= new MethodOverrideTester(declaringType, hierarchy);
+ IMethod res= tester.findDeclaringMethod(method, true);
+ if (res == null || method.equals(res)) {
+ return declaringType;
+ }
+ return res.getDeclaringType();
+ }
+
+ /* (non-Rubydoc)
+ * @see ILabelProvider#getText
+ */
+ public String getText(Object element) {
+ String text= super.getText(element);
+ if (fShowDefiningType) {
+ try {
+ IType type= getDefiningType(element);
+ if (type != null) {
+ StringBuffer buf= new StringBuffer(super.getText(type));
+ buf.append(RubyElementLabels.CONCAT_STRING);
+ buf.append(text);
+ return buf.toString();
+ }
+ } catch (RubyModelException e) {
+ }
+ }
+ return text;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+ */
+ public Color getForeground(Object element) {
+ if (fMethodsViewer.isShowInheritedMethods() && element instanceof IMethod) {
+ IMethod curr= (IMethod) element;
+ IMember declaringType= curr.getDeclaringType();
+
+ if (declaringType.equals(fMethodsViewer.getInput())) {
+ if (fResolvedBackground == null) {
+ Display display= Display.getCurrent();
+ fResolvedBackground= display.getSystemColor(SWT.COLOR_DARK_BLUE);
+ }
+ return fResolvedBackground;
+ }
+ }
+ return null;
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ShowInheritedMembersAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ShowInheritedMembersAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ShowInheritedMembersAction.java 2007-07-18 21:09:04 UTC (rev 2784)
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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 to show / hide inherited members in the method view
+ * Depending in the action state a different label provider is installed in the viewer
+ */
+public class ShowInheritedMembersAction extends Action {
+
+ private MethodsViewer fMethodsViewer;
+
+ /**
+ * Creates the action.
+ */
+ public ShowInheritedMembersAction(MethodsViewer viewer, boolean initValue) {
+ super(TypeHierarchyMessages.ShowInheritedMembersAction_label);
+ setDescription(TypeHierarchyMessages.ShowInheritedMembersAction_description);
+ setToolTipText(TypeHierarchyMessages.ShowInheritedMembersAction_tooltip);
+
+ RubyPluginImages.setLocalImageDescriptors(this, "inher_co.gif"); //$NON-NLS-1$
+
+ fMethodsViewer= viewer;
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.SHOW_INHERITED_ACTION);
+
+ setChecked(initValue);
+ }
+
+ /*
+ * @see Action#actionPerformed
+ */
+ public void run() {
+ BusyIndicator.showWhile(fMethodsViewer.getControl().getDisplay(), new Runnable() {
+ public void run() {
+ fMethodsViewer.showInheritedMethods(isChecked());
+ }
+ });
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ShowInheritedMembersAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SortByDefiningTypeAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SortByDefiningTypeAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SortByDefiningTypeAction.java 2007-07-18 21:09:04 UTC (rev 2784)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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 to let the label provider show the defining type of the method
+ */
+public class SortByDefiningTypeAction extends Action {
+
+ private MethodsViewer fMethodsViewer;
+
+ /**
+ * Creates the action.
+ */
+ public SortByDefiningTypeAction(MethodsViewer viewer, boolean initValue) {
+ super(TypeHierarchyMessages.SortByDefiningTypeAction_label);
+ setDescription(TypeHierarchyMessages.SortByDefiningTypeAction_description);
+ setToolTipText(TypeHierarchyMessages.SortByDefiningTypeAction_tooltip);
+
+ RubyPluginImages.setLocalImageDescriptors(this, "definingtype_sort_co.gif"); //$NON-NLS-1$
+
+ fMethodsViewer= viewer;
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.SORT_BY_DEFINING_TYPE_ACTION);
+
+ setChecked(initValue);
+ }
+
+ /*
+ * @see Action#actionPerformed
+ */
+ public void run() {
+ BusyIndicator.showWhile(fMethodsViewer.getControl().getDisplay(), new Runnable() {
+ public void run() {
+ fMethodsViewer.sortByDefiningType(isChecked());
+ }
+ });
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SortByDefiningTypeAction.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.
|