KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > ddl > impl > ColumnCommand


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.ddl.impl;
21
22 import java.text.MessageFormat JavaDoc;
23 import java.util.Map JavaDoc;
24
25 import org.openide.util.NbBundle;
26
27 import org.netbeans.lib.ddl.DDLException;
28
29 /**
30 * Instances of this command operates with one column.
31 *
32 * @author Slavek Psenicka
33 */

34
35 public class ColumnCommand extends AbstractCommand
36 {
37     /** Column */
38     private TableColumn column;
39
40     static final long serialVersionUID =-4554975764392047624L;
41     /** Creates specification of command
42     * @param type Type of column
43     * @param name Name of column
44     * @param cmd Command
45     */

46     public TableColumn specifyColumn(String JavaDoc type, String JavaDoc name, String JavaDoc cmd)
47     throws ClassNotFoundException JavaDoc, IllegalAccessException JavaDoc, InstantiationException JavaDoc
48     {
49         Map JavaDoc gprops = (Map JavaDoc)getSpecification().getProperties();
50         Map JavaDoc props = (Map JavaDoc)getSpecification().getCommandProperties(cmd);
51         Map JavaDoc bindmap = (Map JavaDoc)props.get("Binding"); // NOI18N
52
String JavaDoc tname = (String JavaDoc)bindmap.get(type);
53         if (tname != null) {
54             Map JavaDoc typemap = (Map JavaDoc)gprops.get(tname);
55             if (typemap == null) throw new InstantiationException JavaDoc(
56                                                 MessageFormat.format(NbBundle.getBundle("org.netbeans.lib.ddl.resources.Bundle").getString("EXC_UnableLocateObject"), // NOI18N
57
new String JavaDoc[] {tname}));
58             Class JavaDoc typeclass = Class.forName((String JavaDoc)typemap.get("Class")); // NOI18N
59
String JavaDoc format = (String JavaDoc)typemap.get("Format"); // NOI18N
60
column = (TableColumn)typeclass.newInstance();
61             column.setObjectName(name);
62             column.setObjectType(type);
63             column.setColumnName(name);
64             column.setFormat(format);
65         } else throw new InstantiationException JavaDoc(MessageFormat.format(NbBundle.getBundle("org.netbeans.lib.ddl.resources.Bundle").getString("EXC_UnableLocateType"), // NOI18N
66
new String JavaDoc[] {type, bindmap.toString() }));
67
68         return column;
69     }
70
71     public TableColumn getColumn()
72     {
73         return column;
74     }
75
76     public void setColumn(TableColumn col)
77     {
78         column = col;
79     }
80
81     /**
82     * Returns properties and it's values supported by this object.
83     * column Specification of the column
84     */

85     public Map JavaDoc getCommandProperties()
86     throws DDLException
87     {
88         Map JavaDoc args = super.getCommandProperties();
89         args.put("column", column.getCommand(this)); // NOI18N
90
return args;
91     }
92 }
93
Popular Tags