List of usage examples for org.apache.wicket.model.util ListModel ListModel
public ListModel(List<T> list)
list
From source file:com.asptt.plongee.resa.ui.web.wicket.page.admin.GererPlongeeAOuvrirTwo.java
public GererPlongeeAOuvrirTwo(final Plongee plongee) { setPageTitle("Ouvrir plongee"); modalPlongee = new ModalWindow("modalPlongee"); modalPlongee.setTitle("This is modal window with panel content."); modalPlongee.setCookieName("modal-plongee"); add(modalPlongee);/*from w w w .j a v a2s. c om*/ CompoundPropertyModel<Plongee> modelPlongee = new CompoundPropertyModel<Plongee>(plongee); List<Adherent> dps; dps = getResaSession().getAdherentService().rechercherDPsNonInscrits( getResaSession().getAdherentService().rechercherAdherentsActifs(), plongee); dps.removeAll(plongee.getParticipants()); IChoiceRenderer<Adherent> rendDp = new ChoiceRenderer<Adherent>("nom", "nom"); final Palette<Adherent> palDp = new Palette<Adherent>("paletteDps", new ListModel<Adherent>(new ArrayList<Adherent>()), new CollectionModel<Adherent>(dps), rendDp, 10, false) { }; List<Adherent> pilotes = getResaSession().getAdherentService().rechercherPilotesNonInscrits( getResaSession().getAdherentService().rechercherAdherentsActifs(), plongee); pilotes.removeAll(plongee.getParticipants()); IChoiceRenderer<Adherent> rendPilote = new ChoiceRenderer<Adherent>("nom", "nom"); final Palette<Adherent> palPilote = new Palette<Adherent>("palettePilotes", new ListModel<Adherent>(new ArrayList<Adherent>()), new CollectionModel<Adherent>(pilotes), rendPilote, 10, false) { }; final Form<Plongee> form = new Form<Plongee>("form") { private static final long serialVersionUID = 4611593854191923422L; @Override protected void onSubmit() { IModel<?> modelDps = palDp.getDefaultModel(); List<Adherent> dps = (List<Adherent>) modelDps.getObject(); IModel<?> modelPilotes = palPilote.getDefaultModel(); List<Adherent> pilotes = (List<Adherent>) modelPilotes.getObject(); /* * Impossible de gerer les doublons avec un HashSet Alors on le * fait ' la main' */ List<String> idInscrits = new ArrayList<String>(); for (Adherent adherent : dps) { if (!idInscrits.contains(adherent.getNumeroLicense())) { idInscrits.add(adherent.getNumeroLicense()); } } for (Adherent adherent : pilotes) { if (!idInscrits.contains(adherent.getNumeroLicense())) { idInscrits.add(adherent.getNumeroLicense()); } } /* * Maintenant qu'on la liste des id on reconstitue une liste * d'adherent */ List<Adherent> adhInscrits = new ArrayList<Adherent>(); for (String id : idInscrits) { adhInscrits.add(getResaSession().getAdherentService().rechercherAdherentParIdentifiant(id)); } /* * Reste plus qu'a inscrire... */ for (Adherent adh : adhInscrits) { try { getResaSession().getPlongeeService().inscrireAdherent(plongee, adh, PlongeeMail.PAS_DE_MAIL); } catch (ResaException e) { e.printStackTrace(); ErrorPage ep = new ErrorPage(e); setResponsePage(ep); } } PageParameters param = new PageParameters(); param.put("plongeeAOuvrir", plongee); param.put("inscrits", adhInscrits); //setResponsePage(new GererPlongeeAOuvrirThree(plongee)); setResponsePage(new InscriptionConfirmationPlongeePage(plongee)); }//fin du onSubmit() }; form.setModel(modelPlongee); // Le nombre max. de places, pour info maxPlaces = new TextField<Integer>("nbMaxPlaces"); maxPlaces.setOutputMarkupId(true); form.add(maxPlaces.setEnabled(false)); // Le niveau mini. des plongeurs, pour info niveauMinimum = new TextField<Integer>("niveauMinimum"); niveauMinimum.setOutputMarkupId(true); form.add(niveauMinimum.setEnabled(false)); // La Date de visibilite de la plonge, pour info dateVisible = new TextField<Date>("dateVisible"); dateVisible.setOutputMarkupId(true); form.add(dateVisible.setEnabled(false)); // Ajout des palettes form.add(palDp); form.add(palPilote); add(form); form.add(new IndicatingAjaxLink("change") { @Override public void onClick(AjaxRequestTarget target) { replaceModalWindow(target, form.getModel()); modalPlongee.show(target); } }); }
From source file:com.asptt.plongee.resa.wicket.page.admin.plongee.GererPlongeeAOuvrirTwo.java
public GererPlongeeAOuvrirTwo(final Plongee plongee) { setPageTitle("Ouvrir plongee"); final FeedbackPanel feedback = new FeedbackPanel("feedback"); feedback.setOutputMarkupId(true);//from w w w . j a v a 2 s. c o m add(feedback); modalPlongee = new ModalWindow("modalPlongee"); modalPlongee.setTitle("This is modal window with panel content."); modalPlongee.setCookieName("modal-plongee"); add(modalPlongee); CompoundPropertyModel<Plongee> modelPlongee = new CompoundPropertyModel<Plongee>(plongee); // Liste des DPs List<Adherent> dps; dps = ResaSession.get().getAdherentService().rechercherDPsNonInscrits( ResaSession.get().getAdherentService().rechercherAdherentsActifs(), plongee); //Suppression des adherents dj inscrits la plonge de la liste des DPs dps.removeAll(plongee.getParticipants()); // Init ChoiceRender des DPs IChoiceRenderer<Adherent> rendDp = new ChoiceRenderer<Adherent>("nom", "nom"); // Init de la palettes des DPs final Palette<Adherent> palDp = new Palette<Adherent>("paletteDps", new ListModel<Adherent>(new ArrayList<Adherent>()), new CollectionModel<Adherent>(dps), rendDp, 10, false) { }; //List des Pilotes List<Adherent> pilotes = ResaSession.get().getAdherentService().rechercherPilotesNonInscrits( ResaSession.get().getAdherentService().rechercherAdherentsActifs(), plongee); //Suppression des adherents dj inscrits la plonge de la liste des Pilotes pilotes.removeAll(plongee.getParticipants()); // Init ChoiceRender des Pilotes IChoiceRenderer<Adherent> rendPilote = new ChoiceRenderer<Adherent>("nom", "nom"); // Init de la palettes des Pilotes final Palette<Adherent> palPilote = new Palette<Adherent>("palettePilotes", new ListModel<Adherent>(new ArrayList<Adherent>()), new CollectionModel<Adherent>(pilotes), rendPilote, 10, false) { }; //Init de la Forme final Form<Plongee> form = new Form<Plongee>("form") { private static final long serialVersionUID = 4611593854191923422L; }; //Dfinition du model de la form == plongee form.setModel(modelPlongee); // Le nombre max. de places, pour info maxPlaces = new TextField<Integer>("nbMaxPlaces"); maxPlaces.setOutputMarkupId(true); form.add(maxPlaces.setEnabled(false)); // Le niveau mini. des plongeurs, pour info niveauMinimum = new TextField<Integer>("niveauMinimum"); niveauMinimum.setOutputMarkupId(true); form.add(niveauMinimum.setEnabled(false)); // La Date de visibilite de la plonge, pour info dateReservation = new TextField<Date>("dateReservation"); dateReservation.setOutputMarkupId(true); form.add(dateReservation.setEnabled(false)); //ajout du warning warning = new TextArea<String>("warning"); warning.setOutputMarkupId(true); form.add(warning.setEnabled(false)); // Ajout des palettes form.add(palDp); form.add(palPilote); // Ajout du lien pour modifier les caracteristiques de la plonge form.add(new IndicatingAjaxLink("change") { @Override public void onClick(AjaxRequestTarget target) { replaceModalWindow(target, form.getModel()); modalPlongee.show(target); } }); // Ajout du bouton submit IndicatingAjaxButton b_valider = new IndicatingAjaxButton("validDpPilote") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { IModel<?> modelDps = palDp.getDefaultModel(); List<Adherent> dps = (List<Adherent>) modelDps.getObject(); IModel<?> modelPilotes = palPilote.getDefaultModel(); List<Adherent> pilotes = (List<Adherent>) modelPilotes.getObject(); if (dps.size() != 1 || pilotes.size() != 1) { error("Un DP et un pilote doivent tre selectionns"); } else { /* * Impossible de gerer les doublons avec un HashSet Alors on le * fait ' la main' */ List<Adherent> l_dpPilote = new ArrayList<Adherent>(); l_dpPilote.add(dps.get(0)); if (!dps.get(0).getNumeroLicense().equalsIgnoreCase(pilotes.get(0).getNumeroLicense())) { l_dpPilote.add(pilotes.get(0)); } // Inscription du DP et Pilote for (Adherent adh : l_dpPilote) { try { ResaSession.get().getPlongeeService().inscrireAdherent(plongee, adh, PlongeeMail.PAS_DE_MAIL); } catch (ResaException e) { e.printStackTrace(); ErrorPage ep = new ErrorPage(e); setResponsePage(ep); } } PageParameters param = new PageParameters(); param.put("plongeeAOuvrir", plongee); param.put("inscrits", l_dpPilote); setResponsePage(new ListeInscritsPlongeePage(plongee)); } }//fin du onSubmit() @Override protected void onError(AjaxRequestTarget target, Form<?> form) { target.addComponent(feedback); } }; form.add(new Link("cancel") { @Override public void onClick() { setResponsePage(GererPlongeeAOuvrirOne.class); } }); //add(new Button("cancel", new ResourceModel("button.cancel"))); form.add(b_valider); add(form); }
From source file:com.axway.ats.testexplorer.pages.runsByTypeDashboard.home.Filter.java
License:Apache License
public Filter() { super("filter"); TestExplorerSession session = (TestExplorerSession) Session.get(); try {//from ww w .j a v a 2s . co m productNames = (ArrayList<String>) session.getDbReadConnection().getAllProductNames("WHERE 1=1"); selectedProductName = null; searchByProduct = new DropDownChoice<String>("search_by_product", new PropertyModel<String>(this, "selectedProductName"), productNames); searchByProduct.setNullValid(false); searchByProduct.setEscapeModelStrings(false); searchByProduct.setOutputMarkupId(true); searchByProduct.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { TestExplorerSession session = (TestExplorerSession) Session.get(); try { versionNames = session.getDbReadConnection() .getAllVersionNames("WHERE productName = '" + selectedProductName + "'"); selectedVersionNames = new ArrayList<String>(versionNames); searchByVersion.getModel().setObject(selectedVersionNames); searchByVersion.setChoices(versionNames); target.add(searchByVersion); } catch (DatabaseAccessException e) { error("Unable to get version names"); LOG.error(e); } } }); } catch (DatabaseAccessException e) { error(e.getMessage()); LOG.error(e); } versionNames = new ArrayList<String>(1); selectedVersionNames = new ArrayList<String>(1); searchByVersion = new ListMultipleChoice<String>("search_by_version", new ListModel<String>(selectedVersionNames), versionNames); searchByVersion.setEscapeModelStrings(false); searchByVersion.setOutputMarkupId(true); add(searchByProduct); add(searchByVersion); AjaxButton searchButton = new AjaxButton("submit") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { List<String[]> productAndVersionNames = new ArrayList<String[]>(1); for (String versionName : selectedVersionNames) { productAndVersionNames.add(new String[] { selectedProductName, versionName }); } TestExplorerSession session = (TestExplorerSession) Session.get(); try { new DashboardHomeUtils().callJavaScript(target, new DashboardHomeUtils().initJsonData( productAndVersionNames, session.getDbReadConnection().getAllBuildTypes("AND 1=1"))); } catch (DatabaseAccessException e) { error("Unable to get runs data"); LOG.error("Unable to get runs data", e); } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { super.onError(target, form); } }; add(searchButton); // search button is the button to trigger when user hit the enter key this.setDefaultButton(searchButton); add(new AjaxButton("clear") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { selectedProductName = null; selectedVersionNames = new ArrayList<String>(1); versionNames = new ArrayList<String>(1); searchByProduct.setModelObject(selectedProductName); searchByVersion.setModelObject(selectedVersionNames); searchByVersion.setChoices(new ListModel<String>(versionNames)); target.add(searchByProduct); target.add(searchByVersion); target.appendJavaScript(";$('#container').empty();"); } }); }
From source file:com.axway.ats.testexplorer.pages.testcasesByGroups.TestcasesByGroupFilter.java
License:Apache License
public TestcasesByGroupFilter(String id) { super(id);// ww w .jav a 2 s . co m searchByProduct = createSearchByProductComponent(); searchByVersion = createSearchByVersionComponent(); searchByAllGroups = createSearchByAllGroupsComponent(); searchByGroupContains = new TextField<String>("search_by_group_contains", new Model<String>("")); searchByGroupContains.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { if (StringUtils.isNullOrEmpty(searchByGroupContains.getModel().getObject())) { TestExplorerSession session = (TestExplorerSession) Session.get(); try { groupNames = session.getDbReadConnection().getAllGroupNames(selectedProductName, selectedVersionNames); } catch (DatabaseAccessException e) { LOG.error("Unable to get all group names", e); error("Unable to get all group names"); } } else { groupNames = new ArrayList<String>(); } selectedGroupNames = groupNames; searchByAllGroups.getModel().setObject(selectedGroupNames); searchByAllGroups.setChoices(groupNames); target.add(searchByAllGroups); } }); searchByAfterDate.setOutputMarkupId(true); searchByAfterDate.add(DateValidator.maximum(new Date(), "dd.MM.yyyy")); searchByBeforeDate.setOutputMarkupId(true); searchByGroupContains.setEscapeModelStrings(false); searchByGroupContains.setOutputMarkupId(true); add(searchByProduct); add(searchByVersion); add(searchByAllGroups); add(searchByAfterDate); add(searchByBeforeDate); add(searchByGroupContains); searchByAfterDate.add(new DatePicker().setShowOnFieldClick(true).setAutoHide(true)); searchByBeforeDate.add(new DatePicker().setShowOnFieldClick(true).setAutoHide(true)); AjaxButton searchButton = new AjaxButton("submit") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (StringUtils.isNullOrEmpty(selectedProductName) && selectedVersionNames.size() == 0 && selectedGroupNames.size() == 0 && StringUtils.isNullOrEmpty(searchByGroupContains.getModel().getObject()) && StringUtils.isNullOrEmpty(searchByAfterDate.getInput()) && StringUtils.isNullOrEmpty(searchByBeforeDate.getInput())) { return; } TestExplorerSession session = (TestExplorerSession) Session.get(); TestcaseInfoPerGroupStorage perGroupStorage = null; try { perGroupStorage = session.getDbReadConnection().getTestcaseInfoPerGroupStorage( selectedProductName, selectedVersionNames, selectedGroupNames, searchByAfterDate.getValue(), searchByBeforeDate.getValue(), searchByGroupContains.getModel().getObject()); } catch (DatabaseAccessException e) { LOG.error("Unable to get Testcases and groups data", e); error("Unable to get Testcases and groups data"); } if (perGroupStorage != null) { String treemapData = perGroupStorage.generateTreemapData(); String testcasesIdsMap = perGroupStorage.generateTestcasesIdsMap(); String script = ";setHiddenValue(\"groups\");drawTreemap(" + treemapData + "," + TestcaseInfoPerGroupStorage.TREEMAP_OPTIONS + ");$('.filterHeader').click();populateFilterDataPanel(" + getFilterData() + ");setTestcasesIdsMap(" + testcasesIdsMap + ");"; target.appendJavaScript(script); } } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { super.onError(target, form); } }; add(searchButton); // search button is the button to trigger when user hit the enter key this.setDefaultButton(searchButton); add(new AjaxButton("clear") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { selectedProductName = null; selectedVersionNames = new ArrayList<String>(1); versionNames = new ArrayList<String>(1); selectedGroupNames = new ArrayList<String>(1); groupNames = new ArrayList<String>(1); searchByProduct.getModel().setObject(selectedProductName); searchByVersion.getModel().setObject(selectedVersionNames); searchByVersion.setChoices(new ListModel<String>(versionNames)); searchByAllGroups.getModel().setObject(selectedGroupNames); searchByAllGroups.setChoices(new ListModel<String>(groupNames)); searchByAfterDate.getModel().setObject(null); searchByAfterDate.clearInput(); searchByBeforeDate.clearInput(); searchByBeforeDate.getModel().setObject(null); searchByGroupContains.getModel().setObject(null); target.add(searchByProduct); target.add(searchByVersion); target.add(searchByAllGroups); target.add(searchByAfterDate); target.add(searchByBeforeDate); target.add(searchByGroupContains); target.appendJavaScript( ";$('#chart_div').empty();populateFilterDataPanel(" + getFilterData() + ");"); } }); }
From source file:com.axway.ats.testexplorer.pages.testcasesByGroups.TestcasesByGroupFilter.java
License:Apache License
private ListMultipleChoice<String> createSearchByVersionComponent() { versionNames = new ArrayList<String>(1); selectedVersionNames = new ArrayList<String>(1); searchByVersion = new ListMultipleChoice<String>("search_by_version", new ListModel<String>(selectedVersionNames), versionNames); searchByVersion.setEscapeModelStrings(false); searchByVersion.setOutputMarkupId(true); searchByVersion.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override//from w w w.j a v a2s. c o m protected void onUpdate(AjaxRequestTarget target) { TestExplorerSession session = (TestExplorerSession) Session.get(); try { groupNames = session.getDbReadConnection().getAllGroupNames(selectedProductName, selectedVersionNames); selectedGroupNames = new ArrayList<String>(groupNames); searchByAllGroups.setChoices(groupNames); searchByAllGroups.getModel().setObject(selectedGroupNames); target.add(searchByAllGroups); } catch (DatabaseAccessException e) { error("Unable to get group names"); } } }); return searchByVersion; }
From source file:com.axway.ats.testexplorer.pages.testcasesByGroups.TestcasesByGroupFilter.java
License:Apache License
private ListMultipleChoice<String> createSearchByAllGroupsComponent() { groupNames = new ArrayList<String>(1); selectedGroupNames = new ArrayList<String>(1); searchByAllGroups = new ListMultipleChoice<String>("search_by_all_groups", new ListModel<String>(selectedGroupNames), groupNames); searchByAllGroups.setEscapeModelStrings(false); searchByAllGroups.setOutputMarkupId(true); searchByAllGroups.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override/*from w w w . j a va2 s . c om*/ protected void onUpdate(AjaxRequestTarget target) { TestExplorerSession session = (TestExplorerSession) Session.get(); try { groupNames = session.getDbReadConnection().getAllGroupNames(selectedProductName, selectedVersionNames); //selectedGroupNames = new ArrayList<String>( groupNames ); searchByAllGroups.setChoices(groupNames); searchByAllGroups.getModel().setObject(selectedGroupNames); target.add(searchByAllGroups); } catch (DatabaseAccessException e) { error("Unable to get group names"); } searchByGroupContains.setModelObject(null); target.add(searchByGroupContains); } }); return searchByAllGroups; }
From source file:com.axway.ats.testexplorer.pages.testcasesByGroups.TestcasesByGroupFilter.java
License:Apache License
public void performSearchOnPageLoad() { if (productNames == null || productNames.size() == 0) { return;/*from w w w . j a v a2 s . co m*/ } selectedProductName = productNames.get(productNames.size() - 1); searchByProduct.getModel().setObject(selectedProductName); TestExplorerSession session = (TestExplorerSession) Session.get(); try { versionNames = session.getDbReadConnection() .getAllVersionNames("WHERE productName = '" + selectedProductName + "'"); selectedVersionNames = Arrays.asList(versionNames.get(versionNames.size() - 1)); searchByVersion.getModel().setObject(selectedVersionNames); searchByVersion.setChoices(versionNames); groupNames = session.getDbReadConnection().getAllGroupNames(selectedProductName, selectedVersionNames); selectedGroupNames = groupNames; searchByAllGroups.getModel().setObject(selectedGroupNames); searchByAllGroups.setChoices(new ListModel<String>(groupNames)); String[] lastRunDateStart = session.getDbReadConnection() .getRuns(0, 1, "WHERE 1=1", "dateStart", false, ((TestExplorerSession) Session.get()).getTimeOffset()) .get(0).getDateStartLong().split(" ")[0].split("-"); searchByAfterDate.getModel().setObject(new SimpleDateFormat("dd.MM.yyyy") .parse(lastRunDateStart[2] + "." + lastRunDateStart[1] + "." + lastRunDateStart[0])); } catch (DatabaseAccessException e) { error("Unable to perform initial search"); LOG.error("Unable to perform initial search", e); } catch (ParseException e) { error("Unable to parse date start for last run"); LOG.error("Unable to parse date start for last run", e); } }
From source file:com.evolveum.midpoint.gui.api.component.FocusBrowserPanel.java
License:Apache License
private void initLayout(Class<T> type, final List<QName> supportedTypes, final boolean multiselect) { WebMarkupContainer typePanel = new WebMarkupContainer(ID_TYPE_PANEL); typePanel.setOutputMarkupId(true);/*w ww . j a v a 2 s . co m*/ typePanel.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return supportedTypes.size() != 1; } }); add(typePanel); DropDownChoice<QName> typeSelect = new DropDownChoice(ID_TYPE, typeModel, new ListModel(supportedTypes), new QNameChoiceRenderer()); typeSelect.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { ObjectListPanel<T> listPanel = (ObjectListPanel<T>) get(ID_TABLE); listPanel = createObjectListPanel(qnameToCompileTimeClass(typeModel.getObject()), multiselect); addOrReplace(listPanel); target.add(listPanel); } }); typePanel.add(typeSelect); ObjectListPanel<T> listPanel = createObjectListPanel(type, multiselect); add(listPanel); AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.addButton")) { @Override public void onClick(AjaxRequestTarget target) { List<T> selected = ((PopupObjectListPanel) getParent().get(ID_TABLE)).getSelectedObjects(); QName type = FocusBrowserPanel.this.typeModel.getObject(); FocusBrowserPanel.this.addPerformed(target, type, selected); } }; addButton.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return multiselect; } }); add(addButton); }
From source file:com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel.java
License:Apache License
private void initLayout(Class<? extends O> type, final List<QName> supportedTypes, final boolean multiselect) { WebMarkupContainer typePanel = new WebMarkupContainer(ID_TYPE_PANEL); typePanel.setOutputMarkupId(true);//from www.j a v a 2 s . c om typePanel.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return supportedTypes.size() != 1; } }); add(typePanel); DropDownChoice<QName> typeSelect = new DropDownChoice<QName>(ID_TYPE, typeModel, new ListModel<QName>(supportedTypes), new QNameChoiceRenderer()); typeSelect.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { ObjectListPanel<O> listPanel = (ObjectListPanel<O>) get(ID_TABLE); listPanel = createObjectListPanel(qnameToCompileTimeClass(typeModel.getObject()), multiselect); addOrReplace(listPanel); target.add(listPanel); } }); typePanel.add(typeSelect); ObjectListPanel<O> listPanel = createObjectListPanel(type, multiselect); add(listPanel); AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.addButton")) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { List<O> selected = ((PopupObjectListPanel) getParent().get(ID_TABLE)).getSelectedObjects(); QName type = ObjectBrowserPanel.this.typeModel.getObject(); ObjectBrowserPanel.this.addPerformed(target, type, selected); } }; addButton.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return multiselect; } }); add(addButton); }
From source file:com.evolveum.midpoint.gui.api.component.TypedAssignablePanel.java
License:Apache License
private void initLayout(Class<T> type, final boolean multiselect) { DropDownChoice<QName> typeSelect = new DropDownChoice(ID_TYPE, typeModel, new ListModel(WebComponentUtil.createAssignableTypesList()), new QNameChoiceRenderer()); typeSelect.add(new OnChangeAjaxBehavior() { @Override/*from ww w . j a v a2 s . co m*/ protected void onUpdate(AjaxRequestTarget target) { target.add(get(ID_TABLES_CONTAINER)); target.add(addOrReplace(createCountContainer())); } }); typeSelect.setOutputMarkupId(true); add(typeSelect); WebMarkupContainer tablesContainer = new WebMarkupContainer(ID_TABLES_CONTAINER); tablesContainer.setOutputMarkupId(true); add(tablesContainer); PopupObjectListPanel<T> listRolePanel = createObjectListPanel(ID_ROLE_TABLE, ID_SELECTED_ROLES, RoleType.COMPLEX_TYPE); tablesContainer.add(listRolePanel); PopupObjectListPanel<T> listResourcePanel = createObjectListPanel(ID_RESOURCE_TABLE, ID_SELECTED_RESOURCES, ResourceType.COMPLEX_TYPE); tablesContainer.add(listResourcePanel); PopupObjectListPanel<T> listOrgPanel = createObjectListPanel(ID_ORG_TABLE, ID_SELECTED_ORGS, OrgType.COMPLEX_TYPE); tablesContainer.add(listOrgPanel); PopupObjectListPanel<T> listServicePanel = createObjectListPanel(ID_SERVICE_TABLE, ID_SELECTED_SERVICES, ServiceType.COMPLEX_TYPE); tablesContainer.add(listServicePanel); WebMarkupContainer countContainer = createCountContainer(); add(countContainer); AjaxButton addButton = new AjaxButton(ID_BUTTON_ASSIGN, createStringResource("userBrowserDialog.button.addButton")) { @Override public void onClick(AjaxRequestTarget target) { List<T> selected = getSelectedData(ID_ROLE_TABLE); selected.addAll(getSelectedData(ID_RESOURCE_TABLE)); selected.addAll(getSelectedData(ID_ORG_TABLE)); selected.addAll(getSelectedData(ID_SERVICE_TABLE)); TypedAssignablePanel.this.addPerformed(target, selected); } }; addButton.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return multiselect; } }); add(addButton); }