Changeset 841


Ignore:
Timestamp:
11/03/10 18:33:18 (14 years ago)
Author:
oschonef
Message:
  • add keywords editing stuff
Location:
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main
Files:
2 added
5 edited

Legend:

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

    r820 r841  
    66<body>
    77<wicket:panel>
     8<div style="display: none" wicket:id="addKeywordDialog"></div>
     9<div style="display: none" wicket:id="deleteKeywordDialog"></div>
    810<fieldset>
    911  <div class="notes">
     
    4143  </div>
    4244  <div class="optional">
    43     <label for="gen_vc_reproducibility_keywords">Keywords</label>
    44     <textarea id="gen_vc_reproducibility_keywords"
    45               cols="40" rows="5"></textarea>
     45    <label>Keywords<br /><a href="#"
     46      wicket:id="keywordsAdd" class="add"><span>[add]</span></a></label>
     47    <div wicket:id="keywordsList" class="keywordsList">
     48      <ul>
     49        <li wicket:id="keywords">
     50          <span wicket:id="itemText">item text</span>
     51          <a wicket:id="itemRemove" href="#"><span class="remove">[remove]</span></a>
     52        </li>
     53      </ul>
     54    </div>
    4655  </div>
    4756</fieldset>
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/wizard/CreateVirtualCollectionWizard.java

    r824 r841  
    33import java.util.Arrays;
    44import java.util.Iterator;
     5import java.util.List;
    56
    67import org.apache.wicket.ajax.AjaxRequestTarget;
    78import org.apache.wicket.ajax.markup.html.AjaxLink;
     9import org.apache.wicket.behavior.AttributeAppender;
    810import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
    911import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
     
    1719import org.apache.wicket.extensions.wizard.dynamic.DynamicWizardStep;
    1820import org.apache.wicket.extensions.wizard.dynamic.IDynamicWizardStep;
     21import org.apache.wicket.markup.html.WebMarkupContainer;
    1922import org.apache.wicket.markup.html.basic.Label;
    2023import org.apache.wicket.markup.html.form.DropDownChoice;
     
    2629import org.apache.wicket.markup.html.form.TextField;
    2730import org.apache.wicket.markup.html.form.validation.AbstractFormValidator;
     31import org.apache.wicket.markup.html.list.ListItem;
     32import org.apache.wicket.markup.html.list.ListView;
    2833import org.apache.wicket.markup.html.panel.Panel;
    2934import org.apache.wicket.markup.repeater.Item;
     35import org.apache.wicket.model.AbstractReadOnlyModel;
    3036import org.apache.wicket.model.CompoundPropertyModel;
    3137import org.apache.wicket.model.IModel;
     
    4349public class CreateVirtualCollectionWizard extends WizardBase {
    4450    private final class GeneralStep extends DynamicWizardStep {
     51        private final class DeleteKeywordDialog extends ConfirmationDialog {
     52            private transient KeywordsList keywordList;
     53            private String keyword;
     54           
     55            public DeleteKeywordDialog(String id, KeywordsList keywordList) {
     56                super(id);
     57                this.keywordList = keywordList;
     58            }
     59
     60            @Override
     61            public void onConfirm(AjaxRequestTarget target) {
     62                vc.getKeywords().remove(keyword);
     63                target.addComponent(keywordList);
     64            }
     65           
     66            public void show(AjaxRequestTarget target, String keyword) {
     67                this.keyword = keyword;
     68                super.show(target, new StringResourceModel("keywords.deleteconfirm", null, new Object[] { keyword }));
     69            }
     70        } // class CreateVirtualCollectionWizard.GeneralStep.DeleteKeywordDialog
     71
     72        private final class KeywordsList extends WebMarkupContainer {
     73            private final ListView<String> itemsView;
     74
     75            public KeywordsList(String id, final List<String> items) {
     76                super(id);
     77                setOutputMarkupId(true);
     78
     79                itemsView = new ListView<String>("keywords", items) {
     80                    @Override
     81                    protected void populateItem(final ListItem<String> item) {
     82                        final IModel<String> model = item.getModel();
     83                        item.add(new Label("itemText", model.getObject()));
     84                        item.add(new AjaxLink<String>("itemRemove",
     85                                new Model<String>("[remove]")) {
     86                            @Override
     87                            public void onClick(AjaxRequestTarget target) {
     88                                deleteKeywordDialog.show(target,
     89                                        model.getObject());
     90                            }
     91                        });
     92                        item.add(new AttributeAppender("class",
     93                                new AbstractReadOnlyModel<String>() {
     94                                    public String getObject() {
     95                                        if (item.getIndex() == 0) {
     96                                            return "first odd";
     97                                        }
     98                                        return (item.getIndex() % 2 == 1) ?
     99                                                    "even" : "odd";
     100                                    }
     101                                }, " "));
     102                    }
     103                };
     104                add(itemsView);
     105            }
     106        } // class CreateVirtualCollectionWizard.GeneralStep.KeywordsList
     107
     108        private final AddKeywordDialog addKeywordDialog;
     109        private final DeleteKeywordDialog deleteKeywordDialog;
     110
    45111        public GeneralStep() {
    46112            super(null, "General", "Yada yada yada ...");
     
    64130            add(reproducibilityChoice);
    65131            add(new TextArea<String>("vc.reproducibilityNotice"));
     132           
     133            final KeywordsList keywordList =
     134                new KeywordsList("keywordsList", vc.getKeywords());
     135            add(keywordList);
     136            add(new AjaxLink<String>("keywordsAdd") {
     137                @Override
     138                public void onClick(AjaxRequestTarget target) {
     139                    addKeywordDialog.show(target);
     140                }
     141            });
     142
     143            addKeywordDialog = new AddKeywordDialog("addKeywordDialog") {
     144                @Override
     145                public void onSubmit(AjaxRequestTarget target, String keyword) {
     146                    if (!vc.getKeywords().contains(keyword)) {
     147                        vc.getKeywords().add(keyword);
     148                    }
     149                    target.addComponent(keywordList);
     150                }
     151            };
     152            add(addKeywordDialog);
     153
     154            deleteKeywordDialog =
     155                new DeleteKeywordDialog("deleteKeywordDialog", keywordList);
     156            add(deleteKeywordDialog);
    66157        }
    67158
     
    505596        System.err.println("Rep: " + vc.getReproducibility());
    506597        System.err.println("RepNot: " + vc.getReproducibilityNotice());
     598        for (String kw : vc.getKeywords()) {
     599            System.err.println("KW: " + kw);
     600        }
    507601        for (Creator c : vc.getCreators()) {
    508602            System.err.println("C: " + c.getName() + ", " + c.getEMail());
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/gui/wizard/CreateVirtualCollectionWizard.properties

    r817 r841  
    1010Type.METADATA: Metadata
    1111Type.RESOURCE: Resource
     12keywords.deleteconfirm: Do you really want to delete "{0}"?
    1213creators.deleteconfirm: Do you really want to delete "${name}"?
    1314resources.deleteconfirm: Do you really want to delete "${ref}"?
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/model/Creator.java

    r804 r841  
    104104    }
    105105
     106    @Override
     107    public String toString() {
     108        StringBuilder sb = new StringBuilder("Creator@");
     109        sb.append(Integer.toHexString(hashCode()));
     110        sb.append("[");
     111        sb.append("name=");
     112        sb.append(name);
     113        if (email != null) {
     114            sb.append(",email=");
     115            sb.append(email);
     116        }
     117        if (organisation != null) {
     118            sb.append(",organisation=");
     119            sb.append(organisation);
     120        }
     121        sb.append("]");
     122        return sb.toString();
     123    }
     124
    106125} // class Creator
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/webapp/css/vcr.css

    r824 r841  
    307307}
    308308
     309/*
    309310div.optional label:after {
    310311  content: ':';
     
    314315  content: ':';
    315316}
     317*/
    316318
    317319form.wizard textarea {
     
    458460}
    459461
     462/*
    460463form.wizard .buttonbar input.button,
    461 div.modalDialog div.modalDialogButtons input.button {
     464div.modalDialog div.modalDialogButtons input.button
     465*/
     466input.button {
    462467        padding: 1px 4px;
    463468        margin: 0 2px;
     
    483488}
    484489
    485 /* modal dialog */
     490
     491/*
     492 * modal dialog
     493 */
    486494div.modalDialog {
    487495        margin: 0;
     
    519527}
    520528
     529
    521530/*
    522531 * dialog customizations
     
    547556div.addResourcesDialog fieldset textarea {
    548557    width: 460px;
     558}
     559
     560div.addKeywordDialog fieldset input {
     561        width: 285px;
    549562}
    550563
     
    580593}
    581594
    582 div.wizard a.add,
    583 div.wizard a.addMore,   
    584 div.wizard table td.action a {
     595a {
    585596        color: #AE0000;
    586597        background-color: inherit;
     
    614625        width: 60px;
    615626}
     627
     628div.keywordsList {
     629        clear: none !important;
     630        width: 602px;
     631        margin-left: 160px;
     632        padding: 3px 0;
     633}
     634
     635div.keywordsList div {
     636        clear: none;
     637}
     638
     639div.keywordsList ul {
     640    list-style-type: square;
     641    margin: 0;
     642    padding: 0 0 0 16px;
     643}
     644
     645div.keywordsList ul li {
     646        margin-top: 2px;
     647}
     648
     649div.keywordsList ul li.first {
     650    margin-top: 0;
     651}
Note: See TracChangeset for help on using the changeset viewer.