adding functionality but the dialog wont show the panel
This commit is contained in:
parent
99977f1f38
commit
2143e9eaab
src/main/java/se/su/dsv/scipro
admin
match/dataobject
@ -14,9 +14,9 @@ public class AdminKeywordPage extends AbstractAdminMatchPage {
|
|||||||
|
|
||||||
public AdminKeywordPage(PageParameters pp) {
|
public AdminKeywordPage(PageParameters pp) {
|
||||||
super(pp);
|
super(pp);
|
||||||
add(new ManageKeywordPanel("manageWordKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.REGULAR), true));
|
add(new ManageKeywordPanel("manageWordKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.REGULAR), true, false));
|
||||||
add(new ManageKeywordPanel("manageUnitKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.UNIT), false));
|
add(new ManageKeywordPanel("manageUnitKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.UNIT), false, false));
|
||||||
add(new ManageKeywordPanel("manageAreaKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.RESEARCH_AREA), false));
|
add(new ManageKeywordPanel("manageAreaKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.RESEARCH_AREA), false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,22 @@
|
|||||||
<div wicket:id="editDialog">
|
<div wicket:id="editDialog">
|
||||||
<div wicket:id="dialogContent"></div>
|
<div wicket:id="dialogContent"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div wicket:id="manageDialog">
|
||||||
|
<div wicket:id="dialogContent"></div>
|
||||||
|
</div>
|
||||||
<a href=# wicket:id="createLink"><img
|
<a href=# wicket:id="createLink"><img
|
||||||
wicket:id="addIcon" alt="" />Create new keyword</a>
|
wicket:id="addIcon" alt="" />Create new keyword</a>
|
||||||
<form>
|
<form>
|
||||||
<table wicket:id="table" class="rounded-corner">
|
<table wicket:id="table" class="rounded-corner">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="rounded-left-top">Name</th><th>Type</th><th>Active</th><th class="rounded-right-top">Edit</th>
|
<th class="rounded-left-top">Name</th><th>Manage associations</th><th>Type</th><th>Active</th><th class="rounded-right-top">Edit</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr wicket:id="keywordsDataView">
|
<tr wicket:id="keywordsDataView">
|
||||||
<td><a href="#" wicket:id="detailsLink"><span wicket:id="name"></span></a></td>
|
<td><a href="#" wicket:id="detailsLink"><span wicket:id="name"></span></a></td>
|
||||||
|
<td><a wicket:id="manageAssociationsLink">Manage</a></td>
|
||||||
<td wicket:id="type"></td>
|
<td wicket:id="type"></td>
|
||||||
<td><a href="#" wicket:id="activeLink">
|
<td><a href="#" wicket:id="activeLink">
|
||||||
<img wicket:id="activeIcon" /></a></td>
|
<img wicket:id="activeIcon" /></a></td>
|
||||||
|
@ -16,33 +16,37 @@ import org.odlabs.wiquery.ui.dialog.Dialog;
|
|||||||
|
|
||||||
import se.su.dsv.scipro.components.LazyDeleteAjaxLink;
|
import se.su.dsv.scipro.components.LazyDeleteAjaxLink;
|
||||||
import se.su.dsv.scipro.icons.ImageObject;
|
import se.su.dsv.scipro.icons.ImageObject;
|
||||||
|
import se.su.dsv.scipro.keywords.KeywordContainer;
|
||||||
|
import se.su.dsv.scipro.keywords.SelectKeywordsPanel;
|
||||||
import se.su.dsv.scipro.match.dao.interfaces.KeywordDao;
|
import se.su.dsv.scipro.match.dao.interfaces.KeywordDao;
|
||||||
|
import se.su.dsv.scipro.match.dao.interfaces.KeywordTypeDao;
|
||||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||||
import se.su.dsv.scipro.match.dataprovider.KeywordsDataProvider;
|
import se.su.dsv.scipro.match.dataprovider.KeywordsDataProvider;
|
||||||
|
|
||||||
public class ManageKeywordPanel extends Panel {
|
public class ManageKeywordPanel extends Panel {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@SpringBean
|
|
||||||
private KeywordDao keywordDao;
|
|
||||||
|
|
||||||
private KeywordsDataProvider keywordsDataProvider;
|
|
||||||
|
|
||||||
private Dialog dialog;
|
|
||||||
private final WebMarkupContainer tableContainer;
|
|
||||||
private final DataView<Keyword> keywordsDataView;
|
|
||||||
|
|
||||||
public ManageKeywordPanel(String str, final KeywordType keywordType, final boolean isEditable) {
|
@SpringBean
|
||||||
super(str);
|
private KeywordDao keywordDao;
|
||||||
|
|
||||||
AjaxLink<Void> createLink = new AjaxLink<Void>("createLink"){
|
private KeywordsDataProvider keywordsDataProvider;
|
||||||
|
|
||||||
|
private Dialog dialog;
|
||||||
|
private Dialog dialog2;
|
||||||
|
private final WebMarkupContainer tableContainer;
|
||||||
|
private final DataView<Keyword> keywordsDataView;
|
||||||
|
|
||||||
|
public ManageKeywordPanel(String str, final KeywordType keywordType, final boolean isEditable, final boolean hasManageAssociations) {
|
||||||
|
super(str);
|
||||||
|
|
||||||
|
AjaxLink<Void> createLink = new AjaxLink<Void>("createLink") {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(AjaxRequestTarget target) {
|
public void onClick(AjaxRequestTarget target) {
|
||||||
dialog.replace(new EditKeywordPanel("dialogContent", new Model<Keyword>(new Keyword()),keywordType));
|
dialog.replace(new EditKeywordPanel("dialogContent", new Model<Keyword>(new Keyword()), keywordType));
|
||||||
target.addComponent(dialog);
|
target.addComponent(dialog);
|
||||||
dialog.setTitle("Add new keyword");
|
dialog.setTitle("Add new keyword");
|
||||||
dialog.open(target);
|
dialog.open(target);
|
||||||
@ -50,104 +54,139 @@ public class ManageKeywordPanel extends Panel {
|
|||||||
};
|
};
|
||||||
createLink.add(new ImageObject("addIcon", ImageObject.SIXTEEN + ImageObject.ADD));
|
createLink.add(new ImageObject("addIcon", ImageObject.SIXTEEN + ImageObject.ADD));
|
||||||
createLink.setVisible(isEditable);
|
createLink.setVisible(isEditable);
|
||||||
|
|
||||||
dialog = new Dialog("editDialog");
|
|
||||||
dialog.setModal(true);
|
|
||||||
dialog.setAutoOpen(false);
|
|
||||||
dialog.setWidth(400);
|
|
||||||
dialog.setHeight(225);
|
|
||||||
dialog.add(new EmptyPanel("dialogContent"));
|
|
||||||
dialog.setOutputMarkupId(true);
|
|
||||||
|
|
||||||
keywordsDataProvider = new KeywordsDataProvider(keywordType, true);
|
|
||||||
|
|
||||||
tableContainer = new WebMarkupContainer("table");
|
|
||||||
tableContainer.setOutputMarkupId(true);
|
|
||||||
|
|
||||||
keywordsDataView = new DataView<Keyword>("keywordsDataView", keywordsDataProvider) {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
dialog = new Dialog("editDialog");
|
||||||
protected void populateItem(final Item<Keyword> item) {
|
dialog.setModal(true);
|
||||||
item.setOutputMarkupId(true);
|
dialog.setAutoOpen(false);
|
||||||
final Keyword keyword = item.getModelObject();
|
dialog.setWidth(400);
|
||||||
|
dialog.setHeight(225);
|
||||||
final ImageObject editIcon = new ImageObject("editIcon", ImageObject.SIXTEEN + ImageObject.EDIT);
|
dialog.add(new EmptyPanel("dialogContent"));
|
||||||
|
dialog.setOutputMarkupId(true);
|
||||||
final AjaxLink<Void> editLink = new AjaxLink<Void>("editLink") {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onInitialize() {
|
|
||||||
super.onInitialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(AjaxRequestTarget target) {
|
|
||||||
target.addComponent(dialog);
|
|
||||||
dialog.setWidth(400);
|
|
||||||
dialog.setHeight(225);
|
|
||||||
dialog.setTitle("Edit keyword: " + item.getModelObject().getKeyword());
|
|
||||||
dialog.replace(new EditKeywordPanel("dialogContent", new Model<Keyword>(item.getModelObject()),null));
|
|
||||||
dialog.open(target);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
editLink.add(editIcon);
|
|
||||||
editLink.setVisible(isEditable);
|
|
||||||
LazyDeleteAjaxLink activeLink = new LazyDeleteAjaxLink("activeLink",
|
|
||||||
new PropertyModel<Boolean>(item.getModel(), "deleted")) {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Override
|
dialog2 = new Dialog("manageDialog");
|
||||||
public void onClick(AjaxRequestTarget target) {
|
dialog2.setModal(true);
|
||||||
super.onClick(target);
|
dialog2.setAutoOpen(false);
|
||||||
IModel<Keyword> model = item.getModel();
|
dialog2.setWidth(800);
|
||||||
model.setObject(keywordDao.save(model.getObject()));
|
dialog2.setHeight(600);
|
||||||
target.addComponent(tableContainer);
|
// dialog2.add(new EmptyPanel("dialogContent"));
|
||||||
}
|
dialog2.add(new Label("dialogContent", "bla bla"));
|
||||||
|
dialog2.setOutputMarkupId(true);
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getIconId() {
|
|
||||||
return "activeIcon";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
final AjaxLink<Void> keywordDetailsLink = new AjaxLink<Void>("detailsLink") {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1340379052190115333L;
|
keywordsDataProvider = new KeywordsDataProvider(keywordType, true);
|
||||||
|
|
||||||
@Override
|
tableContainer = new WebMarkupContainer("table");
|
||||||
public void onClick(AjaxRequestTarget target) {
|
tableContainer.setOutputMarkupId(true);
|
||||||
target.addComponent(dialog);
|
|
||||||
dialog.setWidth(500);
|
|
||||||
dialog.setHeight(580);
|
|
||||||
dialog.setTitle(keyword.getKeyword());
|
|
||||||
dialog.replace(new KeywordDetailsPanel("dialogContent", keyword) {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 8439790560385286282L;
|
keywordsDataView = new DataView<Keyword>("keywordsDataView", keywordsDataProvider) {
|
||||||
|
|
||||||
@Override
|
private static final long serialVersionUID = 1L;
|
||||||
public void onCloseButton(AjaxRequestTarget target) {
|
|
||||||
dialog.close(target);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.open(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
keywordDetailsLink.add(new Label("name", new Model<String>(keyword.getKeyword())));
|
|
||||||
item.add(keywordDetailsLink);
|
|
||||||
item.add(new Label("type", new Model<String>(keyword.getType().getName())));
|
|
||||||
item.add(editLink);
|
|
||||||
item.add(activeLink);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
@Override
|
||||||
tableContainer.add(keywordsDataView);
|
protected void populateItem(final Item<Keyword> item) {
|
||||||
add(createLink);
|
item.setOutputMarkupId(true);
|
||||||
add(dialog);
|
final Keyword keyword = item.getModelObject();
|
||||||
add(tableContainer);
|
|
||||||
}
|
final ImageObject editIcon = new ImageObject("editIcon", ImageObject.SIXTEEN + ImageObject.EDIT);
|
||||||
|
|
||||||
|
final AjaxLink<Void> editLink = new AjaxLink<Void>("editLink") {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onInitialize() {
|
||||||
|
super.onInitialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(AjaxRequestTarget target) {
|
||||||
|
target.addComponent(dialog);
|
||||||
|
dialog.setWidth(400);
|
||||||
|
dialog.setHeight(225);
|
||||||
|
dialog.setTitle("Edit keyword: " + item.getModelObject().getKeyword());
|
||||||
|
dialog.replace(new EditKeywordPanel("dialogContent", new Model<Keyword>(item.getModelObject()), null));
|
||||||
|
dialog.open(target);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
editLink.add(editIcon);
|
||||||
|
editLink.setVisible(isEditable);
|
||||||
|
LazyDeleteAjaxLink activeLink = new LazyDeleteAjaxLink("activeLink",
|
||||||
|
new PropertyModel<Boolean>(item.getModel(), "deleted")) {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(AjaxRequestTarget target) {
|
||||||
|
super.onClick(target);
|
||||||
|
IModel<Keyword> model = item.getModel();
|
||||||
|
model.setObject(keywordDao.save(model.getObject()));
|
||||||
|
target.addComponent(tableContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIconId() {
|
||||||
|
return "activeIcon";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final AjaxLink<Void> keywordDetailsLink = new AjaxLink<Void>("detailsLink") {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1340379052190115333L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(AjaxRequestTarget target) {
|
||||||
|
target.addComponent(dialog);
|
||||||
|
dialog.setWidth(500);
|
||||||
|
dialog.setHeight(580);
|
||||||
|
dialog.setTitle(keyword.getKeyword());
|
||||||
|
dialog.replace(new KeywordDetailsPanel("dialogContent", keyword) {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 8439790560385286282L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCloseButton(AjaxRequestTarget target) {
|
||||||
|
dialog.close(target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.open(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
keywordDetailsLink.add(new Label("name", new Model<String>(keyword.getKeyword())));
|
||||||
|
item.add(keywordDetailsLink);
|
||||||
|
item.add(new Label("type", new Model<String>(keyword.getType().getName())));
|
||||||
|
item.add(editLink);
|
||||||
|
item.add(activeLink);
|
||||||
|
|
||||||
|
|
||||||
|
item.add(new AjaxLink<Void>("manageAssociationsLink") {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(AjaxRequestTarget target) {
|
||||||
|
|
||||||
|
dialog2.replace(new SelectKeywordsPanel("dialogContent", new Model<KeywordContainer>(new KeywordContainer(item.getModelObject().getAssociatedKeywords())), KeywordTypeDao.TYPE.REGULAR, new String("blabla")) {
|
||||||
|
@Override
|
||||||
|
public void onUpdateAdd(AjaxRequestTarget target, Keyword addedKeyword) {
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdateRemove(AjaxRequestTarget target, Keyword removedKeyword) {
|
||||||
|
//To change body of implemented methods use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog2.open(target);
|
||||||
|
}
|
||||||
|
}.setVisible(hasManageAssociations));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
tableContainer.add(keywordsDataView);
|
||||||
|
add(createLink);
|
||||||
|
add(dialog);
|
||||||
|
add(dialog2);
|
||||||
|
add(tableContainer);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
|||||||
|
|
||||||
import se.su.dsv.scipro.data.dataobjects.LazyDeletableDomainObject;
|
import se.su.dsv.scipro.data.dataobjects.LazyDeletableDomainObject;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@ -28,7 +29,15 @@ public class Keyword extends LazyDeletableDomainObject {
|
|||||||
private KeywordType type;
|
private KeywordType type;
|
||||||
|
|
||||||
@ManyToMany
|
@ManyToMany
|
||||||
private Set<Keyword> associatedKeywords;
|
private Set<Keyword> associatedKeywords = new HashSet<Keyword>();
|
||||||
|
|
||||||
|
public Set<Keyword> getAssociatedKeywords() {
|
||||||
|
return associatedKeywords;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAssociatedKeywords(Set<Keyword> associatedKeywords) {
|
||||||
|
this.associatedKeywords = associatedKeywords;
|
||||||
|
}
|
||||||
|
|
||||||
public Keyword() {
|
public Keyword() {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user