Skip to content

Commit af2a597

Browse files
committed
Upgrade plugin to support Vaadin 8
Change-Id: If878ccc4789bff8498a392c124ff882be11ee7af
1 parent 199633a commit af2a597

File tree

7 files changed

+59
-100
lines changed

7 files changed

+59
-100
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
eclipse.preferences.version=1
22
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4-
org.eclipse.jdt.core.compiler.compliance=1.6
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.compliance=1.8
55
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
66
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
77
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
8-
org.eclipse.jdt.core.compiler.source=1.6
8+
org.eclipse.jdt.core.compiler.source=1.8

.settings/org.eclipse.wst.common.project.facet.core.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
<installed facet="jst.web" version="2.4"/>
88
<installed facet="com.vaadin.integration.eclipse.core" version="7.0"/>
99
<installed facet="wst.jsdt.web" version="1.0"/>
10-
<installed facet="java" version="1.6"/>
10+
<installed facet="java" version="1.8"/>
1111
</faceted-project>

pom.xml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
<groupId>org.vaadin.addons</groupId>
77
<artifactId>graph-explorer</artifactId>
8-
<packaging>jar</packaging>
9-
<version>0.7.3</version>
8+
<packaging>bundle</packaging>
9+
<version>0.8.0</version>
1010
<name>Graph Explorer (Vaadin 7)</name>
1111

1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14-
<vaadin.version>7.7.6</vaadin.version>
14+
<vaadin.version>8.0.0</vaadin.version>
1515
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
1616

1717
<gwt-graphics.version>1.0.0</gwt-graphics.version>
@@ -21,7 +21,7 @@
2121
<Implementation-Version>${project.version}</Implementation-Version>
2222
<!-- Must not change this because of the Directory -->
2323
<Implementation-Title>${project.name}</Implementation-Title>
24-
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
24+
<Implementation-Vendor>Vaadin Community</Implementation-Vendor>
2525
<Vaadin-License-Title>Apache License 2.0</Vaadin-License-Title>
2626
<Vaadin-Addon>${project.artifactId}-${project.version}.jar</Vaadin-Addon>
2727
</properties>
@@ -114,8 +114,8 @@
114114
<artifactId>maven-compiler-plugin</artifactId>
115115
<version>3.0</version>
116116
<configuration>
117-
<source>1.6</source>
118-
<target>1.6</target>
117+
<source>1.8</source>
118+
<target>1.8</target>
119119
</configuration>
120120
</plugin>
121121

@@ -169,6 +169,19 @@
169169
</executions>
170170
</plugin>
171171

172+
<plugin>
173+
<groupId>org.apache.felix</groupId>
174+
<artifactId>maven-bundle-plugin</artifactId>
175+
<version>2.5.3</version>
176+
<extensions>true</extensions>
177+
<configuration>
178+
<instructions>
179+
<Export-Package>!com.vaadin.graph.client,com.vaadin.graph.*</Export-Package>
180+
<Import-Package>!com.google.gwt.*,!com.vaadin.client.*,!org.vaadin.gwtgraphics.*,*</Import-Package>
181+
</instructions>
182+
</configuration>
183+
</plugin>
184+
172185
<plugin>
173186
<groupId>org.apache.maven.plugins</groupId>
174187
<artifactId>maven-assembly-plugin</artifactId>

src/main/java/com/vaadin/graph/GraphController.java

Lines changed: 31 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@
2121
import java.util.Map;
2222
import java.util.Set;
2323
import java.util.StringTokenizer;
24+
import java.util.stream.Collectors;
2425

25-
import com.vaadin.event.FieldEvents.TextChangeEvent;
26-
import com.vaadin.event.FieldEvents.TextChangeListener;
26+
import com.vaadin.data.ValueProvider;
27+
import com.vaadin.data.provider.ListDataProvider;
2728
import com.vaadin.graph.shared.ArcProxy;
2829
import com.vaadin.graph.shared.NodeProxy;
2930
import com.vaadin.graph.shared.NodeProxy.NodeKind;
3031
import com.vaadin.graph.shared.NodeProxy.NodeState;
3132
import com.vaadin.server.ResourceReference;
32-
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
3333
import com.vaadin.ui.CustomComponent;
34-
import com.vaadin.ui.Table;
35-
import com.vaadin.ui.Table.ColumnHeaderMode;
34+
import com.vaadin.ui.Grid;
35+
import com.vaadin.ui.Grid.Column;
36+
import com.vaadin.ui.Grid.SelectionMode;
3637
import com.vaadin.ui.TextField;
37-
import com.vaadin.ui.VerticalLayout;
38+
import com.vaadin.ui.components.grid.HeaderRow;
3839

3940
/**
4041
* Graph visualization controller component used to control/override graph construction and visualization.
@@ -162,66 +163,44 @@ public NodeSelector getMemberSelector(final String groupId, final GraphRepositor
162163
@SuppressWarnings("serial")
163164
class SelectorUI extends CustomComponent implements NodeSelector {
164165

165-
private static final String NODENAME = "nodename";
166-
Table matchList = new Table();
167-
private final Map<String, String> members = new HashMap<String, String>();
166+
protected final Grid<N> matchList;
167+
protected final ListDataProvider<N> members;
168168

169169
public SelectorUI() {
170-
VerticalLayout layout = new VerticalLayout();
171-
170+
matchList = new Grid<>();
171+
matchList.setSizeFull();
172+
matchList.setSelectionMode(SelectionMode.MULTI);
173+
Column<N, String> column = matchList.addColumn((node) -> getNodeLabel(node)).setCaption("");
174+
172175
TextField stringMatcher = new TextField();
173-
layout.addComponent(stringMatcher);
174176
stringMatcher.setWidth(100, Unit.PERCENTAGE);
175177

176-
layout.addComponent(matchList);
177-
layout.setExpandRatio(matchList, 1.0f);
178-
matchList.setSizeFull();
179-
matchList.setPageLength(40);
180-
181-
matchList.setSelectable(true);
182-
matchList.setMultiSelect(true);
183-
matchList.addContainerProperty(NODENAME, String.class, "");
184-
matchList.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
185-
186-
stringMatcher.setTextChangeEventMode(TextChangeEventMode.LAZY);
178+
HeaderRow header = matchList.getHeaderRow(0);
179+
header.getCell(column).setComponent(stringMatcher);
187180

188181
StringTokenizer tokenizer = new StringTokenizer(groupId);
189182
String parentId = tokenizer.nextToken();
190-
N parent = repository.getNodeById(parentId);
191-
for (A arc : groups.get(groupId).values()) {
192-
N child = repository.getOpposite(parent, arc);
193-
String id = child.getId();
194-
String label = getNodeLabel(child);
195-
members.put(id, label);
196-
matchList.addItem(id);
197-
matchList.getContainerProperty(id, NODENAME).setValue(label);
198-
}
183+
final N parent = repository.getNodeById(parentId);
184+
members = new ListDataProvider<N>(
185+
groups.get(groupId).values().stream().map((arc) -> repository.getOpposite(parent, arc)).collect(Collectors.toList()));
186+
matchList.setDataProvider(members);
199187

200-
stringMatcher.addTextChangeListener(new TextChangeListener() {
201-
public void textChange(TextChangeEvent event) {
202-
String query = event.getText().toLowerCase().replaceAll("\\s", "");
203-
matchList.removeAllItems();
204-
for (Map.Entry<String, String> entry : members.entrySet()) {
205-
String nodeId = entry.getKey();
206-
String value = entry.getValue();
207-
if (value.toLowerCase().replaceAll("\\s", "").contains(query)) {
208-
matchList.addItem(nodeId);
209-
matchList.getContainerProperty(nodeId, NODENAME).setValue(value);
210-
}
188+
stringMatcher.addValueChangeListener(event -> {
189+
members.setFilter(ValueProvider.identity(), node -> {
190+
if (node == null) {
191+
return false;
211192
}
212-
}
193+
String nodeLabel = getNodeLabel(node).toLowerCase().replaceAll("\\s", "");
194+
String filter = event.getValue().toLowerCase().replaceAll("\\s", "");
195+
return nodeLabel.contains(filter);
196+
});
213197
});
214-
layout.setSizeFull();
215-
setCompositionRoot(layout);
198+
setCompositionRoot(matchList);
216199
setSizeFull();
217200
}
218201

219202
public Collection<String> getSelectedNodeIds() {
220-
Collection<String> match = (Collection<String>) matchList.getValue();
221-
if (match.size() == 0) {
222-
return (Collection<String>) matchList.getItemIds();
223-
}
224-
return match;
203+
return matchList.getSelectedItems().stream().map((node) -> node.getId()).collect(Collectors.toList());
225204
}
226205

227206
}
@@ -244,7 +223,7 @@ protected NodeProxy load(Node node, LayoutEngineModel model) {
244223
return p;
245224
}
246225

247-
public Collection<NodeProxy> loadMembers(String groupId, Collection<String> memberIds, GraphRepository<N, A> repository, LayoutEngineModel model) {
226+
public Collection<NodeProxy> loadMembers(String groupId, Iterable<String> memberIds, GraphRepository<N, A> repository, LayoutEngineModel model) {
248227
StringTokenizer tokenizer = new StringTokenizer(groupId);
249228
final String parentId = tokenizer.nextToken();
250229
final N parent = repository.getNodeById(parentId);

src/main/java/com/vaadin/graph/client/GraphProxy.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
*/
1616
package com.vaadin.graph.client;
1717

18-
import java.util.*;
18+
import java.util.Collection;
19+
import java.util.Collections;
20+
import java.util.HashMap;
21+
import java.util.Map;
1922

2023
/**
2124
* Client-side proxy of the server-side graph model.

src/main/java/com/vaadin/graph/client/NodePresenter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Set;
2121

2222
import com.google.gwt.animation.client.Animation;
23+
import com.google.gwt.dom.client.Element;
2324
import com.google.gwt.dom.client.Style;
2425
import com.google.gwt.dom.client.Style.Unit;
2526
import com.google.gwt.event.dom.client.MouseDownEvent;
@@ -29,7 +30,6 @@
2930
import com.google.gwt.event.dom.client.MouseUpEvent;
3031
import com.google.gwt.event.dom.client.MouseUpHandler;
3132
import com.google.gwt.user.client.DOM;
32-
import com.google.gwt.user.client.Element;
3333
import com.google.gwt.user.client.Window;
3434
import com.google.gwt.user.client.ui.HTML;
3535
import com.vaadin.graph.shared.NodeProxy;

src/main/resources/com/vaadin/graph/GraphExplorerWidgetset.gwt.xml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,6 @@
77
<inherits name="com.vaadin.DefaultWidgetSet" />
88
<inherits name="org.vaadin.gwtgraphics.GWTGraphics" />
99

10-
<!--
11-
Uncomment the following to compile the widgetset for one browser only.
12-
This can reduce the GWT compilation time significantly when debugging.
13-
The line should be commented out before deployment to production
14-
environments.
15-
16-
Multiple browsers can be specified for GWT 1.7 as a comma separated
17-
list. The supported user agents at the moment of writing were:
18-
ie6,ie8,gecko,gecko1_8,safari,opera
19-
20-
The value gecko1_8 is used for Firefox 3 and later and safari is used for
21-
webkit based browsers including Google Chrome.
22-
-->
23-
<!-- <set-property name="user.agent" value="gecko1_8"/> -->
24-
25-
<!--
26-
To enable SuperDevMode, uncomment this line.
27-
28-
SuperDevMode enables debugging of the client side of a Vaadin
29-
application using the JavaScript debugger of a browser. Java code is
30-
shown and debugging can take place on the Java level when using a browser
31-
that support source maps (currently Chrome, implementation under work
32-
for Firefox).
33-
34-
After uncommenting this property, compile the widgetset once and then
35-
start the SuperDevMode server process in parallel with your normal
36-
server. Then add the command line parameter ?superdevmode to your
37-
application URL. Vaadin Eclipse plug-in can create a launch for the
38-
SuperDevMode server (Project Properties... -> Vaadin).
39-
40-
See https://vaadin.com/wiki/-/wiki/Main/Using%20SuperDevMode for more
41-
information and instructions.
42-
-->
43-
<!-- <set-configuration-property name="devModeRedirectEnabled" value="true" /> -->
44-
45-
4610
<!-- Fix GWTGraphics binding in case of IE10 (should actually be in org/vaadin/gwtgraphics/GWTGraphics.gwt.xml)-->
4711
<replace-with class='org.vaadin.gwtgraphics.client.impl.SVGImpl'>
4812
<when-type-is class='org.vaadin.gwtgraphics.client.impl.SVGImpl'/>

0 commit comments

Comments
 (0)