Skip to content

Commit

Permalink
Internationalize Zest SWT Snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
ptziegler committed Oct 24, 2024
1 parent a5e3ce7 commit 274e5f8
Show file tree
Hide file tree
Showing 25 changed files with 378 additions and 134 deletions.
123 changes: 123 additions & 0 deletions org.eclipse.zest.examples/src/org/eclipse/zest/examples/Messages.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*******************************************************************************
* Copyright (c) 2024 Patrick Ziegler and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Patrick Ziegler - initial API and implementation
*******************************************************************************/

package org.eclipse.zest.examples;

import org.eclipse.osgi.util.NLS;

public class Messages extends NLS {
private static final String BUNDLE_NAME = Messages.class.getPackageName() + ".messages"; //$NON-NLS-1$
// Used in multiple snippets
public static String Paper;
public static String Rock;
public static String Scissors;
public static String Information;
public static String Warning;
public static String Error;
public static String Root;
//
public static String AnimationSnippet_Animate;
public static String AnimationSnippet_Title;
public static String CustomLayout_Title;
public static String GraphSnippet1_Title;
public static String GraphSnippet10_Title;
public static String GraphSnippet10_ChangeCurve;
public static String GraphSnippet11_Title;
public static String GraphSnippet11_Node1;
public static String GraphSnippet11_Node2;
public static String GraphSnippet12_Title;
public static String GraphSnippet12_PDE;
public static String GraphSnippet12_Zest;
public static String GraphSnippet12_PDEVizTool;
public static String GraphSnippet13_Title;
public static String GraphSnippet13_Tooltip_Name;
public static String GraphSnippet13_Tooltip_Location;
public static String GraphSnippet13_USA;
public static String GraphSnippet13_Canada;
public static String GraphSnippet13_Node1;
public static String GraphSnippet13_Node2;
public static String GraphSnippet14_Title;
public static String GraphSnippet14_RevealAll;
public static String GraphSnippet2_Title;
public static String GraphSnippet3_Title;
public static String GraphSnippet4_Title;
public static String GraphSnippet4_Tooltip1;
public static String GraphSnippet4_Tooltip2;
public static String GraphSnippet5_Title;
public static String GraphSnippet5_Information;
public static String GraphSnippet5_Warning;
public static String GraphSnippet5_Error;
public static String GraphSnippet6_Title;
public static String GraphSnippet7_Title;
public static String GraphSnippet7_SystemOut;
public static String GraphSnippet8_Title;
public static String GraphSnippet8_Node1;
public static String GraphSnippet8_Node2;
public static String GraphSnippet8_Node3;
public static String GraphSnippet8_Node4;
public static String GraphSnippet8_Node5;
public static String GraphSnippet8_Node6;
public static String GraphSnippet8_Node7;
public static String GraphSnippet9_Title;
public static String GraphSnippet9_Connection;
public static String HelloWorld_Title;
public static String HelloWorld_Node1;
public static String HelloWorld_Node2;
public static String LayoutExample_Title;
public static String LayoutExample_Node1;
public static String LayoutExample_Node2;
public static String ManhattanLayoutGraphSnippet_Title;
public static String ManhattanLayoutGraphSnippet_ChangeRouter;
public static String NestedGraphSnippet_Title;
public static String NestedGraphSnippet_Container1;
public static String NestedGraphSnippet_Container2;
public static String NestedGraphSnippet_Container3;
public static String NestedGraphSnippet_Node1;
public static String NestedGraphSnippet_Node2;
public static String NestedGraphSnippet_Node3;
public static String NestedGraphSnippet_Node4;
public static String NestedGraphSnippet_Node5;
public static String NestedGraphSnippet2_Title;
public static String NestedGraphSnippet2_Connection;
public static String NestedGraphSnippet2_Container1;
public static String NestedGraphSnippet2_Container2;
public static String NestedGraphSnippet2_Container3;
public static String NestedGraphSnippet2_Container4;
public static String NestedGraphSnippet2_Container5;
public static String NestedGraphSnippet2_Container6;
public static String NestedGraphSnippet2_Container7;
public static String NestedGraphSnippet2_Node1;
public static String NestedGraphSnippet2_Node2;
public static String NestedGraphSnippet2_Node3;
public static String NestedGraphSnippet2_Node4;
public static String NestedGraphSnippet2_Node5;
public static String PaintSnippet_Title;
public static String PaintSnippet_TakeScreenshot;
public static String PaintSnippet_Popup_Title;
public static String ZoomSnippet_Title;
public static String ZoomSnippet_Container1;
public static String ZoomSnippet_Container2;
public static String ZoomSnippet_Container3;
public static String ZoomSnippet_Node1;
public static String ZoomSnippet_Node2;
public static String ZoomSnippet_Node3;
public static String ZoomSnippet_Node4;
public static String ZoomSnippet_Node5;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}

private Messages() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Paper=Paper
Rock=Rock
Scissors=Scissors
Information=Information
Warning=Warning
Error=Error
Root=Root
AnimationSnippet_Animate=Animate
AnimationSnippet_Title=Animation Example
CustomLayout_Title=Custom Layout Example
GraphSnippet1_Title=GraphSnippet1
GraphSnippet10_Title=GraphSnippet10
GraphSnippet10_ChangeCurve=Change Curve
GraphSnippet11_Title=GraphSnippet11
GraphSnippet11_Node1=Node 1
GraphSnippet11_Node2=Node 2
GraphSnippet12_Title=GraphSnippet12
GraphSnippet12_PDE=PDE
GraphSnippet12_Zest=Zest
GraphSnippet12_PDEVizTool=PDE Viz tool
GraphSnippet13_Title=GraphSnippet13
GraphSnippet13_Tooltip_Name=Name: Chris Aniszczyk
GraphSnippet13_Tooltip_Location=Location: Austin, Texas
GraphSnippet13_USA=USA
GraphSnippet13_Canada=Canada
GraphSnippet13_Node1=Ian B.
GraphSnippet13_Node2=Chris A.
GraphSnippet14_Title=GraphSnippet14
GraphSnippet14_RevealAll=Reveal All
GraphSnippet2_Title=GraphSnippet2
GraphSnippet3_Title=GraphSnippet3
GraphSnippet4_Title=GraphSnippet4
GraphSnippet4_Tooltip1=Information to Warning
GraphSnippet4_Tooltip2=Warning to Error
GraphSnippet5_Title=GraphSnippet5
GraphSnippet5_Information=org.eclipse.Information
GraphSnippet5_Warning=org.eclipse.Warning
GraphSnippet5_Error=org.eclipse.Error
GraphSnippet6_Title=GraphSnippet6
GraphSnippet7_Title=GraphSnippet7
GraphSnippet7_SystemOut={0} is at ({1}, {2})
GraphSnippet8_Title=GraphSnippet8
GraphSnippet8_Node1=B
GraphSnippet8_Node2=C
GraphSnippet8_Node3=D
GraphSnippet8_Node4=E
GraphSnippet8_Node5=F
GraphSnippet8_Node6=G
GraphSnippet8_Node7=H
GraphSnippet9_Title=GraphSnippet9
GraphSnippet9_Connection=A to A
HelloWorld_Title=Hello, World
HelloWorld_Node1=Hello
HelloWorld_Node2=World
LayoutExample_Title=LayoutExample
LayoutExample_Node1=1 - {0}
LayoutExample_Node2=2 - {0}
ManhattanLayoutGraphSnippet_Title=ManhattanLayout GraphSnippet
ManhattanLayoutGraphSnippet_ChangeRouter=Change Router
NestedGraphSnippet_Title=NestedGraphSnippet1
NestedGraphSnippet_Container1=SomeClass.java
NestedGraphSnippet_Container2=SomeNestedClass.java
NestedGraphSnippet_Container3=DefaultAction.java
NestedGraphSnippet_Node1=SomeClass.java
NestedGraphSnippet_Node2=SomeNestedClass.java
NestedGraphSnippet_Node3=DefaultAction.java
NestedGraphSnippet_Node4=LastAction(Hero).java
NestedGraphSnippet_Node5=LastAction(Hero).java
NestedGraphSnippet2_Title=NestedGraphSnippet2
NestedGraphSnippet2_Connection=Network (bandwidth:1)
NestedGraphSnippet2_Container1=Machine 1 (prop:1)
NestedGraphSnippet2_Container2=Machine 2
NestedGraphSnippet2_Container3=Machine 3
NestedGraphSnippet2_Container4=Host 1
NestedGraphSnippet2_Container5=Host 2
NestedGraphSnippet2_Container6=Host 3
NestedGraphSnippet2_Container7=Host 4
NestedGraphSnippet2_Node1=JSP Object
NestedGraphSnippet2_Node2=JSP Object 2
NestedGraphSnippet2_Node3=JSP Object 3
NestedGraphSnippet2_Node4=JSP Object 4
NestedGraphSnippet2_Node5=JSP Object 5
PaintSnippet_Title=PaintSnippet
PaintSnippet_TakeScreenshot=Take Screenshot
PaintSnippet_Popup_Title=Image
ZoomSnippet_Title=ZoomSnippet
ZoomSnippet_Container1=SomeClass.java
ZoomSnippet_Container2=SomeNestedClass.java
ZoomSnippet_Container3=DefaultAction.java
ZoomSnippet_Node1=SomeClass.java
ZoomSnippet_Node2=SomeNestedClass.java
ZoomSnippet_Node3=DefaultAction.java
ZoomSnippet_Node4=LastAction(Hero).java
ZoomSnippet_Node5=LastAction(Hero).java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.eclipse.zest.core.widgets.Graph;
import org.eclipse.zest.core.widgets.GraphConnection;
import org.eclipse.zest.core.widgets.GraphNode;
import org.eclipse.zest.examples.Messages;

import org.eclipse.draw2d.Animation;

Expand All @@ -29,17 +30,17 @@ public static void main(String[] args) {

final Shell shell = new Shell();
Display d = shell.getDisplay();
shell.setText("Animation Example");
shell.setText(Messages.AnimationSnippet_Title);
shell.setLayout(new FillLayout(SWT.VERTICAL));
shell.setSize(400, 400);

Button b = new Button(shell, SWT.PUSH);
b.setText("Animate");
b.setText(Messages.AnimationSnippet_Animate);

g = new Graph(shell, SWT.NONE);

final GraphNode n = new GraphNode(g, SWT.NONE, "Paper");
final GraphNode n2 = new GraphNode(g, SWT.NONE, "Rock");
final GraphNode n = new GraphNode(g, SWT.NONE, Messages.Paper);
final GraphNode n2 = new GraphNode(g, SWT.NONE, Messages.Rock);

b.addSelectionListener(new SelectionListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.eclipse.zest.core.widgets.Graph;
import org.eclipse.zest.core.widgets.GraphConnection;
import org.eclipse.zest.core.widgets.GraphNode;
import org.eclipse.zest.examples.Messages;
import org.eclipse.zest.layouts.algorithms.AbstractLayoutAlgorithm;
import org.eclipse.zest.layouts.interfaces.EntityLayout;

Expand All @@ -25,15 +26,15 @@ public class CustomLayout {
public static void main(String[] args) {
Shell shell = new Shell();
Display d = shell.getDisplay();
shell.setText("Custom Layout Example");
shell.setText(Messages.CustomLayout_Title);
shell.setLayout(new FillLayout());
shell.setSize(400, 400);

g = new Graph(shell, SWT.NONE);

GraphNode n = new GraphNode(g, SWT.NONE, "Paper");
GraphNode n2 = new GraphNode(g, SWT.NONE, "Rock");
GraphNode n3 = new GraphNode(g, SWT.NONE, "Scissors");
GraphNode n = new GraphNode(g, SWT.NONE, Messages.Paper);
GraphNode n2 = new GraphNode(g, SWT.NONE, Messages.Rock);
GraphNode n3 = new GraphNode(g, SWT.NONE, Messages.Scissors);
new GraphConnection(g, SWT.NONE, n, n2);
new GraphConnection(g, SWT.NONE, n2, n3);
new GraphConnection(g, SWT.NONE, n3, n);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.zest.core.widgets.GraphConnection;
import org.eclipse.zest.core.widgets.GraphNode;
import org.eclipse.zest.core.widgets.internal.NodeSearchDialog;
import org.eclipse.zest.examples.Messages;
import org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm;

/**
Expand All @@ -42,15 +43,15 @@ public class GraphSnippet1 {
public static void main(String[] args) {
Shell shell = new Shell();
Display d = shell.getDisplay();
shell.setText("GraphSnippet1");
shell.setText(Messages.GraphSnippet1_Title);
shell.setLayout(new FillLayout());
shell.setSize(400, 400);

g = new Graph(shell, SWT.NONE);

GraphNode n = new GraphNode(g, SWT.NONE, "Paper");
GraphNode n2 = new GraphNode(g, SWT.NONE, "Rock");
GraphNode n3 = new GraphNode(g, SWT.NONE, "Scissors");
GraphNode n = new GraphNode(g, SWT.NONE, Messages.Paper);
GraphNode n2 = new GraphNode(g, SWT.NONE, Messages.Rock);
GraphNode n3 = new GraphNode(g, SWT.NONE, Messages.Scissors);
new GraphConnection(g, SWT.NONE, n, n2);
new GraphConnection(g, SWT.NONE, n2, n3);
new GraphConnection(g, SWT.NONE, n3, n);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.zest.core.widgets.Graph;
import org.eclipse.zest.core.widgets.GraphConnection;
import org.eclipse.zest.core.widgets.GraphNode;
import org.eclipse.zest.examples.Messages;
import org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm;

/**
Expand All @@ -39,25 +40,25 @@ public class GraphSnippet10 {
public static void main(String[] args) {
Shell shell = new Shell();
Display d = shell.getDisplay();
shell.setText("GraphSnippet1");
shell.setText(Messages.GraphSnippet10_Title);
shell.setLayout(new FillLayout());
shell.setSize(400, 400);

g = new Graph(shell, SWT.NONE);

GraphNode n = new GraphNode(g, SWT.NONE, "Paper");
GraphNode n = new GraphNode(g, SWT.NONE, Messages.Paper);
n.setBorderColor(org.eclipse.draw2d.ColorConstants.yellow);
n.setBorderWidth(3);
GraphNode n2 = new GraphNode(g, SWT.NONE, "Rock");
GraphNode n3 = new GraphNode(g, SWT.NONE, "Scissors");
GraphNode n2 = new GraphNode(g, SWT.NONE, Messages.Rock);
GraphNode n3 = new GraphNode(g, SWT.NONE, Messages.Scissors);
final GraphConnection connection = new GraphConnection(g, SWT.NONE, n, n2);
connection.setLineWidth(3);
new GraphConnection(g, SWT.NONE, n2, n3);
new GraphConnection(g, SWT.NONE, n3, n);
g.setLayoutAlgorithm(new SpringLayoutAlgorithm(), true);

Button button = new Button(shell, SWT.PUSH);
button.setText("Change Curve");
button.setText(Messages.GraphSnippet10_ChangeCurve);
button.addSelectionListener(new SelectionAdapter() {
int count = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.zest.core.widgets.Graph;
import org.eclipse.zest.core.widgets.GraphConnection;
import org.eclipse.zest.core.widgets.GraphNode;
import org.eclipse.zest.examples.Messages;
import org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm;

import org.eclipse.draw2d.ColorConstants;
Expand All @@ -45,13 +46,13 @@ public static void createConnection(Graph g, GraphNode n1, GraphNode n2, Color c
public static void main(String[] args) {
Shell shell = new Shell();
Display d = shell.getDisplay();
shell.setText("GraphSnippet11"); //$NON-NLS-1$
shell.setText(Messages.GraphSnippet11_Title);
shell.setLayout(new FillLayout());
shell.setSize(400, 400);

g = new Graph(shell, SWT.NONE);
GraphNode n = new GraphNode(g, SWT.NONE, "Node 1"); //$NON-NLS-1$
GraphNode n2 = new GraphNode(g, SWT.NONE, "Node 2"); //$NON-NLS-1$
GraphNode n = new GraphNode(g, SWT.NONE, Messages.GraphSnippet11_Node1);
GraphNode n2 = new GraphNode(g, SWT.NONE, Messages.GraphSnippet11_Node2);
createConnection(g, n, n2, ColorConstants.darkGreen, 20);
createConnection(g, n, n2, ColorConstants.darkGreen, -20);
createConnection(g, n, n2, ColorConstants.darkBlue, 40);
Expand Down
Loading

0 comments on commit 274e5f8

Please sign in to comment.