// tell section to put right class to paragraph
contentSection.markPart(selectedPartsID, TCSection.MARKUP_PART_NOMATCH);
} else {
// prepare tabpanel, add matches and create a lookup table
final TabPanel tabPanel = new TabPanel();
tabPanel.setStyleName("tc-inner-panel");
if(ClientState.showHighlighting)
tabPanel.addStyleName("showHighlighting");
tabPanel.setPlain(true);
tabPanel.setBodyBorder(false);
tabPanel.setBorders(false);
final HashMap<TabItem, TCLink> tabLookup = new HashMap<TabItem, TCLink>();
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);
matchMenu.add(new SeparatorMenuItem());
MenuItem confirmLink = new MenuItem("Confirm Match");
confirmLink.setIconStyle("icon-menu-confirmLink");
confirmLink.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
// find out which tab was selected
TCLink link = tabLookup.get(tabPanel.getSelectedItem());
Commands.getInstance().confirmMatch(link);
}
});
matchMenu.add(confirmLink);
matchMenu.add(new SeparatorMenuItem());
MenuItem deleteLink = new MenuItem("Delete Match");
deleteLink.setIconStyle("icon-menu-deleteLink");
deleteLink.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
// find out which tab was selected
TCLink link = tabLookup.get(tabPanel.getSelectedItem());
Commands.getInstance().removeMatch(link);
}
});
matchMenu.add(deleteLink);
// separator
mb.add(new SeparatorToolItem());
// Highlighting
Button highlightingMenuHead = new Button("Highlighting");
highlightingMenuHead.setIconStyle("icon-menu-highlightMenu");
Menu highlightingMenu = new Menu();
highlightingMenuHead.setMenu(highlightingMenu);
mb.add(highlightingMenuHead);
final MenuItem toggleHighlighting = new MenuItem();
if(ClientState.showHighlighting){
toggleHighlighting.setText("Deactivate Highlighting");
toggleHighlighting.setIconStyle("icon-menu-highlightingActivated");
} else {
toggleHighlighting.setText("Activate Highlighting");
toggleHighlighting.setIconStyle("icon-menu-highlightingDeactivated");
}
toggleHighlighting.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
ClientState.showHighlighting = !ClientState.showHighlighting;
if(ClientState.showHighlighting)
tabPanel.addStyleName("showHighlighting");
else
tabPanel.removeStyleName("showHighlighting");
// switch state
if(ClientState.showHighlighting){
toggleHighlighting.setText("Deactivate Highlighting");
toggleHighlighting.setIconStyle("icon-menu-highlightingActivated");
} else {
toggleHighlighting.setText("Activate Highlighting");
toggleHighlighting.setIconStyle("icon-menu-highlightingDeactivated");
}
}
});
highlightingMenu.add(toggleHighlighting);
highlightingMenu.add(new SeparatorMenuItem());
MenuItem highlightInSource = new MenuItem("Highlight in Source");
highlightInSource.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
// find out which tab was selected
TCLink link = tabLookup.get(tabPanel.getSelectedItem());
Commands.getInstance().highlightSource(selectedPartsID, link.getCurrentDerivedId());
}
});
highlightingMenu.add(highlightInSource);