1 11 package org.eclipse.compare; 12 13 import org.eclipse.swt.widgets.*; 14 import org.eclipse.swt.custom.SashForm; 15 16 28 public class Splitter extends SashForm { 29 30 private static final String VISIBILITY= "org.eclipse.compare.internal.visibility"; 32 55 public Splitter(Composite parent, int style) { 56 super(parent, style); 57 } 58 59 68 public void setVisible(Control child, boolean visible) { 69 70 boolean wasEmpty= isEmpty(); 71 72 child.setVisible(visible); 73 child.setData(VISIBILITY, new Boolean (visible)); 74 75 if (wasEmpty != isEmpty()) { 76 Composite parent= getParent(); 78 if (parent instanceof Splitter) { 79 Splitter sp= (Splitter) parent; 80 sp.setVisible(this, visible); 81 sp.layout(); 82 } 83 } else { 84 layout(); 85 } 86 } 87 88 92 public void setMaximizedControl(Control control) { 93 if (control == null || control == getMaximizedControl()) 94 super.setMaximizedControl(null); 95 else 96 super.setMaximizedControl(control); 97 98 Composite parent= getParent(); 100 if (parent instanceof Splitter) 101 ((Splitter) parent).setMaximizedControl(this); 102 else 103 layout(true); 104 } 105 106 109 private boolean isEmpty() { 110 Control[] controls= getChildren(); 111 for (int i= 0; i < controls.length; i++) 112 if (isVisible(controls[i])) 113 return false; 114 return true; 115 } 116 117 121 private boolean isVisible(Control child) { 122 if (child instanceof Sash) 123 return false; 124 Object data= child.getData(VISIBILITY); 125 if (data instanceof Boolean ) 126 return ((Boolean )data).booleanValue(); 127 return true; 128 } 129 } 130 | Popular Tags |