List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow getContentId
public String getContentId()
From source file:org.apache.syncope.client.console.panels.ModalContent.java
License:Apache License
public ModalContent(final ModalWindow window, final PageReference pageRef) { super(window.getContentId()); this.pageRef = pageRef; this.window = window; feedbackPanel = new NotificationPanel(Constants.FEEDBACK); feedbackPanel.setOutputMarkupId(true); add(feedbackPanel);/*from ww w .j av a 2 s .co m*/ }
From source file:org.apache.syncope.console.pages.ResultStatusModalPage.java
License:Apache License
private ResultStatusModalPage(final Builder builder) { super();//from ww w. j av a 2s . c om this.subject = builder.subject; statusUtils = new StatusUtils(this.userRestClient); if (builder.mode == null) { this.mode = UserModalPage.Mode.ADMIN; } else { this.mode = builder.mode; } final BaseModalPage page = this; final WebMarkupContainer container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); add(container); final Fragment fragment = new Fragment("resultFrag", mode == UserModalPage.Mode.SELF ? "userSelfResultFrag" : "propagationResultFrag", this); fragment.setOutputMarkupId(true); container.add(fragment); if (mode == UserModalPage.Mode.ADMIN) { // add Syncope propagation status PropagationStatus syncope = new PropagationStatus(); syncope.setResource("Syncope"); syncope.setStatus(PropagationTaskExecStatus.SUCCESS); List<PropagationStatus> propagations = new ArrayList<PropagationStatus>(); propagations.add(syncope); propagations.addAll(subject.getPropagationStatusTOs()); fragment.add(new Label("info", ((subject instanceof UserTO) && ((UserTO) subject).getUsername() != null) ? ((UserTO) subject).getUsername() : ((subject instanceof RoleTO) && ((RoleTO) subject).getName() != null) ? ((RoleTO) subject).getName() : String.valueOf(subject.getId()))); final ListView<PropagationStatus> propRes = new ListView<PropagationStatus>("resources", propagations) { private static final long serialVersionUID = -1020475259727720708L; @Override protected void populateItem(final ListItem<PropagationStatus> item) { final PropagationStatus propTO = (PropagationStatus) item.getDefaultModelObject(); final ListView attributes = getConnObjectView(propTO); final Fragment attrhead; if (attributes.getModelObject() == null || attributes.getModelObject().isEmpty()) { attrhead = new Fragment("attrhead", "emptyAttrHeadFrag", page); } else { attrhead = new Fragment("attrhead", "attrHeadFrag", page); } item.add(attrhead); item.add(attributes); attrhead.add(new Label("resource", propTO.getResource())); attrhead.add(new Label("propagation", propTO.getStatus() == null ? "UNDEFINED" : propTO.getStatus().toString())); final Image image; final String alt, title; final ModalWindow failureWindow = new ModalWindow("failureWindow"); final AjaxLink<?> failureWindowLink = new AjaxLink<Void>("showFailureWindow") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(AjaxRequestTarget target) { failureWindow.show(target); } }; switch (propTO.getStatus()) { case SUCCESS: case SUBMITTED: case CREATED: image = new Image("icon", IMG_STATUSES + Status.ACTIVE.toString() + Constants.PNG_EXT); alt = "success icon"; title = "success"; failureWindow.setVisible(false); failureWindowLink.setEnabled(false); break; default: image = new Image("icon", IMG_STATUSES + Status.SUSPENDED.toString() + Constants.PNG_EXT); alt = "failure icon"; title = "failure"; } image.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("alt", alt); tag.put("title", title); } }); final FailureMessageModalPage executionFailureMessagePage; if (propTO.getFailureReason() == null) { executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(), StringUtils.EMPTY); } else { executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(), propTO.getFailureReason()); } failureWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return executionFailureMessagePage; } }); failureWindow.setCookieName("failureWindow"); failureWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY); failureWindowLink.add(image); attrhead.add(failureWindowLink); attrhead.add(failureWindow); } }; fragment.add(propRes); } final AjaxLink<Void> close = new IndicatingAjaxLink<Void>("close") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (mode == UserModalPage.Mode.SELF && anonymousUser.equals(SyncopeSession.get().getUsername())) { SyncopeSession.get().invalidate(); } builder.window.close(target); } }; container.add(close); setOutputMarkupId(true); }
From source file:org.artifactory.webapp.actionable.action.CopyAction.java
License:Open Source License
@Override public void onAction(RepoAwareItemEvent event) { RepoPath repoPath = event.getRepoPath(); //Create a modal window and add the move path panel to it ItemEventTargetComponents eventTargetComponents = event.getTargetComponents(); ModalWindow modalWindow = eventTargetComponents.getModalWindow(); CopyPathPanel panel = new CopyPathPanel(modalWindow.getContentId(), repoPath); BaseModalPanel modalPanel = new PanelNestingBorderedModal(panel); modalPanel.setWidth(500);/* w w w . j av a 2s .c om*/ modalPanel.setTitle(String.format("Copy '%s'", repoPath)); modalWindow.setContent(modalPanel); modalWindow.show(event.getTarget()); }
From source file:org.artifactory.webapp.actionable.action.DeleteVersionsAction.java
License:Open Source License
@Override public void onAction(RepoAwareItemEvent event) { RepoAwareActionableItem source = event.getSource(); org.artifactory.fs.ItemInfo info = source.getItemInfo(); RepoPath itemPath = info.getRepoPath(); if (!info.isFolder() && itemPath.getParent() != null) { itemPath = itemPath.getParent(); }/*w ww . j a v a 2 s . c o m*/ RepositoryService repositoryService = getRepoService(); ItemSearchResults<VersionUnitSearchResult> results = repositoryService.getVersionUnitsUnder(itemPath); List<VersionUnit> versionUnits = Lists.newArrayList(); for (VersionUnitSearchResult result : results.getResults()) { versionUnits.add(result.getVersionUnit()); } ItemEventTargetComponents eventTargetComponents = event.getTargetComponents(); ModalWindow modalWindow = eventTargetComponents.getModalWindow(); WebMarkupContainer nodePanelContainer = eventTargetComponents.getNodePanelContainer(); TreeBrowsePanel browseRepoPanel = (TreeBrowsePanel) nodePanelContainer.getParent(); DeleteVersionsPanel panel = new DeleteVersionsPanel(modalWindow.getContentId(), versionUnits, browseRepoPanel, event.getSource()); BaseModalPanel modalPanel = new PanelNestingBorderedModal(panel); modalPanel.setTitle("Delete Versions"); modalWindow.setContent(modalPanel); AjaxRequestTarget target = event.getTarget(); //VfsQueryDb returns -1 if userQueryLimit was exceeded. boolean exceededQueryLimit = results.getFullResultsCount() == -1; String warnMessage = ""; String bubbleMessage = ""; if (exceededQueryLimit) { modalWindow.setInitialWidth(700); //So that the warning text and the bubble are inline warnMessage = "The results shown are limited. Try executing Delete Versions from a node lower in the " + "hierarchy."; bubbleMessage = "The results shown are limited by the artifactory.search.userQueryLimit system property." + "\n You can modify it to get more results, but this can dramatically impact performance on large " + "repositories."; } Label label = new Label("largeQueryWarn", warnMessage); HelpBubble bubble = new HelpBubble("largeQueryWarn.help", bubbleMessage); panel.add(label); panel.add(bubble); label.setVisible(exceededQueryLimit); bubble.setVisible(exceededQueryLimit); modalWindow.show(target); }
From source file:org.artifactory.webapp.actionable.action.MoveAction.java
License:Open Source License
@Override public void onAction(RepoAwareItemEvent event) { RepoPath repoPath = event.getRepoPath(); // create a modal window and add the move path panel to it ItemEventTargetComponents eventTargetComponents = event.getTargetComponents(); // should be the tree Component tree = eventTargetComponents.getRefreshableComponent(); WebMarkupContainer nodaPanelContainer = eventTargetComponents.getNodePanelContainer(); TreeBrowsePanel browseRepoPanel = (TreeBrowsePanel) nodaPanelContainer.getParent(); ModalWindow modalWindow = eventTargetComponents.getModalWindow(); MovePathPanel panel = new MovePathPanel(modalWindow.getContentId(), repoPath, tree, browseRepoPanel); BaseModalPanel modalPanel = new PanelNestingBorderedModal(panel); modalPanel.setWidth(500);//from w w w. ja v a2 s .c o m modalPanel.setTitle(String.format("Move '%s'", repoPath)); modalWindow.setContent(modalPanel); modalWindow.show(event.getTarget()); }
From source file:org.brixcms.plugin.prototype.ManagePrototypesPanel.java
License:Apache License
public ManagePrototypesPanel(String id, final IModel<Workspace> model) { super(id, model); setOutputMarkupId(true);//from www . jav a 2 s .c om IModel<List<Workspace>> prototypesModel = new LoadableDetachableModel<List<Workspace>>() { @Override protected List<Workspace> load() { List<Workspace> list = PrototypePlugin.get().getPrototypes(); return getBrix().filterVisibleWorkspaces(list, Context.ADMINISTRATION); } }; Form<Void> modalWindowForm = new Form<Void>("modalWindowForm"); add(modalWindowForm); final ModalWindow modalWindow = new ModalWindow("modalWindow"); modalWindow.setInitialWidth(64); modalWindow.setWidthUnit("em"); modalWindow.setUseInitialHeight(false); modalWindow.setResizable(false); modalWindow.setTitle(new ResourceModel("selectItems")); modalWindowForm.add(modalWindow); add(new ListView<Workspace>("prototypes", prototypesModel) { @Override protected IModel<Workspace> getListItemModel(IModel<? extends List<Workspace>> listViewModel, int index) { return new WorkspaceModel(listViewModel.getObject().get(index)); } @Override protected void populateItem(final ListItem<Workspace> item) { PrototypePlugin plugin = PrototypePlugin.get(); final String name = plugin.getUserVisibleName(item.getModelObject(), false); item.add(new Label("label", name)); item.add(new Link<Void>("browse") { @Override public void onClick() { model.setObject(item.getModelObject()); } }); item.add(new AjaxLink<Void>("restoreItems") { @Override public void onClick(AjaxRequestTarget target) { String prototypeId = item.getModelObject().getId(); String targetId = ManagePrototypesPanel.this.getModelObject().getId(); Panel panel = new RestoreItemsPanel(modalWindow.getContentId(), prototypeId, targetId); modalWindow.setTitle(new ResourceModel("selectItems")); modalWindow.setContent(panel); modalWindow.show(target); } @Override public boolean isVisible() { Workspace target = ManagePrototypesPanel.this.getModelObject(); Action action = new RestorePrototypeAction(Context.ADMINISTRATION, item.getModelObject(), target); return getBrix().getAuthorizationStrategy().isActionAuthorized(action); } }); item.add(new Link<Void>("delete") { @Override public void onClick() { Workspace prototype = item.getModelObject(); prototype.delete(); } @Override public boolean isVisible() { Action action = new DeletePrototypeAction(Context.ADMINISTRATION, item.getModelObject()); return getBrix().getAuthorizationStrategy().isActionAuthorized(action); } }); } }); Form<Object> form = new Form<Object>("form") { @Override public boolean isVisible() { Workspace current = ManagePrototypesPanel.this.getModelObject(); Action action = new CreatePrototypeAction(Context.ADMINISTRATION, current); return getBrix().getAuthorizationStrategy().isActionAuthorized(action); } }; TextField<String> prototypeName = new TextField<String>("prototypeName", new PropertyModel<String>(this, "prototypeName")); form.add(prototypeName); prototypeName.setRequired(true); prototypeName.add(new UniquePrototypeNameValidator()); final FeedbackPanel feedback; add(feedback = new FeedbackPanel("feedback")); feedback.setOutputMarkupId(true); form.add(new AjaxButton("submit") { @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { String workspaceId = ManagePrototypesPanel.this.getModelObject().getId(); CreatePrototypePanel panel = new CreatePrototypePanel(modalWindow.getContentId(), workspaceId, ManagePrototypesPanel.this.prototypeName); modalWindow.setContent(panel); modalWindow.setTitle(new ResourceModel("selectItemsToCreate")); modalWindow.setWindowClosedCallback(new WindowClosedCallback() { public void onClose(AjaxRequestTarget target) { target.addComponent(ManagePrototypesPanel.this); } }); modalWindow.show(target); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.addComponent(feedback); } }); add(form); }
From source file:org.dcm4chee.web.war.tc.TCResultPanel.java
License:LGPL
@SuppressWarnings("serial") public TCResultPanel(final String id, final TCListModel model, final IModel<Boolean> trainingModeModel) { super(id, model != null ? model : new TCListModel()); setOutputMarkupId(true);//w ww. j av a2 s. com stPermHelper = StudyPermissionHelper.get(); initWebviewerLinkProvider(); add(msgWin); final ModalWindow modalWindow = new ModalWindow("modal-window"); add(modalWindow); final ModalWindow forumWindow = new ModalWindow("forum-window"); add(forumWindow); final TCStudyListPage studyPage = new TCStudyListPage(); final ModalWindow studyWindow = new ModalWindow("study-window"); studyWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; public Page createPage() { return studyPage; } }); add(studyWindow); tclistProvider = new SortableTCListProvider((TCListModel) getDefaultModel()); final TCAttributeVisibilityStrategy attrVisibilityStrategy = new TCAttributeVisibilityStrategy( trainingModeModel); final DataView<TCModel> dataView = new DataView<TCModel>("row", tclistProvider) { private final StudyListLocal dao = (StudyListLocal) JNDIUtils.lookup(StudyListLocal.JNDI_NAME); private final Map<String, List<String>> studyActions = new HashMap<String, List<String>>(); @Override protected void populateItem(final Item<TCModel> item) { final TCModel tc = item.getModelObject(); final StringBuilder jsStopEventPropagationInline = new StringBuilder( "var event=arguments[0] || window.event; if (event.stopPropagation) {event.stopPropagation();} else {event.cancelBubble=True;};"); item.setOutputMarkupId(true); item.add(new TCMultiLineLabel("title", new AbstractReadOnlyModel<String>() { public String getObject() { if (!attrVisibilityStrategy.isAttributeVisible(TCAttribute.Title)) { return TCUtilities.getLocalizedString("tc.case.text") + " " + tc.getId(); } return tc.getTitle(); } }, new AutoClampSettings(40))); item.add(new TCMultiLineLabel("abstract", new AbstractReadOnlyModel<String>() { public String getObject() { if (!attrVisibilityStrategy.isAttributeVisible(TCAttribute.Abstract)) { return TCUtilities.getLocalizedString("tc.obfuscation.text"); } return tc.getAbstract(); } }, new AutoClampSettings(40))); item.add(new TCMultiLineLabel("author", new AbstractReadOnlyModel<String>() { public String getObject() { if (!attrVisibilityStrategy.isAttributeVisible(TCAttribute.AuthorName)) { return TCUtilities.getLocalizedString("tc.obfuscation.text"); } return tc.getAuthor(); } }, new AutoClampSettings(40))); item.add(new Label("date", new Model<Date>(tc.getCreationDate())) { private static final long serialVersionUID = 1L; @Override public IConverter getConverter(Class<?> type) { return new DateConverter() { private static final long serialVersionUID = 1L; @Override public DateFormat getDateFormat(Locale locale) { if (locale == null) { locale = Locale.getDefault(); } return DateFormat.getDateInstance(DateFormat.MEDIUM, locale); } }; } }); final String stuid = tc.getStudyInstanceUID(); if (dao != null && !studyActions.containsKey(stuid)) { studyActions.put(stuid, dao.findStudyPermissionActions(stuid, stPermHelper.getDicomRoles())); } item.add(Webviewer.getLink(tc, webviewerLinkProviders, stPermHelper, new TooltipBehaviour("tc.result.table.", "webviewer"), modalWindow, new WebviewerLinkClickedCallback() { public void linkClicked(AjaxRequestTarget target) { TCAuditLog.logTFImagesViewed(tc); } }).add(new SecurityBehavior(TCPanel.getModuleName() + ":webviewerInstanceLink"))); final Component viewLink = new IndicatingAjaxLink<String>("tc-view") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { selectTC(item, tc, target); openTC(tc, false, target); } protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("ondblclick", jsStopEventPropagationInline); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { try { return TCPanel.getMaskingBehaviour().getAjaxCallDecorator(); } catch (Exception e) { log.error("Failed to get IAjaxCallDecorator: ", e); } return null; } }.add(new Image("tcViewImg", ImageManager.IMAGE_COMMON_DICOM_DETAILS) .add(new ImageSizeBehaviour("vertical-align: middle;"))) .add(new TooltipBehaviour("tc.result.table.", "view")).setOutputMarkupId(true); final Component editLink = new IndicatingAjaxLink<String>("tc-edit") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { selectTC(item, tc, target); openTC(tc, true, target); } protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("ondblclick", jsStopEventPropagationInline); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { try { return TCPanel.getMaskingBehaviour().getAjaxCallDecorator(); } catch (Exception e) { log.error("Failed to get IAjaxCallDecorator: ", e); } return null; } }.add(new Image("tcEditImg", ImageManager.IMAGE_COMMON_DICOM_EDIT) .add(new ImageSizeBehaviour("vertical-align: middle;"))) .add(new TooltipBehaviour("tc.result.table.", "edit")) .add(new SecurityBehavior(TCPanel.getModuleName() + ":editTC")).setOutputMarkupId(true); final Component studyLink = new IndicatingAjaxLink<String>("tc-study") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { selectTC(item, tc, target); try { TCObject tcObject = TCObject.create(tc); List<TCReferencedStudy> refStudies = tcObject.getReferencedStudies(); if (refStudies != null && !refStudies.isEmpty()) { if (refStudies.size() == 1) { studyPage.setStudyInstanceUID(refStudies.get(0).getStudyUID()); } else { studyPage.setPatientIdAndIssuer(tc.getPatientId(), tc.getIssuerOfPatientId()); } } if (studyPage.getStudyInstanceUID() != null || studyPage.getPatientId() != null) { studyPage.getStudyViewPort().clear(); studyWindow .setTitle(new StringResourceModel("tc.result.studywindow.title", this, null, new Object[] { maskNull(cutAtISOControl(tc.getTitle(), 40), "?"), maskNull(cutAtISOControl(tc.getAbstract(), 25), "?"), maskNull(cutAtISOControl(tc.getAuthor(), 20), "?"), maskNull(tc.getCreationDate(), tc.getCreatedTime()) })); studyWindow.setInitialWidth(1200); studyWindow.setInitialHeight(600); studyWindow.setMinimalWidth(800); studyWindow.setMinimalHeight(400); if (studyWindow.isShown()) { log.warn("###### StudyView is already shown ???!!!"); try { Field showField = ModalWindow.class.getDeclaredField("shown"); showField.setAccessible(true); showField.set(studyWindow, false); } catch (Exception e) { log.error("Failed to reset shown Field from ModalWindow!"); } log.info("###### studyWindow.isShown():" + studyWindow.isShown()); } studyWindow.show(target); } else { log.warn("Showing TC referenced studies discarded: No referened study found!"); msgWin.setInfoMessage(getString("tc.result.studywindow.noStudies")); msgWin.show(target); } } catch (Exception e) { msgWin.setErrorMessage(getString("tc.result.studywindow.failed")); msgWin.show(target); log.error("Unable to show TC referenced studies!", e); } } @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("ondblclick", jsStopEventPropagationInline); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { try { return TCPanel.getMaskingBehaviour().getAjaxCallDecorator(); } catch (Exception e) { log.error("Failed to get IAjaxCallDecorator: ", e); } return null; } }.add(new Image("tcStudyImg", ImageManager.IMAGE_COMMON_SEARCH) .add(new ImageSizeBehaviour("vertical-align: middle;"))) .add(new TooltipBehaviour("tc.result.table.", "showStudy")) .add(new SecurityBehavior(TCPanel.getModuleName() + ":showTCStudy")) .setOutputMarkupId(true); final Component forumLink = new IndicatingAjaxLink<String>("tc-forum") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { try { TCForumPostsPanel content = new TCForumPostsPanel(forumWindow.getContentId(), new Model<String>(TCForumIntegration .get(WebCfgDelegate.getInstance().getTCForumIntegrationType()) .getPostsPageURL(tc))); forumWindow.setInitialHeight(820); forumWindow.setInitialWidth(1024); forumWindow.setContent(content); forumWindow.show(target); } catch (Exception e) { log.error("Unable to open case forum page!", e); } } @Override public boolean isVisible() { return TCForumIntegration .get(WebCfgDelegate.getInstance().getTCForumIntegrationType()) != null; } @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("ondblclick", jsStopEventPropagationInline); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { try { return TCPanel.getMaskingBehaviour().getAjaxCallDecorator(); } catch (Exception e) { log.error("Failed to get IAjaxCallDecorator: ", e); } return null; } }.add(new Image("tcForumImg", ImageManager.IMAGE_TC_FORUM) .add(new ImageSizeBehaviour("vertical-align: middle;"))) .add(new TooltipBehaviour("tc.result.table.", "showForum")).setOutputMarkupId(true); item.add(viewLink); item.add(editLink); item.add(studyLink); item.add(forumLink); item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { if (selected != null && selected.equals(tc)) { return "mouse-out-selected"; } else { return item.getIndex() % 2 == 1 ? "even-mouse-out" : "odd-mouse-out"; } } })); item.add(new AttributeModifier("selected", true, new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { if (selected != null && selected.equals(tc)) { return "selected"; } else { return null; } } })); item.add(new AttributeModifier("onmouseover", true, new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { StringBuffer sbuf = new StringBuffer(); sbuf.append("if ($(this).attr('selected')==null) {"); sbuf.append(" $(this).removeClass();"); sbuf.append(" if (").append(item.getIndex()) .append("%2==1) $(this).addClass('even-mouse-over');"); sbuf.append(" else $(this).addClass('odd-mouse-over');"); sbuf.append("}"); return sbuf.toString(); } })); item.add(new AttributeModifier("onmouseout", true, new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { StringBuffer sbuf = new StringBuffer(); sbuf.append("if ($(this).attr('selected')==null) {"); sbuf.append(" $(this).removeClass();"); sbuf.append(" if (").append(item.getIndex()) .append("%2==1) $(this).addClass('even-mouse-out');"); sbuf.append(" else $(this).addClass('odd-mouse-out');"); sbuf.append("}"); return sbuf.toString(); } })); item.add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { selectTC(item, tc, target); } }); item.add(new AjaxEventBehavior("ondblclick") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { boolean edit = WebCfgDelegate.getInstance().getTCEditOnDoubleClick(); if (edit) { edit = SecureComponentHelper.isActionAuthorized(editLink, "render"); } openTC(selected, edit, target); } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { try { return new IAjaxCallDecorator() { private static final long serialVersionUID = 1L; public final CharSequence decorateScript(CharSequence script) { return "if(typeof showMask == 'function') { showMask(); $('body').css('cursor','wait'); };" + script; } public final CharSequence decorateOnSuccessScript(CharSequence script) { return "hideMask();$('body').css('cursor','');" + script; } public final CharSequence decorateOnFailureScript(CharSequence script) { return "hideMask();$('body').css('cursor','');" + script; } }; } catch (Exception e) { log.error("Failed to get IAjaxCallDecorator: ", e); } return null; } }); } }; dataView.setItemReuseStrategy(new ReuseIfModelsEqualStrategy()); dataView.setItemsPerPage(WebCfgDelegate.getInstance().getDefaultFolderPagesize()); dataView.setOutputMarkupId(true); SortLinkGroup sortGroup = new SortLinkGroup(dataView); add(new SortLink("sortTitle", sortGroup, TCModel.Sorter.Title)); add(new SortLink("sortAbstract", sortGroup, TCModel.Sorter.Abstract)); add(new SortLink("sortDate", sortGroup, TCModel.Sorter.Date)); add(new SortLink("sortAuthor", sortGroup, TCModel.Sorter.Author)); add(dataView); add(new Label("numberOfMatchingInstances", new StringResourceModel("tc.list.numberOfMatchingInstances", this, null, new Object[] { new Model<Integer>() { private static final long serialVersionUID = 1L; @Override public Integer getObject() { return ((TCListModel) TCResultPanel.this.getDefaultModel()).getObject().size(); } } }))); add(new PagingNavigator("navigator", dataView)); }
From source file:org.efaps.ui.wicket.components.bpm.process.ActionPanel.java
License:Apache License
/** * @param _wicketID component id/*w ww . j av a 2 s . c o m*/ * @param _model model for contact * @param _pageReference reference to the calling page */ public ActionPanel(final String _wicketID, final IModel<UIProcessInstanceLog> _model, final PageReference _pageReference) { super(_wicketID, _model); final ModalWindow modal = new AbstractModalWindow("modal", _model) { private static final long serialVersionUID = 1L; }.setInitialWidth(200).setInitialHeight(100); this.add(modal); final AjaxLink<UIProcessInstanceLog> select = new AjaxLink<UIProcessInstanceLog>("select", _model) { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget _target) { final UIProcessInstanceLog processinstance = (UIProcessInstanceLog) getDefaultModelObject(); if (processinstance != null) { getPage().visitChildren(AjaxFallbackDefaultDataTable.class, new IVisitor<AjaxFallbackDefaultDataTable<?, ?>, Void>() { @Override public void component(final AjaxFallbackDefaultDataTable<?, ?> _table, final IVisit<Void> _visit) { final IDataProvider<?> provider = _table.getDataProvider(); if (provider instanceof NodeInstanceProvider) { ((NodeInstanceProvider) provider) .setProcessInstanceId(processinstance.getProcessInstanceId()); ((NodeInstanceProvider) provider).requery(); _target.add(_table); } else if (provider instanceof VariableInstanceProvider) { ((VariableInstanceProvider) provider) .setProcessInstanceId(processinstance.getProcessInstanceId()); ((VariableInstanceProvider) provider).requery(); _target.add(_table); } } }); } } }; add(select); final AjaxLink<UIProcessInstanceLog> abort = new AjaxLink<UIProcessInstanceLog>("abort", _model) { private static final long serialVersionUID = 1L; @Override public void onClick(final AjaxRequestTarget _target) { modal.setContent(new AjaxButton<UIProcessInstanceLog>(modal.getContentId(), _model, Button.ICON.ACCEPT.getReference(), "OK") { private static final long serialVersionUID = 1L; @Override public void onSubmit(final AjaxRequestTarget _target) { final UIProcessInstanceLog processinstance = (UIProcessInstanceLog) getDefaultModelObject(); BPM.abortProcessInstance(processinstance.getProcessInstanceId()); modal.close(_target); } }); modal.show(_target); } }; add(abort); }
From source file:org.geoserver.community.css.web.CssDemoPage.java
License:Open Source License
private void doMainLayout() { final Fragment mainContent = new Fragment("main-content", "normal", this); final ModalWindow popup = new ModalWindow("popup"); mainContent.add(popup);//w ww. j a v a 2s . com final StyleNameModel styleNameModel = new StyleNameModel(style); final PropertyModel layerNameModel = new PropertyModel(layer, "prefixedName"); mainContent.add(new AjaxLink("create.style", new ParamResourceModel("CssDemoPage.createStyle", this)) { public void onClick(AjaxRequestTarget target) { target.appendJavascript("Wicket.Window.unloadConfirmation = false;"); popup.setInitialHeight(200); popup.setInitialWidth(300); popup.setTitle(new Model("Choose name for new style")); popup.setContent(new StyleNameInput(popup.getContentId(), CssDemoPage.this)); popup.show(target); } }); mainContent.add(new SimpleAjaxLink("change.style", styleNameModel) { public void onClick(AjaxRequestTarget target) { target.appendJavascript("Wicket.Window.unloadConfirmation = false;"); popup.setInitialHeight(400); popup.setInitialWidth(600); popup.setTitle(new Model("Choose style to edit")); popup.setContent(new StyleChooser(popup.getContentId(), CssDemoPage.this)); popup.show(target); } }); mainContent.add(new SimpleAjaxLink("change.layer", layerNameModel) { public void onClick(AjaxRequestTarget target) { target.appendJavascript("Wicket.Window.unloadConfirmation = false;"); popup.setInitialHeight(400); popup.setInitialWidth(600); popup.setTitle(new Model("Choose layer to edit")); popup.setContent(new LayerChooser(popup.getContentId(), CssDemoPage.this)); popup.show(target); } }); mainContent .add(new AjaxLink("associate.styles", new ParamResourceModel("CssDemoPage.associateStyles", this)) { public void onClick(AjaxRequestTarget target) { target.appendJavascript("Wicket.Window.unloadConfirmation = false;"); popup.setInitialHeight(400); popup.setInitialWidth(600); popup.setTitle(new Model("Choose layers to associate")); popup.setContent(new MultipleLayerChooser(popup.getContentId(), CssDemoPage.this)); popup.show(target); } }); ParamResourceModel associateToLayer = new ParamResourceModel("CssDemoPage.associateDefaultStyle", this, styleNameModel, layerNameModel); final SimpleAjaxLink associateDefaultStyle = new SimpleAjaxLink("associate.default.style", new Model(), associateToLayer) { public void onClick(final AjaxRequestTarget linkTarget) { final Component theComponent = this; dialog.setResizable(false); dialog.setHeightUnit("em"); dialog.setWidthUnit("em"); dialog.setInitialHeight(7); dialog.setInitialWidth(50); dialog.showOkCancel(linkTarget, new DialogDelegate() { boolean success = false; @Override protected boolean onSubmit(AjaxRequestTarget target, Component contents) { layer.setDefaultStyle(style); getCatalog().save(layer); theComponent.setEnabled(false); success = true; return true; } @Override public void onClose(AjaxRequestTarget target) { super.onClose(target); target.addComponent(theComponent); if (success) { CssDemoPage.this.info(new ParamResourceModel("CssDemoPage.styleAssociated", CssDemoPage.this, styleNameModel, layerNameModel).getString()); target.addComponent(getFeedbackPanel()); } } @Override protected Component getContents(String id) { ParamResourceModel confirm = new ParamResourceModel("CssDemoPage.confirmAssocation", CssDemoPage.this, styleNameModel.getObject(), layerNameModel.getObject(), layer.getDefaultStyle().getName()); return new Label(id, confirm); } }); } }; associateDefaultStyle.setOutputMarkupId(true); if (layer.getDefaultStyle().equals(style)) { associateDefaultStyle.setEnabled(false); } mainContent.add(associateDefaultStyle); final IModel<String> sldModel = new AbstractReadOnlyModel<String>() { public String getObject() { try { // if file already in css format transform to sld, otherwise load the SLD file if (CssHandler.FORMAT.equals(style.getFormat())) { StyledLayerDescriptor sld = Styles.sld(style.getStyle()); return Styles.string(sld, new SLDHandler(), SLDHandler.VERSION_10, true); } else { File file = findStyleFile(style); if (file != null && file.isFile()) { BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); StringBuilder builder = new StringBuilder(); char[] line = new char[4096]; int len = 0; while ((len = reader.read(line, 0, 4096)) >= 0) builder.append(line, 0, len); return builder.toString(); } finally { if (reader != null) reader.close(); } } else { return "No SLD file found for this style. One will be generated automatically if you save the CSS."; } } } catch (IOException e) { throw new WicketRuntimeException(e); } } }; final CompoundPropertyModel model = new CompoundPropertyModel<CssDemoPage>(CssDemoPage.this); List<ITab> tabs = new ArrayList<ITab>(); tabs.add(new PanelCachingTab(new AbstractTab(new Model("Generated SLD")) { public Panel getPanel(String id) { SLDPreviewPanel panel = new SLDPreviewPanel(id, sldModel); sldPreview = panel.getLabel(); return panel; } })); tabs.add(new PanelCachingTab(new AbstractTab(new Model("Map")) { public Panel getPanel(String id) { return map = new OpenLayersMapPanel(id, layer, style); } })); if (layer.getResource() instanceof FeatureTypeInfo) { tabs.add(new PanelCachingTab(new AbstractTab(new Model("Data")) { public Panel getPanel(String id) { try { return new DataPanel(id, model, (FeatureTypeInfo) layer.getResource()); } catch (IOException e) { throw new WicketRuntimeException(e); } }; })); } else if (layer.getResource() instanceof CoverageInfo) { tabs.add(new PanelCachingTab(new AbstractTab(new Model("Data")) { public Panel getPanel(String id) { return new BandsPanel(id, (CoverageInfo) layer.getResource()); }; })); } tabs.add(new AbstractTab(new Model("CSS Reference")) { public Panel getPanel(String id) { return new DocsPanel(id); } }); File sldFile = findStyleFile(style); File cssFile = new File(sldFile.getParentFile(), style.getName() + ".css"); mainContent.add(new StylePanel("style.editing", model, CssDemoPage.this, cssFile)); mainContent.add(new AjaxTabbedPanel("context", tabs)); add(mainContent); add(dialog = new GeoServerDialog("dialog")); }
From source file:org.geoserver.qos.web.LayersListModalBuilder.java
License:Open Source License
@Override public WebMarkupContainer build(WebMarkupContainer mainDiv, ModalWindow modalWindow, IModel<LimitedAreaRequestConstraints> model) { WebMarkupContainer layersDiv = new WebMarkupContainer("layersDiv"); layersDiv.setOutputMarkupId(true);/* w w w. j av a 2 s .co m*/ mainDiv.add(layersDiv); final ListView<String> layersListView = new ListView<String>("layersList", new PropertyModel<>(model, "layerNames")) { @Override protected void populateItem(ListItem<String> item) { TextField<String> layerField = new TextField<>("layerName", item.getModel()); layerField.setEnabled(false); item.add(layerField); AjaxSubmitLink deleteLayerLink = new AjaxSubmitLink("deleteLayer") { @Override protected void onAfterSubmit(AjaxRequestTarget target, Form<?> form) { super.onAfterSubmit(target, form); model.getObject().getLayerNames().remove(item.getModel().getObject()); target.add(mainDiv); } }; item.add(deleteLayerLink); } }; layersDiv.add(layersListView); final AjaxLink addLayerLink = new AjaxLink("addLayer") { @Override public void onClick(AjaxRequestTarget target) { modalWindow.setInitialHeight(375); modalWindow.setInitialWidth(525); modalWindow.setTitle("Choose layer"); WorkspaceInfo wsi = mainDiv.findParent(QosWmsAdminPanel.class).getMainModel().getObject() .getWorkspace(); modalWindow.setContent(new LayerListPanel(modalWindow.getContentId(), wsi) { @Override protected void handleLayer(org.geoserver.catalog.LayerInfo layer, AjaxRequestTarget target) { if (!model.getObject().getLayerNames().contains(model.getObject().getLayerNames())) { model.getObject().getLayerNames().add(layer.prefixedName()); } modalWindow.close(target); target.add(mainDiv); }; }); modalWindow.show(target); } }; layersDiv.add(addLayerLink); return layersDiv; }