Forum Message UI Improvement (Thesis Board #3470) #61
@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org">
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<span wicket:id="msgCount"></span>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -1,29 +0,0 @@
|
||||
package se.su.dsv.scipro.forum.panels;
|
||||
|
||||
import org.apache.wicket.markup.ComponentTag;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
|
||||
public abstract class NumberOfMessagesPanel extends Panel {
|
||||
|
||||
private Model<String> model = Model.of("");
|
||||
|
||||
public NumberOfMessagesPanel(final String id) {
|
||||
super(id);
|
||||
add(new Label("msgCount", model));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onComponentTag(ComponentTag tag) {
|
||||
super.onComponentTag(tag);
|
||||
|
||||
long count = getMessageCount();
|
||||
|
||||
if (count > 0) {
|
||||
model.setObject("(" + count + ")");
|
||||
}
|
||||
}
|
||||
|
||||
public abstract long getMessageCount();
|
||||
}
|
@ -44,7 +44,9 @@
|
||||
|
||||
<wicket:fragment wicket:id="readStateColumnMarkupId">
|
||||
<span wicket:id="flag"></span>
|
||||
<wicket:container wicket:id="counter"></wicket:container>
|
||||
<wicket:enclosure child="counter">
|
||||
(<wicket:container wicket:id="counter"></wicket:container>)
|
||||
</wicket:enclosure>
|
||||
</wicket:fragment>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
|
@ -15,6 +15,7 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColu
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.data.table.LambdaColumn;
|
||||
import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.EnumChoiceRenderer;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.LambdaChoiceRenderer;
|
||||
@ -257,7 +258,7 @@ public class SupervisorMyProjectsPanel extends Panel {
|
||||
|
||||
@Override
|
||||
public void populateItem(Item<ICellPopulator<Project>> item, String id, IModel<Project> projectModel) {
|
||||
// Since table cell only can contain one item, we use Wicket Fragment here. It will contains two components,
|
||||
// Since table cell only can contain one item, we use Wicket Fragment here. It will contain two components,
|
||||
// one for flag, one for unread messages counter.
|
||||
|
||||
Fragment fragment = new Fragment(id, "readStateColumnMarkupId", SupervisorMyProjectsPanel.this);
|
||||
@ -289,14 +290,15 @@ public class SupervisorMyProjectsPanel extends Panel {
|
||||
|
||||
fragment.add(readStatePanel);
|
||||
|
||||
fragment.add(
|
||||
new NumberOfMessagesPanel("counter") {
|
||||
Label counterLabel = new Label("counter", msgCount) {
|
||||
@Override
|
||||
public long getMessageCount() {
|
||||
return msgCount;
|
||||
protected void onConfigure() {
|
||||
super.onConfigure();
|
||||
setVisible(msgCount > 0);
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
fragment.add(counterLabel);
|
||||
|
||||
item.add(fragment);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user