| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| |
| package org.netbeans.modules.xml.multiview.ui; |
| |
| import java.awt.*; |
| import javax.swing.*; |
| |
| import org.openide.explorer.view.BeanTreeView; |
| |
| /** |
| * The TreePanelDesignEditor two pane editor. This is basically a container that implements the ExplorerManager |
| * interface. It coordinates the selection of a node in the structure pane and the display of a panel by the a PanelView |
| * in the content pane. It will populate the tree view in the structure pane |
| * from the root node of the supplied PanelView. |
| * |
| **/ |
| |
| public class TreePanelDesignEditor extends AbstractDesignEditor { |
| |
| public static final int CONTENT_RIGHT = 0; |
| public static final int CONTENT_LEFT = 1; |
| |
| /** The default width of the ComponentInspector */ |
| public static final int DEFAULT_STRUCTURE_WIDTH = 170; |
| /** The default height of the ComponentInspector */ |
| public static final int DEFAULT_STRUCTURE_HEIGHT = 300; |
| |
| /** Default icon base for control panel. */ |
| private static final String EMPTY_INSPECTOR_ICON_BASE = |
| "/org/netbeans/modules/form/resources/emptyInspector"; // NOI18N |
| |
| protected JSplitPane split; |
| protected int panelOrientation; |
| |
| /** |
| * Creates a new instance of ComponentPanel |
| * @param panel The PanelView which will provide the node tree for the structure view |
| * and the set of panels the nodes map to. |
| */ |
| public TreePanelDesignEditor(PanelView panel) { |
| super(panel); |
| initComponents(); |
| panelOrientation=CONTENT_RIGHT; |
| } |
| |
| /** |
| * Creates a new instance of ComponentPanel |
| * @param panel The PanelView which will provide the node tree for the structure view |
| * and the set of panels the nodes map to. |
| * @param orientation Determines if the content pane is on the left or the right. |
| */ |
| public TreePanelDesignEditor(PanelView panel, int orientation){ |
| this(panel); |
| panelOrientation = orientation; |
| } |
| |
| protected void initComponents() { |
| add(BorderLayout.CENTER,createDesignPanel()); |
| }; |
| |
| protected JComponent createDesignPanel() { |
| if (panelOrientation == CONTENT_LEFT) { |
| split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,getContentView(), getStructureView()); |
| } else { |
| split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,getStructureView(), getContentView()); |
| } |
| split.setOneTouchExpandable(true); |
| return split; |
| |
| } |
| |
| /** |
| * Used to get the JComponent used for the structure pane. Usually a container for the structure component or the structure component itself. |
| * @return the JComponent |
| */ |
| public JComponent getStructureView(){ |
| if (structureView ==null){ |
| structureView = createStructureComponent(); |
| structureView.getAccessibleContext().setAccessibleName("ACS_StructureView"); |
| structureView.getAccessibleContext().setAccessibleDescription("ACSD_StructureView"); |
| } |
| return structureView; |
| } |
| /** |
| * Used to create an instance of the JComponent used for the structure component. Usually a subclass of BeanTreeView. |
| * @return the JComponent |
| */ |
| public JComponent createStructureComponent() { |
| return new BeanTreeView(); |
| } |
| |
| /** |
| * Used to create an instance of the JComponent used for the properties component. Usually a subclass of PropertySheetView. |
| * @return JComponent |
| */ |
| public JComponent createPropertiesComponent(){ |
| return null; |
| } |
| |
| public ErrorPanel getErrorPanel() { |
| return getContentView().getErrorPanel(); |
| } |
| |
| } |