// separator
mb.add(new SeparatorToolItem());
// Proposal
Button proposalMenuHead = new Button("Proposal");
Menu proposalMenu = new Menu();
proposalMenuHead.setMenu(proposalMenu);
mb.add(proposalMenuHead);
MenuItem entireProposal = new MenuItem("Show Proposal");
entireProposal.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
matchProp.showProposal();
}
});
proposalMenu.add(entireProposal);
MenuItem moreInformation = new MenuItem("More Information");
moreInformation.setIconStyle("icon-menu-information");
moreInformation.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
matchProp.displayInformation();
}
});
proposalMenu.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) {
MatchProposal selectedProposal = matchProp.getSelectedMatchProposal();
if(null == selectedProposal)
Window.alert("Please select proposal");
else
Commands.getInstance().gotoStaticDisplay(selectedProposal.getId(), ClientUtils.DERIVED);
}
});
proposalMenu.add(gotoStaticDisplay);
proposalMenu.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) {
//
MatchProposal selectedProposal = matchProp.getSelectedMatchProposal();
if(null == selectedProposal)
Window.alert("Please select proposal.");
else {
String id = selectedProposal.getId();
new NotesPanel(id, TCNote.TYPE_PARAGRAPH, new NotePanelCallback<TCNote, Integer>(){
public void callback(TCNote note, Integer type) {
if(type == NotesPanel.NOTE_ADDED)
matchProp.addNote(note);
}
});
}
}
});
proposalMenu.add(addNote);
proposalMenu.add(new SeparatorMenuItem());
MenuItem createLink = new MenuItem("Create Link");
createLink.setIconStyle("icon-menu-createLink");
createLink.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
MatchProposal selectedProposal = matchProp.getSelectedMatchProposal();
if(null == selectedProposal)
Window.alert("Please select proposal.");
else if(selectedProposal.isMatched())
Window.alert("The match has has already been established.");
else
Commands.getInstance().createLink(selectedPartsID, selectedProposal);
}
});
proposalMenu.add(createLink);
// sepearator
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-highlightingDeactivated");
} else {
toggleHighlighting.setText("Activate Highlighting");
toggleHighlighting.setIconStyle("icon-menu-highlightingActivated");
}
toggleHighlighting.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
matchProp.toggleHighlighting();
// 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 Proposal in Source");
highlightInSource.addSelectionListener(new SelectionListener<MenuEvent>(){
@Override
public void componentSelected(MenuEvent ce) {
MatchProposal selectedProposal = matchProp.getSelectedMatchProposal();
if(null == selectedProposal)
Window.alert("Please select proposal");
else
Commands.getInstance().highlightSource(selectedPartsID, selectedProposal.getId());
}
});
highlightingMenu.add(highlightInSource);
// separator
mb.add(new SeparatorToolItem());
// more matches
if(results.getType() == SearchResults.TYPE_PROPOSED){
// propose matches
final Button proposeMatch = new Button("Propose More Matches");
if(null != ClientState.proposeMoreMatches && ClientState.proposeMoreMatches.equals(selectedPartsID))
proposeMatch.disable();
proposeMatch.addSelectionListener(new SelectionListener<ButtonEvent>(){
@Override
public void componentSelected(ButtonEvent ce) {
proposeMatch.disable();
ClientState.proposeMoreMatches = selectedPartsID;
Commands.getInstance().findNewMatchFor(selectedPartsID,ClientUtils.SHINGLE_CLOUD_FUZZY);
}
});
mb.add(proposeMatch);
}
// Navigation
if(results.getType() == SearchResults.TYPE_MANUAL_SEARCH){
Button navigationMenuHead = new Button("Navigation");
Menu navigationMenu = new Menu();
navigationMenuHead.setMenu(navigationMenu);
mb.add(navigationMenuHead);
Button gotoNextSection = new Button("Goto Next Page");
gotoNextSection.setIconStyle("icon-menu-nextSection");
if(! results.isMore())
gotoNextSection.disable();
gotoNextSection.addSelectionListener(new SelectionListener<ButtonEvent>(){
@Override
public void componentSelected(ButtonEvent ce) {
Commands.getInstance().performManualSearch(
ClientState.getCurrentlyDerivedFile(), results.getQuery(), results.getStart() + results.getOffset(),
new CommandCallback<SearchResults>(){
public void cc_callback(SearchResults proposals) {
displayMatchProposalsFor(selectedPartsID, proposals);
}
}
);
}
} );
navigationMenu.add(gotoNextSection);
Button gotoPrevSection = new Button("Goto Previous Page");
gotoPrevSection.setIconStyle("icon-menu-previousSection");
if(results.getStart() == 0)
gotoPrevSection.disable();
gotoPrevSection.addSelectionListener(new SelectionListener<ButtonEvent>(){
@Override
public void componentSelected(ButtonEvent ce) {
Commands.getInstance().performManualSearch(
ClientState.getCurrentlyDerivedFile(), results.getQuery(), results.getStart() - results.getOffset(),
new CommandCallback<SearchResults>(){
public void cc_callback(SearchResults proposals) {
displayMatchProposalsFor(selectedPartsID, proposals);
}
}
);
}
} );
navigationMenu.add(gotoPrevSection);
}
// end toolbar