List of usage examples for org.apache.wicket.extensions.markup.html.form.palette.theme DefaultTheme DefaultTheme
DefaultTheme
From source file:nl.verheulconsultants.monitorisp.ui.HomePage.java
License:Open Source License
/** * Wicket initializes this page multiple times. Be aware not to execute code multiple times if not allowed. */// ww w. j ava2s .co m public HomePage() { // Prevent spurious reloads by checking if the contoller is allready running // Only start automatically when the previous session data could be read if (CONTROLLER.isRunning()) { startAutomatically = false; } else { startAutomatically = CONTROLLER.initWithPreviousSessionData(); } address = new InputRouterAddress(CONTROLLER.getRouterAddress()); routerAddress = new TextField<>("routerAddress", new PropertyModel(address, "address")); newUrl = new TextField<>("newHost", Model.of("")); formSelectHosts = new Form<Void>("paletteForm") { @Override protected void onSubmit() { if (CONTROLLER.getSessionData().saveData()) { LOGGER.info("All data are saved."); } } }; formRouter = new Form<Void>("routerForm") { @Override protected void onSubmit() { final String addressValue = routerAddress.getModelObject(); if ("unknown".equals(addressValue) || isValidHostAddress(addressValue)) { CONTROLLER.setRouterAddress(addressValue); LOGGER.info("The router address is set to {}", addressValue); } else { error("Wrong router address. Please try again or type unknown"); } } }; stopButton = new Button("stopButton") { @Override public void onSubmit() { if (CONTROLLER != null && CONTROLLER.isBusyCheckingConnections()) { CONTROLLER.stopTemporarily(); LOGGER.info("The service is stopped temporarely."); } else { LOGGER.info("Can not stop, the controller is not running."); } } }; formNewHost = new Form<Void>("addHostForm") { @Override protected void onSubmit() { final String urlValue = newUrl.getModelObject(); if (isValidHostAddress(urlValue)) { Collection<Host> hostsLocal = CONTROLLER.getPaletteModel().getObject(); hostsLocal.add(new Host(Integer.toString(hostsLocal.size()), urlValue)); LOGGER.info("The URL {} is added", urlValue); LOGGER.info("The host list is changed to {}", CONTROLLER.getPaletteModel()); } else { error("Wrong host address. Please try again."); } } }; startButton = new Button("startButton") { @Override public void onSubmit() { startRunning(); } }; removeButton = new Button("removeButton") { @Override public void onSubmit() { Collection<Host> hostsLocal = CONTROLLER.getPaletteModel().getObject(); LOGGER.info("These URL's will be removed {}", CONTROLLER.getSelected()); hostsLocal.removeAll(CONTROLLER.getSelected()); LOGGER.info("The model is changed to {}", CONTROLLER.getPaletteModel()); } }; // To show a message. add(new FeedbackPanel("feedback")); IChoiceRenderer<Host> renderer = new ChoiceRenderer<>("hostAddress", "id"); palette = new Palette<>("palette1", CONTROLLER.getSelectedModel(), CONTROLLER.getPaletteModel(), renderer, 10, true, false); LOGGER.info("The palette is initiated with choices {}.", CONTROLLER.getPaletteModel()); LOGGER.info("The palette is initiated with selection {}.", CONTROLLER.getSelected()); // version 7.x.x palette.add(new DefaultTheme()); add(formSelectHosts); formSelectHosts.add(palette); formSelectHosts.add(removeButton); formSelectHosts.add(startButton); formSelectHosts.add(stopButton); newUrl.setRequired(false); add(formNewHost); formNewHost.add(newUrl); add(formRouter); routerAddress.setRequired(false); formRouter.add(routerAddress); //get the list of items to display from provider (database, etc) //in the form of a LoadableDetachableModel IModel listStatusViewModel = new LoadableDetachableModel() { @Override protected Object load() { return CONTROLLER.getStatusData(); } }; ListView statusListView = new ListView("statusListView", listStatusViewModel) { @Override protected void populateItem(final ListItem item) { StatusListItem sli = (StatusListItem) item.getModelObject(); item.add(new Label("Name", sli.getName())); item.add(new Label("Value", sli.getValue())); item.add(new Label("Index", sli.getIndex())); } }; //encapsulate the ListView in a WebMarkupContainer in order for it to update WebMarkupContainer statusListContainer = new WebMarkupContainer("statusContainer"); //generate a markup-id so the contents can be updated through an AJAX call statusListContainer.setOutputMarkupId(true); statusListContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(AJAX_UPDATE_INTERVAL))); // add the list view to the container statusListContainer.add(statusListView); // finally add the container to the page add(statusListContainer); //get the list of items to display from provider (database, etc) //in the form of a LoadableDetachableModel IModel listOutageViewModel = new LoadableDetachableModel() { @Override protected Object load() { return CONTROLLER.getOutageDataReversedOrder(); } }; ListView outageListView = new ListView("outageListView", listOutageViewModel) { @Override protected void populateItem(final ListItem item) { OutageListItem olu = (OutageListItem) item.getModelObject(); item.add(new Label("Index", olu.getIndex())); item.add(new Label("Start", olu.getStart())); item.add(new Label("End", olu.getEnd())); item.add(new Label("Duration", millisToTime(olu.getDuration()))); item.add(new Label("OutageCausedInternal", olu.getOutageCauseAsString())); } }; //encapsulate the ListView in a WebMarkupContainer in order for it to update WebMarkupContainer outageListContainer = new WebMarkupContainer("outageContainer"); //generate a markup-id so the contents can be updated through an AJAX call outageListContainer.setOutputMarkupId(true); outageListContainer.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(AJAX_UPDATE_INTERVAL))); // add the list view to the container outageListContainer.add(outageListView); // finally add the container to the page add(outageListContainer); if (startAutomatically) { LOGGER.info("The controller will be started automatically."); startRunning(); } }
From source file:org.geoserver.web.publish.ServiceLayerConfigurationPanel.java
License:Open Source License
public ServiceLayerConfigurationPanel(String id, IModel<LayerInfo> layerModel) { super(id, layerModel); final AjaxCheckBox configEnabledCheck = new AjaxCheckBox("configEnabled", new PropertyModel<Boolean>(layerModel, "resource.serviceConfiguration")) { private static final long serialVersionUID = 1L; @Override/*from w w w . j av a2s . com*/ protected void onUpdate(AjaxRequestTarget target) { ServiceLayerConfigurationPanel.this.servicesMultiSelector.setVisible(getModelObject()); target.add(ServiceLayerConfigurationPanel.this.serviceSelectionContainer); } }; add(configEnabledCheck); PropertyModel<List<String>> dsModel = new PropertyModel<>(layerModel, "resource.disabledServices"); final IChoiceRenderer<String> renderer = new ChoiceRenderer<String>() { @Override public String getObject(String id, IModel<? extends List<? extends String>> choices) { return id; } @Override public Object getDisplayValue(String object) { if (object == null) return null; return super.getDisplayValue(object); } @Override public String getIdValue(String object, int index) { return object; } }; servicesMultiSelector = new Palette<String>("servicesSelection", dsModel, servicesVotedModel(layerModel.getObject().getResource()), renderer, 10, false) { private static final long serialVersionUID = 1L; @Override public Component newSelectedHeader(final String componentId) { return new Label(componentId, new ResourceModel("DisabledServicesPalette.selectedHeader")); } @Override public Component newAvailableHeader(final String componentId) { return new Label(componentId, new ResourceModel("DisabledServicesPalette.availableHeader")); } }; servicesMultiSelector.add(new DefaultTheme()); servicesMultiSelector.setVisible(layerModel.getObject().getResource().isServiceConfiguration()); serviceSelectionContainer = new WebMarkupContainer("serviceSelectionContainer"); serviceSelectionContainer.setOutputMarkupPlaceholderTag(true); add(serviceSelectionContainer); serviceSelectionContainer.add(servicesMultiSelector); }