List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow show
public void show(final IPartialPageRequestHandler target)
From source file:cz.zcu.kiv.eegdatabase.wui.ui.order.OrderItemPanel.java
License:Apache License
private ModalWindow addPromoCodePopup(final OrderItem parent, WebMarkupContainer membershipPlanContainer) { final ModalWindow popup = new ModalWindow("promoCodePopup"); popup.setAutoSize(true);//from ww w .jav a2 s . co m popup.setResizable(false); popup.setMinimalWidth(500); popup.setWidthUnit("px"); popup.showUnloadConfirmation(false); PromoCodePopupForm popupForm = new PromoCodePopupForm(popup.getContentId(), new Model<StringWrapper>(new StringWrapper())) { @Override protected void onSubmitAction(IModel<StringWrapper> strWrapper, AjaxRequestTarget target, Form<?> form) { String code = strWrapper.getObject().getValue(); if (parent.getMembershipPlan() != null) { if (parent.getResearchGroup() == null) { if (promoFacade.isValidPersonalPlanCode(code)) { PromoCode promoCode = promoFacade.getPromoCodeByKeyword(code); parent.setPromoCode(promoCode); double price = parent.getMembershipPlan().getPrice().doubleValue() * (1d - ((double) promoCode.getDiscount() / 100d)); parent.setPrice(new BigDecimal(price)); } } else { if (promoFacade.isValidGroupPlanCode(code)) { PromoCode promoCode = promoFacade.getPromoCodeByKeyword(code); parent.setPromoCode(promoCode); double price = parent.getMembershipPlan().getPrice().doubleValue() * (1d - ((double) promoCode.getDiscount() / 100d)); parent.setPrice(new BigDecimal(price)); } } } ModalWindow.closeCurrent(target); setResponsePage(ShoppingCartPage.class); } @Override protected void onCancelAction(IModel<StringWrapper> strWrapper, AjaxRequestTarget target, Form<?> form) { ModalWindow.closeCurrent(target); } }; popup.setContent(popupForm); membershipPlanContainer.add(popup); AjaxLink popupLink = new AjaxLink<Object>("applyPromoCode") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { //License l = this.getModelObject(); //if (l!=null) System.out.println(l.getTitle()); popup.show(target); } }; popup.setOutputMarkupPlaceholderTag(true); popup.setVisibilityAllowed(true); String promoCode = ""; if (parent.getPromoCode() != null) { promoCode = "Applied code: " + parent.getPromoCode().getKeyword() + " (" + parent.getPromoCode().getDiscount() + "% off)"; } membershipPlanContainer.add(new Label("promoCodeText", promoCode)); membershipPlanContainer.add(popupLink); popupLink.setVisible(malleable); return popup; }
From source file:de.alpharogroup.wicket.components.examples.ajaxtabs.addable.AddableTabbedPanel.java
License:Apache License
public AddableTabbedPanel(final String id, final IModel<TabbedPanelModels<String>> model) { super(id, model); setDefaultModel(new CompoundPropertyModel<TabbedPanelModels<String>>(model)); final List<TabModel<String>> tabModels = model.getObject().getTabModels(); for (int i = 0; i < tabModels.size(); i++) { tabs.add(new AbstractContentTab<TabModel<String>>(tabModels.get(i).getTitle(), Model.of(tabModels.get(i)), Model.of("x")) { private static final long serialVersionUID = 1L; @Override// ww w . ja v a 2 s . c om public Panel getPanel(final String panelId) { final Panel p = new TabPanel(panelId, getContent().getObject().getContent()); return p; } }); } add(ajaxTabbedPanel = new AjaxAddableTabbedPanel<ICloseableTab>("tabs", tabs) { private static final long serialVersionUID = 1L; @Override protected Component newAddTab(final String id, final IModel<String> model) { final WebMarkupContainer addTabContainer = new WebMarkupContainer(id); addTabContainer.setOutputMarkupId(true); addTabContainer.add(new AttributeAppender("class", " label")); final ModalWindow modalWindow = newAddTabModalWindow("modalWindow", Model.of("Add new tab")); addTabContainer.add(modalWindow); final AjaxLink<Void> openModal = new AjaxLink<Void>("openModal") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { target.prependJavaScript("Wicket.Window.unloadConfirmation = false;"); modalWindow.show(target); } }; openModal.setOutputMarkupId(true); openModal.add(newAddTabButtonLabel("addTabLabel", Model.of("+"))); openModal.add(new AttributeAppender("class", " label-success")); addTabContainer.add(openModal); return addTabContainer; } @Override protected Label newaddTabLabel(final String id, final IModel<String> model) { return ComponentFactory.newLabel(id, model); } @Override protected IModel<String> newAddTabLabelModel() { return Model.of("+"); } @Override protected ModalWindow newAddTabModalWindow(final String id, final IModel<String> model) { final ModalWindow modalWindow = new ModalWindow(id); modalWindow.setOutputMarkupId(true); modalWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY); modalWindow.setTitle(model.getObject()); modalWindow.setInitialHeight(200); modalWindow.setInitialWidth(300); modalWindow.setContent( new SaveDialogPanel<String>(modalWindow.getContentId(), Model.of(new String())) { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override protected void onCancel(final AjaxRequestTarget target, final Form<?> form) { super.onCancel(target, form); modalWindow.close(target); } @SuppressWarnings("unchecked") @Override protected void onSave(AjaxRequestTarget target, final Form<?> form) { super.onSave(target, form); if (target == null) { target = ComponentFinder.findAjaxRequestTarget(); } final Object value = getModel(); String v = null; if (value instanceof IModel) { final Object obj = ((IModel<?>) value).getObject(); if (obj instanceof String) { v = (String) obj; } } target.add(ajaxTabbedPanel); final TabModel<String> newTabModel = new TabModel<>(Model.of(v), Model.of(v), Model.of("x")); final AbstractContentTab<TabModel<String>> tab = new AbstractContentTab<TabModel<String>>( newTabModel.getTitle(), Model.of(newTabModel), Model.of("x")) { private static final long serialVersionUID = 1L; @Override public Panel getPanel(final String panelId) { final Panel p = new TabPanel(panelId, getContent().getObject().getContent()); return p; } }; final Object object = AddableTabbedPanel.this.getDefaultModelObject(); final TabbedPanelModels<String> tabbedModel = (TabbedPanelModels<String>) object; final List<TabModel<String>> tabModels = tabbedModel.getTabModels(); tabModels.add(newTabModel); ajaxTabbedPanel.onNewTab(target, tab); modalWindow.close(target); } }); return modalWindow; } @Override protected WebMarkupContainer newCloseLink(final String linkId, final int index) { final WebMarkupContainer wmc = super.newCloseLink(linkId, index); wmc.add(new AttributeAppender("class", "close label label-warning")); return wmc; } @Override protected WebMarkupContainer newLink(final String linkId, final int index) { final WebMarkupContainer wmc = super.newLink(linkId, index); wmc.add(new AttributeAppender("class", "label label-success")); return wmc; } }); }
From source file:de.alpharogroup.wicket.data.provider.examples.refreshingview.ModalDialogWithStylePanel.java
License:Apache License
public ModalDialogWithStylePanel(final String id) { super(id);/* ww w . j a v a2s . c o m*/ final ModalWindow modal = new ModalWindow("modal"); modal.setCssClassName("w_vegas"); modal.setTitle("Trivial Modal"); final AjaxLink<Void> modalLink = new AjaxLink<Void>("modalLink") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { target.appendJavaScript("var originalStyle = $('.wicket-modal').attr('style');" + "$('.wicket-modal').attr('style', originalStyle + 'opacity: 0.5;');"); } }; final Fragment modalFragment = new Fragment(modal.getContentId(), "modalContent", this); modalFragment.add(modalLink); modal.setContent(modalFragment); add(modal); add(new AjaxLink<Void>("openModal") { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { modal.show(target); } }); }
From source file:de.alpharogroup.wicket.dialogs.examples.HomePage.java
License:Apache License
/** * Constructor that is invoked when page is invoked without a session. * * @param parameters// ww w. j a v a 2 s . c o m * Page parameters */ public HomePage(final PageParameters parameters) { final WebMarkupContainer wmc = new WebMarkupContainer("comments"); wmc.setOutputMarkupId(true); final List<MessageBean> noteList = new ArrayList<MessageBean>(); final MessageBean messageBean = new MessageBean(); messageBean.setMessageContent("hello"); final IModel<MessageBean> dialogModel = new CompoundPropertyModel<MessageBean>(messageBean); final ModalWindow modalWindow = new BaseModalWindow<MessageBean>("baseModalWindow", dialogModel, "Title", 350, 160) { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void onCancel(final AjaxRequestTarget target) { target.add(wmc); close(target); } @Override public void onSelect(final AjaxRequestTarget target, final MessageBean object) { final MessageBean clone = (MessageBean) WicketObjects.cloneObject(object); noteList.add(clone); // Clear the content from textarea in the dialog. object.setMessageContent(""); target.add(wmc); close(target); } }; modalWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY); modalWindow.setResizable(false); add(modalWindow); final AjaxLink<String> linkToModalWindow = new AjaxLink<String>("linkToModalWindow") { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { modalWindow.show(target); } }; // Add the WebMarkupContainer... add(wmc); final Label linkToModalWindowLabel = new Label("linkToModalWindowLabel", "show modal dialog"); linkToModalWindow.add(linkToModalWindowLabel); // The AjaxLink to open the modal window add(linkToModalWindow); // here we have to set the message content from the bean in a repeater... final ListView<MessageBean> repliesAndNotesListView = new ListView<MessageBean>("repliesAndNotesListView", noteList) { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<MessageBean> item) { final MessageBean repliesandnotes = item.getModelObject(); item.add(new RepliesandnotesPanel("repliesandnotesPanel", repliesandnotes)); } }; repliesAndNotesListView.setVisible(true); wmc.add(repliesAndNotesListView); @SuppressWarnings("rawtypes") final Link showUploadPage = new Link("showUploadPage") { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick() { setResponsePage(new UploadPage(getPageParameters())); } }; add(showUploadPage); add(new ModalDialogWithStylePanel("modalDialogWithStylePanel", Model.of("bla"))); }
From source file:de.alpharogroup.wicket.dialogs.examples.UploadPage.java
License:Apache License
public UploadPage(final PageParameters parameters) { super(parameters); final ModalWindow uploadFileDialog = new ModalWindow("uploadFileDialog"); add(uploadFileDialog);// w w w . j a v a2 s. c om final UploadFilePanel uploadFilePanel = new UploadFilePanel("content"); uploadFileDialog.setContent(uploadFilePanel); add(new AjaxLink<Void>("showUpdoadFileDialog") { /** * The serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { uploadFileDialog.show(target); } }); }
From source file:de.jetwick.ui.UserPanel.java
License:Apache License
public UserPanel(String id, final TweetSearchPage tweetSearchRef) { super(id);//from www .j a v a2s . co m ExternalLink profileImageLink = new ExternalLink("profileImageLink", new PropertyModel(this, "profileLink")); profileImageLink.add(new ContextImage("profileImage", new PropertyModel(this, "imageUrl"))); profileImageLink.add(new AttributeAppender("title", new PropertyModel(this, "title"), " ")); add(profileImageLink); add(new WebMarkupContainer("gojetslideLink") { @Override public boolean isVisible() { return !tweetSearchRef.getMySession().hasLoggedIn(); } }); Link loginLink = new Link("loginLink") { @Override public void onClick() { setResponsePage(Login.class); } }; add(loginLink); if (!tweetSearchRef.getMySession().hasLoggedIn()) { add(new WebMarkupContainer("loginContainer").setVisible(false)); add(new AttributeModifier("class", "logged-in", new Model("logged-out"))); return; } title = tweetSearchRef.getMySession().getUser().getScreenName(); imageUrl = tweetSearchRef.getMySession().getUser().getProfileImageUrl(); profileLink = Helper.TURL + "/" + title; loginLink.setVisible(false); WebMarkupContainer container = new WebMarkupContainer("loginContainer") { { final JUser user = tweetSearchRef.getMySession().getUser(); String name = user.getRealName(); if (name == null) name = user.getScreenName(); add(new Label("loginText", "Hi " + name + "!")); add(new Link("logout") { @Override public void onClick() { onLogout(); } }); add(new AjaxFallbackLink("showHomeline") { @Override public void onClick(AjaxRequestTarget target) { onHomeline(target, user.getScreenName()); } }); add(new AjaxFallbackLink("showTweets") { @Override public void onClick(AjaxRequestTarget target) { onShowTweets(target, user.getScreenName()); } }); final ModalWindow modalW = new ModalWindow("userModal"); add(modalW); add(new AjaxLink("grabTweets") { @Override public void onClick(AjaxRequestTarget target) { modalW.show(target); } }); modalW.setTitle("Specify the user and the number of tweets you want to grab"); final GrabTweetsDialog dialog = new GrabTweetsDialog(modalW.getContentId(), user.getScreenName()) { @Override public TwitterSearch getTwitterSearch() { return tweetSearchRef.getTwitterSearch(); } @Override public void updateAfterAjax(AjaxRequestTarget target) { UserPanel.this.updateAfterAjax(target); } @Override public void onClose(AjaxRequestTarget target) { modalW.close(target); } @Override protected Collection<String> getUserChoices(String input) { return UserPanel.this.getUserChoices(input); } }; modalW.setContent(dialog); modalW.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { @Override public boolean onCloseButtonClicked(AjaxRequestTarget target) { logger.info("cancel grabber archiving thread!"); dialog.interruptGrabber(); modalW.close(target); return true; } }); modalW.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { @Override public void onClose(AjaxRequestTarget target) { logger.info("closed dialog"); } }); modalW.setCookieName("user-modal"); } }; add(container); }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.page.annotation.AnnotationPage.java
License:Apache License
public AnnotationPage() { editor = new AnnotationDetailEditorPanel("annotationDetailEditorPanel", new Model<BratAnnotatorModel>(bModel)) { private static final long serialVersionUID = 2857345299480098279L; @Override//from ww w .ja v a 2 s . c o m protected void onChange(AjaxRequestTarget aTarget, BratAnnotatorModel aBModel) { aTarget.addChildren(getPage(), FeedbackPanel.class); try { annotator.bratRender(aTarget, getCas(aBModel)); } catch (UIMAException | ClassNotFoundException | IOException e) { LOG.info("Error reading CAS " + e.getMessage()); error("Error reading CAS " + e.getMessage()); return; } annotator.bratRenderHighlight(aTarget, aBModel.getSelection().getAnnotation()); annotator.onChange(aTarget, aBModel); } @Override protected void onAutoForward(AjaxRequestTarget aTarget, BratAnnotatorModel aBModel) { try { annotator.autoForward(aTarget, getCas(aBModel)); } catch (UIMAException | ClassNotFoundException | IOException | BratAnnotationException e) { LOG.info("Error reading CAS " + e.getMessage()); error("Error reading CAS " + e.getMessage()); return; } } }; editor.setOutputMarkupId(true); add(editor); annotator = new BratAnnotator("embedder1", new Model<BratAnnotatorModel>(bModel), editor) { private static final long serialVersionUID = 7279648231521710155L; @Override public void onChange(AjaxRequestTarget aTarget, BratAnnotatorModel aBratAnnotatorModel) { bModel = aBratAnnotatorModel; aTarget.add(numberOfPages); } @Override public void renderHead(IHeaderResponse aResponse) { super.renderHead(aResponse); // If the page is reloaded in the browser and a document was already open, we need // to render it. We use the "later" commands here to avoid polluting the Javascript // header items with document data and because loading times are not that critical // on a reload. if (getModelObject().getProject() != null) { // We want to trigger a late rendering only on a page reload, but not on a // Ajax request. if (!aResponse.getResponse().getClass().getName().endsWith("AjaxResponse")) { aResponse.render(OnLoadHeaderItem.forScript(bratInitLaterCommand())); aResponse.render(OnLoadHeaderItem.forScript(bratRenderLaterCommand())); } } } }; // This is an Annotation Operation, set model to ANNOTATION mode bModel.setMode(Mode.ANNOTATION); add(annotator); add(documentNamePanel = (DocumentNamePanel) new DocumentNamePanel("documentNamePanel", new Model<BratAnnotatorModel>(bModel)).setOutputMarkupId(true)); numberOfPages = new Label("numberOfPages", new Model<String>()); numberOfPages.setOutputMarkupId(true); add(numberOfPages); final ModalWindow openDocumentsModal; add(openDocumentsModal = new ModalWindow("openDocumentsModal")); openDocumentsModal.setOutputMarkupId(true); openDocumentsModal.setInitialWidth(500); openDocumentsModal.setInitialHeight(300); openDocumentsModal.setResizable(true); openDocumentsModal.setWidthUnit("px"); openDocumentsModal.setHeightUnit("px"); openDocumentsModal.setTitle("Open document"); openDocumentsModal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { private static final long serialVersionUID = -5423095433535634321L; @Override public boolean onCloseButtonClicked(AjaxRequestTarget aTarget) { closeButtonClicked = true; return true; } }); add(new AjaxLink<Void>("showOpenDocumentModal") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { editor.reset(aTarget); closeButtonClicked = false; openDocumentsModal.setContent(new OpenModalWindowPanel(openDocumentsModal.getContentId(), bModel, openDocumentsModal, Mode.ANNOTATION) { private static final long serialVersionUID = -3434069761864809703L; @Override protected void onCancel(AjaxRequestTarget aTarget) { closeButtonClicked = true; }; }); openDocumentsModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = -1746088901018629567L; @Override public void onClose(AjaxRequestTarget target) { // A hack, the dialog opens for the first time, and if no document is // selected window will be "blind down". Something in the brat js causes // this! if (bModel.getProject() == null || bModel.getDocument() == null) { setResponsePage(WelcomePage.class); } // Dialog was cancelled rather that a document was selected. if (closeButtonClicked) { return; } loadDocumentAction(target); String username = SecurityContextHolder.getContext().getAuthentication().getName(); User user = userRepository.get(username); editor.setEnabled( !FinishImage.isFinished(new Model<BratAnnotatorModel>(bModel), user, repository)); } }); // target.appendJavaScript("Wicket.Window.unloadConfirmation = false;"); openDocumentsModal.show(aTarget); } }); add(new AnnotationLayersModalPanel("annotationLayersModalPanel", new Model<BratAnnotatorModel>(bModel), editor) { private static final long serialVersionUID = -4657965743173979437L; @Override protected void onChange(AjaxRequestTarget aTarget) { try { JCas jCas = getJCas(); annotator.bratRender(aTarget, jCas); updateSentenceAddress(jCas, aTarget); } catch (UIMAException | ClassNotFoundException | IOException e) { LOG.info("Error reading CAS " + e.getMessage()); error("Error reading CAS " + e.getMessage()); return; } } }); add(new ExportModalPanel("exportModalPanel", new Model<BratAnnotatorModel>(bModel))); // Show the previous document, if exist add(new AjaxLink<Void>("showPreviousDocument") { private static final long serialVersionUID = 7496156015186497496L; /** * Get the current beginning sentence address and add on it the size of the display * window */ @Override public void onClick(AjaxRequestTarget aTarget) { editor.reset(aTarget); // List of all Source Documents in the project List<SourceDocument> listOfSourceDocuements = repository.listSourceDocuments(bModel.getProject()); String username = SecurityContextHolder.getContext().getAuthentication().getName(); User user = userRepository.get(username); List<SourceDocument> sourceDocumentsinIgnorState = new ArrayList<SourceDocument>(); for (SourceDocument sourceDocument : listOfSourceDocuements) { if (repository.existsAnnotationDocument(sourceDocument, user) && repository.getAnnotationDocument(sourceDocument, user).getState() .equals(AnnotationDocumentState.IGNORE)) { sourceDocumentsinIgnorState.add(sourceDocument); } } listOfSourceDocuements.removeAll(sourceDocumentsinIgnorState); // Index of the current source document in the list int currentDocumentIndex = listOfSourceDocuements.indexOf(bModel.getDocument()); // If the first the document if (currentDocumentIndex == 0) { aTarget.appendJavaScript("alert('This is the first document!')"); return; } bModel.setDocumentName(listOfSourceDocuements.get(currentDocumentIndex - 1).getName()); bModel.setDocument(listOfSourceDocuements.get(currentDocumentIndex - 1)); loadDocumentAction(aTarget); } }.add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_up }, EventType.click))); // Show the next document if exist add(new AjaxLink<Void>("showNextDocument") { private static final long serialVersionUID = 7496156015186497496L; /** * Get the current beginning sentence address and add on it the size of the display * window */ @Override public void onClick(AjaxRequestTarget aTarget) { editor.reset(aTarget); // List of all Source Documents in the project List<SourceDocument> listOfSourceDocuements = repository.listSourceDocuments(bModel.getProject()); String username = SecurityContextHolder.getContext().getAuthentication().getName(); User user = userRepository.get(username); List<SourceDocument> sourceDocumentsinIgnorState = new ArrayList<SourceDocument>(); for (SourceDocument sourceDocument : listOfSourceDocuements) { if (repository.existsAnnotationDocument(sourceDocument, user) && repository.getAnnotationDocument(sourceDocument, user).getState() .equals(AnnotationDocumentState.IGNORE)) { sourceDocumentsinIgnorState.add(sourceDocument); } } listOfSourceDocuements.removeAll(sourceDocumentsinIgnorState); // Index of the current source document in the list int currentDocumentIndex = listOfSourceDocuements.indexOf(bModel.getDocument()); // If the first document if (currentDocumentIndex == listOfSourceDocuements.size() - 1) { aTarget.appendJavaScript("alert('This is the last document!')"); return; } bModel.setDocumentName(listOfSourceDocuements.get(currentDocumentIndex + 1).getName()); bModel.setDocument(listOfSourceDocuements.get(currentDocumentIndex + 1)); loadDocumentAction(aTarget); } }.add(new InputBehavior(new KeyType[] { KeyType.Shift, KeyType.Page_down }, EventType.click))); // Show the next page of this document add(new AjaxLink<Void>("showNext") { private static final long serialVersionUID = 7496156015186497496L; /** * Get the current beginning sentence address and add on it the size of the display * window */ @Override public void onClick(AjaxRequestTarget aTarget) { try { if (bModel.getDocument() != null) { JCas jCas = getJCas(); int nextSentenceAddress = BratAjaxCasUtil.getNextPageFirstSentenceAddress(jCas, bModel.getSentenceAddress(), bModel.getPreferences().getWindowSize()); if (bModel.getSentenceAddress() != nextSentenceAddress) { updateSentenceNumber(jCas, nextSentenceAddress); aTarget.addChildren(getPage(), FeedbackPanel.class); annotator.bratRenderLater(aTarget); gotoPageTextField.setModelObject( BratAjaxCasUtil.getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1); updateSentenceAddress(jCas, aTarget); } else { aTarget.appendJavaScript("alert('This is last page!')"); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }.add(new InputBehavior(new KeyType[] { KeyType.Page_down }, EventType.click))); // Show the previous page of this document add(new AjaxLink<Void>("showPrevious") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { try { if (bModel.getDocument() != null) { JCas jCas = getJCas(); int previousSentenceAddress = BratAjaxCasUtil.getPreviousDisplayWindowSentenceBeginAddress( jCas, bModel.getSentenceAddress(), bModel.getPreferences().getWindowSize()); if (bModel.getSentenceAddress() != previousSentenceAddress) { updateSentenceNumber(jCas, previousSentenceAddress); aTarget.addChildren(getPage(), FeedbackPanel.class); annotator.bratRenderLater(aTarget); gotoPageTextField.setModelObject( BratAjaxCasUtil.getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1); updateSentenceAddress(jCas, aTarget); } else { aTarget.appendJavaScript("alert('This is First Page!')"); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }.add(new InputBehavior(new KeyType[] { KeyType.Page_up }, EventType.click))); add(new AjaxLink<Void>("showFirst") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { try { if (bModel.getDocument() != null) { JCas jCas = getJCas(); if (bModel.getFirstSentenceAddress() != bModel.getSentenceAddress()) { updateSentenceNumber(jCas, bModel.getFirstSentenceAddress()); aTarget.addChildren(getPage(), FeedbackPanel.class); annotator.bratRenderLater(aTarget); gotoPageTextField.setModelObject( BratAjaxCasUtil.getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1); updateSentenceAddress(jCas, aTarget); } else { aTarget.appendJavaScript("alert('This is first page!')"); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }.add(new InputBehavior(new KeyType[] { KeyType.Home }, EventType.click))); add(new AjaxLink<Void>("showLast") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { try { if (bModel.getDocument() != null) { JCas jCas = getJCas(); int lastDisplayWindowBeginingSentenceAddress = BratAjaxCasUtil .getLastDisplayWindowFirstSentenceAddress(jCas, bModel.getPreferences().getWindowSize()); if (lastDisplayWindowBeginingSentenceAddress != bModel.getSentenceAddress()) { updateSentenceNumber(jCas, lastDisplayWindowBeginingSentenceAddress); aTarget.addChildren(getPage(), FeedbackPanel.class); annotator.bratRenderLater(aTarget); gotoPageTextField.setModelObject( BratAjaxCasUtil.getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1); updateSentenceAddress(jCas, aTarget); } else { aTarget.appendJavaScript("alert('This is last Page!')"); } } else { aTarget.appendJavaScript("alert('Please open a document first!')"); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }.add(new InputBehavior(new KeyType[] { KeyType.End }, EventType.click))); add(new AjaxLink<Void>("toggleScriptDirection") { private static final long serialVersionUID = -4332566542278611728L; @Override public void onClick(AjaxRequestTarget aTarget) { if (ScriptDirection.LTR.equals(bModel.getScriptDirection())) { bModel.setScriptDirection(ScriptDirection.RTL); } else { bModel.setScriptDirection(ScriptDirection.LTR); } annotator.bratRenderLater(aTarget); } }); add(new GuidelineModalPanel("guidelineModalPanel", new Model<BratAnnotatorModel>(bModel))); gotoPageTextField = (NumberTextField<Integer>) new NumberTextField<Integer>("gotoPageText", new Model<Integer>(0)); Form<Void> gotoPageTextFieldForm = new Form<Void>("gotoPageTextFieldForm"); gotoPageTextFieldForm.add(new AjaxFormSubmitBehavior(gotoPageTextFieldForm, "onsubmit") { private static final long serialVersionUID = -4549805321484461545L; @Override protected void onSubmit(AjaxRequestTarget aTarget) { try { if (gotoPageAddress == 0) { aTarget.appendJavaScript("alert('The sentence number entered is not valid')"); return; } if (bModel.getSentenceAddress() != gotoPageAddress) { JCas jCas = getJCas(); updateSentenceNumber(jCas, gotoPageAddress); aTarget.addChildren(getPage(), FeedbackPanel.class); annotator.bratRenderLater(aTarget); aTarget.add(numberOfPages); gotoPageTextField.setModelObject( BratAjaxCasUtil.getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1); aTarget.add(gotoPageTextField); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }); gotoPageTextField.setType(Integer.class); gotoPageTextField.setMinimum(1); gotoPageTextField.setDefaultModelObject(1); add(gotoPageTextFieldForm.add(gotoPageTextField)); gotoPageTextField.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 56637289242712170L; @Override protected void onUpdate(AjaxRequestTarget aTarget) { try { if (gotoPageTextField.getModelObject() < 1) { aTarget.appendJavaScript("alert('Page number shouldn't be less than 1')"); } else { updateSentenceAddress(getJCas(), aTarget); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }); add(new AjaxLink<Void>("gotoPageLink") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget aTarget) { try { if (gotoPageAddress == 0) { aTarget.appendJavaScript("alert('The sentence number entered is not valid')"); return; } if (bModel.getDocument() == null) { aTarget.appendJavaScript("alert('Please open a document first!')"); return; } if (bModel.getSentenceAddress() != gotoPageAddress) { JCas jCas = getJCas(); updateSentenceNumber(jCas, gotoPageAddress); updateSentenceAddress(jCas, aTarget); annotator.bratRenderLater(aTarget); } } catch (Exception e) { error(e.getMessage()); aTarget.addChildren(getPage(), FeedbackPanel.class); } } }); finish = new FinishImage("finishImage", new Model<BratAnnotatorModel>(bModel)); finish.setOutputMarkupId(true); add(new FinishLink("showYesNoModalPanel", new Model<BratAnnotatorModel>(bModel), finish) { private static final long serialVersionUID = -4657965743173979437L; }); }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.page.annotation.component.AnnotationLayersModalPanel.java
License:Apache License
public AnnotationLayersModalPanel(String id, final IModel<BratAnnotatorModel> aBModel, AnnotationDetailEditorPanel aEditor) { super(id, aBModel); // dialog window to select annotation layer preferences final ModalWindow annotationLayerSelectionModal; add(annotationLayerSelectionModal = new ModalWindow("annotationLayerModal")); annotationLayerSelectionModal.setOutputMarkupId(true); annotationLayerSelectionModal.setInitialWidth(450); annotationLayerSelectionModal.setInitialHeight(350); annotationLayerSelectionModal.setResizable(true); annotationLayerSelectionModal.setWidthUnit("px"); annotationLayerSelectionModal.setHeightUnit("px"); annotationLayerSelectionModal.setTitle("Annotation Layer and window size configuration Window"); annotationLayerSelectionModal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { private static final long serialVersionUID = -5423095433535634321L; @Override/*from w w w . j a va2s .c om*/ public boolean onCloseButtonClicked(AjaxRequestTarget aTarget) { closeButtonClicked = true; return true; } }); add(new AjaxLink<Void>("showannotationLayerModal") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget target) { if (aBModel.getObject().getProject() == null) { target.appendJavaScript("alert('Please open a project first!')"); } else { closeButtonClicked = false; annotationLayerSelectionModal.setContent( new AnnotationPreferenceModalPanel(annotationLayerSelectionModal.getContentId(), annotationLayerSelectionModal, aBModel.getObject(), aEditor) { private static final long serialVersionUID = -3434069761864809703L; @Override protected void onCancel(AjaxRequestTarget aTarget) { closeButtonClicked = true; }; }); annotationLayerSelectionModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1643342179335627082L; @Override public void onClose(AjaxRequestTarget target) { if (!closeButtonClicked) { onChange(target); } } }); annotationLayerSelectionModal.show(target); } } }); }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.page.annotation.component.ExportModalPanel.java
License:Apache License
public ExportModalPanel(String id, final IModel<BratAnnotatorModel> aModel) { super(id, aModel); final ModalWindow exportModal; add(exportModal = new ModalWindow("exportModal")); exportModal.setCookieName("modal-1"); exportModal.setInitialWidth(550);/*from w w w .j a v a 2 s.c om*/ exportModal.setInitialHeight(450); exportModal.setResizable(true); exportModal.setWidthUnit("px"); exportModal.setHeightUnit("px"); exportModal.setTitle("Export Annotated data to a given Format"); exportModal.setContent( new ExportModalWindowPanel(exportModal.getContentId(), exportModal, aModel.getObject())); add(new AjaxLink<Void>("showExportModal") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget target) { if (aModel.getObject().getDocument() == null) { target.appendJavaScript("alert('Please open a document first!')"); } else { exportModal.show(target); } } }); }
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.page.annotation.component.FinishLink.java
License:Apache License
public FinishLink(String id, final IModel<BratAnnotatorModel> aModel, final FinishImage finishImag) { super(id, aModel); final ModalWindow FinishModal; add(FinishModal = new ModalWindow("yesNoModal")); FinishModal.setOutputMarkupId(true); FinishModal.setInitialWidth(400);//from w w w . ja va 2 s.c om FinishModal.setInitialHeight(50); FinishModal.setResizable(true); FinishModal.setWidthUnit("px"); FinishModal.setHeightUnit("px"); FinishModal.setTitle("Are you sure you want to finish annotating?"); AjaxLink<Void> showYesNoModal; add(showYesNoModal = new AjaxLink<Void>("showYesNoModal") { private static final long serialVersionUID = 7496156015186497496L; @Override public void onClick(AjaxRequestTarget target) { String username = SecurityContextHolder.getContext().getAuthentication().getName(); User user = userRepository.get(username); if (FinishImage.isFinished(aModel, user, repository)) { target.appendJavaScript("alert('Document already closed!')"); } else { FinishModal.setContent(new YesNoFinishModalPanel(FinishModal.getContentId(), aModel.getObject(), FinishModal, Mode.ANNOTATION)); FinishModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = -1746088901018629567L; @Override public void onClose(AjaxRequestTarget target) { target.add(finishImag.setOutputMarkupId(true)); } }); FinishModal.show(target); } } }); showYesNoModal.add(finishImag); }