KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > i18n > wizard > SourceData


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
21 package org.netbeans.modules.i18n.wizard;
22
23
24 import java.util.Comparator JavaDoc;
25 import java.util.Map JavaDoc;
26 import java.util.Set JavaDoc;
27 import org.netbeans.modules.i18n.*;
28
29 import org.netbeans.modules.i18n.I18nSupport;
30
31 import org.openide.loaders.DataObject;
32
33
34 /**
35  * Object representing source dependent i18n data passed to i18n wizard
36  * descriptor and its panels via readSettings and storeSettings methods.
37  * It's the "value part" of <code>Map</code> (keyed by DataObject)
38  * passed as settings for wizard descriptor and to individual panels.
39  *
40  * @author Peter Zavadsky
41  * @see ResourceWizardPanel where lifecycle begins.
42  * @see org.openide.WizardDescriptor
43  * @see org.openide.WizardDescriptor.Panel#readSettings
44  * @see org.openide.WizardDecritptor.Panel#storeSettings
45  */

46 final class SourceData {
47
48     /** Resource where to put i18n string */
49     private DataObject resource;
50
51     /** Support used by i18n-zing. */
52     private I18nSupport support;
53
54     /** Mapping found hard coded strings to i18n strings. */
55     private Map JavaDoc stringMap = new java.util.TreeMap JavaDoc(new HardStringComparator());
56     
57     private static class HardStringComparator implements java.util.Comparator JavaDoc {
58         public int compare(Object JavaDoc obj, Object JavaDoc obj1) {
59             HardCodedString hcs1 = (HardCodedString)obj;
60             HardCodedString hcs2 = (HardCodedString)obj1;
61             return hcs1.getStartPosition().getOffset() -
62                     hcs2.getStartPosition().getOffset();
63         }
64      }
65     
66     /** Hard coded strings user selected to non-proceed. */
67     private Set JavaDoc removedStrings;
68
69     
70     /** Constructor. */
71     public SourceData(DataObject resource) {
72         this.resource = resource;
73     }
74
75     /** Constructor. */
76     public SourceData(DataObject resource, I18nSupport support) {
77         this.resource = resource;
78         this.support = support;
79         
80         support.getResourceHolder().setResource(resource);
81     }
82
83
84     /** Getter for <code>resource</code> property. */
85     public DataObject getResource() {
86         return resource;
87     }
88
89     /** Getter for <code>resource</code> property. */
90     public I18nSupport getSupport() {
91         return support;
92     }
93
94     /** Getter for <code>stringMap</code> property. */
95     public Map JavaDoc getStringMap() {
96         return stringMap;
97     }
98     
99     /** Setter for <code>stringMap</code> prtoperty. */
100     public void setStringMap(Map JavaDoc stringMap) {
101         this.stringMap.clear();
102         this.stringMap.putAll(stringMap);
103     }
104     
105     /** Getter for <code>removedStrings</code> property. */
106     public Set JavaDoc getRemovedStrings() {
107         return removedStrings;
108     }
109     
110     /** Setter for <code>removedStrings</code> property. */
111     public void setRemovedStrings(Set JavaDoc removedStrings) {
112         this.removedStrings = removedStrings;
113     }
114     
115 }
116
Popular Tags