Skip to content

Commit 770e615

Browse files
EcljpseB0Tjukzi
authored andcommitted
BndTools: fix warnings
mostly 'Non-externalized string literal' warning
1 parent eb34cab commit 770e615

11 files changed

+92
-55
lines changed

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/bndtools/BndTargetLocation.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,29 @@
5252

5353
public abstract class BndTargetLocation extends AbstractBundleContainer
5454
implements ITargetLocationHandler, ILabelProvider {
55-
static final String PLUGIN_ID = "bndtools.pde";
55+
static final String PLUGIN_ID = "bndtools.pde"; //$NON-NLS-1$
5656

57-
static final String MESSAGE_UNABLE_TO_LOCATE_WORKSPACE = "Unable to locate the Bnd workspace";
58-
static final String MESSAGE_UNABLE_TO_RESOLVE_BUNDLES = "Unable to resolve bundles";
57+
static final String MESSAGE_UNABLE_TO_LOCATE_WORKSPACE = "Unable to locate the Bnd workspace"; //$NON-NLS-1$
58+
static final String MESSAGE_UNABLE_TO_RESOLVE_BUNDLES = "Unable to resolve bundles"; //$NON-NLS-1$
5959

60-
static final String ELEMENT_LOCATION = "location";
61-
static final String ATTRIBUTE_LOCATION_TYPE = "type";
60+
static final String ELEMENT_LOCATION = "location"; //$NON-NLS-1$
61+
static final String ATTRIBUTE_LOCATION_TYPE = "type"; //$NON-NLS-1$
6262

6363
private final String type;
6464
private final Image containerIcon;
6565

6666
public BndTargetLocation(String type, String containerIconName) {
6767
this.type = Objects.requireNonNull(type);
68-
this.containerIcon = PDEPluginImages.get("/icons/bndtools/" + containerIconName);
68+
this.containerIcon = PDEPluginImages.get("/icons/bndtools/" + containerIconName); //$NON-NLS-1$
6969
}
7070

7171
@SuppressWarnings("unchecked")
7272
@Override
7373
public <T> T getAdapter(Class<T> adapter) {
7474
if (adapter == ILabelProvider.class) {
7575
return (T) this;
76-
77-
} else {
78-
return super.getAdapter(adapter);
7976
}
77+
return super.getAdapter(adapter);
8078
}
8179

8280

@@ -146,7 +144,7 @@ public String serialize() {
146144
Transformer transformer = org.eclipse.core.internal.runtime.XmlProcessorFactory
147145
.createTransformerFactoryWithErrorOnDOCTYPE()
148146
.newTransformer();
149-
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
147+
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
150148
transformer.transform(new DOMSource(document), result);
151149
return result.getWriter()
152150
.toString();

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/bndtools/BndTargetLocationFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,19 @@ public ITargetLocation getTargetLocation(String type, String serializedXML) thro
4040
if (this.type.equals(type)) {
4141
Element locationElement;
4242
try {
43+
@SuppressWarnings("restriction")
4344
DocumentBuilder docBuilder = org.eclipse.core.internal.runtime.XmlProcessorFactory
4445
.createDocumentBuilderFactoryIgnoringDOCTYPE()
4546
.newDocumentBuilder();
46-
Document document = docBuilder.parse(new ByteArrayInputStream(serializedXML.getBytes("UTF-8")));
47+
Document document = docBuilder.parse(new ByteArrayInputStream(serializedXML.getBytes("UTF-8"))); //$NON-NLS-1$
4748
locationElement = document.getDocumentElement();
4849

4950
if (this.type.equals(locationElement.getAttribute(BndTargetLocation.ATTRIBUTE_LOCATION_TYPE))) {
5051
return getTargetLocation(locationElement);
5152
}
5253
} catch (Exception e) {
5354
ILog.get()
54-
.error("Problem reading target location " + type);
55+
.error("Problem reading target location " + type); //$NON-NLS-1$
5556
return null;
5657
}
5758
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/bndtools/BndTargetLocationPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
public abstract class BndTargetLocationPage extends WizardPage implements IEditBundleContainerPage {
3737
private final String message;
3838
private final ITargetDefinition targetDefinition;
39-
private static final Image bundleIcon = PDEPluginImages.get("/icons/bndtools/bundle.png");
39+
private static final Image bundleIcon = PDEPluginImages.get("/icons/bndtools/bundle.png"); //$NON-NLS-1$
4040

4141
public BndTargetLocationPage(String pageName, String title, String message, ITargetDefinition targetDefinition) {
4242
super(pageName);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.eclipse.pde.internal.ui.bndtools;
2+
3+
import org.eclipse.osgi.util.NLS;
4+
5+
public class BndToolsMessages extends NLS {
6+
private static final String BUNDLE_NAME = BndToolsMessages.class.getPackageName() + ".messages"; //$NON-NLS-1$
7+
public static String RepositoryTargetLocationPage_AddBndRepository;
8+
public static String RepositoryTargetLocationPage_AddBndRepositoryContainer;
9+
public static String RepositoryTargetLocationPage_Contents;
10+
public static String RepositoryTargetLocationPage_Location;
11+
public static String RepositoryTargetLocationPage_Repository;
12+
public static String RepositoryTargetLocationPage_ToBeAdded;
13+
public static String RepositoryTargetLocationWizard_BndRepositoryTargetLocation;
14+
public static String RunDescriptorTargetLocationPage_AddBndRunDescriptor;
15+
public static String RunDescriptorTargetLocationPage_AddBndRunDescriptorContainer;
16+
public static String RunDescriptorTargetLocationPage_RunBundles;
17+
public static String RunDescriptorTargetLocationPage_RunDescriptor;
18+
public static String RunDescriptorTargetLocationPage_Select;
19+
static {
20+
// initialize resource bundle
21+
NLS.initializeMessages(BUNDLE_NAME, BndToolsMessages.class);
22+
}
23+
24+
private BndToolsMessages() {
25+
}
26+
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/bndtools/RepositoryTargetLocation.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@
4141
import aQute.bnd.version.Version;
4242

4343
public class RepositoryTargetLocation extends BndTargetLocation {
44-
static final String TYPE = "BndRepositoryLocation";
44+
static final String TYPE = "BndRepositoryLocation"; //$NON-NLS-1$
4545

46-
static final String MESSAGE_UNABLE_TO_RESOLVE_REPOSITORIES = "Unable to resolve Bnd repository plugins";
46+
static final String MESSAGE_UNABLE_TO_RESOLVE_REPOSITORIES = "Unable to resolve Bnd repository plugins"; //$NON-NLS-1$
4747

48-
static final String ELEMENT_REPOSITORY = "repository";
49-
static final String ATTRIBUTE_REPOSITORY_NAME = "name";
48+
static final String ELEMENT_REPOSITORY = "repository"; //$NON-NLS-1$
49+
static final String ATTRIBUTE_REPOSITORY_NAME = "name"; //$NON-NLS-1$
5050

5151
private String repositoryName;
5252
private RepositoryPlugin repository;
5353

5454
public RepositoryTargetLocation() {
55-
super(TYPE, "database.png");
55+
super(TYPE, "database.png"); //$NON-NLS-1$
5656
}
5757

5858
public RepositoryTargetLocation setRepository(String repositoryName) {
@@ -95,12 +95,12 @@ protected TargetBundle[] resolveBundles(ITargetDefinition definition, IProgressM
9595
try {
9696
List<TargetBundle> bundles = new ArrayList<>();
9797

98-
List<String> bsns = repository.list("*");
99-
monitor.beginTask("Resolving Bundles", bsns.size());
98+
List<String> bsns = repository.list("*"); //$NON-NLS-1$
99+
monitor.beginTask("Resolving Bundles", bsns.size()); //$NON-NLS-1$
100100

101101
int i = 0;
102102
for (String bsn : bsns) {
103-
if (bsn.contains(":")) {
103+
if (bsn.contains(":")) { //$NON-NLS-1$
104104
continue;
105105
}
106106
Version version = repository.versions(bsn)
@@ -111,7 +111,7 @@ protected TargetBundle[] resolveBundles(ITargetDefinition definition, IProgressM
111111
bundles.add(new TargetBundle(download));
112112
} catch (Exception e) {
113113
throw new CoreException(new Status(IStatus.WARNING, PLUGIN_ID,
114-
"Invalid plugin in repository: " + bsn + " @ " + getLocation(false), e));
114+
"Invalid plugin in repository: " + bsn + " @ " + getLocation(false), e)); //$NON-NLS-1$ //$NON-NLS-2$
115115
}
116116

117117
if (monitor.isCanceled())
@@ -152,14 +152,14 @@ private void resolveRepository() throws CoreException {
152152

153153
if (this.repository == null)
154154
throw new CoreException(
155-
new Status(IStatus.ERROR, PLUGIN_ID, "Unable to locate the named repository: " + repositoryName));
155+
new Status(IStatus.ERROR, PLUGIN_ID, "Unable to locate the named repository: " + repositoryName)); //$NON-NLS-1$
156156
}
157157

158158
@Override
159159
public String getLocation(boolean resolve) throws CoreException {
160160
if (resolve)
161161
resolveRepository();
162-
return repository != null ? repository.getLocation() : "";
162+
return repository != null ? repository.getLocation() : ""; //$NON-NLS-1$
163163
}
164164

165165
@Override
@@ -188,7 +188,7 @@ public ITargetLocation getTargetLocation(Element locationElement) throws CoreExc
188188
}
189189
}
190190

191-
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "No repository name specified"));
191+
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "No repository name specified")); //$NON-NLS-1$
192192
}
193193
}
194194

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/bndtools/RepositoryTargetLocationPage.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import aQute.bnd.service.ResolutionPhase;
3939

4040
public class RepositoryTargetLocationPage extends BndTargetLocationPage {
41-
private static final String CACHE_REPOSITORY = "cache";
41+
private static final String CACHE_REPOSITORY = "cache"; //$NON-NLS-1$
4242

4343
private RepositoryTargetLocation targetLocation;
4444

@@ -49,7 +49,7 @@ public class RepositoryTargetLocationPage extends BndTargetLocationPage {
4949
private Text pluginLocationText;
5050

5151
public RepositoryTargetLocationPage(ITargetDefinition targetDefinition, RepositoryTargetLocation targetLocation) {
52-
super("AddBndRepositoryContainer", "Add Bnd Repository", "Select a Bnd repository to be added to your target",
52+
super(BndToolsMessages.RepositoryTargetLocationPage_AddBndRepositoryContainer, BndToolsMessages.RepositoryTargetLocationPage_AddBndRepository, BndToolsMessages.RepositoryTargetLocationPage_ToBeAdded,
5353
targetDefinition);
5454

5555
if (targetLocation != null) {
@@ -88,15 +88,15 @@ public RepositoryTargetLocationPage(ITargetDefinition targetDefinition, Reposito
8888
}
8989

9090
private String getLocation() {
91-
return repository != null ? repository.getLocation() : "";
91+
return repository != null ? repository.getLocation() : ""; //$NON-NLS-1$
9292
}
9393

9494
@Override
9595
public void createControl(Composite parent) {
9696
Composite composite = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
9797

9898
Combo pluginsCombo = createRepositoryComboArea(composite);
99-
SWTFactory.createLabel(composite, "Contents: ", 2);
99+
SWTFactory.createLabel(composite, BndToolsMessages.RepositoryTargetLocationPage_Contents, 2);
100100
bundleList = createBundleListArea(composite, 2);
101101

102102
updateTarget();
@@ -127,10 +127,10 @@ protected Combo createRepositoryComboArea(Composite composite) {
127127
names[i++] = plugin.getName();
128128
}
129129

130-
SWTFactory.createLabel(composite, "Repository: ", 1);
130+
SWTFactory.createLabel(composite, BndToolsMessages.RepositoryTargetLocationPage_Repository, 1);
131131
final Combo pluginsCombo = SWTFactory.createCombo(composite, SWT.READ_ONLY, 1, GridData.FILL_HORIZONTAL, names);
132132

133-
SWTFactory.createLabel(composite, "Location: ", 1);
133+
SWTFactory.createLabel(composite, BndToolsMessages.RepositoryTargetLocationPage_Location, 1);
134134
pluginLocationText = SWTFactory.createText(composite, SWT.READ_ONLY, 1, GridData.FILL_HORIZONTAL);
135135
pluginLocationText.setText(getLocation());
136136

@@ -162,7 +162,7 @@ protected void updateTarget() {
162162
pluginLocationText.setText(getLocation());
163163
setPageComplete(true);
164164
} catch (Exception e) {
165-
logError("Unable to list bundles for repository: " + repository.getName(), e);
165+
logError("Unable to list bundles for repository: " + repository.getName(), e); //$NON-NLS-1$
166166
clearTarget();
167167
}
168168
}
@@ -176,12 +176,12 @@ private void clearTarget() {
176176
protected Collection<?> getBundles() throws Exception {
177177
List<String> bundles = new ArrayList<>();
178178
if (repository != null) {
179-
for (String bsn : repository.list("*")) {
180-
bundles.add(bsn + " - " + repository.versions(bsn)
179+
for (String bsn : repository.list("*")) { //$NON-NLS-1$
180+
bundles.add(bsn + " - " + repository.versions(bsn) //$NON-NLS-1$
181181
.last());
182182
}
183183
if (bundles.isEmpty())
184-
logWarning("Repository is empty: " + repository.getName(), null);
184+
logWarning("Repository is empty: " + repository.getName(), null); //$NON-NLS-1$
185185
else
186186
resetMessage();
187187
}

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/bndtools/RepositoryTargetLocationWizard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class RepositoryTargetLocationWizard extends Wizard implements ITargetLoc
2626
private RepositoryTargetLocationPage targetLocationPage;
2727

2828
public RepositoryTargetLocationWizard() {
29-
setWindowTitle("Bnd Repository Target Location");
29+
setWindowTitle(BndToolsMessages.RepositoryTargetLocationWizard_BndRepositoryTargetLocation);
3030
}
3131

3232
@Override

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/bndtools/RunDescriptorTargetLocation.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@
4646
import biz.aQute.resolve.Bndrun;
4747

4848
public class RunDescriptorTargetLocation extends BndTargetLocation {
49-
static final String TYPE = "BndRunDescriptorLocation";
49+
static final String TYPE = "BndRunDescriptorLocation"; //$NON-NLS-1$
5050

51-
static final String ELEMENT_RUN_DESCRIPTOR = "bndrun";
52-
static final String ATTRIBUTE_RUN_DESCRIPTOR_FILE = "file";
51+
static final String ELEMENT_RUN_DESCRIPTOR = "bndrun"; //$NON-NLS-1$
52+
static final String ATTRIBUTE_RUN_DESCRIPTOR_FILE = "file"; //$NON-NLS-1$
5353

5454
private String bndrunFileName;
5555
private IFile bndrunFile;
5656

5757
public RunDescriptorTargetLocation() {
58-
super(TYPE, "bndrun.gif");
58+
super(TYPE, "bndrun.gif"); //$NON-NLS-1$
5959
}
6060

6161
public RunDescriptorTargetLocation setRunDescriptor(IFile bndrunFile) {
@@ -106,15 +106,15 @@ protected TargetBundle[] resolveBundles(ITargetDefinition definition, IProgressM
106106
Collection<Container> containers = bndRun.getRunbundles();
107107
List<TargetBundle> bundles = new ArrayList<>(containers.size());
108108

109-
monitor.beginTask("Resolving Bundles", containers.size());
109+
monitor.beginTask("Resolving Bundles", containers.size()); //$NON-NLS-1$
110110

111111
int i = 0;
112112
for (Container container : containers) {
113113
try {
114114
bundles.add(new TargetBundle(container.getFile()));
115115
} catch (Exception e) {
116-
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "Invalid plugin in run descriptor: "
117-
+ container.getBundleSymbolicName() + " @ " + getLocation(false), e));
116+
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "Invalid plugin in run descriptor: " //$NON-NLS-1$
117+
+ container.getBundleSymbolicName() + " @ " + getLocation(false), e)); //$NON-NLS-1$
118118
}
119119

120120
if (monitor.isCanceled())
@@ -141,7 +141,7 @@ private void resolveBndrunFile() throws CoreException {
141141
if (resource instanceof IFile) {
142142
bndrunFile = (IFile) resource;
143143
} else {
144-
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "No file at path: " + bndrunFileName));
144+
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "No file at path: " + bndrunFileName)); //$NON-NLS-1$
145145
}
146146
}
147147

@@ -176,7 +176,7 @@ public ITargetLocation getTargetLocation(Element locationElement) throws CoreExc
176176
}
177177
}
178178

179-
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "No run descriptor file specified"));
179+
throw new CoreException(new Status(IStatus.ERROR, PLUGIN_ID, "No run descriptor file specified")); //$NON-NLS-1$
180180
}
181181
}
182182

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/bndtools/RunDescriptorTargetLocationPage.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import biz.aQute.resolve.Bndrun;
4343

4444
public class RunDescriptorTargetLocationPage extends BndTargetLocationPage {
45-
private static final String FILE_EXTENSION = "bndrun";
45+
private static final String FILE_EXTENSION = "bndrun"; //$NON-NLS-1$
4646

4747
private RunDescriptorTargetLocation targetLocation;
4848

@@ -51,8 +51,8 @@ public class RunDescriptorTargetLocationPage extends BndTargetLocationPage {
5151

5252
public RunDescriptorTargetLocationPage(ITargetDefinition targetDefinition,
5353
RunDescriptorTargetLocation targetLocation) {
54-
super("AddBndRunDescriptorContainer", "Add Bnd Run Descriptor",
55-
"Select a Bnd run descriptor to be added to your target", targetDefinition);
54+
super(BndToolsMessages.RunDescriptorTargetLocationPage_AddBndRunDescriptorContainer, BndToolsMessages.RunDescriptorTargetLocationPage_AddBndRunDescriptor,
55+
BndToolsMessages.RunDescriptorTargetLocationPage_Select, targetDefinition);
5656

5757
if (targetLocation != null) {
5858
this.targetLocation = targetLocation;
@@ -64,9 +64,9 @@ public RunDescriptorTargetLocationPage(ITargetDefinition targetDefinition,
6464
public void createControl(Composite parent) {
6565
Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
6666

67-
SWTFactory.createLabel(composite, "Run descriptor:", 1);
67+
SWTFactory.createLabel(composite, BndToolsMessages.RunDescriptorTargetLocationPage_RunDescriptor, 1);
6868
TreeViewer projectTree = createRunDescriptorSelectionArea(composite);
69-
SWTFactory.createLabel(composite, "Run bundles:", 1);
69+
SWTFactory.createLabel(composite, BndToolsMessages.RunDescriptorTargetLocationPage_RunBundles, 1);
7070
bundleList = createBundleListArea(composite, 1);
7171

7272
setControl(composite);
@@ -77,7 +77,7 @@ public void createControl(Composite parent) {
7777

7878
if (projectTree.getTree()
7979
.getItems().length == 0)
80-
logError("No run descriptors found in workspace", null);
80+
logError("No run descriptors found in workspace", null); //$NON-NLS-1$
8181
}
8282

8383
private TreeViewer createRunDescriptorSelectionArea(Composite composite) {
@@ -118,7 +118,7 @@ public boolean isElementSelectable(Object element) {
118118
return element instanceof IFile;
119119
}
120120
};
121-
bndrunFilter.setPattern("*");
121+
bndrunFilter.setPattern("*"); //$NON-NLS-1$
122122
return new ViewerFilter[] {
123123
bndrunFilter
124124
};
@@ -137,15 +137,15 @@ private void updateTarget() {
137137

138138
try (Bndrun bndRun = new Bndrun(workspace, file)) {
139139
for (Container bundle : bndRun.getRunbundles()) {
140-
bundles.add(bundle.getBundleSymbolicName() + " - " + bundle.getVersion());
140+
bundles.add(bundle.getBundleSymbolicName() + " - " + bundle.getVersion()); //$NON-NLS-1$
141141
}
142142
bundleList.setInput(bundles);
143143
}
144144

145145
setPageComplete(true);
146146

147147
if (bundles.isEmpty())
148-
logWarning("Run descriptor is empty: " + runDescriptorFile.getFullPath(), null);
148+
logWarning("Run descriptor is empty: " + runDescriptorFile.getFullPath(), null); //$NON-NLS-1$
149149
else
150150
resetMessage();
151151
} catch (Exception e) {

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/bndtools/RunDescriptorTargetLocationWizard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class RunDescriptorTargetLocationWizard extends Wizard implements ITarget
2626
private RunDescriptorTargetLocationPage targetLocationPage;
2727

2828
public RunDescriptorTargetLocationWizard() {
29-
setWindowTitle("Run Descriptor Target Location");
29+
setWindowTitle("Run Descriptor Target Location"); //$NON-NLS-1$
3030
}
3131

3232
@Override

0 commit comments

Comments
 (0)