Search in sources :

Example 1 with MultiSplitPane

use of org.netbeans.core.windows.view.ui.MultiSplitPane in project netbeans-rcp-lite by outersky.

the class ResizeModeAction method actionPerformed.

@Override
public void actionPerformed(java.awt.event.ActionEvent ev) {
    updateEnabled();
    if (!isEnabled())
        return;
    ModeImpl contextMode = getModeToWorkWith();
    Component c = contextMode.getSelectedTopComponent();
    MultiSplitPane splitPane = (MultiSplitPane) SwingUtilities.getAncestorOfClass(MultiSplitPane.class, c);
    splitPane.startResizing(c);
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl) MultiSplitPane(org.netbeans.core.windows.view.ui.MultiSplitPane) TopComponent(org.openide.windows.TopComponent) Component(java.awt.Component)

Example 2 with MultiSplitPane

use of org.netbeans.core.windows.view.ui.MultiSplitPane in project netbeans-rcp-lite by outersky.

the class ResizeModeAction method updateEnabled.

private void updateEnabled() {
    ModeImpl contextMode = getModeToWorkWith();
    if (null == contextMode || contextMode.getKind() == Constants.MODE_KIND_EDITOR || contextMode.getState() == Constants.MODE_STATE_SEPARATED || null == contextMode.getSelectedTopComponent()) {
        setEnabled(false);
        return;
    }
    Component c = contextMode.getSelectedTopComponent();
    MultiSplitPane splitPane = (MultiSplitPane) SwingUtilities.getAncestorOfClass(MultiSplitPane.class, c);
    if (null == splitPane) {
        setEnabled(false);
        return;
    }
    setEnabled(true);
}
Also used : ModeImpl(org.netbeans.core.windows.ModeImpl) MultiSplitPane(org.netbeans.core.windows.view.ui.MultiSplitPane) TopComponent(org.openide.windows.TopComponent) Component(java.awt.Component)

Example 3 with MultiSplitPane

use of org.netbeans.core.windows.view.ui.MultiSplitPane in project netbeans-rcp-lite by outersky.

the class SplitView method getSplitPane.

private MultiSplitPane getSplitPane() {
    if (splitPane == null) {
        splitPane = new MultiSplitPane();
        updateSplitPane();
        int dividerSize;
        // get default divider size from SplitPane's UI
        if (orientation == JSplitPane.VERTICAL_SPLIT) {
            // NOI18N
            dividerSize = UIManager.getInt("Nb.SplitPane.dividerSize.vertical");
            if (dividerSize == 0) {
                // NOI18N
                dividerSize = UIManager.getInt("SplitPane.dividerSize");
                if (dividerSize == 0) {
                    dividerSize = Constants.DIVIDER_SIZE_VERTICAL;
                }
            }
        } else {
            // NOI18N
            dividerSize = UIManager.getInt("Nb.SplitPane.dividerSize.horizontal");
            if (dividerSize == 0) {
                // NOI18N
                dividerSize = UIManager.getInt("SplitPane.dividerSize");
                if (dividerSize == 0) {
                    dividerSize = Constants.DIVIDER_SIZE_HORIZONTAL;
                }
            }
        }
        // NOI18N
        Integer override = Integer.getInteger("Nb.SplitPane.dividerSize");
        if (null != override) {
            dividerSize = override.intValue();
        }
        splitPane.setDividerSize(dividerSize);
        splitPane.setBorder(BorderFactory.createEmptyBorder());
        // NOI18N
        splitPane.addPropertyChangeListener(// NOI18N
        "splitPositions", new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                ArrayList<Double> weights = new ArrayList<Double>(children.size());
                ArrayList<ViewElement> views = new ArrayList<ViewElement>(children.size());
                splitPane.calculateSplitWeights(views, weights);
                ViewElement[] arrViews = new ViewElement[views.size()];
                double[] arrWeights = new double[views.size()];
                for (int i = 0; i < views.size(); i++) {
                    arrViews[i] = views.get(i);
                    arrWeights[i] = weights.get(i).doubleValue();
                }
                getController().userMovedSplit(SplitView.this, arrViews, arrWeights);
            }
        });
    }
    return splitPane;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ArrayList(java.util.ArrayList) MultiSplitPane(org.netbeans.core.windows.view.ui.MultiSplitPane)

Aggregations

MultiSplitPane (org.netbeans.core.windows.view.ui.MultiSplitPane)3 Component (java.awt.Component)2 ModeImpl (org.netbeans.core.windows.ModeImpl)2 TopComponent (org.openide.windows.TopComponent)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 ArrayList (java.util.ArrayList)1