|
Lines 11-22
Link Here
|
| 11 |
package org.eclipse.ui.internal.presentations; |
11 |
package org.eclipse.ui.internal.presentations; |
| 12 |
|
12 |
|
| 13 |
import java.util.ArrayList; |
13 |
import java.util.ArrayList; |
|
|
14 |
import java.util.Iterator; |
| 15 |
import java.util.List; |
| 14 |
|
16 |
|
| 15 |
import org.eclipse.jface.action.GroupMarker; |
17 |
import org.eclipse.jface.action.GroupMarker; |
| 16 |
import org.eclipse.jface.action.IMenuManager; |
18 |
import org.eclipse.jface.action.IMenuManager; |
| 17 |
import org.eclipse.jface.action.MenuManager; |
19 |
import org.eclipse.jface.action.MenuManager; |
| 18 |
import org.eclipse.jface.action.Separator; |
20 |
import org.eclipse.jface.action.Separator; |
| 19 |
import org.eclipse.jface.preference.IPreferenceStore; |
21 |
import org.eclipse.jface.preference.IPreferenceStore; |
|
|
22 |
import org.eclipse.jface.util.Assert; |
| 20 |
import org.eclipse.jface.util.Geometry; |
23 |
import org.eclipse.jface.util.Geometry; |
| 21 |
import org.eclipse.jface.util.IPropertyChangeListener; |
24 |
import org.eclipse.jface.util.IPropertyChangeListener; |
| 22 |
import org.eclipse.jface.util.PropertyChangeEvent; |
25 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
Lines 38-45
Link Here
|
| 38 |
import org.eclipse.swt.widgets.Event; |
41 |
import org.eclipse.swt.widgets.Event; |
| 39 |
import org.eclipse.swt.widgets.Listener; |
42 |
import org.eclipse.swt.widgets.Listener; |
| 40 |
import org.eclipse.swt.widgets.Menu; |
43 |
import org.eclipse.swt.widgets.Menu; |
|
|
44 |
import org.eclipse.ui.IMemento; |
| 41 |
import org.eclipse.ui.IPropertyListener; |
45 |
import org.eclipse.ui.IPropertyListener; |
| 42 |
import org.eclipse.ui.internal.IPreferenceConstants; |
46 |
import org.eclipse.ui.internal.IPreferenceConstants; |
|
|
47 |
import org.eclipse.ui.internal.IWorkbenchConstants; |
| 43 |
import org.eclipse.ui.internal.WorkbenchPlugin; |
48 |
import org.eclipse.ui.internal.WorkbenchPlugin; |
| 44 |
import org.eclipse.ui.internal.WorkbenchWindow; |
49 |
import org.eclipse.ui.internal.WorkbenchWindow; |
| 45 |
import org.eclipse.ui.internal.dnd.DragUtil; |
50 |
import org.eclipse.ui.internal.dnd.DragUtil; |
|
Lines 51-56
Link Here
|
| 51 |
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem; |
56 |
import org.eclipse.ui.internal.presentations.r21.widgets.CTabItem; |
| 52 |
import org.eclipse.ui.presentations.IPartMenu; |
57 |
import org.eclipse.ui.presentations.IPartMenu; |
| 53 |
import org.eclipse.ui.presentations.IPresentablePart; |
58 |
import org.eclipse.ui.presentations.IPresentablePart; |
|
|
59 |
import org.eclipse.ui.presentations.IPresentationSerializer; |
| 54 |
import org.eclipse.ui.presentations.IStackPresentationSite; |
60 |
import org.eclipse.ui.presentations.IStackPresentationSite; |
| 55 |
import org.eclipse.ui.presentations.PresentationUtil; |
61 |
import org.eclipse.ui.presentations.PresentationUtil; |
| 56 |
import org.eclipse.ui.presentations.StackDropResult; |
62 |
import org.eclipse.ui.presentations.StackDropResult; |
|
Lines 649-662
Link Here
|
| 649 |
// Select a location for newly inserted parts |
655 |
// Select a location for newly inserted parts |
| 650 |
idx = tabFolder.getItemCount(); |
656 |
idx = tabFolder.getItemCount(); |
| 651 |
} |
657 |
} |
| 652 |
|
|
|
| 653 |
if (getTab(newPart) != null) { |
| 654 |
return; |
| 655 |
} |
| 656 |
|
658 |
|
| 657 |
createPartTab(newPart, idx); |
659 |
addPart(newPart, idx); |
| 658 |
} |
660 |
} |
| 659 |
|
661 |
|
|
|
662 |
/** |
| 663 |
* Adds the given presentable part to this presentation at the given index. |
| 664 |
* Does nothing if a tab already exists for the given part. |
| 665 |
* |
| 666 |
* @param newPart |
| 667 |
* @param index |
| 668 |
*/ |
| 669 |
public void addPart(IPresentablePart newPart, int index) { |
| 670 |
// If we already have a tab for this part, do nothing |
| 671 |
if (getTab(newPart) != null) { |
| 672 |
return; |
| 673 |
} |
| 674 |
createPartTab(newPart, index); |
| 675 |
|
| 676 |
//setControlSize(); |
| 677 |
} |
| 678 |
|
| 660 |
/* |
679 |
/* |
| 661 |
* (non-Javadoc) |
680 |
* (non-Javadoc) |
| 662 |
* |
681 |
* |
|
Lines 869-872
Link Here
|
| 869 |
activeState = newState; |
888 |
activeState = newState; |
| 870 |
updateGradient(); |
889 |
updateGradient(); |
| 871 |
} |
890 |
} |
|
|
891 |
|
| 892 |
/** |
| 893 |
* Restores a presentation from a previously stored state |
| 894 |
* |
| 895 |
* @param serializer (not null) |
| 896 |
* @param savedState (not null) |
| 897 |
*/ |
| 898 |
public void restoreState(IPresentationSerializer serializer, IMemento savedState) { |
| 899 |
IMemento[] parts = savedState.getChildren(IWorkbenchConstants.TAG_PART); |
| 900 |
|
| 901 |
for (int idx = 0; idx < parts.length; idx++) { |
| 902 |
String id = parts[idx].getString(IWorkbenchConstants.TAG_ID); |
| 903 |
|
| 904 |
if (id != null) { |
| 905 |
IPresentablePart part = serializer.getPart(id); |
| 906 |
|
| 907 |
if (part != null) { |
| 908 |
addPart(part, tabFolder.getItemCount()); |
| 909 |
} |
| 910 |
} |
| 911 |
} |
| 912 |
} |
| 913 |
|
| 914 |
|
| 915 |
/* (non-Javadoc) |
| 916 |
* @see org.eclipse.ui.presentations.StackPresentation#saveState(org.eclipse.ui.presentations.IPresentationSerializer, org.eclipse.ui.IMemento) |
| 917 |
*/ |
| 918 |
public void saveState(IPresentationSerializer context, IMemento memento) { |
| 919 |
super.saveState(context, memento); |
| 920 |
|
| 921 |
List parts = getPresentableParts(); |
| 922 |
|
| 923 |
Iterator iter = parts.iterator(); |
| 924 |
while (iter.hasNext()) { |
| 925 |
IPresentablePart next = (IPresentablePart)iter.next(); |
| 926 |
|
| 927 |
IMemento childMem = memento.createChild(IWorkbenchConstants.TAG_PART); |
| 928 |
childMem.putString(IWorkbenchConstants.TAG_ID, context.getId(next)); |
| 929 |
} |
| 930 |
} |
| 931 |
|
| 932 |
/** |
| 933 |
* Returns the List of IPresentablePart currently in this presentation |
| 934 |
*/ |
| 935 |
List getPresentableParts() { |
| 936 |
Assert.isTrue(!isDisposed()); |
| 937 |
|
| 938 |
CTabItem[] items = tabFolder.getItems(); |
| 939 |
List result = new ArrayList(items.length); |
| 940 |
|
| 941 |
for (int idx = 0; idx < tabFolder.getItemCount(); idx++) { |
| 942 |
result.add(getPartForTab(items[idx])); |
| 943 |
} |
| 944 |
|
| 945 |
return result; |
| 946 |
} |
| 947 |
|
| 872 |
} |
948 |
} |