001/*
002 * ModeShape (http://www.modeshape.org)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *       http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.modeshape.web.client.contents;
017
018import com.smartgwt.client.widgets.layout.HLayout;
019import com.smartgwt.client.widgets.layout.VLayout;
020
021/**
022 * Two columns layout.
023 * 
024 * Left column contains children nodes and binary editor, right column contains
025 * details of the node such as properties and permissions.
026 * 
027 * 
028 * @author kulikov
029 */
030public class ContentsLayout extends HLayout {
031    private ChildrenEditor children;
032    private DetailsLayout details;
033    private boolean showDetails = false;
034    
035    /**
036     * Creates layout.
037     * 
038     * @param children children nodes area.
039     * @param binary binary content area.
040     * @param details node details area.
041     */
042    public ContentsLayout(ChildrenEditor children, BinaryEditor binary, DetailsLayout details) {
043        this.children = children;
044        this.details = details;
045        
046        //left column
047        VLayout panel = new VLayout();
048
049        HLayout hstrut = new HLayout();
050        hstrut.setHeight(30);
051        
052        //put children and binary editors separated by stut.
053        panel.addMember(children);
054        panel.addMember(hstrut);
055        panel.addMember(binary);
056        
057        VLayout strut = new VLayout();
058        strut.setWidth(10);
059        
060        addMember(panel);
061        addMember(strut);
062        addMember(details);
063    }
064    
065    /**
066     * Gets status of the details area.
067     * 
068     * @return true if details are visible on the screen.
069     */
070    public boolean showDetails() {
071        return showDetails;
072    }
073    
074    /**
075     * Modifies status of the details area on the screen.
076     * 
077     * @param showDetails true enables details on the screen.
078     */
079    public void setShowDetails( boolean showDetails ) {
080        this.showDetails = showDetails;
081        details.setVisible(showDetails);
082    }
083    
084    @Override
085    public void setVisible(boolean visible) {
086        children.setVisible(visible);
087        if (showDetails) {
088            details.setVisible(visible);
089        } else {
090            details.setVisible(false);
091        }
092    }
093    
094}