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) {
|
||||
super(pp);
|
||||
add(new ManageKeywordPanel("manageWordKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.REGULAR), true));
|
||||
add(new ManageKeywordPanel("manageUnitKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.UNIT), false));
|
||||
add(new ManageKeywordPanel("manageAreaKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.RESEARCH_AREA), false));
|
||||
add(new ManageKeywordPanel("manageWordKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.REGULAR), true, false));
|
||||
add(new ManageKeywordPanel("manageUnitKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.UNIT), false, false));
|
||||
add(new ManageKeywordPanel("manageAreaKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.RESEARCH_AREA), false, true));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,18 +6,22 @@
|
||||
<div wicket:id="editDialog">
|
||||
<div wicket:id="dialogContent"></div>
|
||||
</div>
|
||||
<div wicket:id="manageDialog">
|
||||
<div wicket:id="dialogContent"></div>
|
||||
</div>
|
||||
<a href=# wicket:id="createLink"><img
|
||||
wicket:id="addIcon" alt="" />Create new keyword</a>
|
||||
<form>
|
||||
<table wicket:id="table" class="rounded-corner">
|
||||
<thead>
|
||||
<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>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr wicket:id="keywordsDataView">
|
||||
<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><a href="#" wicket:id="activeLink">
|
||||
<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.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.KeywordTypeDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
import se.su.dsv.scipro.match.dataprovider.KeywordsDataProvider;
|
||||
|
||||
public class ManageKeywordPanel extends Panel {
|
||||
|
||||
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;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ManageKeywordPanel(String str, final KeywordType keywordType, final boolean isEditable) {
|
||||
super(str);
|
||||
|
||||
AjaxLink<Void> createLink = new AjaxLink<Void>("createLink"){
|
||||
@SpringBean
|
||||
private KeywordDao keywordDao;
|
||||
|
||||
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;
|
||||
|
||||
@Override
|
||||
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);
|
||||
dialog.setTitle("Add new keyword");
|
||||
dialog.open(target);
|
||||
@ -50,104 +54,139 @@ public class ManageKeywordPanel extends Panel {
|
||||
};
|
||||
createLink.add(new ImageObject("addIcon", ImageObject.SIXTEEN + ImageObject.ADD));
|
||||
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
|
||||
protected void populateItem(final Item<Keyword> item) {
|
||||
item.setOutputMarkupId(true);
|
||||
final Keyword keyword = item.getModelObject();
|
||||
|
||||
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();
|
||||
}
|
||||
dialog = new Dialog("editDialog");
|
||||
dialog.setModal(true);
|
||||
dialog.setAutoOpen(false);
|
||||
dialog.setWidth(400);
|
||||
dialog.setHeight(225);
|
||||
dialog.add(new EmptyPanel("dialogContent"));
|
||||
dialog.setOutputMarkupId(true);
|
||||
|
||||
@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);
|
||||
}
|
||||
dialog2 = new Dialog("manageDialog");
|
||||
dialog2.setModal(true);
|
||||
dialog2.setAutoOpen(false);
|
||||
dialog2.setWidth(800);
|
||||
dialog2.setHeight(600);
|
||||
// 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
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
target.addComponent(dialog);
|
||||
dialog.setWidth(500);
|
||||
dialog.setHeight(580);
|
||||
dialog.setTitle(keyword.getKeyword());
|
||||
dialog.replace(new KeywordDetailsPanel("dialogContent", keyword) {
|
||||
tableContainer = new WebMarkupContainer("table");
|
||||
tableContainer.setOutputMarkupId(true);
|
||||
|
||||
private static final long serialVersionUID = 8439790560385286282L;
|
||||
keywordsDataView = new DataView<Keyword>("keywordsDataView", keywordsDataProvider) {
|
||||
|
||||
@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);
|
||||
}
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
};
|
||||
tableContainer.add(keywordsDataView);
|
||||
add(createLink);
|
||||
add(dialog);
|
||||
add(tableContainer);
|
||||
}
|
||||
@Override
|
||||
protected void populateItem(final Item<Keyword> item) {
|
||||
item.setOutputMarkupId(true);
|
||||
final Keyword keyword = item.getModelObject();
|
||||
|
||||
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 java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@ -28,7 +29,15 @@ public class Keyword extends LazyDeletableDomainObject {
|
||||
private KeywordType type;
|
||||
|
||||
@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() {
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user