KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > serverconfig > DocumentPreviewConfigOptions


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.serverconfig;
20
21 import java.awt.*;
22 import java.awt.event.*;
23
24 import javax.swing.*;
25
26 import org.openharmonise.commons.xml.namespace.*;
27 import org.openharmonise.him.*;
28 import org.openharmonise.him.configuration.*;
29 import org.openharmonise.him.harmonise.*;
30 import org.openharmonise.him.swing.resourcetree.*;
31 import org.openharmonise.vfs.*;
32 import org.openharmonise.vfs.metadata.*;
33 import org.openharmonise.vfs.servers.ServerList;
34
35
36 /**
37  *
38  * @author matt treanor
39  * @version $Revision: 1.2 $
40  *
41  */

42 public class DocumentPreviewConfigOptions extends AbstractPreviewConfigOptions implements LayoutManager, ActionListener, ApplyChangesListener, TreeViewListener {
43
44     private ResourceTree m_pageTree = null;
45     private ResourceTree m_sectionTree = null;
46     private RelatedResourceDisplay m_pages = null;
47     private JTextArea m_sectionTextLabel = null;
48     private JTextArea m_pageTextLabel = null;
49     
50     /**
51      * @param dialog
52      */

53     public DocumentPreviewConfigOptions(PreviewConfigDialog dialog) {
54         super(dialog);
55         setup();
56     }
57     private void setup() {
58         try {
59             setLayout(this);
60
61             String JavaDoc fontName = "Dialog";
62             int fontSize = 11;
63             Font font = new Font(fontName, Font.PLAIN, fontSize);
64             
65             this.m_sectionTree = new ResourceTree();
66             this.m_sectionTree.setBorder(BorderFactory.createEtchedBorder());
67             this.m_sectionTree.setShowLeafNodes(false);
68             this.m_sectionTree.setShowApprovedOnly(true);
69             
70 // Put back after layout editing finished
71
AbstractVirtualFileSystem vfs = ServerList.getInstance().getHarmoniseServer().getVFS();
72             this.m_sectionTree.addCollection(vfs.getVirtualFile( HarmonisePaths.PATH_DOCUMENTS ).getResource());
73             m_sectionTree.addListener(this);
74             add(this.m_sectionTree);
75         
76             m_pages = new RelatedResourceDisplay(this);
77             m_pages.setShowApprovedOnly(true);
78             add(m_pages);
79             
80             m_sectionTextLabel = new JTextArea("Select a Section to Apply Templates to");
81             m_sectionTextLabel.setOpaque(false);
82             add(m_sectionTextLabel);
83             m_pageTextLabel = new JTextArea("Select Template to Apply");
84             m_pageTextLabel.setOpaque(false);
85             add(m_pageTextLabel);
86         } catch (Exception JavaDoc e) {
87             e.printStackTrace(System.err);
88         }
89         
90     }
91
92     public void save(){
93         m_pages.saveChangedValues();
94     }
95
96     /* (non-Javadoc)
97      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
98      */

99     public void layoutContainer(Container arg0) {
100         int width = getParent().getWidth();
101         int height = getParent().getHeight();
102         setSize(width, height-20);
103         setLocation(0, 20);
104         setBorder( BorderFactory.createEtchedBorder() );
105         
106         int x = 10;
107         
108         this.m_sectionTree.setSize(200,230);
109         this.m_sectionTree.setLocation(x, 30);
110         this.m_sectionTree.setBorder(BorderFactory.createEtchedBorder());
111         
112         m_pages.setSize(m_pages.getPreferredSize());
113         m_pages.setLocation(x+250,30);
114         
115         m_sectionTextLabel.setSize(250,20);
116         m_sectionTextLabel.setLocation(x,10);
117         
118         m_pageTextLabel.setSize(150,20);
119         m_pageTextLabel.setLocation(x+250,10);
120     }
121     
122     /* (non-Javadoc)
123      * @see com.simulacramedia.contentmanager.displaycomponents.tree.TreeViewListener#virtualFileSelected(com.simulacramedia.vfs.AbstractVirtualFileSystem, java.lang.String)
124      */

125     public void virtualFileSelected(AbstractVirtualFileSystem vfs, String JavaDoc sPath) {
126         //get the page preview prop and populate the RelatedResourceDisplay
127
VirtualFile vFile = vfs.getVirtualFile(sPath).getResource();
128         PropertyInstance propInst = vFile.getProperty(NamespaceType.OHRM.getURI(),"PREVIEWPAGE");
129         m_pages.populate(propInst);
130     }
131     
132     /* (non-Javadoc)
133      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
134      */

135     public void removeLayoutComponent(Component arg0) {
136         
137     }
138
139     /* (non-Javadoc)
140      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
141      */

142     public void addLayoutComponent(String JavaDoc arg0, Component arg1) {
143     }
144
145     /* (non-Javadoc)
146      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
147      */

148     public Dimension minimumLayoutSize(Container arg0) {
149         return null;
150     }
151
152     /* (non-Javadoc)
153      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
154      */

155     public Dimension preferredLayoutSize(Container arg0) {
156         return null;
157     }
158
159     /* (non-Javadoc)
160      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
161      */

162     public void actionPerformed(ActionEvent arg0) {
163     }
164
165     /* (non-Javadoc)
166      * @see com.simulacramedia.contentmanager.configuration.ApplyChangesListener#applyChanges()
167      */

168     public boolean applyChanges() {
169         return true;
170         
171     }
172
173     /* (non-Javadoc)
174      * @see com.simulacramedia.contentmanager.configuration.ApplyChangesListener#discardChanges()
175      */

176     public void discardChanges() {
177     }
178
179     /* (non-Javadoc)
180      * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
181      */

182     public void keyPressed(KeyEvent arg0) {
183     }
184
185     /* (non-Javadoc)
186      * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
187      */

188     public void keyReleased(KeyEvent arg0) {
189     }
190
191     /* (non-Javadoc)
192      * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
193      */

194     public void keyTyped(KeyEvent arg0) {
195     }
196 }
197
Popular Tags