Package org.flexdock.docking.state

Examples of org.flexdock.docking.state.DockingState


        Element layoutSequenceElement = document.createElement(PersistenceConstants.LAYOUT_SEQUENCE_ELEMENT_NAME);

        List dockingStates = layoutSequence.getDockingStates();
        ISerializer dockableStateSerializer = SerializerRegistry.getSerializer(DockingState.class);
        for (int i = 0; i < dockingStates.size(); i++) {
            DockingState dockingState = (DockingState) dockingStates.get(i);
            Element dockingStateElement = dockableStateSerializer.serialize(document, dockingState);

            layoutSequenceElement.appendChild(dockingStateElement);
        }
View Full Code Here


        ISerializer dockingStateSerializer = SerializerRegistry.getSerializer(DockingState.class);
        for (int i=0; i<dockingStateNodeList.getLength(); i++) {
            Node dockingStateNode = dockingStateNodeList.item(i);
            if (dockingStateNode instanceof Element) {
                Element dockingStateElement = (Element) dockingStateNode;
                DockingState dockingState = (DockingState) dockingStateSerializer.deserialize(dockingStateElement);
                layoutSequence.add(dockingState);
            }
        }

        return layoutSequence;
View Full Code Here

        Dockable[] dockables = layout.getDockables();
        ISerializer dockingStateSerializer = SerializerRegistry.getSerializer(DockingState.class);
        for (int i = 0; i < dockables.length; i++) {
            Dockable dockable = dockables[i];
            DockingState dockingState = layout.getDockingState(dockable);
            Element dockingStateElement = dockingStateSerializer.serialize(document, dockingState);
            layoutElement.appendChild(dockingStateElement);
        }

        ISerializer floatingGroupSerializer = SerializerRegistry.getSerializer(FloatingGroup.class);
View Full Code Here

        NodeList dockingStateNodeList = element.getElementsByTagName(PersistenceConstants.DOCKING_STATE_ELEMENT_NAME);
        for (int i = 0; i < dockingStateNodeList.getLength(); i++) {
            Node node = dockingStateNodeList.item(i);
            if (node instanceof Element) {
                Element dockingStateElement = (Element) node;
                DockingState dockingState = (DockingState) dockingStateSerializer.deserialize(dockingStateElement);
                String dockableId = dockingState.getDockableId();
                layout.setDockingState(dockableId, dockingState);
            }
        }

        ISerializer floatingGroupsSerializer = SerializerRegistry.getSerializer(FloatingGroup.class);
View Full Code Here

        return new PinButtonModel();
    }

    private static class PinButtonModel extends ViewButtonModel {
        public boolean isSelected() {
            DockingState info = getDockingState();
            if(info==null)
                return super.isSelected();
            return info.isMinimized();
        }
View Full Code Here

    /**
     * @see org.flexdock.perspective.persist.xml.ISerializer#serialize(org.w3c.dom.Document, java.lang.Object)
     */
    public Element serialize(Document document, Object object) {
        DockingState dockingState = (DockingState) object;

        Element dockingStateElement = document.createElement(PersistenceConstants.DOCKING_STATE_ELEMENT_NAME);
        dockingStateElement.setAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_DOCKABLE_ID, dockingState.getDockableId());
        if (dockingState.getRelativeParentId() != null && !dockingState.getRelativeParentId().equals("")) {
            dockingStateElement.setAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_RELATIVE_PARENT_ID, dockingState.getRelativeParentId());
        }
        dockingStateElement.setAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_REGION, dockingState.getRegion().toLowerCase());

        if (dockingState.getSplitRatio() != DockingConstants.UNINITIALIZED_RATIO) {
            dockingStateElement.setAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_SPLIT_RATIO, String.valueOf(dockingState.getSplitRatio()));
        }

        handleDockingState(dockingStateElement, dockingState);

        if (dockingState.isFloating()) {
            dockingStateElement.setAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_FLOATING_GROUP_NAME, dockingState.getFloatingGroup());
        } else if (dockingState.isMinimized()) {
            int constraint = dockingState.getMinimizedConstraint();
            String presConstraint = getPresentationMinimizeConstraint(constraint);
            dockingStateElement.setAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_MINIMIZE_CONSTRAINT, presConstraint);
        }

        if (dockingState.hasCenterPoint()) {
            ISerializer pointSerializer = SerializerRegistry.getSerializer(Point.class);
            Element pointElement = pointSerializer.serialize(document, dockingState.getCenterPoint());
            dockingStateElement.appendChild(pointElement);
        }

        if (dockingState.hasDockingPath()) {
            ISerializer dockingPathSerializer = SerializerRegistry.getSerializer(DockingPath.class);
            Element dockingPathElement = dockingPathSerializer.serialize(document, dockingState.getPath());
            dockingStateElement.appendChild(dockingPathElement);
        }

        return dockingStateElement;
    }
View Full Code Here

    public Object deserialize(Element element) {
        String dockableId = element.getAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_DOCKABLE_ID);
        String relativeParentId = element.getAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_RELATIVE_PARENT_ID);
        String region = element.getAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_REGION);

        DockingState dockingState = new DockingState(dockableId);
        if (relativeParentId != null && !relativeParentId.equals("")) {
            dockingState.setRelativeParentId(relativeParentId);
        }

        dockingState.setRegion(region.toUpperCase());

        String splitRatioString = element.getAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_SPLIT_RATIO);
        if (splitRatioString != null && !splitRatioString.equals("")) {
            float splitRatio = Float.parseFloat(splitRatioString);
            dockingState.setSplitRatio(splitRatio);
        }

        String dockingStateState = element.getAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_STATE);
        if (dockingStateState.equals(FLOATING_STATE)) {
            String floatingGroupName = element.getAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_FLOATING_GROUP_NAME);
            if (floatingGroupName != null && !floatingGroupName.equals("")) {
                dockingState.setFloatingGroup(floatingGroupName);
            }
        } else if (dockingStateState.equals(MINIMIZED_STATE)) {
            String minimizeConstraint = element.getAttribute(PersistenceConstants.DOCKING_STATE_ATTRIBUTE_MINIMIZE_CONSTRAINT);
            int minimizeConstraintInt = getRealMinimizeConstraint(minimizeConstraint);
            dockingState.setMinimizedConstraint(minimizeConstraintInt);
        }
        ISerializer pointDeserializer = SerializerRegistry.getSerializer(Point.class);
        NodeList pointNodeList = element.getElementsByTagName(PersistenceConstants.POINT_ELEMENT_NAME);
        if (pointNodeList.getLength() > 0 && pointNodeList.item(0) instanceof Element) {
            Element centerPointElement = (Element) pointNodeList.item(0);
            Point centerPoint = (Point) pointDeserializer.deserialize(centerPointElement);
            dockingState.setCenter(centerPoint);
        }

        ISerializer dockingPathDeserializer = SerializerRegistry.getSerializer(DockingPath.class);
        NodeList dockingPathNodeList = element.getElementsByTagName(PersistenceConstants.DOCKING_PATH_ELEMENT_NAME);
        if (dockingPathNodeList.getLength() > 0 && dockingPathNodeList.item(0) instanceof Element) {
            Element dockingPathElement = (Element) dockingPathNodeList.item(0);
            DockingPath dockingPath = (DockingPath) dockingPathDeserializer.deserialize(dockingPathElement);
            dockingState.setPath(dockingPath);
        }

        return dockingState;
    }
View Full Code Here

    }


    public boolean restore(Dockable dockable) {
        if(dockable != null) {
            DockingState info = PerspectiveManager.getInstance().getDockingState(dockable, true);
            HashMap context = new HashMap();
            for(Iterator it=restorationHandlers.iterator(); it.hasNext();) {
                RestorationHandler handler = (RestorationHandler)it.next();
                if(handler.restore(dockable, info, context))
                    return true;
View Full Code Here

            return;

        if(relativeParentId==null && sequence.size() > 0)
            throw new IllegalStateException("All calls to add() after the first dockable has been added MUST specify a relative dockable parent.");

        DockingState info = new DockingState(dockableId);
        info.setRelativeParentId(relativeParentId);
        info.setRegion(region);
        info.setSplitRatio(ratio);
        sequence.add(info);
    }
View Full Code Here

        PerspectiveManager.clear(port);
        int len = sequence.size();
        Dockable[] dockables = new Dockable[len];
        for(int i=0; i<len; i++) {
            DockingState info = (DockingState)sequence.get(i);
            Dockable dockable = info.getDockable();
            dockables[i] = dockable;
            String region = info.getRegion();
            if(i==0) {
                DockingManager.dock(info.getDockable(), port, info.getRegion());
                continue;
            }

            Dockable parent = info.getRelativeParent();
            float ratio = info.getSplitRatio();
            DockingUtility.dockRelative(dockable, parent, region, ratio);
        }

        PerspectiveManager.setDockingStateListening(listen);
        PerspectiveManager.updateDockingStates(dockables);
View Full Code Here

TOP

Related Classes of org.flexdock.docking.state.DockingState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.