Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 198657 | Differences between
and this patch

Collapse All | Expand All

(-)a/core.windows/src/org/netbeans/core/windows/Central.java (+19 lines)
 Lines 552-557    Link Here 
552
            WindowManager.PROP_MODES, null, null);
552
            WindowManager.PROP_MODES, null, null);
553
    }
553
    }
554
554
555
    /** change weights of splitter children */
556
    public boolean adjustSizes(ModeImpl mode, WindowManager.WeightCalculator wc) {
557
        SplitConstraint[] oldC = getModeConstraints(mode);
558
        if(!model.adjustSizes(mode, wc)) {
559
            return false;
560
        }
561
        SplitConstraint[] newC = getModeConstraints(mode);
562
563
        if(isVisible()) {
564
                    // XXX is following more appropriate?
565
                    // mode.getKind() == Constants.MODE_KIND_EDITOR
566
                    //     ? View.CHANGE_EDITOR_AREA_CONSTRAINTS_CHANGED
567
                    //     : View.CHANGE_MODE_CONSTRAINTS_CHANGED,
568
            viewRequestor.scheduleRequest(
569
                new ViewRequest(null, View.CHANGE_MODE_CONSTRAINTS_CHANGED, oldC, newC));
570
        }
571
        return true;
572
    }
573
555
    /** Removes mode from model and requests view (if needed). */
574
    /** Removes mode from model and requests view (if needed). */
556
    public void removeMode(ModeImpl mode) {
575
    public void removeMode(ModeImpl mode) {
557
        if(!getModes().contains(mode)) {
576
        if(!getModes().contains(mode)) {
(-)a/core.windows/src/org/netbeans/core/windows/WindowManagerImpl.java (+27 lines)
 Lines 766-771    Link Here 
766
            central.addMode(mode, modeConstraints);
766
            central.addMode(mode, modeConstraints);
767
        }
767
        }
768
    }
768
    }
769
770
    public void addModeOnSide(Mode mode, String side, TopComponent tc) {
771
        if(tc == null || !tc.isOpened())
772
            throw new NullPointerException("null TopComponent or not open");
773
774
        central.userDroppedTopComponents((ModeImpl)mode, new TopComponent[] {tc}, side);
775
    }
776
777
    public void addModeAround(Mode mode, String side, TopComponent tc) {
778
        if(tc == null || !tc.isOpened())
779
            throw new NullPointerException("null TopComponent or not open");
780
781
        TopComponent[] tcs = new TopComponent[] {tc};
782
        if(((ModeImpl)mode).getKind() == Constants.MODE_KIND_EDITOR) {
783
            central.userDroppedTopComponentsAroundEditor(
784
                    tcs, side, Constants.MODE_KIND_EDITOR);
785
        } else {
786
            central.userDroppedTopComponentsAround(tcs, side);
787
        }
788
    }
789
790
    /** change weights of splitter children */
791
    @Override
792
    public boolean adjustSizes(Mode mode, WeightCalculator wc)
793
    {
794
        return central.adjustSizes((ModeImpl)mode, wc);
795
    }
769
    
796
    
770
    /** Removes mode. */
797
    /** Removes mode. */
771
    public void removeMode(ModeImpl mode) {
798
    public void removeMode(ModeImpl mode) {
(-)a/core.windows/src/org/netbeans/core/windows/model/DefaultModel.java (+7 lines)
 Lines 70-75    Link Here 
70
import org.netbeans.core.windows.WindowSystemSnapshot;
70
import org.netbeans.core.windows.WindowSystemSnapshot;
71
import org.openide.windows.RetainLocation;
71
import org.openide.windows.RetainLocation;
72
import org.openide.windows.TopComponent;
72
import org.openide.windows.TopComponent;
73
import org.openide.windows.WindowManager;
73
74
74
75
75
/**
76
/**
 Lines 283-288    Link Here 
283
        }
284
        }
284
    }
285
    }
285
    
286
    
287
    /** change weights of splitter children */
288
    public boolean adjustSizes(ModeImpl mode, WindowManager.WeightCalculator wc) {
289
        synchronized(LOCK_MODES) {
290
            return modesSubModel.adjustSizes(mode, wc);
291
        }
292
    }
286
    
293
    
287
    /** Removes mode. */
294
    /** Removes mode. */
288
    public void removeMode(ModeImpl mode) {
295
    public void removeMode(ModeImpl mode) {
(-)a/core.windows/src/org/netbeans/core/windows/model/Model.java (+3 lines)
 Lines 56-61    Link Here 
56
import java.util.List;
56
import java.util.List;
57
import java.util.Map;
57
import java.util.Map;
58
import java.util.Set;
58
import java.util.Set;
59
import org.openide.windows.WindowManager;
59
60
60
61
61
/**
62
/**
 Lines 106-111    Link Here 
106
    // XXX
107
    // XXX
107
    /** Adds mode around editor area (attaches from side). */
108
    /** Adds mode around editor area (attaches from side). */
108
    public void addModeAroundEditor(ModeImpl mode, String side);
109
    public void addModeAroundEditor(ModeImpl mode, String side);
110
    /** change weights of splitter children */
111
    public boolean adjustSizes(ModeImpl mode, WindowManager.WeightCalculator wc);
109
    /** Removes mode. */
112
    /** Removes mode. */
110
    public void removeMode(ModeImpl mode);
113
    public void removeMode(ModeImpl mode);
111
    /** Sets mode constraints. */
114
    /** Sets mode constraints. */
(-)a/core.windows/src/org/netbeans/core/windows/model/ModesSubModel.java (+10 lines)
 Lines 58-63    Link Here 
58
import java.util.Set;
58
import java.util.Set;
59
import org.netbeans.core.windows.WindowManagerImpl;
59
import org.netbeans.core.windows.WindowManagerImpl;
60
import org.openide.windows.TopComponent;
60
import org.openide.windows.TopComponent;
61
import org.openide.windows.WindowManager;
61
62
62
63
63
/**
64
/**
 Lines 282-287    Link Here 
282
            slideInSizes.put( side+tcId, new Integer(size) );
283
            slideInSizes.put( side+tcId, new Integer(size) );
283
        }
284
        }
284
    }
285
    }
286
287
    /** change weights of splitter children */
288
    public boolean adjustSizes(ModeImpl mode, WindowManager.WeightCalculator wc) {
289
        if(mode.getKind() == Constants.MODE_KIND_EDITOR) {
290
            return editorSplitSubModel.getEditorArea().adjustSizes(mode, wc);
291
        } else {
292
            return editorSplitSubModel.adjustSizes(mode, wc);
293
        }
294
    }
285
    
295
    
286
    public boolean removeMode(ModeImpl mode) {
296
    public boolean removeMode(ModeImpl mode) {
287
        int kind = mode.getKind();
297
        int kind = mode.getKind();
(-)a/core.windows/src/org/netbeans/core/windows/model/SplitSubModel.java (+70 lines)
 Lines 50-55    Link Here 
50
import java.util.logging.Level;
50
import java.util.logging.Level;
51
import java.util.logging.Logger;
51
import java.util.logging.Logger;
52
import org.netbeans.core.windows.*;
52
import org.netbeans.core.windows.*;
53
import org.openide.windows.WindowManager;
53
54
54
55
55
/**
56
/**
 Lines 1162-1167    Link Here 
1162
        }
1163
        }
1163
    } // End of nested ModeNode class.
1164
    } // End of nested ModeNode class.
1164
1165
1166
    /** change weights of splitter children */
1167
    public boolean adjustSizes(ModeImpl mode, WindowManager.WeightCalculator wc) {
1168
        if(mode == null) {
1169
            throw new NullPointerException("Cannot adjust sizes of null mode!");
1170
        }
1171
        if(mode.getOpenedTopComponents().isEmpty())
1172
            return false;
1173
        ModeNode node = getModeNode(mode);
1174
        if(!isInTree(node)) {
1175
            return false;
1176
        }
1177
        SplitNode parent = node.getParent();
1178
        if(parent == null)
1179
            return false;
1180
        List<Node> children = parent.getVisibleChildren();
1181
        List<Double> w = new ArrayList<Double>(children.size());
1182
1183
        int iTarget = -1;
1184
        for(int i = 0; i < children.size(); i++) {
1185
            Node n = children.get(i);
1186
            if(node.equals(n)) {
1187
                iTarget = i;
1188
            }
1189
            w.add(parent.getChildSplitWeight(n));
1190
        }
1191
1192
        SiblingState state = new SiblingState(w, iTarget,
1193
                        parent.getOrientation() == Constants.HORIZONTAL
1194
                            ? WindowManager.SiblingState.Orientation.HORIZONTAL
1195
                            : WindowManager.SiblingState.Orientation.VERTICAL);
1196
        w = wc.getWeights(state);
1197
1198
        // the weight for the node of interest must be different
1199
        if(w.size() != state.weights.size()
1200
                || w.get(iTarget).equals(state.weights.get(iTarget))) {
1201
            return false;
1202
        }
1203
        Iterator<Double> it = w.iterator();
1204
        for(Node n : children) {
1205
            parent.setChildSplitWeight(n, it.next());
1206
        }
1207
        return true;
1208
    }
1209
1210
    private static class SiblingState implements WindowManager.SiblingState {
1211
        private List<Double> weights;
1212
        private int targetIndex;
1213
        private WindowManager.SiblingState.Orientation orientation;
1214
1215
        public SiblingState(List<Double> weights, int targetIndex,
1216
                            Orientation orientation)
1217
        {
1218
            this.weights = weights;
1219
            this.targetIndex = targetIndex;
1220
            this.orientation = orientation;
1221
        }
1222
1223
        @Override public WindowManager.SiblingState.Orientation getOrientation() {
1224
            return orientation;
1225
        }
1226
1227
        @Override public int getTargetIndex() {
1228
            return targetIndex;
1229
        }
1230
1231
        @Override public List<Double> getWeights() {
1232
            return new ArrayList<Double>(weights);
1233
        }
1234
    }
1165
1235
1166
}
1236
}
1167
1237
(-)a/openide.windows/src/org/openide/windows/DummyWindowManager.java (+18 lines)
 Lines 455-460    Link Here 
455
        return "editor".equals(mode.getName());
455
        return "editor".equals(mode.getName());
456
    }
456
    }
457
457
458
    @Override
459
    public void addModeAround(Mode mode, String side, TopComponent tc)
460
    {
461
        throw new UnsupportedOperationException("Not supported yet.");
462
    }
463
464
    @Override
465
    public void addModeOnSide(Mode mode, String side, TopComponent tc)
466
    {
467
        throw new UnsupportedOperationException("Not supported yet.");
468
    }
469
470
    @Override
471
    public boolean adjustSizes(Mode mode, WeightCalculator wc)
472
    {
473
        throw new UnsupportedOperationException("Not supported yet.");
474
    }
475
458
    private final class W implements Workspace {
476
    private final class W implements Workspace {
459
        private static final long serialVersionUID = 1L;
477
        private static final long serialVersionUID = 1L;
460
        private final String name;
478
        private final String name;
(-)a/openide.windows/src/org/openide/windows/WindowManager.java (+105 lines)
 Lines 710-713    Link Here 
710
         */
710
         */
711
        public Set<Workspace> whereOpened();
711
        public Set<Workspace> whereOpened();
712
    }
712
    }
713
    //////////////////////////////////////////////////////////////////////
714
    //
715
    // REVIEWERS:
716
    //        - For side, could have enum WindowManager.Side
717
    //          (then have Orientation in WindowManager instead of SiblingState
718
    //
719
    //        - The WeightCalculator is removed from these addMode* API
720
    //          to simplify implementation.
721
    //          It can be put back and handled here,
722
    //          then performance optimized at a later date.
723
    //
724
    //        - The original proposal returned the new mode, but that isn't
725
    //          a pattern I see around. Should it return a mode?
726
    //
727
    //////////////////////////////////////////////////////////////////////
728
729
    /**
730
     * Add a new Mode, with a TopComponent in it, on a side of the specified
731
     * mode. Constants from JSplitPane are used to specify the side:
732
     * TOP, BOTTOM, LEFT, RIGHT.
733
     *
734
     * @param mode the new mode is next to this mode
735
     * @param side which side to attach the new mode.
736
     * @param tc TopComponent to put into the new mode.
737
     */
738
    abstract public void addModeOnSide(Mode mode, String side, TopComponent tc);
739
740
    /**
741
     * Add a new Mode, with a TopComponent in it, that touches the side
742
     * of the specified mode. The new mode is either wider or higher
743
     * than the mode.
744
     * Constants from JSplitPane are used to specify the side:
745
     * TOP, BOTTOM, LEFT, RIGHT.
746
     * When mode's container's orientation is the same as
747
     * the specified side, this method does the same thing as addModeOnSide.
748
     *
749
     * @param mode
750
     * @param side
751
     * @param tc
752
     */
753
    abstract public void addModeAround(Mode mode, String side, TopComponent tc);
754
755
    //////////////////////////////////////////////////////////////////////
756
    //
757
    // REVIEWERS:
758
    //          The restriction that the specified mode's weight must
759
    //          be changed can be relaxed so that a modification to any
760
    //          weight will trigger a change.
761
    //
762
    //          To do that is trivial if in
763
    //              ViewRequest(null, View.CHANGE_MODE_CONSTRAINTS_CHANGED,
764
    //                  oldConstraints, newConstraints)
765
    //          it doesn't matter if oldContstraints == newConstraints. Or
766
    //          if oldConstraints can simply be set to null.
767
    //          If the type of ViewRequest requires accurate old/new then
768
    //          the restriction can still be relaxed by keeping track
769
    //          of the constraints for each of the modes.
770
    //
771
    //////////////////////////////////////////////////////////////////////
772
773
    /**
774
     * Change the sizing weights of a mode, and optionally its siblings,
775
     * within a splitter. If the weight for the specified mode is not
776
     * changed then no action takes place even if sibling weights are
777
     * changed.
778
     * @param mode
779
     * @param wc provides new size informaiton
780
     * @return true if the sizes changed
781
     */
782
    abstract public boolean adjustSizes(Mode mode, WeightCalculator wc);
783
784
    /**
785
     * Used with the adjustSizes method to provide new weights.
786
     */
787
    public interface WeightCalculator {
788
        /**
789
         * Invoked by the window system to get the new weights.
790
         * @param currentState splitter and sibling information
791
         * @return new weights
792
         */
793
        List<Double> getWeights(SiblingState currentState);
794
    }
795
796
    /**
797
     * Information about a splitter's children.
798
     */
799
    public interface SiblingState {
800
        enum Orientation { HORIZONTAL, VERTICAL; }
801
        /**
802
         * Splitter orientation.
803
         * @return the splitter orientation
804
         */
805
        Orientation getOrientation();
806
        /**
807
         * @return the index of the mode to change
808
         */
809
        int getTargetIndex();
810
        /**
811
         * The current weights of the splitter's children, either top to bottom
812
         * or left to right depending on orientation. The returned list
813
         * can be modified.
814
         * @return current weights
815
         */
816
        List<Double> getWeights();
817
    }
713
}
818
}

Return to bug 198657
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo