|
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.
|