Skip to content

Commit fea5a61

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of team/bundles/org.eclipse.team.ui
1 parent 6659005 commit fea5a61

File tree

189 files changed

+2338
-1613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+2338
-1613
lines changed

team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/DefaultUIFileModificationValidator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ public IStatus validateEdit(final IFile[] allFiles, FileModificationValidationCo
137137
}
138138

139139
private Shell getShell(FileModificationValidationContext context) {
140-
if (context.getShell() != null)
140+
if (context.getShell() != null) {
141141
return (Shell)context.getShell();
142+
}
142143
IWorkbench workbench = PlatformUI.getWorkbench();
143144
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
144145
if (window != null) {

team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/Policy.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ public class Policy {
4242
public static ResourceBundle getActionBundle() {
4343
// thread safety
4444
ResourceBundle tmpBundle = actionBundle;
45-
if (tmpBundle != null)
45+
if (tmpBundle != null) {
4646
return tmpBundle;
47+
}
4748
return actionBundle = ResourceBundle.getBundle(ACTION_BUNDLE);
4849
}
4950

@@ -68,16 +69,19 @@ public static void checkCanceled(IProgressMonitor monitor) {
6869
}
6970

7071
public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
71-
if (monitor == null)
72+
if (monitor == null) {
7273
return new NullProgressMonitor();
73-
if (monitor instanceof NullProgressMonitor)
74+
}
75+
if (monitor instanceof NullProgressMonitor) {
7476
return monitor;
77+
}
7578
return SubMonitor.convert(monitor, ticks);
7679
}
7780

7881
public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
79-
if (monitor == null)
82+
if (monitor == null) {
8083
return new NullProgressMonitor();
84+
}
8185
return monitor;
8286
}
8387
}

team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetContentHandler.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,22 @@ public void startElement(String namespaceURI, String localName, String qName, At
4141
isVersionOne = version.equals("1.0"); //$NON-NLS-1$
4242
return;
4343
}
44-
if (isVersionOne) return;
44+
if (isVersionOne) {
45+
return;
46+
}
4547
if (elementName.equals("provider")) { //$NON-NLS-1$
46-
if (!inPsf) throw new SAXException(TeamUIMessages.ProjectSetContentHandler_Element_provider_must_be_contained_in_element_psf_4);
48+
if (!inPsf) {
49+
throw new SAXException(TeamUIMessages.ProjectSetContentHandler_Element_provider_must_be_contained_in_element_psf_4);
50+
}
4751
inProvider = true;
4852
id = atts.getValue("id"); //$NON-NLS-1$
4953
references = new ArrayList<>();
5054
return;
5155
}
5256
if (elementName.equals("project")) { //$NON-NLS-1$
53-
if (!inProvider) throw new SAXException(TeamUIMessages.ProjectSetContentHandler_Element_project_must_be_contained_in_element_provider_7);
57+
if (!inProvider) {
58+
throw new SAXException(TeamUIMessages.ProjectSetContentHandler_Element_project_must_be_contained_in_element_provider_7);
59+
}
5460
inProject = true;
5561
String reference = atts.getValue("reference"); //$NON-NLS-1$
5662
references.add(reference);
@@ -65,7 +71,9 @@ public void endElement(String namespaceURI, String localName, String qName) thro
6571
inPsf = false;
6672
return;
6773
}
68-
if (isVersionOne) return;
74+
if (isVersionOne) {
75+
return;
76+
}
6977
if (elementName.equals("provider")) { //$NON-NLS-1$
7078
map.put(id, references);
7179
references = null;

team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ProjectSetImporter.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ private static IProject[] importProjectSet(XMLMemento xmlMemento,
9898
IProjectSetSerializer serializer = Team.getProjectSetSerializer("versionOneSerializer"); //$NON-NLS-1$
9999
if (serializer != null) {
100100
IProject[] projects = serializer.addToWorkspace(new String[0], filename, shell, monitor);
101-
if (projects != null)
101+
if (projects != null) {
102102
newProjects.addAll(Arrays.asList(projects));
103+
}
103104
}
104105
} else {
105106
UIProjectSetSerializationContext context = new UIProjectSetSerializationContext(shell, filename);
@@ -128,8 +129,9 @@ private static IProject[] importProjectSet(XMLMemento xmlMemento,
128129
ProjectSetCapability.ensureBackwardsCompatible(providerType, serializer);
129130
if (serializer != null) {
130131
IProject[] allProjects = serializer.addToWorkspace(referenceStrings.toArray(new String[referenceStrings.size()]), context, monitor);
131-
if (allProjects != null)
132+
if (allProjects != null) {
132133
newProjects.addAll(Arrays.asList(allProjects));
134+
}
133135
}
134136
} catch (TeamException e) {
135137
errors.add(e);
@@ -269,8 +271,9 @@ private static void mergeWorkingSets(IWorkingSet newWs, IWorkingSet oldWs) {
269271
}
270272

271273
private static void replaceWorkingSet(IWorkingSetManager wsManager, IWorkingSet newWs, IWorkingSet oldWs) {
272-
if (oldWs != null)
274+
if (oldWs != null) {
273275
wsManager.removeWorkingSet(oldWs);
276+
}
274277
wsManager.addWorkingSet(newWs);
275278
}
276279

team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/SWTUtils.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ public static Group createHFillGroup(Composite parent, String text, int margins,
152152
final Group group= new Group(parent, SWT.NONE);
153153
group.setFont(parent.getFont());
154154
group.setLayoutData(createHFillGridData());
155-
if (text != null)
155+
if (text != null) {
156156
group.setText(text);
157+
}
157158
group.setLayout(createGridLayout(rows, new PixelConverter(parent), margins));
158159
return group;
159160
}
@@ -166,8 +167,9 @@ public static Group createHVFillGroup(Composite parent, String text, int margins
166167
final Group group= new Group(parent, SWT.NONE);
167168
group.setFont(parent.getFont());
168169
group.setLayoutData(createHVFillGridData());
169-
if (text != null)
170+
if (text != null) {
170171
group.setText(text);
172+
}
171173
group.setLayout(createGridLayout(rows, new PixelConverter(parent), margins));
172174
return group;
173175
}
@@ -233,8 +235,9 @@ public static Label createLabel(Composite parent, String message) {
233235

234236
public static Label createLabel(Composite parent, String message, int span) {
235237
final Label label= new Label(parent, SWT.WRAP);
236-
if (message != null)
238+
if (message != null) {
237239
label.setText(message);
240+
}
238241
label.setLayoutData(createHFillGridData(span));
239242
return label;
240243
}
@@ -301,8 +304,9 @@ public static int calculateControlSize(PixelConverter converter, Control [] cont
301304
int minimum= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
302305
for (int i = start; i <= end; i++) {
303306
final int length= controls[i].computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
304-
if (minimum < length)
307+
if (minimum < length) {
305308
minimum= length;
309+
}
306310
}
307311
return minimum;
308312
}
@@ -325,8 +329,9 @@ public static int getWidthInCharsForLongest(PixelConverter converter, String []
325329
int minimum= 0;
326330
for (String string : strings) {
327331
final int length = converter.convertWidthInCharsToPixels(string.length());
328-
if (minimum < length)
332+
if (minimum < length) {
329333
minimum= length;
334+
}
330335
}
331336
return minimum;
332337
}

team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/StorageTypedElement.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,22 @@ public String getType() {
8787
String name = getName();
8888
if (name != null) {
8989
int index = name.lastIndexOf('.');
90-
if (index == -1)
90+
if (index == -1) {
9191
return ""; //$NON-NLS-1$
92-
if (index == (name.length() - 1))
92+
}
93+
if (index == (name.length() - 1)) {
9394
return ""; //$NON-NLS-1$
95+
}
9496
return name.substring(index + 1);
9597
}
9698
return ITypedElement.FOLDER_TYPE;
9799
}
98100

99101
@Override
100102
public String getCharset() throws CoreException {
101-
if (localEncoding != null)
103+
if (localEncoding != null) {
102104
return localEncoding;
105+
}
103106
if (bufferedContents == null) {
104107
cacheContents(new NullProgressMonitor());
105108
}
@@ -114,7 +117,7 @@ public String getCharset() throws CoreException {
114117
public <T> T getAdapter(Class<T> adapter) {
115118
if (adapter == ISharedDocumentAdapter.class) {
116119
synchronized (this) {
117-
if (sharedDocumentAdapter == null)
120+
if (sharedDocumentAdapter == null) {
118121
sharedDocumentAdapter = new SharedDocumentAdapter() {
119122
@Override
120123
public IEditorInput getDocumentKey(Object element) {
@@ -128,6 +131,7 @@ public void flushDocument(IDocumentProvider provider,
128131
// The document is read-only
129132
}
130133
};
134+
}
131135
return (T) sharedDocumentAdapter;
132136
}
133137
}

team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamAdapterFactory.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
4848
if(adaptableObject instanceof DiffNode && adapterType == IWorkbenchAdapter.class) {
4949
return (T) diffNodeAdapter;
5050
}
51-
if (adaptableObject instanceof ModelProvider) {
52-
ModelProvider provider = (ModelProvider) adaptableObject;
51+
if (adaptableObject instanceof ModelProvider provider) {
5352
if (provider.getDescriptor().getId().equals(ModelProvider.RESOURCE_MODEL_PROVIDER_ID)) {
5453
if (adapterType == IResourceMappingMerger.class) {
5554
return (T) new DefaultResourceMappingMerger((ModelProvider)adaptableObject);
@@ -62,8 +61,7 @@ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
6261
if (adaptableObject instanceof ModelProvider && adapterType == ISynchronizationCompareAdapter.class) {
6362
return (T) COMPARE_ADAPTER;
6463
}
65-
if (adaptableObject instanceof RepositoryProviderType && adapterType == ITeamStateProvider.class) {
66-
RepositoryProviderType rpt = (RepositoryProviderType) adaptableObject;
64+
if (adaptableObject instanceof RepositoryProviderType rpt && adapterType == ITeamStateProvider.class) {
6765
return (T) TeamUIPlugin.getPlugin().getDecoratedStateProvider(rpt);
6866
}
6967

team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamCapabilityHelper.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ public String getPluginId() {
125125
* @param workbenchActivitySupport the activity support
126126
*/
127127
protected void processProject(IProject project, IWorkbenchActivitySupport workbenchActivitySupport) throws CoreException {
128-
if (!project.isOpen())
128+
if (!project.isOpen()) {
129129
return;
130+
}
130131
String id = getProviderIdFor(project);
131132
processRepositoryId(id, workbenchActivitySupport);
132133
}
@@ -138,23 +139,26 @@ protected void processProject(IProject project, IWorkbenchActivitySupport workbe
138139
* @param workbenchActivitySupport the activity support
139140
*/
140141
public void processRepositoryId(String id, IWorkbenchActivitySupport workbenchActivitySupport) {
141-
if (id == null)
142+
if (id == null) {
142143
return;
144+
}
143145
IActivityManager activityManager = workbenchActivitySupport
144146
.getActivityManager();
145147
Set<String> activities = new HashSet<>(activityManager.getEnabledActivityIds());
146148
boolean changed = false;
147149

148150
IPluginContribution contribution = providerIdToPluginId.get(id);
149-
if (contribution == null)
151+
if (contribution == null) {
150152
return; //bad provider ID.
153+
}
151154
IIdentifier identifier = activityManager.getIdentifier(WorkbenchActivityHelper.createUnifiedId(contribution));
152155
if (activities.addAll(identifier.getActivityIds())) {
153156
changed = true;
154157
}
155158

156-
if (changed)
159+
if (changed) {
157160
workbenchActivitySupport.setEnabledActivityIds(activities);
161+
}
158162
}
159163

160164
/**
@@ -170,8 +174,7 @@ public String getProviderIdFor(IProject project) throws CoreException {
170174
if(project.isAccessible()) {
171175
//First, look for the session property
172176
Object prop = project.getSessionProperty(TeamPlugin.PROVIDER_PROP_KEY);
173-
if(prop != null && prop instanceof RepositoryProvider) {
174-
RepositoryProvider provider = (RepositoryProvider) prop;
177+
if(prop != null && prop instanceof RepositoryProvider provider) {
175178
return provider.getID();
176179
}
177180
//Next, check if it has the ID as a persistent property

team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIPlugin.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,11 @@ public static Object createExtension(final IConfigurationElement element, final
134134
exc[0] = e;
135135
}
136136
});
137-
if (exc[0] != null)
137+
if (exc[0] != null) {
138138
throw exc[0];
139-
else
139+
} else {
140140
return ret[0];
141+
}
141142
}
142143
}
143144

@@ -151,7 +152,9 @@ public static Object createExtension(final IConfigurationElement element, final
151152
*/
152153
public static IWorkbenchPage getActivePage() {
153154
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
154-
if (window == null) return null;
155+
if (window == null) {
156+
return null;
157+
}
155158
return window.getActivePage();
156159
}
157160

@@ -247,8 +250,9 @@ public void stop(BundleContext context) throws Exception {
247250
debugRegistration.unregister();
248251
debugRegistration = null;
249252

250-
if (synchronizeManager != null)
253+
if (synchronizeManager != null) {
251254
synchronizeManager.dispose();
255+
}
252256
} finally {
253257
super.stop(context);
254258
}
@@ -454,8 +458,9 @@ public org.osgi.service.prefs.Preferences getInstancePreferences() {
454458

455459
public synchronized TeamStateProvider getDecoratedStateProvider(RepositoryProviderType rpt) {
456460
TeamStateProvider provider = decoratedStateProviders.get(rpt.getID());
457-
if (provider != null)
461+
if (provider != null) {
458462
return provider;
463+
}
459464
Subscriber subscriber = rpt.getSubscriber();
460465
if (subscriber != null) {
461466
provider = new SubscriberTeamStateProvider(subscriber);
@@ -472,8 +477,9 @@ public synchronized TeamStateProvider getDecoratedStateProvider(RepositoryProvid
472477
* provider
473478
*/
474479
public synchronized ITeamStateProvider getDecoratedStateProvider() {
475-
if (provider == null)
480+
if (provider == null) {
476481
provider = new WorkspaceTeamStateProvider();
482+
}
477483
return provider;
478484
}
479485

team/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/UIProjectSetSerializationContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ public IProject[] confirmOverwrite(final IProject[] projects) throws TeamExcepti
8989
List resources = Arrays.asList(projects);
9090
@Override
9191
public boolean needsPrompt(IResource resource) {
92-
if (resource instanceof IProject) {
93-
IProject project = (IProject) resource;
92+
if (resource instanceof IProject project) {
9493
return (project.exists() || getTargetFile(project).exists()) && resources.contains(resource);
9594
}
9695
return false;
9796
}
9897
@Override
9998
public String promptMessage(IResource resource) {
100-
if (resource.exists())
99+
if (resource.exists()) {
101100
return NLS.bind(TeamUIMessages.UIProjectSetSerializationContext_0, resource.getName());
101+
}
102102
return NLS.bind(TeamUIMessages.UIProjectSetSerializationContext_2, resource.getName(),
103103
getTargetFile((IProject) resource).getAbsolutePath());
104104
}

0 commit comments

Comments
 (0)