You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(41) |
Apr
(9) |
May
|
Jun
|
Jul
(39) |
Aug
(38) |
Sep
(135) |
Oct
(220) |
Nov
(75) |
Dec
(74) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(44) |
Feb
(160) |
Mar
(49) |
Apr
(69) |
May
(40) |
Jun
(52) |
Jul
(47) |
Aug
(51) |
Sep
(19) |
Oct
(22) |
Nov
(36) |
Dec
(76) |
| 2007 |
Jan
(154) |
Feb
(165) |
Mar
(186) |
Apr
(143) |
May
(175) |
Jun
(133) |
Jul
(203) |
Aug
(177) |
Sep
(136) |
Oct
|
Nov
|
Dec
|
|
From: <caw...@us...> - 2007-07-19 15:40:48
|
Revision: 2797
http://svn.sourceforge.net/rubyeclipse/?rev=2797&view=rev
Author: cawilliams
Date: 2007-07-19 08:40:45 -0700 (Thu, 19 Jul 2007)
Log Message:
-----------
icons for type hierarchy view
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/eview16/class_hi.gif
Added: trunk/org.rubypeople.rdt.ui/icons/full/eview16/class_hi.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/eview16/class_hi.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-19 15:40:31
|
Revision: 2796
http://svn.sourceforge.net/rubyeclipse/?rev=2796&view=rev
Author: cawilliams
Date: 2007-07-19 08:40:29 -0700 (Thu, 19 Jul 2007)
Log Message:
-----------
icons for type hierarchy view
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/definingtype_sort_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/hierarchy_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/history_list.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/impl_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/inher_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/sub_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/super_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_automatic.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_horizontal.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_showqualified.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_single.gif
trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_vertical.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/definingtype_sort_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/hierarchy_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/history_list.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/impl_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/inher_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/sub_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/super_co.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_automatic.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_horizontal.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_showqualified.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_single.gif
trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_vertical.gif
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/definingtype_sort_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/definingtype_sort_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/hierarchy_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/hierarchy_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/history_list.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/history_list.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/impl_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/impl_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/inher_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/inher_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/sub_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/sub_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/super_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/super_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_automatic.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_automatic.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_horizontal.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_horizontal.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_showqualified.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_showqualified.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_single.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_single.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_vertical.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/dlcl16/th_vertical.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/definingtype_sort_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/definingtype_sort_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/hierarchy_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/hierarchy_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/history_list.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/history_list.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/impl_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/impl_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/inher_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/inher_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/sub_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/sub_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/super_co.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/super_co.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_automatic.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_automatic.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_horizontal.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_horizontal.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_showqualified.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_showqualified.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_single.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_single.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_vertical.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/elcl16/th_vertical.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-19 15:39:35
|
Revision: 2795
http://svn.sourceforge.net/rubyeclipse/?rev=2795&view=rev
Author: cawilliams
Date: 2007-07-19 08:39:34 -0700 (Thu, 19 Jul 2007)
Log Message:
-----------
set parent to parent of first type in array of types
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LogicalType.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LogicalType.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LogicalType.java 2007-07-18 21:48:08 UTC (rev 2794)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LogicalType.java 2007-07-19 15:39:34 UTC (rev 2795)
@@ -12,7 +12,7 @@
private IType[] types;
public LogicalType(IType[] types) {
- super(null, types[0].getElementName());
+ super((RubyElement)types[0].getParent(), types[0].getElementName());
this.types = types;
}
@@ -35,5 +35,5 @@
}
return false;
}
-
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-18 21:48:12
|
Revision: 2794
http://svn.sourceforge.net/rubyeclipse/?rev=2794&view=rev
Author: cawilliams
Date: 2007-07-18 14:48:08 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java 2007-07-18 21:46:50 UTC (rev 2793)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java 2007-07-18 21:48:08 UTC (rev 2794)
@@ -1,6 +1,8 @@
package org.rubypeople.rdt.ui;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+
public interface IContextMenuConstants {
/**
* Type hierarchy view part: pop-up menu target ID for type hierarchy viewer
@@ -25,4 +27,28 @@
* @since 2.0
*/
public static final String TARGET_ID_SUBTYPES_VIEW= RubyUI.ID_TYPE_HIERARCHY + ".subtypes"; //$NON-NLS-1$
+
+ /**
+ * Pop-up menu: name of group for show actions (value <code>"group.show"</code>).
+ * <p>
+ * Examples for show actions are:
+ * <ul>
+ * <li>Show in Navigator</li>
+ * <li>Show in Type Hierarchy</li>
+ * </ul>
+ * </p>
+ */
+ public static final String GROUP_SHOW= ICommonMenuConstants.GROUP_SHOW;
+
+ /**
+ * Pop-up menu: name of group for new actions (value <code>"group.new"</code>).
+ * <p>
+ * Examples for new actions are:
+ * <ul>
+ * <li>Create new class</li>
+ * <li>Create new interface</li>
+ * </ul>
+ * </p>
+ */
+ public static final String GROUP_NEW= ICommonMenuConstants.GROUP_NEW;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-18 21:46:51
|
Revision: 2793
http://svn.sourceforge.net/rubyeclipse/?rev=2793&view=rev
Author: cawilliams
Date: 2007-07-18 14:46:50 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/NewWizardsActionGroup.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java 2007-07-18 21:45:09 UTC (rev 2792)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java 2007-07-18 21:46:50 UTC (rev 2793)
@@ -62,6 +62,7 @@
public static String SelectAllAction_label;
public static String SelectAllAction_tooltip;
+ public static String NewWizardsActionGroup_new;
static {
NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/NewWizardsActionGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/NewWizardsActionGroup.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/NewWizardsActionGroup.java 2007-07-18 21:46:50 UTC (rev 2793)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.actions;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchSite;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.NewWizardMenu;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.ui.IContextMenuConstants;
+
+
+/**
+ * Action group that adds the 'new' menu to a context menu.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.
+ * </p>
+ *
+ * @since 2.1
+ */
+public class NewWizardsActionGroup extends ActionGroup {
+
+ private IWorkbenchSite fSite;
+
+ /**
+ * Creates a new <code>NewWizardsActionGroup</code>. The group requires
+ * that the selection provided by the part's selection provider is of type <code>
+ * org.eclipse.jface.viewers.IStructuredSelection</code>.
+ *
+ * @param site the view part that owns this action group
+ */
+ public NewWizardsActionGroup(IWorkbenchSite site) {
+ fSite= site;
+ }
+
+
+ /* (non-Rubydoc)
+ * Method declared in ActionGroup
+ */
+ public void fillContextMenu(IMenuManager menu) {
+ super.fillContextMenu(menu);
+
+ ISelection selection= getContext().getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection sel= (IStructuredSelection) selection;
+ if (sel.size() <= 1 && isNewTarget(sel.getFirstElement())) {
+ MenuManager newMenu = new MenuManager(ActionMessages.NewWizardsActionGroup_new);
+ menu.appendToGroup(IContextMenuConstants.GROUP_NEW, newMenu);
+ newMenu.add(new NewWizardMenu(fSite.getWorkbenchWindow()));
+ }
+ }
+
+ }
+
+ private boolean isNewTarget(Object element) {
+ if (element == null)
+ return true;
+ if (element instanceof IResource) {
+ return true;
+ }
+ if (element instanceof IRubyElement) {
+ int type= ((IRubyElement)element).getElementType();
+ return type == IRubyElement.RUBY_PROJECT ||
+ type == IRubyElement.SOURCE_FOLDER_ROOT ||
+ type == IRubyElement.SOURCE_FOLDER ||
+ type == IRubyElement.SCRIPT ||
+ type == IRubyElement.TYPE;
+ }
+ return false;
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/NewWizardsActionGroup.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.
|
|
From: <caw...@us...> - 2007-07-18 21:45:10
|
Revision: 2792
http://svn.sourceforge.net/rubyeclipse/?rev=2792&view=rev
Author: cawilliams
Date: 2007-07-18 14:45:09 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectAllAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleLinkingAction.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java 2007-07-18 21:39:52 UTC (rev 2791)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java 2007-07-18 21:45:09 UTC (rev 2792)
@@ -59,6 +59,9 @@
public static String OpenNewRubyProjectWizardAction_text;
public static String OpenNewRubyProjectWizardAction_description;
public static String OpenNewRubyProjectWizardAction_tooltip;
+
+ public static String SelectAllAction_label;
+ public static String SelectAllAction_tooltip;
static {
NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectAllAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectAllAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectAllAction.java 2007-07-18 21:45:09 UTC (rev 2792)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+
+/**
+ * This action selects all entries currently showing in view.
+ */
+public class SelectAllAction extends Action {
+
+ private TableViewer fViewer;
+
+ /**
+ * Creates the action.
+ */
+ public SelectAllAction(TableViewer viewer) {
+ super("selectAll"); //$NON-NLS-1$
+ setText(ActionMessages.SelectAllAction_label);
+ setToolTipText(ActionMessages.SelectAllAction_tooltip);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.SELECT_ALL_ACTION);
+ Assert.isNotNull(viewer);
+ fViewer= viewer;
+ }
+
+ /**
+ * Selects all resources in the view.
+ */
+ public void run() {
+ fViewer.getTable().selectAll();
+ // force viewer selection change
+ fViewer.setSelection(fViewer.getSelection());
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectAllAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleLinkingAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleLinkingAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleLinkingAction.java 2007-07-18 21:45:09 UTC (rev 2792)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.rubypeople.rdt.internal.ui.actions.AbstractToggleLinkingAction;
+
+
+/**
+ * This action toggles whether the type hierarchy links its selection to the active
+ * editor.
+ *
+ * @since 2.1
+ */
+public class ToggleLinkingAction extends AbstractToggleLinkingAction {
+
+ TypeHierarchyViewPart fHierarchyViewPart;
+
+ /**
+ * Constructs a new action.
+ */
+ public ToggleLinkingAction(TypeHierarchyViewPart part) {
+ setChecked(part.isLinkingEnabled());
+ fHierarchyViewPart= part;
+ }
+
+ /**
+ * Runs the action.
+ */
+ public void run() {
+ fHierarchyViewPart.setLinkingEnabled(isChecked());
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleLinkingAction.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.
|
|
From: <caw...@us...> - 2007-07-18 21:39:54
|
Revision: 2791
http://svn.sourceforge.net/rubyeclipse/?rev=2791&view=rev
Author: cawilliams
Date: 2007-07-18 14:39:52 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/DelegatingDropAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/DelegatingDropAdapter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/DelegatingDropAdapter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/DelegatingDropAdapter.java 2007-07-18 21:39:52 UTC (rev 2791)
@@ -0,0 +1,270 @@
+/*******************************************************************************
+ * 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.ui.dnd;
+
+import org.eclipse.core.runtime.SafeRunner;
+
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.dnd.TransferData;
+
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.jface.util.TransferDropTargetListener;
+
+/**
+ * A delegating drop adapter negotiates between a set of
+ * <code>TransferDropTargetListener</code> s On <code>dragEnter</code> the
+ * adapter determines the listener to be used for any further <code>drag*</code>
+ * callback.
+ */
+public class DelegatingDropAdapter implements DropTargetListener {
+
+ private TransferDropTargetListener[] fListeners;
+ private TransferDropTargetListener fCurrentListener;
+ private int fOriginalDropType;
+
+ /**
+ * Creates a new delegating drop adapter.
+ *
+ * @param listeners an array of potential listeners
+ */
+ public DelegatingDropAdapter(TransferDropTargetListener[] listeners) {
+ Assert.isNotNull(listeners);
+ fListeners= listeners;
+ }
+
+ /**
+ * The cursor has entered the drop target boundaries. The current listener
+ * is updated, and <code>#dragEnter()</code> is forwarded to the current
+ * listener.
+ *
+ * @param event the drop target event
+ * @see DropTargetListener#dragEnter(DropTargetEvent)
+ */
+ public void dragEnter(DropTargetEvent event) {
+ fOriginalDropType= event.detail;
+ updateCurrentListener(event);
+ }
+
+ /**
+ * The cursor has left the drop target boundaries. The event is forwarded to
+ * the current listener.
+ *
+ * @param event the drop target event
+ * @see DropTargetListener#dragLeave(DropTargetEvent)
+ */
+ public void dragLeave(final DropTargetEvent event) {
+ setCurrentListener(null, event);
+ }
+
+ /**
+ * The operation being performed has changed (usually due to the user
+ * changing a drag modifier key while dragging). Updates the current
+ * listener and forwards this event to that listener.
+ *
+ * @param event the drop target event
+ * @see DropTargetListener#dragOperationChanged(DropTargetEvent)
+ */
+ public void dragOperationChanged(final DropTargetEvent event) {
+ fOriginalDropType= event.detail;
+ TransferDropTargetListener oldListener= getCurrentListener();
+ updateCurrentListener(event);
+ final TransferDropTargetListener newListener= getCurrentListener();
+ // only notify the current listener if it hasn't changed based on the
+ // operation change. otherwise the new listener would get a dragEnter
+ // followed by a dragOperationChanged with the exact same event.
+ if (newListener != null && newListener == oldListener) {
+ SafeRunner.run(new SafeRunnable() {
+ public void run() throws Exception {
+ newListener.dragOperationChanged(event);
+ }
+ });
+ }
+ }
+
+ /**
+ * The cursor is moving over the drop target. Updates the current listener
+ * and forwards this event to that listener. If no listener can handle the
+ * drag operation the <code>event.detail</code> field is set to
+ * <code>DND.DROP_NONE</code> to indicate an invalid drop.
+ *
+ * @param event the drop target event
+ * @see DropTargetListener#dragOver(DropTargetEvent)
+ */
+ public void dragOver(final DropTargetEvent event) {
+ TransferDropTargetListener oldListener= getCurrentListener();
+ updateCurrentListener(event);
+ final TransferDropTargetListener newListener= getCurrentListener();
+
+ // only notify the current listener if it hasn't changed based on the
+ // drag over. otherwise the new listener would get a dragEnter
+ // followed by a dragOver with the exact same event.
+ if (newListener != null && newListener == oldListener) {
+ SafeRunner.run(new SafeRunnable() {
+ public void run() throws Exception {
+ newListener.dragOver(event);
+ }
+ });
+ }
+ }
+
+ /**
+ * Forwards this event to the current listener, if there is one. Sets the
+ * current listener to <code>null</code> afterwards.
+ *
+ * @param event the drop target event
+ * @see DropTargetListener#drop(DropTargetEvent)
+ */
+ public void drop(final DropTargetEvent event) {
+ updateCurrentListener(event);
+ if (getCurrentListener() != null) {
+ SafeRunner.run(new SafeRunnable() {
+ public void run() throws Exception {
+ getCurrentListener().drop(event);
+ }
+ });
+ }
+ setCurrentListener(null, event);
+ }
+
+ /**
+ * Forwards this event to the current listener if there is one.
+ *
+ * @param event the drop target event
+ * @see DropTargetListener#dropAccept(DropTargetEvent)
+ */
+ public void dropAccept(final DropTargetEvent event) {
+ if (getCurrentListener() != null) {
+ SafeRunner.run(new SafeRunnable() {
+ public void run() throws Exception {
+ getCurrentListener().dropAccept(event);
+ }
+ });
+ }
+ }
+
+ /**
+ * Returns the listener which currently handles drop events.
+ *
+ * @return the <code>TransferDropTargetListener</code> which currently
+ * handles drop events.
+ */
+ private TransferDropTargetListener getCurrentListener() {
+ return fCurrentListener;
+ }
+
+ /**
+ * Returns the transfer data type supported by the given listener. Returns
+ * <code>null</code> if the listener does not support any of the specified
+ * data types.
+ *
+ * @param dataTypes available data types
+ * @param listener <code>TransferDropTargetListener</code> to use for
+ * testing supported data types.
+ * @return the transfer data type supported by the given listener or
+ * <code>null</code>.
+ */
+ private TransferData getSupportedTransferType(TransferData[] dataTypes, TransferDropTargetListener listener) {
+ for (int i= 0; i < dataTypes.length; i++) {
+ if (listener.getTransfer().isSupportedType(dataTypes[i])) {
+ return dataTypes[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the combined set of <code>Transfer</code> types of all
+ * <code>TransferDropTargetListeners</code>.
+ *
+ * @return the combined set of <code>Transfer</code> types
+ */
+ public Transfer[] getTransfers() {
+ Transfer[] types= new Transfer[fListeners.length];
+ for (int i= 0; i < fListeners.length; i++) {
+ types[i]= fListeners[i].getTransfer();
+ }
+ return types;
+ }
+
+ /**
+ * Sets the current listener to <code>listener</code>. Sends the given
+ * <code>DropTargetEvent</code> if the current listener changes.
+ *
+ * @return <code>true</code> if the new listener is different than the
+ * previous <code>false</code> otherwise
+ */
+ private boolean setCurrentListener(TransferDropTargetListener listener, final DropTargetEvent event) {
+ if (fCurrentListener == listener)
+ return false;
+ if (fCurrentListener != null) {
+ SafeRunner.run(new SafeRunnable() {
+ public void run() throws Exception {
+ fCurrentListener.dragLeave(event);
+ }
+ });
+ }
+ fCurrentListener= listener;
+ if (fCurrentListener != null) {
+ SafeRunner.run(new SafeRunnable() {
+ public void run() throws Exception {
+ fCurrentListener.dragEnter(event);
+ }
+ });
+ }
+ return true;
+ }
+
+ /**
+ * Updates the current listener to one that can handle the drop. There can
+ * be many listeners and each listener may be able to handle many
+ * <code>TransferData</code> types. The first listener found that can
+ * handle a drop of one of the given <code>TransferData</code> types will
+ * be selected. If no listener can handle the drag operation the
+ * <code>event.detail</code> field is set to <code>DND.DROP_NONE</code>
+ * to indicate an invalid drop.
+ *
+ * @param event the drop target event
+ */
+ private void updateCurrentListener(DropTargetEvent event) {
+ int originalDetail= event.detail;
+ // Revert the detail to the "original" drop type that the User
+ // indicated. This is necessary because the previous listener
+ // may have changed the detail to something other than what the
+ // user indicated.
+ event.detail= fOriginalDropType;
+
+ for (int i= 0; i < fListeners.length; i++) {
+ TransferDropTargetListener listener= fListeners[i];
+ TransferData dataType= getSupportedTransferType(event.dataTypes, listener);
+ if (dataType != null) {
+ TransferData originalDataType= event.currentDataType;
+ // set the data type supported by the drop listener
+ event.currentDataType= dataType;
+ if (listener.isEnabled(event)) {
+ // if the listener stays the same, set its previously
+ // determined
+ // event detail
+ if (!setCurrentListener(listener, event))
+ event.detail= originalDetail;
+ return;
+ } else {
+ event.currentDataType= originalDataType;
+ }
+ }
+ }
+ setCurrentListener(null, event);
+ event.detail= DND.DROP_NONE;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/DelegatingDropAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java 2007-07-18 21:39:52 UTC (rev 2791)
@@ -0,0 +1,28 @@
+package org.rubypeople.rdt.ui;
+
+
+public interface IContextMenuConstants {
+ /**
+ * Type hierarchy view part: pop-up menu target ID for type hierarchy viewer
+ * (value <code>"org.rubypeople.rdt.ui.TypeHierarchy.typehierarchy"</code>).
+ *
+ * @since 2.0
+ */
+ public static final String TARGET_ID_HIERARCHY_VIEW= RubyUI.ID_TYPE_HIERARCHY + ".typehierarchy"; //$NON-NLS-1$
+
+ /**
+ * Type hierarchy view part: pop-up menu target ID for supertype hierarchy viewer
+ * (value <code>"org.rubypeople.rdt.ui.TypeHierarchy.supertypes"</code>).
+ *
+ * @since 2.0
+ */
+ public static final String TARGET_ID_SUPERTYPES_VIEW= RubyUI.ID_TYPE_HIERARCHY + ".supertypes"; //$NON-NLS-1$
+
+ /**
+ * Type hierarchy view part: Pop-up menu target ID for the subtype hierarchy viewer
+ * (value <code>"org.rubypeople.rdt.ui.TypeHierarchy.subtypes"</code>).
+ *
+ * @since 2.0
+ */
+ public static final String TARGET_ID_SUBTYPES_VIEW= RubyUI.ID_TYPE_HIERARCHY + ".subtypes"; //$NON-NLS-1$
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java 2007-07-18 21:35:16 UTC (rev 2790)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java 2007-07-18 21:39:52 UTC (rev 2791)
@@ -101,6 +101,22 @@
public static final String ID_PERSPECTIVE= "org.rubypeople.rdt.ui.PerspectiveRuby"; //$NON-NLS-1$
public static final String ID_RUBY_RESOURCE_VIEW = "org.rubypeople.rdt.ui.ViewRubyResources"; //$NON-NLS-1$
+
+ /**
+ * The view part id of the type hierarchy part
+ * (value <code>"org.rubypeople.rdt.ui.TypeHierarchy"</code>).
+ * <p>
+ * When this id is used to access
+ * a view part with <code>IWorkbenchPage.findView</code> or
+ * <code>showView</code>, the returned <code>IViewPart</code>
+ * can be safely cast to an <code>ITypeHierarchyViewPart</code>.
+ * </p>
+ *
+ * @see ITypeHierarchyViewPart
+ * @see org.eclipse.ui.IWorkbenchPage#findView(java.lang.String)
+ * @see org.eclipse.ui.IWorkbenchPage#showView(java.lang.String)
+ */
+ public static final String ID_TYPE_HIERARCHY= "org.rubypeople.rdt.ui.TypeHierarchy"; //$NON-NLS-1$
/**
* Returns the Ruby element wrapped by the given editor input.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-18 21:35:20
|
Revision: 2790
http://svn.sourceforge.net/rubyeclipse/?rev=2790&view=rev
Author: cawilliams
Date: 2007-07-18 14:35:16 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
working set stuff. for the type hierarchy stuff.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMessages.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SelectionTransferDragAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/ClearWorkingSetAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/EditWorkingSetAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/IWorkingSetActionGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/SelectWorkingSetAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetFilter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetFilterActionGroup.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMenuContributionItem.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java 2007-07-18 21:35:16 UTC (rev 2790)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * 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.dnd;
+
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSourceAdapter;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.Transfer;
+
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.TransferDragSourceListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+
+import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
+
+public class BasicSelectionTransferDragAdapter extends DragSourceAdapter implements TransferDragSourceListener {
+
+ private ISelectionProvider fProvider;
+
+ public BasicSelectionTransferDragAdapter(ISelectionProvider provider) {
+ Assert.isNotNull(provider);
+ fProvider= provider;
+ }
+
+ /**
+ * @see TransferDragSourceListener#getTransfer
+ */
+ public Transfer getTransfer() {
+ return LocalSelectionTransfer.getInstance();
+ }
+
+ /* non Java-doc
+ * @see org.eclipse.swt.dnd.DragSourceListener#dragStart
+ */
+ public void dragStart(DragSourceEvent event) {
+ ISelection selection= fProvider.getSelection();
+ LocalSelectionTransfer.getInstance().setSelection(selection);
+ LocalSelectionTransfer.getInstance().setSelectionSetTime(event.time & 0xFFFFFFFFL);
+ event.doit= isDragable(selection);
+ }
+
+ /**
+ * Checks if the elements contained in the given selection can
+ * be dragged.
+ * <p>
+ * Subclasses may override.
+ *
+ * @param selection containing the elements to be dragged
+ */
+ protected boolean isDragable(ISelection selection) {
+ return true;
+ }
+
+
+ /* non Java-doc
+ * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData
+ */
+ public void dragSetData(DragSourceEvent event) {
+ // For consistency set the data to the selection even though
+ // the selection is provided by the LocalSelectionTransfer
+ // to the drop target adapter.
+ event.data= LocalSelectionTransfer.getInstance().getSelection();
+ }
+
+
+ /* non Java-doc
+ * @see org.eclipse.swt.dnd.DragSourceListener#dragFinished
+ */
+ public void dragFinished(DragSourceEvent event) {
+ // Make sure we don't have to do any remaining work
+ Assert.isTrue(event.detail != DND.DROP_MOVE);
+ LocalSelectionTransfer.getInstance().setSelection(null);
+ LocalSelectionTransfer.getInstance().setSelectionSetTime(0);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/dnd/BasicSelectionTransferDragAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SelectionTransferDragAdapter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SelectionTransferDragAdapter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SelectionTransferDragAdapter.java 2007-07-18 21:35:16 UTC (rev 2790)
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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.packageview;
+
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.rubypeople.rdt.internal.ui.dnd.BasicSelectionTransferDragAdapter;
+
+public class SelectionTransferDragAdapter extends BasicSelectionTransferDragAdapter {
+
+ public SelectionTransferDragAdapter(ISelectionProvider provider) {
+ super(provider);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/packageview/SelectionTransferDragAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/ClearWorkingSetAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/ClearWorkingSetAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/ClearWorkingSetAction.java 2007-07-18 21:35:16 UTC (rev 2790)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.workingsets;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+
+/**
+ * Clears the selected working set in the action group's view.
+ *
+ * @since 2.0
+ */
+public class ClearWorkingSetAction extends Action {
+
+ private WorkingSetFilterActionGroup fActionGroup;
+
+ public ClearWorkingSetAction(WorkingSetFilterActionGroup actionGroup) {
+ super(WorkingSetMessages.ClearWorkingSetAction_text);
+ Assert.isNotNull(actionGroup);
+ setToolTipText(WorkingSetMessages.ClearWorkingSetAction_toolTip);
+ setEnabled(actionGroup.getWorkingSet() != null);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.CLEAR_WORKING_SET_ACTION);
+ fActionGroup= actionGroup;
+ }
+
+ /*
+ * Overrides method from Action
+ */
+ public void run() {
+ fActionGroup.setWorkingSet(null, true);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/ClearWorkingSetAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/EditWorkingSetAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/EditWorkingSetAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/EditWorkingSetAction.java 2007-07-18 21:35:16 UTC (rev 2790)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.workingsets;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IWorkingSetEditWizard;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+/**
+ * Displays an IWorkingSetEditWizard for editing a working set.
+ *
+ * @since 2.1
+ */
+public class EditWorkingSetAction extends Action {
+ private IWorkbenchPartSite fSite;
+ private Shell fShell;
+ private WorkingSetFilterActionGroup fActionGroup;
+
+ public EditWorkingSetAction(WorkingSetFilterActionGroup actionGroup, IWorkbenchPartSite site) {
+ this(actionGroup);
+ fSite= site;
+ }
+
+ public EditWorkingSetAction(WorkingSetFilterActionGroup actionGroup, Shell shell) {
+ this(actionGroup);
+ fShell= shell;
+ }
+
+ private EditWorkingSetAction(WorkingSetFilterActionGroup actionGroup) {
+ super(WorkingSetMessages.EditWorkingSetAction_text);
+ Assert.isNotNull(actionGroup);
+ setToolTipText(WorkingSetMessages.EditWorkingSetAction_toolTip);
+ setEnabled(actionGroup.getWorkingSet() != null);
+ fActionGroup= actionGroup;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.EDIT_WORKING_SET_ACTION);
+ }
+
+ /*
+ * Overrides method from Action
+ */
+ public void run() {
+ Shell shell= getShell();
+ IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager();
+ IWorkingSet workingSet= fActionGroup.getWorkingSet();
+ if (workingSet == null || workingSet.isAggregateWorkingSet()) {
+ setEnabled(false);
+ return;
+ }
+ IWorkingSetEditWizard wizard= manager.createWorkingSetEditWizard(workingSet);
+ if (wizard == null) {
+ String title= WorkingSetMessages.EditWorkingSetAction_error_nowizard_title;
+ String message= WorkingSetMessages.EditWorkingSetAction_error_nowizard_message;
+ MessageDialog.openError(shell, title, message);
+ return;
+ }
+ WizardDialog dialog= new WizardDialog(shell, wizard);
+ dialog.create();
+ if (dialog.open() == Window.OK)
+ fActionGroup.setWorkingSet(wizard.getSelection(), true);
+ }
+
+ private Shell getShell() {
+ if (fSite != null) {
+ return fSite.getShell();
+ } else if (fShell != null) {
+ return fShell;
+ } else {
+ return RubyPlugin.getActiveWorkbenchShell();
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/EditWorkingSetAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/IWorkingSetActionGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/IWorkingSetActionGroup.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/IWorkingSetActionGroup.java 2007-07-18 21:35:16 UTC (rev 2790)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.workingsets;
+
+import org.eclipse.jface.action.IMenuManager;
+
+public interface IWorkingSetActionGroup {
+
+ public static final String ACTION_GROUP= "working_set_action_group"; //$NON-NLS-1$
+
+ public void fillViewMenu(IMenuManager mm);
+
+ public void cleanViewMenu(IMenuManager menuManager);
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/IWorkingSetActionGroup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/SelectWorkingSetAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/SelectWorkingSetAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/SelectWorkingSetAction.java 2007-07-18 21:35:16 UTC (rev 2790)
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * 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.workingsets;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+/**
+ * Displays an IWorkingSetSelectionDialog and sets the selected
+ * working set in the action group's view.
+ *
+ * @since 2.0
+ */
+public class SelectWorkingSetAction extends Action {
+ private IWorkbenchPartSite fSite;
+ private Shell fShell;
+ private WorkingSetFilterActionGroup fActionGroup;
+
+ public SelectWorkingSetAction(WorkingSetFilterActionGroup actionGroup, IWorkbenchPartSite site) {
+ this(actionGroup);
+ fSite= site;
+ }
+
+ public SelectWorkingSetAction(WorkingSetFilterActionGroup actionGroup, Shell shell) {
+ this(actionGroup);
+ fShell= shell;
+ }
+
+ private SelectWorkingSetAction(WorkingSetFilterActionGroup actionGroup) {
+ super(WorkingSetMessages.SelectWorkingSetAction_text);
+ Assert.isNotNull(actionGroup);
+ setToolTipText(WorkingSetMessages.SelectWorkingSetAction_toolTip);
+ fActionGroup= actionGroup;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.SELECT_WORKING_SET_ACTION);
+ }
+
+ /*
+ * Overrides method from Action
+ */
+ public void run() {
+ Shell shell= getShell();
+ IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager();
+ IWorkingSetSelectionDialog dialog= manager.createWorkingSetSelectionDialog(shell, false);
+ IWorkingSet workingSet= fActionGroup.getWorkingSet();
+ if (workingSet != null)
+ dialog.setSelection(new IWorkingSet[]{workingSet});
+
+ if (dialog.open() == Window.OK) {
+ IWorkingSet[] result= dialog.getSelection();
+ if (result != null && result.length > 0) {
+ fActionGroup.setWorkingSet(result[0], true);
+ manager.addRecentWorkingSet(result[0]);
+ }
+ else
+ fActionGroup.setWorkingSet(null, true);
+ }
+ }
+
+ private Shell getShell() {
+ if (fSite != null) {
+ return fSite.getShell();
+ } else if (fShell != null) {
+ return fShell;
+ } else {
+ return RubyPlugin.getActiveWorkbenchShell();
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/SelectWorkingSetAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetFilter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetFilter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetFilter.java 2007-07-18 21:35:16 UTC (rev 2790)
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * 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.ui.workingsets;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.ui.IWorkingSet;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
+import org.rubypeople.rdt.internal.ui.packageview.LoadPathContainer;
+
+/**
+ * Working set filter for Ruby viewers.
+ */
+public class WorkingSetFilter extends ViewerFilter {
+
+ private IWorkingSet fWorkingSet= null;
+ private IAdaptable[] fCachedWorkingSet= null;
+
+ /**
+ * Returns the working set which is used by this filter.
+ *
+ * @return the working set
+ */
+ public IWorkingSet getWorkingSet() {
+ return fWorkingSet;
+ }
+
+ /**
+ * Sets this filter's working set.
+ *
+ * @param workingSet the working set
+ */
+ public void setWorkingSet(IWorkingSet workingSet) {
+ fWorkingSet= workingSet;
+ }
+
+ /*
+ * Overrides method from ViewerFilter.
+ */
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (fWorkingSet == null || (fWorkingSet.isAggregateWorkingSet() && fWorkingSet.getElements().length == 0))
+ return true;
+
+ if (element instanceof IRubyElement)
+ return isEnclosing((IRubyElement)element);
+
+ if (element instanceof IResource)
+ return isEnclosing(((IResource)element).getFullPath());
+
+ if (element instanceof LoadPathContainer) {
+ return isEnclosing((LoadPathContainer)element);
+ }
+
+ if (element instanceof IAdaptable) {
+ IAdaptable adaptable= (IAdaptable)element;
+ IRubyElement je= (IRubyElement)adaptable.getAdapter(IRubyElement.class);
+ if (je != null)
+ return isEnclosing(je);
+
+ IResource resource= (IResource)adaptable.getAdapter(IResource.class);
+ if (resource != null)
+ return isEnclosing(resource.getFullPath());
+ }
+
+ return true;
+ }
+
+ private boolean isEnclosing(LoadPathContainer container) {
+ // check whether the containing packagefragment root is enclosed
+ Object[] roots= container.getSourceFolderRoots();
+ if (roots.length > 0)
+ return isEnclosing((ISourceFolderRoot)roots[0]);
+ return false;
+ }
+
+ /*
+ * Overrides method from ViewerFilter
+ */
+ public Object[] filter(Viewer viewer, Object parent, Object[] elements) {
+ Object[] result= null;
+ if (fWorkingSet != null)
+ fCachedWorkingSet= fWorkingSet.getElements();
+ try {
+ result= super.filter(viewer, parent, elements);
+ } finally {
+ fCachedWorkingSet= null;
+ }
+ return result;
+ }
+
+ private boolean isEnclosing(IPath elementPath) {
+ if (elementPath == null)
+ return false;
+
+ IAdaptable[] cachedWorkingSet= fCachedWorkingSet;
+ if (cachedWorkingSet == null)
+ cachedWorkingSet= fWorkingSet.getElements();
+
+ int length= cachedWorkingSet.length;
+ for (int i= 0; i < length; i++) {
+ if (isEnclosing(cachedWorkingSet[i], elementPath))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isEnclosing(IRubyElement element) {
+ Assert.isNotNull(element);
+
+ IAdaptable[] cachedWorkingSet= fCachedWorkingSet;
+ if (cachedWorkingSet == null)
+ cachedWorkingSet= fWorkingSet.getElements();
+
+ boolean isElementPathComputed= false;
+ IPath elementPath= null; // will be lazy computed if needed
+
+ int length= cachedWorkingSet.length;
+ for (int i= 0; i < length; i++) {
+ IRubyElement scopeElement= (IRubyElement)cachedWorkingSet[i].getAdapter(IRubyElement.class);
+ if (scopeElement != null) {
+ // compare Ruby elements
+ IRubyElement searchedElement= element;
+ while (searchedElement != null) {
+ if (searchedElement.equals(scopeElement))
+ return true;
+ else {
+ if (scopeElement.getElementType() == IRubyElement.RUBY_PROJECT && searchedElement.getElementType() == IRubyElement.SOURCE_FOLDER_ROOT) {
+ ISourceFolderRoot pkgRoot= (ISourceFolderRoot)searchedElement;
+ if (pkgRoot.isExternal() && pkgRoot.isArchive()) {
+ if (((IRubyProject)scopeElement).isOnLoadpath(searchedElement))
+ return true;
+ }
+ }
+ searchedElement= searchedElement.getParent();
+ if (searchedElement != null && searchedElement.getElementType() == IRubyElement.SCRIPT) {
+ IRubyScript unit= (IRubyScript)searchedElement;
+ unit= unit.getPrimary();
+ }
+ }
+ }
+ while (scopeElement != null) {
+ if (element.equals(scopeElement))
+ return true;
+ else
+ scopeElement= scopeElement.getParent();
+ }
+ } else {
+ // compare resource paths
+ if (!isElementPathComputed) {
+ IResource elementResource= (IResource)element.getAdapter(IResource.class);
+ if (elementResource != null)
+ elementPath= elementResource.getFullPath();
+ }
+ if (isEnclosing(cachedWorkingSet[i], elementPath))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isEnclosing(IAdaptable element, IPath path) {
+ if (path == null)
+ return false;
+
+ IPath elementPath= null;
+
+ IResource elementResource= (IResource)element.getAdapter(IResource.class);
+ if (elementResource != null)
+ elementPath= elementResource.getFullPath();
+
+ if (elementPath == null) {
+ IRubyElement javaElement= (IRubyElement)element.getAdapter(IRubyElement.class);
+ if (javaElement != null)
+ elementPath= javaElement.getPath();
+ }
+
+ if (elementPath == null && element instanceof IStorage)
+ elementPath= ((IStorage)element).getFullPath();
+
+ if (elementPath == null)
+ return false;
+
+ if (elementPath.isPrefixOf(path))
+ return true;
+
+ if (path.isPrefixOf(elementPath))
+ return true;
+
+ return false;
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetFilter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetFilterActionGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetFilterActionGroup.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetFilterActionGroup.java 2007-07-18 21:35:16 UTC (rev 2790)
@@ -0,0 +1,346 @@
+/*******************************************************************************
+ * 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.ui.workingsets;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.IWorkbenchPreferenceConstants;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionGroup;
+import org.rubypeople.rdt.internal.ui.search.WorkingSetComparator;
+
+/**
+ * Working set filter actions (set / clear)
+ *
+ * @since 2.0
+ *
+ */
+public class WorkingSetFilterActionGroup extends ActionGroup implements IWorkingSetActionGroup {
+
+ private static final String TAG_WORKING_SET_NAME= "workingSetName"; //$NON-NLS-1$
+ private static final String TAG_IS_WINDOW_WORKING_SET= "isWindowWorkingSet"; //$NON-NLS-1$
+ private static final String LRU_GROUP= "workingSet_lru_group"; //$NON-NLS-1$
+
+ private final WorkingSetFilter fWorkingSetFilter;
+
+ private IWorkingSet fWorkingSet= null;
+
+ private final ClearWorkingSetAction fClearWorkingSetAction;
+ private final SelectWorkingSetAction fSelectWorkingSetAction;
+ private final EditWorkingSetAction fEditWorkingSetAction;
+
+ private IPropertyChangeListener fWorkingSetListener;
+ private IPropertyChangeListener fChangeListener;
+
+ private int fLRUMenuCount;
+ private IMenuManager fMenuManager;
+ private IMenuListener fMenuListener;
+ private List fContributions= new ArrayList();
+ private final IWorkbenchPage fWorkbenchPage;
+ private boolean fAllowWindowWorkingSetByDefault;
+
+ public WorkingSetFilterActionGroup(IWorkbenchPartSite site, IPropertyChangeListener changeListener) {
+ Assert.isNotNull(site);
+ Assert.isNotNull(changeListener);
+
+ fChangeListener= changeListener;
+ fWorkbenchPage= site.getPage();
+ fAllowWindowWorkingSetByDefault= true;
+ fClearWorkingSetAction= new ClearWorkingSetAction(this);
+ fSelectWorkingSetAction= new SelectWorkingSetAction(this, site);
+ fEditWorkingSetAction= new EditWorkingSetAction(this, site);
+
+ fWorkingSetListener= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ doPropertyChange(event);
+ }
+ };
+ fWorkingSetFilter= new WorkingSetFilter();
+
+ IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager();
+ manager.addPropertyChangeListener(fWorkingSetListener);
+
+ if (useWindowWorkingSetByDefault()) {
+ setWorkingSet(site.getPage().getAggregateWorkingSet(), false);
+ }
+ }
+
+ public WorkingSetFilterActionGroup(Shell shell, IWorkbenchPage page, IPropertyChangeListener changeListener) {
+ Assert.isNotNull(shell);
+ Assert.isNotNull(changeListener);
+
+ fWorkbenchPage= page;
+ fAllowWindowWorkingSetByDefault= false;
+ fChangeListener= changeListener;
+ fClearWorkingSetAction= new ClearWorkingSetAction(this);
+ fSelectWorkingSetAction= new SelectWorkingSetAction(this, shell);
+ fEditWorkingSetAction= new EditWorkingSetAction(this, shell);
+
+ fWorkingSetListener= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ doPropertyChange(event);
+ }
+ };
+
+ fWorkingSetFilter= new WorkingSetFilter();
+
+ IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager();
+ manager.addPropertyChangeListener(fWorkingSetListener);
+
+ setWorkingSet(null, false);
+ }
+
+ /**
+ * Returns whether the current working set filters the given element
+ *
+ * @param parent the parent
+ * @param object the element to test
+ * @return the working set
+ */
+ public boolean isFiltered(Object parent, Object object) {
+ if (fWorkingSetFilter == null)
+ return false;
+ return !fWorkingSetFilter.select(null, parent, object);
+ }
+
+
+ /**
+ * Returns the working set which is used by the filter.
+ *
+ * @return the working set
+ */
+ public IWorkingSet getWorkingSet() {
+ return fWorkingSet;
+ }
+
+ /**
+ * Sets this filter's working set.
+ *
+ * @param workingSet the working set
+ * @param refreshViewer Indicates if the viewer should be refreshed.
+ */
+ public void setWorkingSet(IWorkingSet workingSet, boolean refreshViewer) {
+ // Update action
+ fClearWorkingSetAction.setEnabled(workingSet != null);
+ fEditWorkingSetAction.setEnabled(workingSet != null && !workingSet.isAggregateWorkingSet());
+
+ fWorkingSet= workingSet;
+
+ fWorkingSetFilter.setWorkingSet(workingSet);
+ if (refreshViewer) {
+ fChangeListener.propertyChange(new PropertyChangeEvent(this, IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE, null, workingSet));
+ }
+ }
+
+ /**
+ * Saves the state of the filter actions in a memento.
+ *
+ * @param memento the memento
+ */
+ public void saveState(IMemento memento) {
+ String workingSetName= ""; //$NON-NLS-1$
+ boolean isWindowWorkingSet= false;
+ if (fWorkingSet != null) {
+ if (fWorkingSet.isAggregateWorkingSet()) {
+ isWindowWorkingSet= true;
+ } else {
+ workingSetName= fWorkingSet.getName();
+ }
+ }
+ memento.putString(TAG_IS_WINDOW_WORKING_SET, Boolean.toString(isWindowWorkingSet));
+ memento.putString(TAG_WORKING_SET_NAME, workingSetName);
+ }
+
+ /**
+ * Restores the state of the filter actions from a memento.
+ * <p>
+ * Note: This method does not refresh the viewer.
+ * </p>
+ * @param memento
+ */
+ public void restoreState(IMemento memento) {
+ boolean isWindowWorkingSet;
+ if (memento.getString(TAG_IS_WINDOW_WORKING_SET) != null) {
+ isWindowWorkingSet= Boolean.valueOf(memento.getString(TAG_IS_WINDOW_WORKING_SET)).booleanValue();
+ } else {
+ isWindowWorkingSet= useWindowWorkingSetByDefault();
+ }
+ String workingSetName= memento.getString(TAG_WORKING_SET_NAME);
+ boolean hasWorkingSetName= workingSetName != null && workingSetName.length() > 0;
+
+ IWorkingSet ws= null;
+ // First handle name if present.
+ if (hasWorkingSetName) {
+ ws= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName);
+ } else if (isWindowWorkingSet && fWorkbenchPage != null) {
+ ws= fWorkbenchPage.getAggregateWorkingSet();
+ }
+ setWorkingSet(ws, false);
+ }
+
+ private boolean useWindowWorkingSetByDefault() {
+ return fAllowWindowWorkingSetByDefault && PlatformUI.getPreferenceStore().getBoolean(IWorkbenchPreferenceConstants.USE_WINDOW_WORKING_SET_BY_DEFAULT);
+ }
+
+
+ /* (non-Rubydoc)
+ * @see ActionGroup#fillActionBars(IActionBars)
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ fillToolBar(actionBars.getToolBarManager());
+ fillViewMenu(actionBars.getMenuManager());
+ }
+
+ /**
+ * Adds the filter actions to the tool bar
+ *
+ * @param tbm the tool bar manager
+ */
+ private void fillToolBar(IToolBarManager tbm) {
+ // do nothing
+ }
+
+ /**
+ * Adds the filter actions to the menu
+ *
+ * @param mm the menu manager
+ */
+ public void fillViewMenu(IMenuManager mm) {
+ if (mm.find(IWorkingSetActionGroup.ACTION_GROUP) == null) {
+ mm.add(new Separator(IWorkingSetActionGroup.ACTION_GROUP));
+ }
+ add(mm, fSelectWorkingSetAction);
+ add(mm, fClearWorkingSetAction);
+ add(mm, fEditWorkingSetAction);
+ add(mm, new Separator());
+ add(mm, new Separator(LRU_GROUP));
+
+ fMenuManager= mm;
+ fMenuListener= new IMenuListener() {
+ public void menuAboutToShow(IMenuManager manager) {
+ removePreviousLRUWorkingSetActions(manager);
+ addLRUWorkingSetActions(manager);
+ }
+ };
+ fMenuManager.addMenuListener(fMenuListener);
+ }
+
+ private void add(IMenuManager mm, IAction action) {
+ IContributionItem item= new ActionContributionItem(action);
+ mm.appendToGroup(ACTION_GROUP, item);
+ fContributions.add(item);
+ }
+
+ private void add(IMenuManager mm, IContributionItem item) {
+ mm.appendToGroup(ACTION_GROUP, item);
+ fContributions.add(item);
+ }
+
+ private void removePreviousLRUWorkingSetActions(IMenuManager mm) {
+ for (int i= 1; i < fLRUMenuCount; i++) {
+ String id= WorkingSetMenuContributionItem.getId(i);
+ IContributionItem item= mm.remove(id);
+ fContributions.remove(item);
+ }
+ }
+
+ private void addLRUWorkingSetActions(IMenuManager mm) {
+ IWorkingSet[] workingSets= PlatformUI.getWorkbench().getWorkingSetManager().getRecentWorkingSets();
+ Arrays.sort(workingSets, new WorkingSetComparator());
+
+ int currId= 1;
+ if (fWorkbenchPage != null) {
+ addLRUWorkingSetAction(mm, currId++, fWorkbenchPage.getAggregateWorkingSet());
+ }
+
+ for (int i= 0; i < workingSets.length; i++) {
+ if (!workingSets[i].isAggregateWorkingSet()) {
+ addLRUWorkingSetAction(mm, currId++, workingSets[i]);
+ }
+ }
+ fLRUMenuCount= currId;
+ }
+
+ private void addLRUWorkingSetAction(IMenuManager mm, int id, IWorkingSet workingSet) {
+ IContributionItem item= new WorkingSetMenuContributionItem(id, this, workingSet);
+ mm.insertBefore(LRU_GROUP, item);
+ fContributions.add(item);
+ }
+
+
+ public void cleanViewMenu(IMenuManager menuManager) {
+ for (Iterator iter= fContributions.iterator(); iter.hasNext();) {
+ menuManager.remove((IContributionItem)iter.next());
+ }
+ fContributions.clear();
+ fMenuManager.removeMenuListener(fMenuListener);
+ fMenuListener= null;
+ }
+
+ /* (non-Rubydoc)
+ * @see ActionGroup#dispose()
+ */
+ public void dispose() {
+ if (fMenuManager != null && fMenuListener != null)
+ fMenuManager.removeMenuListener(fMenuListener);
+
+ if (fWorkingSetListener != null) {
+ PlatformUI.getWorkbench().getWorkingSetManager().removePropertyChangeListener(fWorkingSetListener);
+ fWorkingSetListener= null;
+ }
+ fChangeListener= null; // clear the reference to the viewer
+
+ super.dispose();
+ }
+
+ /**
+ * @return Returns viewer filter always configured with the current working set.
+ */
+ public ViewerFilter getWorkingSetFilter() {
+ return fWorkingSetFilter;
+ }
+
+ /*
+ * Called by the working set change listener
+ */
+ private void doPropertyChange(PropertyChangeEvent event) {
+ String property= event.getProperty();
+ if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property)) {
+ fChangeListener.propertyChange(event);
+ } else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
+ IWorkingSet newWorkingSet= (IWorkingSet) event.getNewValue();
+ if (newWorkingSet.equals(fWorkingSet)) {
+ fChangeListener.propertyChange(event);
+ }
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetFilterActionGroup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMenuContributionItem.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMenuContributionItem.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMenuContributionItem.java 2007-07-18 21:35:16 UTC (rev 2790)
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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.workingsets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.Assert;
+
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Menu contribution item which shows and lets select a working set.
+ *
+ * @since 2.0
+ */
+public class WorkingSetMenuContributionItem extends ContributionItem {
+
+ private int fId;
+ private IWorkingSet fWorkingSet;
+ private WorkingSetFilterActionGroup fActionGroup;
+ private Image fImage;
+
+ /**
+ * Constructor for WorkingSetMenuContributionItem.
+ *
+ * @param id the id
+ * @param actionGroup the action group
+ * @param workingSet the working set
+ */
+ public WorkingSetMenuContributionItem(int id, WorkingSetFilterActionGroup actionGroup, IWorkingSet workingSet) {
+ super(getId(id));
+ Assert.isNotNull(actionGroup);
+ Assert.isNotNull(workingSet);
+ fId= id;
+ fActionGroup= actionGroup;
+ fWorkingSet= workingSet;
+ }
+
+ /*
+ * Overrides method from ContributionItem.
+ */
+ public void fill(Menu menu, int index) {
+ MenuItem mi= new MenuItem(menu, SWT.RADIO, index);
+
+ String name= fWorkingSet.getLabel();
+
+ mi.setText("&" + fId + " " + name); //$NON-NLS-1$ //$NON-NLS-2$
+ if (fImage == null) {
+ ImageDescriptor imageDescriptor= fWorkingSet.getImage();
+ if (imageDescriptor != null)
+ fImage= imageDescriptor.createImage();
+ }
+ mi.setImage(fImage);
+ mi.setSelection(fWorkingSet.equals(fActionGroup.getWorkingSet()));
+ mi.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ IWorkingSetManager manager= PlatformUI.getWorkbench().getWorkingSetManager();
+ fActionGroup.setWorkingSet(fWorkingSet, true);
+ manager.addRecentWorkingSet(fWorkingSet);
+ }
+ });
+ }
+
+ /*
+ * @see org.eclipse.jface.action.ContributionItem#dispose()
+ * @since 3.0
+ */
+ public void dispose() {
+ if (fImage != null && !fImage.isDisposed())
+ fImage.dispose();
+ fImage= null;
+
+ super.dispose();
+ }
+
+ /*
+ * @see org.eclipse.jface.action.IContributionItem#isDynamic()
+ */
+ public boolean isDynamic() {
+ return true;
+ }
+
+ static String getId(int id) {
+ return WorkingSetMenuContributionItem.class.getName() + "." + id; //$NON-NLS-1$
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMenuContributionItem.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMessages.java 2007-07-18 21:25:17 UTC (rev 2789)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMessages.java 2007-07-18 21:35:16 UTC (rev 2790)
@@ -18,7 +18,17 @@
public static String WorkingSetModel_others_name;
+ public static String ClearWorkingSetAction_text;
+ public static String ClearWorkingSetAction_toolTip;
+ public static String SelectWorkingSetAction_text;
+ public static String SelectWorkingSetAction_toolTip;
+
+ public static String EditWorkingSetAction_text;
+ public static String EditWorkingSetAction_toolTip;
+ public static String EditWorkingSetAction_error_nowizard_title;
+ public static String EditWorkingSetAction_error_nowizard_message;
+
static {
NLS.initializeMessages(BUNDLE_NAME, WorkingSetMessages.class);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-18 21:25:18
|
Revision: 2789
http://svn.sourceforge.net/rubyeclipse/?rev=2789&view=rev
Author: cawilliams
Date: 2007-07-18 14:25:17 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
type. hierarchy.
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SubTypeHierarchyViewer.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TraditionalHierarchyViewer.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SubTypeHierarchyViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SubTypeHierarchyViewer.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SubTypeHierarchyViewer.java 2007-07-18 21:25:17 UTC (rev 2789)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.ui.typehierarchy;
+
+import java.util.List;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.ITypeHierarchy;
+
+/**
+ * A viewer including the content provider for the subtype hierarchy.
+ * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
+ * on construction (shared type hierarchy)
+ */
+public class SubTypeHierarchyViewer extends TypeHierarchyViewer {
+
+ public SubTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
+ super(parent, new SubTypeHierarchyContentProvider(lifeCycle), lifeCycle, part);
+ }
+
+ /*
+ * @see TypeHierarchyViewer#getTitle
+ */
+ public String getTitle() {
+ if (isMethodFiltering()) {
+ return TypeHierarchyMessages.SubTypeHierarchyViewer_filtered_title;
+ } else {
+ return TypeHierarchyMessages.SubTypeHierarchyViewer_title;
+ }
+ }
+
+ /*
+ * @see TypeHierarchyViewer#updateContent
+ */
+ public void updateContent(boolean expand) {
+ getTree().setRedraw(false);
+ refresh();
+
+ if (expand) {
+ int expandLevel= 2;
+ if (isMethodFiltering()) {
+ expandLevel++;
+ }
+ expandToLevel(expandLevel);
+ }
+ getTree().setRedraw(true);
+ }
+
+ /**
+ * Content provider for the subtype hierarchy
+ */
+ public static class SubTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
+ public SubTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
+ super(lifeCycle);
+ }
+
+ protected final void getTypesInHierarchy(IType type, List res) {
+ ITypeHierarchy hierarchy= getHierarchy();
+ if (hierarchy != null) {
+ IType[] types= hierarchy.getSubtypes(type);
+ if (isObject(type)) {
+ for (int i= 0; i < types.length; i++) {
+ IType curr= types[i];
+ if (!isAnonymousFromInterface(curr)) {
+ res.add(curr);
+ }
+ }
+ } else {
+ for (int i= 0; i < types.length; i++) {
+ res.add(types[i]);
+ }
+ }
+ }
+
+ }
+
+ protected IType getParentType(IType type) {
+ ITypeHierarchy hierarchy= getHierarchy();
+ if (hierarchy != null) {
+ return hierarchy.getSuperclass(type);
+ // dont handle interfaces
+ }
+ return null;
+ }
+
+}
+
+
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SubTypeHierarchyViewer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java 2007-07-18 21:25:17 UTC (rev 2789)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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 java.util.List;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.ITypeHierarchy;
+
+/**
+ * A viewer including the content provider for the supertype hierarchy.
+ * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
+ * on construction (shared type hierarchy)
+ */
+public class SuperTypeHierarchyViewer extends TypeHierarchyViewer {
+
+ public SuperTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
+ super(parent, new SuperTypeHierarchyContentProvider(lifeCycle), lifeCycle, part);
+ }
+
+ /*
+ * @see TypeHierarchyViewer#getTitle
+ */
+ public String getTitle() {
+ if (isMethodFiltering()) {
+ return TypeHierarchyMessages.SuperTypeHierarchyViewer_filtered_title;
+ } else {
+ return TypeHierarchyMessages.SuperTypeHierarchyViewer_title;
+ }
+ }
+
+ /*
+ * @see TypeHierarchyViewer#updateContent
+ */
+ public void updateContent(boolean expand) {
+ getTree().setRedraw(false);
+ refresh();
+ if (expand) {
+ expandAll();
+ }
+ getTree().setRedraw(true);
+ }
+
+ /*
+ * Content provider for the supertype hierarchy
+ */
+ public static class SuperTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
+ public SuperTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
+ super(lifeCycle);
+ }
+
+ protected final void getTypesInHierarchy(IType type, List res) {
+ ITypeHierarchy hierarchy= getHierarchy();
+ if (hierarchy != null) {
+ IType[] types= hierarchy.getSupertypes(type);
+ for (int i= 0; i < types.length; i++) {
+ res.add(types[i]);
+ }
+ }
+ }
+
+ protected IType getParentType(IType type) {
+ // cant handle
+ return null;
+ }
+
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TraditionalHierarchyViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TraditionalHierarchyViewer.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TraditionalHierarchyViewer.java 2007-07-18 21:25:17 UTC (rev 2789)
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * 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.ui.typehierarchy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPart;
+import org.rubypeople.rdt.core.Flags;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.ITypeHierarchy;
+
+/**
+ * A TypeHierarchyViewer that looks like the type hierarchy view of VA/Java:
+ * Starting form Object down to the element in focus, then all subclasses from
+ * this element.
+ * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
+ * on construction (shared type hierarchy)
+ */
+public class TraditionalHierarchyViewer extends TypeHierarchyViewer {
+
+ public TraditionalHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
+ super(parent, new TraditionalHierarchyContentProvider(lifeCycle), lifeCycle, part);
+ }
+
+ /*
+ * @see TypeHierarchyViewer#getTitle
+ */
+ public String getTitle() {
+ if (isMethodFiltering()) {
+ return TypeHierarchyMessages.TraditionalHierarchyViewer_filtered_title;
+ } else {
+ return TypeHierarchyMessages.TraditionalHierarchyViewer_title;
+ }
+ }
+
+ /*
+ * @see TypeHierarchyViewer#updateContent
+ */
+ public void updateContent(boolean expand) {
+ getTree().setRedraw(false);
+ refresh();
+
+ if (expand) {
+ TraditionalHierarchyContentProvider contentProvider= (TraditionalHierarchyContentProvider) getContentProvider();
+ int expandLevel= contentProvider.getExpandLevel();
+ if (isMethodFiltering()) {
+ expandLevel++;
+ }
+ expandToLevel(expandLevel);
+ }
+ getTree().setRedraw(true);
+ }
+
+ /**
+ * Content provider for the 'traditional' type hierarchy.
+ */
+ public static class TraditionalHierarchyContentProvider extends TypeHierarchyContentProvider {
+
+
+ public TraditionalHierarchyContentProvider(TypeHierarchyLifeCycle provider) {
+ super(provider);
+ }
+
+ public int getExpandLevel() {
+ ITypeHierarchy hierarchy= getHierarchy();
+ if (hierarchy != null) {
+ IType input= hierarchy.getType();
+ if (input != null) {
+ return getDepth(hierarchy, input) + 2;
+ } else {
+ return 5;
+ }
+ }
+ return 2;
+ }
+
+ private int getDepth(ITypeHierarchy hierarchy, IType input) {
+ int count= 0;
+ IType superType= hierarchy.getSuperclass(input);
+ while (superType != null) {
+ count++;
+ superType= hierarchy.getSuperclass(superType);
+ }
+ return count;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.typehierarchy.TypeHierarchyContentProvider#getRootTypes(java.util.List)
+ */
+ protected final void getRootTypes(List res) {
+ ITypeHierarchy hierarchy= getHierarchy();
+ if (hierarchy != null) {
+ IType input= hierarchy.getType();
+ if (input == null) {
+ IType[] classes= hierarchy.getRootClasses();
+ for (int i= 0; i < classes.length; i++) {
+ res.add(classes[i]);
+ }
+ IType[] interfaces= hierarchy.getRootInterfaces();
+ for (int i= 0; i < interfaces.length; i++) {
+ res.add(interfaces[i]);
+ }
+ } else {
+ if (Flags.isModule(hierarchy.getCachedFlags(input))) {
+ res.add(input);
+ } else if (isAnonymousFromInterface(input)) {
+ res.add(hierarchy.getSuperInterfaces(input)[0]);
+ } else {
+ IType[] roots= hierarchy.getRootClasses();
+ for (int i= 0; i < roots.length; i++) {
+ if (isObject(roots[i])) {
+ res.add(roots[i]);
+ return;
+ }
+ }
+ res.addAll(Arrays.asList(roots)); // something wrong with the hierarchy
+ }
+ }
+ }
+ }
+
+ /*
+ * @see TypeHierarchyContentProvider.getTypesInHierarchy
+ */
+ protected final void getTypesInHierarchy(IType type, List res) {
+ ITypeHierarchy hierarchy= getHierarchy();
+ if (hierarchy != null) {
+ IType[] types= hierarchy.getSubtypes(type);
+ if (isObject(type)) {
+ for (int i= 0; i < types.length; i++) {
+ IType curr= types[i];
+ if (!isAnonymousFromInterface(curr)) { // no anonymous classes on 'Object' -> will be children of interface
+ res.add(curr);
+ }
+ }
+ } else {
+ boolean isHierarchyOnType= (hierarchy.getType() != null);
+ boolean isClass= !Flags.isModule(hierarchy.getCachedFlags(type));
+ if (isClass || isHierarchyOnType) {
+ for (int i= 0; i < types.length; i++) {
+ res.add(types[i]);
+ }
+ } else {
+ for (int i= 0; i < types.length; i++) {
+ IType curr= types[i];
+ // no classes implementing interfaces, only if anonymous
+ if (Flags.isModule(hierarchy.getCachedFlags(curr)) || isAnonymous(curr)) {
+ res.add(curr);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected IType getParentType(IType type) {
+ ITypeHierarchy hierarchy= getHierarchy();
+ if (hierarchy != null) {
+ return hierarchy.getSuperclass(type);
+ // don't handle interfaces
+ }
+ return null;
+ }
+
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TraditionalHierarchyViewer.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.
|
|
From: <caw...@us...> - 2007-07-18 21:21:46
|
Revision: 2788
http://svn.sourceforge.net/rubyeclipse/?rev=2788&view=rev
Author: cawilliams
Date: 2007-07-18 14:21:44 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyViewer.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyContentProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyContentProvider.java 2007-07-18 21:21:44 UTC (rev 2788)
@@ -0,0 +1,353 @@
+/*******************************************************************************
+ * 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.ui.typehierarchy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+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.corext.util.RubyModelUtil;
+import org.rubypeople.rdt.ui.IWorkingCopyProvider;
+
+/**
+ * Base class for content providers for type hierarchy viewers.
+ * Implementors must override 'getTypesInHierarchy'.
+ * Ruby delta processing is also performed by the content provider
+ */
+public abstract class TypeHierarchyContentProvider implements ITreeContentProvider, IWorkingCopyProvider {
+ protected static final Object[] NO_ELEMENTS= new Object[0];
+
+ protected TypeHierarchyLifeCycle fTypeHierarchy;
+ protected IMember[] fMemberFilter;
+
+ protected TreeViewer fViewer;
+
+ private ViewerFilter fWorkingSetFilter;
+ private MethodOverrideTester fMethodOverrideTester;
+ private ITypeHierarchyLifeCycleListener fTypeHierarchyLifeCycleListener;
+
+
+ public TypeHierarchyContentProvider(TypeHierarchyLifeCycle lifecycle) {
+ fTypeHierarchy= lifecycle;
+ fMemberFilter= null;
+ fWorkingSetFilter= null;
+ fMethodOverrideTester= null;
+ fTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() {
+ public void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchyProvider, IType[] changedTypes) {
+ if (changedTypes == null) {
+ fMethodOverrideTester= null;
+ }
+ }
+ };
+ lifecycle.addChangedListener(fTypeHierarchyLifeCycleListener);
+ }
+
+ /**
+ * Sets members to filter the hierarchy for. Set to <code>null</code> to disable member filtering.
+ * When member filtering is enabled, the hierarchy contains only types that contain
+ * an implementation of one of the filter members and the members themself.
+ * The hierarchy can be empty as well.
+ */
+ public final void setMemberFilter(IMember[] memberFilter) {
+ fMemberFilter= memberFilter;
+ }
+
+ private boolean initializeMethodOverrideTester(IMethod filterMethod, IType typeToFindIn) {
+ IType filterType= filterMethod.getDeclaringType();
+ ITypeHierarchy hierarchy= fTypeHierarchy.getHierarchy();
+
+ boolean filterOverrides= RubyModelUtil.isSuperType(hierarchy, typeToFindIn, filterType);
+ IType focusType= filterOverrides ? filterType : typeToFindIn;
+
+ if (fMethodOverrideTester == null || !fMethodOverrideTester.getFocusType().equals(focusType)) {
+ fMethodOverrideTester= new MethodOverrideTester(focusType, hierarchy);
+ }
+ return filterOverrides;
+ }
+
+ private void addCompatibleMethods(IMethod filterMethod, IType typeToFindIn, List children) throws RubyModelException {
+ boolean filterMethodOverrides= initializeMethodOverrideTester(filterMethod, typeToFindIn);
+ IMethod[] methods= typeToFindIn.getMethods();
+ for (int i= 0; i < methods.length; i++) {
+ IMethod curr= methods[i];
+ if (isCompatibleMethod(filterMethod, curr, filterMethodOverrides) && !children.contains(curr)) {
+ children.add(curr);
+ }
+ }
+ }
+
+ private boolean hasCompatibleMethod(IMethod filterMethod, IType typeToFindIn) throws RubyModelException {
+ boolean filterMethodOverrides= initializeMethodOverrideTester(filterMethod, typeToFindIn);
+ IMethod[] methods= typeToFindIn.getMethods();
+ for (int i= 0; i < methods.length; i++) {
+ if (isCompatibleMethod(filterMethod, methods[i], filterMethodOverrides)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isCompatibleMethod(IMethod filterMethod, IMethod method, boolean filterOverrides) throws RubyModelException {
+ if (filterOverrides) {
+ return fMethodOverrideTester.isSubsignature(filterMethod, method);
+ } else {
+ return fMethodOverrideTester.isSubsignature(method, filterMethod);
+ }
+ }
+
+ /**
+ * The members to filter or <code>null</code> if member filtering is disabled.
+ */
+ public IMember[] getMemberFilter() {
+ return fMemberFilter;
+ }
+
+ /**
+ * Sets a filter representing a working set or <code>null</code> if working sets are disabled.
+ */
+ public void setWorkingSetFilter(ViewerFilter filter) {
+ fWorkingSetFilter= filter;
+ }
+
+
+ protected final ITypeHierarchy getHierarchy() {
+ return fTypeHierarchy.getHierarchy();
+ }
+
+
+ /* (non-Rubydoc)
+ * @see IReconciled#providesWorkingCopies()
+ */
+ public boolean providesWorkingCopies() {
+ return true;
+ }
+
+
+ /*
+ * Called for the root element
+ * @see IStructuredContentProvider#getElements
+ */
+ public Object[] getElements(Object parent) {
+ ArrayList types= new ArrayList();
+ getRootTypes(types);
+ for (int i= types.size() - 1; i >= 0; i--) {
+ IType curr= (IType) types.get(i);
+ try {
+ if (!isInTree(curr)) {
+ types.remove(i);
+ }
+ } catch (RubyModelException e) {
+ // ignore
+ }
+ }
+ return types.toArray();
+ }
+
+ protected void getRootTypes(List res) {
+ ITypeHierarchy hierarchy= getHierarchy();
+ if (hierarchy != null) {
+ IType input= hierarchy.getType();
+ if (input != null) {
+ res.add(input);
+ }
+ // opened on a region: dont show
+ }
+ }
+
+ /**
+ * Hook to overwrite. Filter will be applied on the returned types
+ */
+ protected abstract void getTypesInHierarchy(IType type, List res);
+
+ /**
+ * Hook to overwrite. Return null if parent is ambiguous.
+ */
+ protected abstract IType getParentType(IType type);
+
+
+ private boolean isInScope(IType type) {
+ if (fWorkingSetFilter != null && !fWorkingSetFilter.select(null, null, type)) {
+ return false;
+ }
+
+ IRubyElement input= fTypeHierarchy.getInputElement();
+ int inputType= input.getElementType();
+ if (inputType == IRubyElement.TYPE) {
+ return true;
+ }
+
+ IRubyElement parent= type.getAncestor(input.getElementType());
+ if (inputType == IRubyElement.SOURCE_FOLDER) {
+ if (parent == null || parent.getElementName().equals(input.getElementName())) {
+ return true;
+ }
+ } else if (input.equals(parent)) {
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * Called for the tree children.
+ * @see ITreeContentProvider#getChildren
+ */
+ public Object[] getChildren(Object element) {
+ if (element instanceof IType) {
+ try {
+ IType type= (IType)element;
+
+ List children= new ArrayList();
+ if (fMemberFilter != null) {
+ addFilteredMemberChildren(type, children);
+ }
+
+ addTypeChildren(type, children);
+
+ return children.toArray();
+ } catch (RubyModelException e) {
+ // ignore
+ }
+ }
+ return NO_ELEMENTS;
+ }
+
+ /*
+ * @see ITreeContentProvider#hasChildren
+ */
+ public boolean hasChildren(Object element) {
+ if (element instanceof IType) {
+ try {
+ IType type= (IType) element;
+ return hasTypeChildren(type) || (fMemberFilter != null && hasMemberFilterChildren(type));
+ } catch (RubyModelException e) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ private void addFilteredMemberChildren(IType parent, List children) throws RubyModelException {
+ for (int i= 0; i < fMemberFilter.length; i++) {
+ IMember member= fMemberFilter[i];
+ if (parent.equals(member.getDeclaringType())) {
+ if (!children.contains(member)) {
+ children.add(member);
+ }
+ } else if (member instanceof IMethod) {
+ addCompatibleMethods((IMethod) member, parent, children);
+ }
+ }
+ }
+
+ private void addTypeChildren(IType type, List children) throws RubyModelException {
+ ArrayList types= new ArrayList();
+ getTypesInHierarchy(type, types);
+ int len= types.size();
+ for (int i= 0; i < len; i++) {
+ IType curr= (IType) types.get(i);
+ if (isInTree(curr)) {
+ children.add(curr);
+ }
+ }
+ }
+
+ protected final boolean isInTree(IType type) throws RubyModelException {
+ if (isInScope(type)) {
+ if (fMemberFilter != null) {
+ return hasMemberFilterChildren(type) || hasTypeChildren(type);
+ } else {
+ return true;
+ }
+ }
+ return hasTypeChildren(type);
+ }
+
+ private boolean hasMemberFilterChildren(IType type) throws RubyModelException {
+ for (int i= 0; i < fMemberFilter.length; i++) {
+ IMember member= fMemberFilter[i];
+ if (type.equals(member.getDeclaringType())) {
+ return true;
+ } else if (member instanceof IMethod) {
+ if (hasCompatibleMethod((IMethod) member, type)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean hasTypeChildren(IType type) throws RubyModelException {
+ ArrayList types= new ArrayList();
+ getTypesInHierarchy(type, types);
+ int len= types.size();
+ for (int i= 0; i < len; i++) {
+ IType curr= (IType) types.get(i);
+ if (isInTree(curr)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * @see IContentProvider#inputChanged
+ */
+ public void inputChanged(Viewer part, Object oldInput, Object newInput) {
+ Assert.isTrue(part instanceof TreeViewer);
+ fViewer= (TreeViewer)part;
+ }
+
+ /*
+ * @see IContentProvider#dispose
+ */
+ public void dispose() {
+ fTypeHierarchy.removeChangedListener(fTypeHierarchyLifeCycleListener);
+
+ }
+
+ /*
+ * @see ITreeContentProvider#getParent
+ */
+ public Object getParent(Object element) {
+ if (element instanceof IMember) {
+ IMember member= (IMember) element;
+ if (member.getElementType() == IRubyElement.TYPE) {
+ return getParentType((IType)member);
+ }
+ return member.getDeclaringType();
+ }
+ return null;
+ }
+
+ protected final boolean isAnonymous(IType type) {
+ return type.getElementName().length() == 0;
+ }
+
+ protected final boolean isAnonymousFromInterface(IType type) {
+ return isAnonymous(type) && fTypeHierarchy.getHierarchy().getSuperInterfaces(type).length != 0;
+ }
+
+ protected final boolean isObject(IType type) {
+ return "Object".equals(type.getElementName()) && type.getDeclaringType() == null && "java.lang".equals(type.getSourceFolder().getElementName()); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyViewer.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyViewer.java 2007-07-18 21:21:44 UTC (rev 2788)
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * 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.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.internal.ui.viewsupport.DecoratingRubyLabelProvider;
+import org.rubypeople.rdt.internal.ui.viewsupport.ProblemTreeViewer;
+import org.rubypeople.rdt.ui.RubyElementLabels;
+import org.rubypeople.rdt.ui.actions.OpenAction;
+
+public abstract class TypeHierarchyViewer extends ProblemTreeViewer {
+
+ private OpenAction fOpen;
+ private HierarchyLabelProvider fLabelProvider;
+
+ public TypeHierarchyViewer(Composite parent, IContentProvider contentProvider, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
+ super(new Tree(parent, SWT.SINGLE));
+
+ fLabelProvider= new HierarchyLabelProvider(lifeCycle);
+
+ setLabelProvider(new DecoratingRubyLabelProvider(fLabelProvider, true));
+ setUseHashlookup(true);
+
+ setContentProvider(contentProvider);
+ setSorter(new HierarchyViewerSorter(lifeCycle));
+
+ fOpen= new OpenAction(part.getSite());
+ addOpenListener(new IOpenListener() {
+ public void open(OpenEvent event) {
+ fOpen.run();
+ }
+ });
+ // FIXME Uncomment when we have RubyUIHelp
+// RubyUIHelp.setHelp(this, IRubyHelpContextIds.TYPE_HIERARCHY_VIEW);
+ }
+
+ public void setQualifiedTypeName(boolean on) {
+ if (on) {
+ fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() | RubyElementLabels.T_POST_QUALIFIED);
+ } else {
+ fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() & ~RubyElementLabels.T_POST_QUALIFIED);
+ }
+ refresh();
+ }
+
+ /**
+ * Attaches a contextmenu listener to the tree
+ */
+ public void initContextMenu(IMenuListener menuListener, String popupId, IWorkbenchPartSite viewSite) {
+ MenuManager menuMgr= new MenuManager();
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(menuListener);
+ Menu menu= menuMgr.createContextMenu(getTree());
+ getTree().setMenu(menu);
+ viewSite.registerContextMenu(popupId, menuMgr, this);
+ }
+
+ /**
+ * Fills up the context menu with items for the hierarchy viewer
+ * Should be called by the creator of the context menu
+ */
+ public void contributeToContextMenu(IMenuManager menu) {
+ }
+
+ /**
+ * Set the member filter
+ */
+ public void setMemberFilter(IMember[] memberFilter) {
+ TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
+ if (contentProvider != null) {
+ contentProvider.setMemberFilter(memberFilter);
+ }
+ }
+
+ /**
+ * Returns if method filtering is enabled.
+ */
+ public boolean isMethodFiltering() {
+ TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
+ if (contentProvider != null) {
+ return contentProvider.getMemberFilter() != null;
+ }
+ return false;
+ }
+
+ public void setWorkingSetFilter(ViewerFilter filter) {
+ fLabelProvider.setFilter(filter);
+ TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
+ if (contentProvider != null) {
+ contentProvider.setWorkingSetFilter(filter);
+ }
+ }
+
+ /**
+ * Returns true if the hierarchy contains elements. Returns one of them
+ * With member filtering it is possible that no elements are visible
+ */
+ public Object containsElements() {
+ TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
+ if (contentProvider != null) {
+ Object[] elements= contentProvider.getElements(null);
+ if (elements.length > 0) {
+ return elements[0];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns true if the hierarchy contains elements. Returns one of them
+ * With member filtering it is possible that no elements are visible
+ */
+ public IType getTreeRootType() {
+ TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
+ if (contentProvider != null) {
+ Object[] elements= contentProvider.getElements(null);
+ if (elements.length > 0 && elements[0] instanceof IType) {
+ return (IType) elements[0];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns true if the hierarchy contains element the element.
+ */
+ public boolean isElementShown(Object element) {
+ return findItem(element) != null;
+ }
+
+ /**
+ * Updates the content of this viewer: refresh and expanding the tree in the way wanted.
+ */
+ public abstract void updateContent(boolean doExpand);
+
+ /**
+ * Returns the title for the current view
+ */
+ public abstract String getTitle();
+
+ /*
+ * @see StructuredViewer#setContentProvider
+ * Content provider must be of type TypeHierarchyContentProvider
+ */
+ public void setContentProvider(IContentProvider cp) {
+ Assert.isTrue(cp instanceof TypeHierarchyContentProvider);
+ super.setContentProvider(cp);
+ }
+
+ protected TypeHierarchyContentProvider getHierarchyContentProvider() {
+ return (TypeHierarchyContentProvider)getContentProvider();
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyViewer.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.
|
|
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.
|
|
From: <caw...@us...> - 2007-07-18 21:13:44
|
Revision: 2786
http://svn.sourceforge.net/rubyeclipse/?rev=2786&view=rev
Author: cawilliams
Date: 2007-07-18 14:13:43 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
type hierarchy. duh.
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryDropDownAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryListAction.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryAction.java 2007-07-18 21:13:43 UTC (rev 2786)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.ui.typehierarchy;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.corext.util.Messages;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.viewsupport.RubyElementImageProvider;
+import org.rubypeople.rdt.ui.RubyElementLabels;
+
+/**
+ * Action used for the type hierarchy forward / backward buttons
+ */
+public class HistoryAction extends Action {
+
+ private TypeHierarchyViewPart fViewPart;
+ private IRubyElement fElement;
+
+ public HistoryAction(TypeHierarchyViewPart viewPart, IRubyElement element) {
+ super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+ fViewPart= viewPart;
+ fElement= element;
+
+ String elementName= RubyElementLabels.getElementLabel(element, RubyElementLabels.ALL_POST_QUALIFIED | RubyElementLabels.ALL_DEFAULT);
+ setText(elementName);
+ setImageDescriptor(getImageDescriptor(element));
+
+ setDescription(Messages.format(TypeHierarchyMessages.HistoryAction_description, elementName));
+ setToolTipText(Messages.format(TypeHierarchyMessages.HistoryAction_tooltip, elementName));
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.HISTORY_ACTION);
+ }
+
+ private ImageDescriptor getImageDescriptor(IRubyElement elem) {
+ RubyElementImageProvider imageProvider= new RubyElementImageProvider();
+ ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
+ imageProvider.dispose();
+ return desc;
+ }
+
+ /*
+ * @see Action#run()
+ */
+ public void run() {
+ fViewPart.gotoHistoryEntry(fElement);
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryDropDownAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryDropDownAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryDropDownAction.java 2007-07-18 21:13:43 UTC (rev 2786)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.ui.typehierarchy;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+
+public class HistoryDropDownAction extends Action implements IMenuCreator {
+
+ public static class ClearHistoryAction extends Action {
+
+ private TypeHierarchyViewPart fView;
+
+ public ClearHistoryAction(TypeHierarchyViewPart view) {
+ super(TypeHierarchyMessages.HistoryDropDownAction_clearhistory_label);
+ fView= view;
+ }
+
+ public void run() {
+ fView.setHistoryEntries(new IRubyElement[0]);
+ fView.setInputElement(null);
+ }
+ }
+
+ public static final int RESULTS_IN_DROP_DOWN= 10;
+
+ private TypeHierarchyViewPart fHierarchyView;
+ private Menu fMenu;
+
+ public HistoryDropDownAction(TypeHierarchyViewPart view) {
+ fHierarchyView= view;
+ fMenu= null;
+ setToolTipText(TypeHierarchyMessages.HistoryDropDownAction_tooltip);
+ RubyPluginImages.setLocalImageDescriptors(this, "history_list.gif"); //$NON-NLS-1$
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.TYPEHIERARCHY_HISTORY_ACTION);
+ setMenuCreator(this);
+ }
+
+ public void dispose() {
+ // action is reused, can be called several times.
+ if (fMenu != null) {
+ fMenu.dispose();
+ fMenu= null;
+ }
+ }
+
+ public Menu getMenu(Menu parent) {
+ return null;
+ }
+
+ public Menu getMenu(Control parent) {
+ if (fMenu != null) {
+ fMenu.dispose();
+ }
+ fMenu= new Menu(parent);
+ IRubyElement[] elements= fHierarchyView.getHistoryEntries();
+ addEntries(fMenu, elements);
+ new MenuItem(fMenu, SWT.SEPARATOR);
+ addActionToMenu(fMenu, new HistoryListAction(fHierarchyView));
+ addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
+ return fMenu;
+ }
+
+ private boolean addEntries(Menu menu, IRubyElement[] elements) {
+ boolean checked= false;
+
+ int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
+ for (int i= 0; i < min; i++) {
+ HistoryAction action= new HistoryAction(fHierarchyView, elements[i]);
+ action.setChecked(elements[i].equals(fHierarchyView.getInputElement()));
+ checked= checked || action.isChecked();
+ addActionToMenu(menu, action);
+ }
+
+
+ return checked;
+ }
+
+
+ protected void addActionToMenu(Menu parent, Action action) {
+ ActionContributionItem item= new ActionContributionItem(action);
+ item.fill(parent, -1);
+ }
+
+ public void run() {
+ (new HistoryListAction(fHierarchyView)).run();
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryDropDownAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryListAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryListAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryListAction.java 2007-07-18 21:13:43 UTC (rev 2786)
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * 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.ui.typehierarchy;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo;
+import org.rubypeople.rdt.internal.ui.wizards.dialogfields.DialogField;
+import org.rubypeople.rdt.internal.ui.wizards.dialogfields.IListAdapter;
+import org.rubypeople.rdt.internal.ui.wizards.dialogfields.LayoutUtil;
+import org.rubypeople.rdt.internal.ui.wizards.dialogfields.ListDialogField;
+import org.rubypeople.rdt.ui.RubyElementLabelProvider;
+
+public class HistoryListAction extends Action {
+
+ private class HistoryListDialog extends StatusDialog {
+
+ private ListDialogField fHistoryList;
+ private IStatus fHistoryStatus;
+ private IRubyElement fResult;
+
+ private HistoryListDialog(Shell shell, IRubyElement[] elements) {
+ super(shell);
+ setTitle(TypeHierarchyMessages.HistoryListDialog_title);
+
+ String[] buttonLabels= new String[] {
+ TypeHierarchyMessages.HistoryListDialog_remove_button,
+ };
+
+ IListAdapter adapter= new IListAdapter() {
+ public void customButtonPressed(ListDialogField field, int index) {
+ doCustomButtonPressed();
+ }
+ public void selectionChanged(ListDialogField field) {
+ doSelectionChanged();
+ }
+
+ public void doubleClicked(ListDialogField field) {
+ doDoubleClicked();
+ }
+ };
+
+ RubyElementLabelProvider labelProvider= new RubyElementLabelProvider(RubyElementLabelProvider.SHOW_QUALIFIED | RubyElementLabelProvider.SHOW_ROOT);
+
+ fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
+ fHistoryList.setLabelText(TypeHierarchyMessages.HistoryListDialog_label);
+ fHistoryList.setElements(Arrays.asList(elements));
+
+ ISelection sel;
+ if (elements.length > 0) {
+ sel= new StructuredSelection(elements[0]);
+ } else {
+ sel= new StructuredSelection();
+ }
+
+ fHistoryList.selectElements(sel);
+ }
+
+
+ /*
+ * @see Dialog#createDialogArea(Composite)
+ */
+ protected Control createDialogArea(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite composite= (Composite) super.createDialogArea(parent);
+
+ Composite inner= new Composite(composite, SWT.NONE);
+ inner.setFont(parent.getFont());
+
+ inner.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
+ LayoutUtil.setHeightHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
+ LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null));
+
+ applyDialogFont(composite);
+ return composite;
+ }
+
+ /**
+ * Method doCustomButtonPressed.
+ */
+ private void doCustomButtonPressed() {
+ fHistoryList.removeElements(fHistoryList.getSelectedElements());
+ }
+
+ private void doDoubleClicked() {
+ if (fHistoryStatus.isOK()) {
+ okPressed();
+ }
+ }
+
+
+ private void doSelectionChanged() {
+ StatusInfo status= new StatusInfo();
+ List selected= fHistoryList.getSelectedElements();
+ if (selected.size() != 1) {
+ status.setError(""); //$NON-NLS-1$
+ fResult= null;
+ } else {
+ fResult= (IRubyElement) selected.get(0);
+ }
+ fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
+ fHistoryStatus= status;
+ updateStatus(status);
+ }
+
+ public IRubyElement getResult() {
+ return fResult;
+ }
+
+ public IRubyElement[] getRemaining() {
+ List elems= fHistoryList.getElements();
+ return (IRubyElement[]) elems.toArray(new IRubyElement[elems.size()]);
+ }
+
+ /*
+ * @see org.eclipse.jface.window.Window#configureShell(Shell)
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IRubyHelpContextIds.HISTORY_LIST_DIALOG);
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.window.Window#create()
+ */
+ public void create() {
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ super.create();
+ }
+
+ }
+
+ private TypeHierarchyViewPart fView;
+
+ public HistoryListAction(TypeHierarchyViewPart view) {
+ fView= view;
+ setText(TypeHierarchyMessages.HistoryListAction_label);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.HISTORY_LIST_ACTION);
+ }
+
+ /*
+ * @see IAction#run()
+ */
+ public void run() {
+ IRubyElement[] historyEntries= fView.getHistoryEntries();
+ HistoryListDialog dialog= new HistoryListDialog(RubyPlugin.getActiveWorkbenchShell(), historyEntries);
+ if (dialog.open() == Window.OK) {
+ fView.setHistoryEntries(dialog.getRemaining());
+ fView.setInputElement(dialog.getResult());
+ }
+ }
+
+}
+
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HistoryListAction.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.
|
|
From: <caw...@us...> - 2007-07-18 21:11:41
|
Revision: 2785
http://svn.sourceforge.net/rubyeclipse/?rev=2785&view=rev
Author: cawilliams
Date: 2007-07-18 14:11:39 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
what could this possibly be? Type hier-archy!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HierarchyViewerSorter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsViewer.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java 2007-07-18 21:09:04 UTC (rev 2784)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java 2007-07-18 21:11:39 UTC (rev 2785)
@@ -288,6 +288,7 @@
* @return Returns <code>true</code> if the method has the given name and parameter types and constructor state.
*/
public static boolean isSameMethodSignature(String name, String[] paramTypes, boolean isConstructor, IMethod curr) throws RubyModelException {
+ // XXX Remove paramTypes arg!
if (isConstructor || name.equals(curr.getElementName())) {
if (isConstructor == curr.isConstructor()) {
// if (paramTypes.length == curr.getNumberOfParameters()) {
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HierarchyViewerSorter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HierarchyViewerSorter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HierarchyViewerSorter.java 2007-07-18 21:11:39 UTC (rev 2785)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.ITypeHierarchy;
+
+/**
+ */
+public class HierarchyViewerSorter extends AbstractHierarchyViewerSorter {
+
+ private final TypeHierarchyLifeCycle fHierarchy;
+ private boolean fSortByDefiningType;
+
+ public HierarchyViewerSorter(TypeHierarchyLifeCycle cycle) {
+ fHierarchy= cycle;
+ }
+
+ public void setSortByDefiningType(boolean sortByDefiningType) {
+ fSortByDefiningType= sortByDefiningType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.typehierarchy.AbstractHierarchyViewerSorter#getTypeKind(org.eclipse.jdt.core.IType)
+ */
+ protected int getTypeFlags(IType type) {
+ ITypeHierarchy hierarchy= getHierarchy(type);
+ if (hierarchy != null) {
+ return fHierarchy.getHierarchy().getCachedFlags(type);
+ }
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.typehierarchy.AbstractHierarchyViewerSorter#isSortByDefiningType()
+ */
+ public boolean isSortByDefiningType() {
+ return fSortByDefiningType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.typehierarchy.AbstractHierarchyViewerSorter#isSortAlphabetically()
+ */
+ public boolean isSortAlphabetically() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.typehierarchy.AbstractHierarchyViewerSorter#getHierarchy(org.eclipse.jdt.core.IType)
+ */
+ protected ITypeHierarchy getHierarchy(IType type) {
+ return fHierarchy.getHierarchy(); // hierarchy contains all types shown
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/HierarchyViewerSorter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsContentProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsContentProvider.java 2007-07-18 21:11:39 UTC (rev 2785)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.ITypeHierarchy;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.ui.IWorkingCopyProvider;
+
+/**
+ * Content provider used for the method view.
+ * Allows also seeing methods inherited from base classes.
+ */
+public class MethodsContentProvider implements IStructuredContentProvider, IWorkingCopyProvider {
+
+ private static final Object[] NO_ELEMENTS = new Object[0];
+
+ private boolean fShowInheritedMethods;
+ private TypeHierarchyLifeCycle fHierarchyLifeCycle;
+ private TableViewer fViewer;
+
+ public MethodsContentProvider(TypeHierarchyLifeCycle lifecycle) {
+ fHierarchyLifeCycle= lifecycle;
+ fShowInheritedMethods= false;
+ fViewer= null;
+ }
+
+ /**
+ * Turn on / off showing of inherited methods
+ */
+ public void showInheritedMethods(boolean show) {
+ if (show != fShowInheritedMethods) {
+ fShowInheritedMethods= show;
+ if (fViewer != null) {
+ fViewer.refresh();
+ }
+ }
+ }
+
+ /* (non-Rubydoc)
+ * @see IStructuredContentProvider#providesWorkingCopies()
+ */
+ public boolean providesWorkingCopies() {
+ return true;
+ }
+
+ /**
+ * Returns true if inherited methods are shown
+ */
+ public boolean isShowInheritedMethods() {
+ return fShowInheritedMethods;
+ }
+
+
+ private void addAll(Object[] arr, List res) {
+ if (arr != null) {
+ for (int j= 0; j < arr.length; j++) {
+ res.add(arr[j]);
+ }
+ }
+ }
+
+ /*
+ * @see IStructuredContentProvider#getElements
+ */
+ public Object[] getElements(Object element) {
+ if (element instanceof IType) {
+ IType type= (IType)element;
+
+ List res= new ArrayList();
+ try {
+ ITypeHierarchy hierarchy= fHierarchyLifeCycle.getHierarchy();
+ if (fShowInheritedMethods && hierarchy != null) {
+ IType[] allSupertypes= hierarchy.getAllSupertypes(type);
+ // sort in from last to first: elements with same name
+ // will show up in hierarchy order
+ for (int i= allSupertypes.length - 1; i >= 0; i--) {
+ IType superType= allSupertypes[i];
+ if (superType.exists()) {
+ addAll(superType.getMethods(), res);
+ addAll(superType.getFields(), res);
+ }
+ }
+ }
+ if (type.exists()) {
+ addAll(type.getMethods(), res);
+ addAll(type.getFields(), res);
+ }
+ } catch (RubyModelException e) {
+ RubyPlugin.log(e);
+ }
+ return res.toArray();
+ }
+ return NO_ELEMENTS;
+ }
+
+
+ /*
+ * @see IContentProvider#inputChanged
+ */
+ public void inputChanged(Viewer input, Object oldInput, Object newInput) {
+ Assert.isTrue(input instanceof TableViewer);
+
+ fViewer= (TableViewer) input;
+ }
+
+ /*
+ * @see IContentProvider#dispose
+ */
+ public void dispose() {
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsViewer.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsViewer.java 2007-07-18 21:11:39 UTC (rev 2785)
@@ -0,0 +1,299 @@
+/*******************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.viewers.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.corext.util.RubyModelUtil;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.util.SelectionUtil;
+import org.rubypeople.rdt.internal.ui.viewsupport.DecoratingRubyLabelProvider;
+import org.rubypeople.rdt.internal.ui.viewsupport.ProblemTableViewer;
+import org.rubypeople.rdt.ui.RubyElementLabels;
+import org.rubypeople.rdt.ui.actions.MemberFilterActionGroup;
+import org.rubypeople.rdt.ui.actions.OpenAction;
+
+/**
+ * Method viewer shows a list of methods of a input type.
+ * Offers filter actions.
+ * No dependency to the type hierarchy view
+ */
+public class MethodsViewer extends ProblemTableViewer {
+
+ private static final String TAG_SHOWINHERITED= "showinherited"; //$NON-NLS-1$
+ private static final String TAG_SORTBYDEFININGTYPE= "sortbydefiningtype"; //$NON-NLS-1$
+ private static final String TAG_VERTICAL_SCROLL= "mv_vertical_scroll"; //$NON-NLS-1$
+
+ private MethodsLabelProvider fLabelProvider;
+
+ private MemberFilterActionGroup fMemberFilterActionGroup;
+
+ private OpenAction fOpen;
+ private ShowInheritedMembersAction fShowInheritedMembersAction;
+ private SortByDefiningTypeAction fSortByDefiningTypeAction;
+
+ public MethodsViewer(Composite parent, final TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
+ super(new Table(parent, SWT.MULTI));
+
+// addFilter(new SyntheticMembersFilter());
+
+ fLabelProvider= new MethodsLabelProvider(lifeCycle, this);
+
+ setLabelProvider(new DecoratingRubyLabelProvider(fLabelProvider, true));
+ setContentProvider(new MethodsContentProvider(lifeCycle));
+
+ HierarchyViewerSorter sorter= new HierarchyViewerSorter(lifeCycle);
+ sorter.setSortByDefiningType(false);
+ setSorter(sorter);
+
+ fOpen= new OpenAction(part.getSite());
+ addOpenListener(new IOpenListener() {
+ public void open(OpenEvent event) {
+ fOpen.run();
+ }
+ });
+
+ fMemberFilterActionGroup= new MemberFilterActionGroup(this, "HierarchyMethodView", false, MemberFilterActionGroup.ALL_FILTERS & ~MemberFilterActionGroup.FILTER_LOCALTYPES); //$NON-NLS-1$
+
+ fShowInheritedMembersAction= new ShowInheritedMembersAction(this, false);
+ fSortByDefiningTypeAction= new SortByDefiningTypeAction(this, false);
+
+ showInheritedMethodsNoRedraw(false);
+ sortByDefiningTypeNoRedraw(false);
+ // FIXME Uncomment when we have RubyUIHelp
+// RubyUIHelp.setHelp(this, IRubyHelpContextIds.TYPE_HIERARCHY_VIEW);
+ }
+
+ private void showInheritedMethodsNoRedraw(boolean on) {
+ MethodsContentProvider cprovider= (MethodsContentProvider) getContentProvider();
+ cprovider.showInheritedMethods(on);
+ fShowInheritedMembersAction.setChecked(on);
+ if (on) {
+ fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() | RubyElementLabels.ALL_POST_QUALIFIED);
+ } else {
+ fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() & ~RubyElementLabels.ALL_POST_QUALIFIED);
+ }
+ if (on) {
+ sortByDefiningTypeNoRedraw(false);
+ }
+ fSortByDefiningTypeAction.setEnabled(!on);
+
+ }
+
+ /**
+ * Show inherited methods
+ */
+ public void showInheritedMethods(boolean on) {
+ if (on == isShowInheritedMethods()) {
+ return;
+ }
+ try {
+ getTable().setRedraw(false);
+ showInheritedMethodsNoRedraw(on);
+ refresh();
+ } finally {
+ getTable().setRedraw(true);
+ }
+ }
+
+ private void sortByDefiningTypeNoRedraw(boolean on) {
+ fSortByDefiningTypeAction.setChecked(on);
+ fLabelProvider.setShowDefiningType(on);
+ ((HierarchyViewerSorter) getSorter()).setSortByDefiningType(on);
+ }
+
+ /**
+ * Show the name of the defining type
+ */
+ public void sortByDefiningType(boolean on) {
+ if (on == isShowDefiningTypes()) {
+ return;
+ }
+ try {
+ getTable().setRedraw(false);
+ sortByDefiningTypeNoRedraw(on);
+ refresh();
+ } finally {
+ getTable().setRedraw(true);
+ }
+ }
+
+ /*
+ * @see Viewer#inputChanged(Object, Object)
+ */
+ protected void inputChanged(Object input, Object oldInput) {
+ super.inputChanged(input, oldInput);
+ }
+
+ /**
+ * Returns <code>true</code> if inherited methods are shown.
+ */
+ public boolean isShowInheritedMethods() {
+ return ((MethodsContentProvider) getContentProvider()).isShowInheritedMethods();
+ }
+
+ /**
+ * Returns <code>true</code> if defining types are shown.
+ */
+ public boolean isShowDefiningTypes() {
+ return fLabelProvider.isShowDefiningType();
+ }
+
+ /**
+ * Saves the state of the filter actions
+ */
+ public void saveState(IMemento memento) {
+ fMemberFilterActionGroup.saveState(memento);
+
+ memento.putString(TAG_SHOWINHERITED, String.valueOf(isShowInheritedMethods()));
+ memento.putString(TAG_SORTBYDEFININGTYPE, String.valueOf(isShowDefiningTypes()));
+
+ ScrollBar bar= getTable().getVerticalBar();
+ int position= bar != null ? bar.getSelection() : 0;
+ memento.putString(TAG_VERTICAL_SCROLL, String.valueOf(position));
+ }
+
+ /**
+ * Restores the state of the filter actions
+ */
+ public void restoreState(IMemento memento) {
+ fMemberFilterActionGroup.restoreState(memento);
+ getControl().setRedraw(false);
+ refresh();
+ getControl().setRedraw(true);
+
+ boolean showInherited= Boolean.valueOf(memento.getString(TAG_SHOWINHERITED)).booleanValue();
+ showInheritedMethods(showInherited);
+
+ boolean showDefiningTypes= Boolean.valueOf(memento.getString(TAG_SORTBYDEFININGTYPE)).booleanValue();
+ sortByDefiningType(showDefiningTypes);
+
+ ScrollBar bar= getTable().getVerticalBar();
+ if (bar != null) {
+ Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
+ if (vScroll != null) {
+ bar.setSelection(vScroll.intValue());
+ }
+ }
+ }
+
+ /**
+ * Attaches a contextmenu listener to the table
+ */
+ public void initContextMenu(IMenuListener menuListener, String popupId, IWorkbenchPartSite viewSite) {
+ MenuManager menuMgr= new MenuManager();
+ menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.addMenuListener(menuListener);
+ Menu menu= menuMgr.createContextMenu(getTable());
+ getTable().setMenu(menu);
+ viewSite.registerContextMenu(popupId, menuMgr, this);
+ }
+
+
+ /**
+ * Fills up the context menu with items for the method viewer
+ * Should be called by the creator of the context menu
+ */
+ public void contributeToContextMenu(IMenuManager menu) {
+ }
+
+ /**
+ * Fills up the tool bar with items for the method viewer
+ * Should be called by the creator of the tool bar
+ */
+ public void contributeToToolBar(ToolBarManager tbm) {
+ tbm.add(fShowInheritedMembersAction);
+ tbm.add(fSortByDefiningTypeAction);
+ tbm.add(new Separator());
+ fMemberFilterActionGroup.contributeToToolBar(tbm);
+ }
+
+ public void dispose() {
+ if (fMemberFilterActionGroup != null) {
+ fMemberFilterActionGroup.dispose();
+ fMemberFilterActionGroup= null;
+ }
+ }
+
+ /*
+ * @see StructuredViewer#handleInvalidSelection(ISelection, ISelection)
+ */
+ protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
+ // on change of input, try to keep selected methods stable by selecting a method with the same
+ // signature: See #5466
+ List oldSelections= SelectionUtil.toList(invalidSelection);
+ List newSelections= SelectionUtil.toList(newSelection);
+ if (!oldSelections.isEmpty()) {
+ ArrayList newSelectionElements= new ArrayList(newSelections);
+ try {
+ Object[] currElements= getFilteredChildren(getInput());
+ for (int i= 0; i < oldSelections.size(); i++) {
+ Object curr= oldSelections.get(i);
+ if (curr instanceof IMethod && !newSelections.contains(curr)) {
+ IMethod method= (IMethod) curr;
+ if (method.exists()) {
+ IMethod similar= findSimilarMethod(method, currElements);
+ if (similar != null) {
+ newSelectionElements.add(similar);
+ }
+ }
+ }
+ }
+ if (!newSelectionElements.isEmpty()) {
+ newSelection= new StructuredSelection(newSelectionElements);
+ } else if (currElements.length > 0) {
+ newSelection= new StructuredSelection(currElements[0]);
+ }
+ } catch (RubyModelException e) {
+ RubyPlugin.log(e);
+ }
+ }
+ setSelection(newSelection);
+ updateSelection(newSelection);
+ }
+
+ private IMethod findSimilarMethod(IMethod meth, Object[] elements) throws RubyModelException {
+ String name= meth.getElementName();
+ String[] paramTypes= null;
+ boolean isConstructor= meth.isConstructor();
+
+ for (int i= 0; i < elements.length; i++) {
+ Object curr= elements[i];
+ if (curr instanceof IMethod && RubyModelUtil.isSameMethodSignature(name, paramTypes, isConstructor, (IMethod) curr)) {
+ return (IMethod) curr;
+ }
+ }
+ return null;
+ }
+
+
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/MethodsViewer.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.
|
|
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.
|
|
From: <caw...@us...> - 2007-07-18 21:03:39
|
Revision: 2783
http://svn.sourceforge.net/rubyeclipse/?rev=2783&view=rev
Author: cawilliams
Date: 2007-07-18 14:03:38 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
yet more type hierarchy junk
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/EnableMemberFilterAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/FocusOnSelectionAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/FocusOnTypeAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleViewAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyMessages.properties
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/EnableMemberFilterAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/EnableMemberFilterAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/EnableMemberFilterAction.java 2007-07-18 21:03:38 UTC (rev 2783)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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 member filtering
+ */
+public class EnableMemberFilterAction extends Action {
+
+ private TypeHierarchyViewPart fView;
+
+ public EnableMemberFilterAction(TypeHierarchyViewPart v, boolean initValue) {
+ super(TypeHierarchyMessages.EnableMemberFilterAction_label);
+ setDescription(TypeHierarchyMessages.EnableMemberFilterAction_description);
+ setToolTipText(TypeHierarchyMessages.EnableMemberFilterAction_tooltip);
+
+ RubyPluginImages.setLocalImageDescriptors(this, "impl_co.gif"); //$NON-NLS-1$
+
+ fView= v;
+ setChecked(initValue);
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.ENABLE_METHODFILTER_ACTION);
+
+ }
+
+ /*
+ * @see Action#actionPerformed
+ */
+ public void run() {
+ BusyIndicator.showWhile(fView.getSite().getShell().getDisplay(), new Runnable() {
+ public void run() {
+ fView.enableMemberFilter(isChecked());
+ }
+ });
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/EnableMemberFilterAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/FocusOnSelectionAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/FocusOnSelectionAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/FocusOnSelectionAction.java 2007-07-18 21:03:38 UTC (rev 2783)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.internal.corext.util.Messages;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.util.SelectionUtil;
+import org.rubypeople.rdt.ui.RubyElementLabels;
+
+/**
+ * Refocuses the type hierarchy on the currently selection type.
+ */
+public class FocusOnSelectionAction extends Action {
+
+ private TypeHierarchyViewPart fViewPart;
+
+ public FocusOnSelectionAction(TypeHierarchyViewPart part) {
+ super(TypeHierarchyMessages.FocusOnSelectionAction_label);
+ setDescription(TypeHierarchyMessages.FocusOnSelectionAction_description);
+ setToolTipText(TypeHierarchyMessages.FocusOnSelectionAction_tooltip);
+ fViewPart= part;
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.FOCUS_ON_SELECTION_ACTION);
+ }
+
+ private ISelection getSelection() {
+ ISelectionProvider provider= fViewPart.getSite().getSelectionProvider();
+ if (provider != null) {
+ return provider.getSelection();
+ }
+ return null;
+ }
+
+
+ /*
+ * @see Action#run
+ */
+ public void run() {
+ Object element= SelectionUtil.getSingleElement(getSelection());
+ if (element instanceof IType) {
+ fViewPart.setInputElement((IType)element);
+ }
+ }
+
+ public boolean canActionBeAdded() {
+ Object element= SelectionUtil.getSingleElement(getSelection());
+ if (element instanceof IType) {
+ IType type= (IType)element;
+ setText(Messages.format(
+ TypeHierarchyMessages.FocusOnSelectionAction_label,
+ RubyElementLabels.getTextLabel(type, 0)));
+ return true;
+ }
+ return false;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/FocusOnSelectionAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/FocusOnTypeAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/FocusOnTypeAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/FocusOnTypeAction.java 2007-07-18 21:03:38 UTC (rev 2783)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.search.IRubySearchConstants;
+import org.rubypeople.rdt.core.search.SearchEngine;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.dialogs.TypeSelectionDialog2;
+
+/**
+ * Refocuses the type hierarchy on a type selection from a all types dialog.
+ */
+public class FocusOnTypeAction extends Action {
+
+ private TypeHierarchyViewPart fViewPart;
+
+ public FocusOnTypeAction(TypeHierarchyViewPart part) {
+ super(TypeHierarchyMessages.FocusOnTypeAction_label);
+ setDescription(TypeHierarchyMessages.FocusOnTypeAction_description);
+ setToolTipText(TypeHierarchyMessages.FocusOnTypeAction_tooltip);
+
+ fViewPart= part;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.FOCUS_ON_TYPE_ACTION);
+ }
+
+ /*
+ * @see Action#run
+ */
+ public void run() {
+ Shell parent= fViewPart.getSite().getShell();
+ TypeSelectionDialog2 dialog= new TypeSelectionDialog2(parent, false,
+ PlatformUI.getWorkbench().getProgressService(),
+ SearchEngine.createWorkspaceScope(), IRubySearchConstants.TYPE);
+
+ dialog.setTitle(TypeHierarchyMessages.FocusOnTypeAction_dialog_title);
+ dialog.setMessage(TypeHierarchyMessages.FocusOnTypeAction_dialog_message);
+ if (dialog.open() != IDialogConstants.OK_ID) {
+ return;
+ }
+
+ Object[] types= dialog.getResult();
+ if (types != null && types.length > 0) {
+ IType type= (IType)types[0];
+ fViewPart.setInputElement(type);
+ }
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/FocusOnTypeAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleViewAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleViewAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleViewAction.java 2007-07-18 21:03:38 UTC (rev 2783)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.jface.util.Assert;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+
+/**
+ * Action to switch between the different hierarchy views.
+ */
+public class ToggleViewAction extends Action {
+
+ private TypeHierarchyViewPart fViewPart;
+ private int fViewerIndex;
+
+ public ToggleViewAction(TypeHierarchyViewPart v, int viewerIndex) {
+ super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+ String contextHelpId= null;
+ if (viewerIndex == TypeHierarchyViewPart.VIEW_ID_SUPER) {
+ setText(TypeHierarchyMessages.ToggleViewAction_supertypes_label);
+ contextHelpId= IRubyHelpContextIds.SHOW_SUPERTYPES;
+ setDescription(TypeHierarchyMessages.ToggleViewAction_supertypes_description);
+ setToolTipText(TypeHierarchyMessages.ToggleViewAction_supertypes_tooltip);
+ RubyPluginImages.setLocalImageDescriptors(this, "super_co.gif"); //$NON-NLS-1$
+ } else if (viewerIndex == TypeHierarchyViewPart.VIEW_ID_SUB) {
+ setText(TypeHierarchyMessages.ToggleViewAction_subtypes_label);
+ contextHelpId= IRubyHelpContextIds.SHOW_SUBTYPES;
+ setDescription(TypeHierarchyMessages.ToggleViewAction_subtypes_description);
+ setToolTipText(TypeHierarchyMessages.ToggleViewAction_subtypes_tooltip);
+ RubyPluginImages.setLocalImageDescriptors(this, "sub_co.gif"); //$NON-NLS-1$
+ } else if (viewerIndex == TypeHierarchyViewPart.VIEW_ID_TYPE) {
+ setText(TypeHierarchyMessages.ToggleViewAction_vajhierarchy_label);
+ contextHelpId= IRubyHelpContextIds.SHOW_HIERARCHY;
+ setDescription(TypeHierarchyMessages.ToggleViewAction_vajhierarchy_description);
+ setToolTipText(TypeHierarchyMessages.ToggleViewAction_vajhierarchy_tooltip);
+ RubyPluginImages.setLocalImageDescriptors(this, "hierarchy_co.gif"); //$NON-NLS-1$
+ } else {
+ Assert.isTrue(false);
+ }
+
+ fViewPart= v;
+ fViewerIndex= viewerIndex;
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, contextHelpId);
+ }
+
+ public int getViewerIndex() {
+ return fViewerIndex;
+ }
+
+ /*
+ * @see Action#actionPerformed
+ */
+ public void run() {
+ fViewPart.setView(fViewerIndex);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleViewAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyMessages.properties (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyMessages.properties 2007-07-18 21:03:38 UTC (rev 2783)
@@ -0,0 +1,108 @@
+###############################################################################
+# 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
+###############################################################################
+
+EnableMemberFilterAction_label=Members in Hierarchy
+EnableMemberFilterAction_tooltip=Lock View and Show Members in Hierarchy
+EnableMemberFilterAction_description=Lock view and show members in hierarchy
+
+ToggleOrientationAction_horizontal_label=&Horizontal View Orientation
+ToggleOrientationAction_horizontal_tooltip=Horizontal View Orientation
+ToggleOrientationAction_horizontal_description=Horizontal View Orientation
+
+ToggleOrientationAction_vertical_label=&Vertical View Orientation
+ToggleOrientationAction_vertical_tooltip=Vertical View Orientation
+ToggleOrientationAction_vertical_description=Vertical View Orientation
+
+ToggleOrientationAction_automatic_label=&Automatic View Orientation
+ToggleOrientationAction_automatic_tooltip=Automatic View Orientation
+ToggleOrientationAction_automatic_description=Automatic View Orientation
+
+
+ToggleOrientationAction_single_label=Hierarchy View &Only
+ToggleOrientationAction_single_tooltip=Hierarchy View Only
+ToggleOrientationAction_single_description=Hierarchy View Only
+
+FocusOnSelectionAction_label=Fo&cus On ''{0}''
+FocusOnSelectionAction_tooltip=Focus the Type Hierarchy on the Selected Element
+FocusOnSelectionAction_description=Focus the Type Hierarchy on the selected element
+
+FocusOnTypeAction_label=Foc&us On...
+FocusOnTypeAction_tooltip=Focus the Type Hierarchy on a New Type
+FocusOnTypeAction_description=Focus the Type Hierarchy on a new type
+FocusOnTypeAction_dialog_title=Focus On Type
+FocusOnTypeAction_dialog_message=&Select the type to be shown in the Type Hierarchy view:
+
+HistoryDropDownAction_tooltip=Previous Type Hierarchies
+HistoryDropDownAction_clearhistory_label=Clear History
+
+HistoryAction_description=Open ''{0}'' in Hierarchy
+HistoryAction_tooltip=Open ''{0}'' in Hierarchy
+
+HistoryListDialog_title=Type Hierarchy History
+HistoryListDialog_label=&Select the element to open in the type hierarchy:
+HistoryListDialog_remove_button=&Remove
+
+HistoryListAction_label=History...
+
+ShowInheritedMembersAction_label=All Inherited Members
+ShowInheritedMembersAction_tooltip=Show All Inherited Members
+ShowInheritedMembersAction_description=Show all inherited members
+
+ShowQualifiedTypeNamesAction_label=Show &Qualified Type Names
+ShowQualifiedTypeNamesAction_tooltip=Show Qualified Type Names
+ShowQualifiedTypeNamesAction_description=Show qualified type names
+
+SortByDefiningTypeAction_label=Sort by the Defining Type
+SortByDefiningTypeAction_tooltip=Sort Methods by the Defining Type
+SortByDefiningTypeAction_description=Sort methods by the defining type
+
+SubTypeHierarchyViewer_title=Hierarchy
+SubTypeHierarchyViewer_filtered_title=Hierarchy
+
+SuperTypeHierarchyViewer_title=Hierarchy
+SuperTypeHierarchyViewer_filtered_title=Hierarchy
+
+TraditionalHierarchyViewer_title=Hierarchy
+TraditionalHierarchyViewer_filtered_title=Hierarchy
+
+TypeHierarchyViewPart_error_title=Open Type Hierarchy
+
+TypeHierarchyViewPart_error_message=The selected element only exists in the editor. To perform this operation you have to save the editor first.
+TypeHierarchyViewPart_empty=To display the type hierarchy, select a type (for example in the outline view or in the editor), and select the \'Open Type Hierarchy\' menu option. Alternatively, you can drag and drop an element (e.g. project, package, type) onto this view.
+TypeHierarchyViewPart_nodecl=All types of the current hierarchy ''{0}'' have been filtered by either the selected working set or the chosen locked method.
+TypeHierarchyViewPart_exception_title=Type Hierarchy
+TypeHierarchyViewPart_exception_message=Creating hierarchy failed. See log for details.
+
+TypeHierarchyViewPart_title={1}
+TypeHierarchyViewPart_tooltip={0} of ''{1}''
+TypeHierarchyViewPart_ws_title={1}, working set: {2}
+TypeHierarchyViewPart_ws_tooltip={0} of {1} - working set: {2}
+
+TypeHierarchyViewPart_restoreinput=Restoring type hierarchy of ''{0}''...
+
+TypeHierarchyViewPart_layout_submenu=&Layout
+
+ToggleViewAction_subtypes_label=Su&btype Hierarchy
+ToggleViewAction_subtypes_tooltip=Show the Subtype Hierarchy
+ToggleViewAction_subtypes_description=Show the subtype hierarchy
+
+ToggleViewAction_supertypes_label=Su&pertype Hierarchy
+ToggleViewAction_supertypes_tooltip=Show the Supertype Hierarchy
+ToggleViewAction_supertypes_description=Show the supertype hierarchy
+
+ToggleViewAction_vajhierarchy_label=&Type Hierarchy
+ToggleViewAction_vajhierarchy_tooltip=Show the Type Hierarchy
+ToggleViewAction_vajhierarchy_description=Show the type hierarchy
+
+HierarchyInformationControl_methodhierarchy_label=Types implementing or defining ''{0}.{1}''
+HierarchyInformationControl_hierarchy_label=Type hierarchy of ''{0}'':
+HierarchyInformationControl_toggle_traditionalhierarchy_label=Press ''{0}'' to see the subtype hierarchy
+HierarchyInformationControl_toggle_superhierarchy_label=Press ''{0}'' to see the supertype hierarchy
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyMessages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-18 21:00:19
|
Revision: 2782
http://svn.sourceforge.net/rubyeclipse/?rev=2782&view=rev
Author: cawilliams
Date: 2007-07-18 14:00:18 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
more type hierarchy junk
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleOrientationAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/SelectionProviderMediator.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleOrientationAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleOrientationAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleOrientationAction.java 2007-07-18 21:00:18 UTC (rev 2782)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.jface.util.Assert;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+
+/**
+ * Toggles the orientationof the layout of the type hierarchy
+ */
+public class ToggleOrientationAction extends Action {
+
+ private TypeHierarchyViewPart fView;
+ private int fActionOrientation;
+
+ public ToggleOrientationAction(TypeHierarchyViewPart v, int orientation) {
+ super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+ if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL) {
+ setText(TypeHierarchyMessages.ToggleOrientationAction_horizontal_label);
+ setDescription(TypeHierarchyMessages.ToggleOrientationAction_horizontal_description);
+ setToolTipText(TypeHierarchyMessages.ToggleOrientationAction_horizontal_tooltip);
+ RubyPluginImages.setLocalImageDescriptors(this, "th_horizontal.gif"); //$NON-NLS-1$
+ } else if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_VERTICAL) {
+ setText(TypeHierarchyMessages.ToggleOrientationAction_vertical_label);
+ setDescription(TypeHierarchyMessages.ToggleOrientationAction_vertical_description);
+ setToolTipText(TypeHierarchyMessages.ToggleOrientationAction_vertical_tooltip);
+ RubyPluginImages.setLocalImageDescriptors(this, "th_vertical.gif"); //$NON-NLS-1$
+ } else if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_AUTOMATIC) {
+ setText(TypeHierarchyMessages.ToggleOrientationAction_automatic_label);
+ setDescription(TypeHierarchyMessages.ToggleOrientationAction_automatic_description);
+ setToolTipText(TypeHierarchyMessages.ToggleOrientationAction_automatic_tooltip);
+ RubyPluginImages.setLocalImageDescriptors(this, "th_automatic.gif"); //$NON-NLS-1$
+ } else if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_SINGLE) {
+ setText(TypeHierarchyMessages.ToggleOrientationAction_single_label);
+ setDescription(TypeHierarchyMessages.ToggleOrientationAction_single_description);
+ setToolTipText(TypeHierarchyMessages.ToggleOrientationAction_single_tooltip);
+ RubyPluginImages.setLocalImageDescriptors(this, "th_single.gif"); //$NON-NLS-1$
+ } else {
+ Assert.isTrue(false);
+ }
+ fView= v;
+ fActionOrientation= orientation;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.TOGGLE_ORIENTATION_ACTION);
+ }
+
+ public int getOrientation() {
+ return fActionOrientation;
+ }
+
+ /*
+ * @see Action#actionPerformed
+ */
+ public void run() {
+ if (isChecked()) {
+ fView.fOrientation= fActionOrientation;
+ fView.computeOrientation();
+ }
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/ToggleOrientationAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyMessages.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyMessages.java 2007-07-18 21:00:18 UTC (rev 2782)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.ui.typehierarchy;
+
+import org.eclipse.osgi.util.NLS;
+
+public final class TypeHierarchyMessages extends NLS {
+
+ private static final String BUNDLE_NAME= TypeHierarchyMessages.class.getName();
+
+ private TypeHierarchyMessages() {
+ // Do not instantiate
+ }
+
+ public static String EnableMemberFilterAction_label;
+ public static String EnableMemberFilterAction_tooltip;
+ public static String EnableMemberFilterAction_description;
+ public static String HistoryDropDownAction_clearhistory_label;
+ public static String ToggleOrientationAction_horizontal_label;
+ public static String ToggleOrientationAction_horizontal_tooltip;
+ public static String ToggleOrientationAction_horizontal_description;
+ public static String ToggleOrientationAction_vertical_label;
+ public static String ToggleOrientationAction_vertical_tooltip;
+ public static String ToggleOrientationAction_vertical_description;
+ public static String ToggleOrientationAction_automatic_label;
+ public static String ToggleOrientationAction_automatic_tooltip;
+ public static String ToggleOrientationAction_automatic_description;
+ public static String ToggleOrientationAction_single_label;
+ public static String ToggleOrientationAction_single_tooltip;
+ public static String ToggleOrientationAction_single_description;
+ public static String FocusOnSelectionAction_label;
+ public static String FocusOnSelectionAction_tooltip;
+ public static String FocusOnSelectionAction_description;
+ public static String FocusOnTypeAction_label;
+ public static String FocusOnTypeAction_tooltip;
+ public static String FocusOnTypeAction_description;
+ public static String FocusOnTypeAction_dialog_title;
+ public static String FocusOnTypeAction_dialog_message;
+ public static String HistoryDropDownAction_tooltip;
+ public static String HistoryAction_description;
+ public static String HistoryAction_tooltip;
+ public static String HistoryListDialog_title;
+ public static String HistoryListDialog_label;
+ public static String HistoryListDialog_remove_button;
+ public static String HistoryListAction_label;
+ public static String ShowInheritedMembersAction_label;
+ public static String ShowInheritedMembersAction_tooltip;
+ public static String ShowInheritedMembersAction_description;
+ public static String ShowQualifiedTypeNamesAction_label;
+ public static String ShowQualifiedTypeNamesAction_tooltip;
+ public static String ShowQualifiedTypeNamesAction_description;
+ public static String SortByDefiningTypeAction_label;
+ public static String SortByDefiningTypeAction_tooltip;
+ public static String SortByDefiningTypeAction_description;
+ public static String SubTypeHierarchyViewer_title;
+ public static String SubTypeHierarchyViewer_filtered_title;
+ public static String SuperTypeHierarchyViewer_title;
+ public static String SuperTypeHierarchyViewer_filtered_title;
+ public static String TraditionalHierarchyViewer_title;
+ public static String TraditionalHierarchyViewer_filtered_title;
+ public static String TypeHierarchyViewPart_error_title;
+ public static String TypeHierarchyViewPart_error_message;
+ public static String TypeHierarchyViewPart_empty;
+ public static String TypeHierarchyViewPart_nodecl;
+ public static String TypeHierarchyViewPart_exception_title;
+ public static String TypeHierarchyViewPart_exception_message;
+ public static String TypeHierarchyViewPart_title;
+ public static String TypeHierarchyViewPart_tooltip;
+ public static String TypeHierarchyViewPart_ws_title;
+ public static String TypeHierarchyViewPart_ws_tooltip;
+ public static String TypeHierarchyViewPart_restoreinput;
+ public static String TypeHierarchyViewPart_layout_submenu;
+ public static String ToggleViewAction_subtypes_label;
+ public static String ToggleViewAction_subtypes_tooltip;
+ public static String ToggleViewAction_subtypes_description;
+ public static String ToggleViewAction_supertypes_label;
+ public static String ToggleViewAction_supertypes_tooltip;
+ public static String ToggleViewAction_supertypes_description;
+ public static String ToggleViewAction_vajhierarchy_label;
+ public static String ToggleViewAction_vajhierarchy_tooltip;
+ public static String ToggleViewAction_vajhierarchy_description;
+ public static String HierarchyInformationControl_methodhierarchy_label;
+ public static String HierarchyInformationControl_hierarchy_label;
+ public static String HierarchyInformationControl_toggle_traditionalhierarchy_label;
+ public static String HierarchyInformationControl_toggle_superhierarchy_label;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, TypeHierarchyMessages.class);
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyMessages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/SelectionProviderMediator.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/SelectionProviderMediator.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/SelectionProviderMediator.java 2007-07-18 21:00:18 UTC (rev 2782)
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * 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.ui.viewsupport;
+
+import org.eclipse.core.runtime.ListenerList;
+
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Widget;
+
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.IPostSelectionProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+
+/**
+ * A selection provider for view parts with more that one viewer.
+ * Tracks the focus of the viewers to provide the correct selection.
+ */
+public class SelectionProviderMediator implements IPostSelectionProvider {
+
+ private class InternalListener implements ISelectionChangedListener, FocusListener {
+ /*
+ * @see ISelectionChangedListener#selectionChanged
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ doSelectionChanged(event);
+ }
+
+ /*
+ * @see FocusListener#focusGained
+ */
+ public void focusGained(FocusEvent e) {
+ doFocusChanged(e.widget);
+ }
+
+ /*
+ * @see FocusListener#focusLost
+ */
+ public void focusLost(FocusEvent e) {
+ // do not reset due to focus behavior on GTK
+ //fViewerInFocus= null;
+ }
+ }
+
+ private class InternalPostSelectionListener implements ISelectionChangedListener {
+ public void selectionChanged(SelectionChangedEvent event) {
+ doPostSelectionChanged(event);
+ }
+
+ }
+
+ private StructuredViewer[] fViewers;
+
+ private StructuredViewer fViewerInFocus;
+ private ListenerList fSelectionChangedListeners;
+ private ListenerList fPostSelectionChangedListeners;
+
+ /**
+ * @param viewers All viewers that can provide a selection
+ * @param viewerInFocus the viewer currently in focus or <code>null</code>
+ */
+ public SelectionProviderMediator(StructuredViewer[] viewers, StructuredViewer viewerInFocus) {
+ Assert.isNotNull(viewers);
+ fViewers= viewers;
+ InternalListener listener= new InternalListener();
+ fSelectionChangedListeners= new ListenerList();
+ fPostSelectionChangedListeners= new ListenerList();
+ fViewerInFocus= viewerInFocus;
+
+ for (int i= 0; i < fViewers.length; i++) {
+ StructuredViewer viewer= fViewers[i];
+ viewer.addSelectionChangedListener(listener);
+ viewer.addPostSelectionChangedListener(new InternalPostSelectionListener());
+ Control control= viewer.getControl();
+ control.addFocusListener(listener);
+ }
+ }
+
+ private void doFocusChanged(Widget control) {
+ for (int i= 0; i < fViewers.length; i++) {
+ if (fViewers[i].getControl() == control) {
+ propagateFocusChanged(fViewers[i]);
+ return;
+ }
+ }
+ }
+
+ final void doPostSelectionChanged(SelectionChangedEvent event) {
+ ISelectionProvider provider= event.getSelectionProvider();
+ if (provider == fViewerInFocus) {
+ firePostSelectionChanged();
+ }
+ }
+
+ final void doSelectionChanged(SelectionChangedEvent event) {
+ ISelectionProvider provider= event.getSelectionProvider();
+ if (provider == fViewerInFocus) {
+ fireSelectionChanged();
+ }
+ }
+
+ final void propagateFocusChanged(StructuredViewer viewer) {
+ if (viewer != fViewerInFocus) { // OK to compare by identity
+ fViewerInFocus= viewer;
+ fireSelectionChanged();
+ firePostSelectionChanged();
+ }
+ }
+
+ private void fireSelectionChanged() {
+ if (fSelectionChangedListeners != null) {
+ SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
+
+ Object[] listeners= fSelectionChangedListeners.getListeners();
+ for (int i= 0; i < listeners.length; i++) {
+ ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
+ listener.selectionChanged(event);
+ }
+ }
+ }
+
+ private void firePostSelectionChanged() {
+ if (fPostSelectionChangedListeners != null) {
+ SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
+
+ Object[] listeners= fPostSelectionChangedListeners.getListeners();
+ for (int i= 0; i < listeners.length; i++) {
+ ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
+ listener.selectionChanged(event);
+ }
+ }
+ }
+
+ /*
+ * @see ISelectionProvider#addSelectionChangedListener
+ */
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ fSelectionChangedListeners.add(listener);
+ }
+
+ /*
+ * @see ISelectionProvider#removeSelectionChangedListener
+ */
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ fSelectionChangedListeners.remove(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
+ */
+ public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
+ fPostSelectionChangedListeners.add(listener);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
+ */
+ public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
+ fPostSelectionChangedListeners.remove(listener);
+ }
+
+ /*
+ * @see ISelectionProvider#getSelection
+ */
+ public ISelection getSelection() {
+ if (fViewerInFocus != null) {
+ return fViewerInFocus.getSelection();
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ /*
+ * @see ISelectionProvider#setSelection
+ */
+ public void setSelection(ISelection selection) {
+ if (fViewerInFocus != null) {
+ fViewerInFocus.setSelection(selection);
+ }
+ }
+
+ public void setSelection(ISelection selection, boolean reveal) {
+ if (fViewerInFocus != null) {
+ fViewerInFocus.setSelection(selection, reveal);
+ }
+ }
+
+ /**
+ * Returns the viewer in focus or null if no viewer has the focus
+ */
+ public StructuredViewer getViewerInFocus() {
+ return fViewerInFocus;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/SelectionProviderMediator.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.
|
|
From: <caw...@us...> - 2007-07-18 18:27:11
|
Revision: 2781
http://svn.sourceforge.net/rubyeclipse/?rev=2781&view=rev
Author: cawilliams
Date: 2007-07-18 11:27:10 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
fix url for SVN repo (must now be rubyeclipse.svn.sourceforge.net, not just svn.sourceforge.net)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.build/cruiseControl/config.xml
Modified: trunk/org.rubypeople.rdt.build/cruiseControl/config.xml
===================================================================
--- trunk/org.rubypeople.rdt.build/cruiseControl/config.xml 2007-07-18 16:09:43 UTC (rev 2780)
+++ trunk/org.rubypeople.rdt.build/cruiseControl/config.xml 2007-07-18 18:27:10 UTC (rev 2781)
@@ -10,7 +10,7 @@
<!-- Defines where cruise looks for changes, to decide whether to run the build -->
<modificationset quietperiod="180">
- <svn RepositoryLocation="https://svn.sourceforge.net/svnroot/rubyeclipse"/>
+ <svn RepositoryLocation="https://rubyeclipse.svn.sourceforge.net/svnroot/rubyeclipse"/>
</modificationset>
<!-- Configures the actual build loop, how often and which build file/target -->
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-18 16:22:03
|
Revision: 2775
http://svn.sourceforge.net/rubyeclipse/?rev=2775&view=rev
Author: cawilliams
Date: 2007-07-18 08:37:12 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
apply Martin's patch
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/ruby/classic-debug.rb
Modified: trunk/org.rubypeople.rdt.launching/ruby/classic-debug.rb
===================================================================
--- trunk/org.rubypeople.rdt.launching/ruby/classic-debug.rb 2007-07-17 21:14:46 UTC (rev 2774)
+++ trunk/org.rubypeople.rdt.launching/ruby/classic-debug.rb 2007-07-18 15:37:12 UTC (rev 2775)
@@ -1,1169 +1,1199 @@
-# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
-# Copyright (C) 2000 Information-technology Promotion Agency, Japan
-require 'cgi'
-require 'thread'
-require 'yaml'
-
-# REMOTE_DEBUG_PORT is the port on which the debugger waits for commands from a
-# front-end.
-#
-# RDT note: if you change this, you must also change the corresponding port in
-# org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy
-REMOTE_DEBUG_PORT = (defined? $RemoteDebugPort) ? $RemoteDebugPort : 1098
-
-# VERBOSE_DEBUGGER prints the communication between a front-end and ruby
-# debugger on stderr. If you have started a front-end debug session (and use
-# default preferences for colors of streams), the communication will be printed
-# in red letters to the front-end console.
-VERBOSE_DEBUGGER = defined? DebugVerbose
-
-class PrinterMultiplexer
- def initialize
- @printers = []
- end
-
- def addPrinter(printer)
- @printers << printer
- end
-
- def method_missing(methodName, *args)
- @printers.each { |printer|
- printer.send(methodName, *args)
- }
- end
-end
-
-class XmlPrinter
-
- def initialize(socket)
- @socket = socket
- end
-
- def out(*params)
- debugIntern(false, *params)
- if @socket then
- @socket.printf(*params)
- end
- end
-
- def printXml(s, *params)
- out(s, *params)
- end
-
- def printError(s, *params)
- out("<error>" + s + "</error>", *params)
- end
-
- def printVariable(name, binding, kind)
- printVariableValue(name, eval(name, binding), kind)
- end
-
- def printVariableValue(name, value, kind)
- if value == nil then
- out("<variable name=\"%s\" kind=\"%s\"/>", CGI.escapeHTML(name), kind)
- return
- end
- if value.class().name == "Array" or value.class().name == "Hash" then
- hasChildren = value.length > 0
- if value.length == 0 then
- valueString = "Empty " + value.class().name
- else
- valueString = value.class().name + " (" + value.length.to_s + " element(s))"
- end
- else
- hasChildren = value.instance_variables.length > 0 || value.class.class_variables.length > 0
- valueString = value.to_s
- if valueString =~ /^\"/ then
- valueString.slice!(1..(valueString.length)-2)
- end
- end
- valueString = "[Binary Data]" if valueString.is_binary_data?
- out("<variable name=\"%s\" kind=\"%s\" value=\"%s\" type=\"%s\" hasChildren=\"%s\" objectId=\"%#+x\"/>", CGI.escapeHTML(name), kind, CGI.escapeHTML(valueString), value.class(), hasChildren, value.respond_to?(:object_id) ? value.object_id : value.id)
- end
-
- def printBreakpoint(n, debugFuncName, file, pos)
- out("<breakpoint file=\"%s\" line=\"%s\" threadId=\"%s\"/>", file, pos, DEBUGGER__.get_thread_num())
- end
-
- def printException(file, pos, exception)
- out("<exception file=\"%s\" line=\"%s\" type=\"%s\" message=\"%s\" threadId=\"%s\"/>", file, pos, exception.class, CGI.escapeHTML(exception.to_s), DEBUGGER__.get_thread_num())
- end
-
- def printStepEnd(file, line, framesCount)
- out("<suspended file=\"%s\" line=\"%s\" frames=\"%s\" threadId=\"%s\"/>", file, line, framesCount, DEBUGGER__.get_thread_num())
- end
-
- def printFrame(pos, n, file, line, id)
- out("<frame no=\"%s\" file=\"%s\" line=\"%s\"/>", n, file, line)
- end
-
- def printThread(num, thread)
- out("<thread id=\"%s\" status=\"%s\"/>", num, thread.status)
- end
-
- def printLoadResult(file, exception=nil)
- if exception then
- out("<loadResult file=\"%s\" exceptionType=\"%s\" exceptionMessage=\"%s\"/>", file, exception.class, CGI.escapeHTML(exception.to_s))
- else
- out("<loadResult file=\"%s\" status=\"OK\"/>", file)
- end
- end
-
- def debug(*params)
- debugIntern(true, *params)
- end
-
- def debugIntern(escape, *params)
- if VERBOSE_DEBUGGER then
- output = sprintf(*params)
- output = CGI.escapeHTML(output) if escape
- STDERR.print(output)
-# STDERR.print(' [[' + caller(0)[2].sub(/[^:]*:/, '') + ' ')
-# STDERR.print(Thread.current.to_s + ']]')
- STDERR.print("\n")
- end
- end
-end
-
-#multiplex = PrinterMultiplexer.new
-#multiplex.addPrinter(XmlPrinter.new(nil))
-#multiplex.addPrinter(XmlPrinter.new(nil))
-#multiplex.printXml("TEST")
-
-require 'socket'
-require 'tracer'
-
-class Tracer
- def Tracer.trace_func(*vars)
- Single.trace_func(*vars)
- end
-end
-
-SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
-
-class DEBUGGER__
-
- # type: 0 - breakpoint, 1 - watchpoint
- Breakpoint = Struct.new("Breakpoint", :valid, :type, :file, :pos)
-
- class CommandLinePrinter
- def printXml(s)
- # print XML only
- end
-
- def printVariable(name, binding, kind)
- stdout.printf " %s => %s\n", name, eval(name, binding).inspect
- end
-
- def printBreakpoint(n, debugFuncName, file, pos)
- stdout.printf "Breakpoint %d, %s at %s:%s\n", n, debugFuncName, file, pos
- stdout.flush
- end
-
- def printFrame(pos, n, file, line, id)
- if pos == n
- stdout.printf "--> #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
- else
- stdout.printf " #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
- end
- end
-
- def printException(file, line, exception)
- stdout.printf "%s:%d: `%s' (%s)\n", file, line, exception, exception.class
- stdout.flush
- end
-
- def printThread(num, thread)
- if thread == Thread.current
- stdout.print "+"
- else
- stdout.print " "
- end
- stdout.printf "%d ", num
- stdout.print thread.inspect, "\t"
- file = DEBUGGER__.context(thread).instance_eval{@file}
- if file
- stdout.print file, ":", DEBUGGER__.context(thread).instance_eval{@line}
- end
- stdout.print "\n"
- end
-
-
- def printStepEnd(file, line, framesCount)
-
- end
-
- def debug(*params)
-
- end
-
- def stdout
- DEBUGGER__.stdout
- end
- end
-
- class Context
- attr_reader :shouldResume
- def initialize
- @printer = DEBUGGER__.printer
- @socket = DEBUGGER__.socket
- @stop_next = 0
- @last_file = nil
- @file = nil
- @line = nil
- @no_step = nil
- @frames = []
- @current_frame = -1
- @finish_pos = 0
- @trace = false
- @catch = nil # "StandardError"
- @suspend_next = false
- @shouldResume = false
- end
-
- def stop_next(n=1)
- @stop_next = n
- end
-
- def set_suspend
- @suspend_next = true
- end
-
- def clear_suspend
- @suspend_next = false
- end
-
- def stopCurrentThread
- @printer.debug("Suspending : %s", Thread.current)
- Thread.stop()
- @printer.debug("Resumed : %s", Thread.current)
- end
-
- def trace?
- @trace
- end
-
- def set_trace(arg)
- @trace = arg
- end
-
- def stdout
- if @socket then
- @socket
- else
- DEBUGGER__.stdout
- end
- end
-
- def break_points
- DEBUGGER__.break_points
- end
-
- def display
- DEBUGGER__.display
- end
-
- def context(th)
- DEBUGGER__.context(th)
- end
-
- def set_trace_all(arg)
- DEBUGGER__.set_trace(arg)
- end
-
- def set_last_thread(th)
- DEBUGGER__.set_last_thread(th)
- end
-
- def debug_eval_private(str, binding)
- # evaluates str like "var.@instance_var.@instance_var"
- # and "var.privateMethod"
- # return value might be nil
- # the scan must detect array and hash accesses, which might
- # themselves contain point separated expressions, e.g.
- # array[Test.getX].y
- names = str.scan(/[^\[\]]*(?=\.)|.*\[.*\](?=\.)|.*$/)
- # names can contain empty strings
- obj = eval(names[0], binding)
- (1..names.length-1).each { |i|
- if names[i] != "" then
- if names[i].length > 2 && names[i][0..1] == '@@' then
- @printer.debug("Evaluating (class_var): %s on %s", names[i], obj )
- obj = obj.class.class_eval("#{names[i]}")
- else
- @printer.debug("Evaluating (instance_var): %s on %s", names[i], obj )
- obj = obj.instance_eval("#{names[i]}")
- end
- end
- }
- return obj
- end
-
- def debug_eval(str, binding, noPrivateInstanceVars = false)
- begin
- if noPrivateInstanceVars then
- val = eval(str, binding)
- else
- val = debug_eval_private(str, binding)
- end
- val
- rescue ScriptError, StandardError => error
- if error.to_s =~ /private method .* called for/ then
- return debug_eval(str, binding, true)
- end
- @printer.debug("Error in debug_eval (noPrivateInstancsVars=%s): %s", noPrivateInstanceVars, error)
- raise error
- end
- end
-
- def debug_silent_eval(str, binding)
- begin
- val = eval(str, binding)
- val
- rescue StandardError, ScriptError
- nil
- end
- end
-
- def var_list(ary, binding, kind)
- ary.sort!
- @printer.printXml("<variables>")
- for v in ary
- @printer.printVariable(v,binding, kind)
- end
- @printer.printXml("</variables>")
- end
-
- def printArrayElements(array)
- index = 0
- array.each { |e|
- @printer.printVariableValue('[' + index.to_s + ']', e, 'instance')
- index += 1
- }
- end
-
- def printHashElements(hash)
- hash.keys.each { | k |
- if k.class.name == "String"
- name = '\'' + k + '\''
- else
- name = k.to_s
- end
- @printer.printVariableValue(name, hash[k], 'instance')
- }
- end
-
-
- def getConstantsInClass(aClass)
- constants = aClass.constants() - Object.constants
- return constants.delete_if { |c| ! aClass.const_defined? c }
- end
-
-
- def getBinding(pos)
- # returns frame info of frame pos, if pos is within bound, nil otherwise
- pos = @current_frame unless pos
- pos = pos.to_i - 1
- if pos < 0 then
- @printer.debug("ERROR: illegal stack frame, using top frame.")
- pos = 0
- end
- if pos >= @frames.size then
- @printer.debug("ERROR: given stack frame number %i too high.", pos + 1)
- pos = @frames.size - 1
- end
- @printer.debug("Using frame %s (1-based) for evaluation of variable.", pos + 1)
- return @frames[pos][0]
- end
-
-
- def debug_variable_info(input, binding)
-
- case input
- when /^\s*g(?:lobal)?$/
- var_list(global_variables, binding, 'global')
-
- when /^\s*l(?:ocal)?\s*(\d+)?$/
- @printer.debug("Getting binding for frame #{$1}")
- new_binding = getBinding($1)
- if new_binding then
- binding = new_binding
- end
- begin
- #@printer.debug("binding=%s", binding)
- localVars = eval("local_variables", binding)
- # v 1.8.1 dies in eval @printer.debug("HERE")
- if eval('self.to_s', binding) !~ /main/ then
- localVars << "self"
- end
- var_list(localVars, binding, 'local')
- rescue StandardError => bang
- @printer.debug("Exception while evaluating local_variables: %s", bang)
- var_list([], binding, 'local')
- end
-
- when /^\s*i(?:nstance)?\s*(\d+)?\s+((?:[\\+-]0x)[\dabcdef]+)?/
- new_binding = getBinding($1)
- if new_binding then
- binding = new_binding
- end
- begin
- @printer.printXml("<variables>")
- if $2 then
- obj = ObjectSpace._id2ref($2.hex)
- if (!obj) then
- @printer.debug("unknown object id : %s", $2)
- end
- else
- obj = debug_eval($', binding)
- end
- if (obj.class.name == "Array") then
- printArrayElements(obj)
- return
- end
- if (obj.class.name == "Hash") then
- printHashElements(obj)
- return
- end
- @printer.debug("%s", obj)
- instanceBinding = obj.instance_eval{binding()}
- obj.instance_variables.each {
- | instanceVar |
- @printer.printVariable(instanceVar, instanceBinding, 'instance')
- }
- classBinding = obj.class.class_eval('binding()')
- obj.class.class_variables.each {
- | classVar |
- @printer.printVariable(classVar, classBinding, 'class')
- }
- # I'd like to optimize getting the constants, but they are more dynamic
- # than one would expect from true constants.
- getConstantsInClass(obj.class).each {
- | constant |
- @printer.printVariable(constant, classBinding, 'constant')
- }
- rescue StandardError => error
- @printer.debug("%s", error)
- ensure
- @printer.printXml("</variables>")
- end
-
-
- when /^\s*inspect\s*(\d+)?\s+/
- new_binding = getBinding($1)
- if new_binding then
- binding = new_binding
- end
- begin
- obj = debug_eval($', binding, true)
- rescue ScriptError, StandardError => error
- @printer.printXml("<processingException type=\"%s\" message=\"%s\"/>", error.class, CGI.escapeHTML(error.message))
- return
- end
- @printer.debug("%s", obj)
- @printer.printXml("<variables>")
- @printer.printVariableValue($', obj, "local")
- @printer.printXml("</variables>")
- end
- end
-
- def debug_method_info(input, binding)
- case input
- when /^i(:?nstance)?\s+/
- obj = debug_eval($', binding) # correct highlighting since RDT editor does not recognize $'
-
- len = 0
- for v in obj.methods.sort
- len += v.size + 1
- if len > 70
- len = v.size + 1
- stdout.print "\n"
- end
- stdout.print v, " "
- end
- stdout.print "\n"
-
- else
- obj = debug_eval(input, binding)
- unless obj.kind_of? Module
- stdout.print "Should be Class/Module: ", input, "\n"
- else
- len = 0
- for v in obj.instance_methods.sort
- len += v.size + 1
- if len > 70
- len = v.size + 1
- stdout.print "\n"
- end
- stdout.print v, " "
- end
- stdout.print "\n"
- end
- end
- end
-
- def thnum(thread=Thread.current)
- num = DEBUGGER__.instance_eval{@thread_list[thread]}
- unless num
- DEBUGGER__.make_thread_list
- num = DEBUGGER__.instance_eval{@thread_list[thread]}
- end
- num
- end
-
- def processInput(input)
- binding, file, line, id = @frames[0]
- input.split(";").each {
- | singleCommand |
- readUserInput(binding, file, line, singleCommand.strip)
- }
- end
-
- def readUserInput(binding, binding_file, binding_line, input)
-
- @printer.debug("Processing #{input}, binding=%s", binding)
- @shouldResume = false
- frame_pos = 0
- previous_line = nil
- display_expressions(binding)
-
- case input
- when /^\s*tr(?:ace)?(?:\s+(on|off))?(?:\s+(all))?$/
- if defined?( $2 )
- if $1 == 'on'
- set_trace_all true
- else
- set_trace_all false
- end
- elsif defined?( $1 )
- if $1 == 'on'
- set_trace true
- else
- set_trace false
- end
- end
- if trace?
- stdout.print "Trace on.\n"
- else
- stdout.print "Trace off.\n"
- end
-
- when /^\s*b(?:reak)?\s+(?:(.+):)?([^.:]+)$/
- pos = $2
- file = File.basename($1)
- if pos =~ /^\d+$/
- pname = pos
- pos = pos.to_i
- else
- pname = pos = pos.intern.id2name
- end
- # TODO: pname is not used
- id = DEBUGGER__.next_breakpoint_id
- break_points[id] = Breakpoint.new(true, 0, file, pos)
- @printer.printXml("<breakpointAdded no=\"%d\" location=\"%s:%s\"/>", id, file, pos)
-
- when /^\s*delete\s+(\d+)$/
- breakpoint_id = $1.to_i
- if break_points.delete(breakpoint_id)
- @printer.printXml("<breakpointDeleted no=\"%d\"/>", breakpoint_id)
- else
- @printer.printXml("<error>No breakpoint with id: %d. Currently following breakpoints defined: %s</error>",
- breakpoint_id, break_points.keys.join(', '))
- end
-
- # when /^\s*wat(?:ch)?\s+(.+)$/
- # exp = $1
- # break_points.push [true, 1, exp]
- # stdout.printf "Set watchpoint %d\n", break_points.size, exp
-
- # when /^\s*b(?:reak)?$/
- # if break_points.find{|b| b[1] == 0}
- # n = 1
- # stdout.print "Breakpoints:\n"
- # for b in break_points
- # if b[0] and b[1] == 0
- # stdout.printf " %d %s:%s\n", n, b[2], b[3]
- # end
- # n += 1
- # end
- # end
- # if break_points.find{|b| b[1] == 1}
- # n = 1
- # stdout.print "\n"
- # stdout.print "Watchpoints:\n"
- # for b in break_points
- # if b[0] and b[1] == 1
- # stdout.printf " %d %s\n", n, b[2]
- # end
- # n += 1
- # end
- # end
- # if break_points.size == 0
- # stdout.print "No breakpoints\n"
- # else
- # stdout.print "\n"
- # end
-
- # when /^\s*disp(?:lay)?\s+(.+)$/
- # exp = $1
- # display.push [true, exp]
- # stdout.printf "%d: ", display.size
- # display_expression(exp, binding)
- #
- # when /^\s*disp(?:lay)?$/
- # display_expressions(binding)
- #
- # when /^\s*undisp(?:lay)?(?:\s+(\d+))?$/
- # pos = $1
- # unless pos
- # input = readline("Clear all expressions? (y/n) ", false)
- # if input == "y"
- # for d in display
- # d[0] = false
- # end
- # end
- # else
- # pos = pos.to_i
- # if display[pos-1]
- # display[pos-1][0] = false
- # else
- # stdout.printf "Display expression %d is not defined\n", pos
- # end
- # end
-
- when /^\s*c(?:ont)?$/
- @shouldResume = true
-
- when /^\s*s(?:tep)?(?:\s+(\d+))?$/
- if $1
- lev = $1.to_i
- else
- lev = 1
- end
- @stop_next = lev
- @shouldResume = true
-
- when /^\s*n(?:ext)?(?:\s+(\d+))?$/
- if $1
- lev = $1.to_i
- else
- lev = 1
- end
- @stop_next = lev
- @no_step = @frames.size - frame_pos
- @shouldResume = true
-
- when /^\s*w(?:here)?$/, /^\s*f(?:rame)?$/
- display_frames(frame_pos)
-
- # when /^\s*fin(?:ish)?$/
- # if frame_pos == @frames.size
- # stdout.print "\"finish\" not meaningful in the outermost frame.\n"
- # else
- # @finish_pos = @frames.size - frame_pos
- # frame_pos = 0
- # prompt = false
- # end
- when /^\s*f(?:rame)?\s+(\d+)\s*$/
- @printer.debug("Setting frame to #{$1}")
- @current_frame = $1.to_i
-
-
- when /^\s*cat(?:ch)?(?:\s+(.+))?$/
- # $1 can also be nil
- @catch = $1
- @catch = nil if @catch == 'off'
- if @catch then
- @printer.debug("Catchpoint set to #{@catch}")
- else
- @printer.debug("Catchpoints disabled")
- end
-
-
- when /^\s*v(?:ar)?\s+/
- debug_variable_info($', binding)
-
- when /^\s*m(?:ethod)?\s+/
- debug_method_info($', binding)
-
- when /^\s*th(?:read)?\s+/
- DEBUGGER__.debug_thread_info($', binding)
-
- when /^\s*p\s+/
- stdout.printf "%s\n", debug_eval($', binding).inspect
-
- when /^\s*load\s+/
- @printer.debug("loading file: %s", $')
- begin
- load $'
- @printer.printLoadResult($')
- rescue Exception => error
- @printer.printLoadResult($', error)
- end
-
- else
- @printer.debug("Unknown input : %s", input)
- end
-
- end
-
- def display_expressions(binding)
- n = 1
- for d in display
- if d[0]
- stdout.printf "%d: ", n
- display_expression(d[1], binding)
- end
- n += 1
- end
- end
-
- def display_expression(exp, binding)
- stdout.printf "%s = %s\n", exp, debug_silent_eval(exp, binding).to_s
- end
-
- def frame_set_pos(binding, file, line, id)
- if @frames[0] then
- @frames[0][0] = binding
- @frames[0][1] = file
- @frames[0][2] = line
- @frames[0][3] = id
- else
- @frames[0] = [binding, file, line, id]
- end
- end
-
- def display_frames(pos)
- pos += 1
- n = 0
- at = @frames
- @printer.printXml("<frames>")
- for bind, file, line, id in at
- n += 1
- break unless bind
- @printer.printFrame(pos, n, file, line, id)
- end
- @printer.printXml("</frames>")
- end
-
- def debug_funcname(id)
- if id.nil?
- "toplevel"
- else
- id.id2name
- end
- end
-
- def debug_command(file, line, id, binding)
- @printer.debug("debug_command, @stop_next=%s, @frames.size=%s", @stop_next, @frames.size)
- if @stop_next == 0 && @frames.size > 0 then
- # write suspended only if the suspension was originated by stepping and not before the start
- # of the program
- @printer.printStepEnd(file, line, @frames.size)
- end
- set_last_thread(Thread.current)
-
- #readUserInput(binding, file, line )
- #Thread.stop
- end
-
- def check_break_points(file, pos, binding, id)
- return false if break_points.empty?
- file = File.basename(file)
- n = 1
- break_points.each_value do |b|
- @printer.debug("file=%s, pos=%s; breakpoint=[valid=%s, type=%s, file=%s, pos=%s]\n ",
- file, pos, b.valid, b.type, b.file, b.pos)
- if b.valid
- if b.type == 0 and b.file == file and b.pos == pos # breakpoint
- @printer.printBreakpoint(n, debug_funcname(id), file, pos)
- return true
- elsif b.type == 1 # watchpoint
- if debug_silent_eval(b.file, binding)
- stdout.printf "Watchpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos
- return true
- end
- end
- end
- n += 1
- end
- return false
- end
-
- def excn_handle(file, line, id, binding)
-
- if $!.class <= SystemExit
- @printer.debug( "SystemExit at %s:%d: `%s' (%s)\n", file, line, $!, $!.class )
- set_trace_func nil
- exit
- end
- if @catch and ($!.class.ancestors.find { |e| e.to_s == @catch })
- @printer.printException(file, line, $!)
- fs = @frames.size
- tb = caller(0)[-fs..-1]
- stopCurrentThread
- @frames[0] = [binding, file, line, id]
- debug_command(file, line, id, binding)
- end
-
- end
-
- def trace_func(event, file, line, id, binding, klass)
- Tracer.trace_func(event, file, line, id, binding, klass) if trace?
-
- @file = file
- @line = line
- case event
- when 'line'
- DEBUGGER__.printer().debug("trace line, file=%s, line=%s, stop_next=%d, binding=%s", file, line, @stop_next, binding)
- frame_set_pos(binding, file, line, id)
- if !@no_step or @frames.size == @no_step
- @stop_next -= 1
- @stop_next = -1 if @stop_next < 0
- elsif @frames.size < @no_step
- @stop_next = 0 # break here before leaving...
- else
- # nothing to do. skipped
- end
- if @stop_next == 0 or check_break_points(file, line, binding, id)
- @no_step = nil
- debug_command(file, line, id, binding)
- stopCurrentThread
- end
-
- when 'call'
- DEBUGGER__.printer().debug("trace call, file=%s, line=%s, method=%s", file, line, id.id2name)
- @frames.unshift [binding, file, line, id]
- if check_break_points(file, id.id2name, binding, id) or
- check_break_points(klass.to_s, id.id2name, binding, id) then
- stopCurrentThread
- debug_command(file, line, id, binding)
- end
-
- when 'c-call'
- if @frames[0] then
- @frames[0][1] = file
- @frames[0][2] = line
- else
- @frames[0] = [binding, file, line, id]
- end
-
- when 'class'
- @frames.unshift [binding, file, line, id]
-
- when 'return', 'end'
- DEBUGGER__.printer().debug("trace return and end, file=%s, line=%s", file, line)
- if @frames.size == @finish_pos
- @stop_next = 1
- @finish_pos = 0
- end
- @frames.shift
-
- when 'end'
- DEBUGGER__.printer().debug("trace end, file=%s, line=%s", file, line)
- @frames.shift
-
- when 'raise'
- excn_handle(file, line, id, binding)
-
- end
- @last_file = file
- end
- end
-
- trap("INT") { DEBUGGER__.interrupt }
- @last_thread = Thread::main
- @max_thread = 1
- @max_breakpoint_id = 0
- @thread_list = {Thread::main => 1}
- @break_points = {} # id => Breakpoint
- @display = []
- @waiting = []
- @stdout = STDOUT
-
- class << DEBUGGER__
- def stdout
- @stdout
- end
-
- def stdout=(s)
- @stdout = s
- end
-
- def display
- @display
- end
-
- def break_points
- @break_points
- end
-
- def waiting
- @waiting
- end
-
- def set_trace( arg )
- Thread.critical = true
- make_thread_list
- for th in @thread_list
- context(th[0]).set_trace arg
- end
- Thread.critical = false
- end
-
- def set_last_thread(th)
- @last_thread = th
- end
-
- def suspend
- printer.debug("Suspending all")
- Thread.critical = true
- make_thread_list
- for th in @thread_list
- next if th[0] == Thread.current
- context(th[0]).set_suspend
- end
- Thread.critical = false
- # Schedule other threads to suspend as soon as possible.
- Thread.pass
- end
-
- def resume
- Thread.critical = true
- make_thread_list
- for th in @thread_list
- next if th[0] == Thread.current
- context(th[0]).clear_suspend
- end
- waiting.each do |th|
- th.run
- end
- waiting.clear
- Thread.critical = false
- # Schedule other threads to restart as soon as possible.
- Thread.pass
- end
-
- def context(thread=Thread.current)
- c = thread[:__debugger_data__]
- unless c
- thread[:__debugger_data__] = c = Context.new
- end
- c
- end
-
- def findThread(context)
- for thread in Thread::list
- if context == thread[:__debugger_data__]
- return thread
- end
- end
- end
-
- def interrupt
- context(@last_thread).stop_next
- end
-
- def get_thread(num)
- th = @thread_list.index(num)
- unless th
- printer.debug("No thread ##{num}\n")
- end
- th
- end
-
- def get_thread_num(thread=Thread.current)
- make_thread_list
- @thread_list[thread]
- end
-
- def print_thread(thread)
- num = @thread_list[thread]
- printer.printThread(num, thread)
- end
-
- def thread_list_all
- printer.printXml("<threads>")
- for num in @thread_list.values.sort
- printer.printThread(num, get_thread(num))
- end
- printer.printXml("</threads>")
- end
-
- def make_thread_list
- hash = {}
- for th in Thread::list
- next if th == @@inputReader
- if @thread_list.key? th
- hash[th] = @thread_list[th]
- else
- @max_thread += 1
- hash[th] = @max_thread
- end
- end
- @thread_list = hash
- end
-
- def debug_thread_info(input, binding)
- case input
- when /^l(?:ist)?/
- make_thread_list
- thread_list_all
-
- when /^c(?:ur(?:rent)?)?$/
- make_thread_list
- print_thread()
-
- when /^(?:sw(?:itch)?\s+)?(\d+)/
- make_thread_list
- th = get_thread($1.to_i)
- if th == Thread.current
- @stdout.print "It's the current thread.\n"
- else
- print_thread(th)
- context(th).stop_next
- th.run
- return
- end
-
- when /^stop\s+(\d+)/
- make_thread_list
- th = get_thread($1.to_i)
- if th == Thread.current
- @stdout.print "It's the current thread.\n"
- elsif th.stop?
- @stdout.print "Already stopped.\n"
- else
- print_thread(th)
- context(th).suspend
- end
-
- when /^resume\s+(\d+)/
- make_thread_list
- th = get_thread($1.to_i)
- if th == Thread.current
- @stdout.print "It's the current thread.\n"
- elsif !th.stop?
- @stdout.print "Already running."
- else
- print_thread(th)
- th.run
- end
-
- when /^change\s+(\d+)/
- make_thread_list
- th = get_thread($1.to_i)
- print_thread(th)
- return context(th)
- end
- end
-
- def next_breakpoint_id
- @max_breakpoint_id += 1
- end
- end
-
- @@socket = nil
- @@printer = nil
- @@inputReader = nil
- @@isStarted = false
-
- def DEBUGGER__.printer
- @@printer
- end
-
- def DEBUGGER__.socket
- @@socket
- end
-
- def DEBUGGER__.isStarted
- @@isStarted
- end
-
- def DEBUGGER__.setStarted
- @@isStarted = true
- end
-
-
- def DEBUGGER__.inputReader
- @@inputReader
- end
-
- def DEBUGGER__.traceOn()
- set_trace_func @@traceProc
- Thread.critical = false
- end
-
- def DEBUGGER__.traceOff()
- Thread.critical = true
- set_trace_func nil
- end
-
- def DEBUGGER__.readCommandLoop()
- sleep(1.0) # workaround for large files with ruby 1.6.8, otherwise parse exceptions
- loop do
- sleep(0.1)
- newData, _, _ = IO.select( [socket], nil, nil, 0.001 )
- next unless newData
- DEBUGGER__.traceOff()
- input = newData[0].gets.chomp!
- input.strip!
- @@printer.debug("READ #{input}")
- if !DEBUGGER__.isStarted && input == "cont" then
- DEBUGGER__.setStarted()
- DEBUGGER__.traceOn()
- next
- end
- input =~ /^th\s+(\d+)\s*;\s*/
- if $~ then
- @@printer.debug("Using context for thread: %s", $1.to_i)
- context = DEBUGGER__.context(get_thread($1.to_i))
- input = input[$~[0].length..input.length]
- else
- @@printer.debug("Using context for main thread : %s", Thread.main)
- context = DEBUGGER__.context(Thread.main)
- end
- context.processInput(input)
- if context.shouldResume then
- threadToResume = DEBUGGER__.findThread(context)
- end
- DEBUGGER__.traceOn()
- next unless threadToResume
- threadToResume.run()
- end
- end
-
- # use 127.0.0.1 instead of localhost because OSX 10.4
- server = TCPServer.new('127.0.0.1', REMOTE_DEBUG_PORT)
- puts "ruby #{RUBY_VERSION} debugger listens on port #{REMOTE_DEBUG_PORT}"
- $stdout.flush
- STDERR.sync = true
- @@socket = server.accept
- @@printer = XmlPrinter.new(@@socket)
- @@printer.debug("Socket connection established.")
-
- @@printer.debug("Starting command reader loop.")
- @@inputReader = Thread.new {
- begin
- DEBUGGER__.readCommandLoop()
- rescue ScriptError, StandardError => error
- puts error
- end
- }
-
- @@traceProc = proc { |event, file, line, id, binding, klass, *rest|
-
- #@@printer.debug("trace %s, %s:%s", event, file, line)
- next if Thread.current == DEBUGGER__.inputReader
- next if file =~ /classic-debug.rb$/
- #@@printer.debug("trace %s, %s:%s", event, file, line)
- while (!DEBUGGER__.isStarted) do
- @@printer.debug("Debugging not yet started.")
- sleep(1)
- end
- DEBUGGER__.context.trace_func event, file, line, id, binding, klass
- }
-
- @@printer.debug("Setting trace func: %s", @@traceProc)
- set_trace_func @@traceProc
-end
+# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
+# Copyright (C) 2000 Information-technology Promotion Agency, Japan
+require 'cgi'
+require 'thread'
+require 'yaml'
+
+# REMOTE_DEBUG_PORT is the port on which the debugger waits for commands from a
+# front-end.
+#
+# RDT note: if you change this, you must also change the corresponding port in
+# org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy
+REMOTE_DEBUG_PORT = (defined? $RemoteDebugPort) ? $RemoteDebugPort : 1098
+
+# VERBOSE_DEBUGGER prints the communication between a front-end and ruby
+# debugger on stderr. If you have started a front-end debug session (and use
+# default preferences for colors of streams), the communication will be printed
+# in red letters to the front-end console.
+VERBOSE_DEBUGGER = defined? DebugVerbose
+
+class PrinterMultiplexer
+ def initialize
+ @printers = []
+ end
+
+ def addPrinter(printer)
+ @printers << printer
+ end
+
+ def method_missing(methodName, *args)
+ @printers.each { |printer|
+ printer.send(methodName, *args)
+ }
+ end
+end
+
+class XmlPrinter
+
+ def initialize(socket)
+ @socket = socket
+ end
+
+ def out(*params)
+ debugIntern(false, *params)
+ if @socket then
+ @socket.printf(*params)
+ end
+ end
+
+ def printXml(s, *params)
+ out(s, *params)
+ end
+
+ def printError(s, *params)
+ out("<error>" + s + "</error>", *params)
+ end
+
+ def printMessage(s, *params)
+ out("<message>" + s + "</message>", *params)
+ end
+
+ def printVariable(name, binding, kind)
+ printVariableValue(name, eval(name, binding), kind)
+ end
+
+ def printVariableValue(name, value, kind)
+ if value == nil then
+ out("<variable name=\"%s\" kind=\"%s\"/>", CGI.escapeHTML(name), kind)
+ return
+ end
+ if value.class().name == "Array" or value.class().name == "Hash" then
+ hasChildren = value.length > 0
+ if value.length == 0 then
+ valueString = "Empty " + value.class().name
+ else
+ valueString = value.class().name + " (" + value.length.to_s + " element(s))"
+ end
+ else
+ hasChildren = value.instance_variables.length > 0 || value.class.class_variables.length > 0
+ valueString = value.to_s
+ if valueString =~ /^\"/ then
+ valueString.slice!(1..(valueString.length)-2)
+ end
+ end
+ valueString = "[Binary Data]" if valueString.is_binary_data?
+ out("<variable name=\"%s\" kind=\"%s\" value=\"%s\" type=\"%s\" hasChildren=\"%s\" objectId=\"%#+x\"/>", CGI.escapeHTML(name), kind, CGI.escapeHTML(valueString), value.class(), hasChildren, value.respond_to?(:object_id) ? value.object_id : value.id)
+ end
+
+ def printBreakpoint(n, debugFuncName, file, pos)
+ out("<breakpoint file=\"%s\" line=\"%s\" threadId=\"%s\"/>", file, pos, DEBUGGER__.get_thread_num())
+ end
+
+ def printException(file, pos, exception)
+ out("<exception file=\"%s\" line=\"%s\" type=\"%s\" message=\"%s\" threadId=\"%s\"/>", file, pos, exception.class, CGI.escapeHTML(exception.to_s), DEBUGGER__.get_thread_num())
+ end
+
+ def printStepEnd(file, line, framesCount)
+ out("<suspended file=\"%s\" line=\"%s\" frames=\"%s\" threadId=\"%s\"/>", file, line, framesCount, DEBUGGER__.get_thread_num())
+ end
+
+ def printFrame(pos, n, file, line, id)
+ out("<frame no=\"%s\" file=\"%s\" line=\"%s\"/>", n, file, line)
+ end
+
+ def printThread(num, thread)
+ out("<thread id=\"%s\" status=\"%s\"/>", num, thread.status)
+ end
+
+ def printLoadResult(file, exception=nil)
+ if exception then
+ out("<loadResult file=\"%s\" exceptionType=\"%s\" exceptionMessage=\"%s\"/>", file, exception.class, CGI.escapeHTML(exception.to_s))
+ else
+ out("<loadResult file=\"%s\" status=\"OK\"/>", file)
+ end
+ end
+
+ def debug(*params)
+ debugIntern(true, *params)
+ end
+
+ def debugIntern(escape, *params)
+ if VERBOSE_DEBUGGER then
+ output = sprintf(*params)
+ output = CGI.escapeHTML(output) if escape
+ STDERR.print(output)
+# STDERR.print(' [[' + caller(0)[2].sub(/[^:]*:/, '') + ' ')
+# STDERR.print(Thread.current.to_s + ']]')
+ STDERR.print("\n")
+ end
+ end
+end
+
+#multiplex = PrinterMultiplexer.new
+#multiplex.addPrinter(XmlPrinter.new(nil))
+#multiplex.addPrinter(XmlPrinter.new(nil))
+#multiplex.printXml("TEST")
+
+require 'socket'
+require 'tracer'
+
+class Tracer
+ def Tracer.trace_func(*vars)
+ Single.trace_func(*vars)
+ end
+end
+
+SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
+
+class DEBUGGER__
+
+ # type: 0 - breakpoint, 1 - watchpoint
+ Breakpoint = Struct.new("Breakpoint", :valid, :type, :file, :pos)
+
+ class CommandLinePrinter
+ def printXml(s)
+ # print XML only
+ end
+
+ def printVariable(name, binding, kind)
+ stdout.printf " %s => %s\n", name, eval(name, binding).inspect
+ end
+
+ def printBreakpoint(n, debugFuncName, file, pos)
+ stdout.printf "Breakpoint %d, %s at %s:%s\n", n, debugFuncName, file, pos
+ stdout.flush
+ end
+
+ def printFrame(pos, n, file, line, id)
+ if pos == n
+ stdout.printf "--> #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
+ else
+ stdout.printf " #%d %s:%s%s\n", n, file, line, id ? ":in `#{id.id2name}'":""
+ end
+ end
+
+ def printException(file, line, exception)
+ stdout.printf "%s:%d: `%s' (%s)\n", file, line, exception, exception.class
+ stdout.flush
+ end
+
+ def printThread(num, thread)
+ if thread == Thread.current
+ stdout.print "+"
+ else
+ stdout.print " "
+ end
+ stdout.printf "%d ", num
+ stdout.print thread.inspect, "\t"
+ file = DEBUGGER__.context(thread).instance_eval{@file}
+ if file
+ stdout.print file, ":", DEBUGGER__.context(thread).instance_eval{@line}
+ end
+ stdout.print "\n"
+ end
+
+
+ def printStepEnd(file, line, framesCount)
+
+ end
+
+ def debug(*params)
+
+ end
+
+ def stdout
+ DEBUGGER__.stdout
+ end
+ end
+
+ class Context
+ attr_reader :shouldResume
+ def initialize
+ @printer = DEBUGGER__.printer
+ @socket = DEBUGGER__.socket
+ @stop_next = 0
+ @last_file = nil
+ @file = nil
+ @line = nil
+ @no_step = nil
+ @frames = []
+ @current_frame = -1
+ @finish_pos = 0
+ @trace = false
+ @catch = nil # "StandardError"
+ @suspend_next = false
+ @shouldResume = false
+ end
+
+ def stop_next(n=1)
+ @stop_next = n
+ end
+
+ def set_suspend
+ @suspend_next = true
+ end
+
+ def clear_suspend
+ @suspend_next = false
+ end
+
+ def stopCurrentThread
+ @printer.debug("Suspending : %s", Thread.current)
+ Thread.stop()
+ @printer.debug("Resumed : %s", Thread.current)
+ end
+
+ def trace?
+ @trace
+ end
+
+ def set_trace(arg)
+ @trace = arg
+ end
+
+ def stdout
+ if @socket then
+ @socket
+ else
+ DEBUGGER__.stdout
+ end
+ end
+
+ def break_points
+ DEBUGGER__.break_points
+ end
+
+ def display
+ DEBUGGER__.display
+ end
+
+ def context(th)
+ DEBUGGER__.context(th)
+ end
+
+ def set_trace_all(arg)
+ DEBUGGER__.set_trace(arg)
+ end
+
+ def set_last_thread(th)
+ DEBUGGER__.set_last_thread(th)
+ end
+
+ def debug_eval_private(str, binding)
+ # evaluates str like "var.@instance_var.@instance_var"
+ # and "var.privateMethod"
+ # return value might be nil
+ # the scan must detect array and hash accesses, which might
+ # themselves contain point separated expressions, e.g.
+ # array[Test.getX].y
+ names = str.scan(/[^\[\]]*(?=\.)|.*\[.*\](?=\.)|.*$/)
+ # names can contain empty strings
+ obj = eval(names[0], binding)
+ (1..names.length-1).each { |i|
+ if names[i] != "" then
+ if names[i].length > 2 && names[i][0..1] == '@@' then
+ @printer.debug("Evaluating (class_var): %s on %s", names[i], obj )
+ obj = obj.class.class_eval("#{names[i]}")
+ else
+ @printer.debug("Evaluating (instance_var): %s on %s", names[i], obj )
+ obj = obj.instance_eval("#{names[i]}")
+ end
+ end
+ }
+ return obj
+ end
+
+ def debug_eval(str, binding, noPrivateInstanceVars = false)
+ begin
+ if noPrivateInstanceVars then
+ val = eval(str, binding)
+ else
+ val = debug_eval_private(str, binding)
+ end
+ val
+ rescue ScriptError, StandardError => error
+ if error.to_s =~ /private method .* called for/ then
+ return debug_eval(str, binding, true)
+ end
+ @printer.debug("Error in debug_eval (noPrivateInstancsVars=%s): %s", noPrivateInstanceVars, error)
+ raise error
+ end
+ end
+
+ def debug_silent_eval(str, binding)
+ begin
+ val = eval(str, binding)
+ val
+ rescue StandardError, ScriptError
+ nil
+ end
+ end
+
+ def var_list(ary, binding, kind)
+ ary.sort! do |v1, v2|
+ if v1 == 'self'
+ result = -1
+ elsif v2 == 'self'
+ result = 1
+ else
+ result = v1 <=> v2
+ end
+ result
+ end
+ @printer.printXml("<variables>")
+ for v in ary
+ @printer.printVariable(v,binding, kind)
+ end
+ @printer.printXml("</variables>")
+ end
+
+ def printArrayElements(array)
+ index = 0
+ array.each { |e|
+ @printer.printVariableValue('[' + index.to_s + ']', e, 'instance')
+ index += 1
+ }
+ end
+
+ def printHashElements(hash)
+ hash.keys.each { | k |
+ if k.class.name == "String"
+ name = '\'' + k + '\''
+ else
+ name = k.to_s
+ end
+ @printer.printVariableValue(name, hash[k], 'instance')
+ }
+ end
+
+
+ def getConstantsInClass(aClass)
+ constants = aClass.constants() - Object.constants
+ return constants.delete_if { |c| ! aClass.const_defined? c }
+ end
+
+
+ def getBinding(pos)
+ # returns frame info of frame pos, if pos is within bound, nil otherwise
+ pos = @current_frame unless pos
+ pos = pos.to_i - 1
+ if pos < 0 then
+ @printer.debug("ERROR: illegal stack frame, using top frame.")
+ pos = 0
+ end
+ if pos >= @frames.size then
+ @printer.debug("ERROR: given stack frame number %i too high.", pos + 1)
+ pos = @frames.size - 1
+ end
+ @printer.debug("Using frame %s (1-based) for evaluation of variable.", pos + 1)
+ return @frames[pos][0]
+ end
+
+
+ def debug_variable_info(input, binding)
+
+ case input
+ when /^\s*g(?:lobal)?$/
+ var_list(global_variables, binding, 'global')
+
+ when /^\s*l(?:ocal)?\s*(\d+)?$/
+ @printer.debug("Getting binding for frame #{$1}")
+ new_binding = getBinding($1)
+ if new_binding then
+ binding = new_binding
+ end
+ begin
+ #@printer.debug("binding=%s", binding)
+ localVars = eval("local_variables", binding)
+ # v 1.8.1 dies in eval @printer.debug("HERE")
+ if eval('self.to_s', binding) !~ /main/ then
+ localVars << "self"
+ end
+ var_list(localVars, binding, 'local')
+ rescue StandardError => bang
+ @printer.debug("Exception while evaluating local_variables: %s", bang)
+ var_list([], binding, 'local')
+ end
+
+ when /^\s*i(?:nstance)?\s*(\d+)?\s+((?:[\\+-]0x)[\dabcdef]+)?/
+ new_binding = getBinding($1)
+ if new_binding then
+ binding = new_binding
+ end
+ begin
+ @printer.printXml("<variables>")
+ if $2 then
+ obj = ObjectSpace._id2ref($2.hex)
+ if (!obj) then
+ @printer.debug("unknown object id : %s", $2)
+ end
+ else
+ obj = debug_eval($', binding)
+ end
+ if (obj.class.name == "Array") then
+ printArrayElements(obj)
+ return
+ end
+ if (obj.class.name == "Hash") then
+ printHashElements(obj)
+ return
+ end
+ @printer.debug("%s", obj)
+ instanceBinding = obj.instance_eval{binding()}
+ obj.instance_variables.each {
+ | instanceVar |
+ @printer.printVariable(instanceVar, instanceBinding, 'instance')
+ }
+ classBinding = obj.class.class_eval('binding()')
+ obj.class.class_variables.each {
+ | classVar |
+ @printer.printVariable(classVar, classBinding, 'class')
+ }
+ # I'd like to optimize getting the constants, but they are more dynamic
+ # than one would expect from true constants.
+ getConstantsInClass(obj.class).each {
+ | constant |
+ @printer.printVariable(constant, classBinding, 'constant')
+ }
+ rescue StandardError => error
+ @printer.debug("%s", error)
+ ensure
+ @printer.printXml("</variables>")
+ end
+
+
+ when /^\s*inspect\s*(\d+)?\s+/
+ new_binding = getBinding($1)
+ if new_binding then
+ binding = new_binding
+ end
+ begin
+ obj = debug_eval($', binding, true)
+ rescue ScriptError, StandardError => error
+ @printer.printXml("<processingException type=\"%s\" message=\"%s\"/>", error.class, CGI.escapeHTML(error.message))
+ return
+ end
+ @printer.debug("%s", obj)
+ @printer.printXml("<variables>")
+ @printer.printVariableValue($', obj, "local")
+ @printer.printXml("</variables>")
+ end
+ end
+
+ def debug_method_info(input, binding)
+ case input
+ when /^i(:?nstance)?\s+/
+ obj = debug_eval($', binding) # correct highlighting since RDT editor does not recognize $'
+
+ len = 0
+ for v in obj.methods.sort
+ len += v.size + 1
+ if len > 70
+ len = v.size + 1
+ stdout.print "\n"
+ end
+ stdout.print v, " "
+ end
+ stdout.print "\n"
+
+ else
+ obj = debug_eval(input, binding)
+ unless obj.kind_of? Module
+ stdout.print "Should be Class/Module: ", input, "\n"
+ else
+ len = 0
+ for v in obj.instance_methods.sort
+ len += v.size + 1
+ if len > 70
+ len = v.size + 1
+ stdout.print "\n"
+ end
+ stdout.print v, " "
+ end
+ stdout.print "\n"
+ end
+ end
+ end
+
+ def thnum(thread=Thread.current)
+ num = DEBUGGER__.instance_eval{@thread_list[thread]}
+ unless num
+ DEBUGGER__.make_thread_list
+ num = DEBUGGER__.instance_eval{@thread_list[thread]}
+ end
+ num
+ end
+
+ def processInput(input)
+ binding, file, line, id = @frames[0]
+ input.split(";").each {
+ | singleCommand |
+ readUserInput(binding, file, line, singleCommand.strip)
+ }
+ end
+
+ def readUserInput(binding, binding_file, binding_line, input)
+
+ @printer.debug("Processing #{input}, binding=%s", binding)
+ @shouldResume = false
+ frame_pos = 0
+ previous_line = nil
+ display_expressions(binding)
+
+ case input
+ when /^\s*tr(?:ace)?(?:\s+(on|off))?(?:\s+(all))?$/
+ if defined?( $2 )
+ if $1 == 'on'
+ set_trace_all true
+ else
+ set_trace_all false
+ end
+ elsif defined?( $1 )
+ if $1 == 'on'
+ set_trace true
+ else
+ set_trace false
+ end
+ end
+ if trace?
+ stdout.print "Trace on.\n"
+ else
+ stdout.print "Trace off.\n"
+ end
+
+ when /^\s*b(?:reak)?\s+(?:(.+):)?([^.:]+)$/
+ pos = $2
+ file = File.basename($1)
+ if pos =~ /^\d+$/
+ pname = pos
+ pos = pos.to_i
+ else
+ pname = pos = pos.intern.id2name
+ end
+ # TODO: pname is not used
+ id = DEBUGGER__.next_breakpoint_id
+ break_points[id] = Breakpoint.new(true, 0, file, pos)
+ @printer.printXml("<breakpointAdded no=\"%d\" location=\"%s:%s\"/>", id, file, pos)
+
+ when /^\s*delete\s+(.*)$/
+ arg = $1
+ if arg !~ /(?:^\d+$)/
+ @printer.printError "Delete argument '#{arg}' needs to be positive number"
+ else
+ breakpoint_id = arg.to_i
+ if break_points.delete(breakpoint_id)
+ @printer.printXml("<breakpointDeleted no=\"%d\"/>", breakpoint_id)
+ else
+ @printer.printError("No breakpoint with id: %d. Currently following breakpoints defined: %s",
+ breakpoint_id, break_points.keys.join(', '))
+ end
+ end
+
+ # when /^\s*wat(?:ch)?\s+(.+)$/
+ # exp = $1
+ # break_points.push [true, 1, exp]
+ # stdout.printf "Set watchpoint %d\n", break_points.size, exp
+
+ # when /^\s*b(?:reak)?$/
+ # if break_points.find{|b| b[1] == 0}
+ # n = 1
+ # stdout.print "Breakpoints:\n"
+ # for b in break_points
+ # if b[0] and b[1] == 0
+ # stdout.printf " %d %s:%s\n", n, b[2], b[3]
+ # end
+ # n += 1
+ # end
+ # end
+ # if break_points.find{|b| b[1] == 1}
+ # n = 1
+ # stdout.print "\n"
+ # stdout.print "Watchpoints:\n"
+ # for b in break_points
+ # if b[0] and b[1] == 1
+ # stdout.printf " %d %s\n", n, b[2]
+ # end
+ # n += 1
+ # end
+ # end
+ # if break_points.size == 0
+ # stdout.print "No breakpoints\n"
+ # else
+ # stdout.print "\n"
+ # end
+
+ # when /^\s*disp(?:lay)?\s+(.+)$/
+ # exp = $1
+ # display.push [true, exp]
+ # stdout.printf "%d: ", display.size
+ # display_expression(exp, binding)
+ #
+ # when /^\s*disp(?:lay)?$/
+ # display_expressions(binding)
+ #
+ # when /^\s*undisp(?:lay)?(?:\s+(\d+))?$/
+ # pos = $1
+ # unless pos
+ # input = readline("Clear all expressions? (y/n) ", false)
+ # if input == "y"
+ # for d in display
+ # d[0] = false
+ # end
+ # end
+ # else
+ # pos = pos.to_i
+ # if display[pos-1]
+ # display[pos-1][0] = false
+ # else
+ # stdout.printf "Display expression %d is not defined\n", pos
+ # end
+ # end
+
+ when /^\s*c(?:ont)?$/
+ @shouldResume = true
+
+ when /^\s*s(?:tep)?(?:\s+(\d+))?$/
+ if $1
+ lev = $1.to_i
+ else
+ lev = 1
+ end
+ @stop_next = lev
+ @shouldResume = true
+
+ when /^\s*n(?:ext)?(?:\s+(\d+))?$/
+ if $1
+ lev = $1.to_i
+ else
+ lev = 1
+ end
+ @stop_next = lev
+ @no_step = @frames.size - frame_pos
+ @shouldResume = true
+
+ when /^\s*w(?:here)?$/, /^\s*f(?:rame)?$/
+ display_frames(frame_pos)
+
+ # when /^\s*fin(?:ish)?$/
+ # if frame_pos == @frames.size
+ # stdout.print "\"finish\" not meaningful in the outermost frame.\n"
+ # else
+ # @finish_pos = @frames.size - frame_pos
+ # frame_pos = 0
+ # prompt = false
+ # end
+ when /^\s*f(?:rame)?\s+(\d+)\s*$/
+ @printer.debug("Setting frame to #{$1}")
+ @current_frame = $1.to_i
+
+
+ when /^\s*cat(?:ch)?(?:\s+(.+))?$/
+ # $1 can also be nil
+ @catch = $1
+ @catch = nil if @catch == 'off'
+ if @catch then
+ @printer.debug("Catchpoint set to #{@catch}")
+ else
+ @printer.debug("Catchpoints disabled")
+ end
+
+
+ when /^\s*v(?:ar)?\s+/
+ debug_variable_info($', binding)
+
+ when /^\s*m(?:ethod)?\s+/
+ debug_method_info($', binding)
+
+ when /^\s*th(?:read)?\s+/
+ DEBUGGER__.debug_thread_info($', binding)
+
+ when /^\s*p\s+/
+ stdout.printf "%s\n", debug_eval($', binding).inspect
+
+ when /^\s*load\s+/
+ @printer.debug("loading file: %s", $')
+ begin
+ load $'
+ @printer.printLoadResult($')
+ rescue Exception => error
+ @printer.printLoadResult($', error)
+ end
+
+ when /^\s*exit$/
+ @printer.printMessage("finished")
+ set_trace_func nil
+ @socket.close
+ exit!
+
+ else
+ @printer.printMessage("Unknown input: %s", input)
+ end
+
+ end
+
+ def display_expressions(binding)
+ n = 1
+ for d in display
+ if d[0]
+ stdout.printf "%d: ", n
+ display_expression(d[1], binding)
+ end
+ n += 1
+ end
+ end
+
+ def display_expression(exp, binding)
+ stdout.printf "%s = %s\n", exp, debug_silent_eval(exp, binding).to_s
+ end
+
+ def frame_set_pos(binding, file, line, id)
+ if @frames[0] then
+ @frames[0][0] = binding
+ @frames[0][1] = file
+ @frames[0][2] = line
+ @frames[0][3] = id
+ else
+ @frames[0] = [binding, file, line, id]
+ end
+ end
+
+ def display_frames(pos)
+ pos += 1
+ n = 0
+ at = @frames
+ @printer.printXml("<frames>")
+ for bind, file, line, id in at
+ n += 1
+ break unless bind
+ @printer.printFrame(pos, n, file, line, id)
+ end
+ @printer.printXml("</frames>")
+ end
+
+ def debug_funcname(id)
+ if id.nil?
+ "toplevel"
+ else
+ id.id2name
+ end
+ end
+
+ def debug_command(file, line, id, binding)
+ @printer.debug("debug_command, @stop_next=%s, @frames.size=%s", @stop_next, @frames.size)
+ if @stop_next == 0 && @frames.size > 0 then
+ # write suspended only if the suspension was originated by stepping and not before the start
+ # of the program
+ @printer.printStepEnd(file, line, @frames.size)
+ end
+ set_last_thread(Thread.current)
+
+ #readUserInput(binding, file, line )
+ #Thread.stop
+ end
+
+ def check_break_points(file, pos, binding, id)
+ return false if break_points.empty?
+ file = File.basename(file)
+ n = 1
+ break_points.each_value do |b|
+# @printer.debug("file=%s, pos=%s; breakpoint=[valid=%s, type=%s, file=%s, pos=%s]\n ",
+# file, pos, b.valid, b.type, b.file, b.pos)
+ if b.valid
+ if b.type == 0 and b.file == file and b.pos == pos # breakpoint
+ @printer.printBreakpoint(n, debug_funcname(id), file, pos)
+ return true
+ elsif b.type == 1 # watchpoint
+ if debug_silent_eval(b.file, binding)
+ stdout.printf "Watchpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos
+ return true
+ end
+ end
+ end
+ n += 1
+ end
+ return false
+ end
+
+ def excn_handle(file, line, id, binding)
+
+ if $!.class <= SystemExit
+ @printer.debug( "SystemExit at %s:%d: `%s' (%s)\n", file, line, $!, $!.class )
+ set_trace_func nil
+ exit
+ end
+ if @catch and ($!.class.ancestors.find { |e| e.to_s == @catch })
+ @printer.printException(file, line, $!)
+ fs = @frames.size
+ tb = caller(0)[-fs..-1]
+ stopCurrentThread
+ @frames[0] = [binding, file, line, id]
+ debug_command(file, line, id, binding)
+ end
+
+ end
+
+ def trace_func(event, file, line, id, binding, klass)
+ Tracer.trace_func(event, file, line, id, binding, klass) if trace?
+
+ @file = file
+ @line = line
+ case event
+ when 'line'
+ # DEBUGGER__.printer().debug("trace line, file=%s, line=%s, stop_next=%d, binding=%s", file, line, @stop_next, binding)
+ frame_set_pos(binding, file, line, id)
+ if !@no_step or @frames.size == @no_step
+ @stop_next -= 1
+ @stop_next = -1 if @stop_next < 0
+ elsif @frames.size < @no_step
+ @stop_next = 0 # break here before leaving...
+ else
+ # nothing to do. skipped
+ end
+ if @stop_next == 0 or check_break_points(file, line, binding, id)
+ @no_step = nil
+ debug_command(file, line, id, binding)
+ stopCurrentThread
+ end
+
+ when 'call'
+# DEBUGGER__.printer().debug("trace call, file=%s, line=%s, method=%s", file, line, id.id2name)
+ @frames.unshift [binding, file, line, id]
+ if check_break_points(file, id.id2name, binding, id) or
+ check_break_points(klass.to_s, id.id2name, binding, id) then
+ stopCurrentThread
+ debug_command(file, line, id, binding)
+ end
+
+ when 'c-call'
+ if @frames[0] then
+ @frames[0][1] = file
+ @frames[0][2] = line
+ else
+ @frames[0] = [binding, file, line, id]
+ end
+
+ when 'class'
+ @frames.unshift [binding, file, line, id]
+
+ when 'return', 'end'
+# DEBUGGER__.printer().debug("trace return and end, file=%s, line=%s", file, line)
+ if @frames.size == @finish_pos
+ @stop_next = 1
+ @finish_pos = 0
+ end
+ @frames.shift
+
+ when 'end'
+# DEBUGGER__.printer().debug("trace end, file=%s, line=%s", file, line)
+ @frames.shift
+
+ when 'raise'
+ excn_handle(file, line, id, binding)
+
+ end
+ @last_file = file
+ end
+ end
+
+ trap("INT") { DEBUGGER__.interrupt }
+ @last_thread = Thread::main
+ @max_thread = 1
+ @max_breakpoint_id = 0
+ @thread_list = {Thread::main => 1}
+ @break_points = {} # id => Breakpoint
+ @display = []
+ @waiting = []
+ @stdout = STDOUT
+
+ class << DEBUGGER__
+ def stdout
+ @stdout
+ end
+
+ def stdout=(s)
+ @stdout = s
+ end
+
+ def displa...
[truncated message content] |
|
From: <caw...@us...> - 2007-07-18 16:09:46
|
Revision: 2780
http://svn.sourceforge.net/rubyeclipse/?rev=2780&view=rev
Author: cawilliams
Date: 2007-07-18 09:09:43 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
actually read the "no" attribute on frames and use that as the index (rather than assuming 1 and counting up each time we read a frame in).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/FramesReader.java
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/FramesReader.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/FramesReader.java 2007-07-18 15:55:28 UTC (rev 2779)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/FramesReader.java 2007-07-18 16:09:43 UTC (rev 2780)
@@ -1,9 +1,10 @@
package org.rubypeople.rdt.internal.debug.core.parsing;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
-import org.eclipse.debug.core.model.IStackFrame;
import org.rubypeople.rdt.internal.debug.core.RdtDebugCorePlugin;
import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
import org.rubypeople.rdt.internal.debug.core.model.RubyThread;
@@ -13,8 +14,7 @@
public class FramesReader extends XmlStreamReader {
private RubyThread thread;
- int index = 1;
- private List<IStackFrame> frames;
+ private List<RubyStackFrame> frames;
public FramesReader(XmlPullParser xpp) {
super(xpp);
@@ -27,13 +27,19 @@
public RubyStackFrame[] readFrames(RubyThread thread) {
this.thread = thread;
- this.frames = new ArrayList<IStackFrame>();
+ this.frames = new ArrayList<RubyStackFrame>();
try {
this.read();
} catch (Exception ex) {
RdtDebugCorePlugin.log(ex);
return new RubyStackFrame[0];
}
+ Collections.sort(frames, new Comparator<RubyStackFrame>() {
+ public int compare(RubyStackFrame one, RubyStackFrame two) {
+ return Integer.valueOf(one.getIndex()).compareTo(Integer.valueOf(two.getIndex()));
+ }
+
+ });
RubyStackFrame[] frameArray = new RubyStackFrame[frames.size()];
frames.toArray(frameArray);
thread.setStackFrames(frameArray);
@@ -48,9 +54,10 @@
return true;
}
if (name.equals("frame")) {
- int line = Integer.parseInt(xpp.getAttributeValue("", "line"));
+ int line = Integer.parseInt(xpp.getAttributeValue("", "line"));
+ int index = Integer.parseInt(xpp.getAttributeValue("", "no"));
String file = xpp.getAttributeValue("", "file");
- this.frames.add(new RubyStackFrame(thread, file, line, index++));
+ this.frames.add(new RubyStackFrame(thread, file, line, index));
return true;
}
return false;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-18 15:55:30
|
Revision: 2779
http://svn.sourceforge.net/rubyeclipse/?rev=2779&view=rev
Author: cawilliams
Date: 2007-07-18 08:55:28 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
fix broken test and test plugin
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core.tests/build.properties
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_ClassicDebuggerCommunicationTest.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.core.tests/META-INF/
trunk/org.rubypeople.rdt.debug.core.tests/META-INF/MANIFEST.MF
Removed Paths:
-------------
trunk/org.rubypeople.rdt.debug.core.tests/plugin.xml
Added: trunk/org.rubypeople.rdt.debug.core.tests/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/META-INF/MANIFEST.MF (rev 0)
+++ trunk/org.rubypeople.rdt.debug.core.tests/META-INF/MANIFEST.MF 2007-07-18 15:55:28 UTC (rev 2779)
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: RDT Debug Core Tests
+Bundle-SymbolicName: org.rubypeople.rdt.debug.core.tests
+Bundle-Version: 0.0.0
+Bundle-ClassPath: rdtdebugcoretests.jar
+Bundle-Activator: org.rubypeople.rdt.debug.core.tests.RdtDebugTestsPlugin
+Bundle-Vendor: RubyPeople
+Bundle-Localization: plugin
+Export-Package: org.rubypeople.rdt.debug.core.tests
+Require-Bundle: org.junit,
+ org.rubypeople.rdt.debug.core,
+ org.eclipse.debug.core,
+ org.kxml2,
+ org.eclipse.core.resources,
+ org.rubypeople.rdt.launching,
+ org.eclipse.core.runtime,
+ org.rubypeople.rdt.core,
+ org.rubypeople.eclipse.testutils
+Eclipse-LazyStart: true
Property changes on: trunk/org.rubypeople.rdt.debug.core.tests/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.debug.core.tests/build.properties
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/build.properties 2007-07-18 15:46:32 UTC (rev 2778)
+++ trunk/org.rubypeople.rdt.debug.core.tests/build.properties 2007-07-18 15:55:28 UTC (rev 2779)
@@ -1,3 +1,5 @@
source.rdtdebugcoretests.jar = src/
bin.includes = rdtdebugcoretests.jar,\
- plugin.xml
+ plugin.xml,\
+ META-INF/,\
+ ruby/
Deleted: trunk/org.rubypeople.rdt.debug.core.tests/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/plugin.xml 2007-07-18 15:46:32 UTC (rev 2778)
+++ trunk/org.rubypeople.rdt.debug.core.tests/plugin.xml 2007-07-18 15:55:28 UTC (rev 2779)
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.rubypeople.rdt.debug.core.tests"
- name="RDT Debug Core Tests"
- version="0.0.0"
- provider-name="RubyPeople"
- class="org.rubypeople.rdt.debug.core.tests.RdtDebugTestsPlugin">
-
- <runtime>
- <library name="rdtdebugcoretests.jar">
- <export name="*"/>
- </library>
- </runtime>
-
- <requires>
- <import plugin="org.junit"/>
- <import plugin="org.rubypeople.rdt.debug.core"/>
- <import plugin="org.eclipse.debug.core"/>
- <import plugin="org.kxml2"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.rubypeople.rdt.launching"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.rubypeople.rdt.core"/>
- <import plugin="org.rubypeople.eclipse.testutils"/>
- </requires>
-
-</plugin>
Modified: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_ClassicDebuggerCommunicationTest.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_ClassicDebuggerCommunicationTest.java 2007-07-18 15:46:32 UTC (rev 2778)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_ClassicDebuggerCommunicationTest.java 2007-07-18 15:55:28 UTC (rev 2779)
@@ -72,7 +72,7 @@
}
public void startRubyProcess() throws Exception {
- String cmd = FTC_ClassicDebuggerCommunicationTest.RUBY_INTERPRETER + " -I" + createIncludeDir() + " -I" + getTmpDir().replace('\\', '/') + " -reclipseDebugVerbose.rb " + getRubyTestFilename();
+ String cmd = FTC_ClassicDebuggerCommunicationTest.RUBY_INTERPRETER + " -I" + createIncludeDir() + " -I" + getTmpDir().replace('\\', '/') + " -rclassic-debug-verbose.rb " + getRubyTestFilename();
System.out.println("Starting: " + cmd);
process = Runtime.getRuntime().exec(cmd);
rubyStderrRedirectorThread = new OutputRedirectorThread(process.getErrorStream());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-18 15:46:42
|
Revision: 2778
http://svn.sourceforge.net/rubyeclipse/?rev=2778&view=rev
Author: cawilliams
Date: 2007-07-18 08:46:32 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
convert to plugin project
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core.tests/.project
Modified: trunk/org.rubypeople.rdt.debug.core.tests/.project
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/.project 2007-07-18 15:45:10 UTC (rev 2777)
+++ trunk/org.rubypeople.rdt.debug.core.tests/.project 2007-07-18 15:46:32 UTC (rev 2778)
@@ -13,8 +13,19 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-18 15:45:22
|
Revision: 2777
http://svn.sourceforge.net/rubyeclipse/?rev=2777&view=rev
Author: cawilliams
Date: 2007-07-18 08:45:10 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.properties
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2007-07-18 15:37:42 UTC (rev 2776)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-07-18 15:45:10 UTC (rev 2777)
@@ -131,6 +131,12 @@
ActionDefinition.openEditor.name= Open Declaration
ActionDefinition.openEditor.description= Open an editor on the selected element
+ActionDefinition.show.outline.name= Quick Outline
+ActionDefinition.show.outline.description= Show the quick outline for the editor input
+
+ActionDefinition.open.structure.name= Open Structure
+ActionDefinition.open.structure.description= Show the structure of the selected element
+
scope.rubyEditor.name=Ruby Editor
scope.rubyEditor.description=Ruby Editor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-18 15:40:49
|
Revision: 2776
http://svn.sourceforge.net/rubyeclipse/?rev=2776&view=rev
Author: cawilliams
Date: 2007-07-18 08:37:42 -0700 (Wed, 18 Jul 2007)
Log Message:
-----------
fix looksLikeTertiaryConditional to handle bad offsets
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-07-18 15:37:12 UTC (rev 2775)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-07-18 15:37:42 UTC (rev 2776)
@@ -169,8 +169,14 @@
private boolean looksLikeTertiaryConditionalWithNoSpaces() {
if (fTokenLength > 1) return false;
- char c = fContents.charAt((fOffset - origOffset) - 1);
- return !Character.isWhitespace(c) && Character.isUnicodeIdentifierPart(c);
+ int index = (fOffset - origOffset) - 1;
+ if (index < 0) return false;
+ try {
+ char c = fContents.charAt(index);
+ return !Character.isWhitespace(c) && Character.isUnicodeIdentifierPart(c);
+ } catch (RuntimeException e) {
+ return false;
+ }
}
private boolean shouldReturnDefault(int i) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-17 21:14:48
|
Revision: 2774
http://svn.sourceforge.net/rubyeclipse/?rev=2774&view=rev
Author: cawilliams
Date: 2007-07-17 14:14:46 -0700 (Tue, 17 Jul 2007)
Log Message:
-----------
when loading local gems and notifying listeners, iterate over a copy of the listeners to avoid concurrent modification exceptions (if listeners as a result of the notification the remove themselves)
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-07-17 18:55:52 UTC (rev 2773)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-07-17 21:14:46 UTC (rev 2774)
@@ -671,12 +671,12 @@
}
isInitialized = true;
synchronized (listeners) {
- for (GemListener listener : listeners) {
+ for (GemListener listener : new ArrayList<GemListener>(listeners)) {
listener.managerInitialized();
}
}
synchronized (listeners) {
- for (GemListener listener : listeners) {
+ for (GemListener listener : new ArrayList<GemListener>(listeners)) {
listener.gemsRefreshed();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-07-17 18:55:56
|
Revision: 2773
http://svn.sourceforge.net/rubyeclipse/?rev=2773&view=rev
Author: cawilliams
Date: 2007-07-17 11:55:52 -0700 (Tue, 17 Jul 2007)
Log Message:
-----------
whenever running anything, log the command line as info.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingPlugin.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractVMRunner.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingPlugin.java 2007-07-17 16:42:38 UTC (rev 2772)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/LaunchingPlugin.java 2007-07-17 18:55:52 UTC (rev 2773)
@@ -849,4 +849,8 @@
return null;
}
}
+
+ public static void info(String string) {
+ log(new Status(IStatus.INFO, PLUGIN_ID, -1, string, null));
+ }
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractVMRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractVMRunner.java 2007-07-17 16:42:38 UTC (rev 2772)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractVMRunner.java 2007-07-17 18:55:52 UTC (rev 2773)
@@ -22,6 +22,7 @@
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IProcess;
import org.rubypeople.rdt.internal.launching.LaunchingMessages;
+import org.rubypeople.rdt.internal.launching.LaunchingPlugin;
/**
* Abstract implementation of a VM runner.
@@ -67,7 +68,7 @@
* @see DebugPlugin#exec(String[], File, String[])
*/
protected Process exec(String[] cmdLine, File workingDirectory, String[] envp) throws CoreException {
-// LaunchingPlugin.debug("Starting: " + getCmdLineAsString(cmdLine)) ;
+ LaunchingPlugin.info("Starting: " + getCmdLineAsString(cmdLine)) ;
return DebugPlugin.exec(cmdLine, workingDirectory, envp);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|