01: /*
02: * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.ffj.properties;
06:
07: import java.io.IOException;
08: import java.io.File;
09:
10: import java.beans.PropertyEditor;
11:
12: import org.openide.util.NbBundle;
13:
14: import org.openide.nodes.PropertySupport;
15:
16: import org.openide.filesystems.FileObject;
17: import org.openide.filesystems.FileUtil;
18: import org.openide.filesystems.FileSystem;
19:
20: import org.openide.TopManager;
21: import org.openide.ErrorManager;
22:
23: import com.sun.portal.ffj.util.PSConstants;
24: import com.sun.portal.ffj.util.PortletList;
25:
26: public class PortletSetProperty extends PropertySupport.ReadWrite
27: implements PSConstants {
28:
29: public PortletSetProperty(FileObject obj) {
30: super (PORTLET_SET_PROPERTY, String.class, displayName(),
31: shortDesc());
32: m_FObj = obj;
33: }
34:
35: public Object getValue() {
36: Object attr = m_FObj.getAttribute(PORTLET_SET_PROPERTY);
37: if (attr == null) {
38: return ALL_PORTLETS;
39: }
40: return attr;
41: }
42:
43: public void setValue(Object obj) throws IllegalAccessException {
44: try {
45: m_FObj.setAttribute(PORTLET_SET_PROPERTY, obj);
46: } catch (IOException ex) {
47: throw new IllegalAccessException(ex.getMessage());
48: }
49: }
50:
51: public PropertyEditor getPropertyEditor() {
52: try {
53: return new PortletSelectionEditor(new PortletList(
54: findRoot(m_FObj)));
55: } catch (Exception ex) {
56: TopManager.getDefault().getErrorManager().notify(
57: ErrorManager.USER, ex);
58: }
59: return null;
60: }
61:
62: private File findRoot(FileObject fob) throws IOException {
63: FileSystem fs = fob.getFileSystem();
64: File rdir = FileUtil.toFile(fs.getRoot());
65: return new File(rdir, "WEB-INF/classes");
66: }
67:
68: private static String displayName() {
69: return NbBundle.getMessage(PortletSetProperty.class,
70: "LBL_PortletSetDisplayName");
71: }
72:
73: private static String shortDesc() {
74: return NbBundle.getMessage(PortletSetProperty.class,
75: "LBL_PortletShortDesc");
76: }
77:
78: private FileObject m_FObj;
79: }
|