for(int i = 0; i < matches.size(); i++){
TabItem item = new TabItem("match " + (i+1));
item.setScrollMode(Scroll.AUTO);
item.setLayout(new FitLayout());
NoteItem mItem = new NoteItem(matches.get(i).getText(), matches.get(i).getLink().getCurrentDerivedId(), matches.get(i).getNotes());
item.add(mItem);
if(matches.get(i).getLink().getType().equals(TCLink.TYPE_CONFIRMED))
item.addStyleName("tc-match-confirmedMatch");
else
item.addStyleName("tc-match-unconfirmedMatch");
tabPanel.add(item);
tabLookup.put(item, matches.get(i).getLink());
}
// tab selection listener to unhighlight paragraph in TCSection
tabPanel.addListener(Events.Select, new Listener<TabPanelEvent>(){
public void handleEvent(TabPanelEvent be) {
contentSection.unhighlightParagraph();
}
});
// create menu
ToolBar mb = new ToolBar();
// Match Menu
Button matchMenuHead = new Button("Match");
Menu matchMenu = new Menu();
matchMenuHead.setMenu(matchMenu);
mb.add(matchMenuHead);
MenuItem moreInformation = new MenuItem("More Information");
moreInformation.setIconStyle("icon-menu-information");
moreInformation.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
// find out which tab was selected
TCLink link = tabLookup.get(tabPanel.getSelectedItem());
Commands.getInstance().getInformationOn(link.getCurrentDerivedId(), ClientUtils.DERIVED);
}
});
matchMenu.add(moreInformation);
MenuItem gotoStaticDisplay = new MenuItem("Goto static display");
gotoStaticDisplay.setIconStyle("icon-menu-gotoStatic");
gotoStaticDisplay.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
// find out which tab was selected
TCLink link = tabLookup.get(tabPanel.getSelectedItem());
Commands.getInstance().gotoStaticDisplay(link.getCurrentDerivedId(), ClientUtils.DERIVED);
}
});
matchMenu.add(gotoStaticDisplay);
matchMenu.add(new SeparatorMenuItem());
MenuItem addNote = new MenuItem("Add Note to Paragraph");
addNote.setIconStyle("icon-menu-addNote");
addNote.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
//
final NoteItem mItem = (NoteItem) tabPanel.getSelectedItem().getWidget(0);
String id = mItem.getId();
new NotesPanel(id, TCNote.TYPE_PARAGRAPH, new NotePanelCallback<TCNote, Integer>(){
public void callback(TCNote note, Integer type) {
if(type == NotesPanel.NOTE_ADDED)
mItem.addNote(note);
}
});
}
});
matchMenu.add(addNote);
MenuItem addNoteMatch = new MenuItem("Add Note to Match");
addNoteMatch.setIconStyle("icon-menu-addNote");
addNoteMatch.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
//
final NoteItem mItem = (NoteItem) tabPanel.getSelectedItem().getWidget(0);
String id = mItem.getId();
new NotesPanel(id, TCNote.TYPE_LINK, new NotePanelCallback<TCNote, Integer>(){
public void callback(TCNote note, Integer type) {
if(type == NotesPanel.NOTE_ADDED)
mItem.addNote(note);
}
});
}
});
matchMenu.add(addNoteMatch);