KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > jbuilder > node > PrimeDocumentNode


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  *
21  */

22 package org.enhydra.kelp.jbuilder.node;
23
24 // ToolBox imports
25
import org.enhydra.tool.common.PathHandle;
26
27 // Kelp imports
28
import org.enhydra.kelp.common.Constants;
29 import org.enhydra.kelp.common.PropUtil;
30 import org.enhydra.kelp.common.node.OtterProject;
31 import org.enhydra.kelp.common.node.OtterNode;
32 import org.enhydra.kelp.common.node.OtterDocumentNode;
33 import org.enhydra.kelp.common.node.PropertyKeys;
34
35 // JBuilder Foundation imports
36
import com.borland.primetime.node.FileNode;
37 import com.borland.primetime.vfs.InvalidUrlException;
38
39 // Standard imports
40
import java.io.IOException JavaDoc;
41
42 //
43
/**
44  * Class declaration
45  *
46  *
47  * @author Paul Mahar
48  */

49 public class PrimeDocumentNode extends PrimeNode
50     implements OtterDocumentNode {
51
52     //
53
public PrimeDocumentNode(FileNode n) {
54         super(n);
55     }
56
57     /**
58      * Constructor declaration
59      *
60      *
61      * @param otterNode
62      * @param path
63      */

64     public PrimeDocumentNode(OtterNode otterNode, String JavaDoc path) {
65         super(otterNode, path);
66     }
67
68     public void setSelected(boolean b) {
69         super.setSelected(b);
70         if (b) {
71             setStatic(false);
72         }
73     }
74
75     public boolean isStatic() {
76         String JavaDoc in = getProperty(PropertyKeys.NAME_RESOURCE_STATIC);
77
78         return PropUtil.stringToBoolean(in, false);
79     }
80
81     public void setStatic(boolean b) {
82         setProperty(PropertyKeys.NAME_RESOURCE_STATIC,
83                     PropUtil.booleanToString(b));
84         if (b) {
85             setSelected(false);
86         }
87     }
88
89     public void preCompile() {
90         if (getNativeNode() instanceof FileNode) {
91             FileNode nativeNode = (FileNode) getNativeNode();
92
93             if (nativeNode.isModified()) {
94                 try {
95                     nativeNode.save();
96                 } catch (InvalidUrlException e) {
97                     e.printStackTrace();
98                 } catch (IOException JavaDoc e) {
99                     e.printStackTrace();
100                 }
101             }
102         }
103     }
104
105 }
106
Popular Tags