Lines 47-56
Link Here
|
47 |
import java.util.ResourceBundle; |
47 |
import java.util.ResourceBundle; |
48 |
import javax.swing.JComponent; |
48 |
import javax.swing.JComponent; |
49 |
import javax.swing.JPanel; |
49 |
import javax.swing.JPanel; |
|
|
50 |
import javax.swing.text.BadLocationException; |
50 |
import org.netbeans.api.project.Project; |
51 |
import org.netbeans.api.project.Project; |
51 |
import org.netbeans.modules.java.j2seproject.J2SEProject; |
52 |
import org.netbeans.modules.java.j2seproject.J2SEProject; |
52 |
import org.netbeans.modules.java.j2seproject.J2SEProjectUtil; |
53 |
import org.netbeans.modules.java.j2seproject.J2SEProjectUtil; |
|
|
54 |
import org.netbeans.spi.project.support.ant.ui.CustomizerUtilities; |
53 |
import org.netbeans.spi.project.ui.support.ProjectCustomizer; |
55 |
import org.netbeans.spi.project.ui.support.ProjectCustomizer; |
|
|
56 |
import org.openide.filesystems.FileObject; |
57 |
import org.openide.util.Exceptions; |
54 |
import org.openide.util.Lookup; |
58 |
import org.openide.util.Lookup; |
55 |
import org.openide.util.NbBundle; |
59 |
import org.openide.util.NbBundle; |
56 |
|
60 |
|
Lines 68-73
Link Here
|
68 |
private static final String JAVADOC = "Javadoc"; |
72 |
private static final String JAVADOC = "Javadoc"; |
69 |
public static final String RUN = "Run"; |
73 |
public static final String RUN = "Run"; |
70 |
private static final String APPLICATION = "Application"; |
74 |
private static final String APPLICATION = "Application"; |
|
|
75 |
private static final String LICENSE = "License"; |
71 |
|
76 |
|
72 |
private String name; |
77 |
private String name; |
73 |
|
78 |
|
Lines 75-80
Link Here
|
75 |
this.name = name; |
80 |
this.name = name; |
76 |
} |
81 |
} |
77 |
|
82 |
|
|
|
83 |
@Override |
78 |
public ProjectCustomizer.Category createCategory(Lookup context) { |
84 |
public ProjectCustomizer.Category createCategory(Lookup context) { |
79 |
ResourceBundle bundle = NbBundle.getBundle( CustomizerProviderImpl.class ); |
85 |
ResourceBundle bundle = NbBundle.getBundle( CustomizerProviderImpl.class ); |
80 |
ProjectCustomizer.Category toReturn = null; |
86 |
ProjectCustomizer.Category toReturn = null; |
Lines 103-108
Link Here
|
103 |
JAVADOC, |
109 |
JAVADOC, |
104 |
bundle.getString( "LBL_Config_Javadoc" ), // NOI18N |
110 |
bundle.getString( "LBL_Config_Javadoc" ), // NOI18N |
105 |
null); |
111 |
null); |
|
|
112 |
} else if (LICENSE.equals(name)) { |
113 |
toReturn = ProjectCustomizer.Category.create( |
114 |
LICENSE, |
115 |
"License Headers", // NOI18N |
116 |
null); |
106 |
} else if (RUN.equals(name)) { |
117 |
} else if (RUN.equals(name)) { |
107 |
boolean fxOverride = false; |
118 |
boolean fxOverride = false; |
108 |
final Project project = context.lookup(Project.class); |
119 |
final Project project = context.lookup(Project.class); |
Lines 123-131
Link Here
|
123 |
return toReturn; |
134 |
return toReturn; |
124 |
} |
135 |
} |
125 |
|
136 |
|
126 |
public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) { |
137 |
@Override |
|
|
138 |
public JComponent createComponent(ProjectCustomizer.Category category, final Lookup context) { |
127 |
String nm = category.getName(); |
139 |
String nm = category.getName(); |
128 |
J2SEProjectProperties uiProps = context.lookup(J2SEProjectProperties.class); |
140 |
final J2SEProjectProperties uiProps = context.lookup(J2SEProjectProperties.class); |
129 |
if (SOURCES.equals(nm)) { |
141 |
if (SOURCES.equals(nm)) { |
130 |
return new CustomizerSources(uiProps); |
142 |
return new CustomizerSources(uiProps); |
131 |
} else if (LIBRARIES.equals(nm)) { |
143 |
} else if (LIBRARIES.equals(nm)) { |
Lines 142-148
Link Here
|
142 |
return new CustomizerRun(uiProps); |
154 |
return new CustomizerRun(uiProps); |
143 |
} else if (APPLICATION.equals(nm)) { |
155 |
} else if (APPLICATION.equals(nm)) { |
144 |
return new CustomizerApplication(uiProps); |
156 |
return new CustomizerApplication(uiProps); |
|
|
157 |
} else if (LICENSE.equals(nm)) { |
158 |
CustomizerUtilities.LicensePanelContentHandler handler = |
159 |
new CustomizerUtilities.LicensePanelContentHandler() { |
160 |
@Override |
161 |
public String getProjectLicenseLocation() { |
162 |
try { |
163 |
String path = uiProps.LICENSE_PATH_DOC.getText(0, uiProps.LICENSE_PATH_DOC.getLength()); |
164 |
if (path != null && path.trim().isEmpty()) { |
165 |
path = null; |
145 |
} |
166 |
} |
|
|
167 |
return path; |
168 |
} catch (BadLocationException ex) { |
169 |
Exceptions.printStackTrace(ex); |
170 |
} |
171 |
return null; |
172 |
} |
173 |
|
174 |
@Override |
175 |
public String getGlobalLicenseName() { |
176 |
try { |
177 |
String name = uiProps.LICENSE_NAME_DOC.getText(0, uiProps.LICENSE_NAME_DOC.getLength()); |
178 |
if (name != null && name.trim().isEmpty()) { |
179 |
name = null; |
180 |
} |
181 |
return name; |
182 |
} catch (BadLocationException ex) { |
183 |
Exceptions.printStackTrace(ex); |
184 |
} |
185 |
return null; |
186 |
} |
187 |
|
188 |
@Override |
189 |
public FileObject resolveProjectLocation(String path) { |
190 |
final J2SEProject project = context.lookup(J2SEProject.class); |
191 |
String evaluated = uiProps.getEvaluator().evaluate(path); |
192 |
return project.getAntProjectHelper().resolveFileObject(evaluated); |
193 |
} |
194 |
|
195 |
@Override |
196 |
public void setProjectLicenseLocation(String newLocation) { |
197 |
try { |
198 |
uiProps.LICENSE_PATH_DOC.remove(0, uiProps.LICENSE_PATH_DOC.getLength()); |
199 |
uiProps.LICENSE_PATH_DOC.insertString(0, newLocation, null); |
200 |
} catch (BadLocationException ex) { |
201 |
Exceptions.printStackTrace(ex); |
202 |
} |
203 |
} |
204 |
|
205 |
@Override |
206 |
public void setGlobalLicenseName(String newName) { |
207 |
try { |
208 |
uiProps.LICENSE_NAME_DOC.remove(0, uiProps.LICENSE_NAME_DOC.getLength()); |
209 |
uiProps.LICENSE_NAME_DOC.insertString(0, newName, null); |
210 |
} catch (BadLocationException ex) { |
211 |
Exceptions.printStackTrace(ex); |
212 |
} |
213 |
} |
214 |
|
215 |
@Override |
216 |
public String getDefaultProjectLicenseLocation() { |
217 |
return "./nbproject/licenseheader.txt"; |
218 |
} |
219 |
|
220 |
@Override |
221 |
public void setProjectLicenseContent(String text) { |
222 |
uiProps.CHANGED_LICENSE_PATH_CONTENT = text; |
223 |
} |
224 |
}; |
225 |
|
226 |
return CustomizerUtilities.createLicenseHeaderCustomizerPanel(category, handler); |
227 |
} |
146 |
return new JPanel(); |
228 |
return new JPanel(); |
147 |
|
229 |
|
148 |
} |
230 |
} |
Lines 207-210
Link Here
|
207 |
public static J2SECompositePanelProvider createApplication() { |
289 |
public static J2SECompositePanelProvider createApplication() { |
208 |
return new J2SECompositePanelProvider(APPLICATION); |
290 |
return new J2SECompositePanelProvider(APPLICATION); |
209 |
} |
291 |
} |
|
|
292 |
|
293 |
@ProjectCustomizer.CompositeCategoryProvider.Registration( |
294 |
projectType="org-netbeans-modules-java-j2seproject", |
295 |
position=600 |
296 |
) |
297 |
public static J2SECompositePanelProvider createLicense() { |
298 |
return new J2SECompositePanelProvider(LICENSE); |
210 |
} |
299 |
} |
|
|
300 |
|
301 |
} |