Commit 5b757f9e authored by Nuno Oliveira's avatar Nuno Oliveira
Browse files

[GEOS-7348] Rules priority can be managed using drag and drop

parent eb197202
......@@ -17,6 +17,14 @@
<name>GeoFence Server</name>
<description>GeoFence security internal server</description>
<repositories>
<repository>
<id>wicket-dnd</id>
<name>Wicket-dnd Repository</name>
<url>http://wicket-dnd.googlecode.com/svn/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.googlecode.genericdao</groupId>
......@@ -120,6 +128,17 @@
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</dependency>
<dependency>
<groupId>wicket-dnd</groupId>
<artifactId>wicket-dnd</artifactId>
<version>0.4.2</version>
</dependency>
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>prototype</artifactId>
<version>1.4.7</version>
</dependency>
<!-- test dependencies -->
<dependency>
......
......@@ -10,6 +10,7 @@ import org.apache.wicket.ResourceReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.CSSPackageResource;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.geoserver.geofence.services.dto.ShortRule;
......@@ -18,6 +19,8 @@ import org.geoserver.web.wicket.GeoServerTablePanel;
import org.geoserver.web.wicket.ImageAjaxLink;
import org.geoserver.web.wicket.ParamResourceModel;
import org.geoserver.web.wicket.GeoServerDataProvider.Property;
import wicketdnd.*;
import wicketdnd.theme.WebTheme;
/**
* GeoFence Server wicket administration UI for GeoServer.
......@@ -75,6 +78,27 @@ public class GeofenceServerPage extends GeoServerSecuredPage {
target.addComponent(remove);
}
});
rulesPanel.add(CSSPackageResource.getHeaderContribution(new WebTheme()));
rulesPanel.add(new DragSource(Operation.MOVE).drag("tr"));
rulesPanel.add(new DropTarget(Operation.MOVE) {
public void onDrop(AjaxRequestTarget target, Transfer transfer, Location location) {
if (location == null || !(location.getComponent().getDefaultModel().getObject() instanceof ShortRule)) {
return;
}
ShortRule movedRule = transfer.getData();
ShortRule targetRule = (ShortRule) location.getComponent().getDefaultModel().getObject();
if (movedRule.getId().equals(targetRule.getId())) {
return;
}
if (movedRule.getPriority() < targetRule.getPriority()) {
movedRule.setPriority(targetRule.getPriority() + 1);
} else {
movedRule.setPriority(targetRule.getPriority());
}
rulesModel.save(movedRule);
doReturn(GeofenceServerPage.class);
}
}.dropCenter("tr"));
rulesPanel.setOutputMarkupId(true);
}
......
......@@ -136,8 +136,9 @@ public abstract class GeoServerTablePanel<T> extends Panel {
@Override
protected Item newItem(String id, int index, IModel model) {
// TODO Auto-generated method stub
return new OddEvenItem<T>(id, index, model);
OddEvenItem item = new OddEvenItem(id, index, model);
item.setOutputMarkupId(true);
return item;
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment