Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Externalize Zest JFace examples #638

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,45 @@ public class Messages extends NLS {
public static String Paper;
public static String Rock;
public static String Scissors;
public static String Rock2Paper;
public static String Paper2Scissors;
public static String Scissors2Paper;
public static String Scissors2Rock;
public static String Information;
public static String Warning;
public static String Error;
public static String Root;
public static String One;
public static String Two;
public static String Three;
public static String First;
public static String Second;
public static String Third;
public static String Fourth;
//
public static String AnimationSnippet_Animate;
public static String AnimationSnippet_Title;
public static String CustomFigureJFaceSnippet_Title;
public static String CustomLayout_Title;
public static String GraphJFaceSnippet1_Title;
public static String GraphJFaceSnippet1_Reload;
public static String GraphJFaceSnippet2_Title;
public static String GraphJFaceSnippet3_Title;
public static String GraphJFaceSnippet4_Title;
public static String GraphJFaceSnippet5_Title;
public static String GraphJFaceSnippet5_Refresh;
public static String GraphJFaceSnippet6_Title;
public static String GraphJFaceSnippet6_Push;
public static String GraphJFaceSnippet7_Title;
public static String GraphJFaceSnippet7_Push;
public static String GraphJFaceSnippet7_Class;
public static String GraphJFaceSnippet7_Field_Columns;
public static String GraphJFaceSnippet7_Field_Rows;
public static String GraphJFaceSnippet7_Method_GetColumns;
public static String GraphJFaceSnippet7_Method_GetRows;
public static String GraphJFaceSnippet8_Title;
public static String GraphJFaceSnippet9_Title;
public static String GraphJFaceSnippet9_Reload;
public static String GraphSnippet1_Title;
public static String GraphSnippet10_Title;
public static String GraphSnippet10_ChangeCurve;
Expand Down Expand Up @@ -78,6 +109,7 @@ public class Messages extends NLS {
public static String LayoutExample_Node2;
public static String ManhattanLayoutGraphSnippet_Title;
public static String ManhattanLayoutGraphSnippet_ChangeRouter;
public static String ManhattanLayoutJFaceSnippet_Title;
public static String NestedGraphSnippet_Title;
public static String NestedGraphSnippet_Container1;
public static String NestedGraphSnippet_Container2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.zest.core.viewers.IGraphEntityContentProvider;
import org.eclipse.zest.core.widgets.ILabeledFigure;
import org.eclipse.zest.core.widgets.IStyleableFigure;
import org.eclipse.zest.examples.Messages;
import org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm;

import org.eclipse.draw2d.Graphics;
Expand Down Expand Up @@ -113,21 +114,21 @@ static class MyContentProvider implements IGraphEntityContentProvider {

@Override
public Object[] getConnectedTo(Object entity) {
if (entity.equals("One")) {
return new Object[] { "Two" };
if (entity.equals(Messages.One)) {
return new Object[] { Messages.Two };
}
if (entity.equals("Two")) {
return new Object[] { "Three" };
if (entity.equals(Messages.Two)) {
return new Object[] { Messages.Three };
}
if (entity.equals("Three")) {
return new Object[] { "One" };
if (entity.equals(Messages.Three)) {
return new Object[] { Messages.One };
}
return null;
}

@Override
public Object[] getElements(Object inputElement) {
return new String[] { "One", "Two", "Three" };
return new String[] { Messages.One, Messages.Two, Messages.Three };
}

@Override
Expand Down Expand Up @@ -177,7 +178,7 @@ public IFigure getFigure(Object element) {
public static void main(String[] args) {
Display d = new Display();
Shell shell = new Shell(d);
shell.setText("CustomFigureJFaceSnippet");
shell.setText(Messages.CustomFigureJFaceSnippet_Title);
shell.setLayout(new FillLayout(SWT.VERTICAL));
shell.setSize(400, 400);
viewer = new GraphViewer(shell, SWT.NONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.zest.core.viewers.GraphViewer;
import org.eclipse.zest.core.viewers.IGraphEntityContentProvider;
import org.eclipse.zest.examples.Messages;
import org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm;

/**
Expand All @@ -47,24 +48,24 @@

@Override
public Object[] getConnectedTo(Object entity) {
if (entity.equals("First")) {
return new Object[] { "Second" };
if (entity.equals(Messages.First)) {
return new Object[] { Messages.Second };
}
if (entity.equals("Second")) {
return new Object[] { "Third" };
if (entity.equals(Messages.Second)) {
return new Object[] { Messages.Third };
}
if (entity.equals("Third")) {
return new Object[] { "First" };
if (entity.equals(Messages.Third)) {
return new Object[] { Messages.First };
}
return null;
}

@Override
public Object[] getElements(Object inputElement) {
return new String[] { "First", "Second", "Third" };
return new String[] { Messages.First, Messages.Second, Messages.Third };
}

public double getWeight(Object entity1, Object entity2) {

Check warning on line 68 in org.eclipse.zest.examples/src/org/eclipse/zest/examples/jface/GraphJFaceSnippet1.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
return 0;
}

Expand Down Expand Up @@ -110,8 +111,9 @@
Display d = shell.getDisplay();
shell.setLayout(new FillLayout(SWT.VERTICAL));
shell.setSize(400, 400);
shell.setText(Messages.GraphJFaceSnippet1_Title);
Button button = new Button(shell, SWT.PUSH);
button.setText("Reload");
button.setText(Messages.GraphJFaceSnippet1_Reload);
button.addSelectionListener(new SelectionAdapter() {

@Override
Expand All @@ -125,7 +127,7 @@
viewer.setContentProvider(new MyContentProvider());
viewer.setLabelProvider(new MyLabelProvider());
viewer.setLayoutAlgorithm(new SpringLayoutAlgorithm());
viewer.addSelectionChangedListener(event -> System.out.println("Selection changed: " + (event.getSelection())));
viewer.addSelectionChangedListener(event -> System.out.println("Selection changed: " + (event.getSelection()))); //$NON-NLS-1$
viewer.setInput(new Object());

shell.open();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.zest.core.viewers.GraphViewer;
import org.eclipse.zest.core.viewers.IGraphContentProvider;
import org.eclipse.zest.examples.Messages;
import org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm;

/**
Expand All @@ -43,34 +44,34 @@

@Override
public Object getDestination(Object rel) {
if ("Rock2Paper".equals(rel)) {
return "Rock";
} else if ("Paper2Scissors".equals(rel)) {
return "Paper";
} else if ("Scissors2Rock".equals(rel)) {
return "Scissors";
if (Messages.Rock2Paper.equals(rel)) {
return Messages.Rock;
} else if (Messages.Paper2Scissors.equals(rel)) {
return Messages.Paper;
} else if (Messages.Scissors2Rock.equals(rel)) {
return Messages.Scissors;
}
return null;
}

@Override
public Object[] getElements(Object input) {
return new Object[] { "Rock2Paper", "Paper2Scissors", "Scissors2Rock" };
return new Object[] { Messages.Rock2Paper, Messages.Paper2Scissors, Messages.Scissors2Rock };
}

@Override
public Object getSource(Object rel) {
if ("Rock2Paper".equals(rel)) {
return "Paper";
} else if ("Paper2Scissors".equals(rel)) {
return "Scissors";
} else if ("Scissors2Rock".equals(rel)) {
return "Rock";
if (Messages.Rock2Paper.equals(rel)) {
return Messages.Paper;
} else if (Messages.Paper2Scissors.equals(rel)) {
return Messages.Scissors;
} else if (Messages.Scissors2Rock.equals(rel)) {
return Messages.Rock;
}
return null;
}

public double getWeight(Object connection) {

Check warning on line 74 in org.eclipse.zest.examples/src/org/eclipse/zest/examples/jface/GraphJFaceSnippet2.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
return 0;
}

Expand All @@ -89,7 +90,7 @@

@Override
public Image getImage(Object element) {
if (element.equals("Rock") || element.equals("Paper") || element.equals("Scissors")) {
if (element.equals(Messages.Rock) || element.equals(Messages.Paper) || element.equals(Messages.Scissors)) {
return image;
}
return null;
Expand All @@ -110,7 +111,7 @@
public static void main(String[] args) {
Shell shell = new Shell();
Display d = shell.getDisplay();
shell.setText("GraphJFaceSnippet2");
shell.setText(Messages.GraphJFaceSnippet2_Title);
shell.setLayout(new FillLayout(SWT.VERTICAL));
shell.setSize(400, 400);
viewer = new GraphViewer(shell, SWT.NONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.zest.core.viewers.GraphViewer;
import org.eclipse.zest.core.viewers.IGraphContentProvider;
import org.eclipse.zest.examples.Messages;
import org.eclipse.zest.layouts.algorithms.RadialLayoutAlgorithm;

/**
Expand Down Expand Up @@ -71,7 +72,7 @@
return parts[0];
}

public double getWeight(Object connection) {

Check warning on line 75 in org.eclipse.zest.examples/src/org/eclipse/zest/examples/jface/GraphJFaceSnippet3.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
return 0;
}

Expand All @@ -83,7 +84,7 @@
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (newInput != null) {
graph = new StringTokenizer((String) newInput, "\n"); //$NON-NLS-1$
graph = new StringTokenizer((String) newInput, System.lineSeparator());
}
}

Expand All @@ -94,7 +95,7 @@
public static void main(String[] args) throws IOException {
Shell shell = new Shell();
Display display = shell.getDisplay();
shell.setText("Simple Graph File Format"); //$NON-NLS-1$
shell.setText(Messages.GraphJFaceSnippet3_Title);

shell.setLayout(new FillLayout(SWT.VERTICAL));
shell.setSize(400, 400);
Expand All @@ -110,7 +111,7 @@
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
StringBuilder stringBuffer = new StringBuilder();
while (bufferedReader.ready()) {
stringBuffer.append(bufferedReader.readLine() + "\n"); //$NON-NLS-1$
stringBuffer.append(bufferedReader.readLine()).append(System.lineSeparator());
}
viewer.setInput(stringBuffer.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,42 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.zest.core.viewers.GraphViewer;
import org.eclipse.zest.core.viewers.IGraphContentProvider;
import org.eclipse.zest.examples.Messages;
import org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm;

public class GraphJFaceSnippet4 {
static class MyContentProvider implements IGraphContentProvider {

@Override
public Object getDestination(Object rel) {
if ("Rock2Paper".equals(rel)) {
return "Rock";
} else if ("Paper2Scissors".equals(rel)) {
return "Paper";
} else if ("Scissors2Rock".equals(rel)) {
return "Scissors";
if (Messages.Rock2Paper.equals(rel)) {
return Messages.Rock;
} else if (Messages.Paper2Scissors.equals(rel)) {
return Messages.Paper;
} else if (Messages.Scissors2Rock.equals(rel)) {
return Messages.Scissors;
}
return null;
}

@Override
public Object[] getElements(Object input) {
return new Object[] { "Rock2Paper", "Paper2Scissors", "Scissors2Rock" };
return new Object[] { Messages.Rock2Paper, Messages.Paper2Scissors, Messages.Scissors2Rock };
}

@Override
public Object getSource(Object rel) {
if ("Rock2Paper".equals(rel)) {
return "Paper";
} else if ("Paper2Scissors".equals(rel)) {
return "Scissors";
} else if ("Scissors2Rock".equals(rel)) {
return "Rock";
if (Messages.Rock2Paper.equals(rel)) {
return Messages.Paper;
} else if (Messages.Paper2Scissors.equals(rel)) {
return Messages.Scissors;
} else if (Messages.Scissors2Rock.equals(rel)) {
return Messages.Rock;
}
return null;
}

public double getWeight(Object connection) {

Check warning on line 65 in org.eclipse.zest.examples/src/org/eclipse/zest/examples/jface/GraphJFaceSnippet4.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
return 0;
}

Expand All @@ -80,7 +81,7 @@

@Override
public Image getImage(Object element) {
if (element.equals("Rock") || element.equals("Paper") || element.equals("Scissors")) {
if (element.equals(Messages.Rock) || element.equals(Messages.Paper) || element.equals(Messages.Scissors)) {
return image;
}
return null;
Expand All @@ -101,7 +102,7 @@
public static void main(String[] args) {
Shell shell = new Shell();
Display d = shell.getDisplay();
shell.setText("GraphJFaceSnippet2");
shell.setText(Messages.GraphJFaceSnippet4_Title);
shell.setLayout(new FillLayout(SWT.VERTICAL));
shell.setSize(400, 400);
viewer = new GraphViewer(shell, SWT.NONE);
Expand All @@ -114,18 +115,18 @@
@Override
public void selectionChanged(SelectionChangedEvent event) {
System.out
.println("Selection Changed: " + selectionToString((StructuredSelection) event.getSelection()));
.println("Selection Changed: " + selectionToString((StructuredSelection) event.getSelection())); //$NON-NLS-1$
}

private String selectionToString(StructuredSelection selection) {
StringBuffer stringBuffer = new StringBuffer();
Iterator iterator = selection.iterator();

Check warning on line 123 in org.eclipse.zest.examples/src/org/eclipse/zest/examples/jface/GraphJFaceSnippet4.java

View check run for this annotation

Jenkins - Eclipse GEF / Java Compiler

tycho-compiler:compile

NORMAL:
boolean first = true;
while (iterator.hasNext()) {
if (first) {
first = false;
} else {
stringBuffer.append(" : ");
stringBuffer.append(" : "); //$NON-NLS-1$
}
stringBuffer.append(iterator.next());
}
Expand Down
Loading
Loading