|
From: Christopher W. <caw...@us...> - 2006-03-30 03:09:12
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv441/src/org/rubypeople/rdt/internal/ui/browsing Modified Files: MembersView.java RubyBrowsingPart.java RubyBrowsingContentProvider.java TypesView.java ProjectsView.java Added Files: RubyBrowsingMessages.java RubyBrowsingMessages.properties PatchedOpenInNewWindowAction.java Log Message: Index: TypesView.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/TypesView.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TypesView.java 25 Mar 2006 02:37:43 -0000 1.1 --- TypesView.java 30 Mar 2006 03:09:01 -0000 1.2 *************** *** 6,9 **** --- 6,10 ---- import org.rubypeople.rdt.core.IRubyScript; import org.rubypeople.rdt.core.IType; + import org.rubypeople.rdt.ui.PreferenceConstants; public class TypesView extends RubyBrowsingPart { *************** *** 21,24 **** --- 22,29 ---- } + protected String getLinkToEditorKey() { + return PreferenceConstants.LINK_BROWSING_TYPES_TO_EDITOR; + } + /** * Finds the element which has to be selected in this part. --- NEW FILE: RubyBrowsingMessages.properties --- ############################################################################### # 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 ############################################################################### RubyBrowsingPart_toolTip= Working Set: {0} RubyBrowsingPart_toolTip2= {0} - Working Set: {1} LexicalSortingAction_label= Sort LexicalSortingAction_tooltip= Sort LexicalSortingAction_description= Enable Sorting # the first argument is the string to which the second one is appended StatusBar_concat= {0}, {1} Index: RubyBrowsingPart.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/RubyBrowsingPart.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RubyBrowsingPart.java 25 Mar 2006 02:37:43 -0000 1.1 --- RubyBrowsingPart.java 30 Mar 2006 03:09:01 -0000 1.2 *************** *** 10,23 **** --- 10,35 ---- import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; + import org.eclipse.jface.action.IAction; + import org.eclipse.jface.action.IMenuManager; + import org.eclipse.jface.action.IToolBarManager; + import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.IContentProvider; + import org.eclipse.jface.viewers.IOpenListener; [...1270 lines suppressed...] + protected IRubyElement getElementAt(IEditorInput input, int offset) { + IWorkingCopyManager manager= RubyPlugin.getDefault().getWorkingCopyManager(); + IRubyScript unit= manager.getWorkingCopy(input); + if (unit != null) + try { + if (unit.isConsistent()) + return unit.getElementAt(offset); + else { + /* + * XXX: We should set the selection later when the + * CU is reconciled. + * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=51290 + */ + } + } catch (RubyModelException ex) { + // fall through + } + return null; + } } --- NEW FILE: PatchedOpenInNewWindowAction.java --- /******************************************************************************* * 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.browsing; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.actions.OpenInNewWindowAction; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.RubyCore; /* * XXX: This is a workaround for: http://dev.eclipse.org/bugs/show_bug.cgi?id=13070 * This class can be removed once the bug is fixed. * * @since 2.0 */ public class PatchedOpenInNewWindowAction extends OpenInNewWindowAction { private IWorkbenchWindow fWorkbenchWindow; public PatchedOpenInNewWindowAction(IWorkbenchWindow window, IAdaptable input) { super(window, input); fWorkbenchWindow= window; } public void run() { RubyBrowsingPerspectiveFactory.setInputFromAction(getSelectedRubyElement()); try { super.run(); } finally { RubyBrowsingPerspectiveFactory.setInputFromAction(null); } } private IRubyElement getSelectedRubyElement() { if (fWorkbenchWindow.getActivePage() != null) { ISelection selection= fWorkbenchWindow.getActivePage().getSelection(); if (selection instanceof IStructuredSelection && !selection.isEmpty()) { Object selectedElement= ((IStructuredSelection)selection).getFirstElement(); if (selectedElement instanceof IRubyElement) return (IRubyElement)selectedElement; if (!(selectedElement instanceof IRubyElement) && selectedElement instanceof IAdaptable) return (IRubyElement)((IAdaptable)selectedElement).getAdapter(IRubyElement.class); else if (selectedElement instanceof IWorkspace) return RubyCore.create(((IWorkspace)selectedElement).getRoot()); } } return null; } } Index: MembersView.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/MembersView.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MembersView.java 25 Mar 2006 02:37:43 -0000 1.1 --- MembersView.java 30 Mar 2006 03:09:01 -0000 1.2 *************** *** 1,4 **** --- 1,13 ---- package org.rubypeople.rdt.internal.ui.browsing; + import org.eclipse.jface.action.IToolBarManager; + import org.eclipse.jface.util.IPropertyChangeListener; + import org.eclipse.jface.util.PropertyChangeEvent; + import org.eclipse.jface.viewers.DoubleClickEvent; + import org.eclipse.jface.viewers.IDoubleClickListener; + import org.eclipse.jface.viewers.IStructuredSelection; + import org.eclipse.jface.viewers.StructuredViewer; + import org.eclipse.jface.viewers.TreeViewer; + import org.eclipse.swt.widgets.Composite; import org.rubypeople.rdt.core.IImportContainer; import org.rubypeople.rdt.core.IImportDeclaration; *************** *** 8,14 **** import org.rubypeople.rdt.core.IType; import org.rubypeople.rdt.core.RubyModelException; ! public class MembersView extends RubyBrowsingPart { /** * Answers if the given <code>element</code> is a valid --- 17,57 ---- import org.rubypeople.rdt.core.IType; import org.rubypeople.rdt.core.RubyModelException; + import org.rubypeople.rdt.internal.ui.RubyPlugin; + import org.rubypeople.rdt.internal.ui.actions.LexicalSortingAction; + import org.rubypeople.rdt.internal.ui.preferences.MembersOrderPreferenceCache; + import org.rubypeople.rdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; + import org.rubypeople.rdt.internal.ui.viewsupport.RubyUILabelProvider; + import org.rubypeople.rdt.ui.PreferenceConstants; + import org.rubypeople.rdt.ui.RubyElementLabels; + import org.rubypeople.rdt.ui.RubyUI; + import org.rubypeople.rdt.ui.actions.MemberFilterActionGroup; ! public class MembersView extends RubyBrowsingPart implements IPropertyChangeListener { + private MemberFilterActionGroup fMemberFilterActionGroup; + + public MembersView() { + // setHasWorkingSetFilter(false); + setHasCustomSetFilter(true); + RubyPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); + } + + /** + * Creates and returns the label provider for this part. + * + * @return the label provider + * @see org.eclipse.jface.viewers.ILabelProvider + */ + protected RubyUILabelProvider createLabelProvider() { + return new AppearanceAwareLabelProvider( + AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | RubyElementLabels.M_PARAMETER_NAMES, + AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS + ); + } + + protected String getLinkToEditorKey() { + return PreferenceConstants.LINK_BROWSING_MEMBERS_TO_EDITOR; + } + /** * Answers if the given <code>element</code> is a valid *************** *** 50,53 **** --- 93,108 ---- return false; } + + protected void hookViewerListeners() { + super.hookViewerListeners(); + getViewer().addDoubleClickListener(new IDoubleClickListener() { + public void doubleClick(DoubleClickEvent event) { + TreeViewer viewer= (TreeViewer)getViewer(); + Object element= ((IStructuredSelection)event.getSelection()).getFirstElement(); + if (viewer.isExpandable(element)) + viewer.setExpandedState(element, !viewer.getExpandedState(element)); + } + }); + } /** *************** *** 135,137 **** --- 190,230 ---- } + /* (non-Javadoc) + * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent event) { + if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) { + getViewer().refresh(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#dispose() + */ + public void dispose() { + if (fMemberFilterActionGroup != null) { + fMemberFilterActionGroup.dispose(); + fMemberFilterActionGroup= null; + } + super.dispose(); + RubyPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); + } + + /** + * Creates the the viewer of this part. + * + * @param parent the parent for the viewer + */ + protected StructuredViewer createViewer(Composite parent) { + StructuredViewer viewer = super.createViewer(parent); + fMemberFilterActionGroup= new MemberFilterActionGroup(viewer, RubyUI.ID_MEMBERS_VIEW); + return viewer; + } + + protected void fillToolBar(IToolBarManager tbm) { + tbm.add(new LexicalSortingAction(getViewer(), RubyUI.ID_MEMBERS_VIEW)); + fMemberFilterActionGroup.contributeToToolBar(tbm); + super.fillToolBar(tbm); + } + } Index: RubyBrowsingContentProvider.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/RubyBrowsingContentProvider.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RubyBrowsingContentProvider.java 25 Mar 2006 02:37:43 -0000 1.1 --- RubyBrowsingContentProvider.java 30 Mar 2006 03:09:01 -0000 1.2 *************** *** 8,18 **** --- 8,25 ---- import org.eclipse.core.resources.IResource; + import org.eclipse.jface.viewers.AbstractTreeViewer; + import org.eclipse.jface.viewers.IBasicPropertyConstants; + import org.eclipse.jface.viewers.ListViewer; import org.eclipse.jface.viewers.StructuredViewer; + import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; + import org.rubypeople.rdt.core.ElementChangedEvent; + import org.rubypeople.rdt.core.IElementChangedListener; import org.rubypeople.rdt.core.IImportContainer; import org.rubypeople.rdt.core.IParent; import org.rubypeople.rdt.core.IRubyElement; + import org.rubypeople.rdt.core.IRubyElementDelta; import org.rubypeople.rdt.core.IRubyProject; import org.rubypeople.rdt.core.IRubyScript; *************** *** 21,28 **** import org.rubypeople.rdt.core.RubyCore; import org.rubypeople.rdt.core.RubyModelException; import org.rubypeople.rdt.ui.StandardRubyElementContentProvider; public class RubyBrowsingContentProvider extends ! StandardRubyElementContentProvider { private RubyBrowsingPart fBrowsingPart; --- 28,37 ---- import org.rubypeople.rdt.core.RubyCore; 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.ui.StandardRubyElementContentProvider; public class RubyBrowsingContentProvider extends ! StandardRubyElementContentProvider implements IElementChangedListener { private RubyBrowsingPart fBrowsingPart; *************** *** 36,41 **** fBrowsingPart = browsingPart; fViewer = fBrowsingPart.getViewer(); ! // TODO Add element change listener ! // RubyCore.addElementChangedListener(this); } --- 45,49 ---- fBrowsingPart = browsingPart; fViewer = fBrowsingPart.getViewer(); ! RubyCore.addElementChangedListener(this); } *************** *** 158,168 **** } ! /* ! * (non-Javadoc) Method declared on IContentProvider. */ public void dispose() { super.dispose(); ! // TODO Listen for element changes ! // RubyCore.removeElementChangedListener(this); } --- 166,175 ---- } ! /* (non-Javadoc) ! * Method declared on IContentProvider. */ public void dispose() { super.dispose(); ! RubyCore.removeElementChangedListener(this); } *************** *** 194,196 **** --- 201,449 ---- } + /* (non-Javadoc) + * Method declared on IElementChangedListener. + */ + public void elementChanged(final ElementChangedEvent event) { + try { + processDelta(event.getDelta()); + } catch(RubyModelException e) { + RubyPlugin.log(e.getStatus()); + } + } + + /** + * Processes a delta recursively. When more than two children are affected the + * tree is fully refreshed starting at this node. The delta is processed in the + * current thread but the viewer updates are posted to the UI thread. + */ + protected void processDelta(IRubyElementDelta delta) throws RubyModelException { + int kind= delta.getKind(); + int flags= delta.getFlags(); + final IRubyElement element= delta.getElement(); + final boolean isElementValidForView= fBrowsingPart.isValidElement(element); + + if (!getProvideWorkingCopy() && element instanceof IRubyScript && ((IRubyScript)element).isWorkingCopy()) + return; + + if (element != null && element.getElementType() == IRubyElement.SCRIPT && !isOnClassPath((IRubyScript)element)) + return; + + // handle open and closing of a solution or project + if (((flags & IRubyElementDelta.F_CLOSED) != 0) || ((flags & IRubyElementDelta.F_OPENED) != 0)) { + postRefresh(null); + return; + } + + if (kind == IRubyElementDelta.REMOVED) { + Object parent= internalGetParent(element); + if (isElementValidForView) { + if (element instanceof IRubyScript && !((IRubyScript)element).isWorkingCopy()) { + postRefresh(null); + } else if (element instanceof IRubyScript && ((IRubyScript)element).isWorkingCopy()) { + if (getProvideWorkingCopy()) + postRefresh(null); + } else if (parent instanceof IRubyScript && getProvideWorkingCopy() && !((IRubyScript)parent).isWorkingCopy()) { + if (element instanceof IRubyScript && ((IRubyScript)element).isWorkingCopy()) { + // working copy removed from system - refresh + postRefresh(null); + } + } else if (element instanceof IRubyScript && ((IRubyScript)element).isWorkingCopy() && parent != null && parent.equals(fInput)) + // closed editor - removing working copy + postRefresh(null); + else + postRemove(element); + } + + if (fBrowsingPart.isAncestorOf(element, fInput)) { + if (element instanceof IRubyScript && ((IRubyScript)element).isWorkingCopy()) { + postAdjustInputAndSetSelection(RubyModelUtil.toOriginal((IRubyElement) fInput)); + } else + postAdjustInputAndSetSelection(null); + } + + if (fInput != null && fInput.equals(element)) + postRefresh(null); + + + return; + } + if (kind == IRubyElementDelta.ADDED && delta.getMovedFromElement() != null && element instanceof IRubyScript) + return; + + if (kind == IRubyElementDelta.ADDED) { + if (isElementValidForView) { + Object parent= internalGetParent(element); + if (element instanceof IRubyScript && !((IRubyScript)element).isWorkingCopy()) { + postAdd(parent, ((IRubyScript)element).getTypes()); + } else if (parent instanceof IRubyScript && getProvideWorkingCopy() && !((IRubyScript)parent).isWorkingCopy()) { + // do nothing + } else if (element instanceof IRubyScript && ((IRubyScript)element).isWorkingCopy()) { + // new working copy comes to live + postRefresh(null); + } else + postAdd(parent, element); + } else if (fInput == null) { + IRubyElement newInput= fBrowsingPart.findInputForRubyElement(element); + if (newInput != null) + postAdjustInputAndSetSelection(element); + } else if (element instanceof IType && fBrowsingPart.isValidInput(element)) { + IRubyElement cu1= element.getAncestor(IRubyElement.SCRIPT); + IRubyElement cu2= ((IRubyElement)fInput).getAncestor(IRubyElement.SCRIPT); + if (cu1 != null && cu2 != null && cu1.equals(cu2)) + postAdjustInputAndSetSelection(element); + } + return; + } + + if (kind == IRubyElementDelta.CHANGED) { + if (fInput != null && fInput.equals(element) && (flags & IRubyElementDelta.F_CHILDREN) != 0 && (flags & IRubyElementDelta.F_FINE_GRAINED) != 0) { + postRefresh(null, true); + return; + } + if (isElementValidForView && (flags & IRubyElementDelta.F_MODIFIERS) != 0) { + postUpdateIcon(element); + } + } + + if (isClassPathChange(delta)) + // throw the towel and do a full refresh + postRefresh(null); + + + + IRubyElementDelta[] affectedChildren= delta.getAffectedChildren(); + for (int i= 0; i < affectedChildren.length; i++) { + processDelta(affectedChildren[i]); + } + } + + private boolean isOnClassPath(IRubyScript element) throws RubyModelException { + IRubyProject project= element.getRubyProject(); + if (project == null || !project.exists()) + return false; + return project.isOnLoadpath(element); + } + + /** + * Updates the package icon + */ + private void postUpdateIcon(final IRubyElement element) { + postRunnable(new Runnable() { + public void run() { + Control ctrl= fViewer.getControl(); + if (ctrl != null && !ctrl.isDisposed()) + fViewer.update(element, new String[]{IBasicPropertyConstants.P_IMAGE}); + } + }); + } + + private void postRefresh(final Object root, final boolean updateLabels) { + postRunnable(new Runnable() { + public void run() { + Control ctrl= fViewer.getControl(); + if (ctrl != null && !ctrl.isDisposed()) + fViewer.refresh(root, updateLabels); + } + }); + } + + private void postRefresh(final Object root) { + postRefresh(root, false); + } + + private void postAdd(final Object parent, final Object element) { + postAdd(parent, new Object[] {element}); + } + + private void postAdd(final Object parent, final Object[] elements) { + if (elements == null || elements.length <= 0) + return; + + postRunnable(new Runnable() { + public void run() { + Control ctrl= fViewer.getControl(); + if (ctrl != null && !ctrl.isDisposed()) { + Object[] newElements= getNewElements(elements); + if (fViewer instanceof AbstractTreeViewer) { + if (fViewer.testFindItem(parent) == null) { + Object root= ((AbstractTreeViewer)fViewer).getInput(); + if (root != null) + ((AbstractTreeViewer)fViewer).add(root, newElements); + } + else + ((AbstractTreeViewer)fViewer).add(parent, newElements); + } + else if (fViewer instanceof ListViewer) + ((ListViewer)fViewer).add(newElements); + else if (fViewer instanceof TableViewer) + ((TableViewer)fViewer).add(newElements); + if (fViewer.testFindItem(elements[0]) != null) + fBrowsingPart.adjustInputAndSetSelection(elements[0]); + } + } + }); + } + + private Object[] getNewElements(Object[] elements) { + int elementsLength= elements.length; + ArrayList result= new ArrayList(elementsLength); + for (int i= 0; i < elementsLength; i++) { + Object element= elements[i]; + if (fViewer.testFindItem(element) == null) + result.add(element); + } + return result.toArray(); + } + + private void postRemove(final Object element) { + postRemove(new Object[] {element}); + } + + private void postRemove(final Object[] elements) { + if (elements.length <= 0) + return; + + postRunnable(new Runnable() { + public void run() { + Control ctrl= fViewer.getControl(); + if (ctrl != null && !ctrl.isDisposed()) { + if (fViewer instanceof AbstractTreeViewer) + ((AbstractTreeViewer)fViewer).remove(elements); + else if (fViewer instanceof ListViewer) + ((ListViewer)fViewer).remove(elements); + else if (fViewer instanceof TableViewer) + ((TableViewer)fViewer).remove(elements); + } + } + }); + } + + private void postAdjustInputAndSetSelection(final Object element) { + postRunnable(new Runnable() { + public void run() { + Control ctrl= fViewer.getControl(); + if (ctrl != null && !ctrl.isDisposed()) { + ctrl.setRedraw(false); + fBrowsingPart.adjustInputAndSetSelection(element); + ctrl.setRedraw(true); + } + } + }); + } + + private void postRunnable(final Runnable r) { + Control ctrl= fViewer.getControl(); + if (ctrl != null && !ctrl.isDisposed()) { + fBrowsingPart.setProcessSelectionEvents(false); + try { + if (isDisplayThread() && fReadsInDisplayThread == 0) + ctrl.getDisplay().syncExec(r); + else + ctrl.getDisplay().asyncExec(r); + } finally { + fBrowsingPart.setProcessSelectionEvents(true); + } + } + } + } --- NEW FILE: RubyBrowsingMessages.java --- /******************************************************************************* * 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.browsing; import org.eclipse.osgi.util.NLS; /** * Helper class to get NLSed messages. */ public final class RubyBrowsingMessages extends NLS { private static final String BUNDLE_NAME= RubyBrowsingMessages.class.getName(); private RubyBrowsingMessages() { // Do not instantiate } public static String RubyBrowsingPart_toolTip; public static String RubyBrowsingPart_toolTip2; public static String LexicalSortingAction_label; public static String LexicalSortingAction_tooltip; public static String LexicalSortingAction_description; public static String StatusBar_concat; static { NLS.initializeMessages(BUNDLE_NAME, RubyBrowsingMessages.class); } } Index: ProjectsView.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/ProjectsView.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProjectsView.java 28 Mar 2006 23:08:08 -0000 1.2 --- ProjectsView.java 30 Mar 2006 03:09:01 -0000 1.3 *************** *** 1,5 **** --- 1,9 ---- package org.rubypeople.rdt.internal.ui.browsing; + import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IContentProvider; + import org.eclipse.jface.viewers.IDoubleClickListener; + import org.eclipse.jface.viewers.IStructuredSelection; + import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.part.IShowInTargetList; *************** *** 9,12 **** --- 13,17 ---- import org.rubypeople.rdt.core.RubyCore; import org.rubypeople.rdt.internal.ui.RubyPlugin; + import org.rubypeople.rdt.ui.PreferenceConstants; import org.rubypeople.rdt.ui.RubyUI; *************** *** 28,31 **** --- 33,40 ---- } + protected String getLinkToEditorKey() { + return PreferenceConstants.LINK_BROWSING_PROJECTS_TO_EDITOR; + } + /** * Answer the property defined by key. *************** *** 42,45 **** --- 51,69 ---- return super.getAdapter(key); } + + /** + * Adds additional listeners to this view. + */ + protected void hookViewerListeners() { + super.hookViewerListeners(); + getViewer().addDoubleClickListener(new IDoubleClickListener() { + public void doubleClick(DoubleClickEvent event) { + TreeViewer viewer= (TreeViewer)getViewer(); + Object element= ((IStructuredSelection)event.getSelection()).getFirstElement(); + if (viewer.isExpandable(element)) + viewer.setExpandedState(element, !viewer.getExpandedState(element)); + } + }); + } /** |