001: /*******************************************************************************
002: * Copyright (c) 2004, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal.presentations;
011:
012: import java.util.ArrayList;
013: import java.util.Iterator;
014: import java.util.List;
015:
016: import org.eclipse.jface.util.Geometry;
017: import org.eclipse.swt.SWT;
018: import org.eclipse.swt.custom.CTabFolder;
019: import org.eclipse.swt.custom.CTabFolder2Adapter;
020: import org.eclipse.swt.custom.CTabFolderEvent;
021: import org.eclipse.swt.custom.CTabItem;
022: import org.eclipse.swt.custom.ViewForm;
023: import org.eclipse.swt.events.ControlEvent;
024: import org.eclipse.swt.events.ControlListener;
025: import org.eclipse.swt.events.DisposeEvent;
026: import org.eclipse.swt.events.DisposeListener;
027: import org.eclipse.swt.events.MouseAdapter;
028: import org.eclipse.swt.events.MouseEvent;
029: import org.eclipse.swt.events.MouseListener;
030: import org.eclipse.swt.graphics.Color;
031: import org.eclipse.swt.graphics.Point;
032: import org.eclipse.swt.graphics.Rectangle;
033: import org.eclipse.swt.widgets.Composite;
034: import org.eclipse.swt.widgets.Control;
035: import org.eclipse.ui.internal.dnd.DragUtil;
036: import org.eclipse.ui.internal.dnd.SwtUtil;
037: import org.eclipse.ui.internal.layout.SizeCache;
038: import org.eclipse.ui.internal.presentations.util.ProxyControl;
039: import org.eclipse.ui.internal.tweaklets.TabBehaviour;
040: import org.eclipse.ui.internal.tweaklets.Tweaklets;
041: import org.eclipse.ui.presentations.IStackPresentationSite;
042:
043: /**
044: * This class implements the tab folders that contains can contain two toolbars
045: * and status text. Wherever possible, the toolbars are aligned with the tabs.
046: * If there is not enough room beside the tabs, the toolbars are aligned with
047: * the status text. This is the same tab folder that is used to arrange views
048: * and editors in Eclipse.
049: * <p>
050: * This is closely related to DefaultPartPresentation, but they have different
051: * responsibilities. This is essentially a CTabFolder that can manage a toolbar.
052: * It should not depend on data structures from the workbench, and its public
053: * interface should only use SWT objects or listeners. DefaultPartPresentation
054: * uses a PaneFolder to arrange views or editors. Knowledge of higher-level data
055: * structures should go there.
056: * </p>
057: * <p>
058: * Although it is not actually a control, the public interface is much like an
059: * SWT control. Implementation-wise, this is actually a combination of a
060: * CTabFolder and a ViewForm. It encapsulates the details of moving the toolbar
061: * between the CTabFolder and the ViewForm, and provides a simpler interface to
062: * the ViewForm/CTabFolder.
063: * </p>
064: * To be consistent with SWT composites, this object can deal with its children
065: * being disposed without warning. This is treated like a removal.
066: *
067: * @since 3.0
068: */
069: public final class PaneFolder {
070: // Tab folder and associated proxy controls
071: private CTabFolder tabFolder;
072:
073: private Control titleAreaProxy;
074:
075: // View form and associated proxy controls
076: private ViewForm viewForm;
077:
078: private ProxyControl contentProxy;
079:
080: private ProxyControl viewFormTopLeftProxy;
081:
082: private ProxyControl viewFormTopRightProxy;
083:
084: private ProxyControl viewFormTopCenterProxy;
085:
086: // Cached sizes of the top-right and top-center controls
087: private SizeCache topRightCache = new SizeCache();
088:
089: private SizeCache topCenterCache = new SizeCache();
090:
091: private SizeCache topLeftCache = new SizeCache();
092:
093: private boolean putTrimOnTop = true;
094:
095: // HACK: Sometimes the topright control isn't resized when
096: // CTabFolder.setBounds is called.
097: // We use the following data structures to detect if this has happened and
098: // force a layout when necessary.
099: private boolean topRightResized = false;
100:
101: private boolean useTopRightOptimization = false;
102:
103: private int lastWidth = 0;
104:
105: // END OF HACK
106:
107: private DisposeListener tabFolderDisposeListener = new DisposeListener() {
108: /*
109: * (non-Javadoc)
110: *
111: * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
112: */
113: public void widgetDisposed(DisposeEvent e) {
114: PaneFolder.this .widgetDisposed();
115: }
116: };
117:
118: /**
119: * Listens for its children being disposed, and removes them if this happens
120: * (although this may indicate a programming error, this behavior is
121: * consistent with SWT composites).
122: */
123: private DisposeListener prematureDisposeListener = new DisposeListener() {
124:
125: public void widgetDisposed(DisposeEvent e) {
126: Control disposedControl = (Control) e.widget;
127:
128: if (isDisposed()) {
129: return;
130: }
131:
132: // Probably unnecessary, but it can't hurt garbage collection
133: disposedControl.removeDisposeListener(this );
134:
135: if (disposedControl == topLeftCache.getControl()) {
136: setTopLeft(null);
137: }
138:
139: if (disposedControl == topRightCache.getControl()) {
140: setTopRight(null);
141: }
142:
143: if (disposedControl == topCenterCache.getControl()) {
144: setTopCenter(null);
145: }
146: }
147:
148: };
149:
150: /**
151: * List of PaneFolderButtonListener
152: */
153: private List buttonListeners = new ArrayList(1);
154:
155: private int state = IStackPresentationSite.STATE_RESTORED;
156:
157: /**
158: * State of the folder at the last mousedown event. This is used to prevent
159: * a mouseup over the minimize or maximize buttons from undoing a state
160: * change that was caused by the mousedown.
161: */
162: private int mousedownState = -1;
163:
164: // CTabFolder listener
165: private CTabFolder2Adapter expandListener = new CTabFolder2Adapter() {
166: public void minimize(CTabFolderEvent event) {
167: event.doit = false;
168: notifyButtonListeners(IStackPresentationSite.STATE_MINIMIZED);
169: }
170:
171: public void restore(CTabFolderEvent event) {
172: event.doit = false;
173: notifyButtonListeners(IStackPresentationSite.STATE_RESTORED);
174: }
175:
176: public void maximize(CTabFolderEvent event) {
177: event.doit = false;
178: notifyButtonListeners(IStackPresentationSite.STATE_MAXIMIZED);
179: }
180:
181: /*
182: * (non-Javadoc)
183: *
184: * @see org.eclipse.swt.custom.CTabFolder2Adapter#close(org.eclipse.swt.custom.CTabFolderEvent)
185: */
186: public void close(CTabFolderEvent event) {
187: event.doit = false;
188: notifyCloseListeners((CTabItem) event.item);
189: }
190:
191: public void showList(CTabFolderEvent event) {
192: notifyShowListeners(event);
193: }
194:
195: };
196:
197: private MouseListener mouseListener = new MouseAdapter() {
198: public void mouseDown(MouseEvent e) {
199: mousedownState = getState();
200: }
201:
202: public void mouseDoubleClick(MouseEvent e) {
203: }
204: };
205:
206: private boolean showButtons = true;
207: private boolean minimizeVisible = false;
208: private boolean maximizeVisible = false;
209:
210: /**
211: * Make sure we don't recursively enter the layout() code.
212: */
213: private boolean inLayout = false;
214:
215: private int tabPosition;
216:
217: /**
218: * Creates a pane folder. This will create exactly one child control in the
219: * given parent.
220: *
221: * @param parent
222: * @param flags
223: */
224: public PaneFolder(Composite parent, int flags) {
225: // Initialize tab folder
226: {
227: tabFolder = new CTabFolder(parent, flags);
228:
229: tabFolder.setMRUVisible(((TabBehaviour) Tweaklets
230: .get(TabBehaviour.KEY)).enableMRUTabVisibility());
231:
232: // Create a proxy control to measure the title area of the tab folder
233: titleAreaProxy = new Composite(tabFolder, SWT.NO_BACKGROUND);
234: titleAreaProxy.setVisible(false);
235: titleAreaProxy.addControlListener(new ControlListener() {
236: public void controlMoved(ControlEvent e) {
237: topRightResized = true;
238: }
239:
240: public void controlResized(ControlEvent e) {
241: topRightResized = true;
242:
243: // bug 101683 - we need to do a layout of the PaneFolder
244: // when the title area proxy is resized.
245: if (!inLayout && !PaneFolder.this .isDisposed()
246: && viewForm != null && contentProxy != null) {
247: PaneFolder.this .aboutToResize();
248: PaneFolder.this .layout(false);
249: }
250: }
251: });
252: tabFolder.setTopRight(titleAreaProxy, SWT.FILL);
253:
254: tabFolder.addCTabFolder2Listener(expandListener);
255:
256: tabFolder.addMouseListener(mouseListener);
257:
258: tabFolder.addDisposeListener(tabFolderDisposeListener);
259: }
260:
261: // Initialize view form
262: {
263: viewForm = new ViewForm(tabFolder, SWT.NO_BACKGROUND);
264:
265: // Only attach these to the viewForm when there's actually a control
266: // to display
267: viewFormTopLeftProxy = new ProxyControl(viewForm);
268: viewFormTopCenterProxy = new ProxyControl(viewForm);
269: viewFormTopRightProxy = new ProxyControl(viewForm);
270:
271: contentProxy = new ProxyControl(viewForm);
272: viewForm.setContent(contentProxy.getControl());
273: }
274: }
275:
276: /**
277: * Returns the title area (the empty region to the right of the tabs), in
278: * the tab folder's coordinate system.
279: *
280: * @return the title area (the empty region to the right of the tabs)
281: */
282: public Rectangle getTitleArea() {
283: return titleAreaProxy.getBounds();
284: }
285:
286: /**
287: * Return the main control for this pane folder
288: *
289: * @return
290: */
291: public Composite getControl() {
292: return tabFolder;
293: }
294:
295: public void flushTopCenterSize() {
296: topCenterCache.flush();
297: viewForm.changed(new Control[] { viewFormTopCenterProxy
298: .getControl() });
299: }
300:
301: /**
302: * Sets the top-center control (usually a toolbar), or null if none. Note
303: * that the control can have any parent.
304: *
305: * @param topCenter
306: * the top-center control or null if none
307: */
308: public void setTopCenter(Control topCenter) {
309: if (topCenter == topCenterCache.getControl()) {
310: return;
311: }
312:
313: removeDisposeListener(topCenterCache.getControl());
314:
315: topCenterCache.setControl(topCenter);
316:
317: if (putTrimOnTop) {
318: viewFormTopCenterProxy.setTarget(null);
319: } else {
320: viewFormTopCenterProxy.setTarget(topCenterCache);
321: }
322:
323: viewForm.changed(new Control[] { viewFormTopCenterProxy
324: .getControl() });
325:
326: if (topCenter != null) {
327: topCenter.addDisposeListener(prematureDisposeListener);
328:
329: if (!putTrimOnTop) {
330: if (!viewForm.isDisposed()) {
331: viewForm.setTopCenter(viewFormTopCenterProxy
332: .getControl());
333: }
334: }
335: } else {
336: if (!putTrimOnTop) {
337: if (!viewForm.isDisposed()) {
338: viewForm.setTopCenter(null);
339: }
340: }
341: }
342: }
343:
344: /**
345: * Sets the top-right control (usually a dropdown), or null if none
346: *
347: * @param topRight
348: */
349: public void setTopRight(Control topRight) {
350: if (topRightCache.getControl() == topRight) {
351: return;
352: }
353:
354: removeDisposeListener(topRightCache.getControl());
355:
356: topRightCache.setControl(topRight);
357:
358: if (putTrimOnTop) {
359: viewFormTopRightProxy.setTarget(null);
360: } else {
361: viewFormTopRightProxy.setTarget(topRightCache);
362: }
363:
364: if (topRight != null) {
365: topRight.addDisposeListener(prematureDisposeListener);
366: if (!putTrimOnTop) {
367:
368: viewForm
369: .setTopRight(viewFormTopRightProxy.getControl());
370: }
371: } else {
372: if (!putTrimOnTop) {
373: viewForm.setTopRight(null);
374: }
375: }
376: }
377:
378: /**
379: * Sets the top-left control (usually a title label), or null if none
380: *
381: * @param topLeft
382: */
383: public void setTopLeft(Control topLeft) {
384: if (topLeftCache.getControl() == topLeft) {
385: return;
386: }
387:
388: removeDisposeListener(topLeftCache.getControl());
389:
390: topLeftCache.setControl(topLeft);
391: // The top-left control always goes directly in the ViewForm
392: if (topLeft != null) {
393: topLeft.addDisposeListener(prematureDisposeListener);
394: viewFormTopLeftProxy.setTarget(topLeftCache);
395: viewForm.setTopLeft(viewFormTopLeftProxy.getControl());
396: } else {
397: viewFormTopLeftProxy.setTarget(null);
398: viewForm.setTopLeft(null);
399: }
400: }
401:
402: /**
403: * Optimization: calling this method immediately before setting the
404: * control's bounds will allow for improved caching.
405: */
406: public void aboutToResize() {
407: useTopRightOptimization = true;
408: topRightResized = false;
409: lastWidth = getControl().getBounds().width;
410: }
411:
412: /**
413: * Cause the folder to hide or show its
414: * Minimize and Maximize affordances.
415: *
416: * @param show
417: * <code>true</code> - the min/max buttons are visible.
418: * @since 3.3
419: */
420: public void showMinMax(boolean show) {
421: showButtons = show;
422: setMaximizeVisible(show);
423: setMinimizeVisible(show);
424: layout(true);
425: }
426:
427: public void layout(boolean flushCache) {
428: if (inLayout) {
429: return;
430: }
431:
432: inLayout = true;
433: try {
434:
435: viewForm.setLayoutDeferred(true);
436:
437: tabFolder
438: .setMinimizeVisible(showButtons && minimizeVisible);
439: tabFolder
440: .setMaximizeVisible(showButtons && maximizeVisible);
441:
442: // Flush the cached sizes if necessary
443: if (flushCache) {
444: topLeftCache.flush();
445: topRightCache.flush();
446: topCenterCache.flush();
447: }
448:
449: // HACK: Force the tab folder to do a layout, since it doesn't always
450: // resize its title area each time setBounds is called.
451: if (!(useTopRightOptimization && (topRightResized || lastWidth == getControl()
452: .getBounds().width))) {
453: // If we can't use the optimization, then we need to force a layout
454: // of the tab folder
455: tabFolder.setTopRight(titleAreaProxy, SWT.FILL);
456: }
457: useTopRightOptimization = false;
458: // END OF HACK
459:
460: Rectangle titleArea = DragUtil
461: .getDisplayBounds(titleAreaProxy);
462:
463: Point topRightSize = topRightCache.computeSize(SWT.DEFAULT,
464: SWT.DEFAULT);
465: Point topCenterSize = topCenterCache.computeSize(
466: SWT.DEFAULT, SWT.DEFAULT);
467:
468: // Determine if there is enough room for the trim in the title area
469: int requiredWidth = topRightSize.x + topCenterSize.x;
470: int requiredHeight = Math.max(topRightSize.y,
471: topCenterSize.y);
472:
473: boolean lastTrimOnTop = putTrimOnTop;
474: putTrimOnTop = (titleArea.width >= requiredWidth && titleArea.height >= requiredHeight);
475:
476: Control topRight = topRightCache.getControl();
477: Control topCenter = topCenterCache.getControl();
478:
479: if (putTrimOnTop) {
480: // Try to avoid calling setTop* whenever possible, since this will
481: // trigger a layout
482: // of the viewForm.
483: if (!lastTrimOnTop) {
484: // Arrange controls in the title bar
485: viewFormTopCenterProxy.setTarget(null);
486: viewFormTopRightProxy.setTarget(null);
487: viewForm.setTopCenter(null);
488: viewForm.setTopRight(null);
489: }
490:
491: Rectangle topRightArea = new Rectangle(titleArea.x
492: + titleArea.width - topRightSize.x, titleArea.y
493: + (titleArea.height - topRightSize.y) / 2,
494: topRightSize.x, topRightSize.y);
495:
496: if (topRight != null) {
497: topRight.setBounds(Geometry.toControl(topRight
498: .getParent(), topRightArea));
499: }
500:
501: if (topCenter != null) {
502: Rectangle topCenterArea = new Rectangle(
503: topRightArea.x - topCenterSize.x,
504: titleArea.y
505: + (titleArea.height - topCenterSize.y)
506: / 2, topCenterSize.x,
507: topCenterSize.y);
508:
509: Rectangle localCoords = Geometry.toControl(
510: topCenter.getParent(), topCenterArea);
511:
512: topCenter.setBounds(localCoords);
513: }
514: } else {
515: if (lastTrimOnTop) {
516: if (topCenter != null) {
517: viewFormTopCenterProxy
518: .setTarget(topCenterCache);
519: viewForm.setTopCenter(viewFormTopCenterProxy
520: .getControl());
521: }
522:
523: if (topRight != null) {
524: viewFormTopRightProxy.setTarget(topRightCache);
525: viewForm.setTopRight(viewFormTopRightProxy
526: .getControl());
527: }
528: }
529: }
530:
531: Rectangle newBounds = tabFolder.getClientArea();
532: viewForm.setBounds(newBounds);
533: } finally {
534: viewForm.setLayoutDeferred(false);
535: inLayout = false;
536: }
537:
538: viewFormTopRightProxy.layout();
539: viewFormTopLeftProxy.layout();
540: viewFormTopCenterProxy.layout();
541: }
542:
543: public Composite getContentParent() {
544: return viewForm;
545: }
546:
547: public void setContent(Control newContent) {
548: viewForm.setContent(newContent);
549: }
550:
551: /**
552: * Returns the current state of the folder (as shown on the button icons)
553: *
554: * @return one of the IStackPresentationSite.STATE_* constants
555: */
556: public int getState() {
557: return state;
558: }
559:
560: /**
561: * @param buttonId
562: * one of the IStackPresentationSite.STATE_* constants
563: */
564: protected void notifyButtonListeners(int buttonId) {
565: if (mousedownState == getState()) {
566: Iterator iter = buttonListeners.iterator();
567:
568: while (iter.hasNext()) {
569: PaneFolderButtonListener listener = (PaneFolderButtonListener) iter
570: .next();
571:
572: listener.stateButtonPressed(buttonId);
573: }
574: }
575: }
576:
577: public Control getContent() {
578: return viewForm.getContent();
579: }
580:
581: /**
582: * Notifies all listeners that the user clicked on the chevron
583: *
584: * @param tabItem
585: */
586: protected void notifyShowListeners(CTabFolderEvent event) {
587: Iterator iter = buttonListeners.iterator();
588:
589: while (iter.hasNext()) {
590: PaneFolderButtonListener listener = (PaneFolderButtonListener) iter
591: .next();
592:
593: listener.showList(event);
594: }
595: }
596:
597: /**
598: * Notifies all listeners that the close button was pressed
599: *
600: * @param tabItem
601: */
602: protected void notifyCloseListeners(CTabItem tabItem) {
603: Iterator iter = buttonListeners.iterator();
604:
605: while (iter.hasNext()) {
606: PaneFolderButtonListener listener = (PaneFolderButtonListener) iter
607: .next();
608:
609: listener.closeButtonPressed(tabItem);
610: }
611: }
612:
613: /**
614: * Sets the state that will be shown on the CTabFolder's buttons
615: *
616: * @param state
617: * one of the IStackPresentationSite.STATE_* constants
618: */
619: public void setState(int state) {
620: this .state = state;
621:
622: tabFolder
623: .setMinimized(state == IStackPresentationSite.STATE_MINIMIZED);
624: tabFolder
625: .setMaximized(state == IStackPresentationSite.STATE_MAXIMIZED);
626: }
627:
628: public void addButtonListener(PaneFolderButtonListener listener) {
629: buttonListeners.add(listener);
630: }
631:
632: public void removeButtonListener(PaneFolderButtonListener listener) {
633: buttonListeners.remove(listener);
634: }
635:
636: public void setTabPosition(int newTabPosition) {
637: tabPosition = newTabPosition;
638: tabFolder.setTabPosition(tabPosition);
639: }
640:
641: public int getTabPosition() {
642: return tabPosition;
643: }
644:
645: public boolean isDisposed() {
646: return tabFolder == null || tabFolder.isDisposed();
647: }
648:
649: public CTabItem createItem(int style, int index) {
650: return new CTabItem(tabFolder, style, index);
651: }
652:
653: public Point computeMinimumSize() {
654: Point result = Geometry.getSize(tabFolder.computeTrim(0, 0, 0,
655: 0));
656:
657: // Add some space for the minimize and maximize buttons plus a tab.
658: // Right now this isn't exposed from SWT as API, so we just add 50
659: // pixels.
660: result.x += 100;
661: return result;
662: }
663:
664: /**
665: * Removes the dispose listener from the given control, unless the given
666: * control is null or disposed.
667: *
668: * @param oldControl
669: * control to detach the dispose listener from
670: */
671: private void removeDisposeListener(Control oldControl) {
672: if (!SwtUtil.isDisposed(oldControl)) {
673: oldControl.removeDisposeListener(prematureDisposeListener);
674: }
675: }
676:
677: private void widgetDisposed() {
678: removeDisposeListener(topCenterCache.getControl());
679: topCenterCache.setControl(null);
680: removeDisposeListener(topRightCache.getControl());
681: topRightCache.setControl(null);
682: removeDisposeListener(topLeftCache.getControl());
683: topLeftCache.setControl(null);
684: }
685:
686: public Point getChevronLocation() {
687: // get the last visible item
688: int numItems = tabFolder.getItemCount();
689: CTabItem item = null, tempItem = null;
690: for (int i = 0; i < numItems; i++) {
691: tempItem = tabFolder.getItem(i);
692: if (tempItem.isShowing()) {
693: item = tempItem;
694: }
695: }
696:
697: // if we have no visible tabs, abort.
698: if (item == null) {
699: return new Point(0, 0);
700: }
701:
702: Rectangle itemBounds = item.getBounds();
703: int x = itemBounds.x + itemBounds.width;
704: int y = itemBounds.y + itemBounds.height;
705: return new Point(x, y);
706: }
707:
708: ///////////////////////////////////////////////////////////////////////////////////////
709: // The remainder of the methods in this class redirect directly to
710: // CTabFolder methods
711:
712: public void setSelection(int selection) {
713: tabFolder.setSelection(selection);
714: }
715:
716: /**
717: * @param i
718: * @param j
719: * @param k
720: * @param l
721: * @return
722: */
723: public Rectangle computeTrim(int i, int j, int k, int l) {
724: return tabFolder.computeTrim(i, j, k, l);
725: }
726:
727: /**
728: * @param b
729: */
730: public void setUnselectedCloseVisible(boolean b) {
731: tabFolder.setUnselectedCloseVisible(b);
732: }
733:
734: /**
735: * @param fgColor
736: */
737: public void setSelectionForeground(Color fgColor) {
738: tabFolder.setSelectionForeground(fgColor);
739: }
740:
741: /**
742: * @param bgColors
743: * @param percentages
744: * @param vertical
745: */
746: public void setSelectionBackground(Color[] bgColors,
747: int[] percentages, boolean vertical) {
748: tabFolder.setSelectionBackground(bgColors, percentages,
749: vertical);
750: }
751:
752: public CTabItem getItem(int idx) {
753: return tabFolder.getItem(idx);
754: }
755:
756: public int getSelectionIndex() {
757: return tabFolder.getSelectionIndex();
758: }
759:
760: public int getTabHeight() {
761: return tabFolder.getTabHeight();
762: }
763:
764: public int indexOf(CTabItem toFind) {
765: return tabFolder.indexOf(toFind);
766: }
767:
768: public void setTabHeight(int height) {
769: tabFolder.setTabHeight(height);
770: }
771:
772: /**
773: * @return
774: */
775: public int getItemCount() {
776: return tabFolder.getItemCount();
777: }
778:
779: /**
780: * @return
781: */
782: public CTabItem[] getItems() {
783: return tabFolder.getItems();
784: }
785:
786: public CTabItem getItem(Point toGet) {
787: return tabFolder.getItem(toGet);
788: }
789:
790: public CTabItem getSelection() {
791: return tabFolder.getSelection();
792: }
793:
794: /**
795: * @param isVisible
796: */
797: public void setMinimizeVisible(boolean isVisible) {
798: tabFolder.setMinimizeVisible(isVisible);
799: minimizeVisible = isVisible;
800: }
801:
802: /**
803: * Changes the minimum number of characters to display in a pane folder tab.
804: * This control how much information will be displayed to the user.
805: *
806: * @param count
807: * The number of characters to display in the tab folder; this
808: * value should be a positive integer.
809: * @see org.eclipse.swt.custom.CTabFolder#setMinimumCharacters(int)
810: * @since 3.1
811: */
812: public void setMinimumCharacters(int count) {
813: tabFolder.setMinimumCharacters(count);
814: }
815:
816: /**
817: * @param isVisible
818: */
819: public void setMaximizeVisible(boolean isVisible) {
820: tabFolder.setMaximizeVisible(isVisible);
821: maximizeVisible = isVisible;
822: }
823:
824: /**
825: * @param traditionalTab
826: */
827: public void setSimpleTab(boolean traditionalTab) {
828: tabFolder.setSimple(traditionalTab);
829: }
830:
831: /**
832: * @param b
833: */
834: public void setUnselectedImageVisible(boolean b) {
835: tabFolder.setUnselectedImageVisible(b);
836: }
837:
838: /**
839: * @param b
840: */
841: public void setSingleTab(boolean b) {
842: tabFolder.setSingle(b);
843: }
844:
845: public void hideTitle() {
846: tabFolder.setTabHeight(0);
847: }
848:
849: public ViewForm getViewForm() {
850: return viewForm;
851: }
852:
853: /**
854: * Propogate the visibility change requests to the proxy controls. When
855: * their target is null, they no longer get visibility updates. Currently
856: * this only propagates the changes to the ProxyControls held by this
857: * folder.
858: *
859: * @param visible
860: * <code>true</code> - it's visible.
861: * @since 3.2
862: */
863: public void setVisible(boolean visible) {
864: contentProxy.setVisible(visible);
865: viewFormTopCenterProxy.setVisible(visible);
866: viewFormTopLeftProxy.setVisible(visible);
867: viewFormTopRightProxy.setVisible(visible);
868: }
869: }
|