Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 62218 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/presentations/R21BasicStackPresentation.java (+62 lines)
Lines 11-21 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;
21
import org.eclipse.jface.util.Assert;
19
import org.eclipse.jface.util.Geometry;
22
import org.eclipse.jface.util.Geometry;
20
import org.eclipse.jface.window.Window;
23
import org.eclipse.jface.window.Window;
21
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
Lines 40-46 Link Here
40
import org.eclipse.swt.widgets.Shell;
43
import org.eclipse.swt.widgets.Shell;
41
import org.eclipse.swt.widgets.ToolBar;
44
import org.eclipse.swt.widgets.ToolBar;
42
import org.eclipse.swt.widgets.ToolItem;
45
import org.eclipse.swt.widgets.ToolItem;
46
import org.eclipse.ui.IMemento;
43
import org.eclipse.ui.IPropertyListener;
47
import org.eclipse.ui.IPropertyListener;
48
import org.eclipse.ui.internal.IWorkbenchConstants;
44
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
49
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
45
import org.eclipse.ui.internal.WorkbenchImages;
50
import org.eclipse.ui.internal.WorkbenchImages;
46
import org.eclipse.ui.internal.WorkbenchWindow;
51
import org.eclipse.ui.internal.WorkbenchWindow;
Lines 52-57 Link Here
52
import org.eclipse.ui.internal.util.Util;
57
import org.eclipse.ui.internal.util.Util;
53
import org.eclipse.ui.presentations.IPartMenu;
58
import org.eclipse.ui.presentations.IPartMenu;
54
import org.eclipse.ui.presentations.IPresentablePart;
59
import org.eclipse.ui.presentations.IPresentablePart;
60
import org.eclipse.ui.presentations.IPresentationSerializer;
55
import org.eclipse.ui.presentations.IStackPresentationSite;
61
import org.eclipse.ui.presentations.IStackPresentationSite;
56
import org.eclipse.ui.presentations.PresentationUtil;
62
import org.eclipse.ui.presentations.PresentationUtil;
57
import org.eclipse.ui.presentations.StackDropResult;
63
import org.eclipse.ui.presentations.StackDropResult;
Lines 986-989 Link Here
986
		setActive(newState == AS_ACTIVE_FOCUS);
992
		setActive(newState == AS_ACTIVE_FOCUS);
987
	}
993
	}
988
994
995
    /**
996
     * Restores a presentation from a previously stored state
997
     * 
998
     * @param serializer (not null)
999
     * @param savedState (not null)
1000
     */
1001
    public void restoreState(IPresentationSerializer serializer, IMemento savedState) {
1002
        IMemento[] parts = savedState.getChildren(IWorkbenchConstants.TAG_PART);
1003
        
1004
        for (int idx = 0; idx < parts.length; idx++) {
1005
            String id = parts[idx].getString(IWorkbenchConstants.TAG_ID);
1006
            
1007
            if (id != null) {
1008
                IPresentablePart part = serializer.getPart(id);
1009
                
1010
                if (part != null) {
1011
                    addPart(part, getPaneFolder().getItemCount());
1012
                }
1013
            } 
1014
        }
1015
    }
1016
    
1017
    
1018
    /* (non-Javadoc)
1019
     * @see org.eclipse.ui.presentations.StackPresentation#saveState(org.eclipse.ui.presentations.IPresentationSerializer, org.eclipse.ui.IMemento)
1020
     */
1021
    public void saveState(IPresentationSerializer context, IMemento memento) {
1022
        super.saveState(context, memento);
1023
        
1024
        List parts = getPresentableParts();
1025
        
1026
        Iterator iter = parts.iterator();
1027
        while (iter.hasNext()) {
1028
            IPresentablePart next = (IPresentablePart)iter.next();
1029
            
1030
            IMemento childMem = memento.createChild(IWorkbenchConstants.TAG_PART);
1031
            childMem.putString(IWorkbenchConstants.TAG_ID, context.getId(next));
1032
        }
1033
    }
1034
    
1035
    /**
1036
     * Returns the List of IPresentablePart currently in this presentation
1037
     */
1038
    List getPresentableParts() {
1039
        Assert.isTrue(!isDisposed());
1040
        
1041
        CTabItem[] items = getPaneFolder().getItems();
1042
        List result = new ArrayList(items.length);
1043
        
1044
        for (int idx = 0; idx < getPaneFolder().getItemCount(); idx++) {
1045
            result.add(getPartForTab(items[idx]));
1046
        }
1047
        
1048
        return result;
1049
    }
1050
    
989
}
1051
}
(-)src/org/eclipse/ui/internal/presentations/R21EditorStackPresentation.java (-5 / +81 lines)
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
}

Return to bug 62218