1 11 package org.eclipse.ui.internal.presentations.defaultpresentation; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.events.PaintEvent; 15 import org.eclipse.swt.events.PaintListener; 16 import org.eclipse.swt.graphics.Color; 17 import org.eclipse.swt.graphics.Point; 18 import org.eclipse.swt.graphics.Rectangle; 19 import org.eclipse.swt.widgets.Composite; 20 import org.eclipse.swt.widgets.Control; 21 import org.eclipse.ui.internal.presentations.util.AbstractTabFolder; 22 import org.eclipse.ui.internal.presentations.util.AbstractTabItem; 23 import org.eclipse.ui.internal.presentations.util.EnhancedFillLayout; 24 import org.eclipse.ui.internal.presentations.util.PartInfo; 25 26 33 public class EmptyTabFolder extends AbstractTabFolder { 34 35 private Composite control; 36 private Control childControl; 37 private Color borderColor; 38 39 public EmptyTabFolder(Composite parent, boolean showborder) { 40 control = new Composite(parent, SWT.NONE); 41 EnhancedFillLayout layout = new EnhancedFillLayout(); 42 control.setLayout(layout); 43 borderColor = parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); 44 if (showborder) { 45 layout.xmargin = 1; 46 layout.ymargin = 1; 47 control.addPaintListener(new PaintListener() { 48 public void paintControl(PaintEvent e) { 49 e.gc.setForeground(borderColor); 50 Rectangle rect = control.getClientArea(); 51 rect.width--; 52 rect.height--; 53 e.gc.drawRectangle(rect); 54 } 55 }); 56 } 57 } 58 59 62 public Point computeSize(int widthHint, int heightHint) { 63 if (childControl != null) { 64 if (childControl instanceof Composite) { 72 Composite composite = (Composite) childControl; 73 if (composite.getChildren().length == 0) { 74 EnhancedFillLayout layout = (EnhancedFillLayout) control.getLayout(); 75 int w = widthHint == SWT.DEFAULT ? layout.xmargin * 2 : widthHint; 76 int h = heightHint == SWT.DEFAULT ? layout.ymargin * 2 : heightHint; 77 return new Point(w, h); 78 } 79 } 80 return childControl.computeSize(widthHint, heightHint); 81 } 82 return new Point(0,0); 83 } 84 85 88 public AbstractTabItem add(int index, int flags) { 89 return new EmptyTabItem(); 90 } 91 92 95 public Composite getContentParent() { 96 return control; 97 } 98 99 102 public void setContent(Control newContent) { 103 childControl = newContent; 104 } 105 106 109 public AbstractTabItem[] getItems() { 110 return new AbstractTabItem[0]; 111 } 112 113 116 public AbstractTabItem getSelection() { 117 return null; 118 } 119 120 123 public void setSelection(AbstractTabItem toSelect) { 124 125 } 126 127 public void setToolbar(Control toolbar) { 128 if (toolbar != null) { 129 toolbar.setVisible(false); 130 } 131 } 132 133 public void layout(boolean flushCache) { 134 super.layout(flushCache); 135 136 control.layout(flushCache); 137 } 138 139 142 public void setSelectedInfo(PartInfo info) { 143 144 } 145 146 149 public void enablePaneMenu(boolean enabled) { 150 151 } 152 153 156 public Composite getToolbarParent() { 157 return control; 158 } 159 160 163 public Control getControl() { 164 return control; 165 } 166 167 170 public Rectangle getTabArea() { 171 return new Rectangle(0,0,0,0); 172 } 173 } 174 | Popular Tags |