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: Christopher W. <caw...@us...> - 2006-03-29 22:46:24
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30360/src/org/rubypeople/rdt/internal/core Modified Files: RubyProject.java Log Message: add isOnLoadPath method (default to always true for now) Index: RubyProject.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** RubyProject.java 25 Mar 2006 02:27:36 -0000 1.20 --- RubyProject.java 29 Mar 2006 22:46:22 -0000 1.21 *************** *** 719,722 **** --- 719,727 ---- return ((RubyProjectElementInfo) getElementInfo()).getNonRubyResources(this); } + + public boolean isOnLoadpath(IRubyScript element) { + // TODO We cheat and assume all scripts are on loadpath. Thsi may not be true. We shoudl check! + return true; + } } |
|
From: Christopher W. <caw...@us...> - 2006-03-29 22:46:24
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30360/src/org/rubypeople/rdt/core Modified Files: IRubyProject.java Log Message: add isOnLoadPath method (default to always true for now) Index: IRubyProject.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IRubyProject.java 25 Mar 2006 02:27:36 -0000 1.6 --- IRubyProject.java 29 Mar 2006 22:46:21 -0000 1.7 *************** *** 108,110 **** --- 108,112 ---- public abstract Object[] getNonRubyResources() throws RubyModelException; + public abstract boolean isOnLoadpath(IRubyScript element); + } \ No newline at end of file |
|
From: Christopher W. <caw...@us...> - 2006-03-29 22:45:27
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29746a/src/org/rubypeople/rdt/core Modified Files: RubyCore.java Log Message: use single source of record for ruby like files Index: RubyCore.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** RubyCore.java 25 Mar 2006 02:27:36 -0000 1.31 --- RubyCore.java 29 Mar 2006 22:45:23 -0000 1.32 *************** *** 51,54 **** --- 51,55 ---- import org.rubypeople.rdt.internal.core.symbols.ISymbolFinder; import org.rubypeople.rdt.internal.core.symbols.SymbolIndex; + import org.rubypeople.rdt.internal.core.util.Util; public class RubyCore extends Plugin { *************** *** 365,375 **** project = create(file.getProject()); } ! // FIXME Use the associations to determine if we should create the file! ! for (int i = 0; i < IRubyScript.EXTENSIONS.length; i++) { ! if (IRubyScript.EXTENSIONS[i].equalsIgnoreCase(file.getFileExtension())) { ! RubyScript script = new RubyScript((RubyProject) project, file, file.getName(), ! DefaultWorkingCopyOwner.PRIMARY); ! return script; ! } } return null; --- 366,372 ---- project = create(file.getProject()); } ! if(isRubyLikeFileName(file.getName())) { ! return new RubyScript((RubyProject) project, file, file.getName(), ! DefaultWorkingCopyOwner.PRIMARY); } return null; *************** *** 614,618 **** public static boolean isRubyLikeFileName(String name) { ! return name.endsWith(".rb") || name.endsWith(".rbw"); } } \ No newline at end of file --- 611,615 ---- public static boolean isRubyLikeFileName(String name) { ! return Util.isRubyLikeFileName(name); } } \ No newline at end of file |
|
From: Christopher W. <caw...@us...> - 2006-03-29 22:39:10
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25013 Modified Files: plugin.xml Log Message: refer to definitive list in plugin.properties for ruby filenames/extensions Index: plugin.xml =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/plugin.xml,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** plugin.xml 10 Feb 2006 18:34:30 -0000 1.37 --- plugin.xml 29 Mar 2006 22:39:06 -0000 1.38 *************** *** 94,99 **** <content-type base-type="org.eclipse.core.runtime.text" ! file-extensions="rb,rbw,cgi,fcgi,rake" ! file-names="Rakefile,generate,profiler,console,destroy,benchmarker,breakpointer,runner,server,rails,tracker,update,listener,breakpointer_for_gem,switchtower,switchtower_for_gem" id="rubySource" name="%rubySourceName" --- 94,99 ---- <content-type base-type="org.eclipse.core.runtime.text" ! file-extensions="%rubySource.extension" ! file-names="%rubySource.filenames" id="rubySource" name="%rubySourceName" |
|
From: Christopher W. <caw...@us...> - 2006-03-29 22:38:41
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24637 Modified Files: plugin.properties Log Message: add definitive list of ruby extensions and filenames for use in core plugin Index: plugin.properties =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/plugin.properties,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** plugin.properties 22 Jul 2005 03:45:15 -0000 1.6 --- plugin.properties 29 Mar 2006 22:38:39 -0000 1.7 *************** *** 12,13 **** --- 12,17 ---- transientRubyProblemName=Transient Ruby Problem rubySourceName=Ruby Source File + + rubySource.extension=rb,rbw,cgi,fcgi,rake,rjs,rxml + rubySource.filenames=Rakefile,generate,profiler,console,server,reaper,spawner,spinner,about,destroy,plugin,benchmarker,breakpointer,runner,server,rails,tracker,update,listener,breakpointer_for_gem + |
|
From: Christopher W. <caw...@us...> - 2006-03-29 22:38:13
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24171/src/org/rubypeople/rdt/internal/core/util Modified Files: Util.java Log Message: check content types for dtermining if a file is ruby like. Use full filenames in addition to just extensions Index: Util.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Util.java 25 Mar 2006 02:27:35 -0000 1.8 --- Util.java 29 Mar 2006 22:38:00 -0000 1.9 *************** *** 38,41 **** --- 38,42 ---- private static boolean ENABLE_RUBY_LIKE_EXTENSIONS = true; private static char[][] RUBY_LIKE_EXTENSIONS; + private static char[][] RUBY_LIKE_FILENAMES; private final static String bundleName = "org.rubypeople.rdt.internal.core.util.messages"; //$NON-NLS-1$ *************** *** 264,270 **** } ! public static boolean isRubyLikeFileName(String name) { ! return name.endsWith(".rb") || name.endsWith(".rbw"); ! } /** --- 265,281 ---- } ! /** ! * Returns true if the given name ends with one of the known ruby like extension. ! * (implementation is not creating extra strings) ! */ ! public final static boolean isRubyLikeFileName(String name) { ! if (name == null) return false; ! char[][] rubyFileNames = getRubyLikeFilenames(); ! for (int i = 0; i < rubyFileNames.length; i++) { ! char[] filename = rubyFileNames[i]; ! if(name.equals(new String(filename))) return true; ! } ! return indexOfRubyLikeExtension(name) != -1; ! } /** *************** *** 374,380 **** public static int indexOfRubyLikeExtension(String fileName) { int fileNameLength = fileName.length(); ! char[][] javaLikeExtensions = getRubyLikeExtensions(); ! extensions: for (int i = 0, length = javaLikeExtensions.length; i < length; i++) { ! char[] extension = javaLikeExtensions[i]; int extensionLength = extension.length; int extensionStart = fileNameLength - extensionLength; --- 385,391 ---- public static int indexOfRubyLikeExtension(String fileName) { int fileNameLength = fileName.length(); ! char[][] rubyLikeExtensions = getRubyLikeExtensions(); ! extensions: for (int i = 0, length = rubyLikeExtensions.length; i < length; i++) { ! char[] extension = rubyLikeExtensions[i]; int extensionLength = extension.length; int extensionStart = fileNameLength - extensionLength; *************** *** 398,406 **** // TODO (jerome) reenable once RDT UI supports other file extensions (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=71460) if (!ENABLE_RUBY_LIKE_EXTENSIONS) ! RUBY_LIKE_EXTENSIONS = new char[][] {"rb".toCharArray()}; else { ! IContentType javaContentType = Platform.getContentTypeManager().getContentType(RubyCore.RUBY_SOURCE_CONTENT_TYPE); ! String[] fileExtensions = javaContentType == null ? null : javaContentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); ! // note that file extensions contains "java" as it is defined in JDT Core's plugin.xml int length = fileExtensions == null ? 0 : fileExtensions.length; char[][] extensions = new char[length][]; --- 409,417 ---- // TODO (jerome) reenable once RDT UI supports other file extensions (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=71460) if (!ENABLE_RUBY_LIKE_EXTENSIONS) ! RUBY_LIKE_EXTENSIONS = new char[][] {"rb".toCharArray(), "rbw".toCharArray(), "rjs".toCharArray(), "rxml".toCharArray()}; else { ! IContentType rubyContentType = Platform.getContentTypeManager().getContentType(RubyCore.RUBY_SOURCE_CONTENT_TYPE); ! String[] fileExtensions = rubyContentType == null ? null : rubyContentType.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); ! // note that file extensions contains "ruby" as it is defined in RDT Core's plugin.xml int length = fileExtensions == null ? 0 : fileExtensions.length; char[][] extensions = new char[length][]; *************** *** 424,429 **** --- 435,478 ---- return RUBY_LIKE_EXTENSIONS; } + + /** + * Returns the registered Ruby like filenames. + */ + public static char[][] getRubyLikeFilenames() { + if (RUBY_LIKE_FILENAMES == null) { + IContentType rubyContentType = Platform.getContentTypeManager() + .getContentType(RubyCore.RUBY_SOURCE_CONTENT_TYPE); + String[] filenames = rubyContentType == null ? null + : rubyContentType + .getFileSpecs(IContentType.FILE_NAME_SPEC); + int length = filenames == null ? 0 : filenames.length; + names = new char[length][]; + SimpleWordSet knownExtensions = new SimpleWordSet(length); // used + // to + // ensure + // no + // duplicate + // names + names[0] = "Rakefile".toCharArray(); // ensure that "Rakefile" is first + knownExtensions.add(names[0]); + int index = 1; + for (int i = 0; i < length; i++) { + String fileExtension = filenames[i]; + char[] extension = fileExtension.toCharArray(); + if (!knownExtensions.includes(extension)) { + names[index++] = extension; + knownExtensions.add(extension); + } + } + if (index != length) + System.arraycopy(names, 0, names = new char[index][], + 0, index); + RUBY_LIKE_FILENAMES = names; + } + return RUBY_LIKE_FILENAMES; + } private static final int DEFAULT_READING_SIZE = 8192; + private static char[][] names; /** |
|
From: Christopher W. <caw...@us...> - 2006-03-28 23:15:51
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18162/src/org/rubypeople/rdt/ui/actions Added Files: OpenAction.java Log Message: start laying groundwork for the F3/Open action where users can easily navigate from text selections and menus with IRubyElements to the source. --- NEW FILE: OpenAction.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.ui.actions; import java.util.Iterator; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IStorage; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.OpenStrategy; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.IEditorStatusLine; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.ISourceReference; import org.rubypeople.rdt.core.RubyModelException; import org.rubypeople.rdt.internal.corext.util.Messages; import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds; import org.rubypeople.rdt.internal.ui.IRubyStatusConstants; import org.rubypeople.rdt.internal.ui.RubyPlugin; import org.rubypeople.rdt.internal.ui.actions.ActionMessages; import org.rubypeople.rdt.internal.ui.actions.ActionUtil; import org.rubypeople.rdt.internal.ui.actions.OpenActionUtil; import org.rubypeople.rdt.internal.ui.actions.SelectionConverter; import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor; import org.rubypeople.rdt.internal.ui.util.ExceptionHandler; /** * This action opens a Ruby editor on a Ruby element or file. * <p> * The action is applicable to selections containing elements of * type <code>ICompilationUnit</code>, <code>IMember</code> * or <code>IFile</code>. * * <p> * This class may be instantiated; it is not intended to be subclassed. * </p> * * @since 2.0 */ public class OpenAction extends SelectionDispatchAction { private RubyEditor fEditor; /** * Creates a new <code>OpenAction</code>. The action requires * that the selection provided by the site's selection provider is of type <code> * org.eclipse.jface.viewers.IStructuredSelection</code>. * * @param site the site providing context information for this action */ public OpenAction(IWorkbenchSite site) { super(site); setText(ActionMessages.OpenAction_label); setToolTipText(ActionMessages.OpenAction_tooltip); setDescription(ActionMessages.OpenAction_description); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.OPEN_ACTION); } /** * Note: This constructor is for internal use only. Clients should not call this constructor. * @param editor the Ruby editor */ public OpenAction(RubyEditor editor) { this(editor.getEditorSite()); fEditor= editor; setText(ActionMessages.OpenAction_declaration_label); setEnabled(SelectionConverter.canOperateOn(fEditor)); } /* (non-Rubydoc) * Method declared on SelectionDispatchAction. */ public void selectionChanged(ITextSelection selection) { } /* (non-Rubydoc) * Method declared on SelectionDispatchAction. */ public void selectionChanged(IStructuredSelection selection) { setEnabled(checkEnabled(selection)); } private boolean checkEnabled(IStructuredSelection selection) { if (selection.isEmpty()) return false; for (Iterator iter= selection.iterator(); iter.hasNext();) { Object element= iter.next(); if (element instanceof ISourceReference) continue; if (element instanceof IFile) continue; if (element instanceof IStorage) continue; return false; } return true; } /* (non-Rubydoc) * Method declared on SelectionDispatchAction. */ public void run(ITextSelection selection) { if (!ActionUtil.isProcessable(getShell(), fEditor)) return; try { IRubyElement element= SelectionConverter.codeResolve(fEditor, getShell(), getDialogTitle(), ActionMessages.OpenAction_select_element); if (element == null) { IEditorStatusLine statusLine= (IEditorStatusLine) fEditor.getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(true, ActionMessages.OpenAction_error_messageBadSelection, null); getShell().getDisplay().beep(); return; } IRubyElement input= SelectionConverter.getInput(fEditor); int type= element.getElementType(); if (type == IRubyElement.RUBY_PROJECT) element= input; run(new Object[] {element} ); } catch (RubyModelException e) { showError(e); } } /* (non-Rubydoc) * Method declared on SelectionDispatchAction. */ public void run(IStructuredSelection selection) { if (!checkEnabled(selection)) return; run(selection.toArray()); } /** * Note: this method is for internal use only. Clients should not call this method. * * @param elements the elements to process */ public void run(Object[] elements) { if (elements == null) return; for (int i= 0; i < elements.length; i++) { Object element= elements[i]; try { element= getElementToOpen(element); boolean activateOnOpen= fEditor != null ? true : OpenStrategy.activateOnOpen(); OpenActionUtil.open(element, activateOnOpen); } catch (RubyModelException e) { RubyPlugin.log(new Status(IStatus.ERROR, RubyPlugin.getPluginId(), IRubyStatusConstants.INTERNAL_ERROR, ActionMessages.OpenAction_error_message, e)); ErrorDialog.openError(getShell(), getDialogTitle(), ActionMessages.OpenAction_error_messageProblems, e.getStatus()); } catch (PartInitException x) { String name= null; if (element instanceof IRubyElement) { name= ((IRubyElement) element).getElementName(); } else if (element instanceof IStorage) { name= ((IStorage) element).getName(); } else if (element instanceof IResource) { name= ((IResource) element).getName(); } if (name != null) { MessageDialog.openError(getShell(), ActionMessages.OpenAction_error_messageProblems, Messages.format(ActionMessages.OpenAction_error_messageArgs, new String[] { name, x.getMessage() } )); } } } } /** * Note: this method is for internal use only. Clients should not call this method. * * @param object the element to open * @return the real element to open * @throws RubyModelException if an error occurs while accessing the Ruby model */ public Object getElementToOpen(Object object) throws RubyModelException { return object; } private String getDialogTitle() { return ActionMessages.OpenAction_error_title; } private void showError(CoreException e) { ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.OpenAction_error_message); } } |
|
From: Christopher W. <caw...@us...> - 2006-03-28 23:15:51
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18162/src/org/rubypeople/rdt/internal/ui/rubyeditor Added Files: EditorUtility.java Log Message: start laying groundwork for the F3/Open action where users can easily navigate from text selections and menus with IRubyElements to the source. --- NEW FILE: EditorUtility.java --- package org.rubypeople.rdt.internal.ui.rubyeditor; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.IAction; import org.eclipse.jface.text.Assert; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorSite; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.WorkspaceModifyOperation; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.ide.IGotoMarker; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; import org.eclipse.ui.texteditor.TextEditorAction; import org.rubypeople.rdt.core.IMember; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyScript; import org.rubypeople.rdt.core.ISourceRange; import org.rubypeople.rdt.core.ISourceReference; 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.PreferenceConstants; public class EditorUtility { /** * Opens a Java editor for an element (IJavaElement, IFile, IStorage...) * @return the IEditorPart or null if wrong element type or opening failed */ public static IEditorPart openInEditor(Object inputElement, boolean activate) throws RubyModelException, PartInitException { if (inputElement instanceof IFile) return openInEditor((IFile) inputElement, activate); IEditorInput input= getEditorInput(inputElement); if (input instanceof IFileEditorInput) { IFileEditorInput fileInput= (IFileEditorInput) input; return openInEditor(fileInput.getFile(), activate); } if (input != null) return openInEditor(input, getEditorID(input, inputElement), activate); return null; } private static IEditorPart openInEditor(IEditorInput input, String editorID, boolean activate) throws PartInitException { if (input != null) { IWorkbenchPage p= RubyPlugin.getActivePage(); if (p != null) { IEditorPart editorPart= p.openEditor(input, editorID, activate); initializeHighlightRange(editorPart); return editorPart; } } return null; } private static void initializeHighlightRange(IEditorPart editorPart) { if (editorPart instanceof ITextEditor) { IAction toggleAction= editorPart.getEditorSite().getActionBars().getGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY); boolean enable= toggleAction != null; if (enable && editorPart instanceof RubyEditor) enable= RubyPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SHOW_SEGMENTS); else enable= enable && toggleAction.isEnabled() && toggleAction.isChecked(); if (enable) { if (toggleAction instanceof TextEditorAction) { // Reset the action ((TextEditorAction)toggleAction).setEditor(null); // Restore the action ((TextEditorAction)toggleAction).setEditor((ITextEditor)editorPart); } else { // Un-check toggleAction.run(); // Check toggleAction.run(); } } } } private static String getEditorID(IEditorInput input, Object inputObject) { IEditorDescriptor editorDescriptor; try { editorDescriptor= IDE.getEditorDescriptor(input.getName()); } catch (PartInitException e) { return null; } if (editorDescriptor != null) return editorDescriptor.getId(); return null; } public static IEditorInput getEditorInput(Object input) throws RubyModelException { if (input instanceof IRubyElement) return getEditorInput((IRubyElement) input); if (input instanceof IFile) return new FileEditorInput((IFile) input); return null; } private static IEditorInput getEditorInput(IRubyElement element) throws RubyModelException { while (element != null) { if (element instanceof IRubyScript) { IRubyScript unit= RubyModelUtil.toOriginal((IRubyScript) element); IResource resource= unit.getResource(); if (resource instanceof IFile) return new FileEditorInput((IFile) resource); } element= element.getParent(); } return null; } /** * Selects a Java Element in an editor */ public static void revealInEditor(IEditorPart part, IRubyElement element) { if (element == null) return; if (part instanceof RubyEditor) { ((RubyEditor) part).setSelection(element); return; } // Support for non-Ruby editor try { ISourceRange range= null; if (element instanceof IRubyScript) range= null; // else if (element instanceof ILocalVariable) // range= ((ILocalVariable)element).getNameRange(); else if (element instanceof IMember) range= ((IMember)element).getNameRange(); else if (element instanceof ISourceReference) range= ((ISourceReference)element).getSourceRange(); if (range != null) revealInEditor(part, range.getOffset(), range.getLength()); } catch (RubyModelException e) { // don't reveal } } /** * Selects and reveals the given offset and length in the given editor part. */ public static void revealInEditor(IEditorPart editor, final int offset, final int length) { if (editor instanceof ITextEditor) { ((ITextEditor)editor).selectAndReveal(offset, length); return; } // Support for non-text editor - try IGotoMarker interface if (editor instanceof IGotoMarker) { final IEditorInput input= editor.getEditorInput(); if (input instanceof IFileEditorInput) { final IGotoMarker gotoMarkerTarget= (IGotoMarker)editor; WorkspaceModifyOperation op = new WorkspaceModifyOperation() { protected void execute(IProgressMonitor monitor) throws CoreException { IMarker marker= null; try { marker= ((IFileEditorInput)input).getFile().createMarker(IMarker.TEXT); marker.setAttribute(IMarker.CHAR_START, offset); marker.setAttribute(IMarker.CHAR_END, offset + length); gotoMarkerTarget.gotoMarker(marker); } finally { if (marker != null) marker.delete(); } } }; try { op.run(null); } catch (InvocationTargetException ex) { // reveal failed } catch (InterruptedException e) { Assert.isTrue(false, "this operation can not be canceled"); //$NON-NLS-1$ } } return; } /* * Workaround: send out a text selection * XXX: Needs to be improved, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=32214 */ if (editor != null && editor.getEditorSite().getSelectionProvider() != null) { IEditorSite site= editor.getEditorSite(); if (site == null) return; ISelectionProvider provider= editor.getEditorSite().getSelectionProvider(); if (provider == null) return; provider.setSelection(new TextSelection(offset, length)); } } } |
|
From: Christopher W. <caw...@us...> - 2006-03-28 23:15:50
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18162/src/org/rubypeople/rdt/internal/ui/actions Modified Files: SelectionConverter.java ActionMessages.java Added Files: ActionUtil.java OpenActionUtil.java Log Message: start laying groundwork for the F3/Open action where users can easily navigate from text selections and menus with IRubyElements to the source. --- NEW FILE: ActionUtil.java --- package org.rubypeople.rdt.internal.ui.actions; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyProject; import org.rubypeople.rdt.core.RubyCore; import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor; public class ActionUtil { private ActionUtil() {} public static boolean isProcessable(Shell shell, RubyEditor editor) { if (editor == null) return true; IRubyElement input= SelectionConverter.getInput(editor); // if a Ruby editor doesn't have an input of type Ruby element // then it is for sure not on the build path if (input == null) { MessageDialog.openInformation(shell, ActionMessages.ActionUtil_notOnBuildPath_title, ActionMessages.ActionUtil_notOnBuildPath_message); return false; } return isProcessable(shell, input); } public static boolean isProcessable(Shell shell, Object element) { if (!(element instanceof IRubyElement)) return true; if (isOnBuildPath((IRubyElement)element)) return true; MessageDialog.openInformation(shell, ActionMessages.ActionUtil_notOnBuildPath_title, ActionMessages.ActionUtil_notOnBuildPath_message); return false; } public static boolean isOnBuildPath(IRubyElement element) { //fix for bug http://dev.eclipse.org/bugs/show_bug.cgi?id=20051 if (element.getElementType() == IRubyElement.RUBY_PROJECT) return true; IRubyProject project= element.getRubyProject(); try { // TODO When we handle loadpaths correctly, uncomment // if (!project.isOnLoadpath(element)) // return false; IProject resourceProject= project.getProject(); if (resourceProject == null) return false; IProjectNature nature= resourceProject.getNature(RubyCore.NATURE_ID); // We have a Ruby project if (nature != null) return true; } catch (CoreException e) { } return false; } } --- NEW FILE: OpenActionUtil.java --- package org.rubypeople.rdt.internal.ui.actions; import org.eclipse.jface.window.Window; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PartInitException; import org.eclipse.ui.dialogs.ElementListSelectionDialog; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.RubyModelException; import org.rubypeople.rdt.internal.ui.rubyeditor.EditorUtility; import org.rubypeople.rdt.ui.RubyElementLabelProvider; public class OpenActionUtil { /** * Opens the editor on the given element and subsequently selects it. */ public static void open(Object element, boolean activate) throws RubyModelException, PartInitException { IEditorPart part= EditorUtility.openInEditor(element, activate); if (element instanceof IRubyElement) EditorUtility.revealInEditor(part, (IRubyElement)element); } /** * Shows a dialog for resolving an ambiguous ruby element. * Utility method that can be called by subclasses. */ public static IRubyElement selectRubyElement(IRubyElement[] elements, Shell shell, String title, String message) { int nResults= elements.length; if (nResults == 0) return null; if (nResults == 1) return elements[0]; int flags= RubyElementLabelProvider.SHOW_DEFAULT | RubyElementLabelProvider.SHOW_QUALIFIED | RubyElementLabelProvider.SHOW_ROOT; ElementListSelectionDialog dialog= new ElementListSelectionDialog(shell, new RubyElementLabelProvider(flags)); dialog.setTitle(title); dialog.setMessage(message); dialog.setElements(elements); if (dialog.open() == Window.OK) { Object[] selection= dialog.getResult(); if (selection != null && selection.length > 0) { nResults= selection.length; for (int i= 0; i < nResults; i++) { Object current= selection[i]; if (current instanceof IRubyElement) return (IRubyElement) current; } } } return null; } } Index: ActionMessages.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ActionMessages.java 10 Feb 2006 19:58:29 -0000 1.1 --- ActionMessages.java 28 Mar 2006 23:15:47 -0000 1.2 *************** *** 36,39 **** --- 36,51 ---- public static String MemberFilterActionGroup_hide_localtypes_tooltip; public static String MemberFilterActionGroup_hide_localtypes_description; + public static String OpenAction_label; + public static String OpenAction_tooltip; + public static String OpenAction_description; + public static String OpenAction_declaration_label; + public static String OpenAction_select_element; + public static String OpenAction_error_messageBadSelection; + public static String OpenAction_error_message; + public static String OpenAction_error_messageProblems; + public static String OpenAction_error_messageArgs; + public static String OpenAction_error_title; + public static String ActionUtil_notOnBuildPath_title; + public static String ActionUtil_notOnBuildPath_message; static { Index: SelectionConverter.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/SelectionConverter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SelectionConverter.java 10 Feb 2006 19:58:29 -0000 1.1 --- SelectionConverter.java 28 Mar 2006 23:15:47 -0000 1.2 *************** *** 1,7 **** --- 1,12 ---- package org.rubypeople.rdt.internal.ui.actions; + import org.eclipse.jface.text.ITextSelection; + import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; + import org.rubypeople.rdt.core.ICodeAssist; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyScript; + 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.rubyeditor.RubyEditor; *************** *** 26,28 **** --- 31,73 ---- } + public static boolean canOperateOn(RubyEditor editor) { + if (editor == null) + return false; + return getInput(editor) != null; + } + + private static final IRubyElement[] EMPTY_RESULT= new IRubyElement[0]; + + /** + * Converts the text selection provided by the given editor a Ruby element by + * asking the user if code reolve returned more than one result. If the selection + * doesn't cover a Ruby element <code>null</code> is returned. + */ + public static IRubyElement codeResolve(RubyEditor editor, Shell shell, String title, String message) throws RubyModelException { + IRubyElement[] elements= codeResolve(editor); + if (elements == null || elements.length == 0) + return null; + IRubyElement candidate= elements[0]; + if (elements.length > 1) { + candidate= OpenActionUtil.selectRubyElement(elements, shell, title, message); + } + return candidate; + } + + public static IRubyElement[] codeResolve(RubyEditor editor) throws RubyModelException { + return codeResolve(getInput(editor), (ITextSelection)editor.getSelectionProvider().getSelection()); + } + + public static IRubyElement[] codeResolve(IRubyElement input, ITextSelection selection) throws RubyModelException { + if (input instanceof ICodeAssist) { + if (input instanceof IRubyScript) { + RubyModelUtil.reconcile((IRubyScript) input); + } + IRubyElement[] elements= ((ICodeAssist)input).codeSelect(selection.getOffset(), selection.getLength()); + if (elements != null && elements.length > 0) + return elements; + } + return EMPTY_RESULT; + } + } |
|
From: Christopher W. <caw...@us...> - 2006-03-28 23:15:47
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18128/src/org/rubypeople/rdt/internal/codeassist Added Files: SelectionEngine.java Log Message: start laying groundwork for the F3/Open action where users can easily navigate from text selections and menus with IRubyElements to the source. --- NEW FILE: SelectionEngine.java --- package org.rubypeople.rdt.internal.codeassist; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyScript; import org.rubypeople.rdt.internal.core.Openable; public class SelectionEngine { private Openable openable; public SelectionEngine(Openable openable) { this.openable = openable; } public IRubyElement[] select(IRubyScript cu, int start, int end) { // TODO Auto-generated method stub return new IRubyElement[0]; } } |
|
From: Christopher W. <caw...@us...> - 2006-03-28 23:15:47
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18128/src/org/rubypeople/rdt/internal/core Modified Files: Openable.java RubyScript.java Log Message: start laying groundwork for the F3/Open action where users can easily navigate from text selections and menus with IRubyElements to the source. Index: RubyScript.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** RubyScript.java 25 Mar 2006 02:27:36 -0000 1.19 --- RubyScript.java 28 Mar 2006 23:15:43 -0000 1.20 *************** *** 41,44 **** --- 41,45 ---- import org.jruby.lexer.yacc.SyntaxException; import org.rubypeople.rdt.core.IBuffer; + import org.rubypeople.rdt.core.ICodeAssist; import org.rubypeople.rdt.core.IImportContainer; import org.rubypeople.rdt.core.IImportDeclaration; *************** *** 633,635 **** --- 634,649 ---- return null; } + + /** + * @see ICodeAssist#codeSelect(int, int) + */ + public IRubyElement[] codeSelect(int offset, int length) throws RubyModelException { + return codeSelect(offset, length, DefaultWorkingCopyOwner.PRIMARY); + } + /** + * @see ICodeAssist#codeSelect(int, int, WorkingCopyOwner) + */ + public IRubyElement[] codeSelect(int offset, int length, WorkingCopyOwner workingCopyOwner) throws RubyModelException { + return super.codeSelect(this, offset, length, workingCopyOwner); + } } \ No newline at end of file Index: Openable.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Openable.java 25 Mar 2006 02:27:36 -0000 1.7 --- Openable.java 28 Mar 2006 23:15:43 -0000 1.8 *************** *** 19,23 **** --- 19,26 ---- import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyModelStatusConstants; + import org.rubypeople.rdt.core.IRubyScript; import org.rubypeople.rdt.core.RubyModelException; + import org.rubypeople.rdt.core.WorkingCopyOwner; + import org.rubypeople.rdt.internal.codeassist.SelectionEngine; import org.rubypeople.rdt.internal.core.buffer.BufferManager; *************** *** 342,344 **** --- 345,361 ---- getElementInfo(pm); } + + protected IRubyElement[] codeSelect(IRubyScript cu, int offset, int length, WorkingCopyOwner owner) throws RubyModelException { + IBuffer buffer = getBuffer(); + if (buffer == null) { + return new IRubyElement[0]; + } + int end= buffer.getLength(); + if (offset < 0 || length < 0 || offset + length > end ) { + throw new RubyModelException(new RubyModelStatus(IRubyModelStatusConstants.INDEX_OUT_OF_BOUNDS)); + } + + SelectionEngine engine = new SelectionEngine(this); + return engine.select(cu, offset, offset + length - 1); + } } |
|
From: Christopher W. <caw...@us...> - 2006-03-28 23:15:47
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18128/src/org/rubypeople/rdt/core Modified Files: IRubyScript.java Added Files: ICodeAssist.java Log Message: start laying groundwork for the F3/Open action where users can easily navigate from text selections and menus with IRubyElements to the source. Index: IRubyScript.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyScript.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IRubyScript.java 25 Mar 2006 02:27:36 -0000 1.9 --- IRubyScript.java 28 Mar 2006 23:15:43 -0000 1.10 *************** *** 31,35 **** * */ ! public interface IRubyScript extends IRubyElement, ISourceReference, IParent, IOpenable { public String[] EXTENSIONS = { "rb", "rbw", "rhtml", "rjs", "rxml"}; --- 31,35 ---- * */ ! public interface IRubyScript extends IRubyElement, ISourceReference, IParent, IOpenable, ICodeAssist { public String[] EXTENSIONS = { "rb", "rbw", "rhtml", "rjs", "rxml"}; --- NEW FILE: ICodeAssist.java --- package org.rubypeople.rdt.core; public interface ICodeAssist { public IRubyElement[] codeSelect(int offset, int length) throws RubyModelException; public IRubyElement[] codeSelect(int offset, int length, WorkingCopyOwner workingCopyOwner) throws RubyModelException; } |
|
From: Christopher W. <caw...@us...> - 2006-03-28 23:15:41
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18081/src/org/rubypeople/rdt/internal/codeassist Log Message: Directory /cvsroot/rubyeclipse/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist added to the repository |
|
From: Christopher W. <caw...@us...> - 2006-03-28 23:14:50
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17533 Modified Files: plugin.xml Log Message: always refer to same place for ruby file extensions and filenames. Add perspective shortcuts to the Ruby perspective to open debug/browsing. add new open action (F3). Index: plugin.xml =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/plugin.xml,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** plugin.xml 25 Mar 2006 19:37:45 -0000 1.76 --- plugin.xml 28 Mar 2006 23:14:45 -0000 1.77 *************** *** 54,57 **** --- 54,60 ---- </page> </extension> + <!-- =========================================================================== --> + <!-- Ruby Perspective --> + <!-- =========================================================================== --> <extension point="org.eclipse.ui.perspectives"> *************** *** 63,66 **** --- 66,110 ---- </perspective> </extension> + <extension point="org.eclipse.ui.perspectiveExtensions"> + <perspectiveExtension + targetID="org.rubypeople.rdt.ui.RubyBrowsingPerspective"> + <perspectiveShortcut + id="org.rubypeople.rdt.ui.PerspectiveRuby"> + </perspectiveShortcut> + </perspectiveExtension> + <perspectiveExtension + targetID="org.eclipse.debug.ui.DebugPerspective"> + <perspectiveShortcut + id="org.rubypeople.rdt.ui.PerspectiveRuby"> + </perspectiveShortcut> + </perspectiveExtension> + <perspectiveExtension targetID="org.eclipse.ui.resourcePerspective"> + <perspectiveShortcut id="org.rubypeople.rdt.ui.PerspectiveRuby" /> + </perspectiveExtension> + <perspectiveExtension targetID="org.rubypeople.rdt.ui.PerspectiveRuby"> + <newWizardShortcut id="org.rubypeople.rdt.ui.wizards.NewWizardProjectCreation"/> + <newWizardShortcut id="org.eclipse.ui.wizards.new.folder"/> + <newWizardShortcut id="org.eclipse.ui.wizards.new.file"/> + <viewShortcut id="org.eclipse.ui.views.ContentOutline"/> + <viewShortcut id="org.rubypeople.rdt.ui.ViewRubyResources"/> + <viewShortcut id="org.eclipse.ui.console.ConsoleView"/> + <viewShortcut id="org.eclipse.ui.views.ProblemView"/> + <viewShortcut id="org.eclipse.ui.views.TaskList"/> + <viewShortcut id="org.rubypeople.rdt.ui.views.RIView"/> + <perspectiveShortcut + id="org.rubypeople.rdt.ui.RubyBrowsingPerspective"> + </perspectiveShortcut> + <perspectiveShortcut + id="org.eclipse.debug.ui.DebugPerspective"> + </perspectiveShortcut> + <perspectiveShortcut + id="org.rubypeople.rdt.ui.PerspectiveRuby"> + </perspectiveShortcut> + <perspectiveShortcut id="org.eclipse.ui.resourcePerspective" /> + </perspectiveExtension> + <perspectiveExtension targetID="org.eclipse.jdt.ui.JavaPerspective"> + <perspectiveShortcut id="org.rubypeople.rdt.ui.PerspectiveRuby" /> + </perspectiveExtension> + </extension> <!-- =========================================================================== --> <!-- Ruby Browsing --> *************** *** 90,94 **** </perspectiveExtension> <perspectiveExtension ! targetID="org.rubypeople.rdt.ui.RubyPerspective"> <perspectiveShortcut id="org.rubypeople.rdt.ui.RubyBrowsingPerspective"> --- 134,138 ---- </perspectiveExtension> <perspectiveExtension ! targetID="org.rubypeople.rdt.ui.PerspectiveRuby"> <perspectiveShortcut id="org.rubypeople.rdt.ui.RubyBrowsingPerspective"> *************** *** 98,102 **** targetID="org.rubypeople.rdt.ui.RubyBrowsingPerspective"> <perspectiveShortcut ! id="org.rubypeople.rdt.ui.RubyPerspective"> </perspectiveShortcut> </perspectiveExtension> --- 142,146 ---- targetID="org.rubypeople.rdt.ui.RubyBrowsingPerspective"> <perspectiveShortcut ! id="org.rubypeople.rdt.ui.PerspectiveRuby"> </perspectiveShortcut> </perspectiveExtension> *************** *** 225,248 **** </view> </extension> - <extension point="org.eclipse.ui.perspectiveExtensions"> - <perspectiveExtension targetID="org.eclipse.ui.resourcePerspective"> - <perspectiveShortcut id="org.rubypeople.rdt.ui.PerspectiveRuby" /> - </perspectiveExtension> - <perspectiveExtension targetID="org.rubypeople.rdt.ui.PerspectiveRuby"> - <newWizardShortcut id="org.rubypeople.rdt.ui.wizards.NewWizardProjectCreation"/> - <newWizardShortcut id="org.eclipse.ui.wizards.new.folder"/> - <newWizardShortcut id="org.eclipse.ui.wizards.new.file"/> - <viewShortcut id="org.eclipse.ui.views.ContentOutline"/> - <viewShortcut id="org.rubypeople.rdt.ui.ViewRubyResources"/> - <viewShortcut id="org.eclipse.ui.console.ConsoleView"/> - <viewShortcut id="org.eclipse.ui.views.ProblemView"/> - <viewShortcut id="org.eclipse.ui.views.TaskList"/> - <viewShortcut id="org.rubypeople.rdt.ui.views.RIView"/> - <perspectiveShortcut id="org.eclipse.ui.resourcePerspective" /> - </perspectiveExtension> - <perspectiveExtension targetID="org.eclipse.jdt.ui.JavaPerspective"> - <perspectiveShortcut id="org.rubypeople.rdt.ui.PerspectiveRuby" /> - </perspectiveExtension> - </extension> <extension point="org.eclipse.ui.editors"> <editor --- 269,272 ---- *************** *** 308,316 **** platform="carbon"> </key> ! <key sequence="M1+M2+P" contextId="org.rubypeople.rdt.ui.rubyEditorScope" commandId="org.rubypeople.rdt.ui.edit.text.ruby.goto.matching.bracket" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> </extension> <extension point="org.eclipse.ui.commands"> --- 332,345 ---- platform="carbon"> </key> ! <key sequence="M1+M2+P" contextId="org.rubypeople.rdt.ui.rubyEditorScope" commandId="org.rubypeople.rdt.ui.edit.text.ruby.goto.matching.bracket" schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> + + <key + sequence="F3" + commandId="org.rubypeople.rdt.ui.edit.text.ruby.open.editor" + schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/> </extension> <extension point="org.eclipse.ui.commands"> *************** *** 468,471 **** --- 497,516 ---- </action> </actionSet> + <actionSet + label="%OpenActionSet.label" + description="%OpenActionSet.description" + visible="false" + id="org.rubypeople.rdt.ui.A_OpenActionSet"> + + <action + definitionId="org.rubypeople.rdt.ui.edit.text.ruby.open.editor" + label="%OpenAction.label" + tooltip="%OpenAction.tooltip" + retarget="true" + menubarPath="navigate/open.ext" + allowLabelUpdate="true" + id="org.rubypeople.rdt.ui.actions.Open"> + </action> + </actionSet> </extension> *************** *** 490,493 **** --- 535,559 ---- </part> </actionSetPartAssociation> + <actionSetPartAssociation + targetID="org.rubypeople.rdt.ui.A_OpenActionSet"> + <part + id="org.eclipse.search.SearchResultView"> + </part> + <part + id="org.rubypeople.rdt.ui.ViewRubyResources"> + </part> + <part + id="org.rubypeople.rdt.ui.EditorRubyFile"> + </part> + <part + id="org.rubypeople.rdt.ui.ProjectsView"> + </part> + <part + id="org.rubypeople.rdt.ui.TypesView"> + </part> + <part + id="org.rubypeople.rdt.ui.MembersView"> + </part> + </actionSetPartAssociation> </extension> *************** *** 623,628 **** class="org.rubypeople.rdt.internal.ui.rubyeditor.RubyDocumentSetupParticipant" contentTypeId="org.rubypeople.rdt.core.rubySource" ! extensions="rb,rbw" ! fileNames="Rakefile"> </participant> </extension> --- 689,694 ---- class="org.rubypeople.rdt.internal.ui.rubyeditor.RubyDocumentSetupParticipant" contentTypeId="org.rubypeople.rdt.core.rubySource" ! extensions="%EditorRubyFile.extension" ! fileNames="%EditorRubyFile.filenames"> </participant> </extension> *************** *** 634,639 **** class="org.rubypeople.rdt.internal.ui.rubyeditor.RubyDocumentFactory" contentTypeId="org.rubypeople.rdt.core.rubySource" ! extensions="rb,rbw" ! fileNames="Rakefile"> </factory> </extension> --- 700,705 ---- class="org.rubypeople.rdt.internal.ui.rubyeditor.RubyDocumentFactory" contentTypeId="org.rubypeople.rdt.core.rubySource" ! extensions="%EditorRubyFile.extension" ! fileNames="%EditorRubyFile.filenames"> </factory> </extension> |
|
From: Christopher W. <caw...@us...> - 2006-03-28 23:08:47
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14257 Modified Files: plugin.properties Log Message: add rjs and rxml file extensions, as well as more rails script filenames Index: plugin.properties =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/plugin.properties,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** plugin.properties 25 Mar 2006 02:37:43 -0000 1.29 --- plugin.properties 28 Mar 2006 23:08:42 -0000 1.30 *************** *** 12,16 **** Browsing.projectsViewName= Projects Browsing.typesViewName= Types ! Borwesing.membersViewName = Members editorPopupExtender=Editor Popup Extender --- 12,16 ---- Browsing.projectsViewName= Projects Browsing.typesViewName= Types ! Browsing.membersViewName= Members editorPopupExtender=Editor Popup Extender *************** *** 46,51 **** EditorRubyFile.name=Ruby Editor ! EditorRubyFile.extension=rb, rbw, cgi, fcgi, rake ! EditorRubyFile.filenames=Rakefile, generate, profiler, console, server ExternalEditorRubyFile.name=Ext. Ruby Editor --- 46,51 ---- EditorRubyFile.name=Ruby Editor ! EditorRubyFile.extension=rb, rbw, cgi, fcgi, rake, rjs, rxml ! EditorRubyFile.filenames=Rakefile, generate, profiler, console, server, reaper, spawner, spinner, about, destroy ExternalEditorRubyFile.name=Ext. Ruby Editor |
|
From: Christopher W. <caw...@us...> - 2006-03-28 23:08: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-serv14070/src/org/rubypeople/rdt/internal/ui/browsing Modified Files: ProjectsView.java Log Message: don't allow clearing projects view Index: ProjectsView.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/ProjectsView.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ProjectsView.java 25 Mar 2006 02:37:43 -0000 1.1 --- ProjectsView.java 28 Mar 2006 23:08:08 -0000 1.2 *************** *** 66,69 **** --- 66,80 ---- return element instanceof IRubyProject; } + + /* + * @see RubyBrowsingPart#setInput(Object) + */ + protected void setInput(Object input) { + // Don't allow to clear input for this view + if (input != null) + super.setInput(input); + else + getViewer().setSelection(null); + } /** |
|
From: Matt K. <me...@us...> - 2006-03-28 19:48:26
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28522/src/org/rubypeople/rdt/internal/ui/text/ruby Modified Files: SymbolRule.java Log Message: symbols now only contain a-zA-Z0-9_ Index: SymbolRule.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/SymbolRule.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SymbolRule.java 4 Jan 2006 00:00:22 -0000 1.3 --- SymbolRule.java 28 Mar 2006 19:48:22 -0000 1.4 *************** *** 20,38 **** if (!super.isValidCharacter(c, index)) return false; ! char theChar = (char) c; ! switch (theChar) { ! case ':': // other than first character (prefix) symbols can't contain ! // another colon ! case '[': // FIXME This isn't always the case. There's special method names containing brackets that is valid (only the particular sequence) ! case ']': ! case '{': ! case '}': ! case '(': ! case ')': ! return false; ! ! default: return true; } } --- 20,33 ---- if (!super.isValidCharacter(c, index)) return false; ! ! // Symbols can only contain word characters (a-zA-Z0-9_) ! // TODO which special method names contain brackets? ! String theChar = String.valueOf((char) c); ! if(theChar.matches("\\w")) { return true; } + else { + return false; + } } |
|
From: Christopher W. <caw...@us...> - 2006-03-25 19:43:21
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1247 Modified Files: Changelog.txt Log Message: add in changes since last release Index: Changelog.txt =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt/Changelog.txt,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Changelog.txt 13 Dec 2005 21:04:45 -0000 1.20 --- Changelog.txt 25 Mar 2006 19:43:17 -0000 1.21 *************** *** 1,3 **** ! Changes since 0.6.0: * Debugger * Multiple debugger session possible because a free port will be used for the debugger communication. The port is written to a --- 1,11 ---- ! Changes since 0.7.0: ! * New Ruby Browsing Perspective ! * New Class Wizard ! * Apply code formatting (indentation) to templates ! * Distinct syntax highlighting of globals ! * Distinct syntax highlighting of instance/class variables ! * Goto matching bracket action ! ! Release 0.7.0: * Debugger * Multiple debugger session possible because a free port will be used for the debugger communication. The port is written to a |
|
From: Christopher W. <caw...@us...> - 2006-03-25 19:37:52
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30675/src/org/rubypeople/rdt/internal/ui/browsing Removed Files: SimpleView.java Log Message: remove SimpleView - a very rough version of what eventually became the browsing perspective --- SimpleView.java DELETED --- |
|
From: Christopher W. <caw...@us...> - 2006-03-25 19:37:52
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30675 Modified Files: plugin.xml Log Message: remove SimpleView - a very rough version of what eventually became the browsing perspective Index: plugin.xml =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/plugin.xml,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** plugin.xml 25 Mar 2006 02:37:43 -0000 1.75 --- plugin.xml 25 Mar 2006 19:37:45 -0000 1.76 *************** *** 224,234 **** id="org.rubypeople.rdt.ui.views.RIView"> </view> - <view - name="Browsing" - icon="icons/full/elcl16/help.gif" - category="org.rubypeople.rdt.ui.ruby" - class="org.rubypeople.rdt.internal.ui.browsing.SimpleView" - id="org.rubypeople.rdt.ui.views.BrowsingView"> - </view> </extension> <extension point="org.eclipse.ui.perspectiveExtensions"> --- 224,227 ---- |
|
From: Christopher W. <caw...@us...> - 2006-03-25 02:37:52
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11479/src/org/rubypeople/rdt/internal/ui/rubyeditor Modified Files: RubyAbstractEditor.java Log Message: my initial working version of a Ruby Browsing Perspective Index: RubyAbstractEditor.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyAbstractEditor.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** RubyAbstractEditor.java 18 Feb 2006 17:29:33 -0000 1.23 --- RubyAbstractEditor.java 25 Mar 2006 02:37:44 -0000 1.24 *************** *** 368,372 **** return null; ! if (element.getElementType() == IRubyElement.IMPORT) { IImportDeclaration declaration= (IImportDeclaration) element; --- 368,372 ---- return null; ! if (element.getElementType() == IRubyElement.IMPORT_DECLARATION) { IImportDeclaration declaration= (IImportDeclaration) element; |
|
From: Christopher W. <caw...@us...> - 2006-03-25 02:37:52
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11479/src/org/rubypeople/rdt/internal/ui Modified Files: RubyElementAdapterFactory.java Log Message: my initial working version of a Ruby Browsing Perspective Index: RubyElementAdapterFactory.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementAdapterFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RubyElementAdapterFactory.java 11 Mar 2005 01:59:52 -0000 1.2 --- RubyElementAdapterFactory.java 25 Mar 2006 02:37:44 -0000 1.3 *************** *** 55,59 **** case IRubyElement.SCRIPT: return RubyModelUtil.toOriginal((IRubyScript) element).getResource(); ! case IRubyElement.PROJECT: case IRubyElement.RUBY_MODEL: return element.getResource(); --- 55,59 ---- case IRubyElement.SCRIPT: return RubyModelUtil.toOriginal((IRubyScript) element).getResource(); ! case IRubyElement.RUBY_PROJECT: case IRubyElement.RUBY_MODEL: return element.getResource(); |
|
From: Christopher W. <caw...@us...> - 2006-03-25 02:37:52
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/icons/full/eview16 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11479/icons/full/eview16 Added Files: browse_persp.gif types.gif members.gif projects.gif Log Message: my initial working version of a Ruby Browsing Perspective --- NEW FILE: types.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: projects.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: members.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: browse_persp.gif --- (This appears to be a binary file; contents omitted.) |
|
From: Christopher W. <caw...@us...> - 2006-03-25 02:37:52
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11479/src/org/rubypeople/rdt/internal/ui/browsing Added Files: MembersView.java RubyBrowsingPart.java RubyBrowsingContentProvider.java TypesView.java RubyElementTypeComparator.java ProjectContentProvider.java RubyBrowsingPerspectiveFactory.java ProjectsView.java SimpleView.java Log Message: my initial working version of a Ruby Browsing Perspective --- NEW FILE: SimpleView.java --- package org.rubypeople.rdt.internal.ui.browsing; import java.util.ArrayList; import java.util.Iterator; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.List; import org.eclipse.ui.part.ViewPart; import org.rubypeople.rdt.core.IMethod; import org.rubypeople.rdt.core.IParent; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyModel; import org.rubypeople.rdt.core.IRubyProject; import org.rubypeople.rdt.core.IType; import org.rubypeople.rdt.core.RubyModelException; import org.rubypeople.rdt.internal.core.RubyModel; import org.rubypeople.rdt.internal.core.RubyModelManager; public class SimpleView extends ViewPart { public SimpleView() { super(); } public void createPartControl(Composite parent) { Group methodsGroup = new Group(parent, 8); methodsGroup.setText("Methods"); methodsGroup.setLayout(new FillLayout()); List methodsList = new List(methodsGroup, 0); methodsList.add("Methods"); Group typesGroup = new Group(parent, 8); typesGroup.setText("Types"); typesGroup.setLayout(new FillLayout()); List typeList = new List(typesGroup, 0); typeList.add("Types"); typeList.addSelectionListener(new TypeListener(typeList, methodsList)); java.util.List projects = new ArrayList(); try { RubyModel model = RubyModelManager.getRubyModelManager() .getRubyModel(); projects = model.getChildrenOfType(IRubyElement.RUBY_PROJECT); } catch (RubyModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } Group projectsGroup = new Group(parent, 8); projectsGroup.setText("Projects"); projectsGroup.setLayout(new FillLayout()); List projectList = new List(projectsGroup, 0); for (Iterator iter = projects.iterator(); iter.hasNext();) { IRubyElement project = (IRubyElement) iter.next(); projectList.add(project.getElementName()); } projectList.addSelectionListener(new ProjectListener(projectList, typeList)); } public void setFocus() { // TODO Auto-generated method stub } private static class ProjectListener implements SelectionListener { private List projectList; private List typeList; private ProjectListener(List project, List types) { this.projectList = project; this.typeList = types; } public void widgetSelected(SelectionEvent e) { String[] selectedProjectNames = projectList.getSelection(); if (selectedProjectNames == null || selectedProjectNames.length == 0) return; typeList.removeAll(); for (int i = 0; i < selectedProjectNames.length; i++) { IRubyModel model = RubyModelManager.getRubyModelManager() .getRubyModel(); IRubyProject rubyProject = model .getRubyProject(selectedProjectNames[i]); java.util.List types = getTypes(rubyProject); for (Iterator iter = types.iterator(); iter.hasNext();) { typeList.add(((IType) iter.next()).getElementName()); } } } private java.util.List getTypes(IRubyElement element) { java.util.List types = new ArrayList(); if (element.isType(IRubyElement.TYPE)) types.add(element); if (element instanceof IParent) { IParent parent = (IParent) element; try { IRubyElement[] children = parent.getChildren(); for (int i = 0; i < children.length; i++) { types.addAll(getTypes(children[i])); } } catch (RubyModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return types; } public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } } private static class TypeListener implements SelectionListener { private List methodList; private List typeList; private TypeListener(List types, List methods) { this.methodList = methods; this.typeList = types; } public void widgetSelected(SelectionEvent e) { String[] selectedTypes = typeList.getSelection(); if (selectedTypes == null || selectedTypes.length == 0) return; methodList.removeAll(); for (int i = 0; i < selectedTypes.length; i++) { IRubyModel model = RubyModelManager.getRubyModelManager() .getRubyModel(); IRubyProject rubyProject = model .getRubyProject(selectedTypes[i]); // TODO Get all the methods for the seleted Types and add them to the // method list java.util.List methods = getMethods(rubyProject); for (Iterator iter = methods.iterator(); iter.hasNext();) { methodList.add(((IMethod) iter.next()).getElementName()); } } } private java.util.List getMethods(IRubyElement element) { java.util.List methods = new ArrayList(); if (element.isType(IRubyElement.METHOD)) methods.add(element); if (element instanceof IParent) { IParent parent = (IParent) element; try { IRubyElement[] children = parent.getChildren(); for (int i = 0; i < children.length; i++) { methods.addAll(getMethods(children[i])); } } catch (RubyModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return methods; } public void widgetDefaultSelected(SelectionEvent e) { // TODO Auto-generated method stub } } } --- NEW FILE: RubyElementTypeComparator.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 java.util.Comparator; import org.rubypeople.rdt.core.IRubyElement; public class RubyElementTypeComparator implements Comparator { /** * Compares two Ruby element types. A type is considered to be * greater if it may contain the other. * * @return an int less than 0 if object1 is less than object2, * 0 if they are equal, and > 0 if object1 is greater * * @see Comparator#compare(Object, Object) */ public int compare(Object o1, Object o2) { if (!(o1 instanceof IRubyElement) || !(o2 instanceof IRubyElement)) throw new ClassCastException(); return getIdForRubyElement((IRubyElement)o1) - getIdForRubyElement((IRubyElement)o2); } /** * Compares two Ruby element types. A type is considered to be * greater if it may contain the other. * * @return an int < 0 if object1 is less than object2, * 0 if they are equal, and > 0 if object1 is greater * * @see Comparator#compare(Object, Object) */ public int compare(Object o1, int elementType) { if (!(o1 instanceof IRubyElement)) throw new ClassCastException(); return getIdForRubyElement((IRubyElement)o1) - getIdForRubyElementType(elementType); } int getIdForRubyElement(IRubyElement element) { return getIdForRubyElementType(element.getElementType()); } int getIdForRubyElementType(int elementType) { switch (elementType) { case IRubyElement.RUBY_MODEL: return 130; case IRubyElement.RUBY_PROJECT: return 120; case IRubyElement.SCRIPT: return 90; case IRubyElement.TYPE: return 70; case IRubyElement.FIELD: return 60; case IRubyElement.METHOD: return 50; case IRubyElement.IMPORT_CONTAINER: return 20; case IRubyElement.IMPORT_DECLARATION: return 10; default : return 1; } } } --- NEW FILE: RubyBrowsingPart.java --- package org.rubypeople.rdt.internal.ui.browsing; import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.IContentProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.search.ui.ISearchResultView; import org.eclipse.search.ui.ISearchResultViewPart; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.part.IShowInSource; import org.eclipse.ui.part.ShowInContext; import org.eclipse.ui.part.ViewPart; import org.osgi.framework.Bundle; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyScript; import org.rubypeople.rdt.core.IType; import org.rubypeople.rdt.core.RubyModelException; import org.rubypeople.rdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; import org.rubypeople.rdt.internal.ui.viewsupport.DecoratingRubyLabelProvider; import org.rubypeople.rdt.internal.ui.viewsupport.RubyElementImageProvider; import org.rubypeople.rdt.internal.ui.viewsupport.RubyUILabelProvider; import org.rubypeople.rdt.ui.StandardRubyElementContentProvider; public abstract class RubyBrowsingPart extends ViewPart implements ISelectionListener { private StructuredViewer fViewer; private RubyUILabelProvider fLabelProvider; protected IWorkbenchPart fPreviousSelectionProvider; protected Object fPreviousSelectedElement; /* * Ensure selection changed events being processed only if * initiated by user interaction with this part. */ private boolean fProcessSelectionEvents= true; private RubyElementTypeComparator fTypeComparator; private IPartListener2 fPartListener= new IPartListener2() { public void partActivated(IWorkbenchPartReference ref) { } public void partBroughtToTop(IWorkbenchPartReference ref) { } public void partInputChanged(IWorkbenchPartReference ref) { } public void partClosed(IWorkbenchPartReference ref) { } public void partDeactivated(IWorkbenchPartReference ref) { } public void partOpened(IWorkbenchPartReference ref) { } public void partVisible(IWorkbenchPartReference ref) { if (ref != null && ref.getId() == getSite().getId()){ fProcessSelectionEvents= true; IWorkbenchPage page= getSite().getWorkbenchWindow().getActivePage(); if (page != null) selectionChanged(page.getActivePart(), page.getSelection()); } } public void partHidden(IWorkbenchPartReference ref) { if (ref != null && ref.getId() == getSite().getId()) fProcessSelectionEvents= false; } }; public void createPartControl(Composite parent) { Assert.isTrue(fViewer == null); fViewer = new TreeViewer(parent); fTypeComparator= new RubyElementTypeComparator(); fLabelProvider= createLabelProvider(); fViewer.setLabelProvider(new DecoratingRubyLabelProvider(fLabelProvider)); fViewer.setUseHashlookup(true); getSite().setSelectionProvider(fViewer); fViewer.setContentProvider(createContentProvider()); setInitialInput(); // Initialize selection // TODO Use selection from editor, etc //setInitialSelection(); // Listen to page changes getViewSite().getPage().addPostSelectionListener(this); getViewSite().getPage().addPartListener(fPartListener); } /** * Creates the the content provider of this part. */ protected IContentProvider createContentProvider() { return new RubyBrowsingContentProvider(true, this); } protected final StructuredViewer getViewer() { return fViewer; } protected void setInitialInput() { // Use the selection, if any ISelection selection = getSite().getPage().getSelection(); Object input = getSingleElementFromSelection(selection); if (!(input instanceof IRubyElement)) { // Use the input of the page input = getSite().getPage().getInput(); if (!(input instanceof IRubyElement) && input instanceof IAdaptable) input = ((IAdaptable) input).getAdapter(IRubyElement.class); } setInput(findInputForRubyElement((IRubyElement) input)); } protected RubyUILabelProvider createLabelProvider() { return new AppearanceAwareLabelProvider( AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | RubyElementImageProvider.SMALL_ICONS ); } protected void setInput(Object input) { setViewerInput(input); // TODO Update the title //updateTitle(); } private void setViewerInput(Object input) { fProcessSelectionEvents= false; fViewer.setInput(input); fProcessSelectionEvents= true; } private boolean isSearchResultView(IWorkbenchPart part) { return isSearchPlugInActivated() && (part instanceof ISearchResultView || part instanceof ISearchResultViewPart); } // FIXME Move this to a ruby SearchUtil class public static boolean isSearchPlugInActivated() { return Platform.getBundle("org.eclipse.search").getState() == Bundle.ACTIVE; //$NON-NLS-1$ } protected boolean needsToProcessSelectionChanged(IWorkbenchPart part, ISelection selection) { if (!fProcessSelectionEvents || part == this || isSearchResultView(part)){ if (part == this) fPreviousSelectionProvider= part; return false; } return true; } public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (!needsToProcessSelectionChanged(part, selection)) return; // TODO Handle editor selections // if (fToggleLinkingAction.isChecked() && (part instanceof ITextEditor)) { // setSelectionFromEditor(part, selection); // return; // } if (!(selection instanceof IStructuredSelection)) return; // Set selection Object selectedElement= getSingleElementFromSelection(selection); if (selectedElement != null && (part == null || part.equals(fPreviousSelectionProvider)) && selectedElement.equals(fPreviousSelectedElement)) return; fPreviousSelectedElement= selectedElement; Object currentInput= getViewer().getInput(); if (selectedElement != null && selectedElement.equals(currentInput)) { IRubyElement elementToSelect= findElementToSelect(selectedElement); if (elementToSelect != null && getTypeComparator().compare(selectedElement, elementToSelect) < 0) setSelection(new StructuredSelection(elementToSelect), true); // TODO Uncomment when we have a MembersView // else if (elementToSelect == null && (this instanceof MembersView)) { // setSelection(StructuredSelection.EMPTY, true); // fPreviousSelectedElement= StructuredSelection.EMPTY; // } fPreviousSelectionProvider= part; return; } // Clear input if needed if (part != fPreviousSelectionProvider && selectedElement != null && !selectedElement.equals(currentInput) && isInputResetBy(selectedElement, currentInput, part)) { if (!isAncestorOf(selectedElement, currentInput)) setInput(null); fPreviousSelectionProvider= part; return; } else if (selection.isEmpty() && !isInputResetBy(part)) { fPreviousSelectionProvider= part; return; } else if (selectedElement == null && part == fPreviousSelectionProvider) { setInput(null); fPreviousSelectionProvider= part; return; } fPreviousSelectionProvider= part; // Adjust input and set selection and adjustInputAndSetSelection(selectedElement); } void setSelection(ISelection selection, boolean reveal) { if (selection != null && selection.equals(fViewer.getSelection())) return; fProcessSelectionEvents= false; fViewer.setSelection(selection, reveal); fProcessSelectionEvents= true; } protected Object getInput() { return fViewer.getInput(); } public void setFocus() { fViewer.getControl().setFocus(); } /** * Answer the property defined by key. */ public Object getAdapter(Class key) { if (key == IShowInSource.class) { return getShowInSource(); } // TODO Uncomment when we have RubyUIHelp // if (key == IContextProvider.class) // return RubyUIHelp.getHelpContextProvider(this, getHelpContextId()); return super.getAdapter(key); } /** * Returns the <code>IShowInSource</code> for this view. */ protected IShowInSource getShowInSource() { return new IShowInSource() { public ShowInContext getShowInContext() { return new ShowInContext( null, getSite().getSelectionProvider().getSelection()); } }; } void adjustInputAndSetSelection(Object o) { if (!(o instanceof IRubyElement)) { if (o == null) setInput(null); setSelection(StructuredSelection.EMPTY, true); return; } IRubyElement je= (IRubyElement)o; IRubyElement elementToSelect= getSuitableRubyElement(findElementToSelect(je)); IRubyElement newInput= findInputForRubyElement(je); IRubyElement oldInput= null; if (getInput() instanceof IRubyElement) oldInput= (IRubyElement)getInput(); if (elementToSelect == null && !isValidInput(newInput) && (newInput == null && !isAncestorOf(je, oldInput))) // Clear input setInput(null); else if (mustSetNewInput(elementToSelect, oldInput, newInput)) { // Adjust input to selection setInput(newInput); // Recompute suitable element since it depends on the viewer's input elementToSelect= getSuitableRubyElement(elementToSelect); } if (elementToSelect != null && elementToSelect.exists()) setSelection(new StructuredSelection(elementToSelect), true); else setSelection(StructuredSelection.EMPTY, true); } /** * Converts the given Java element to one which is suitable for this * view. It takes into account whether the view shows working copies or not. * * @param obj the Java element to be converted * @return an element suitable for this view */ IRubyElement getSuitableRubyElement(Object obj) { if (!(obj instanceof IRubyElement)) return null; IRubyElement element= (IRubyElement)obj; if (fTypeComparator.compare(element, IRubyElement.SCRIPT) > 0) return element; if (isInputAWorkingCopy()) { IRubyElement wc= getWorkingCopy(element); if (wc != null) element= wc; return element; } else { return element.getPrimaryElement(); } } boolean isInputAWorkingCopy() { return ((StandardRubyElementContentProvider)getViewer().getContentProvider()).getProvideWorkingCopy(); } /** * Tries to find the given element in a workingcopy. */ protected static IRubyElement getWorkingCopy(IRubyElement input) { // MA: with new working copy story original == working copy return input; } /** * Compute if a new input must be set. * * @return <code>true</code> if the input has to be set * @since 3.0 */ private boolean mustSetNewInput(IRubyElement elementToSelect, IRubyElement oldInput, IRubyElement newInput) { return (newInput == null || !newInput.equals(oldInput)) && (elementToSelect == null || oldInput == null || (!(false && (elementToSelect.getParent().equals(oldInput.getParent())) && (!isAncestorOf(getViewPartInput(), elementToSelect))))); } /* (non-Javadoc) * @see org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput() */ public Object getViewPartInput() { if (fViewer != null) { return fViewer.getInput(); } return null; } /** * Gets the typeComparator. * @return Returns a RubyElementTypeComparator */ protected Comparator getTypeComparator() { return fTypeComparator; } private boolean isInputResetBy(Object newInput, Object input, IWorkbenchPart part) { if (newInput == null) return part == fPreviousSelectionProvider; if (input instanceof IRubyElement && newInput instanceof IRubyElement) return getTypeComparator().compare(newInput, input) > 0; else return false; } private boolean isInputResetBy(IWorkbenchPart part) { if (!(part instanceof RubyBrowsingPart)) return true; Object thisInput= getViewer().getInput(); Object partInput= ((RubyBrowsingPart)part).getViewer().getInput(); if(thisInput instanceof Collection) thisInput= ((Collection)thisInput).iterator().next(); if(partInput instanceof Collection) partInput= ((Collection)partInput).iterator().next(); if (thisInput instanceof IRubyElement && partInput instanceof IRubyElement) return getTypeComparator().compare(partInput, thisInput) > 0; else return true; } protected boolean isAncestorOf(Object ancestor, Object element) { if (element instanceof IRubyElement && ancestor instanceof IRubyElement) return !element.equals(ancestor) && internalIsAncestorOf((IRubyElement)ancestor, (IRubyElement)element); return false; } private boolean internalIsAncestorOf(IRubyElement ancestor, IRubyElement element) { if (element != null) return element.equals(ancestor) || internalIsAncestorOf(ancestor, element.getParent()); else return false; } protected final IRubyElement findElementToSelect(Object obj) { if (obj instanceof IRubyElement) return findElementToSelect((IRubyElement)obj); return null; } /** * Finds the element which has to be selected in this part. * * @param je the Ruby element which has the focus */ abstract protected IRubyElement findElementToSelect(IRubyElement je); protected final Object getSingleElementFromSelection(ISelection selection) { if (!(selection instanceof StructuredSelection) || selection.isEmpty()) return null; Iterator iter= ((StructuredSelection)selection).iterator(); Object firstElement= iter.next(); if (!(firstElement instanceof IRubyElement)) { if (firstElement instanceof IMarker) firstElement= ((IMarker)firstElement).getResource(); if (firstElement instanceof IAdaptable) { IRubyElement je= (IRubyElement)((IAdaptable)firstElement).getAdapter(IRubyElement.class); if (je == null && firstElement instanceof IFile) { IContainer parent= ((IFile)firstElement).getParent(); if (parent != null) return (IRubyElement)parent.getAdapter(IRubyElement.class); else return null; } else return je; } else return firstElement; } Object currentInput= getViewer().getInput(); if (currentInput == null || !currentInput.equals(findInputForRubyElement((IRubyElement)firstElement))) if (iter.hasNext()) // multi-selection and view is empty return null; else // OK: single selection and view is empty return firstElement; // be nice to multi-selection while (iter.hasNext()) { Object element= iter.next(); if (!(element instanceof IRubyElement)) return null; if (!currentInput.equals(findInputForRubyElement((IRubyElement)element))) return null; } return firstElement; } /** * Finds the closest Ruby element which can be used as input for * this part and has the given Ruby element as child * * @param je the Ruby element for which to search the closest input * @return the closest Ruby element used as input for this part */ protected IRubyElement findInputForRubyElement(IRubyElement je) { if (je == null || !je.exists()) return null; if (isValidInput(je)) return je; return findInputForRubyElement(je.getParent()); } /** * Answers if the given <code>element</code> is a valid * input for this part. * * @param element the object to test * @return <code>true</code> if the given element is a valid input */ abstract protected boolean isValidInput(Object element); /** * Answers if the given <code>element</code> is a valid * element for this part. * * @param element the object to test * @return <code>true</code> if the given element is a valid element */ protected boolean isValidElement(Object element) { if (element == null) return false; element= getSuitableRubyElement(element); if (element == null) return false; Object input= getViewer().getInput(); if (input == null) return false; if (input instanceof Collection) return ((Collection)input).contains(element); else return input.equals(element); } protected IType getTypeForRubyScript(IRubyScript script) { script = (IRubyScript) getSuitableRubyElement(script); // Use primary type if possible IType primaryType = script.findPrimaryType(); if (primaryType != null) return primaryType; // Use first top-level type try { IType[] types = script.getTypes(); if (types.length > 0) return types[0]; else return null; } catch (RubyModelException ex) { return null; } } public void dispose() { if (fViewer != null) { getViewSite().getPage().removePostSelectionListener(this); getViewSite().getPage().removePartListener(fPartListener); fViewer= null; } super.dispose(); } } --- NEW FILE: RubyBrowsingPerspectiveFactory.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.runtime.IAdaptable; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPerspectiveFactory; import org.eclipse.ui.IPlaceholderFolderLayout; import org.eclipse.ui.console.IConsoleConstants; import org.eclipse.ui.progress.IProgressConstants; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.ui.PreferenceConstants; import org.rubypeople.rdt.ui.RubyUI; public class RubyBrowsingPerspectiveFactory implements IPerspectiveFactory { /* * XXX: This is a workaround for: http://dev.eclipse.org/bugs/show_bug.cgi?id=13070 */ static IRubyElement fgRubyElementFromAction; /** * Constructs a new Default layout engine. */ public RubyBrowsingPerspectiveFactory() { super(); } public void createInitialLayout(IPageLayout layout) { if (stackBrowsingViewsVertically()) createVerticalLayout(layout); else createHorizontalLayout(layout); // action sets layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET); layout.addActionSet(RubyUI.ID_ACTION_SET); layout.addActionSet(RubyUI.ID_ELEMENT_CREATION_ACTION_SET); layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); // views - ruby //layout.addShowViewShortcut(RubyUI.ID_TYPE_HIERARCHY); layout.addShowViewShortcut(RubyUI.ID_PROJECTS_VIEW); layout.addShowViewShortcut(RubyUI.ID_TYPES_VIEW); layout.addShowViewShortcut(RubyUI.ID_MEMBERS_VIEW); // layout.addShowViewShortcut(RubyUI.ID_SOURCE_VIEW); // views - search layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID); // views - debugging layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW); // views - standard workbench layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW); layout.addShowViewShortcut(IPageLayout.ID_RES_NAV); // new actions - Ruby project creation wizard layout.addNewWizardShortcut("org.rubypeople.rdt.ui.wizards.NewProjectCreationWizard"); //$NON-NLS-1$ layout.addNewWizardShortcut("org.rubypeople.rdt.ui.wizards.NewClassCreationWizard"); //$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$ layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$ } private void createVerticalLayout(IPageLayout layout) { String relativePartId= IPageLayout.ID_EDITOR_AREA; int relativePos= IPageLayout.LEFT; IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ //placeHolderLeft.addPlaceholder(RubyUI.ID_TYPE_HIERARCHY); placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE); placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV); if (shouldShowProjectsView()) { layout.addView(RubyUI.ID_PROJECTS_VIEW, IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); relativePartId= RubyUI.ID_PROJECTS_VIEW; relativePos= IPageLayout.BOTTOM; } layout.addView(RubyUI.ID_TYPES_VIEW, relativePos, (float)0.33, relativePartId); layout.addView(RubyUI.ID_MEMBERS_VIEW, IPageLayout.BOTTOM, (float)0.50, RubyUI.ID_TYPES_VIEW); IPlaceholderFolderLayout placeHolderBottom= layout.createPlaceholderFolder("bottom", IPageLayout.BOTTOM, (float)0.75, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ placeHolderBottom.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW); placeHolderBottom.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID); placeHolderBottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW); placeHolderBottom.addPlaceholder(IPageLayout.ID_BOOKMARKS); // placeHolderBottom.addPlaceholder(RubyUI.ID_SOURCE_VIEW); placeHolderBottom.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID); } private void createHorizontalLayout(IPageLayout layout) { String relativePartId= IPageLayout.ID_EDITOR_AREA; int relativePos= IPageLayout.TOP; if (shouldShowProjectsView()) { layout.addView(RubyUI.ID_PROJECTS_VIEW, IPageLayout.TOP, (float)0.25, IPageLayout.ID_EDITOR_AREA); relativePartId= RubyUI.ID_PROJECTS_VIEW; relativePos= IPageLayout.RIGHT; } layout.addView(RubyUI.ID_TYPES_VIEW, relativePos, (float)0.33, relativePartId); layout.addView(RubyUI.ID_MEMBERS_VIEW, IPageLayout.RIGHT, (float)0.50, RubyUI.ID_TYPES_VIEW); IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ // placeHolderLeft.addPlaceholder(RubyUI.ID_TYPE_HIERARCHY); placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE); placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV); IPlaceholderFolderLayout placeHolderBottom= layout.createPlaceholderFolder("bottom", IPageLayout.BOTTOM, (float)0.75, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$ placeHolderBottom.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW); placeHolderBottom.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID); placeHolderBottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW); placeHolderBottom.addPlaceholder(IPageLayout.ID_BOOKMARKS); // placeHolderBottom.addPlaceholder(RubyUI.ID_SOURCE_VIEW); placeHolderBottom.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID); } private boolean shouldShowProjectsView() { return fgRubyElementFromAction == null || fgRubyElementFromAction.getElementType() == IRubyElement.RUBY_MODEL; } private boolean stackBrowsingViewsVertically() { return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.BROWSING_STACK_VERTICALLY); } /* * XXX: This is a workaround for: http://dev.eclipse.org/bugs/show_bug.cgi?id=13070 */ static void setInputFromAction(IAdaptable input) { if (input instanceof IRubyElement) fgRubyElementFromAction= (IRubyElement)input; else fgRubyElementFromAction= null; } } --- NEW FILE: ProjectContentProvider.java --- package org.rubypeople.rdt.internal.ui.browsing; import java.util.Iterator; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.IContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.rubypeople.rdt.core.IRubyProject; public class ProjectContentProvider extends RubyBrowsingContentProvider implements IContentProvider { ProjectContentProvider(RubyBrowsingPart browsingPart) { super(false, browsingPart); } /* * (non-Javadoc) Method declared on ITreeContentProvider. */ public Object[] getChildren(Object element) { if (!exists(element)) return NO_CHILDREN; try { startReadInDisplayThread(); if (element instanceof IStructuredSelection) { Assert.isLegal(false); Object[] result = new Object[0]; Class clazz = null; Iterator iter = ((IStructuredSelection) element).iterator(); while (iter.hasNext()) { Object item = iter.next(); if (clazz == null) clazz = item.getClass(); if (clazz == item.getClass()) result = concatenate(result, getChildren(item)); else return NO_CHILDREN; } return result; } if (element instanceof IStructuredSelection) { Assert.isLegal(false); Object[] result = new Object[0]; Iterator iter = ((IStructuredSelection) element).iterator(); while (iter.hasNext()) result = concatenate(result, getChildren(iter.next())); return result; } if (element instanceof IRubyProject) return NO_CHILDREN; return super.getChildren(element); //} catch (RubyModelException e) { // return NO_CHILDREN; } finally { finishedReadInDisplayThread(); } } /* * * @see ITreeContentProvider */ public boolean hasChildren(Object element) { return element instanceof IRubyProject && super.hasChildren(element); } } --- NEW FILE: TypesView.java --- package org.rubypeople.rdt.internal.ui.browsing; import org.rubypeople.rdt.core.IMember; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyProject; import org.rubypeople.rdt.core.IRubyScript; import org.rubypeople.rdt.core.IType; public class TypesView extends RubyBrowsingPart { /** * Answers if the given <code>element</code> is a valid input for this * part. * * @param element * the object to test * @return <true> if the given element is a valid input */ protected boolean isValidInput(Object element) { return element instanceof IRubyProject; } /** * Finds the element which has to be selected in this part. * * @param je * the Ruby element which has the focus */ protected IRubyElement findElementToSelect(IRubyElement je) { if (je == null) return null; switch (je.getElementType()) { case IRubyElement.TYPE: IType type = ((IType) je).getDeclaringType(); if (type == null) type = (IType) je; return getSuitableRubyElement(type); case IRubyElement.SCRIPT: return getTypeForRubyScript((IRubyScript) je); case IRubyElement.IMPORT_CONTAINER: case IRubyElement.IMPORT_DECLARATION: return findElementToSelect(je.getParent()); default: if (je instanceof IMember) return findElementToSelect(((IMember) je).getDeclaringType()); return null; } } /** * Answers if the given <code>element</code> is a valid * element for this part. * * @param element the object to test * @return <true> if the given element is a valid element */ protected boolean isValidElement(Object element) { if (element instanceof IRubyScript) return super.isValidElement(((IRubyScript)element).getParent()); else if (element instanceof IType) { IType type= (IType)element; return type.getDeclaringType() == null && isValidElement(type.getRubyScript()); } return false; } } --- NEW FILE: MembersView.java --- package org.rubypeople.rdt.internal.ui.browsing; import org.rubypeople.rdt.core.IImportContainer; import org.rubypeople.rdt.core.IImportDeclaration; import org.rubypeople.rdt.core.IMember; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyScript; 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 * input for this part. * * @param element the object to test * @return <true> if the given element is a valid input */ protected boolean isValidInput(Object element) { if (element instanceof IType) { IType type= (IType)element; return type.getDeclaringType() == null; } return false; } /** * Answers if the given <code>element</code> is a valid * element for this part. * * @param element the object to test * @return <true> if the given element is a valid element */ protected boolean isValidElement(Object element) { if (element instanceof IMember) return super.isValidElement(((IMember)element).getDeclaringType()); else if (element instanceof IImportDeclaration) return isValidElement(((IRubyElement)element).getParent()); else if (element instanceof IImportContainer) { Object input= getViewer().getInput(); if (input instanceof IRubyElement) { IRubyScript cu= (IRubyScript)((IRubyElement)input).getAncestor(IRubyElement.SCRIPT); if (cu != null) { IRubyScript importContainerCu= (IRubyScript)((IRubyElement)element).getAncestor(IRubyElement.SCRIPT); return cu.equals(importContainerCu); } } } return false; } /** * Finds the element which has to be selected in this part. * * @param je the Ruby element which has the focus */ protected IRubyElement findElementToSelect(IRubyElement je) { if (je == null) return null; switch (je.getElementType()) { case IRubyElement.TYPE: if (((IType)je).getDeclaringType() == null) return null; // fall through case IRubyElement.METHOD: // fall through case IRubyElement.FIELD: // fall through case IRubyElement.IMPORT_CONTAINER: return getSuitableRubyElement(je); case IRubyElement.IMPORT_DECLARATION: je= getSuitableRubyElement(je); if (je != null) { IRubyScript cu= (IRubyScript)je.getParent().getParent(); try { if (cu.getImports()[0].equals(je)) { Object selectedElement= getSingleElementFromSelection(getViewer().getSelection()); if (selectedElement instanceof IImportContainer) return (IImportContainer)selectedElement; } } catch (RubyModelException ex) { // return je; } return je; } break; } return null; } /** * Finds the closest Ruby element which can be used as input for * this part and has the given Ruby element as child * * @param je the Ruby element for which to search the closest input * @return the closest Ruby element used as input for this part */ protected IRubyElement findInputForRubyElement(IRubyElement je) { if (je == null || !je.exists()) return null; switch (je.getElementType()) { case IRubyElement.TYPE: IType type= ((IType)je).getDeclaringType(); if (type == null) return je; else return findInputForRubyElement(type); case IRubyElement.SCRIPT: return getTypeForRubyScript((IRubyScript)je); case IRubyElement.IMPORT_DECLARATION: return findInputForRubyElement(je.getParent()); case IRubyElement.IMPORT_CONTAINER: IRubyElement parent= je.getParent(); if (parent instanceof IRubyScript) { return getTypeForRubyScript((IRubyScript)parent); } default: if (je instanceof IMember) return findInputForRubyElement(((IMember)je).getDeclaringType()); } return null; } boolean isInputAWorkingCopy() { Object input= getViewer().getInput(); if (input instanceof IRubyElement) { IRubyScript cu= (IRubyScript)((IRubyElement)input).getAncestor(IRubyElement.SCRIPT); if (cu != null) return cu.isWorkingCopy(); } return false; } } --- NEW FILE: RubyBrowsingContentProvider.java --- package org.rubypeople.rdt.internal.ui.browsing; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.List; import org.eclipse.core.resources.IResource; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.rubypeople.rdt.core.IImportContainer; import org.rubypeople.rdt.core.IParent; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyProject; import org.rubypeople.rdt.core.IRubyScript; import org.rubypeople.rdt.core.ISourceReference; import org.rubypeople.rdt.core.IType; 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; private StructuredViewer fViewer; private int fReadsInDisplayThread; private Object fInput; public RubyBrowsingContentProvider(boolean provideMembers, RubyBrowsingPart browsingPart) { super(provideMembers); fBrowsingPart = browsingPart; fViewer = fBrowsingPart.getViewer(); // TODO Add element change listener // RubyCore.addElementChangedListener(this); } public boolean hasChildren(Object element) { startReadInDisplayThread(); try { return super.hasChildren(element); } finally { finishedReadInDisplayThread(); } } public Object[] getChildren(Object element) { if (!exists(element)) return NO_CHILDREN; startReadInDisplayThread(); try { if (element instanceof Collection) { Collection elements = (Collection) element; if (elements.isEmpty()) return NO_CHILDREN; Object[] result = new Object[0]; Iterator iter = ((Collection) element).iterator(); while (iter.hasNext()) { Object[] children = getChildren(iter.next()); if (children != NO_CHILDREN) result = concatenate(result, children); } return result; } if (fProvideMembers && element instanceof IType) return getChildren((IType) element); if (fProvideMembers && element instanceof ISourceReference && element instanceof IParent) return super.getChildren(element); if (element instanceof IRubyProject) return getRubyTypes((IRubyProject) element); return super.getChildren(element); } catch (RubyModelException e) { return NO_CHILDREN; } finally { finishedReadInDisplayThread(); } } private Object[] getChildren(IType type) throws RubyModelException{ IParent parent= type.getRubyScript(); if (type.getDeclaringType() != null) return type.getChildren(); // Add import declarations IRubyElement[] members= parent.getChildren(); ArrayList tempResult= new ArrayList(members.length); for (int i= 0; i < members.length; i++) if ((members[i] instanceof IImportContainer)) tempResult.add(members[i]); tempResult.addAll(Arrays.asList(type.getChildren())); return tempResult.toArray(); } private Object[] getRubyTypes(IRubyProject project) throws RubyModelException { Object[] scripts = getRubyScripts(project); List list = new ArrayList(); for (int i = 0; i < scripts.length; i++) { IRubyScript script = (IRubyScript) scripts[i]; Object[] types = script.getTypes(); for (int j = 0; j < types.length; j++) { list.add(types[j]); } } return concatenate(list.toArray(), new Object[] {}); } protected Object[] getRubyScripts(IRubyProject project) throws RubyModelException { if (!project.getProject().isOpen()) return NO_CHILDREN; return project.getRubyScripts(); } private boolean isDisplayThread() { Control ctrl = fViewer.getControl(); if (ctrl == null) return false; Display currentDisplay = Display.getCurrent(); return currentDisplay != null && currentDisplay.equals(ctrl.getDisplay()); } protected void startReadInDisplayThread() { if (isDisplayThread()) fReadsInDisplayThread++; } protected void finishedReadInDisplayThread() { if (isDisplayThread()) fReadsInDisplayThread--; } /* * (non-Javadoc) Method declared on IContentProvider. */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { super.inputChanged(viewer, oldInput, newInput); if (newInput instanceof Collection) { // Get a template object from the collection Collection col = (Collection) newInput; if (!col.isEmpty()) newInput = col.iterator().next(); else newInput = null; } fInput = newInput; } /* * (non-Javadoc) Method declared on IContentProvider. */ public void dispose() { super.dispose(); // TODO Listen for element changes // RubyCore.removeElementChangedListener(this); } /** * Returns the parent for the element. * <p> * Note: This method will return a working copy if the parent is a working * copy. The super class implementation returns the original element * instead. * </p> */ protected Object internalGetParent(Object element) { if (element instanceof IRubyProject) { return ((IRubyProject) element).getRubyModel(); } // try to map resources to the containing package fragment if (element instanceof IResource) { IResource parent = ((IResource) element).getParent(); Object jParent = RubyCore.create(parent); if (jParent != null) return jParent; return parent; } if (element instanceof IRubyElement) return ((IRubyElement) element).getParent(); return null; } } --- NEW FILE: ProjectsView.java --- package org.rubypeople.rdt.internal.ui.browsing; import org.eclipse.jface.viewers.IContentProvider; import org.eclipse.ui.IPageLayout; import org.eclipse.ui.part.IShowInTargetList; import org.rubypeople.rdt.core.IRubyElement; import org.rubypeople.rdt.core.IRubyModel; import org.rubypeople.rdt.core.IRubyProject; import org.rubypeople.rdt.core.RubyCore; import org.rubypeople.rdt.internal.ui.RubyPlugin; import org.rubypeople.rdt.ui.RubyUI; public class ProjectsView extends RubyBrowsingPart { /** * Creates the the content provider of this part. */ protected IContentProvider createContentProvider() { return new ProjectContentProvider(this); } protected void setInitialInput() { IRubyElement root = RubyCore .create(RubyPlugin.getWorkspace().getRoot()); getViewer().setInput(root); // TODO Update the title // updateTitle(); } /** * Answer the property defined by key. */ public Object getAdapter(Class key) { if (key == IShowInTargetList.class) { return new IShowInTargetList() { public String[] getShowInTargetIds() { return new String[] { RubyUI.ID_TYPES_VIEW, IPageLayout.ID_RES_NAV }; } }; } return super.getAdapter(key); } /** * Answers if the given <code>element</code> is a valid input for this * part. * * @param element * the object to test * @return <true> if the given element is a valid input */ protected boolean isValidInput(Object element) { return element instanceof IRubyModel; } /** * Answers if the given <code>element</code> is a valid element for this * part. * * @param element * the object to test * @return <true> if the given element is a valid element */ protected boolean isValidElement(Object element) { return element instanceof IRubyProject; } /** * Finds the element which has to be selected in this part. * * @param je the Ruby element which has the focus */ protected IRubyElement findElementToSelect(IRubyElement je) { if (je == null) return null; switch (je.getElementType()) { case IRubyElement.RUBY_MODEL : return null; case IRubyElement.RUBY_PROJECT: return je; default : return findElementToSelect(je.getParent()); } } } |
|
From: Christopher W. <caw...@us...> - 2006-03-25 02:37:50
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11479/src/org/rubypeople/rdt/internal/ui/viewsupport Modified Files: RubyElementImageProvider.java Log Message: my initial working version of a Ruby Browsing Perspective Index: RubyElementImageProvider.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/viewsupport/RubyElementImageProvider.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RubyElementImageProvider.java 10 Feb 2006 19:54:46 -0000 1.1 --- RubyElementImageProvider.java 25 Mar 2006 02:37:44 -0000 1.2 *************** *** 191,195 **** return RubyPluginImages.DESC_OBJS_INSTANCE_VAR; ! case IRubyElement.IMPORT: return RubyPluginImages.DESC_OBJS_IMPDECL; --- 191,195 ---- return RubyPluginImages.DESC_OBJS_INSTANCE_VAR; ! case IRubyElement.IMPORT_DECLARATION: return RubyPluginImages.DESC_OBJS_IMPDECL; *************** *** 208,212 **** return RubyPluginImages.DESC_OBJS_SCRIPT; ! case IRubyElement.PROJECT: IRubyProject jp = (IRubyProject) element; if (jp.getProject().isOpen()) { --- 208,212 ---- return RubyPluginImages.DESC_OBJS_SCRIPT; ! case IRubyElement.RUBY_PROJECT: IRubyProject jp = (IRubyProject) element; if (jp.getProject().isOpen()) { |