Skip to content

Commit d023a82

Browse files
eclipse-pde-botlaeubi
authored andcommitted
Perform clean code of ui/org.eclipse.pde.ui.templates
1 parent 966b668 commit d023a82

26 files changed

+186
-94
lines changed

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/PDETemplateSection.java

+14-7
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,21 @@ public URL getTemplateLocation() {
6868
private String[] getDirectoryCandidates() {
6969
double version = getTargetVersion();
7070
ArrayList<String> result = new ArrayList<>();
71-
if (version >= 3.5)
71+
if (version >= 3.5) {
7272
result.add("templates_3.5" + "/" + getSectionId() + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
73-
if (version >= 3.4)
73+
}
74+
if (version >= 3.4) {
7475
result.add("templates_3.4" + "/" + getSectionId() + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
75-
if (version >= 3.3)
76+
}
77+
if (version >= 3.3) {
7678
result.add("templates_3.3" + "/" + getSectionId() + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
77-
if (version >= 3.2)
79+
}
80+
if (version >= 3.2) {
7881
result.add("templates_3.2" + "/" + getSectionId() + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
79-
if (version >= 3.1)
82+
}
83+
if (version >= 3.1) {
8084
result.add("templates_3.1" + "/" + getSectionId() + "/"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
85+
}
8186
return result.toArray(new String[result.size()]);
8287
}
8388

@@ -91,11 +96,13 @@ protected String getFormattedPackageName(String id) {
9196
for (int i = 0; i < id.length(); i++) {
9297
char ch = id.charAt(i);
9398
if (buffer.length() == 0) {
94-
if (Character.isJavaIdentifierStart(ch))
99+
if (Character.isJavaIdentifierStart(ch)) {
95100
buffer.append(Character.toLowerCase(ch));
101+
}
96102
} else {
97-
if (Character.isJavaIdentifierPart(ch) || ch == '.')
103+
if (Character.isJavaIdentifierPart(ch) || ch == '.') {
98104
buffer.append(ch);
105+
}
99106
}
100107
}
101108
return buffer.toString().toLowerCase(Locale.ENGLISH);

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/AbstractE4NewPluginTemplateWizard.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,25 @@ public boolean performFinish(IProject project, IPluginModelBase model, IProgress
7070
String runtimeVersion = null;
7171

7272
for (IPluginImport ii : pb.getImports()) {
73-
if (ii.getId().equals(ORG_ECLIPSE_UI))
73+
if (ii.getId().equals(ORG_ECLIPSE_UI)) {
7474
ui = ii;
75+
}
7576
if (ii.getId().equals(ORG_ECLIPSE_CORE_RUNTIME)) {
7677
// This plugin appears twice : with and without version (due to ancestor)
77-
if (ii.getVersion() == null)
78+
if (ii.getVersion() == null) {
7879
runtime = ii;
79-
else
80+
} else {
8081
runtimeVersion = ii.getVersion();
82+
}
8183
}
8284

8385
}
8486

8587
// Remove these two bad imports...
8688
try {
87-
if (ui != null)
89+
if (ui != null) {
8890
pb.remove(ui);
91+
}
8992
if (runtime != null) {
9093
// Remove the org.eclipse.core.runtime without any version
9194
pb.remove(runtime);
@@ -124,8 +127,9 @@ private void openEditorForApplicationModel(IProject project) throws PartInitExce
124127
final FileEditorInput input = new FileEditorInput(file);
125128
final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
126129
final IWorkbenchPage page = window.getActivePage();
127-
if (page != null)
130+
if (page != null) {
128131
page.openEditor(input, MODEL_EDITOR_ID);
132+
}
129133
}
130134
}
131135
}

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ApplicationTemplate.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,18 @@ private void createProductExtension() throws CoreException {
143143

144144
extension.add(element);
145145

146-
if (!extension.isInTheModel())
146+
if (!extension.isInTheModel()) {
147147
plugin.add(extension);
148+
}
148149
}
149150

150151
@Override
151152
protected boolean isOkToCreateFolder(File sourceFolder) {
152153
// We copy the files in 'org.eclipse.pde.ui.templates/templates_3.5/E4Application/*/handlers' or 'parts' if content required
153154
String fname = sourceFolder.getName();
154-
if (fname.endsWith("handlers") || fname.endsWith("parts")) //$NON-NLS-1$//$NON-NLS-2$
155+
if (fname.endsWith("handlers") || fname.endsWith("parts")) { //$NON-NLS-1$//$NON-NLS-2$
155156
return getBooleanOption(KEY_CREATE_SAMPLE_CONTENT);
157+
}
156158
return super.isOkToCreateFolder(sourceFolder);
157159
}
158160

@@ -162,8 +164,9 @@ protected boolean isOkToCreateFile(File sourceFile) {
162164
// If file is the lifeCycleClassname (with a $ at the end) we keep it only if life cycle must be created.
163165
String fname = sourceFile.getName();
164166

165-
if (fname.equals(TEMPLATE_LIFECYCLE_FILENAME))
167+
if (fname.equals(TEMPLATE_LIFECYCLE_FILENAME)) {
166168
return getBooleanOption(KEY_CREATE_LIFE_CYCLE);
169+
}
167170

168171
// There are 2 application models :
169172
// the bin/Application.e4xmi containing the empty model

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4HandlerTemplate.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ private void createE4ModelExtension() throws CoreException {
122122

123123
extension.add(element);
124124

125-
if (!extension.isInTheModel())
125+
if (!extension.isInTheModel()) {
126126
plugin.add(extension);
127+
}
127128
}
128129

129130
@Override

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ToolbarContributionTemplate.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ private void createE4ModelExtension() throws CoreException {
123123

124124
extension.add(element);
125125

126-
if (!extension.isInTheModel())
126+
if (!extension.isInTheModel()) {
127127
plugin.add(extension);
128+
}
128129
}
129130

130131
@Override

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/e4/E4ViewTemplate.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ private void createE4ModelExtension() throws CoreException {
124124

125125
extension.add(element);
126126

127-
if (!extension.isInTheModel())
127+
if (!extension.isInTheModel()) {
128128
plugin.add(extension);
129+
}
129130
}
130131

131132
@Override

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/BrowserViewTemplate.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ protected void updateModel(IProgressMonitor monitor) throws CoreException {
142142
viewElement.setAttribute("category", cid); //$NON-NLS-1$
143143
viewElement.setAttribute("inject", "true"); //$NON-NLS-1$ //$NON-NLS-2$
144144
extension.add(viewElement);
145-
if (!extension.isInTheModel())
145+
if (!extension.isInTheModel()) {
146146
plugin.add(extension);
147+
}
147148

148149
if (addToPerspective.isSelected()) {
149150
IPluginExtension perspectiveExtension = createExtension("org.eclipse.ui.perspectiveExtensions", true); //$NON-NLS-1$
@@ -161,8 +162,9 @@ protected void updateModel(IProgressMonitor monitor) throws CoreException {
161162
perspectiveElement.add(view);
162163

163164
perspectiveExtension.add(perspectiveElement);
164-
if (!perspectiveExtension.isInTheModel())
165+
if (!perspectiveExtension.isInTheModel()) {
165166
plugin.add(perspectiveExtension);
167+
}
166168
}
167169
}
168170

@@ -174,8 +176,9 @@ private void createCategory(IPluginExtension extension, String id) throws CoreEx
174176
IPluginAttribute att = element.getAttribute("id"); //$NON-NLS-1$
175177
if (att != null) {
176178
String cid = att.getValue();
177-
if (cid != null && cid.equals(id))
179+
if (cid != null && cid.equals(id)) {
178180
return;
181+
}
179182
}
180183
}
181184
}
@@ -194,24 +197,27 @@ public String[] getNewFiles() {
194197
@Override
195198
public IPluginReference[] getDependencies(String schemaVersion) {
196199
ArrayList<PluginReference> result = new ArrayList<>();
197-
if (schemaVersion != null)
200+
if (schemaVersion != null) {
198201
result.add(new PluginReference("org.eclipse.core.runtime")); //$NON-NLS-1$
202+
}
199203
result.add(new PluginReference("org.eclipse.ui")); //$NON-NLS-1$
200204
return result.toArray(new IPluginReference[result.size()]);
201205
}
202206

203207
@Override
204208
protected String getFormattedPackageName(String id) {
205209
String packageName = super.getFormattedPackageName(id);
206-
if (packageName.length() != 0)
210+
if (packageName.length() != 0) {
207211
return packageName + ".views"; //$NON-NLS-1$
212+
}
208213
return "views"; //$NON-NLS-1$
209214
}
210215

211216
@Override
212217
public Object getValue(String name) {
213-
if (name.equals("useEnablement")) //$NON-NLS-1$
218+
if (name.equals("useEnablement")) { //$NON-NLS-1$
214219
return Boolean.valueOf(getTargetVersion() >= 3.3);
220+
}
215221
return super.getValue(name);
216222
}
217223
}

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/BuilderTemplate.java

+16-8
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,9 @@ protected void updateModel(IProgressMonitor monitor) throws CoreException {
141141
+ "." + getStringOption(KEY_BUILDER_CLASS_NAME)); //$NON-NLS-1$
142142
builder.add(run);
143143

144-
if (!extension1.isInTheModel())
144+
if (!extension1.isInTheModel()) {
145145
plugin.add(extension1);
146+
}
146147

147148
// Nature
148149
IPluginExtension extension2 = createExtension("org.eclipse.core.resources.natures", true); //$NON-NLS-1$
@@ -165,8 +166,9 @@ protected void updateModel(IProgressMonitor monitor) throws CoreException {
165166
+ "." + getStringOption(KEY_BUILDER_ID)); //$NON-NLS-1$
166167
extension2.add(builder2);
167168

168-
if (!extension2.isInTheModel())
169+
if (!extension2.isInTheModel()) {
169170
plugin.add(extension2);
171+
}
170172

171173
// Popup Action
172174
if (actionOption.isSelected()) {
@@ -190,8 +192,9 @@ protected void updateModel(IProgressMonitor monitor) throws CoreException {
190192
command.setAttribute("name", PDETemplateMessages.BuilderTemplate_commandName + getStringOption(KEY_NATURE_NAME)); //$NON-NLS-1$
191193
extension3.add(command);
192194

193-
if (!extension3.isInTheModel())
195+
if (!extension3.isInTheModel()) {
194196
plugin.add(extension3);
197+
}
195198

196199
IPluginExtension extension4 = createExtension("org.eclipse.ui.menus", true); //$NON-NLS-1$
197200
IPluginElement menuContribution = factory.createElement(extension4);
@@ -282,8 +285,9 @@ protected void updateModel(IProgressMonitor monitor) throws CoreException {
282285
+ "." + getStringOption(KEY_NATURE_ID)); //$NON-NLS-1$
283286
not.add(test2);
284287

285-
if (!extension4.isInTheModel())
288+
if (!extension4.isInTheModel()) {
286289
plugin.add(extension4);
290+
}
287291
}
288292

289293
// Marker
@@ -302,27 +306,31 @@ protected void updateModel(IProgressMonitor monitor) throws CoreException {
302306
persistent.setAttribute("value", "true"); //$NON-NLS-1$ //$NON-NLS-2$
303307
extension8.add(persistent);
304308

305-
if (!extension8.isInTheModel())
309+
if (!extension8.isInTheModel()) {
306310
plugin.add(extension8);
311+
}
307312
}
308313

309314
@Override
310315
public IPluginReference[] getDependencies(String schemaVersion) {
311316
ArrayList<PluginReference> result = new ArrayList<>();
312317
result.add(new PluginReference("org.eclipse.core.resources")); //$NON-NLS-1$
313-
if (schemaVersion != null)
318+
if (schemaVersion != null) {
314319
result.add(new PluginReference("org.eclipse.core.runtime")); //$NON-NLS-1$
315-
if (actionOption.isSelected())
320+
}
321+
if (actionOption.isSelected()) {
316322
result.add(new PluginReference("org.eclipse.ui")); //$NON-NLS-1$
323+
}
317324

318325
return result.toArray(new IPluginReference[result.size()]);
319326
}
320327

321328
@Override
322329
protected String getFormattedPackageName(String id) {
323330
String packageName = super.getFormattedPackageName(id);
324-
if (packageName.length() != 0)
331+
if (packageName.length() != 0) {
325332
return packageName + ".builder"; //$NON-NLS-1$
333+
}
326334
return "builder"; //$NON-NLS-1$
327335
}
328336

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/CommonNavigatorTemplate.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,16 @@ private void createAddToPerspective() throws CoreException {
9191
perspectiveElement.add(view);
9292

9393
perspectiveExtension.add(perspectiveElement);
94-
if (!perspectiveExtension.isInTheModel())
94+
if (!perspectiveExtension.isInTheModel()) {
9595
plugin.add(perspectiveExtension);
96+
}
9697
}
9798

9899
private void createViewer() throws CoreException {
99100
IPluginExtension viewerExtension = createExtension("org.eclipse.ui.navigator.viewer", true); //$NON-NLS-1$
100-
if (!viewerExtension.isInTheModel())
101+
if (!viewerExtension.isInTheModel()) {
101102
plugin.add(viewerExtension);
103+
}
102104

103105
createActionBinding(viewerExtension);
104106
createContentBinding(viewerExtension);
@@ -151,8 +153,9 @@ private void createView() throws CoreException {
151153

152154
viewElement.setAttribute("class", "org.eclipse.ui.navigator.CommonNavigator"); //$NON-NLS-1$ //$NON-NLS-2$
153155
viewExtension.add(viewElement);
154-
if (!viewExtension.isInTheModel())
156+
if (!viewExtension.isInTheModel()) {
155157
plugin.add(viewExtension);
158+
}
156159
}
157160

158161
@Override

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/DecoratorTemplate.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,21 @@ protected void updateModel(IProgressMonitor monitor) throws CoreException {
227227
projectObjectElement.setName("objectClass"); //$NON-NLS-1$
228228
projectObjectElement.setAttribute("name", "org.eclipse.core.resources.IProject"); //$NON-NLS-1$ //$NON-NLS-2$
229229

230-
if (readOnlyOption.isSelected())
230+
if (readOnlyOption.isSelected()) {
231231
orElement.add(folderObjectElement);
232-
else if (projectOption.isSelected())
232+
} else if (projectOption.isSelected()) {
233233
orElement.add(projectObjectElement);
234+
}
234235
orElement.add(fileObjectElement);
235236
andElement.add(resourceObjectElement);
236237
andElement.add(orElement);
237238
enablementElement.add(andElement);
238239
decoratorElement.add(enablementElement);
239240

240241
extension.add(decoratorElement);
241-
if (!extension.isInTheModel())
242+
if (!extension.isInTheModel()) {
242243
plugin.add(extension);
244+
}
243245
}
244246

245247
@Override
@@ -252,8 +254,9 @@ protected String getFormattedPackageName(String id) {
252254
// Package name addition to create a location for containing
253255
// any classes required by the decorator.
254256
String packageName = super.getFormattedPackageName(id);
255-
if (packageName.length() != 0)
257+
if (packageName.length() != 0) {
256258
return packageName + ".decorators"; //$NON-NLS-1$
259+
}
257260
return "decorators"; //$NON-NLS-1$
258261
}
259262

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/EditorTemplate.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,17 @@ protected void updateModel(IProgressMonitor monitor) throws CoreException {
142142
editorElement.setAttribute("contributorClass", //$NON-NLS-1$
143143
"org.eclipse.ui.texteditor.BasicTextEditorActionContributor"); //$NON-NLS-1$
144144
extension.add(editorElement);
145-
if (!extension.isInTheModel())
145+
if (!extension.isInTheModel()) {
146146
plugin.add(extension);
147+
}
147148
}
148149

149150
@Override
150151
protected String getFormattedPackageName(String id) {
151152
String packageName = super.getFormattedPackageName(id);
152-
if (packageName.length() != 0)
153+
if (packageName.length() != 0) {
153154
return packageName + ".editors"; //$NON-NLS-1$
155+
}
154156
return "editors"; //$NON-NLS-1$
155157
}
156158
}

ui/org.eclipse.pde.ui.templates/src/org/eclipse/pde/internal/ui/templates/ide/HelloWorldCmdTemplate.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ public String[] getNewFiles() {
204204
@Override
205205
protected String getFormattedPackageName(String id) {
206206
String packageName = super.getFormattedPackageName(id);
207-
if (packageName.length() != 0)
207+
if (packageName.length() != 0) {
208208
return packageName + ".handlers"; //$NON-NLS-1$
209+
}
209210
return "handlers"; //$NON-NLS-1$
210211
}
211212
}

0 commit comments

Comments
 (0)