Skip to content

Commit 0605d3e

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of ua/org.eclipse.ui.intro.universal
1 parent e5db590 commit 0605d3e

File tree

12 files changed

+300
-177
lines changed

12 files changed

+300
-177
lines changed

ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/CustomizationContentsArea.java

Lines changed: 92 additions & 61 deletions
Large diffs are not rendered by default.

ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/ExtensionData.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ public String toString() {
131131
public void write(PrintWriter writer, String indent) {
132132
writer.print(indent);
133133
writer.print("<extension id=\"" + id + "\""); //$NON-NLS-1$ //$NON-NLS-2$
134-
if (!isHidden())
134+
if (!isHidden()) {
135135
writer
136136
.println(" importance=\"" + getImportanceAttributeValue() + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
137-
else
137+
} else {
138138
writer.println("/>"); //$NON-NLS-1$
139+
}
139140
}
140141
}

ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/ExtensionDataTransfer.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public void javaToNative(Object object, TransferData transferData) {
5959
byte[] buffer = bd.getId().getBytes();
6060
writeOut.writeInt(bd.getId().length());
6161
writeOut.write(buffer);
62-
if (bd instanceof ExtensionData) {
63-
ExtensionData ed = (ExtensionData)bd;
62+
if (bd instanceof ExtensionData ed) {
6463
writeOut.writeInt(ed.getName().length());
6564
buffer = ed.getName().getBytes();
6665
writeOut.write(buffer);
@@ -77,8 +76,9 @@ public void javaToNative(Object object, TransferData transferData) {
7776
public Object nativeToJava(TransferData transferData) {
7877
if (isSupportedType(transferData)) {
7978
byte[] buffer = (byte[]) super.nativeToJava(transferData);
80-
if (buffer == null)
79+
if (buffer == null) {
8180
return null;
81+
}
8282

8383
BaseData[] myData = new BaseData[0];
8484
ByteArrayInputStream in = new ByteArrayInputStream(buffer);
@@ -103,10 +103,11 @@ public Object nativeToJava(TransferData transferData) {
103103

104104
BaseData[] newMyData = new BaseData[myData.length + 1];
105105
System.arraycopy(myData, 0, newMyData, 0, myData.length);
106-
if (separator)
106+
if (separator) {
107107
newMyData[myData.length] = new SeparatorData(id);
108-
else
108+
} else {
109109
newMyData[myData.length] = new ExtensionData(id, name, importance);
110+
}
110111
myData = newMyData;
111112
}
112113
} catch (IOException ex) {
@@ -120,13 +121,13 @@ public Object nativeToJava(TransferData transferData) {
120121

121122

122123
boolean checkMyType(Object object) {
123-
if (object == null || !(object instanceof BaseData[]) || ((BaseData[]) object).length == 0) {
124+
if (object == null || !(object instanceof BaseData[] myTypes) || myTypes.length == 0) {
124125
return false;
125126
}
126-
BaseData[] myTypes = (BaseData[]) object;
127127
for (BaseData myType : myTypes) {
128-
if (myType == null || myType.getId() == null || myType instanceof ExtensionData && ((ExtensionData)myType).getName() == null)
128+
if (myType == null || myType.getId() == null || myType instanceof ExtensionData && ((ExtensionData)myType).getName() == null) {
129129
return false;
130+
}
130131
}
131132
return true;
132133
}

ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/GroupData.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ public GroupData(String path, boolean defaultGroup) {
3434
}
3535

3636
public GroupData(Element element) {
37-
if (element.getNodeName().equals("hidden")) //$NON-NLS-1$
37+
if (element.getNodeName().equals("hidden")) { //$NON-NLS-1$
3838
path = IUniversalIntroConstants.HIDDEN;
39-
else
39+
} else {
4040
path = element.getAttribute("path"); //$NON-NLS-1$
41+
}
4142
NodeList children = element.getChildNodes();
4243
for (int i = 0; i < children.getLength(); i++) {
4344
Node child = children.item(i);
@@ -51,8 +52,9 @@ else if (child.getNodeName().equals("separator")) {//$NON-NLS-1$"
5152
}
5253
}
5354
String df = element.getAttribute("default"); //$NON-NLS-1$
54-
if (df!=null && df.equalsIgnoreCase("true")) //$NON-NLS-1$
55+
if (df!=null && df.equalsIgnoreCase("true")) { //$NON-NLS-1$
5556
fDefault = true;
57+
}
5658
}
5759

5860
public boolean isHidden() {
@@ -69,8 +71,9 @@ public void addAnchors(List<IntroElement> result) {
6971
String id = edata.getId();
7072
IntroElement element = null;
7173
String tagName="anchor"; //$NON-NLS-1$
72-
if (edata instanceof SeparatorData)
74+
if (edata instanceof SeparatorData) {
7375
tagName = "hr"; //$NON-NLS-1$
76+
}
7477
element = new IntroElement(tagName);
7578
element.setAttribute("id", id); //$NON-NLS-1$
7679
result.add(element);
@@ -117,8 +120,9 @@ public int getExtensionCount() {
117120
int count=0;
118121
for (int i=0; i<children.size(); i++) {
119122
BaseData data = children.get(i);
120-
if (data instanceof ExtensionData)
123+
if (data instanceof ExtensionData) {
121124
count++;
125+
}
122126
}
123127
return count;
124128
}
@@ -145,8 +149,9 @@ public boolean contains(String id) {
145149
BaseData find(String extensionId) {
146150
for (int i = 0; i < children.size(); i++) {
147151
BaseData data = children.get(i);
148-
if (data.getId().equals(extensionId))
152+
if (data.getId().equals(extensionId)) {
149153
return data;
154+
}
150155
}
151156
return null;
152157
}
@@ -158,8 +163,9 @@ public int getIndexOf(BaseData ed) {
158163
public int getIndexOf(String baseId) {
159164
for (int i = 0; i < children.size(); i++) {
160165
BaseData bd = children.get(i);
161-
if (bd.getId().equals(baseId))
166+
if (bd.getId().equals(baseId)) {
162167
return i;
168+
}
163169
}
164170
return -1;
165171
}
@@ -203,23 +209,25 @@ public void addSeparator(BaseData after) {
203209

204210
public void write(PrintWriter writer, String indent) {
205211
writer.print(indent);
206-
if (isHidden())
212+
if (isHidden()) {
207213
writer.print("<hidden>"); //$NON-NLS-1$
208-
else {
214+
} else {
209215
writer.print("<group path=\""+path+"\""); //$NON-NLS-1$ //$NON-NLS-2$
210-
if (fDefault)
216+
if (fDefault) {
211217
writer.println(" default=\"true\">"); //$NON-NLS-1$
212-
else
218+
} else {
213219
writer.println(">"); //$NON-NLS-1$
220+
}
214221
}
215222
for (int i=0; i<children.size(); i++) {
216223
BaseData ed = children.get(i);
217224
ed.write(writer, indent+" "); //$NON-NLS-1$
218225
}
219226
writer.print(indent);
220-
if (isHidden())
227+
if (isHidden()) {
221228
writer.println("</hidden>"); //$NON-NLS-1$
222-
else
229+
} else {
223230
writer.println("</group>"); //$NON-NLS-1$
231+
}
224232
}
225233
}

ua/org.eclipse.ui.intro.universal/src/org/eclipse/ui/internal/intro/universal/IntroData.java

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ public class IntroData {
4646
public IntroData(String productId, String fileNameOrData, boolean active) {
4747
this.productId = productId;
4848
this.active = active;
49-
if (fileNameOrData!=null)
49+
if (fileNameOrData!=null) {
5050
initialize(fileNameOrData);
51+
}
5152
}
5253

5354
public String getProductId() {
@@ -64,8 +65,9 @@ public boolean isActive() {
6465

6566
private void initialize(String fileNameOrData) {
6667
Document doc = parse(fileNameOrData);
67-
if (doc == null)
68+
if (doc == null) {
6869
return;
70+
}
6971
Element root = doc.getDocumentElement();
7072
NodeList pages = root.getChildNodes();
7173
for (int i = 0; i < pages.getLength(); i++) {
@@ -96,19 +98,22 @@ public void addImplicitContent() {
9698

9799
private void addCandidate(IConfigurationElement element) {
98100
String fileName = element.getAttribute("content"); //$NON-NLS-1$
99-
if (fileName==null)
101+
if (fileName==null) {
100102
return;
103+
}
101104
String bundleId = element.getDeclaringExtension().getContributor().getName();
102105
Bundle bundle = Platform.getBundle(bundleId);
103-
if (bundle==null)
106+
if (bundle==null) {
104107
return;
108+
}
105109
String content = BundleUtil.getResolvedResourceLocation("", fileName, //$NON-NLS-1$
106110
bundle);
107111
IntroContentParser parser = new IntroContentParser(content);
108112
Document dom = parser.getDocument();
109113
// dom can be null if the content file cannot be found
110-
if (dom==null)
114+
if (dom==null) {
111115
return;
116+
}
112117
Element root = dom.getDocumentElement();
113118
Element extension = null;
114119
NodeList children = root.getChildNodes();
@@ -122,18 +127,22 @@ private void addCandidate(IConfigurationElement element) {
122127
}
123128
}
124129
}
125-
if (extension==null)
130+
if (extension==null) {
126131
return;
132+
}
127133
String id = extension.getAttribute("id"); //$NON-NLS-1$
128134
String name = extension.getAttribute("name"); //$NON-NLS-1$
129135
String path = extension.getAttribute("path"); //$NON-NLS-1$
130-
if (id==null || path==null)
136+
if (id==null || path==null) {
131137
return;
138+
}
132139
int at = path.lastIndexOf("/@"); //$NON-NLS-1$
133-
if (at == -1)
140+
if (at == -1) {
134141
return;
135-
if (path.charAt(path.length()-1)!='@')
142+
}
143+
if (path.charAt(path.length()-1)!='@') {
136144
return;
145+
}
137146
String pageId = path.substring(0, at);
138147
PageData pd = pages.get(pageId);
139148
if (pd==null) {
@@ -157,9 +166,9 @@ private Document parse(String fileNameOrData) {
157166
//This is actual content, not the file name
158167
StringReader reader = new StringReader(fileNameOrData);
159168
document = parser.parse(new InputSource(reader));
160-
}
161-
else
169+
} else {
162170
document = parser.parse(fileNameOrData);
171+
}
163172
return document;
164173

165174
} catch (SAXParseException spe) {
@@ -172,14 +181,16 @@ private Document parse(String fileNameOrData) {
172181

173182
// Use the contained exception.
174183
Exception x = spe;
175-
if (spe.getException() != null)
184+
if (spe.getException() != null) {
176185
x = spe.getException();
186+
}
177187
Log.error(buffer.toString(), x);
178188

179189
} catch (SAXException sxe) {
180190
Exception x = sxe;
181-
if (sxe.getException() != null)
191+
if (sxe.getException() != null) {
182192
x = sxe.getException();
193+
}
183194
Log.error(x.getMessage(), x);
184195

185196
} catch (ParserConfigurationException pce) {

0 commit comments

Comments
 (0)