|
Lines 4-10
Link Here
|
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
7 |
* |
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
|
Lines 34-47
Link Here
|
| 34 |
import org.eclipse.swt.events.ControlEvent; |
34 |
import org.eclipse.swt.events.ControlEvent; |
| 35 |
import org.eclipse.swt.graphics.Image; |
35 |
import org.eclipse.swt.graphics.Image; |
| 36 |
import org.eclipse.swt.graphics.Point; |
36 |
import org.eclipse.swt.graphics.Point; |
| 37 |
import org.eclipse.swt.graphics.Rectangle; |
|
|
| 38 |
import org.eclipse.swt.layout.FillLayout; |
37 |
import org.eclipse.swt.layout.FillLayout; |
| 39 |
import org.eclipse.swt.layout.FormAttachment; |
38 |
import org.eclipse.swt.layout.FormAttachment; |
| 40 |
import org.eclipse.swt.layout.FormData; |
39 |
import org.eclipse.swt.layout.FormData; |
| 41 |
import org.eclipse.swt.layout.FormLayout; |
40 |
import org.eclipse.swt.layout.FormLayout; |
| 42 |
import org.eclipse.swt.widgets.Composite; |
41 |
import org.eclipse.swt.widgets.Composite; |
| 43 |
import org.eclipse.swt.widgets.Control; |
42 |
import org.eclipse.swt.widgets.Control; |
| 44 |
import org.eclipse.swt.widgets.ScrollBar; |
|
|
| 45 |
import org.eclipse.ui.IActionBars; |
43 |
import org.eclipse.ui.IActionBars; |
| 46 |
import org.eclipse.ui.IEditorPart; |
44 |
import org.eclipse.ui.IEditorPart; |
| 47 |
import org.eclipse.ui.IPartListener; |
45 |
import org.eclipse.ui.IPartListener; |
|
Lines 61-67
Link Here
|
| 61 |
|
59 |
|
| 62 |
/** |
60 |
/** |
| 63 |
* A property sheet page that provides a tabbed UI. |
61 |
* A property sheet page that provides a tabbed UI. |
| 64 |
* |
62 |
* |
| 65 |
* @author Anthony Hunter |
63 |
* @author Anthony Hunter |
| 66 |
*/ |
64 |
*/ |
| 67 |
public class TabbedPropertySheetPage |
65 |
public class TabbedPropertySheetPage |
|
Lines 138-144
Link Here
|
| 138 |
|
136 |
|
| 139 |
/** |
137 |
/** |
| 140 |
* Constructor that takes in a contributor id taken from a selection. |
138 |
* Constructor that takes in a contributor id taken from a selection. |
| 141 |
* |
139 |
* |
| 142 |
* @param contributorId |
140 |
* @param contributorId |
| 143 |
* the contributor id. |
141 |
* the contributor id. |
| 144 |
*/ |
142 |
*/ |
|
Lines 265-271
Link Here
|
| 265 |
|
263 |
|
| 266 |
/** |
264 |
/** |
| 267 |
* create a new tabbed property sheet page. |
265 |
* create a new tabbed property sheet page. |
| 268 |
* |
266 |
* |
| 269 |
* @param tabbedPropertySheetPageContributor |
267 |
* @param tabbedPropertySheetPageContributor |
| 270 |
* the tabbed property sheet page contributor. |
268 |
* the tabbed property sheet page contributor. |
| 271 |
*/ |
269 |
*/ |
|
Lines 273-287
Link Here
|
| 273 |
ITabbedPropertySheetPageContributor tabbedPropertySheetPageContributor) { |
271 |
ITabbedPropertySheetPageContributor tabbedPropertySheetPageContributor) { |
| 274 |
this(tabbedPropertySheetPageContributor, true); |
272 |
this(tabbedPropertySheetPageContributor, true); |
| 275 |
} |
273 |
} |
| 276 |
|
274 |
|
| 277 |
/** |
275 |
/** |
| 278 |
* create a new tabbed property sheet page. |
276 |
* create a new tabbed property sheet page. |
| 279 |
* |
277 |
* |
| 280 |
* @param tabbedPropertySheetPageContributor |
278 |
* @param tabbedPropertySheetPageContributor |
| 281 |
* the tabbed property sheet page contributor. |
279 |
* the tabbed property sheet page contributor. |
| 282 |
* @param showTitleBar |
280 |
* @param showTitleBar |
| 283 |
* boolean indicating if the title bar should be shown; |
281 |
* boolean indicating if the title bar should be shown; |
| 284 |
* default value is <code>true</code> |
282 |
* default value is <code>true</code> |
| 285 |
* @since 3.5 |
283 |
* @since 3.5 |
| 286 |
*/ |
284 |
*/ |
| 287 |
public TabbedPropertySheetPage( |
285 |
public TabbedPropertySheetPage( |
|
Lines 297-303
Link Here
|
| 297 |
|
295 |
|
| 298 |
/** |
296 |
/** |
| 299 |
* Handle the part activated event. |
297 |
* Handle the part activated event. |
| 300 |
* |
298 |
* |
| 301 |
* @param part |
299 |
* @param part |
| 302 |
* the new activated part. |
300 |
* the new activated part. |
| 303 |
*/ |
301 |
*/ |
|
Lines 350-356
Link Here
|
| 350 |
widgetFactory = new TabbedPropertySheetWidgetFactory(); |
348 |
widgetFactory = new TabbedPropertySheetWidgetFactory(); |
| 351 |
tabbedPropertyComposite = new TabbedPropertyComposite(parent, |
349 |
tabbedPropertyComposite = new TabbedPropertyComposite(parent, |
| 352 |
widgetFactory, hasTitleBar); |
350 |
widgetFactory, hasTitleBar); |
| 353 |
widgetFactory.paintBordersFor(tabbedPropertyComposite); |
351 |
// widgetFactory.paintBordersFor(tabbedPropertyComposite); |
| 354 |
tabbedPropertyComposite.setLayout(new FormLayout()); |
352 |
tabbedPropertyComposite.setLayout(new FormLayout()); |
| 355 |
FormData formData = new FormData(); |
353 |
FormData formData = new FormData(); |
| 356 |
formData.left = new FormAttachment(0, 0); |
354 |
formData.left = new FormAttachment(0, 0); |
|
Lines 392-398
Link Here
|
| 392 |
|
390 |
|
| 393 |
/** |
391 |
/** |
| 394 |
* Initialize the contributor with the provided contributor id. |
392 |
* Initialize the contributor with the provided contributor id. |
| 395 |
* |
393 |
* |
| 396 |
* @param contributorId |
394 |
* @param contributorId |
| 397 |
* the contributor id. |
395 |
* the contributor id. |
| 398 |
*/ |
396 |
*/ |
|
Lines 432-438
Link Here
|
| 432 |
|
430 |
|
| 433 |
/** |
431 |
/** |
| 434 |
* Gets the tab list content provider for the contributor. |
432 |
* Gets the tab list content provider for the contributor. |
| 435 |
* |
433 |
* |
| 436 |
* @return the tab list content provider for the contributor. |
434 |
* @return the tab list content provider for the contributor. |
| 437 |
*/ |
435 |
*/ |
| 438 |
protected IStructuredContentProvider getTabListContentProvider() { |
436 |
protected IStructuredContentProvider getTabListContentProvider() { |
|
Lines 499-505
Link Here
|
| 499 |
contributor); |
497 |
contributor); |
| 500 |
registry = null; |
498 |
registry = null; |
| 501 |
} |
499 |
} |
| 502 |
|
500 |
|
| 503 |
contributor = null; |
501 |
contributor = null; |
| 504 |
currentSelection = null; |
502 |
currentSelection = null; |
| 505 |
} |
503 |
} |
|
Lines 524-531
Link Here
|
| 524 |
} else if (contributor instanceof IViewPart) { |
522 |
} else if (contributor instanceof IViewPart) { |
| 525 |
IViewPart viewPart = (IViewPart) contributor; |
523 |
IViewPart viewPart = (IViewPart) contributor; |
| 526 |
partActionBars = viewPart.getViewSite().getActionBars(); |
524 |
partActionBars = viewPart.getViewSite().getActionBars(); |
| 527 |
} |
525 |
} |
| 528 |
|
526 |
|
| 529 |
if (partActionBars != null) { |
527 |
if (partActionBars != null) { |
| 530 |
IAction action = partActionBars.getGlobalActionHandler(ActionFactory.UNDO |
528 |
IAction action = partActionBars.getGlobalActionHandler(ActionFactory.UNDO |
| 531 |
.getId()); |
529 |
.getId()); |
|
Lines 533-539
Link Here
|
| 533 |
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), action); |
531 |
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), action); |
| 534 |
} |
532 |
} |
| 535 |
action = partActionBars.getGlobalActionHandler(ActionFactory.REDO |
533 |
action = partActionBars.getGlobalActionHandler(ActionFactory.REDO |
| 536 |
.getId()); |
534 |
.getId()); |
| 537 |
if (action != null) { |
535 |
if (action != null) { |
| 538 |
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), action); |
536 |
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), action); |
| 539 |
} |
537 |
} |
|
Lines 570-578
Link Here
|
| 570 |
} |
568 |
} |
| 571 |
|
569 |
|
| 572 |
/** |
570 |
/** |
| 573 |
* Resize the scrolled composite enclosing the sections, which may result in the |
571 |
* Resize the scrolled composite enclosing the sections, which may result in the |
| 574 |
* addition or removal of scroll bars. |
572 |
* addition or removal of scroll bars. |
| 575 |
* |
573 |
* |
| 576 |
* @since 3.5 |
574 |
* @since 3.5 |
| 577 |
*/ |
575 |
*/ |
| 578 |
public void resizeScrolledComposite() { |
576 |
public void resizeScrolledComposite() { |
|
Lines 581-609
Link Here
|
| 581 |
Composite sizeReference = (Composite) tabToComposite |
579 |
Composite sizeReference = (Composite) tabToComposite |
| 582 |
.get(currentTab); |
580 |
.get(currentTab); |
| 583 |
if (sizeReference != null) { |
581 |
if (sizeReference != null) { |
| 584 |
currentTabSize = sizeReference.computeSize(SWT.DEFAULT, SWT.DEFAULT); |
582 |
currentTabSize = sizeReference.computeSize(SWT.DEFAULT, SWT.DEFAULT); |
| 585 |
} |
583 |
} |
| 586 |
} |
584 |
} |
| 587 |
tabbedPropertyComposite.getScrolledComposite().setMinSize( |
585 |
tabbedPropertyComposite.getScrolledComposite().setMinSize( |
| 588 |
currentTabSize); |
586 |
currentTabSize); |
| 589 |
|
587 |
|
| 590 |
ScrollBar verticalScrollBar = tabbedPropertyComposite |
588 |
// ScrollBar verticalScrollBar = tabbedPropertyComposite |
| 591 |
.getScrolledComposite().getVerticalBar(); |
589 |
// .getScrolledComposite().getVerticalBar(); |
| 592 |
if (verticalScrollBar != null) { |
590 |
// if (verticalScrollBar != null) { |
| 593 |
Rectangle clientArea = tabbedPropertyComposite |
591 |
// Rectangle clientArea = tabbedPropertyComposite |
| 594 |
.getScrolledComposite().getClientArea(); |
592 |
// .getScrolledComposite().getClientArea(); |
| 595 |
int increment = clientArea.height - 5; |
593 |
// int increment = clientArea.height - 5; |
| 596 |
verticalScrollBar.setPageIncrement(increment); |
594 |
// verticalScrollBar.setPageIncrement(increment); |
| 597 |
} |
595 |
// } |
| 598 |
|
596 |
|
| 599 |
ScrollBar horizontalScrollBar = tabbedPropertyComposite |
597 |
// ScrollBar horizontalScrollBar = tabbedPropertyComposite |
| 600 |
.getScrolledComposite().getHorizontalBar(); |
598 |
// .getScrolledComposite().getHorizontalBar(); |
| 601 |
if (horizontalScrollBar != null) { |
599 |
// if (horizontalScrollBar != null) { |
| 602 |
Rectangle clientArea = tabbedPropertyComposite |
600 |
// Rectangle clientArea = tabbedPropertyComposite |
| 603 |
.getScrolledComposite().getClientArea(); |
601 |
// .getScrolledComposite().getClientArea(); |
| 604 |
int increment = clientArea.width - 5; |
602 |
// int increment = clientArea.width - 5; |
| 605 |
horizontalScrollBar.setPageIncrement(increment); |
603 |
// horizontalScrollBar.setPageIncrement(increment); |
| 606 |
} |
604 |
// } |
| 607 |
} |
605 |
} |
| 608 |
|
606 |
|
| 609 |
private void disposeTabs(Collection tabs) { |
607 |
private void disposeTabs(Collection tabs) { |
|
Lines 673-679
Link Here
|
| 673 |
|
671 |
|
| 674 |
/** |
672 |
/** |
| 675 |
* Create the tab contents for the provided tab descriptor. |
673 |
* Create the tab contents for the provided tab descriptor. |
| 676 |
* |
674 |
* |
| 677 |
* @param tabDescriptor |
675 |
* @param tabDescriptor |
| 678 |
* the tab descriptor. |
676 |
* the tab descriptor. |
| 679 |
* @return the tab contents. |
677 |
* @return the tab contents. |
|
Lines 685-691
Link Here
|
| 685 |
|
683 |
|
| 686 |
/** |
684 |
/** |
| 687 |
* Helper method for creating property tab composites. |
685 |
* Helper method for creating property tab composites. |
| 688 |
* |
686 |
* |
| 689 |
* @return the property tab composite. |
687 |
* @return the property tab composite. |
| 690 |
*/ |
688 |
*/ |
| 691 |
private Composite createTabComposite() { |
689 |
private Composite createTabComposite() { |
|
Lines 751-757
Link Here
|
| 751 |
|
749 |
|
| 752 |
/** |
750 |
/** |
| 753 |
* Get the currently active tab. |
751 |
* Get the currently active tab. |
| 754 |
* |
752 |
* |
| 755 |
* @return the currently active tab. |
753 |
* @return the currently active tab. |
| 756 |
* @since 3.4 |
754 |
* @since 3.4 |
| 757 |
*/ |
755 |
*/ |
|
Lines 761-767
Link Here
|
| 761 |
|
759 |
|
| 762 |
/** |
760 |
/** |
| 763 |
* Handle the tab selected change event. |
761 |
* Handle the tab selected change event. |
| 764 |
* |
762 |
* |
| 765 |
* @param tabDescriptor |
763 |
* @param tabDescriptor |
| 766 |
* the new selected tab. |
764 |
* the new selected tab. |
| 767 |
*/ |
765 |
*/ |
|
Lines 780-786
Link Here
|
| 780 |
|
778 |
|
| 781 |
/** |
779 |
/** |
| 782 |
* Add a tab selection listener. |
780 |
* Add a tab selection listener. |
| 783 |
* |
781 |
* |
| 784 |
* @param listener |
782 |
* @param listener |
| 785 |
* a tab selection listener. |
783 |
* a tab selection listener. |
| 786 |
*/ |
784 |
*/ |
|
Lines 790-796
Link Here
|
| 790 |
|
788 |
|
| 791 |
/** |
789 |
/** |
| 792 |
* Remove a tab selection listener. |
790 |
* Remove a tab selection listener. |
| 793 |
* |
791 |
* |
| 794 |
* @param listener |
792 |
* @param listener |
| 795 |
* a tab selection listener. |
793 |
* a tab selection listener. |
| 796 |
*/ |
794 |
*/ |
|
Lines 813-819
Link Here
|
| 813 |
|
811 |
|
| 814 |
/** |
812 |
/** |
| 815 |
* Get the widget factory. |
813 |
* Get the widget factory. |
| 816 |
* |
814 |
* |
| 817 |
* @return the widget factory. |
815 |
* @return the widget factory. |
| 818 |
*/ |
816 |
*/ |
| 819 |
public TabbedPropertySheetWidgetFactory getWidgetFactory() { |
817 |
public TabbedPropertySheetWidgetFactory getWidgetFactory() { |
|
Lines 851-857
Link Here
|
| 851 |
|
849 |
|
| 852 |
/** |
850 |
/** |
| 853 |
* Retrieve the contributor from the selection. |
851 |
* Retrieve the contributor from the selection. |
| 854 |
* |
852 |
* |
| 855 |
* @param object - |
853 |
* @param object - |
| 856 |
* the selected element |
854 |
* the selected element |
| 857 |
* @return the TabbedPropertySheetPageContributor or null if not applicable |
855 |
* @return the TabbedPropertySheetPageContributor or null if not applicable |
|
Lines 888-894
Link Here
|
| 888 |
* It is possible for elements in a selection to implement |
886 |
* It is possible for elements in a selection to implement |
| 889 |
* ITabbedPropertySheetPageContributor to provide a different contributor id |
887 |
* ITabbedPropertySheetPageContributor to provide a different contributor id |
| 890 |
* and thus a differenent registry. |
888 |
* and thus a differenent registry. |
| 891 |
* |
889 |
* |
| 892 |
* @param selection |
890 |
* @param selection |
| 893 |
* the current selection in the active workbench part. |
891 |
* the current selection in the active workbench part. |
| 894 |
*/ |
892 |
*/ |
|
Lines 907-920
Link Here
|
| 907 |
} |
905 |
} |
| 908 |
|
906 |
|
| 909 |
ITabbedPropertySheetPageContributor newContributor = getTabbedPropertySheetPageContributor(structuredSelection.getFirstElement()); |
907 |
ITabbedPropertySheetPageContributor newContributor = getTabbedPropertySheetPageContributor(structuredSelection.getFirstElement()); |
| 910 |
|
908 |
|
| 911 |
if (newContributor == null) { |
909 |
if (newContributor == null) { |
| 912 |
/** |
910 |
/** |
| 913 |
* selection does not implement or adapt ITabbedPropertySheetPageContributor. |
911 |
* selection does not implement or adapt ITabbedPropertySheetPageContributor. |
| 914 |
*/ |
912 |
*/ |
| 915 |
newContributor = contributor; |
913 |
newContributor = contributor; |
| 916 |
} |
914 |
} |
| 917 |
|
915 |
|
| 918 |
String selectionContributorId = newContributor.getContributorId(); |
916 |
String selectionContributorId = newContributor.getContributorId(); |
| 919 |
if (selectionContributorId.equals(currentContributorId)) { |
917 |
if (selectionContributorId.equals(currentContributorId)) { |
| 920 |
/** |
918 |
/** |
|
Lines 970-976
Link Here
|
| 970 |
|
968 |
|
| 971 |
/** |
969 |
/** |
| 972 |
* Returns the currently selected tab. |
970 |
* Returns the currently selected tab. |
| 973 |
* |
971 |
* |
| 974 |
* @return the currently selected tab or <code>null</code> if there is no |
972 |
* @return the currently selected tab or <code>null</code> if there is no |
| 975 |
* tab selected. |
973 |
* tab selected. |
| 976 |
* @since 3.5 |
974 |
* @since 3.5 |
|
Lines 988-994
Link Here
|
| 988 |
|
986 |
|
| 989 |
/** |
987 |
/** |
| 990 |
* Returns the list of currently active tabs. |
988 |
* Returns the list of currently active tabs. |
| 991 |
* |
989 |
* |
| 992 |
* @return the currently active tabs. |
990 |
* @return the currently active tabs. |
| 993 |
* @since 3.5 |
991 |
* @since 3.5 |
| 994 |
*/ |
992 |
*/ |
|
Lines 1001-1010
Link Here
|
| 1001 |
} |
999 |
} |
| 1002 |
return new ITabDescriptor[] {}; |
1000 |
return new ITabDescriptor[] {}; |
| 1003 |
} |
1001 |
} |
| 1004 |
|
1002 |
|
| 1005 |
/** |
1003 |
/** |
| 1006 |
* Set the currently selected tab to be that of the provided tab id. |
1004 |
* Set the currently selected tab to be that of the provided tab id. |
| 1007 |
* |
1005 |
* |
| 1008 |
* @param id |
1006 |
* @param id |
| 1009 |
* The string id of the tab to select. |
1007 |
* The string id of the tab to select. |
| 1010 |
* @since 3.5 |
1008 |
* @since 3.5 |
|
Lines 1022-1047
Link Here
|
| 1022 |
} |
1020 |
} |
| 1023 |
} |
1021 |
} |
| 1024 |
} |
1022 |
} |
| 1025 |
|
1023 |
|
| 1026 |
/** |
1024 |
/** |
| 1027 |
* Returns text of the properties title for given selection. If selection is null, |
1025 |
* Returns text of the properties title for given selection. If selection is null, |
| 1028 |
* then currentSelection is used |
1026 |
* then currentSelection is used |
| 1029 |
* |
1027 |
* |
| 1030 |
* @param selection Selection whose properties title text is to be returned |
1028 |
* @param selection Selection whose properties title text is to be returned |
| 1031 |
* @return String representing title text. |
1029 |
* @return String representing title text. |
| 1032 |
* @since 3.5 |
1030 |
* @since 3.5 |
| 1033 |
*/ |
1031 |
*/ |
| 1034 |
public String getTitleText(ISelection selection) { |
1032 |
public String getTitleText(ISelection selection) { |
| 1035 |
if (selection == null) { |
1033 |
if (selection == null) { |
| 1036 |
selection = currentSelection; |
1034 |
selection = currentSelection; |
| 1037 |
} |
1035 |
} |
| 1038 |
return registry.getLabelProvider().getText(selection); |
1036 |
return registry.getLabelProvider().getText(selection); |
| 1039 |
} |
1037 |
} |
| 1040 |
|
1038 |
|
| 1041 |
/** |
1039 |
/** |
| 1042 |
* Returns the title image for given selection. If selection is null, |
1040 |
* Returns the title image for given selection. If selection is null, |
| 1043 |
* then currentSelection is used. |
1041 |
* then currentSelection is used. |
| 1044 |
* |
1042 |
* |
| 1045 |
* @param selection Selection whose properties title image is to be returned |
1043 |
* @param selection Selection whose properties title image is to be returned |
| 1046 |
* @return Image that is used as a title image. |
1044 |
* @return Image that is used as a title image. |
| 1047 |
* @since 3.5 |
1045 |
* @since 3.5 |