Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Tweaks to outline view. #19

Merged
merged 3 commits into from

2 participants

@clanehin

Thanks,
--Lane

clanehin added some commits
@clanehin clanehin Use a different icon for the constructor -vs- data declaration. b75bf90
@clanehin clanehin Compressed outline view.
When a data declaration contains a single constructor with a name identical
to the data declaration, this hides the node for the constructor and
expands the constructor's children directly.  The intent is to reduce the
busy-ness of the outline view and the amount of repetative clicking to expand
it, without ever hiding any information.
ce2df95
@clanehin clanehin Merge branch 'master' of git://github.com/JPMoresmau/eclipsefp 20b8650
@JPMoresmau JPMoresmau merged commit e2772f7 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 11, 2011
  1. @clanehin
  2. @clanehin

    Compressed outline view.

    clanehin authored
    When a data declaration contains a single constructor with a name identical
    to the data declaration, this hides the node for the constructor and
    expands the constructor's children directly.  The intent is to reduce the
    busy-ness of the outline view and the amount of repetative clicking to expand
    it, without ever hiding any information.
  3. @clanehin
This page is out of date. Refresh to see the latest.
View
BIN  net.sf.eclipsefp.haskell.ui/icons/obj16/constructordecl.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
30 net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/outline/OutlineCP.java
@@ -6,6 +6,7 @@
import java.util.List;
import java.util.Map;
import net.sf.eclipsefp.haskell.scion.types.OutlineDef;
+import net.sf.eclipsefp.haskell.scion.types.OutlineDef.OutlineDefType;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
@@ -17,8 +18,35 @@
public class OutlineCP implements ITreeContentProvider{
private Map<String,List<OutlineDef>> input;
+ /**
+ * For elements that expand into an identically-named single element with an obvious
+ * type, we could just expand directly into that child element's children.
+ */
+ public boolean hasSingularChild( final Object o ){
+ if( ((OutlineDef)o).getType() != OutlineDefType.DATA ) {
+ return false;
+ }
+
+ Object[] children = getRawChildren( o );
+
+ if( children.length != 1 ) {
+ return false;
+ }
+
+ return ((OutlineDef)children[0]).getType() == OutlineDefType.CONSTRUCTOR &&
+ ((OutlineDef)children[0]).getName().equals( ((OutlineDef)o).getName() );
+ }
+
public Object[] getChildren( final Object parentElement ) {
- //return input.toArray();
+ Object[] result = getRawChildren( parentElement );
+ if( hasSingularChild( parentElement ) ) {
+ return getChildren( result[0] );
+ } else {
+ return result;
+ }
+ }
+
+ public Object[] getRawChildren( final Object parentElement ) {
List<OutlineDef> l=input.get(((OutlineDef )parentElement).getID());
if (l!=null){
return l.toArray();
View
2  ...sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/internal/views/outline/OutlineLabelProvider.java
@@ -25,7 +25,7 @@
imageKeysByType.put(OutlineDef.OutlineDefType.SYN,IImageNames.TYPE_DECL);
imageKeysByType.put(OutlineDef.OutlineDefType.INSTANCE,IImageNames.INSTANCE_DECL);
imageKeysByType.put(OutlineDef.OutlineDefType.FIELD,IImageNames.FIELD_DECL);
- imageKeysByType.put(OutlineDef.OutlineDefType.CONSTRUCTOR,IImageNames.DATA_DECL);
+ imageKeysByType.put(OutlineDef.OutlineDefType.CONSTRUCTOR,IImageNames.CONSTRUCTOR_DECL);
}
View
1  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/util/HaskellUIImages.java
@@ -91,6 +91,7 @@ private static void declareImages() {
declare( FUNCTION_BINDING, OBJECT + "functionbinding.gif" ); //$NON-NLS-1$
declare( PATTERN_BINDING, OBJECT + "patternbinding.gif" ); //$NON-NLS-1$
declare( DATA_DECL, OBJECT + "datadecl.gif" ); //$NON-NLS-1$
+ declare( CONSTRUCTOR_DECL, OBJECT + "constructordecl.gif" ); //$NON-NLS-1$
declare( TYPE_DECL, OBJECT + "typedecl.gif" ); //$NON-NLS-1$
declare( NEWTYPE_DECL, OBJECT + "typedecl.gif" ); //$NON-NLS-1$
declare( TYPE_SIGNATURE, OBJECT + "typesig.gif" ); //$NON-NLS-1$
View
1  net.sf.eclipsefp.haskell.ui/src/net/sf/eclipsefp/haskell/ui/util/IImageNames.java
@@ -48,6 +48,7 @@
String FUNCTION_BINDING = ID + ".FUNCTION_BINDING"; //$NON-NLS-1$
String PATTERN_BINDING = ID + ".PATTERN_BINDING"; //$NON-NLS-1$
String DATA_DECL = ID + ".DATA_DECL"; //$NON-NLS-1$
+ String CONSTRUCTOR_DECL = ID + ".CONSTRUCTOR_DECL"; //$NON-NLS-1$
String TYPE_SIGNATURE = ID + ".TYPE_SIGNATURE"; //$NON-NLS-1$
String TYPE_DECL = ID + ".TYPE_DECL"; //$NON-NLS-1$
String NEWTYPE_DECL = ID + ".NEWTYPE_DECL"; //$NON-NLS-1$
Something went wrong with that request. Please try again.