Changeset 5495


Ignore:
Timestamp:
07/28/14 15:34:59 (10 years ago)
Author:
Twan Goosen
Message:

Two click moving of references within collection. Refs #597

Location:
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/wizard/CreateVirtualCollectionWizard$ResourcesStep$ActionsPanel.html

    r5494 r5495  
    88  <a wicket:id="edit" href="#" class="edit"><span>[edit]</span></a>
    99  <a wicket:id="delete" href="#" class="delete"><span>[delete]</span></a>
    10   <a wicket:id="move" href="#" class="move"><span>[move]</span></a>
    11   <a wicket:id="target" href="#" class="target"><span>[insert before]</span></a>
    1210</wicket:panel>
    1311</body>
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/wizard/CreateVirtualCollectionWizard$ResourcesStep$MoveItemPanel.html

    r5494 r5495  
    66<body>
    77<wicket:panel>
    8   <a wicket:id="edit" href="#" class="edit"><span>[edit]</span></a>
    9   <a wicket:id="delete" href="#" class="delete"><span>[delete]</span></a>
    10   <a wicket:id="move" href="#" class="move"><span>[move]</span></a>
    11   <a wicket:id="target" href="#" class="target"><span>[insert before]</span></a>
     8  <a wicket:id="move" href="#" class="move" title="Move reference"><span>↕</span></a>
     9  <a wicket:id="target" href="#" class="target" title="Drop reference here"><span>⇒</span></a>
    1210</wicket:panel>
    1311</body>
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/wizard/CreateVirtualCollectionWizard.java

    r5494 r5495  
    1010import java.util.Iterator;
    1111import java.util.List;
     12import org.apache.wicket.AttributeModifier;
    1213import org.apache.wicket.Component;
    1314import org.apache.wicket.Session;
    1415import org.apache.wicket.ajax.AjaxRequestTarget;
    1516import org.apache.wicket.ajax.markup.html.AjaxLink;
     17import org.apache.wicket.behavior.AttributeAppender;
    1618import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
    1719import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
     
    4143import org.apache.wicket.markup.html.panel.Panel;
    4244import org.apache.wicket.markup.repeater.Item;
     45import org.apache.wicket.model.AbstractReadOnlyModel;
    4346import org.apache.wicket.model.CompoundPropertyModel;
    4447import org.apache.wicket.model.IModel;
     
    337340                new HeaderlessColumn<Creator>() {
    338341                    @Override
    339                     public void populateItem(
    340                             Item<ICellPopulator<Creator>> item,
    341                             String compontentId, IModel<Creator> model) {
     342                    public void populateItem(Item<ICellPopulator<Creator>> item, String compontentId, IModel<Creator> model) {
    342343                        item.add(new ActionsPanel(compontentId, model));
    343344                    }
     
    390391                        };
    391392                add(deleteLink);
     393            }
     394
     395        }
     396
     397        private final class MoveItemPanel extends Panel {
     398
     399            public MoveItemPanel(String id, final IModel<Resource> model) {
     400                super(id, model);
     401
    392402                final AjaxLink<Resource> moveLink
    393403                        = new AjaxLink<Resource>("move") {
     
    395405                            @Override
    396406                            public void onClick(AjaxRequestTarget target) {
    397                                 movingResource.setObject(model.getObject());
     407                                if (movingResource.getObject() == null) {
     408                                    // start moving this resource
     409                                    movingResource.setObject(model.getObject());
     410                                } else {
     411                                    // already moving, cancel
     412                                    movingResource.setObject(null);
     413                                }
    398414                                target.addComponent(resourcesContainer);
    399415                            }
     
    402418                            protected void onConfigure() {
    403419                                // only allow to start moving when not moving
    404                                 setVisible(movingResource.getObject() == null);
     420                                setVisible(movingResource.getObject() == null
     421                                        || model.getObject().equals(movingResource.getObject())
     422                                );
    405423                            }
    406424
     
    440458
    441459                        };
     460
    442461                add(targetLink);
    443462            }
     
    499518                                }
    500519                            },
    501                             64);
     520                            64) {
     521
     522                        @Override
     523                        protected Item<Resource> newRowItem(String id, int index, final IModel<Resource> model) {
     524                            final Item<Resource> item = super.newRowItem(id, index, model);
     525                            // mark the row that is being moved
     526                            item.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
     527
     528                                @Override
     529                                public String getObject() {
     530                                    if (model.getObject().equals(movingResource.getObject())) {
     531                                        return "moving";
     532                                    } else {
     533                                        return "";
     534                                    }
     535                                }
     536                            }, " "));
     537                            return item;
     538                        }
     539
     540                    };
    502541            resourcesTable.setOutputMarkupId(true);
     542
     543            // add 'moving' class if table is in moving mode
     544            resourcesTable.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {
     545
     546                @Override
     547                public String getObject() {
     548                    return movingResource.getObject() == null ? "" : "moving";
     549                }
     550            }, " "));
    503551            resourcesContainer.add(resourcesTable);
    504552
     
    586634        private IColumn<Resource>[] createColumns() {
    587635            final IColumn<?>[] columns = new IColumn<?>[]{
     636                new AbstractColumn<Resource>(Model.of("\u2195")) {
     637
     638                    @Override
     639                    public void populateItem(Item<ICellPopulator<Resource>> item, String componentId, IModel<Resource> model) {
     640                        item.add(new MoveItemPanel(componentId, model));
     641                    }
     642
     643                    @Override
     644                    public String getCssClass() {
     645                        return "move";
     646                    }
     647
     648                },
    588649                new AbstractColumn<Resource>(new Model<String>("Type")) {
    589650                    @Override
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/webapp/css/vcr.css

    r5416 r5495  
    602602}
    603603
     604table.resourcesTable tr td.move {
     605    width: 2em;
     606}
     607
     608table.resourcesTable tr td.move a {
     609    display: none;
     610}
     611
     612table.resourcesTable th.move {
     613    text-align: center;   
     614}
     615
     616table.resourcesTable tr:hover td.move a, table.resourcesTable tr.moving td.move a {
     617    display: inline-block;
     618    width: 100%;
     619    text-align: center;
     620}
     621
     622table.resourcesTable tr.moving {
     623    background: #ccc;
     624}
     625
     626table.resourcesTable tr.moving td, table.resourcesTable tr.moving td a {
     627    color: #333;
     628}
     629
    604630a {
    605631        color: #AE0000;
     
    639665table.resourcesTable {
    640666    width: 805px;
     667}
     668
     669table.moving tr:hover td {
     670    border-top: 2px solid;
    641671}
    642672
Note: See TracChangeset for help on using the changeset viewer.