List of usage examples for org.apache.wicket.ajax.markup.html AjaxLink setOutputMarkupId
public final Component setOutputMarkupId(final boolean output)
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private void generateDiscardAtRandomLink(final String id) { final AjaxLink<Void> generateDiscardAtRandomLink = new AjaxLink<Void>(id) { private static final long serialVersionUID = 1L; @Override/*from w w w. j a v a 2 s . c o m*/ public void onClick(final AjaxRequestTarget target) { target.prependJavaScript(BattlefieldService.HIDE_MENUS); final Long _gameId = HomePage.this.session.getGameId(); final List<BigInteger> allPlayersInGame = HomePage.this.persistenceService .giveAllPlayersFromGame(_gameId); final Player playerWhoDiscards = HomePage.this.session.getPlayer(); final Long playerWhoDiscardsDeckId = playerWhoDiscards.getDeck().getDeckId(); final int allCardsInHand = HomePage.this.persistenceService .getNumberOfCardsInACertainZoneForAGameAndADeck(CardZone.HAND, _gameId, playerWhoDiscardsDeckId) .intValue(); if (allCardsInHand == 0) { return; } @SuppressWarnings("boxing") final int randomCardIndex = (allCardsInHand != 1 ? ((Double) Math.floor(Math.random() * allCardsInHand)).intValue() : 0); final List<MagicCard> allCardsInHandForAGameAndAPlayer = HomePage.this.persistenceService .getAllCardsInHandForAGameAndADeck(_gameId, playerWhoDiscardsDeckId); final MagicCard chosenCard = allCardsInHandForAGameAndAPlayer.remove(randomCardIndex); chosenCard.setZone(CardZone.GRAVEYARD); HomePage.this.persistenceService.updateCardWithoutMerge(chosenCard); HomePage.this.persistenceService.updateAllMagicCards(allCardsInHandForAGameAndAPlayer); playerWhoDiscards.setHandDisplayed(Boolean.TRUE); playerWhoDiscards.setGraveyardDisplayed(Boolean.TRUE); if (allCardsInHandForAGameAndAPlayer.isEmpty()) { playerWhoDiscards.getDeck().getCards().clear(); } BattlefieldService.updateHand(target); BattlefieldService.updateGraveyard(target); final NotifierCometChannel ncc = new NotifierCometChannel(NotifierAction.DISCARD_AT_RANDOM, null, playerWhoDiscards.getId(), playerWhoDiscards.getName(), playerWhoDiscards.getSide().getSideName(), chosenCard.getTitle(), null, ""); final ConsoleLogStrategy logger = AbstractConsoleLogStrategy.chooseStrategy( ConsoleLogType.DISCARD_AT_RANDOM, null, null, null, chosenCard.getTitle(), playerWhoDiscards.getName(), null, null, null, Boolean.FALSE, _gameId); EventBusPostService.post(allPlayersInGame, ncc, new ConsoleLogCometChannel(logger)); } }; generateDiscardAtRandomLink.setOutputMarkupId(true); this.add(generateDiscardAtRandomLink); }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private void generateLoginLink(final String id, final ModalWindow window) { window.setInitialWidth(300);//from ww w . j a v a 2 s.c o m window.setInitialHeight(200); window.setTitle("HatchetHarry login"); window.setContent(new LoginModalWindow(window.getContentId(), window)); window.setCssClassName(ModalWindow.CSS_CLASS_GRAY); window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT); window.setOutputMarkupId(true); window.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { private static final long serialVersionUID = 1L; @Override public boolean onCloseButtonClicked(final AjaxRequestTarget target) { target.appendJavaScript("authenticateUserWithFacebook();"); return true; } }); this.add(window); final AjaxLink<Void> loginLink = new AjaxLink<Void>(id) { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { target.prependJavaScript(BattlefieldService.HIDE_MENUS); target.appendJavaScript("Wicket.Window.unloadConfirmation = false;"); HomePage.this.loginWindow.show(target); } }; loginLink.setOutputMarkupId(true); this.add(loginLink); }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private void generatePreferencesLink(final String id, final ModalWindow window) { window.setInitialWidth(630);//from w ww.j a v a 2 s.c o m window.setInitialHeight(300); window.setTitle("User preferences"); window.setCssClassName(ModalWindow.CSS_CLASS_GRAY); window.setMaskType(ModalWindow.MaskType.SEMI_TRANSPARENT); window.setOutputMarkupId(true); this.add(window); final AjaxLink<Void> preferencesLink = new AjaxLink<Void>(id) { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget target) { window.setContent(new UserPreferencesModalWindow(window.getContentId(), window)); target.prependJavaScript(BattlefieldService.HIDE_MENUS); target.appendJavaScript("Wicket.Window.unloadConfirmation = false;"); HomePage.this.preferencesWindow.show(target); } }; preferencesLink.setOutputMarkupId(true); this.add(preferencesLink); }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private void generateInsertDivisionLink(final String id) { final AjaxLink<Void> insertDivisionLink = new AjaxLink<Void>(id) { private static final long serialVersionUID = 1L; @Override/*from www . j a va 2 s .c o m*/ public void onClick(final AjaxRequestTarget target) { final Long _gameId = HomePage.this.session.getGameId(); final ConsoleLogStrategy logger = AbstractConsoleLogStrategy.chooseStrategy( ConsoleLogType.INSERT_DIVISION, null, null, null, null, HomePage.this.session.getPlayer().getName(), null, null, null, null, _gameId); final List<BigInteger> allPlayersInGame = HomePage.this.persistenceService .giveAllPlayersFromGame(_gameId); EventBusPostService.post(allPlayersInGame, new ConsoleLogCometChannel(logger)); } }; insertDivisionLink.setOutputMarkupId(true).setMarkupId(id); this.add(insertDivisionLink); }
From source file:org.alienlabs.hatchetharry.view.page.HomePage.java
License:Open Source License
private void generateShuffleLibraryLink(final String id) { final AjaxLink<Void> insertDivisionLink = new AjaxLink<Void>(id) { private static final long serialVersionUID = 1L; @Override//from w w w . j av a 2s .c o m public void onClick(final AjaxRequestTarget target) { final Long _gameId = HomePage.this.session.getGameId(); final List<BigInteger> allPlayersInGame = HomePage.this.persistenceService .giveAllPlayersFromGame(_gameId); final ConsoleLogStrategy logger = AbstractConsoleLogStrategy.chooseStrategy( ConsoleLogType.SHUFFLE_LIBRARY, null, null, null, null, HomePage.this.session.getPlayer().getName(), null, null, null, null, _gameId); final Player me = HomePage.this.session.getPlayer(); final NotifierCometChannel ncc = new NotifierCometChannel(NotifierAction.SHUFFLE_LIBRARY_ACTION, null, me.getId(), me.getName(), me.getSide().getSideName(), null, null, ""); final List<MagicCard> allCardsInLibrary = HomePage.this.persistenceService .getAllCardsInLibraryForDeckAndPlayer(HomePage.this.session.getGameId(), HomePage.this.session.getPlayer().getId(), HomePage.this.session.getPlayer().getDeck().getDeckId()); Collections.shuffle(allCardsInLibrary); Collections.shuffle(allCardsInLibrary); Collections.shuffle(allCardsInLibrary); for (int i = 0; i < allCardsInLibrary.size(); i++) { allCardsInLibrary.get(i).setZoneOrder(Long.valueOf(i)); } HomePage.this.persistenceService.saveOrUpdateAllMagicCards(allCardsInLibrary); EventBusPostService.post(allPlayersInGame, new ConsoleLogCometChannel(logger), ncc); } }; insertDivisionLink.setOutputMarkupId(true).setMarkupId(id); this.add(insertDivisionLink); }
From source file:org.apache.isis.viewer.wicket.ui.components.bookmarkedpages.BookmarkedPagesPanel.java
License:Apache License
private void buildGui() { final BookmarkedPagesModel bookmarkedPagesModel = getModel(); Component helpText = addHelpText(bookmarkedPagesModel); addOrReplace(helpText);/*from ww w.ja v a2s . c o m*/ final WebMarkupContainer container = new WebMarkupContainer(ID_BOOKMARK_LIST) { private static final long serialVersionUID = 1L; @Override public void renderHead(IHeaderResponse response) { response.render(CssHeaderItem.forReference( new CssResourceReference(BookmarkedPagesPanel.class, "BookmarkedPagesPanel.css"))); response.render(JavaScriptReferenceHeaderItem.forReference(SLIDE_PANEL_JS)); } }; // allow to be updated by AjaxLink container.setOutputMarkupId(true); add(container); final AjaxLink<Void> clearAllBookmarksLink = new AjaxLink<Void>(CLEAR_BOOKMARKS) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { BookmarkedPagesPanel.this.getModel().clear(); setEnabled(false); target.add(container, this); } }; clearAllBookmarksLink.setOutputMarkupId(true); add(clearAllBookmarksLink); clearAllBookmarksLink.setOutputMarkupId(true); if (getModel().isEmpty()) { clearAllBookmarksLink.setVisible(false); } final ListView<BookmarkTreeNode> listView = new ListView<BookmarkTreeNode>(ID_BOOKMARKED_PAGE_ITEM, bookmarkedPagesModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<BookmarkTreeNode> item) { final BookmarkTreeNode node = item.getModelObject(); try { final PageType pageType = node.getPageType(); final Class<? extends Page> pageClass = pageClassRegistry.getPageClass(pageType); final AjaxLink<Object> clearBookmarkLink = new AjaxLink<Object>(ID_CLEAR_BOOKMARK_LINK) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { bookmarkedPagesModel.remove(node); if (bookmarkedPagesModel.isEmpty()) { permanentlyHide(CLEAR_BOOKMARKS); } target.add(container, clearAllBookmarksLink); } }; if (node.getDepth() == 0) { clearBookmarkLink.add(new CssClassAppender("clearBookmark")); } else { clearBookmarkLink.setEnabled(true); } item.add(clearBookmarkLink); PageParameters pageParameters = node.getPageParameters(); final AbstractLink link = Links.newBookmarkablePageLink(ID_BOOKMARKED_PAGE_LINK, pageParameters, pageClass); ObjectSpecification objectSpec = null; RootOid oid = node.getOidNoVer(); if (oid != null) { ObjectSpecId objectSpecId = oid.getObjectSpecId(); objectSpec = getSpecificationLoader().lookupBySpecId(objectSpecId); } final ResourceReference imageResource = imageCache.resourceReferenceForSpec(objectSpec); final Image image = new Image(ID_BOOKMARKED_PAGE_ICON, imageResource) { private static final long serialVersionUID = 1L; @Override protected boolean shouldAddAntiCacheParameter() { return false; } }; link.addOrReplace(image); String title = node.getTitle(); final Label label = new Label(ID_BOOKMARKED_PAGE_TITLE, title); link.add(label); item.add(link); if (bookmarkedPagesModel.isCurrent(pageParameters)) { item.add(new CssClassAppender("disabled")); } item.add(new CssClassAppender("bookmarkDepth" + node.getDepth())); } catch (ObjectNotFoundException ex) { // ignore // this is a partial fix for an infinite redirect loop. // should be a bit smarter here, though; see ISIS-596. } } }; container.add(listView); }
From source file:org.apache.isis.viewer.wicket.ui.components.scalars.isisapplib.IsisBlobOrClobPanelAbstract.java
License:Apache License
private void updateClearLink(InputFieldVisibility visibility) { final MarkupContainer formComponent = (MarkupContainer) getComponentForRegular(); formComponent.setOutputMarkupId(true); // enable ajax link final AjaxLink<Void> ajaxLink = new AjaxLink<Void>(ID_SCALAR_IF_REGULAR_CLEAR) { private static final long serialVersionUID = 1L; @Override/*from ww w . j a va2 s. c o m*/ public void onClick(AjaxRequestTarget target) { setEnabled(false); ScalarModel model = IsisBlobOrClobPanelAbstract.this.getModel(); model.setObject(null); target.add(formComponent); target.add(fileNameLabel); } }; ajaxLink.setOutputMarkupId(true); formComponent.addOrReplace(ajaxLink); final T blobOrClob = getBlobOrClobFromModel(); formComponent.get(ID_SCALAR_IF_REGULAR_CLEAR) .setVisible(blobOrClob != null && visibility == InputFieldVisibility.VISIBLE); }
From source file:org.cast.isi.panel.RatePanel.java
License:Open Source License
/** * @param affectText - name of the affect button *///w ww. j ava 2 s . c o m private void addAffectButton(final String affectText) { AjaxLink<Void> link = new AjaxLink<Void>(affectText) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { if (readOnly) return false; // The currently selected affect button is disabled return (!affectText.equals(RatePanel.this.getDefaultModelObjectAsString())); } @SuppressWarnings("unchecked") @Override public void onClick(AjaxRequestTarget target) { responseService.saveTextResponse(((IModel<Response>) RatePanel.this.getDefaultModel()), affectText, contentLoc.getLocation()); target.addChildren(RatePanel.this, AjaxLink.class); } @Override protected void onComponentTag(ComponentTag tag) { // if this is the selected button then set the class info for display purposes String tagAttribute = null; if (RatePanel.this.getDefaultModelObject() != null && affectText.equals(((Response) RatePanel.this.getDefaultModelObject()).getText())) { tagAttribute = tag.getAttribute("class"); tag.put("class", tagAttribute + " selected"); } super.onComponentTag(tag); } }; add(link); link.setOutputMarkupId(true); }
From source file:org.cast.isi.panel.ThumbPanel.java
License:Open Source License
/** * Add one button for each type of thumb name * @param buttonName//from ww w .j av a 2s .com */ protected void addButton(final String buttonName) { AjaxLink<Void> link = new AjaxLink<Void>(buttonName) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { if (readOnly) return false; // The currently selected rating is disabled return (!buttonName.equals(ThumbPanel.this.getDefaultModelObjectAsString())); } @SuppressWarnings("unchecked") @Override public void onClick(AjaxRequestTarget target) { ISIResponseService.get().saveTextResponse(((IModel<Response>) ThumbPanel.this.getDefaultModel()), buttonName, contentLoc.getLocation()); target.addChildren(ThumbPanel.this, AjaxLink.class); } @Override protected void onComponentTag(ComponentTag tag) { // if the current button is selected, set the class info for the background color String tagAttribute = null; if (ThumbPanel.this.getDefaultModelObject() != null && buttonName .equals(((Response) ThumbPanel.this.getDefaultModel().getObject()).getText())) { tagAttribute = tag.getAttribute("class"); tag.put("class", tagAttribute + " current"); } super.onComponentTag(tag); } }; add(link); link.setOutputMarkupId(true); }
From source file:org.dcm4chee.web.war.tc.TCViewOverviewTab.java
License:LGPL
@SuppressWarnings("serial") public TCViewOverviewTab(final String id, IModel<TCEditableObject> model, TCAttributeVisibilityStrategy attrVisibilityStrategy) { super(id, model, attrVisibilityStrategy); tcId = getTC().getId();//from w ww . j a v a 2 s . com AttributeModifier readonlyModifier = new AttributeAppender("readonly", true, new Model<String>("readonly"), " ") { @Override public boolean isEnabled(Component component) { return !isEditing(); } }; // TITLE final WebMarkupContainer titleRow = new WebMarkupContainer("tc-view-overview-title-row"); titleRow.add(new Label("tc-view-overview-title-label", new InternalStringResourceModel("tc.title.text"))); titleRow.add(new SelfUpdatingTextField("tc-view-overview-title-text", new Model<String>() { @Override public String getObject() { if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Title)) { return TCUtilities.getLocalizedString("tc.case.text") + " " + getTC().getId(); } return getStringValue(TCQueryFilterKey.Title); } @Override public void setObject(String text) { if (isEditing()) { getTC().setTitle(text); } } }).add(readonlyModifier)); // ABSTRACT final WebMarkupContainer abstractRow = new WebMarkupContainer("tc-view-overview-abstract-row"); abstractRow.add( new Label("tc-view-overview-abstract-label", new InternalStringResourceModel("tc.abstract.text"))); abstractRow.add(new SelfUpdatingTextArea("tc-view-overview-abstract-area", new Model<String>() { @Override public String getObject() { if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Abstract)) { return TCUtilities.getLocalizedString("tc.obfuscation.text"); } return getStringValue(TCQueryFilterKey.Abstract); } @Override public void setObject(String text) { if (isEditing()) { getTC().setAbstract(text); } } }).add(readonlyModifier).setOutputMarkupId(true).setMarkupId("tc-view-overview-abstract-area")); // URL final WebMarkupContainer urlRow = new WebMarkupContainer("tc-view-overview-url-row"); urlRow.add(new WebMarkupContainer("tc-view-overview-url-label") .add(new ExternalLink("tc-view-url-link", getTC().getURL()) .add(new Label("tc-view-url-link-title", new InternalStringResourceModel("tc.url.text"))) .add(new Image("tc-view-url-link-follow-image", ImageManager.IMAGE_TC_EXTERNAL)) .add(new TCToolTipAppender("tc.case.url.text")))); urlRow.add(new TextArea<String>("tc-view-overview-url-text", new Model<String>() { @Override public String getObject() { TCObject tc = getTC(); return tc != null ? tc.getURL() : null; } }).add(new AttributeAppender("readonly", true, new Model<String>("readonly"), " "))); // AUTHOR NAME final WebMarkupContainer authorNameRow = new WebMarkupContainer("tc-view-overview-authorname-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorName); } }; authorNameRow.add(new Label("tc-view-overview-authorname-label", new InternalStringResourceModel("tc.author.name.text"))); authorNameRow.add(new SelfUpdatingTextField("tc-view-overview-authorname-text", new Model<String>() { @Override public String getObject() { if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorName)) { return TCUtilities.getLocalizedString("tc.obfuscation.text"); } return getStringValue(TCQueryFilterKey.AuthorName); } @Override public void setObject(String text) { if (isEditing()) { getTC().setAuthorName(text); } } }).add(readonlyModifier)); // AUTHOR AFFILIATION final WebMarkupContainer authorAffiliationRow = new WebMarkupContainer( "tc-view-overview-authoraffiliation-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorAffiliation); } }; authorAffiliationRow.add(new Label("tc-view-overview-authoraffiliation-label", new InternalStringResourceModel("tc.author.affiliation.text"))); authorAffiliationRow .add(new SelfUpdatingTextField("tc-view-overview-authoraffiliation-text", new Model<String>() { @Override public String getObject() { if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorAffiliation)) { return TCUtilities.getLocalizedString("tc.obfuscation.text"); } return getStringValue(TCQueryFilterKey.AuthorAffiliation); } @Override public void setObject(String text) { if (isEditing()) { getTC().setAuthorAffiliation(text); } } }).add(readonlyModifier)); // AUTHOR CONTACT final WebMarkupContainer authorContactRow = new WebMarkupContainer("tc-view-overview-authorcontact-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorContact); } }; authorContactRow.add(new Label("tc-view-overview-authorcontact-label", new InternalStringResourceModel("tc.author.contact.text"))); authorContactRow.add(new SelfUpdatingTextArea("tc-view-overview-authorcontact-area", new Model<String>() { @Override public String getObject() { if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AuthorContact)) { return TCUtilities.getLocalizedString("tc.obfuscation.text"); } return getStringValue(TCQueryFilterKey.AuthorContact); } @Override public void setObject(String text) { if (isEditing()) { getTC().setAuthorContact(text); } } }).add(readonlyModifier)); // KEYWORDS final boolean keywordCodeInput = isEditing() && TCKeywordCatalogueProvider.getInstance().hasCatalogue(TCQueryFilterKey.Keyword); final KeywordsListModel keywordsModel = new KeywordsListModel(); final WebMarkupContainer keywordCodesContainer = new WebMarkupContainer( "tc-view-overview-keyword-input-container"); final ListView<ITextOrCode> keywordCodesView = new ListView<ITextOrCode>( "tc-view-overview-keyword-input-view", keywordsModel) { @Override protected void populateItem(final ListItem<ITextOrCode> item) { final int index = item.getIndex(); AjaxLink<String> addBtn = new AjaxLink<String>("tc-view-overview-keyword-input-add") { @Override public void onClick(AjaxRequestTarget target) { keywordsModel.addKeyword(); target.addComponent(keywordCodesContainer); } }; addBtn.add(new Image("tc-view-overview-keyword-input-add-img", ImageManager.IMAGE_COMMON_ADD) .add(new ImageSizeBehaviour("vertical-align: middle;"))); addBtn.add(new TooltipBehaviour("tc.view.overview.keyword.", "add")); addBtn.setOutputMarkupId(true); addBtn.setVisible(index == 0); AjaxLink<String> removeBtn = new AjaxLink<String>("tc-view-overview-keyword-input-remove") { @Override public void onClick(AjaxRequestTarget target) { keywordsModel.removeKeyword(item.getModelObject()); target.addComponent(keywordCodesContainer); } }; removeBtn.add(new Image("tc-view-overview-keyword-input-remove-img", ImageManager.IMAGE_TC_CANCEL) .add(new ImageSizeBehaviour("vertical-align: middle;"))); removeBtn.add(new TooltipBehaviour("tc.view.overview.keyword.", "remove")); removeBtn.setOutputMarkupId(true); removeBtn.setVisible(index > 0); TCInput keywordInput = TCUtilities.createInput("tc-view-overview-keyword-input", TCQueryFilterKey.Keyword, item.getModelObject(), false); keywordInput.addChangeListener(new ValueChangeListener() { @Override public void valueChanged(ITextOrCode[] values) { keywordsModel.setKeywordAt(index, values != null && values.length > 0 ? values[0] : null); } }); item.setOutputMarkupId(true); item.add(keywordInput.getComponent()); item.add(addBtn); item.add(removeBtn); if (index > 0) { item.add(new AttributeModifier("style", true, new Model<String>("border-top: 4px solid transparent")) { @Override protected String newValue(String currentValue, String newValue) { if (currentValue == null) { return newValue; } else if (newValue == null) { return currentValue; } else { return currentValue + ";" + newValue; } } }); } } }; keywordCodesView.setOutputMarkupId(true); keywordCodesContainer.setOutputMarkupId(true); keywordCodesContainer.setVisible(isEditing()); keywordCodesContainer.add(keywordCodesView); final WebMarkupContainer keywordRow = new WebMarkupContainer("tc-view-overview-keyword-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Keyword); } }; keywordRow.add( new Label("tc-view-overview-keyword-label", new InternalStringResourceModel("tc.keyword.text"))); keywordRow.add(keywordCodesContainer); keywordRow.add(new SelfUpdatingTextArea("tc-view-overview-keyword-area", new Model<String>() { @Override public String getObject() { if (!getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Keyword)) { return TCUtilities.getLocalizedString("tc.obfuscation.text"); } return getShortStringValue(TCQueryFilterKey.Keyword); } @Override public void setObject(String text) { if (isEditing()) { String[] strings = text != null ? text.trim().split(";") : null; List<ITextOrCode> keywords = null; if (strings != null && strings.length > 0) { keywords = new ArrayList<ITextOrCode>(strings.length); for (String s : strings) { keywords.add(TextOrCode.text(s)); } } getTC().setKeywords(keywords); } } }) { @Override public boolean isVisible() { return !keywordCodeInput; } @Override protected void onComponentTag(ComponentTag tag) { tag.put("title", getStringValue(TCQueryFilterKey.Keyword)); //$NON-NLS-1$ } }.add(readonlyModifier).setOutputMarkupId(true).setMarkupId("tc-view-overview-keyword-area")); // ANATOMY anatomyInput = TCUtilities.createInput("tc-view-overview-anatomy-input", TCQueryFilterKey.Anatomy, getTC().getValue(TCQueryFilterKey.Anatomy), true); anatomyInput.getComponent().setVisible(isEditing()); anatomyInput.addChangeListener(new ValueChangeListener() { @Override public void valueChanged(ITextOrCode[] values) { getTC().setAnatomy(values != null && values.length > 0 ? values[0] : null); } }); final WebMarkupContainer anatomyRow = new WebMarkupContainer("tc-view-overview-anatomy-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Anatomy); } }; anatomyRow.add( new Label("tc-view-overview-anatomy-label", new InternalStringResourceModel("tc.anatomy.text"))); anatomyRow.add(anatomyInput.getComponent()); anatomyRow.add(new TextField<String>("tc-view-overview-anatomy-value-label", new Model<String>() { public String getObject() { return getShortStringValue(TCQueryFilterKey.Anatomy); } }) { private static final long serialVersionUID = 3465370488528419531L; @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("title", getStringValue(TCQueryFilterKey.Anatomy)); //$NON-NLS-1$ } @Override public boolean isVisible() { return !isEditing(); } }.add(readonlyModifier)); // PATHOLOGY pathologyInput = TCUtilities.createInput("tc-view-overview-pathology-input", TCQueryFilterKey.Pathology, getTC().getValue(TCQueryFilterKey.Pathology), true); pathologyInput.getComponent().setVisible(isEditing()); pathologyInput.addChangeListener(new ValueChangeListener() { @Override public void valueChanged(ITextOrCode[] values) { getTC().setPathology(values != null && values.length > 0 ? values[0] : null); } }); final WebMarkupContainer pathologyRow = new WebMarkupContainer("tc-view-overview-pathology-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Pathology); } }; pathologyRow.add(new Label("tc-view-overview-pathology-label", new InternalStringResourceModel("tc.pathology.text"))); pathologyRow.add(pathologyInput.getComponent()); pathologyRow.add(new TextField<String>("tc-view-overview-pathology-value-label", new Model<String>() { public String getObject() { return getShortStringValue(TCQueryFilterKey.Pathology); } }) { private static final long serialVersionUID = 3465370488528419531L; @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("title", getStringValue(TCQueryFilterKey.Pathology)); //$NON-NLS-1$ } @Override public boolean isVisible() { return !isEditing(); } }.add(readonlyModifier)); // CATEGORY final TCComboBox<TCQueryFilterValue.Category> categoryCBox = TCUtilities .createEnumComboBox("tc-view-overview-category-select", new Model<Category>() { @Override public Category getObject() { return getTC().getCategory(); } @Override public void setObject(Category value) { getTC().setCategory(value); } }, Arrays.asList(TCQueryFilterValue.Category.values()), true, "tc.category", NullDropDownItem.Undefined, null); final WebMarkupContainer categoryRow = new WebMarkupContainer("tc-view-overview-category-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Category); } }; categoryCBox.setVisible(isEditing()); categoryRow.add( new Label("tc-view-overview-category-label", new InternalStringResourceModel("tc.category.text"))); categoryRow.add(categoryCBox); categoryRow.add(new TextField<String>("tc-view-overview-category-value-label", new Model<String>() { @Override public String getObject() { return getStringValue(TCQueryFilterKey.Category); } }).add(readonlyModifier).setVisible(!isEditing())); // LEVEL final TCComboBox<TCQueryFilterValue.Level> levelCBox = TCUtilities .createEnumComboBox("tc-view-overview-level-select", new Model<Level>() { @Override public Level getObject() { return getTC().getLevel(); } @Override public void setObject(Level level) { getTC().setLevel(level); } }, Arrays.asList(TCQueryFilterValue.Level.values()), true, "tc.level", NullDropDownItem.Undefined, null); final WebMarkupContainer levelRow = new WebMarkupContainer("tc-view-overview-level-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Level); } }; levelCBox.setVisible(isEditing()); levelRow.add(new Label("tc-view-overview-level-label", new InternalStringResourceModel("tc.level.text"))); levelRow.add(new TextField<String>("tc-view-overview-level-value-label", new Model<String>() { @Override public String getObject() { return getStringValue(TCQueryFilterKey.Level); } }).add(readonlyModifier).setVisible(!isEditing())); levelRow.add(levelCBox); // PATIENT SEX final TCComboBox<TCQueryFilterValue.PatientSex> patientSexCBox = TCUtilities .createEnumComboBox("tc-view-overview-patientsex-select", new Model<PatientSex>() { @Override public PatientSex getObject() { return getTC().getPatientSex(); } @Override public void setObject(PatientSex value) { getTC().setPatientSex(value); } }, Arrays.asList(TCQueryFilterValue.PatientSex.values()), true, "tc.patientsex", NullDropDownItem.Undefined, null); final WebMarkupContainer patientSexRow = new WebMarkupContainer("tc-view-overview-patientsex-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.PatientSex); } }; patientSexCBox.setVisible(isEditing()); patientSexRow.add(new Label("tc-view-overview-patientsex-label", new InternalStringResourceModel("tc.patient.sex.text"))); patientSexRow.add(new TextField<String>("tc-view-overview-patientsex-value-label", new Model<String>() { public String getObject() { return getStringValue(TCQueryFilterKey.PatientSex); } }).add(readonlyModifier).setVisible(!isEditing())); patientSexRow.add(patientSexCBox); // PATIENT AGE final TCSpinner<Integer> patientAgeYearSpinner = TCSpinner .createYearSpinner("tc-view-overview-patientage-years-input", new Model<Integer>() { @Override public Integer getObject() { return TCPatientAgeUtilities.toYears(getTC().getPatientAge()); } @Override public void setObject(Integer years) { getTC().setPatientAge(TCPatientAgeUtilities.toDays(years, TCPatientAgeUtilities.toRemainingMonths(getTC().getPatientAge()))); } }, null); final TCSpinner<Integer> patientAgeMonthSpinner = TCSpinner .createMonthSpinner("tc-view-overview-patientage-months-input", new Model<Integer>() { @Override public Integer getObject() { return TCPatientAgeUtilities.toRemainingMonths(getTC().getPatientAge()); } @Override public void setObject(Integer months) { getTC().setPatientAge(TCPatientAgeUtilities .toDays(TCPatientAgeUtilities.toYears(getTC().getPatientAge()), months)); } }, null); final WebMarkupContainer patientAgeRow = new WebMarkupContainer("tc-view-overview-patientage-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.PatientAge); } }; patientAgeYearSpinner.setVisible(isEditing()); patientAgeMonthSpinner.setVisible(isEditing()); patientAgeRow.add(new Label("tc-view-overview-patientage-label", new InternalStringResourceModel("tc.patient.age.text"))); patientAgeRow.add(new TextField<String>("tc-view-overview-patientage-value-label", new Model<String>() { public String getObject() { return TCPatientAgeUtilities.format(getTC().getPatientAge()); } }).add(readonlyModifier).setVisible(!isEditing())); patientAgeRow.add(patientAgeYearSpinner); patientAgeRow.add(patientAgeMonthSpinner); // PATIENT SPECIES List<String> ethnicGroups = WebCfgDelegate.getInstance().getTCEthnicGroups(); boolean ethnicGroupsAvailable = ethnicGroups != null && !ethnicGroups.isEmpty(); SelfUpdatingTextField patientSpeciesField = new SelfUpdatingTextField( "tc-view-overview-patientrace-value-label", new Model<String>() { @Override public String getObject() { return getStringValue(TCQueryFilterKey.PatientSpecies); } @Override public void setObject(String text) { if (isEditing()) { getTC().setPatientSpecies(text); } } }); final WebMarkupContainer patientSpeciesRow = new WebMarkupContainer("tc-view-overview-patientrace-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.PatientSpecies); } }; patientSpeciesRow.add(new Label("tc-view-overview-patientrace-label", new InternalStringResourceModel("tc.patient.species.text"))); patientSpeciesRow.add(patientSpeciesField); patientSpeciesRow .add(TCUtilities.createEditableComboBox("tc-view-overview-patientrace-select", new Model<String>() { @Override public String getObject() { return getTC().getValueAsLocalizedString(TCQueryFilterKey.PatientSpecies, TCViewOverviewTab.this); } @Override public void setObject(String value) { getTC().setValue(TCQueryFilterKey.PatientSpecies, value); } }, ethnicGroups, NullDropDownItem.Undefined, null).add(readonlyModifier) .setVisible(isEditing() && ethnicGroupsAvailable)); patientSpeciesField.setVisible(!isEditing() || !ethnicGroupsAvailable); if (!isEditing()) { patientSpeciesField.add(readonlyModifier); } // MODALITIES final WebMarkupContainer modalitiesRow = new WebMarkupContainer("tc-view-overview-modalities-row") { @Override public boolean isVisible() { return getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.AcquisitionModality); } }; modalitiesRow.add(new Label("tc-view-overview-modalities-label", new InternalStringResourceModel("tc.modalities.text"))); modalitiesRow.add(new SelfUpdatingTextField("tc-view-overview-modalities-text", new Model<String>() { @Override public String getObject() { return getStringValue(TCQueryFilterKey.AcquisitionModality); } @Override public void setObject(String value) { if (isEditing()) { String[] modalities = value != null ? value.trim().split(";") : null; getTC().setValue(TCQueryFilterKey.AcquisitionModality, modalities != null ? Arrays.asList(modalities) : null); } } }).add(readonlyModifier)); // FINDING findingInput = TCUtilities.createInput("tc-view-overview-finding-input", TCQueryFilterKey.Finding, getTC().getValue(TCQueryFilterKey.Finding), true); findingInput.getComponent().setVisible(isEditing()); findingInput.addChangeListener(new ValueChangeListener() { @Override public void valueChanged(ITextOrCode[] values) { getTC().setFinding(values != null && values.length > 0 ? values[0] : null); } }); final WebMarkupContainer findingRow = new WebMarkupContainer("tc-view-overview-finding-row") { @Override public boolean isVisible() { return TCKeywordCatalogueProvider.getInstance().hasCatalogue(TCQueryFilterKey.Finding) && getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Finding); } }; findingRow.add( new Label("tc-view-overview-finding-label", new InternalStringResourceModel("tc.finding.text"))); findingRow.add(findingInput.getComponent()); findingRow.add(new TextField<String>("tc-view-overview-finding-value-label", new Model<String>() { @Override public String getObject() { return getShortStringValue(TCQueryFilterKey.Finding); } }) { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("title", getStringValue(TCQueryFilterKey.Finding)); //$NON-NLS-1$ } @Override public boolean isVisible() { return !isEditing(); } }); // DIAGNOSIS diagnosisInput = TCUtilities.createInput("tc-view-overview-diag-input", TCQueryFilterKey.Diagnosis, getTC().getValue(TCQueryFilterKey.Diagnosis), true); diagnosisInput.getComponent().setVisible(isEditing()); diagnosisInput.addChangeListener(new ValueChangeListener() { @Override public void valueChanged(ITextOrCode[] values) { getTC().setDiagnosis(values != null && values.length > 0 ? values[0] : null); } }); final WebMarkupContainer diagRow = new WebMarkupContainer("tc-view-overview-diag-row") { @Override public boolean isVisible() { return TCKeywordCatalogueProvider.getInstance().hasCatalogue(TCQueryFilterKey.Diagnosis) && getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Diagnosis); } }; diagRow.add(new Label("tc-view-overview-diag-label", new InternalStringResourceModel("tc.diagnosis.text"))); diagRow.add(diagnosisInput.getComponent()); diagRow.add(new TextField<String>("tc-view-overview-diag-value-label", new Model<String>() { @Override public String getObject() { return getShortStringValue(TCQueryFilterKey.Diagnosis); } }) { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("title", getStringValue(TCQueryFilterKey.Diagnosis)); //$NON-NLS-1$ } @Override public boolean isVisible() { return !isEditing(); } }); // DIAGNOSIS CONFIRMED final WebMarkupContainer diagConfirmedRow = new WebMarkupContainer("tc-view-overview-diagconfirmed-row") { @Override public boolean isVisible() { return TCKeywordCatalogueProvider.getInstance().hasCatalogue(TCQueryFilterKey.Diagnosis) && getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.Diagnosis); } }; diagConfirmedRow.add(new Label("tc-view-overview-diagconfirmed-label", new InternalStringResourceModel("tc.diagnosis.confirmed.text"))); diagConfirmedRow.add(new CheckBox("tc-view-overview-diagconfirmed-input", new Model<Boolean>() { @Override public Boolean getObject() { YesNo yesno = getTC().getDiagnosisConfirmed(); if (yesno != null && YesNo.Yes.equals(yesno)) { return true; } else { return false; } } @Override public void setObject(Boolean value) { if (value != null && value == true) { getTC().setDiagnosisConfirmed(YesNo.Yes); } else { getTC().setDiagnosisConfirmed(null); } } }).setEnabled(isEditing())); // DIFFERENTIAL DIAGNOSIS diffDiagnosisInput = TCUtilities.createInput("tc-view-overview-diffdiag-input", TCQueryFilterKey.DifferentialDiagnosis, getTC().getValue(TCQueryFilterKey.DifferentialDiagnosis), true); diffDiagnosisInput.getComponent().setVisible(isEditing()); diffDiagnosisInput.addChangeListener(new ValueChangeListener() { @Override public void valueChanged(ITextOrCode[] values) { getTC().setDiffDiagnosis(values != null && values.length > 0 ? values[0] : null); } }); final WebMarkupContainer diffDiagRow = new WebMarkupContainer("tc-view-overview-diffdiag-row") { @Override public boolean isVisible() { return TCKeywordCatalogueProvider.getInstance().hasCatalogue(TCQueryFilterKey.DifferentialDiagnosis) && getAttributeVisibilityStrategy().isAttributeVisible(TCAttribute.DifferentialDiagnosis); } }; diffDiagRow.add(new Label("tc-view-overview-diffdiag-label", new InternalStringResourceModel("tc.diffdiagnosis.text"))); diffDiagRow.add(diffDiagnosisInput.getComponent()); diffDiagRow.add(new TextField<String>("tc-view-overview-diffdiag-value-label", new Model<String>() { @Override public String getObject() { return getShortStringValue(TCQueryFilterKey.DifferentialDiagnosis); } }) { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("title", getStringValue(TCQueryFilterKey.DifferentialDiagnosis)); //$NON-NLS-1$ } @Override public boolean isVisible() { return !isEditing(); } }); // IMAGE COUNT final WebMarkupContainer imageCountRow = new WebMarkupContainer("tc-view-overview-imagecount-row"); imageCountRow.add(new Label("tc-view-overview-imagecount-label", new InternalStringResourceModel("tc.view.images.count.text"))); imageCountRow.add(new TextField<String>("tc-view-overview-imagecount-value-label", new Model<String>() { public String getObject() { return getTC().getReferencedImages() != null ? Integer.toString(getTC().getReferencedImages().size()) : "0"; } }).add(new AttributeAppender("readonly", true, new Model<String>("readonly"), " "))); add(titleRow); add(abstractRow); add(urlRow); add(authorNameRow); add(authorAffiliationRow); add(authorContactRow); add(keywordRow); add(anatomyRow); add(pathologyRow); add(findingRow); add(diffDiagRow); add(diagRow); add(diagConfirmedRow); add(categoryRow); add(levelRow); add(patientSexRow); add(patientAgeRow); add(patientSpeciesRow); add(modalitiesRow); add(imageCountRow); }