0

Zkoss Timeline issue with removing OccurEvent

asked 2013-12-24 09:54:25 +0800

mimosktzkoss2 gravatar image mimosktzkoss2
1

The Timeline/BandInfo removeOccurEvent cannot remove the selected event. In what basis removeOccurEvent is finding the equal or relevant OccurEvent? Should we override .equals?

delete flag offensive retag edit

Comments

Are you using an XML or a ListModel as the event source? Can you post the sample code?

neillee ( 2013-12-25 11:10:17 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-01-08 11:12:51 +0800

neillee gravatar image neillee flag of Taiwan
1692 1 5
https://plus.google.com/u...

Here is a sample to remove the selected occur event.

sample.zul

<div apply="pkg$.TimelineController">
    <timeline id="timeline" height="300px" width="100%">
        <bandinfo id="bandinfoMonth" width="70%" intervalUnit="month"
            intervalPixels="100" bubbleVisible="false" />
        <bandinfo id="bandinfoYear" width="30%" intervalUnit="year" 
            intervalPixels="200" syncWith="bandinfoMonth" /> 
    </timeline>
</div>

TimelineController.java

package pkg$;
...
@SuppressWarnings("serial")
public class TimelineController extends SelectorComposer<Component> {

    private final static DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

    @Wire
    Timeline timeline;

    @Wire
    private Bandinfo bandinfoMonth, bandinfoYear;

    private ListModelList<OccurEvent> model = null;

    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);

        Date currentDate = DATE_FORMAT.parse("2014-01-08");
        bandinfoMonth.setDate(currentDate);
        bandinfoYear.setDate(currentDate);

        List<OccurEvent> listEvents = new ArrayList<OccurEvent>();
        OccurEvent oe = null;

        oe = new OccurEvent();
        oe.setStart(DATE_FORMAT.parse("2013-10-01"));
        oe.setDescription("I'm not sure precisely when my friend's wedding is.");
        oe.setText("Friend's wedding");
        listEvents.add(oe);

        oe = new OccurEvent();
        oe.setStart(DATE_FORMAT.parse("2013-10-15"));
        oe.setEnd(DATE_FORMAT.parse("2013-11-01"));
        oe.setDescription("A few days to write some documentation for <a href=\"http://www.zkoss.org/doc/styleguide\">Timeline</a>.");
        oe.setText("Writing Style Guide");
        oe.setDuration(true);
        oe.setImageUrl("http://simile.mit.edu/images/csail-logo.gif");
        listEvents.add(oe);

        model = new ListModelList<OccurEvent>(listEvents, true);
        bandinfoMonth.setModel(model);
        bandinfoYear.setModel(model);
    }

    @Listen("onOccurEventSelect=#bandinfoMonth")
    public void doSelect(OccurEventSelectEvent event) {
        OccurEvent oe = event.getOccurEvent();
        OccurEvent ev = null;
        ListIterator<OccurEvent> li = model.listIterator();
        while (li.hasNext()) {
            ev = li.next();
            if (ev.getStart().equals(oe.getStart()))
                break;
        }
        model.remove(ev);
    }

}
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-12-24 09:54:25 +0800

Seen: 9 times

Last updated: Jan 08 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More