Skip to content

Commit 8e17643

Browse files
authored
Externalize more dataflow UI strings (#2245)
* externalize more strings * tests * cleanup * more externalization * fix name * RunOptionsDefaultsComponent * more externalization * code review * update test
1 parent 2eef40c commit 8e17643

11 files changed

Lines changed: 109 additions & 67 deletions

File tree

plugins/com.google.cloud.tools.eclipse.dataflow.ui.test/src/com/google/cloud/tools/eclipse/dataflow/ui/page/MessagesTest.java renamed to plugins/com.google.cloud.tools.eclipse.dataflow.ui.test/src/com/google/cloud/tools/eclipse/dataflow/ui/MessagesTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.tools.eclipse.dataflow.ui.page;
17+
package com.google.cloud.tools.eclipse.dataflow.ui;
1818

1919
import org.junit.Assert;
2020
import org.junit.Test;
2121

2222
public class MessagesTest {
2323

24+
@Test
25+
public void testNewCloudDataflowProject() {
26+
Assert.assertEquals("New Cloud Dataflow Project", Messages.getString("new.cloud.dataflow.project"));
27+
}
28+
2429
@Test
2530
public void testRunOptions() {
2631
Assert.assertEquals(
@@ -36,7 +41,8 @@ public void testWizardDescription() {
3641

3742
@Test
3843
public void testLocationToolTip() {
39-
Assert.assertEquals("The location where the project will be created. Must be an existing local directory.",
44+
Assert.assertEquals("The directory where the project will be created. Must be an existing local directory.",
4045
Messages.getString("LOCATION_TOOLTIP"));
4146
}
47+
4248
}

plugins/com.google.cloud.tools.eclipse.dataflow.ui/src/com/google/cloud/tools/eclipse/dataflow/ui/page/Messages.java renamed to plugins/com.google.cloud.tools.eclipse.dataflow.ui/src/com/google/cloud/tools/eclipse/dataflow/ui/Messages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.tools.eclipse.dataflow.ui.page;
17+
package com.google.cloud.tools.eclipse.dataflow.ui;
1818

1919
import java.text.MessageFormat;
2020
import java.util.MissingResourceException;
2121
import java.util.ResourceBundle;
2222

2323
public class Messages {
2424
private static final String BUNDLE_NAME =
25-
"com.google.cloud.tools.eclipse.dataflow.ui.page.messages"; //$NON-NLS-1$
25+
"com.google.cloud.tools.eclipse.dataflow.ui.messages"; //$NON-NLS-1$
2626

2727
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
2828

plugins/com.google.cloud.tools.eclipse.dataflow.ui/src/com/google/cloud/tools/eclipse/dataflow/ui/launcher/PipelineArgumentsTab.java

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.google.cloud.tools.eclipse.dataflow.core.project.DataflowDependencyManager;
3131
import com.google.cloud.tools.eclipse.dataflow.core.project.MajorVersion;
3232
import com.google.cloud.tools.eclipse.dataflow.ui.DataflowUiPlugin;
33+
import com.google.cloud.tools.eclipse.dataflow.ui.Messages;
3334
import com.google.cloud.tools.eclipse.dataflow.ui.page.MessageTarget;
3435
import com.google.cloud.tools.eclipse.dataflow.ui.page.component.LabeledTextMapComponent;
3536
import com.google.cloud.tools.eclipse.dataflow.ui.page.component.TextAndButtonComponent;
@@ -38,6 +39,7 @@
3839
import com.google.common.annotations.VisibleForTesting;
3940
import com.google.common.base.Joiner;
4041
import com.google.common.base.Preconditions;
42+
import com.google.common.base.Strings;
4143
import com.google.common.collect.ImmutableSet;
4244
import com.google.common.collect.Iterables;
4345
import com.google.common.util.concurrent.SettableFuture;
@@ -81,9 +83,9 @@
8183
* A tab specifying arguments required to run a Dataflow Pipeline.
8284
*/
8385
public class PipelineArgumentsTab extends AbstractLaunchConfigurationTab {
84-
private static final Joiner MISSING_GROUP_MEMBER_JOINER = Joiner.on(", ");
86+
private static final Joiner MISSING_GROUP_MEMBER_JOINER = Joiner.on(", "); //$NON-NLS-1$
8587

86-
private static final String ARGUMENTS_SEPARATOR = "=";
88+
private static final String ARGUMENTS_SEPARATOR = "="; //$NON-NLS-1$
8789

8890
private Executor executor;
8991

@@ -139,7 +141,7 @@ public void createControl(Composite parent) {
139141
internalComposite.setLayout(new GridLayout(1, false));
140142

141143
runnerGroup = new Group(internalComposite, SWT.NULL);
142-
runnerGroup.setText("Runner:");
144+
runnerGroup.setText(Messages.getString("runner")); //$NON-NLS-1$
143145
runnerGroup.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
144146
runnerGroup.setLayout(new GridLayout(2, false));
145147

@@ -152,15 +154,17 @@ public void createControl(Composite parent) {
152154
Set<String> filterProperties =
153155
ImmutableSet.<String>builder()
154156
.addAll(DataflowPreferences.SUPPORTED_DEFAULT_PROPERTIES)
155-
.add("runner")
157+
.add("runner") //$NON-NLS-1$
156158
.build();
157159

158160
Group runnerOptionsGroup = new Group(inputsComposite, SWT.NULL);
159-
runnerOptionsGroup.setText("Pipeline Options:");
161+
runnerOptionsGroup.setText(Messages.getString("pipeline.options")); //$NON-NLS-1$
160162
runnerOptionsGroup.setLayout(new GridLayout());
161163

162164
userOptionsSelector = new TextAndButtonComponent(
163-
runnerOptionsGroup, new GridData(SWT.FILL, SWT.BEGINNING, true, false), "&Search...");
165+
runnerOptionsGroup,
166+
new GridData(SWT.FILL, SWT.BEGINNING, true, false),
167+
Messages.getString("search")); //$NON-NLS-1$
164168
userOptionsSelector.addButtonSelectionListener(openPipelineOptionsSearchListener());
165169

166170
pipelineOptionsForm =
@@ -181,12 +185,12 @@ public void createControl(Composite parent) {
181185
private TextAndButtonSelectionListener openPipelineOptionsSearchListener() {
182186
return new TextAndButtonSelectionListener() {
183187
@Override
184-
public void widgetSelected(SelectionEvent e) {
188+
public void widgetSelected(SelectionEvent event) {
185189
Map<String, PipelineOptionsType> optionsTypes = hierarchy.getAllPipelineOptionsTypes();
186190
PipelineOptionsSelectionDialog dialog =
187191
new PipelineOptionsSelectionDialog(getShell(), optionsTypes);
188192
dialog.setBlockOnOpen(true);
189-
dialog.setInitialPattern("**");
193+
dialog.setInitialPattern("**"); //$NON-NLS-1$
190194
if (dialog.open() == Window.OK) {
191195
String userOptionsName = dialog.getFirstResult().toString();
192196
setTextValue(userOptionsName);
@@ -197,7 +201,7 @@ public void widgetSelected(SelectionEvent e) {
197201
}
198202

199203
@Override
200-
public void widgetDefaultSelected(SelectionEvent e) {}
204+
public void widgetDefaultSelected(SelectionEvent event) {}
201205
};
202206
}
203207

@@ -286,7 +290,7 @@ PipelineRunner getSelectedRunner() {
286290
return runnerButton.getKey();
287291
}
288292
}
289-
throw new IllegalStateException("No runner selected, but a runner starts selected");
293+
throw new IllegalStateException("No runner selected, but a runner starts selected"); //$NON-NLS-1$
290294
}
291295

292296
@Override
@@ -311,12 +315,13 @@ public void initializeFrom(ILaunchConfiguration configuration) {
311315
defaultOptionsComponent.setCustomValues(launchConfiguration.getArgumentValues());
312316

313317
String userOptionsName = launchConfiguration.getUserOptionsName();
314-
userOptionsSelector.setText(userOptionsName == null ? "" : userOptionsName);
318+
userOptionsSelector.setText(Strings.nullToEmpty(userOptionsName));
315319

316320
updatePipelineOptionsForm();
317-
} catch (CoreException e) {
321+
} catch (CoreException ex) {
318322
// TODO: Handle
319-
DataflowUiPlugin.logError(e, "Error while initializing from existing configuration");
323+
DataflowUiPlugin.logError(ex,
324+
"Error while initializing from existing configuration"); //$NON-NLS-1$
320325
}
321326
}
322327

@@ -333,7 +338,7 @@ void updateRunnerButtons(MajorVersion majorVersion) {
333338
runnerButton = runnerButtons.get(PipelineLaunchConfiguration.defaultRunner(majorVersion));
334339
}
335340
Preconditions.checkNotNull(runnerButton,
336-
"runners for %s should always include the default runner", majorVersion);
341+
"runners for %s should always include the default runner", majorVersion); //$NON-NLS-1$
337342
runnerButton.setSelection(true);
338343
runnerGroup.getParent().redraw();
339344
}
@@ -342,7 +347,7 @@ void updateRunnerButtons(MajorVersion majorVersion) {
342347
* Asynchronously updates the project hierarchy.
343348
*/
344349
private void updateHierarchy(final MajorVersion majorVersion) {
345-
Job job = new Job("Update Hierarchy") {
350+
Job job = new Job(Messages.getString("update.hierarchy")) { //$NON-NLS-1$
346351
@Override
347352
public IStatus run(IProgressMonitor progress) {
348353
hierarchy = getPipelineOptionsHierarchy(majorVersion, progress);
@@ -369,7 +374,7 @@ private PipelineOptionsHierarchy getPipelineOptionsHierarchy(
369374
return pipelineOptionsHierarchyFactory.forProject(project, majorVersion, monitor);
370375
} catch (PipelineOptionsRetrievalException e) {
371376
DataflowUiPlugin.logWarning(
372-
"Couldn't retrieve Pipeline Options Hierarchy for project %s", project);
377+
"Couldn't retrieve Pipeline Options Hierarchy for project %s", project); //$NON-NLS-1$
373378
return pipelineOptionsHierarchyFactory.global(monitor);
374379
}
375380
}
@@ -386,13 +391,13 @@ private IProject getProject() {
386391

387392
@Override
388393
public String getName() {
389-
return "Pipeline Arguments";
394+
return Messages.getString("pipeline.arguments"); //$NON-NLS-1$
390395
}
391396

392397
private void updatePipelineOptionsForm() {
393398
final SettableFuture<Map<PipelineOptionsType, Set<PipelineOptionsProperty>>>
394399
optionsHierarchyFuture = SettableFuture.create();
395-
Job job = new Job("Update Pipeline Options Form") {
400+
Job job = new Job("Update Pipeline Options Form") { //$NON-NLS-1$
396401
@Override
397402
protected IStatus run(IProgressMonitor monitor) {
398403
optionsHierarchyFuture.set(launchConfiguration.getOptionsHierarchy(hierarchy));
@@ -412,7 +417,7 @@ public void run() {
412417
pipelineOptionsForm.updateForm(launchConfiguration, optionsHierarchyFuture.get());
413418
updateLaunchConfigurationDialog();
414419
} catch (InterruptedException | ExecutionException e) {
415-
DataflowUiPlugin.logError(e, "Exception while updating available Pipeline Options");
420+
DataflowUiPlugin.logError(e, "Exception while updating available Pipeline Options"); //$NON-NLS-1$
416421
}
417422
}
418423
},
@@ -440,15 +445,15 @@ private boolean validateRequiredGroups(MissingRequiredProperties validationFailu
440445
Map.Entry<String, Set<PipelineOptionsProperty>> missingGroupEntry =
441446
Iterables.getFirst(validationFailures.getMissingGroups().entrySet(), null);
442447
if (missingGroupEntry != null) {
443-
StringBuilder errorBuilder = new StringBuilder("Missing value for group ");
448+
StringBuilder errorBuilder = new StringBuilder("Missing value for group "); //$NON-NLS-1$
444449
errorBuilder.append(missingGroupEntry.getKey());
445-
errorBuilder.append(". Properties satisfying group requirement are ");
450+
errorBuilder.append(". Properties satisfying group requirement are "); //$NON-NLS-1$
446451
Set<String> groupMembers = new HashSet<>();
447452
for (PipelineOptionsProperty missingProperty : missingGroupEntry.getValue()) {
448453
groupMembers.add(missingProperty.getName());
449454
}
450455
errorBuilder.append(MISSING_GROUP_MEMBER_JOINER.join(groupMembers));
451-
errorBuilder.append(".");
456+
errorBuilder.append("."); //$NON-NLS-1$
452457
setErrorMessage(errorBuilder.toString());
453458
return false;
454459
}
@@ -459,7 +464,7 @@ private boolean validateRequiredProperties(MissingRequiredProperties validationF
459464
PipelineOptionsProperty missingProperty =
460465
Iterables.getFirst(validationFailures.getMissingProperties(), null);
461466
if (missingProperty != null) {
462-
setErrorMessage("Missing required property " + missingProperty.getName());
467+
setErrorMessage(Messages.getString("missing.required.property", missingProperty.getName())); //$NON-NLS-1$
463468
return false;
464469
}
465470
return true;

plugins/com.google.cloud.tools.eclipse.dataflow.ui/src/com/google/cloud/tools/eclipse/dataflow/ui/launcher/PipelineOptionsSelectionDialog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public boolean isConsistentItem(Object item) {
114114
}
115115
}
116116

117-
private class PipelineOptionsLabelProvider implements ILabelProvider {
117+
private static class PipelineOptionsLabelProvider implements ILabelProvider {
118118
@Override
119119
public void addListener(ILabelProviderListener listener) {}
120120

@@ -140,7 +140,7 @@ public String getText(Object element) {
140140
return null;
141141
}
142142
String simpleName = Signature.getSimpleName(element.toString());
143-
return String.format("%s - %s", simpleName, element.toString());
143+
return String.format("%s - %s", simpleName, element.toString()); //$NON-NLS-1$
144144
}
145145
}
146146
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
could.not.retrieve.buckets.for.project=Could not retrieve buckets for project {0}
2+
account=&Account:
3+
RUN_OPTIONS=Dataflow Default Run Options
4+
SET_RUN_OPTIONS=Set Default Cloud Dataflow Run Options
5+
DATAFLOW_PIPELINE_OPTIONS=Set default options for running a Dataflow Pipeline.
6+
execution.options.for.google.cloud.platform=Execution Options for Google Cloud Platform
7+
CREATE_DATAFLOW_PROJECT=Create a Cloud Dataflow Project
8+
WIZARD_DESCRIPTION=This wizard creates a new Google Cloud Dataflow project.
9+
GROUP_ID_TOOLTIP=The Maven Group ID. Should be an alphanumeric path separated by periods.
10+
ARTIFACT_ID_TOOLTIP=The Maven Artifact ID. Should be an alphanumeric name separated by dashes.
11+
cloud.platform.project.id=Cloud Platform &Project ID:
12+
cloud.storage.staging.location=Cloud Storage Staging &Location:
13+
could.not.create.staging.location=Could not create staging location at {0}
14+
couldnt.fetch.bucket=Couldn't fetch bucket {0}.
15+
create.bucket=&Create Bucket
16+
created.staging.location.at=Created staging location at {0}
17+
UNSET_PACKAGE_TOOLTIP=If unset this will be the same as the Group ID.
18+
LOCATION_TOOLTIP=The directory where the project will be created. Must be an existing local directory.
19+
missing.required.property=Missing required property {0}
20+
new.cloud.dataflow.project=New Cloud Dataflow Project
21+
runner=Runner:
22+
pipeline.arguments=Pipeline Arguments
23+
pipeline.options=Pipeline Options:
24+
SELECT_PROJECT_LOCATION=Select project location
25+
set.pipeline.run.option.defaults=Set Pipeline Run Option Defaults
26+
sign.into.another.account=Sign into another account...
27+
verified.bucket.is.accessible=Verified bucket {0} is accessible.
28+
search=&Search...
29+
update.hierarchy=Update Hierarchy

plugins/com.google.cloud.tools.eclipse.dataflow.ui/src/com/google/cloud/tools/eclipse/dataflow/ui/page/NewDataflowProjectWizardDefaultRunOptionsPage.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.google.cloud.tools.eclipse.dataflow.core.preferences.DataflowPreferences;
2020
import com.google.cloud.tools.eclipse.dataflow.core.preferences.ProjectOrWorkspaceDataflowPreferences;
21+
import com.google.cloud.tools.eclipse.dataflow.ui.Messages;
2122
import com.google.cloud.tools.eclipse.dataflow.ui.preferences.RunOptionsDefaultsComponent;
2223
import org.eclipse.jface.wizard.WizardPage;
2324
import org.eclipse.swt.SWT;
@@ -28,14 +29,14 @@
2829
* An optional Page to input default run options for a Dataflow Project.
2930
*/
3031
public class NewDataflowProjectWizardDefaultRunOptionsPage extends WizardPage {
31-
private static final String PAGE_NAME = Messages.getString("RUN_OPTIONS");
32+
private static final String PAGE_NAME = Messages.getString("RUN_OPTIONS"); //$NON-NLS-1$
3233

3334
private RunOptionsDefaultsComponent runOptionsDefaultsComponent;
3435

3536
public NewDataflowProjectWizardDefaultRunOptionsPage() {
3637
super(PAGE_NAME);
37-
setTitle(Messages.getString("SET_RUN_OPTIONS"));
38-
setDescription(Messages.getString("DATAFLOW_PIPELINE_OPTIONS"));
38+
setTitle(Messages.getString("SET_RUN_OPTIONS")); //$NON-NLS-1$
39+
setDescription(Messages.getString("DATAFLOW_PIPELINE_OPTIONS")); //$NON-NLS-1$
3940
setPageComplete(true);
4041
}
4142

plugins/com.google.cloud.tools.eclipse.dataflow.ui/src/com/google/cloud/tools/eclipse/dataflow/ui/page/NewDataflowProjectWizardLandingPage.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.google.cloud.tools.eclipse.dataflow.core.project.DataflowProjectCreator.Template;
2222
import com.google.cloud.tools.eclipse.dataflow.core.project.DataflowProjectValidationStatus;
2323
import com.google.cloud.tools.eclipse.dataflow.core.project.MajorVersion;
24+
import com.google.cloud.tools.eclipse.dataflow.ui.Messages;
2425
import com.google.cloud.tools.eclipse.dataflow.ui.util.ButtonFactory;
2526
import com.google.common.base.Strings;
2627
import org.apache.maven.artifact.versioning.ArtifactVersion;
@@ -73,19 +74,19 @@ public class NewDataflowProjectWizardLandingPage extends WizardPage {
7374
private Combo projectNameTemplate;
7475

7576
public NewDataflowProjectWizardLandingPage(DataflowProjectCreator targetCreator) {
76-
super("newDataflowProjectWizardLandingPage");
77+
super("newDataflowProjectWizardLandingPage"); //$NON-NLS-1$
7778
this.dependencyManager = DataflowDependencyManager.create();
7879
this.targetCreator = targetCreator;
79-
setTitle(Messages.getString("CREATE_DATAFLOW_PROJECT"));
80-
setDescription(Messages.getString("WIZARD_DESCRIPTION"));
80+
setTitle(Messages.getString("CREATE_DATAFLOW_PROJECT")); //$NON-NLS-1$
81+
setDescription(Messages.getString("WIZARD_DESCRIPTION")); //$NON-NLS-1$
8182
setImageDescriptor(getDataflowIcon());
8283
setPageComplete(false);
8384
}
8485

8586
private static ImageDescriptor getDataflowIcon() {
86-
String imageFilePath = "icons/Dataflow_64.png";
87+
String imageFilePath = "icons/Dataflow_64.png"; //$NON-NLS-1$
8788
return AbstractUIPlugin.imageDescriptorFromPlugin(
88-
"com.google.cloud.tools.eclipse.dataflow.ui", imageFilePath);
89+
"com.google.cloud.tools.eclipse.dataflow.ui", imageFilePath); //$NON-NLS-1$
8990
}
9091

9192
private static void addLabel(Composite formComposite, String labelText) {

plugins/com.google.cloud.tools.eclipse.dataflow.ui/src/com/google/cloud/tools/eclipse/dataflow/ui/page/messages.properties

Lines changed: 0 additions & 10 deletions
This file was deleted.

plugins/com.google.cloud.tools.eclipse.dataflow.ui/src/com/google/cloud/tools/eclipse/dataflow/ui/preferences/DefaultRunOptionsPage.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.google.cloud.tools.eclipse.dataflow.core.preferences.DataflowPreferences;
2020
import com.google.cloud.tools.eclipse.dataflow.core.preferences.WritableDataflowPreferences;
21+
import com.google.cloud.tools.eclipse.dataflow.ui.Messages;
2122
import com.google.cloud.tools.eclipse.dataflow.ui.page.DialogPageMessageTarget;
2223
import org.eclipse.core.resources.IProject;
2324
import org.eclipse.core.runtime.IAdaptable;
@@ -48,7 +49,7 @@ protected Control createContents(Composite parent) {
4849
Composite composite = new Composite(parent, SWT.NULL);
4950
composite.setLayout(new GridLayout(1, false));
5051
Group group = new Group(composite, SWT.NULL);
51-
group.setText("Execution Options for Google Cloud Platform");
52+
group.setText(Messages.getString("execution.options.for.google.cloud.platform")); //$NON-NLS-1$
5253
int numColumns = 3;
5354
group.setLayout(new GridLayout(numColumns, false));
5455
group.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
@@ -90,7 +91,7 @@ public void setElement(IAdaptable element) {
9091
this.selectedProject = element.getAdapter(IProject.class);
9192
if (selectedProject == null) {
9293
throw new IllegalArgumentException(
93-
"Provided element " + element + " isn't adaptable to a project.");
94+
"Provided element " + element + " isn't adaptable to a project."); //$NON-NLS-1$ //$NON-NLS-2$
9495
} else {
9596
this.preferences = WritableDataflowPreferences.forProject(this.selectedProject);
9697
}

0 commit comments

Comments
 (0)