Skip to content
Browse files

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.
  • Loading branch information...
1 parent b75bf90 commit ce2df954252c597526075f06182f80b2dcf35bc2 @clanehin clanehin committed May 11, 2011
View
30 ...clipsefp.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();

0 comments on commit ce2df95

Please sign in to comment.
Something went wrong with that request. Please try again.