externalize string in HelpDialog class

This commit is contained in:
Eyck Jentzsch 2021-11-15 15:13:09 +01:00
parent 452a28362e
commit 66f365d38d
3 changed files with 31 additions and 13 deletions

View File

@ -82,6 +82,14 @@ public class Messages extends NLS {
public static String cursor;
public static String cursor_drag;
public static String cursor_text;
public static String HelpDialog_0;
public static String HelpDialog_1;
public static String HelpDialog_2;
public static String HelpDialog_3;
public static String HelpDialog_4;
public static String HelpDialog_5;
public static String HelpDialog_6;
public static String HelpDialog_7;
public static String marker;
public static String marker_text;
public static String rel_arrow;

View File

@ -76,6 +76,14 @@ signal_nan=Signal NaN Value
cursor=Cursor
cursor_drag=dragged Cursor
cursor_text=Cursor Text
HelpDialog_0=Back
HelpDialog_1=Forward
HelpDialog_2=Stop
HelpDialog_3=Refresh
HelpDialog_4=Go
HelpDialog_5=Address
HelpDialog_6=https://git.minres.com/VP-Tools/SCViewer/src/branch/master/README.md\#key-shortcuts
HelpDialog_7=Could not instantiate Browser:
marker=Marker
marker_text=Marker TExt
rel_arrow=Relation arrow

View File

@ -24,6 +24,8 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import com.minres.scviewer.e4.application.Messages;
public class HelpDialog extends Dialog {
/**
* Create the dialog.
@ -61,22 +63,22 @@ public class HelpDialog extends Dialog {
container.setLayout(gridLayout);
ToolBar toolbar = new ToolBar(container, SWT.NONE);
ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
itemBack.setText("Back");
itemBack.setText(Messages.HelpDialog_0);
ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
itemForward.setText("Forward");
itemForward.setText(Messages.HelpDialog_1);
ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
itemStop.setText("Stop");
itemStop.setText(Messages.HelpDialog_2);
ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
itemRefresh.setText("Refresh");
itemRefresh.setText(Messages.HelpDialog_3);
ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
itemGo.setText("Go");
itemGo.setText(Messages.HelpDialog_4);
GridData data = new GridData();
data.horizontalSpan = 3;
toolbar.setLayoutData(data);
Label labelAddress = new Label(container, SWT.NONE);
labelAddress.setText("Address");
labelAddress.setText(Messages.HelpDialog_5);
final Text location = new Text(container, SWT.BORDER);
data = new GridData();
@ -112,15 +114,15 @@ public class HelpDialog extends Dialog {
Listener listener = event -> {
ToolItem item = (ToolItem) event.widget;
String string = item.getText();
if (string.equals("Back"))
if (string.equals(Messages.HelpDialog_0))
browser.back();
else if (string.equals("Forward"))
else if (string.equals(Messages.HelpDialog_1))
browser.forward();
else if (string.equals("Stop"))
else if (string.equals(Messages.HelpDialog_2))
browser.stop();
else if (string.equals("Refresh"))
else if (string.equals(Messages.HelpDialog_3))
browser.refresh();
else if (string.equals("Go"))
else if (string.equals(Messages.HelpDialog_4))
browser.setUrl(location.getText());
};
browser.addProgressListener(new ProgressListener() {
@ -147,9 +149,9 @@ public class HelpDialog extends Dialog {
itemGo.addListener(SWT.Selection, listener);
location.addListener(SWT.DefaultSelection, e -> browser.setUrl(location.getText()));
browser.setUrl("https://git.minres.com/VP-Tools/SCViewer/src/branch/master/README.md#key-shortcuts");
browser.setUrl(Messages.HelpDialog_6);
} catch (SWTError e) {
System.out.println("Could not instantiate Browser: " + e.getMessage());
System.out.println(Messages.HelpDialog_7 + e.getMessage());
}
return container;
}