2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
43
package org.netbeans.modules.i18n.wizard;
46
import java.util.Comparator;
49
import java.util.TreeMap;
50
import org.netbeans.modules.i18n.HardCodedString;
51
import org.netbeans.modules.i18n.I18nString;
53
import org.netbeans.modules.i18n.I18nSupport;
55
import org.openide.loaders.DataObject;
59
* Object representing source dependent i18n data passed to i18n wizard
60
* descriptor and its panels via readSettings and storeSettings methods.
61
* It's the "value part" of <code>Map</code> (keyed by DataObject)
62
* passed as settings for wizard descriptor and to individual panels.
64
* @author Peter Zavadsky
65
* @see ResourceWizardPanel where lifecycle begins.
66
* @see org.openide.WizardDescriptor
67
* @see org.openide.WizardDescriptor.Panel#readSettings
68
* @see org.openide.WizardDecritptor.Panel#storeSettings
70
final class SourceData {
72
/** Resource where to put i18n string */
73
private DataObject resource;
75
/** Support used by i18n-zing. */
76
private I18nSupport support;
78
/** Mapping found hard coded strings to i18n strings. */
79
private Map<HardCodedString,I18nString> stringMap
80
= new TreeMap<HardCodedString,I18nString>(new HardStringComparator());
82
private static class HardStringComparator implements Comparator<HardCodedString> {
83
public int compare(HardCodedString hcs1, HardCodedString hcs2) {
84
return hcs1.getStartPosition().getOffset() -
85
hcs2.getStartPosition().getOffset();
89
/** Hard coded strings user selected to non-proceed. */
90
private Set<HardCodedString> removedStrings;
94
public SourceData(DataObject resource) {
95
this.resource = resource;
99
public SourceData(DataObject resource, I18nSupport support) {
100
this.resource = resource;
101
this.support = support;
103
support.getResourceHolder().setResource(resource);
107
/** Getter for <code>resource</code> property. */
108
public DataObject getResource() {
112
/** Getter for <code>resource</code> property. */
113
public I18nSupport getSupport() {
117
/** Getter for <code>stringMap</code> property. */
118
public Map<HardCodedString,I18nString> getStringMap() {
122
/** Setter for <code>stringMap</code> prtoperty. */
123
public void setStringMap(Map<HardCodedString,I18nString> stringMap) {
124
this.stringMap.clear();
125
this.stringMap.putAll(stringMap);
128
/** Getter for <code>removedStrings</code> property. */
129
public Set<HardCodedString> getRemovedStrings() {
130
return removedStrings;
133
/** Setter for <code>removedStrings</code> property. */
134
public void setRemovedStrings(Set<HardCodedString> removedStrings) {
135
this.removedStrings = removedStrings;