001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.serverconfig;
020:
021: import java.awt.*;
022: import java.awt.event.*;
023:
024: import javax.swing.*;
025:
026: import org.openharmonise.commons.xml.namespace.*;
027: import org.openharmonise.him.*;
028: import org.openharmonise.him.configuration.*;
029: import org.openharmonise.him.harmonise.*;
030: import org.openharmonise.him.swing.resourcetree.*;
031: import org.openharmonise.vfs.*;
032: import org.openharmonise.vfs.metadata.*;
033: import org.openharmonise.vfs.servers.ServerList;
034:
035: /**
036: *
037: * @author matt treanor
038: * @version $Revision: 1.2 $
039: *
040: */
041: public class DocumentPreviewConfigOptions extends
042: AbstractPreviewConfigOptions implements LayoutManager,
043: ActionListener, ApplyChangesListener, TreeViewListener {
044:
045: private ResourceTree m_pageTree = null;
046: private ResourceTree m_sectionTree = null;
047: private RelatedResourceDisplay m_pages = null;
048: private JTextArea m_sectionTextLabel = null;
049: private JTextArea m_pageTextLabel = null;
050:
051: /**
052: * @param dialog
053: */
054: public DocumentPreviewConfigOptions(PreviewConfigDialog dialog) {
055: super (dialog);
056: setup();
057: }
058:
059: private void setup() {
060: try {
061: setLayout(this );
062:
063: String fontName = "Dialog";
064: int fontSize = 11;
065: Font font = new Font(fontName, Font.PLAIN, fontSize);
066:
067: this .m_sectionTree = new ResourceTree();
068: this .m_sectionTree.setBorder(BorderFactory
069: .createEtchedBorder());
070: this .m_sectionTree.setShowLeafNodes(false);
071: this .m_sectionTree.setShowApprovedOnly(true);
072:
073: // Put back after layout editing finished
074: AbstractVirtualFileSystem vfs = ServerList.getInstance()
075: .getHarmoniseServer().getVFS();
076: this .m_sectionTree.addCollection(vfs.getVirtualFile(
077: HarmonisePaths.PATH_DOCUMENTS).getResource());
078: m_sectionTree.addListener(this );
079: add(this .m_sectionTree);
080:
081: m_pages = new RelatedResourceDisplay(this );
082: m_pages.setShowApprovedOnly(true);
083: add(m_pages);
084:
085: m_sectionTextLabel = new JTextArea(
086: "Select a Section to Apply Templates to");
087: m_sectionTextLabel.setOpaque(false);
088: add(m_sectionTextLabel);
089: m_pageTextLabel = new JTextArea("Select Template to Apply");
090: m_pageTextLabel.setOpaque(false);
091: add(m_pageTextLabel);
092: } catch (Exception e) {
093: e.printStackTrace(System.err);
094: }
095:
096: }
097:
098: public void save() {
099: m_pages.saveChangedValues();
100: }
101:
102: /* (non-Javadoc)
103: * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
104: */
105: public void layoutContainer(Container arg0) {
106: int width = getParent().getWidth();
107: int height = getParent().getHeight();
108: setSize(width, height - 20);
109: setLocation(0, 20);
110: setBorder(BorderFactory.createEtchedBorder());
111:
112: int x = 10;
113:
114: this .m_sectionTree.setSize(200, 230);
115: this .m_sectionTree.setLocation(x, 30);
116: this .m_sectionTree
117: .setBorder(BorderFactory.createEtchedBorder());
118:
119: m_pages.setSize(m_pages.getPreferredSize());
120: m_pages.setLocation(x + 250, 30);
121:
122: m_sectionTextLabel.setSize(250, 20);
123: m_sectionTextLabel.setLocation(x, 10);
124:
125: m_pageTextLabel.setSize(150, 20);
126: m_pageTextLabel.setLocation(x + 250, 10);
127: }
128:
129: /* (non-Javadoc)
130: * @see com.simulacramedia.contentmanager.displaycomponents.tree.TreeViewListener#virtualFileSelected(com.simulacramedia.vfs.AbstractVirtualFileSystem, java.lang.String)
131: */
132: public void virtualFileSelected(AbstractVirtualFileSystem vfs,
133: String sPath) {
134: //get the page preview prop and populate the RelatedResourceDisplay
135: VirtualFile vFile = vfs.getVirtualFile(sPath).getResource();
136: PropertyInstance propInst = vFile.getProperty(
137: NamespaceType.OHRM.getURI(), "PREVIEWPAGE");
138: m_pages.populate(propInst);
139: }
140:
141: /* (non-Javadoc)
142: * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
143: */
144: public void removeLayoutComponent(Component arg0) {
145:
146: }
147:
148: /* (non-Javadoc)
149: * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
150: */
151: public void addLayoutComponent(String arg0, Component arg1) {
152: }
153:
154: /* (non-Javadoc)
155: * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
156: */
157: public Dimension minimumLayoutSize(Container arg0) {
158: return null;
159: }
160:
161: /* (non-Javadoc)
162: * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
163: */
164: public Dimension preferredLayoutSize(Container arg0) {
165: return null;
166: }
167:
168: /* (non-Javadoc)
169: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
170: */
171: public void actionPerformed(ActionEvent arg0) {
172: }
173:
174: /* (non-Javadoc)
175: * @see com.simulacramedia.contentmanager.configuration.ApplyChangesListener#applyChanges()
176: */
177: public boolean applyChanges() {
178: return true;
179:
180: }
181:
182: /* (non-Javadoc)
183: * @see com.simulacramedia.contentmanager.configuration.ApplyChangesListener#discardChanges()
184: */
185: public void discardChanges() {
186: }
187:
188: /* (non-Javadoc)
189: * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
190: */
191: public void keyPressed(KeyEvent arg0) {
192: }
193:
194: /* (non-Javadoc)
195: * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
196: */
197: public void keyReleased(KeyEvent arg0) {
198: }
199:
200: /* (non-Javadoc)
201: * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
202: */
203: public void keyTyped(KeyEvent arg0) {
204: }
205: }
|