Skip to content

Commit 0900d26

Browse files
eclipse-pde-botakurtakov
authored andcommitted
Perform clean code of ui/org.eclipse.pde.bnd.ui
1 parent 0c9792f commit 0900d26

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/model/repo/RepositoryTreeContentProvider.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ public boolean isShowRepos() {
117117
@SuppressWarnings("unchecked")
118118
public Object[] getElements(Object inputElement) {
119119
Collection<Object> result;
120-
if (inputElement instanceof Workspace) {
120+
if (inputElement instanceof Workspace workspace) {
121121
result = new ArrayList<>();
122-
Workspace workspace = (Workspace) inputElement;
123122
addRepositoryPlugins(result, workspace);
124123
} else if (inputElement instanceof Collection) {
125124
result = new ArrayList<>();

ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/model/repo/RepositoryTreeLabelProvider.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ public void update(ViewerCell cell) {
5353
StyledString label = new StyledString();
5454
Image image = null;
5555
try {
56-
if (element instanceof RepositoryPlugin) {
56+
if (element instanceof RepositoryPlugin repo) {
5757
if (index == 0) {
58-
RepositoryPlugin repo = (RepositoryPlugin) element;
5958
String status = repo.getStatus();
6059
String name = null;
6160
if (repo instanceof Actionable) {
@@ -72,10 +71,8 @@ public void update(ViewerCell cell) {
7271
}
7372
image = Resources.getImage(repo.getIcon());
7473
}
75-
} else if (element instanceof Project) {
74+
} else if (element instanceof Project project) {
7675
if (index == 0) {
77-
@SuppressWarnings("resource")
78-
Project project = (Project) element;
7976
boolean isOk = project.isOk();
8077

8178
label.append(project.getName());
@@ -93,10 +90,8 @@ public void update(ViewerCell cell) {
9390

9491
image = projectImg;
9592
}
96-
} else if (element instanceof ProjectBundle) {
93+
} else if (element instanceof ProjectBundle projectBundle) {
9794
if (index == 0) {
98-
ProjectBundle projectBundle = (ProjectBundle) element;
99-
10095
label.append(projectBundle.getBsn());
10196
if (showRepoId) {
10297
label.append(" ");
@@ -109,9 +104,8 @@ public void update(ViewerCell cell) {
109104
}
110105
image = bundleImg;
111106
}
112-
} else if (element instanceof RepositoryBundle) {
107+
} else if (element instanceof RepositoryBundle bundle) {
113108
if (index == 0) {
114-
RepositoryBundle bundle = (RepositoryBundle) element;
115109
label.append(bundle.getText());
116110
if (showRepoId) {
117111
label.append(" ");
@@ -120,9 +114,8 @@ public void update(ViewerCell cell) {
120114
}
121115
image = bundleImg;
122116
}
123-
} else if (element instanceof RepositoryBundleVersion) {
117+
} else if (element instanceof RepositoryBundleVersion bundleVersion) {
124118
if (index == 0) {
125-
RepositoryBundleVersion bundleVersion = (RepositoryBundleVersion) element;
126119
String versionText = bundleVersion.getText();
127120

128121
if (versionText.contains(" \u21E9")) {

ui/org.eclipse.pde.bnd.ui/src/org/eclipse/pde/bnd/ui/views/repository/RepositoriesView.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,10 @@ public boolean performDrop(Object data) {
396396
final Object element = selection.getFirstElement();
397397
if (element instanceof IAdaptable) {
398398
final URI uri = ((IAdaptable) element).getAdapter(URI.class);
399-
if (uri == null && element instanceof RepositoryEntry) {
399+
if (uri == null && element instanceof final RepositoryEntry entry) {
400400
boolean download = MessageDialog.openQuestion(getSite().getShell(), "Repositories",
401401
"This repository entry is unable to be opened because it has not been downloaded. Download and open it now?");
402402
if (download) {
403-
final RepositoryEntry entry = (RepositoryEntry) element;
404403
Job downloadJob = new Job("Downloading repository entry " + entry.getBsn()) {
405404
@Override
406405
protected IStatus run(IProgressMonitor monitor) {
@@ -833,7 +832,7 @@ void createContextMenu() {
833832
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
834833
if (!selection.isEmpty()) {
835834
final Object firstElement = selection.getFirstElement();
836-
if (firstElement instanceof Actionable) {
835+
if (firstElement instanceof final Actionable act) {
837836

838837
final RepositoryPlugin rp = getRepositoryPlugin(firstElement);
839838

@@ -842,8 +841,6 @@ void createContextMenu() {
842841
// Should extend this to allow other menu entries
843842
// from the view, but currently there are none
844843
//
845-
final Actionable act = (Actionable) firstElement;
846-
847844
// use HierarchicalMenu to build up a menue with SubMenu
848845
// entries
849846
HierarchicalMenu hmenu = new HierarchicalMenu();

0 commit comments

Comments
 (0)