Skip to content
This repository was archived by the owner on Dec 31, 2020. It is now read-only.

Commit 6e19184

Browse files
committed
Seting up 0.3.1, fixing issue #18
1 parent a923857 commit 6e19184

File tree

12 files changed

+1174
-17
lines changed

12 files changed

+1174
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ target/
55
gridstack-demo/src/main/webapp/VAADIN/widgetsets/
66
gridstack-demo/src/main/webapp/VAADIN/themes/demo/addons.scss
77
*.scss.cache
8+
.DS_Store

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ Official releases of this add-on are available at Vaadin Directory. For Maven in
6060

6161
## Release notes
6262

63-
### Version 0.3.1 (TBD)
63+
### Version 0.3.1 (2016-07-20)
6464
- isAreaEmpty will now return false if area goes outside the right edge of layout
65+
- Client side now calls gridstack.js for it's children based on order of coordinates. Issue #18
6566

6667
### Version 0.3.0 (2016-05-18)
6768
- Possibility to move and resize already added children

gridstack-addon/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<groupId>org.vaadin.alump.gridstack</groupId>
66
<artifactId>gridstack-addon</artifactId>
77
<packaging>bundle</packaging>
8-
<version>0.3.1-SNAPSHOT</version>
8+
<version>0.3.1</version>
99
<name>GridStack Add-on</name>
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<vaadin.version>7.6.6</vaadin.version>
13+
<vaadin.version>7.6.8</vaadin.version>
1414
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
1515

1616
<!-- ZIP Manifest fields -->

gridstack-addon/src/main/java/org/vaadin/alump/gridstack/client/GridStackLayoutConnector.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,19 @@ public void onStateChanged(StateChangeEvent event) {
102102

103103
if(getWidget().isInitialized() && event.hasPropertyChanged("childOptions")) {
104104
getWidget().batchUpdate();
105-
//for(Connector connector : getChildConnectorsInCoordinateOrder()) {
106-
for(Connector connector : getState().childOptions.keySet()) {
105+
for(Connector connector : getChildConnectorsInCoordinateOrder()) {
107106
Widget widget = ((ComponentConnector)connector).getWidget();
108107
getWidget().updateChild(widget, getState().childOptions.get(connector));
109108
}
110109
getWidget().commit();
111110
}
112111
}
113112

114-
/* Uncomment this if connectors have to updated in coordinate order
113+
/**
114+
* Short child connectors to order based on their coordinates. This helps to get wanted order defined by server
115+
* side.
116+
* @return Children in order of coordinates
117+
*/
115118
private List<Connector> getChildConnectorsInCoordinateOrder() {
116119
List<Connector> list = new ArrayList<Connector>();
117120
for(Connector connector : getState().childOptions.keySet()) {
@@ -123,6 +126,9 @@ private List<Connector> getChildConnectorsInCoordinateOrder() {
123126
return list;
124127
}
125128

129+
/**
130+
* Compare child connectors by their coordinates
131+
*/
126132
private transient final Comparator<Connector> childConnectorComparator = new Comparator<Connector>() {
127133
@Override
128134
public int compare(Connector a, Connector b) {
@@ -158,7 +164,6 @@ public int compare(Connector a, Connector b) {
158164
return comp;
159165
}
160166
};
161-
*/
162167

163168
@Override
164169
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {

gridstack-demo/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<groupId>org.vaadin.alump.gridstack</groupId>
66
<artifactId>gridstack-demo</artifactId>
77
<packaging>war</packaging>
8-
<version>0.3.1-SNAPSHOT</version>
8+
<version>0.3.1</version>
99
<name>GridStack Add-on Demo</name>
1010

1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13-
<vaadin.version>7.6.6</vaadin.version>
13+
<vaadin.version>7.6.8</vaadin.version>
1414
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
1515
</properties>
1616

@@ -99,6 +99,11 @@
9999
<groupId>com.vaadin</groupId>
100100
<artifactId>vaadin-themes</artifactId>
101101
</dependency>
102+
<dependency>
103+
<groupId>org.vaadin.icons</groupId>
104+
<artifactId>vaadin-icons</artifactId>
105+
<version>1.0.1</version>
106+
</dependency>
102107
<dependency>
103108
<groupId>javax.servlet</groupId>
104109
<artifactId>javax.servlet-api</artifactId>

gridstack-demo/src/main/java/org/vaadin/alump/gridstack/demo/SplitView.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.vaadin.alump.gridstack.demo;
22

3+
import com.vaadin.navigator.Navigator;
34
import com.vaadin.navigator.View;
45
import com.vaadin.navigator.ViewChangeListener;
56
import com.vaadin.ui.*;
@@ -18,8 +19,18 @@
1819
public class SplitView extends HorizontalSplitPanel implements View {
1920

2021
public final static String VIEW_NAME = "split";
22+
23+
private Navigator navigator;
2124
private Random rand = new Random(0xDEADBEEF);
2225

26+
private final static int ORDER_A[] = {28, 17, 4, 22, 2, 15, 20, 29, 24, 9, 12, 14, 10, 11, 13, 5, 16, 1, 18,
27+
19, 6, 21, 3, 23, 8, 25, 26, 27, 0, 7};
28+
29+
private final static String ORDER_A_TEXT[] = {"XXVIII", "XVII", "IV", "XXII", "II", "XV", "XX", "XXIX", "XXIV",
30+
"IX", "XII", "XIV", "X", "XI", "XIII", "V", "XVI", "I", "XVIII", "XIX", "VI", "XXI", "III", "XXIII", "VIII",
31+
"XXV", "XXVI", "XXVII", "nulla", "VII"};
32+
33+
2334
private GridStackLayout gridStack;
2435

2536
public SplitView() {
@@ -41,18 +52,44 @@ private Component createLeftSide() {
4152
//moveRandomChildToAnotherFreePosition();
4253
GridStackDemoUtil.reorderAll(gridStack, rand, 1, 30);
4354
});
55+
shuffleButton.setWidth(100, Unit.PERCENTAGE);
4456
shuffleButton.addStyleName(ValoTheme.BUTTON_SMALL);
4557
layout.addComponent(shuffleButton);
4658

59+
Button orderAButton = new Button("Roman", e -> {
60+
AtomicInteger atIndex = new AtomicInteger(0);
61+
gridStack.iterator().forEachRemaining(iter -> {
62+
gridStack.moveAndResizeComponent(iter, 0, ORDER_A[atIndex.getAndIncrement()], 1, 1);
63+
});
64+
});
65+
orderAButton.setDescription("Order by roman numbers");
66+
orderAButton.setWidth(100, Unit.PERCENTAGE);
67+
orderAButton.addStyleName(ValoTheme.BUTTON_SMALL);
68+
layout.addComponent(orderAButton);
69+
4770
Button resetButton = new Button("Reset", e -> {
4871
AtomicInteger x = new AtomicInteger(0);
4972
gridStack.iterator().forEachRemaining(child -> {
5073
gridStack.moveComponent(child, 0, x.getAndAdd(gridStack.getCoordinates(child).getHeight()));
5174
});
5275
});
76+
resetButton.setWidth(100, Unit.PERCENTAGE);
5377
resetButton.addStyleName(ValoTheme.BUTTON_SMALL);
5478
layout.addComponent(resetButton);
5579

80+
Label expandLabel = new Label("");
81+
expandLabel.setSizeFull();
82+
layout.addComponent(expandLabel);
83+
layout.setExpandRatio(expandLabel, 1f);
84+
85+
Button toTestButton = new Button("Demo", e -> {
86+
navigator.navigateTo(TestView.VIEW_NAME);
87+
});
88+
toTestButton.setDescription("To main demo view");
89+
toTestButton.setWidth(100, Unit.PERCENTAGE);
90+
toTestButton.addStyleName(ValoTheme.BUTTON_SMALL);
91+
layout.addComponent(toTestButton);
92+
5693
return layout;
5794
}
5895

@@ -61,15 +98,15 @@ private Component createRightSide() {
6198
gridStack.setSizeFull();
6299

63100
for(int i = 0; i < 30; ++i) {
64-
Label itemLabel = new Label("Item #" + i);
101+
Label itemLabel = new Label("Item #" + i + " " + ORDER_A_TEXT[i]);
65102
gridStack.addComponent(itemLabel, 0, i);
66103
}
67104
return gridStack;
68105
}
69106

70107
@Override
71108
public void enter(ViewChangeListener.ViewChangeEvent event) {
72-
109+
navigator = event.getNavigator();
73110
}
74111

75112
private void moveRandomChildToAnotherFreePosition() {

gridstack-demo/src/main/java/org/vaadin/alump/gridstack/demo/TestView.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
package org.vaadin.alump.gridstack.demo;
22

33
import com.vaadin.event.LayoutEvents;
4+
import com.vaadin.navigator.Navigator;
45
import com.vaadin.navigator.View;
56
import com.vaadin.navigator.ViewChangeListener;
67
import com.vaadin.server.ExternalResource;
7-
import com.vaadin.server.FontAwesome;
88
import com.vaadin.server.Resource;
99
import com.vaadin.server.ThemeResource;
1010
import com.vaadin.ui.*;
1111
import com.vaadin.ui.themes.ValoTheme;
1212
import org.vaadin.alump.gridstack.GridStackButton;
1313
import org.vaadin.alump.gridstack.GridStackCoordinates;
1414
import org.vaadin.alump.gridstack.GridStackLayout;
15+
import org.vaadin.teemu.VaadinIcons;
1516

1617
import java.util.*;
1718
import java.util.concurrent.atomic.AtomicInteger;
@@ -23,6 +24,7 @@ public class TestView extends VerticalLayout implements View {
2324

2425
public final static String VIEW_NAME = "";
2526

27+
private Navigator navigator;
2628
private GridStackLayout gridStack;
2729

2830
private AtomicInteger eventCounter = new AtomicInteger(0);
@@ -96,7 +98,7 @@ public TestView() {
9698

9799
@Override
98100
public void enter(ViewChangeListener.ViewChangeEvent event) {
99-
101+
navigator = event.getNavigator();
100102
}
101103

102104
private Component createToolbar() {
@@ -105,7 +107,7 @@ private Component createToolbar() {
105107

106108
toolbar.addComponent(new Label("GridStack Demo"));
107109

108-
toolbar.addComponent(createButton(FontAwesome.PLUS, "Add component", e -> {
110+
toolbar.addComponent(createButton(VaadinIcons.PLUS, "Add component", e -> {
109111
int index = gridStack.getComponentCount();
110112
final CssLayout layout = new CssLayout();
111113
layout.addStyleName("hep-layout");
@@ -119,7 +121,7 @@ private Component createToolbar() {
119121
gridStack.addComponent(layout, CLIENT_SELECTS, CLIENT_SELECTS, 1 + rand.nextInt(3), 1);
120122
}));
121123

122-
toolbar.addComponent(createButton(FontAwesome.MINUS, "Remove component", e -> {
124+
toolbar.addComponent(createButton(VaadinIcons.TRASH, "Remove component", e -> {
123125
int index = rand.nextInt(gridStack.getComponentCount());
124126
Iterator<Component> iter = gridStack.iterator();
125127
for(int i = 0; i < index; ++i) {
@@ -139,10 +141,10 @@ private Component createToolbar() {
139141
});
140142
toolbar.addComponent(layoutClicks);
141143

142-
toolbar.addComponent(createButton(FontAwesome.ARROWS, "Move random child to new location",
144+
toolbar.addComponent(createButton(VaadinIcons.ARROWS, "Move random child to new location",
143145
e -> moveRandomChildToAnotherFreePosition()));
144146

145-
toolbar.addComponent(createButton(FontAwesome.RANDOM, "Reorder all items to new order", e -> reorderAll()));
147+
toolbar.addComponent(createButton(VaadinIcons.RANDOM, "Reorder all items to new order", e -> reorderAll()));
146148

147149
CheckBox staticGrid = new CheckBox("Static");
148150
staticGrid.setDescription("If static, dragging and resizing are not allowed by user");
@@ -158,6 +160,9 @@ private Component createToolbar() {
158160
});
159161
toolbar.addComponent(lockItem);
160162

163+
toolbar.addComponent(createButton(VaadinIcons.LIST, "Navigate to list demo",
164+
e -> navigator.navigateTo(SplitView.VIEW_NAME)));
165+
161166
return toolbar;
162167
}
163168

Binary file not shown.

0 commit comments

Comments
 (0)