List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow show
public void show(final IPartialPageRequestHandler target)
From source file:hsa.awp.usergui.FlatListPanel.java
License:Open Source License
/** * Constructor for the FlatList panel, which defines all needed components. * * @param id ID which declares the location in the markup. *//* w w w .j av a 2 s .c o m*/ public FlatListPanel(String id, final Campaign campaign) { super(id); this.campaign = campaign; singleUser = controller.getUserById(SecurityContextHolder.getContext().getAuthentication().getName()); // find events where user is allowed events = controller.getEventsWhereRegistrationIsAllowed(campaign, singleUser); // find categories with events where user is allowed categories = getCategoriesOfEvents(events); // find events of category where user is allowed final LoadableDetachedModel<List<Category>> categoriesModel = new LoadableDetachedModel<List<Category>>() { /** * unique serialization id. */ private static final long serialVersionUID = 1594571791900639307L; @Override protected List<Category> load() { List<Category> categoryList = new ArrayList<Category>(categories); Collections.sort(categoryList, EventSorter.alphabeticalCategoryName()); return categoryList; } }; final WebMarkupContainer flatListContainer = new WebMarkupContainer("flatlist.container"); flatListContainer.setOutputMarkupId(true); flatListContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(30f))); add(flatListContainer); add(new Label("flatlist.capacityDE", new Model<Integer>((int) (capacityPercent * 100)))); add(new Label("flatlist.capacityEN", new Model<Integer>((int) (capacityPercent * 100)))); flatListContainer.add(new ListView<Category>("categorylist", categoriesModel) { /** * Generated serialization id. */ private static final long serialVersionUID = 490760462608363776L; @Override protected void populateItem(ListItem<Category> item) { List<Event> eventsOfCategory = getEventsOfCategory(item.getModelObject(), events); item.add(new Label("categoryname", item.getModelObject().getName())); item.add(new ListView<Event>("eventlist", eventsOfCategory) { /** * Generated serialization id. */ private static final long serialVersionUID = 497760462608363776L; @SuppressWarnings("serial") @Override protected void populateItem(final ListItem<Event> item) { final Event event = item.getModelObject(); int maxParticipants = event.getMaxParticipants(); long participantCount = controller.countConfirmedRegistrationsByEventId(event.getId()); if (participantCount > maxParticipants) { participantCount = maxParticipants; } item.add(new Label("eventNumber", formatEventId(event))); item.add(new Label("subjectname", event.getSubject().getName())); item.add(new Label("eventdescription", formatDetailInformation(event))); item.add(new Label("eventplaces", "(" + participantCount + "/" + maxParticipants + ")")); Link<Object> link = new Link<Object>("submited") { public void onClick() { Procedure procedure = campaign.findCurrentProcedure(); FifoProcedure fifo; if (procedure instanceof FifoProcedure) { fifo = (FifoProcedure) procedure; } else { throw new IllegalStateException("Flatlist works only with Fifoprocedure."); } String initiator = SecurityContextHolder.getContext().getAuthentication().getName(); controller.registerWithFifoProcedure(fifo, event, initiator, initiator, true); } }; Image icon = new Image("icon"); icon.add(new AttributeModifier("src", true, new Model<String>())); if (controller.hasParticipantConfirmedRegistrationInEvent(singleUser, event)) { link.setVisible(false); item.add(new AttributeAppender("class", new Model<String>("disabled"), " ")); } if ((maxParticipants - participantCount) <= 0) { link.setEnabled(false); item.add(new AttributeAppender("class", new Model<String>("disabled"), " ")); icon.add(new AttributeModifier("src", true, new Model<String>("images/red.png"))); } else if ((Float.valueOf(maxParticipants - participantCount) / maxParticipants) <= capacityPercent) { icon.add(new AttributeModifier("src", true, new Model<String>("images/yellow.png"))); } else { icon.add(new AttributeModifier("src", true, new Model<String>("images/green.png"))); } link.add(icon); link.add(new JavascriptEventConfirmation("onclick", "Sind Sie sicher?")); item.add(link); final ModalWindow detailWindow = new ModalWindow("detailWindow"); detailWindow.setTitle(new Model<String>("Veranstaltungsdetails")); detailWindow.setInitialWidth(450); item.add(detailWindow); item.add(new AjaxFallbackLink<Object>("infoLink") { /** * unique serialization id. */ private static final long serialVersionUID = 543607735730300949L; @Override public void onClick(AjaxRequestTarget target) { detailWindow.setContent(new EventDetailPanel(detailWindow.getContentId(), event)); detailWindow.show(target); } }); } }); } }); LoadableDetachedModel<String> dateModel = new LoadableDetachedModel<String>() { /** * unique serialization id. */ private static final long serialVersionUID = -3714278116173742179L; @Override protected String load() { DateFormat singleFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); return singleFormat.format(Calendar.getInstance().getTime()); } }; flatListContainer.add(new Label("flatlist.date", dateModel)); flatListContainer.add(new AjaxFallbackLink<Object>("flatlist.refresh") { /** * unique serialization id. */ private static final long serialVersionUID = 8370439147861506762L; @Override public void onClick(AjaxRequestTarget target) { categoriesModel.detach(); target.addComponent(flatListContainer); } }); flatListContainer.add(new Label("flatlist.userInfo", new LoadableDetachedModel<String>() { @Override protected String load() { //Kampangenname: Phase: Phasenname vom xx.xx.xx. hh:mm bis xx.xx.xx hh:mm StringBuilder sb = new StringBuilder(); sb.append(campaign.getName()); sb.append(": Phase: "); Procedure currentProcedure = campaign.findCurrentProcedure(); sb.append(currentProcedure.getName()); sb.append(" vom "); DateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm"); sb.append(df.format(currentProcedure.getStartDate().getTime())); sb.append(" bis "); sb.append(df.format(currentProcedure.getEndDate().getTime())); return sb.toString(); } })); }
From source file:hsa.awp.usergui.util.DragableElement.java
License:Open Source License
/** * Constructor for the DragableElement./* www .j a v a2 s . c o m*/ * * @param id Wicket id * @param event event to display * @param isActive true if draggabiliy is given */ public DragableElement(String id, final Event event, boolean isActive) { super(id); this.event = event; this.setOutputMarkupId(true); WebMarkupContainer box = new WebMarkupContainer("prioListDragableElement.element"); String eventString = formatEventId(event) + " " + event.getSubject().getName(); box.add(new Label("prioListDragableElement.title", eventString)); box.add(new Label("prioListDragableElement.info", formatDetailInformation(event))); final ModalWindow detailWindow = new ModalWindow("prioListDragableElement.detailWindow"); detailWindow.setContent(new AjaxLazyLoadPanel(detailWindow.getContentId()) { /** * */ private static final long serialVersionUID = -822132746613326567L; @Override public Component getLazyLoadComponent(String markupId) { return new EventDetailPanel(markupId, event); } }); detailWindow.setTitle(new Model<String>("Veranstaltungsdetails")); detailWindow.setInitialWidth(450); box.add(detailWindow); box.add(new AjaxFallbackLink<Object>("prioListDragableElement.infoLink") { /** * unique serialization id. */ private static final long serialVersionUID = 543607735730300949L; @Override public void onClick(AjaxRequestTarget target) { detailWindow.show(target); } }); if (isActive) { dragBehavior = new DraggableBehavior(); dragBehavior.setRevert(true); box.add(dragBehavior); box.add(new AttributeAppender("class", new Model<String>("draggable"), " ")); } add(box); }
From source file:mil.nga.giat.elasticsearch.ElasticConfigurationPanel.java
License:Open Source License
/** * Adds Elasticsearch configuration panel link, configure modal dialog and * implements modal callback.// w w w . j av a 2s .c om * * @see {@link ElasticConfigurationPage#done} */ public ElasticConfigurationPanel(final String panelId, final IModel model) { super(panelId, model); final FeatureTypeInfo fti = (FeatureTypeInfo) model.getObject(); final ModalWindow modal = new ModalWindow("modal"); modal.setInitialWidth(800); modal.setTitle(new ParamResourceModel("modalTitle", ElasticConfigurationPanel.this)); modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { @Override public void onClose(AjaxRequestTarget target) { if (_layerInfo != null) { GeoServerApplication app = (GeoServerApplication) getApplication(); final FeatureTypeInfo ft = (FeatureTypeInfo) getResourceInfo(); app.getCatalog().getResourcePool().clear(ft); app.getCatalog().getResourcePool().clear(ft.getStore()); setResponsePage(new ElasticResourceConfigurationPage(ft)); } } }); if (fti.getMetadata().get(ElasticLayerConfiguration.KEY) == null) { modal.add(new OpenWindowOnLoadBehavior()); } modal.setContent(new ElasticConfigurationPage(panelId, model) { @Override void done(AjaxRequestTarget target, LayerInfo layerInfo, ElasticLayerConfiguration layerConfig) { _layerInfo = layerInfo; _layerConfig = layerConfig; modal.close(target); } }); add(modal); AjaxLink findLink = new AjaxLink("edit") { @Override public void onClick(AjaxRequestTarget target) { modal.show(target); } }; final Fragment attributePanel = new Fragment("esPanel", "esPanelFragment", this); attributePanel.setOutputMarkupId(true); add(attributePanel); attributePanel.add(findLink); }
From source file:net.kornr.swit.site.buttoneditor.ButtonEditor.java
License:Apache License
private void init() { this.innerAdd(new Image("logo", ButtonResource.getReference(), ButtonResource.getValueMap(s_logoTemplate, "The Swit Buttons Generator"))); m_codeEncoder = new ButtonCodeMaker(m_selectedDescriptor, m_currentProperties, new PropertyModel<String>(this, "text")); final Form form = new Form("form") { @Override// w w w . java 2 s. co m protected void onSubmit() { if (((WebRequest) (WebRequestCycle.get().getRequest())).isAjax() == false) createButton(null); } }; this.innerAdd(form); Border sampleborder = new TableImageBorder("sampleborder", s_border3, Color.white); form.add(sampleborder); WebMarkupContainer samplecont = new WebMarkupContainer("samplecontainer"); sampleborder.add(samplecont); samplecont.add((m_sample = new Image("sample")).setOutputMarkupId(true)); sampleborder .add(new ColorPickerField("samplebgcolor", new PropertyModel<String>(this, "bgcolor"), samplecont)); ImageButton submit = new ImageButton("submit", ButtonResource.getReference(), ButtonResource.getValueMap(s_buttonTemplate, "Update that button, now!")); sampleborder.add(submit); submit.add(new AjaxFormSubmitBehavior(form, "onclick") { @Override protected void onError(AjaxRequestTarget arg0) { } @Override protected void onSubmit(AjaxRequestTarget target) { createButton(target); } @Override protected CharSequence getEventHandler() { return new AppendingStringBuffer(super.getEventHandler()).append("; return false;"); } }); sampleborder.add(m_downloadLink = new MutableResourceReferenceLink("downloadbutton", ButtonResource.getReference(), null)); m_downloadLink.setOutputMarkupId(true); // this.innerAdd(m_codeLabel = new Label("code", new PropertyModel(m_codeEncoder, "code"))); // m_codeLabel.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true).setEscapeModelStrings(false); // m_codeLabel.setVisible(true); final ModalWindow codewindow = new ModalWindow("code"); this.innerAdd(codewindow); Fragment codefrag = new Fragment(codewindow.getContentId(), "codepanel", this); Label lcode = new Label("code", new PropertyModel(m_codeEncoder, "code")); codefrag.add(lcode); codewindow.setContent(codefrag); codewindow.setTitle("Java Code"); codewindow.setCookieName("switjavacodewindow"); sampleborder.add(new AjaxLink("showwindowcode") { @Override public void onClick(AjaxRequestTarget target) { codewindow.show(target); } }); form.add((m_feedback = new FeedbackPanel("feedback")).setOutputMarkupId(true) .setOutputMarkupPlaceholderTag(true)); ThreeColumnsLayoutManager layout = new ThreeColumnsLayoutManager("2col-layout", s_layout); form.add(layout); ColumnPanel rightcol = layout.getRightColumn(); ColumnPanel leftcol = layout.getLeftColumn(); Border textborder = new TableImageBorder("textborder", s_shadow, s_blocColor); layout.add(textborder); textborder.add(new TextField<String>("button-text", new PropertyModel<String>(this, "text"))); Border buttonsborder = new TableImageBorder("buttonsborder", s_shadow, s_blocColor); layout.add(buttonsborder); buttonsborder.add(new ListView<ButtonDescriptor>("types", s_buttons) { @Override protected void populateItem(ListItem<ButtonDescriptor> item) { final IModel<ButtonDescriptor> model = item.getModel(); ButtonDescriptor bd = item.getModelObject(); ButtonTemplate tmpl = s_buttonsTemplates.get(bd.getName()); if (tmpl == null) { tmpl = bd.createTemplate(); try { List<ButtonProperty> props = bd.getProperties(); bd.applyProperties(tmpl, props); tmpl.setWidth(200); tmpl.setFont(s_defaultButtonFont); tmpl.setFontColor(Color.white); tmpl.setShadowDisplayed(true); tmpl.addEffect(new ShadowBorder(4, 0, 0, Color.black)); tmpl.setAutoExtend(true); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } s_buttonsTemplates.put(bd.getName(), tmpl); } ImageButton button = new ImageButton("sample", ButtonResource.getReference(), ButtonResource.getValueMap(tmpl, bd.getName())); item.add(button); button.add(new AjaxFormSubmitBehavior(form, "onclick") { @Override protected void onError(AjaxRequestTarget arg0) { } @Override protected void onSubmit(AjaxRequestTarget target) { m_selectedDescriptor = model.getObject(); m_currentProperties = m_selectedDescriptor.getProperties(); if (target != null) { // target.addComponent(m_properties); } createButton(target); } @Override protected CharSequence getEventHandler() { String hider = getJQueryCodeForPropertiesHiding(model.getObject()); return new AppendingStringBuffer(hider + ";" + super.getEventHandler()) .append("; return false;"); } }); } }); m_properties = new TableImageBorder("propertiesborder", s_shadow, s_blocColor); layout.add(m_properties); m_properties.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true); m_currentProperties = m_selectedDescriptor.getProperties(); m_propEditors = new ListView<ButtonDescriptor>("property", s_buttons) { @Override protected void populateItem(ListItem<ButtonDescriptor> item) { ButtonDescriptor desc = item.getModelObject(); WebMarkupContainer container = new WebMarkupContainer("container"); item.add(container); PropertyListEditor lst = new PropertyListEditor("lst", desc.getProperties()); container.add(lst); container.setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true); m_propertiesContainer.add(new Pair(desc.getName(), container)); } }; m_properties.add(m_propEditors); // Border fontborder = new TableImageBorder("fontborder", s_shadow, s_blocColor); // form.add(fontborder); // fontborder.add(new ButtonPropertyEditorPanel("fontselector", PROPERTY_FONT, false)); // fontborder.add(new ButtonPropertyEditorPanel("fontcolor", PROPERTY_FONT_COLOR, false)); // fontborder.add(new ButtonPropertyEditorPanel("fontshadow", PROPERTY_FONT_SHADOW, true)); rightcol.addContent(createFragment(ColumnPanel.CONTENT_ID, Arrays.asList(new Component[] { new ButtonPropertyEditorPanel("element", PROPERTY_WIDTH, true), new ButtonPropertyEditorPanel("element", PROPERTY_HEIGHT, true), new ButtonPropertyEditorPanel("element", PROPERTY_AUTO_EXTEND, true) }), "Button Size")); rightcol.addContent(createFragment(rightcol.CONTENT_ID, Arrays.asList(new Component[] { new ButtonPropertyEditorPanel("element", PROPERTY_FONT, false), new ButtonPropertyEditorPanel("element", PROPERTY_FONT_COLOR, true), new ButtonPropertyEditorPanel("element", PROPERTY_FONT_SHADOW, true) }), "Font Selection")); rightcol.addContent(createFragment( rightcol.CONTENT_ID, new EffectChoicePanel("element", new PropertyModel<Integer>(this, "shadowEffect"), EffectUtils.getShadowEffects()), "Shadow Effect")); rightcol.addContent(createFragment( rightcol.CONTENT_ID, new EffectChoicePanel("element", new PropertyModel<Integer>(this, "mirrorEffect"), EffectUtils.getMirrorEffects()), "Mirror Effect")); createButton(null); }
From source file:net.unit8.longadeseo.page.plugin.PluginListPage.java
License:Apache License
public PluginListPage() { add(new Label("pageTitle", "?")); pluginRegistryList = pluginRegistryService.findAll(); final ModalWindow window = new ModalWindow("testWindow"); window.setTitle("test"); add(window);// w ww. java2 s . com add(new ListView<PluginRegistry>("pluginRegistryList", pluginRegistryList) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<PluginRegistry> item) { final PluginRegistry pluginRegistry = item.getModelObject(); Form<PluginRegistry> pluginUpdateForm = new Form<PluginRegistry>("pluginUpdateForm", new CompoundPropertyModel<PluginRegistry>(pluginRegistry)); item.add(pluginUpdateForm); final Model<String> includes = new Model<String>( StringUtils.join(pluginRegistry.getIncludes(), "\n")); pluginUpdateForm.add(new Label("name")) .add(new AjaxEditableMultiLineLabel<PluginRegistry>("description") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { pluginRegistryService.update(pluginRegistry); super.onSubmit(target); } }).add(new Label("pluginClass", pluginRegistry.getPluginClass().getName())) .add(new AjaxEditableMultiLineLabel<String>("pluginIncludes", includes) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { pluginRegistry.setIncludes(includes.getObject().split("\n")); pluginRegistryService.update(pluginRegistry); super.onSubmit(target); } }).add(new Button("deleteButton") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { pluginRegistryService.delete(pluginRegistry); pluginRegistryList.remove(pluginRegistry); super.onSubmit(); } }).add(new AjaxButton("activeButton", new Model<String>(activeButtonLabel(pluginRegistry.isActive()))) { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { pluginRegistry.setActive(!pluginRegistry.isActive()); this.setModelObject(activeButtonLabel(pluginRegistry.isActive())); pluginRegistryService.update(pluginRegistry); PluginManager pluginManager = (PluginManager) WebApplication.get() .getServletContext().getAttribute(WebdavServlet.PLUGIN_MANAGER_KEY); pluginManager.loadPlugins(); target.add(this); } }.setOutputMarkupId(true)).add(new AjaxButton("testButton") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { window.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; public Page createPage() { return new PluginTestPage(pluginRegistry); } }); window.show(target); } }); final WebMarkupContainer optionsContainer = new WebMarkupContainer("optionsContainer"); final ListView<PluginOptionEntry> options = new ListView<PluginOptionEntry>("options", pluginRegistry.getPlugin().getOptions()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<PluginOptionEntry> item) { final PluginOptionEntry option = item.getModelObject(); item.add(new Label("name", option.getLabel())); switch (option.getFormType()) { case TEXTAREA: item.add(new AjaxEditableMultiLineLabel<PluginOptionEntry>("value", new PropertyModel<PluginOptionEntry>(option, "value")) { private static final long serialVersionUID = 1L; @Override public void onEdit(AjaxRequestTarget target) { String selector = ".codemirror:eq(" + (item.getIndex() - 1) + ") textarea"; target.appendJavaScript("CodeMirror.fromTextArea($('" + selector + "')[0], {mode: 'text/x-ruby', lineNumbers: true,indentUnit: 2,tabMode: 'shift',matchBrackets: true})" + ".on('blur', function(cm) { cm.save(); $('" + selector + "').trigger('blur') });"); super.onEdit(target); } @Override protected void onSubmit(AjaxRequestTarget target) { pluginRegistry.getPlugin().setOption(option.getName(), ValueFactoryImpl.getInstance().createValue(option.getStringValue())); pluginRegistryService.update(pluginRegistry); super.onSubmit(target); } }.add(new AttributeModifier("class", "codemirror"))); break; default: item.add(new AjaxEditableLabel<PluginOptionEntry>("value", new PropertyModel<PluginOptionEntry>(option, "value")) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { pluginRegistry.getPlugin().setOption(option.getName(), ValueFactoryImpl.getInstance().createValue(option.getStringValue())); pluginRegistryService.update(pluginRegistry); super.onSubmit(target); } }); break; } } }; optionsContainer.add(options); pluginUpdateForm.add(optionsContainer); } }); Form<ValueMap> form = new PluginRegistryForm("pluginRegistryForm"); add(form); }
From source file:nl.knaw.dans.dccd.web.search.pages.AdvSearchPage.java
License:Apache License
private void initTaxonSelection(final AdvancedSearchForm form, final AdvSearchData data) { // With plain text input: //add(new TextField("elementTaxon", new SearchFieldModel(data, "elementTaxon"))); // With autocomplete: //add(new TridasVocabularyAutoCompleteSelector("elementTaxon", // new SearchFieldModel(data, "elementTaxon"), // "element.taxon")); // With ComboBox: final DropDown elemTaxonComboBox = new DropDown("elementTaxon", new SearchFieldModel(data, "elementTaxon"), new DropDownDataSource<String>() { private static final long serialVersionUID = 1L; public String getName() { return "element.taxon"; }//from w w w .j a v a 2 s . c o m public List<String> getValues() { // Use current language to get terms for that language String langCode = getSession().getLocale().getLanguage(); return DccdVocabularyService.getService().getTerms("element.taxon", langCode); } public String getDescriptionForValue(String t) { return t; } }, false); elemTaxonComboBox.setCharacterWidth(25); elemTaxonComboBox.setOutputMarkupId(true); //form.add(elemTaxonComboBox); // FIX Container is needed to workaround visural-wicket ISSUE 67 final WebMarkupContainer taxonContainer = new WebMarkupContainer("elementTaxonContainer"); taxonContainer.setOutputMarkupId(true); form.add(taxonContainer); taxonContainer.add(elemTaxonComboBox); //TEST adding the window with the table //Problem, the TaxonSelectPanel wants a real TridasTaxon final ModalWindow modalSelectDialog; form.add(modalSelectDialog = new ModalWindow("taxonSelectPanel")); final TaxonSelectPanel taxonSelectPanel = new TaxonSelectPanel(modalSelectDialog.getContentId(), new Model(null)) { private static final long serialVersionUID = 1L; @Override protected void onSelectionChanged(AjaxRequestTarget target) { String taxonString = getSelectionAsString(); LOGGER.debug("Selected taxon: " + taxonString); data.elementTaxon.setValue(taxonString); //target.addComponent(elemTaxonComboBox); // FIX workaround visural-wicket ISSUE 67 by updating the container target.addComponent(taxonContainer); } }; modalSelectDialog.setContent(taxonSelectPanel); //modalSelectDialog.setTitle(ProjectPermissionSettingsPage.this.getString("userAddDialogTitle")); modalSelectDialog.setCookieName("taxonSelectPanelWindow"); modalSelectDialog.setInitialWidth(400); modalSelectDialog.setInitialHeight(160); modalSelectDialog.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() { private static final long serialVersionUID = 1L; public boolean onCloseButtonClicked(AjaxRequestTarget target) { return true; } }); //button to show the dialog AjaxLink taxonSelectButton = new IndicatingAjaxLink("taxonSelectButton") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { //LOGGER.debug("term=" + data.elementTaxon.getValue()); //taxonSelectPanel.selectTerm(elemTaxonComboBox.getValue()); modalSelectDialog.show(target); } }; form.add(taxonSelectButton); }
From source file:nl.mpi.lamus.web.pages.LamusPage.java
License:Open Source License
/** * edit title of the page, logo and userName *///from w w w . j av a 2 s . c o m @SuppressWarnings("LeakingThisInConstructor") public LamusPage() { super(); String appName = getLocalizer().getString("header_app_name", this); feedbackPanel = new FeedbackPanel("feedbackPanel"); feedbackPanel.setOutputMarkupId(true); feedbackPanel.setOutputMarkupPlaceholderTag(true); feedbackPanel.setEscapeModelStrings(false); add(feedbackPanel); add(new Image("header_tla_logo", new SharedResourceReference("tlaLogoImage"))); add(new Label("header_appname", appName)); add(new Image("header_clarin_logo", new SharedResourceReference("clarinInvertedImage"))); Link homePageLink = new Link("home_page_link") { @Override public void onClick() { final IndexPage resultPage = new IndexPage(); setResponsePage(resultPage); } }; homePageLink.add(new Image("home_image", new SharedResourceReference("homeImage"))); add(homePageLink); final ModalWindow modalAbout = createAboutModalWindow(); add(modalAbout); add(new AjaxLink<Void>("showModalAbout") { @Override public void onClick(AjaxRequestTarget art) { modalAbout.show(art); } }); add(new ExternalLink("manual_link", Model.of(manualUrl))); add(new ExternalLink("register_link", Model.of(registerUrl))); add(new Label("header_username", new HeaderUsernameModel())); if ("anonymous".equals(LamusSession.get().getUserId())) { add(new ExternalLink("loginOrLogoutLink", "login", getLocalizer().getString("header_login_label", this))); } else { add(new ExternalLink("loginOrLogoutLink", "logout", getLocalizer().getString("header_logout_label", this))); } }
From source file:ontopoly.components.DeleteTopicFunctionBoxPanel.java
License:Apache License
public DeleteTopicFunctionBoxPanel(String id) { super(id);/*from w w w . j a v a 2 s .c om*/ add(new Label("title", new ResourceModel("delete.this.topic"))); final ModalWindow deleteModal = new ModalWindow("deleteModal"); ModalConfirmPage modalDeletePanel = new ModalConfirmPage(deleteModal.getContentId()) { @Override protected void onCloseCancel(AjaxRequestTarget target) { // close modal deleteModal.close(target); } @Override protected void onCloseOk(AjaxRequestTarget target) { // close modal deleteModal.close(target); // notify listeners Topic instance = (Topic) getTopicModel().getObject(); onDeleteConfirmed(instance); // remove dependent objects AbstractOntopolyPage page = (AbstractOntopolyPage) getPage(); Collection<Topic> dependentObjects = instance.getDependentObjects(); Iterator<Topic> diter = dependentObjects.iterator(); while (diter.hasNext()) { Topic dtopic = diter.next(); dtopic.remove(page); } // remove topic instance.remove(page); } @Override protected Component getTitleComponent(String id) { return new Label(id, new ResourceModel("delete.confirm")); } @Override protected Component getMessageComponent(String id) { return new Label(id, new ResourceModel("delete.message.topic")); } }; deleteModal.setContent(modalDeletePanel); deleteModal.setTitle(new ResourceModel("ModalWindow.title.delete.topic").getObject().toString()); deleteModal.setCookieName("deleteModal"); add(deleteModal); Button createButton = new Button("deleteButton"); createButton.add(new AjaxFormComponentUpdatingBehavior("onclick") { @Override protected void onUpdate(AjaxRequestTarget target) { WicketHacks.disableWindowUnloadConfirmation(target); deleteModal.show(target); } }); add(createButton); }
From source file:ontopoly.components.DeleteTopicMapFunctionBoxPanel.java
License:Apache License
public DeleteTopicMapFunctionBoxPanel(String id) { super(id);/* ww w . j a v a 2 s . c om*/ add(new Label("title", new ResourceModel("delete.this.topic.map"))); final ModalWindow deleteModal = new ModalWindow("deleteModal"); ModalConfirmPage modalDeletePanel = new ModalConfirmPage(deleteModal.getContentId()) { @Override protected void onCloseCancel(AjaxRequestTarget target) { // close modal deleteModal.close(target); } @Override protected void onCloseOk(AjaxRequestTarget target) { // close modal deleteModal.close(target); // notify listeners TopicMap topicMap = getTopicMapModel().getTopicMap(); onDeleteConfirmed(topicMap); // delete topic map OntopolyContext.getOntopolyRepository().deleteTopicMap(topicMap.getId()); } @Override protected Component getTitleComponent(String id) { return new Label(id, new ResourceModel("delete.confirm")); } @Override protected Component getMessageComponent(String id) { return new Label(id, new ResourceModel("delete.message.topicmap")); } }; deleteModal.setContent(modalDeletePanel); deleteModal.setTitle(new ResourceModel("ModalWindow.title.delete.topicmap").getObject().toString()); deleteModal.setCookieName("deleteModal"); add(deleteModal); Button createButton = new Button("deleteButton"); createButton.add(new AjaxFormComponentUpdatingBehavior("onclick") { @Override protected void onUpdate(AjaxRequestTarget target) { WicketHacks.disableWindowUnloadConfirmation(target); deleteModal.show(target); } }); add(createButton); }
From source file:ontopoly.components.FieldInstanceAssociationBinaryPanel.java
License:Apache License
protected FieldInstanceAssociationBinaryPanel(String id, final FieldInstanceModel fieldInstanceModel, final FieldsViewModel fieldsViewModel, final boolean readonlyField, final boolean embedded, final boolean traversable) { super(id, fieldInstanceModel); FieldInstance fieldInstance = fieldInstanceModel.getFieldInstance(); FieldAssignment fieldAssignment = fieldInstance.getFieldAssignment(); RoleField roleField = (RoleField) fieldAssignment.getFieldDefinition(); this.roleFieldModel = new RoleFieldModel(roleField); add(new FieldDefinitionLabel("fieldLabel", new FieldDefinitionModel(roleField))); // set up container this.fieldValuesContainer = new WebMarkupContainer("fieldValuesContainer"); fieldValuesContainer.setOutputMarkupId(true); add(fieldValuesContainer);/* www . ja v a 2s . com*/ // add feedback panel this.feedbackPanel = new FeedbackPanel("feedback", new AbstractFieldInstancePanelFeedbackMessageFilter()); feedbackPanel.setOutputMarkupId(true); fieldValuesContainer.add(feedbackPanel); this.confirmDeletePanel = new ConfirmDeletePanel("confirm", fieldValuesContainer) { @Override protected void onDeleteTopic(AjaxRequestTarget target) { super.onDeleteTopic(target); FieldInstanceAssociationBinaryPanel.this.onUpdate(target); } }; confirmDeletePanel.setOutputMarkupId(true); fieldValuesContainer.add(confirmDeletePanel); RoleField ofield = (RoleField) roleField.getFieldsForOtherRoles().iterator().next(); this.ofieldModel = new RoleFieldModel(ofield); this.topicModel = new TopicModel<Topic>(fieldInstance.getInstance()); InterfaceControl interfaceControl = ofield.getInterfaceControl(); WebMarkupContainer fieldValuesList = new WebMarkupContainer("fieldValuesList"); fieldValuesContainer.add(fieldValuesList); final String fieldDefinitionId = roleField.getId(); EditMode editMode = roleField.getEditMode(); final boolean ownedvalues = editMode.isOwnedValues(); final boolean allowAdd = !(ownedvalues || editMode.isNewValuesOnly() || editMode.isNoEdit()); final boolean allowCreate = !(editMode.isExistingValuesOnly() || editMode.isNoEdit()); final boolean allowRemove = !editMode.isNoEdit(); final boolean sortable = roleField.isSortable(); // add field values component(s) // TODO: consider moving ordering logic into object model if (sortable) { // HACK: retrieving values ourselves so that we can get them ordered this.fieldValuesModel = new FieldValuesModel(fieldInstanceModel) { @Override protected List<RoleField.ValueIF> getValues(FieldInstance fieldInstance) { Topic instance = fieldInstance.getInstance(); RoleField roleField = (RoleField) fieldInstance.getFieldAssignment().getFieldDefinition(); return roleField.getOrderedValues(instance, ofieldModel.getRoleField()); } }; } else { Comparator<Object> comparator = new RoleFieldValueComparator(topicModel, ofieldModel); this.fieldValuesModel = new FieldValuesModel(fieldInstanceModel, comparator); } this.listView = new ListView<FieldValueModel>("fieldValues", fieldValuesModel) { @Override protected void onBeforeRender() { validateCardinality(); super.onBeforeRender(); } public void populateItem(final ListItem<FieldValueModel> item) { FieldValueModel fieldValueModel = item.getModelObject(); // get topic Topic oplayer = null; if (fieldValueModel.isExistingValue()) { RoleField.ValueIF valueIf = (RoleField.ValueIF) fieldValueModel.getObject(); RoleField ofield = ofieldModel.getRoleField(); oplayer = valueIf.getPlayer(ofield, fieldInstanceModel.getFieldInstance().getInstance()); } final String topicMapId = (oplayer == null ? null : oplayer.getTopicMap().getId()); final String topicId = (oplayer == null ? null : oplayer.getId()); // acquire lock for embedded topic final boolean isLockedByOther; if (embedded && fieldValueModel.isExistingValue()) { OntopolySession session = (OntopolySession) Session.get(); String lockerId = session.getLockerId(getRequest()); LockManager.Lock lock = session.lock(oplayer, lockerId); isLockedByOther = !lock.ownedBy(lockerId); } else { isLockedByOther = false; } final boolean readonly = readonlyField || isLockedByOther; boolean itemSortable = !readonly && sortable && fieldValueModel.isExistingValue(); if (itemSortable) { item.add(new DroppableBehavior(fieldDefinitionId) { @Override protected MarkupContainer getDropContainer() { return listView; } @Override protected void onDrop(Component component, AjaxRequestTarget target) { FieldValueModel fvm_dg = (FieldValueModel) component.getDefaultModelObject(); FieldValueModel fvm_do = (FieldValueModel) getComponent().getDefaultModelObject(); RoleField.ValueIF rfv_dg = (RoleField.ValueIF) fvm_dg.getFieldValue(); RoleField.ValueIF rfv_do = (RoleField.ValueIF) fvm_do.getFieldValue(); Topic topic = topicModel.getTopic(); RoleField rfield = roleFieldModel.getRoleField(); RoleField ofield = ofieldModel.getRoleField(); rfield.moveAfter(topic, ofield, rfv_dg, rfv_do); getModel().detach(); // FIXME: better if we could just tweak model directly without detaching listView.removeAll(); target.addComponent(fieldValuesContainer); } }); item.add(new DraggableBehavior(fieldDefinitionId)); } item.setOutputMarkupId(true); WebMarkupContainer fieldIconContainer = new WebMarkupContainer("fieldIconContainer"); fieldIconContainer .add(new OntopolyImage("fieldIcon", "dnd.gif", new ResourceModel("icon.dnd.reorder"))); fieldIconContainer.setVisible(itemSortable); item.add(fieldIconContainer); final WebMarkupContainer fieldValueButtons = new WebMarkupContainer("fieldValueButtons"); fieldValueButtons.setOutputMarkupId(true); item.add(fieldValueButtons); FieldInstanceRemoveButton removeButton = new FieldInstanceRemoveButton("remove", "remove-value.gif", fieldValueModel) { @Override public boolean isVisible() { boolean visible = !readonly && fieldValueModel.isExistingValue() && allowRemove; // && !isValueProtected; if (visible) { // filter by player AbstractOntopolyPage page = (AbstractOntopolyPage) getPage(); RoleField.ValueIF value = (RoleField.ValueIF) fieldValueModel.getObject(); Topic[] players = value.getPlayers(); for (int i = 0; i < players.length; i++) { if (!page.filterTopic(players[i])) return false; } } return visible; } @Override public void onClick(AjaxRequestTarget target) { // FIXME: could reuse some of these variable from above FieldInstance fieldInstance = fieldValueModel.getFieldInstanceModel().getFieldInstance(); Object value = fieldValueModel.getObject(); Topic currentTopic = fieldInstance.getInstance(); RoleField currentField = (RoleField) fieldInstance.getFieldAssignment() .getFieldDefinition(); RoleField selectedField = ofieldModel.getRoleField(); RoleField.ValueIF valueIf = (RoleField.ValueIF) value; Topic selectedTopic = valueIf.getPlayer(selectedField, fieldInstance.getInstance()); // check with page to see if add is allowed boolean changesMade = false; AbstractOntopolyPage page = (AbstractOntopolyPage) getPage(); if (page.isRemoveAllowed(currentTopic, currentField, selectedTopic, selectedField)) { if (ownedvalues) { // don't remove system topics if (!selectedTopic.isSystemTopic()) { FieldInstanceAssociationBinaryPanel.this.confirmDeletePanel .setTopic(selectedTopic); changesMade = true; } } else { fieldInstance.removeValue(value, page.getListener()); changesMade = true; } } // notify association panel so that it can update itself if (changesMade) FieldInstanceAssociationBinaryPanel.this.onUpdate(target); } }; fieldValueButtons.add(removeButton); // embedded goto button OntopolyImageLink gotoButton = new OntopolyImageLink("goto", "goto.gif", new ResourceModel("icon.goto.topic")) { @Override public boolean isVisible() { FieldValueModel fieldValueModel = item.getModelObject(); return embedded && fieldValueModel.isExistingValue(); } @Override public void onClick(AjaxRequestTarget target) { // navigate to topic PageParameters pageParameters = new PageParameters(); pageParameters.put("topicMapId", topicMapId); pageParameters.put("topicId", topicId); setResponsePage(getPage().getClass(), pageParameters); setRedirect(true); } }; fieldValueButtons.add(gotoButton); // embedded lock button OntopolyImageLink lockButton = new OntopolyImageLink("lock", "lock.gif", new ResourceModel("icon.topic.locked")) { @Override public boolean isVisible() { return embedded && isLockedByOther; } @Override public void onClick(AjaxRequestTarget target) { } }; fieldValueButtons.add(lockButton); // binary // ISSUE: should not really pass in readonly-parameter here as it is only relevant if page is readonly FieldInstanceAssociationBinaryField binaryField = new FieldInstanceAssociationBinaryField( "fieldValue", ofieldModel, fieldValueModel, fieldsViewModel, readonly, embedded, traversable, allowAdd) { @Override protected void performNewSelection(FieldValueModel fieldValueModel, RoleField selectedField, Topic selectedTopic) { RoleField.ValueIF value = FieldInstanceAssociationBinaryPanel.this .performNewSelection(selectedField, selectedTopic); fieldValueModel.setExistingValue(value); } }; if (binaryField.getUpdateableComponent() != null) binaryField.getUpdateableComponent().add(new FieldUpdatingBehaviour(true)); item.add(binaryField); addNewFieldValueCssClass(item, fieldValuesModel, fieldValueModel); } }; listView.setReuseItems(true); fieldValuesList.add(listView); // figure out which buttons to show this.fieldInstanceButtons = new WebMarkupContainer("fieldInstanceButtons"); fieldInstanceButtons.setOutputMarkupId(true); add(fieldInstanceButtons); if (readonlyField || !allowAdd) { // unused components fieldInstanceButtons.add(new Label("add", new Model<String>("unused")).setVisible(false)); fieldInstanceButtons.add(new Label("find", new Model<String>("unused")).setVisible(false)); fieldInstanceButtons.add(new Label("findModal", new Model<String>("unused")).setVisible(false)); // add/find button } else if (interfaceControl.isDropDownList() || interfaceControl.isAutoComplete()) { // "add" button OntopolyImageLink addButton = new OntopolyImageLink("add", "add.gif") { @Override public void onClick(AjaxRequestTarget target) { boolean showExtraField = !fieldValuesModel.getShowExtraField(); fieldValuesModel.setShowExtraField(showExtraField, true); listView.removeAll(); updateDependentComponents(target); } @Override public boolean isVisible() { if (readonlyField) return false; else return fieldValuesModel.containsExisting(); } @Override public String getImage() { return fieldValuesModel.getShowExtraField() ? "remove.gif" : "add.gif"; } @Override public IModel<String> getTitleModel() { return new ResourceModel( fieldValuesModel.getShowExtraField() ? "icon.remove.hide-field" : "icon.add.add-value"); } }; fieldInstanceButtons.add(addButton); // unused components fieldInstanceButtons.add(new Label("find", new Model<String>("unused")).setVisible(false)); fieldInstanceButtons.add(new Label("findModal", new Model<String>("unused")).setVisible(false)); } else if (interfaceControl.isSearchDialog() || interfaceControl.isBrowseDialog()) { // "search"/"browse" button final ModalWindow findModal = new ModalWindow("findModal"); fieldInstanceButtons.add(findModal); int activeTab = (interfaceControl.isSearchDialog() ? ModalFindPage.ACTIVE_TAB_SEARCH : ModalFindPage.ACTIVE_TAB_BROWSE); findModal .setContent(new ModalFindPage<String>(findModal.getContentId(), fieldInstanceModel, activeTab) { @Override protected void onSelectionConfirmed(AjaxRequestTarget target, Collection<String> selected) { FieldInstance fieldInstance = fieldInstanceModel.getFieldInstance(); RoleField currentField = (RoleField) fieldInstance.getFieldAssignment() .getFieldDefinition(); RoleField selectedField = (RoleField) currentField.getFieldsForOtherRoles().iterator() .next(); // check with page to see if add is allowed if (ObjectUtils.different(currentField, selectedField) || // if assoc type is symmetric currentField == selectedField, // but we're still OK to go ahead, so checking for that // (this is issue 457) currentField.getAssociationType().isSymmetric()) { Topic currentTopic = fieldInstance.getInstance(); TopicMap topicMap = currentTopic.getTopicMap(); boolean changesMade = false; Iterator<String> iter = selected.iterator(); while (iter.hasNext()) { String objectId = (String) iter.next(); AbstractOntopolyPage page = (AbstractOntopolyPage) getPage(); Topic selectedTopic = topicMap.getTopicById(objectId); if (page.isAddAllowed(currentTopic, currentField, selectedTopic, selectedField)) { performNewSelection(selectedField, selectedTopic); changesMade = true; } } // notify association panel so that it can update itself if (changesMade) FieldInstanceAssociationBinaryPanel.this.onUpdate(target); } } @Override protected void onCloseCancel(AjaxRequestTarget target) { findModal.close(target); } @Override protected void onCloseOk(AjaxRequestTarget target) { findModal.close(target); } }); findModal.setTitle(new ResourceModel("ModalWindow.title.find.topic").getObject().toString()); findModal.setCookieName("findModal"); OntopolyImageLink findButton = new OntopolyImageLink("find", "search.gif", new ResourceModel("find.topic")) { @Override public void onClick(AjaxRequestTarget target) { findModal.show(target); } }; fieldInstanceButtons.add(findButton); // unused components fieldInstanceButtons.add(new Label("add", new Model<String>("unused")).setVisible(false)); } else { throw new RuntimeException("Unsupported interface control: " + interfaceControl); } // create button if (readonlyField || !allowCreate) { fieldInstanceButtons.add(new Label("create").setVisible(false)); } else { CreateAction ca = roleField.getCreateAction(); int createAction; if (embedded || ca.isNone()) createAction = FieldInstanceCreatePlayerPanel.CREATE_ACTION_NONE; else if (ca.isNavigate()) createAction = FieldInstanceCreatePlayerPanel.CREATE_ACTION_NAVIGATE; else createAction = FieldInstanceCreatePlayerPanel.CREATE_ACTION_POPUP; FieldInstanceCreatePlayerPanel createPanel = new FieldInstanceCreatePlayerPanel("create", fieldInstanceModel, fieldsViewModel, new RoleFieldModel(ofield), this, createAction) { @Override protected void performNewSelection(RoleFieldModel ofieldModel, Topic selectedTopic) { FieldInstanceAssociationBinaryPanel.this.performNewSelection(ofieldModel.getRoleField(), selectedTopic); } }; createPanel.setOutputMarkupId(true); fieldInstanceButtons.add(createPanel); } }