Skip to content

Commit

Permalink
Cleanup and re-format Zest JFace snippets
Browse files Browse the repository at this point in the history
Applies the default format on the classes and removes obsolete/unused
methods.
  • Loading branch information
ptziegler authored and azoitl committed Dec 28, 2024
1 parent 1dd8b35 commit 9f7da2c
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ public Object[] getElements(Object inputElement) {
return new String[] { Messages.First, Messages.Second, Messages.Third };
}

public double getWeight(Object entity1, Object entity2) {
return 0;
}

@Override
public void dispose() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ static class MyContentProvider implements IGraphContentProvider {
public Object getDestination(Object rel) {
if (Messages.Rock2Paper.equals(rel)) {
return Messages.Rock;
} else if (Messages.Paper2Scissors.equals(rel)) {
}
if (Messages.Paper2Scissors.equals(rel)) {
return Messages.Paper;
} else if (Messages.Scissors2Rock.equals(rel)) {
return Messages.Scissors;
Expand All @@ -63,18 +64,15 @@ public Object[] getElements(Object input) {
public Object getSource(Object rel) {
if (Messages.Rock2Paper.equals(rel)) {
return Messages.Paper;
} else if (Messages.Paper2Scissors.equals(rel)) {
}
if (Messages.Paper2Scissors.equals(rel)) {
return Messages.Scissors;
} else if (Messages.Scissors2Rock.equals(rel)) {
return Messages.Rock;
}
return null;
}

public double getWeight(Object connection) {
return 0;
}

@Override
public void dispose() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ public Object getSource(Object rel) {
return parts[0];
}

public double getWeight(Object connection) {
return 0;
}

@Override
public void dispose() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import org.eclipse.swt.widgets.Shell;

import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.zest.core.viewers.GraphViewer;
import org.eclipse.zest.core.viewers.IGraphContentProvider;
Expand All @@ -37,9 +37,11 @@ static class MyContentProvider implements IGraphContentProvider {
public Object getDestination(Object rel) {
if (Messages.Rock2Paper.equals(rel)) {
return Messages.Rock;
} else if (Messages.Paper2Scissors.equals(rel)) {
}
if (Messages.Paper2Scissors.equals(rel)) {
return Messages.Paper;
} else if (Messages.Scissors2Rock.equals(rel)) {
}
if (Messages.Scissors2Rock.equals(rel)) {
return Messages.Scissors;
}
return null;
Expand All @@ -54,18 +56,16 @@ public Object[] getElements(Object input) {
public Object getSource(Object rel) {
if (Messages.Rock2Paper.equals(rel)) {
return Messages.Paper;
} else if (Messages.Paper2Scissors.equals(rel)) {
}
if (Messages.Paper2Scissors.equals(rel)) {
return Messages.Scissors;
} else if (Messages.Scissors2Rock.equals(rel)) {
}
if (Messages.Scissors2Rock.equals(rel)) {
return Messages.Rock;
}
return null;
}

public double getWeight(Object connection) {
return 0;
}

@Override
public void dispose() {
}
Expand Down Expand Up @@ -114,13 +114,12 @@ public static void main(String[] args) {

@Override
public void selectionChanged(SelectionChangedEvent event) {
System.out
.println("Selection Changed: " + selectionToString((StructuredSelection) event.getSelection())); //$NON-NLS-1$
System.out.println("Selection Changed: " + selectionToString(event.getStructuredSelection())); //$NON-NLS-1$
}

private String selectionToString(StructuredSelection selection) {
private String selectionToString(IStructuredSelection selection) {
StringBuffer stringBuffer = new StringBuffer();
Iterator iterator = selection.iterator();
Iterator<?> iterator = selection.iterator();
boolean first = true;
while (iterator.hasNext()) {
if (first) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ public void setElements(Object[] elements) {
this.elements = elements;
}

public double getWeight(Object connection) {
return 0;
}

@Override
public void dispose() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ public Object[] getElements(Object inputElement) {
return new String[] { Messages.First, Messages.Second, Messages.Third };
}

public double getWeight(Object entity1, Object entity2) {
return 0;
}

@Override
public void dispose() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ public Object[] getElements(Object inputElement) {
return new String[] { Messages.First, Messages.Second, Messages.Third };
}

public double getWeight(Object entity1, Object entity2) {
return 0;
}

@Override
public void dispose() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ public Object[] getElements(Object inputElement) {
return new String[] { Messages.First, Messages.Second, Messages.Third };
}

public double getWeight(Object entity1, Object entity2) {
return 0;
}

@Override
public void dispose() {

Expand Down Expand Up @@ -101,7 +97,7 @@ public void selfStyleConnection(Object element, GraphConnection connection) {
pc.setSourceDecoration(createDecoration(ColorConstants.green));
}

private PolygonDecoration createDecoration(final Color color) {
private static PolygonDecoration createDecoration(final Color color) {
PolygonDecoration decoration = new PolygonDecoration() {
@Override
protected void fillShape(Graphics g) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.zest.core.viewers.GraphViewer;
import org.eclipse.zest.core.viewers.IConnectionStyleProvider;
import org.eclipse.zest.core.viewers.IConnectionStyleProvider2;
import org.eclipse.zest.core.viewers.IEntityConnectionStyleProvider2;
import org.eclipse.zest.core.viewers.IGraphContentProvider;
Expand All @@ -40,8 +41,8 @@
import org.eclipse.draw2d.ManhattanConnectionRouter;

/**
* This snippet shows how to use the {@link IConnectionRouterStyleProvider}
* interface to set the connection router for some references.
* This snippet shows how to use the {@link IConnectionStyleProvider} interface
* to set the connection router for some references.
*
* Based on {@link GraphJFaceSnippet4}.
*
Expand Down Expand Up @@ -86,10 +87,6 @@ public Object getSource(Object rel) {
return null;
}

public double getWeight(Object connection) {
return 0;
}

@Override
public void dispose() {
}
Expand Down Expand Up @@ -118,6 +115,7 @@ public String getText(Object element) {

/* Relation-based customization: IConnectionStyleProvider */

@Override
public ConnectionRouter getRouter(Object rel) {
if (!rel.equals(Messages.Scissors2Rock)) {
return new ManhattanConnectionRouter();
Expand Down Expand Up @@ -237,7 +235,7 @@ public void selectionChanged(SelectionChangedEvent event) {

private String selectionToString(StructuredSelection selection) {
StringBuffer stringBuffer = new StringBuffer();
Iterator iterator = selection.iterator();
Iterator<?> iterator = selection.iterator();
boolean first = true;
while (iterator.hasNext()) {
if (first) {
Expand Down

0 comments on commit 9f7da2c

Please sign in to comment.