Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11479/src/org/rubypeople/rdt/ui Modified Files: RubyElementLabels.java RubyUI.java PreferenceConstants.java RubyElementSorter.java Added Files: StandardRubyElementContentProvider.java Log Message: my initial working version of a Ruby Browsing Perspective Index: RubyElementLabels.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RubyElementLabels.java 10 Feb 2006 19:54:54 -0000 1.1 --- RubyElementLabels.java 25 Mar 2006 02:37:43 -0000 1.2 *************** *** 319,326 **** break; case IRubyElement.IMPORT_CONTAINER: ! case IRubyElement.IMPORT: getDeclarationLabel(element, flags, buf); break; ! case IRubyElement.PROJECT: case IRubyElement.RUBY_MODEL: buf.append(element.getElementName()); --- 319,326 ---- break; case IRubyElement.IMPORT_CONTAINER: ! case IRubyElement.IMPORT_DECLARATION: getDeclarationLabel(element, flags, buf); break; ! case IRubyElement.RUBY_PROJECT: case IRubyElement.RUBY_MODEL: buf.append(element.getElementName()); Index: PreferenceConstants.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PreferenceConstants.java 18 Feb 2006 16:53:51 -0000 1.12 --- PreferenceConstants.java 25 Mar 2006 02:37:44 -0000 1.13 *************** *** 224,227 **** --- 224,236 ---- public static final String FORMATTER_PROFILE = "formatter_profile"; //$NON-NLS-1$ + /** + * A named preference that controls the layout of the Ruby Browsing views vertically. Boolean value. + * <p> + * Value is of type <code>Boolean</code>. If <code>true<code> the views are stacked vertical. + * If <code>false</code> they are stacked horizontal. + * </p> + */ + public static final String BROWSING_STACK_VERTICALLY= "org.rubypeople.rdt.ui.browsing.stackVertically"; //$NON-NLS-1$ + public static void initializeDefaultValues(IPreferenceStore store) { store.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false); *************** *** 245,248 **** --- 254,258 ---- store.setDefault(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES, false); store.setDefault(PreferenceConstants.APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW, ""); //$NON-NLS-1$ + store.setDefault(PreferenceConstants.BROWSING_STACK_VERTICALLY, false); // TODO Expose these preferences to the user! Index: RubyElementSorter.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementSorter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RubyElementSorter.java 10 Feb 2006 19:54:54 -0000 1.4 --- RubyElementSorter.java 25 Mar 2006 02:37:44 -0000 1.5 *************** *** 102,108 **** case IRubyElement.IMPORT_CONTAINER: return IMPORT_CONTAINER; ! case IRubyElement.IMPORT: return IMPORT_DECLARATION; ! case IRubyElement.PROJECT: return PROJECTS; case IRubyElement.SCRIPT: --- 102,108 ---- case IRubyElement.IMPORT_CONTAINER: return IMPORT_CONTAINER; ! case IRubyElement.IMPORT_DECLARATION: return IMPORT_DECLARATION; ! case IRubyElement.RUBY_PROJECT: return PROJECTS; case IRubyElement.SCRIPT: --- NEW FILE: StandardRubyElementContentProvider.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; import java.util.ArrayList; import java.util.List; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.Viewer; import org.rubypeople.rdt.core.*; /** * A base content provider for Ruby elements. It provides access to the * Ruby element hierarchy without listening to changes in the Ruby model. * If updating the presentation on Ruby model change is required than * clients have to subclass, listen to Ruby model changes and have to update * the UI using corresponding methods provided by the JFace viewers or their * own UI presentation. * <p> * The following Ruby element hierarchy is surfaced by this content provider: * <p> * <pre> Ruby model (<code>IRubyModel</code>) Ruby project (<code>IRubyProject</code>) package fragment root (<code>IPackageFragmentRoot</code>) package fragment (<code>IPackageFragment</code>) compilation unit (<code>ICompilationUnit</code>) binary class file (<code>IClassFile</code>) * </pre> * </p> * <p> * Note that when the entire Ruby project is declared to be package fragment root, * the corresponding package fragment root element that normally appears between the * Ruby project and the package fragments is automatically filtered out. * </p> * * @since 2.0 */ public class StandardRubyElementContentProvider implements ITreeContentProvider { protected static final Object[] NO_CHILDREN= new Object[0]; protected boolean fProvideMembers; protected boolean fProvideWorkingCopy; /** * Creates a new content provider. The content provider does not * provide members of compilation units or class files. */ public StandardRubyElementContentProvider() { this(false); } /** *@deprecated Use {@link #StandardRubyElementContentProvider(boolean)} instead. * Since 3.0 compilation unit children are always provided as working copies. The Ruby Model * does not support the 'original' mode anymore. */ public StandardRubyElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) { this(provideMembers); } /** * Creates a new <code>StandardRubyElementContentProvider</code>. * * @param provideMembers if <code>true</code> members below compilation units * and class files are provided. */ public StandardRubyElementContentProvider(boolean provideMembers) { fProvideMembers= provideMembers; fProvideWorkingCopy= provideMembers; } /** * Returns whether members are provided when asking * for a compilation units or class file for its children. * * @return <code>true</code> if the content provider provides members; * otherwise <code>false</code> is returned */ public boolean getProvideMembers() { return fProvideMembers; } /** * Sets whether the content provider is supposed to return members * when asking a compilation unit or class file for its children. * * @param b if <code>true</code> then members are provided. * If <code>false</code> compilation units and class files are the * leaves provided by this content provider. */ public void setProvideMembers(boolean b) { //hello fProvideMembers= b; } /** * @deprecated Since 3.0 compilation unit children are always provided as working copies. The Ruby model * does not support the 'original' mode anymore. */ public boolean getProvideWorkingCopy() { return fProvideWorkingCopy; } /** * @deprecated Since 3.0 compilation unit children are always provided from the working copy. The Ruby model * offers a unified world and does not support the 'original' mode anymore. */ public void setProvideWorkingCopy(boolean b) { fProvideWorkingCopy= b; } /* (non-Rubydoc) * @see IWorkingCopyProvider#providesWorkingCopies() */ public boolean providesWorkingCopies() { return getProvideWorkingCopy(); } /* (non-Rubydoc) * Method declared on IStructuredContentProvider. */ public Object[] getElements(Object parent) { return getChildren(parent); } /* (non-Rubydoc) * Method declared on IContentProvider. */ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } /* (non-Rubydoc) * Method declared on IContentProvider. */ public void dispose() { } /* (non-Rubydoc) * Method declared on ITreeContentProvider. */ public Object[] getChildren(Object element) { if (!exists(element)) return NO_CHILDREN; try { if (element instanceof IRubyModel) return getRubyProjects((IRubyModel)element); if (element instanceof IRubyProject) return getRubyScripts((IRubyProject)element); if (element instanceof IFolder) return getResources((IFolder)element); if (getProvideMembers() && element instanceof ISourceReference && element instanceof IParent) { return ((IParent)element).getChildren(); } } catch (RubyModelException e) { return NO_CHILDREN; } return NO_CHILDREN; } private Object[] getRubyScripts(IRubyProject project) throws RubyModelException { return project.getRubyScripts(); } /* (non-Rubydoc) * @see ITreeContentProvider */ public boolean hasChildren(Object element) { if (getProvideMembers()) { // assume scripts are never empty if (element instanceof IRubyScript) { return true; } } else { // don't allow to drill down into a script if (element instanceof IRubyScript || element instanceof IFile) return false; } if (element instanceof IRubyProject) { IRubyProject jp= (IRubyProject)element; if (!jp.getProject().isOpen()) { return false; } } if (element instanceof IParent) { try { // when we have Ruby children return true, else we fetch all the children if (((IParent)element).hasChildren()) return true; } catch(RubyModelException e) { return true; } } Object[] children= getChildren(element); return (children != null) && children.length > 0; } /* (non-Rubydoc) * Method declared on ITreeContentProvider. */ public Object getParent(Object element) { if (!exists(element)) return null; return internalGetParent(element); } /** * Note: This method is for internal use only. Clients should not call this method. */ protected Object[] getRubyProjects(IRubyModel jm) throws RubyModelException { return jm.getRubyProjects(); } private Object[] getResources(IFolder folder) { try { IResource[] members= folder.members(); IRubyProject javaProject= RubyCore.create(folder.getProject()); if (javaProject == null || !javaProject.exists()) return members; // boolean isFolderOnClasspath = javaProject.isOnClasspath(folder); boolean isFolderOnClasspath = true; List nonRubyResources= new ArrayList(); // Can be on classpath but as a member of non-java resource folder for (int i= 0; i < members.length; i++) { IResource member= members[i]; // A resource can also be a java element // in the case of exclusion and inclusion filters. // We therefore exclude Ruby elements from the list // of non-Ruby resources. if (isFolderOnClasspath) { // if (javaProject.findPackageFragmentRoot(member.getFullPath()) == null) { // nonRubyResources.add(member); // } // } else if (!javaProject.isOnClasspath(member)) { // nonRubyResources.add(member); } } return nonRubyResources.toArray(); } catch(CoreException e) { return NO_CHILDREN; } } /** * Note: This method is for internal use only. Clients should not call this method. */ protected boolean isClassPathChange(IRubyElementDelta delta) { // need to test the flags only for package fragment roots //if (delta.getElement().getElementType() != IRubyElement.PACKAGE_FRAGMENT_ROOT) return false; // int flags= delta.getFlags(); // return (delta.getKind() == IRubyElementDelta.CHANGED && // ((flags & IRubyElementDelta.F_ADDED_TO_CLASSPATH) != 0) || // ((flags & IRubyElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) || // ((flags & IRubyElementDelta.F_REORDER) != 0)); } /** * Note: This method is for internal use only. Clients should not call this method. */ protected boolean exists(Object element) { if (element == null) { return false; } if (element instanceof IResource) { return ((IResource)element).exists(); } if (element instanceof IRubyElement) { return ((IRubyElement)element).exists(); } return true; } /** * Note: This method is for internal use only. Clients should not call this method. */ protected Object internalGetParent(Object element) { // try to map resources to the containing package fragment if (element instanceof IResource) { IResource parent= ((IResource)element).getParent(); IRubyElement jParent= RubyCore.create(parent); // http://bugs.eclipse.org/bugs/show_bug.cgi?id=31374 if (jParent != null && jParent.exists()) return jParent; return parent; } else if (element instanceof IRubyElement) { IRubyElement parent= ((IRubyElement) element).getParent(); return parent; } return null; } /** * Note: This method is for internal use only. Clients should not call this method. */ protected static Object[] concatenate(Object[] a1, Object[] a2) { int a1Len= a1.length; int a2Len= a2.length; Object[] res= new Object[a1Len + a2Len]; System.arraycopy(a1, 0, res, 0, a1Len); System.arraycopy(a2, 0, res, a1Len, a2Len); return res; } } Index: RubyUI.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RubyUI.java 12 Mar 2005 15:32:34 -0000 1.1 --- RubyUI.java 25 Mar 2006 02:37:44 -0000 1.2 *************** *** 35,37 **** --- 35,70 ---- */ public static final String ID_PLUGIN = "org.rubypeople.rdt.ui"; //$NON-NLS-1$ + public static final String ID_ACTION_SET = null; + + /** + * The view part id of the Ruby Browsing Projects view + * (value <code>"org.rubypeople.rdt.ui.ProjectsView"</code>). + * + * @since 0.8.0 + */ + public static String ID_PROJECTS_VIEW= "org.rubypeople.rdt.ui.ProjectsView"; //$NON-NLS-1$ + + /** + * The view part id of the Ruby Browsing Types view + * (value <code>"org.rubypeople.rdt.ui.TypesView"</code>). + * + * @since 0.8.0 + */ + public static String ID_TYPES_VIEW= "org.rubypeople.rdt.ui.TypesView"; //$NON-NLS-1$ + + /** + * The view part id of the Ruby Browsing Memberss view + * (value <code>"org.rubypeople.rdt.ui.MembersView"</code>). + * + * @since 0.8.0 + */ + public static String ID_MEMBERS_VIEW= "org.rubypeople.rdt.ui.MembersView"; //$NON-NLS-1$ + + /** + * The id of the Ruby Element Creation action set + * (value <code>"org.rubypeople.rdt.ui.RubyElementCreationActionSet"</code>). + * + * @since 0.8.0 + */ + public static final String ID_ELEMENT_CREATION_ACTION_SET= "org.rubypeople.rdt.ui.RubyElementCreationActionSet"; //$NON-NLS-1$ } \ No newline at end of file |