List of usage examples for com.vaadin.ui Panel setWidth
@Override public void setWidth(String width)
From source file:eu.eco2clouds.portal.page.SubmissionLayout.java
License:Apache License
public SubmissionLayout() { Panel apPanel = new Panel(); //apPanel.setStyleName("e2c"); apPanel.setWidth("100%"); apPanel.setHeight("400px"); apPanel.setContent(new ApplicationProfileLayout()); this.addComponent(apPanel); //Panel notificationPanel = new Panel(); //notificationPanel.setStyleName("e2c"); //notificationPanel.setWidth("100%"); //notificationPanel.setHeight("100%"); //notificationPanel.setContent(notificationTable); //this.addComponent(notificationPanel); //this.setExpandRatio(apPanel, 1.0f); //this.setExpandRatio(notificationPanel, 1.5f); }
From source file:eu.hurion.hello.vaadin.shiro.application.HelloScreen.java
License:Apache License
public HelloScreen(final HerokuShiroApplication app) { setSizeFull();/*from w w w. j a va 2 s . c o m*/ final Subject currentUser = SecurityUtils.getSubject(); final Panel welcomePanel = new Panel(); final FormLayout content = new FormLayout(); final Label label = new Label("Logged in as " + currentUser.getPrincipal().toString()); logout = new Button("logout"); logout.addClickListener(new HerokuShiroApplication.LogoutListener(app)); content.addComponent(label); content.addComponent(logout); welcomePanel.setContent(content); welcomePanel.setWidth("400px"); welcomePanel.setHeight("200px"); addComponent(welcomePanel); setComponentAlignment(welcomePanel, Alignment.MIDDLE_CENTER); final HorizontalLayout footer = new HorizontalLayout(); footer.setHeight("50px"); addComponent(footer); final Button adminButton = new Button("For admin only"); adminButton.setEnabled(currentUser.hasRole("admin")); adminButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { Notification.show("you're an admin"); } }); content.addComponent(adminButton); final Button userButton = new Button("For users with permission 1"); userButton.setEnabled(currentUser.isPermitted("permission_1")); userButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final Button.ClickEvent event) { Notification.show("you've got permission 1"); } }); content.addComponent(userButton); }
From source file:eu.hurion.hello.vaadin.shiro.application.LoginScreen.java
License:Apache License
public LoginScreen(final HerokuShiroApplication app) { setSizeFull();// w ww . j a v a 2s . com final Panel loginPanel = new Panel("Login"); loginPanel.setWidth("300px"); final FormLayout content = new FormLayout(); content.setSizeFull(); user = new TextField("User"); content.addComponent(user); password = new PasswordField("Password"); content.addComponent(password); final Button loginButton = new Button("Log in"); content.setHeight("150px"); loginButton.addClickListener(new ShiroLoginListener(app)); content.addComponent(loginButton); loginPanel.setContent(content); addComponent(loginPanel); setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); final HorizontalLayout footer = new HorizontalLayout(); footer.setHeight("50px"); addComponent(footer); }
From source file:eu.maxschuster.vaadin.signaturefield.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle(pageTitle);// w w w .ja v a 2 s.com final VerticalLayout margin = new VerticalLayout(); setContent(margin); final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("658px"); margin.addComponent(layout); margin.setComponentAlignment(layout, Alignment.TOP_CENTER); final Label header1 = new Label(pageTitle); header1.addStyleName("h1"); header1.setSizeUndefined(); layout.addComponent(header1); layout.setComponentAlignment(header1, Alignment.TOP_CENTER); final TabSheet tabSheet = new TabSheet(); tabSheet.setWidth("100%"); layout.addComponent(tabSheet); layout.setComponentAlignment(tabSheet, Alignment.TOP_CENTER); final Panel signaturePanel = new Panel(); signaturePanel.addStyleName("signature-panel"); signaturePanel.setWidth("100%"); tabSheet.addTab(signaturePanel, "Demo"); final VerticalLayout signatureLayout = new VerticalLayout(); signatureLayout.setMargin(true); signatureLayout.setSpacing(true); signatureLayout.setSizeFull(); signaturePanel.setContent(signatureLayout); final SignatureField signatureField = new SignatureField(); signatureField.setWidth("100%"); signatureField.setHeight("318px"); signatureField.setPenColor(Color.ULTRAMARINE); signatureField.setBackgroundColor("white"); signatureField.setConverter(new StringToDataUrlConverter()); signatureField.setPropertyDataSource(dataUrlProperty); signatureField.setVelocityFilterWeight(0.7); signatureLayout.addComponent(signatureField); signatureLayout.setComponentAlignment(signatureField, Alignment.MIDDLE_CENTER); final HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); signatureLayout.addComponent(buttonLayout); final Button clearButton = new Button("Clear", new ClickListener() { @Override public void buttonClick(ClickEvent event) { signatureField.clear(); } }); buttonLayout.addComponent(clearButton); buttonLayout.setComponentAlignment(clearButton, Alignment.MIDDLE_LEFT); final Label message = new Label("Sign above"); message.setSizeUndefined(); buttonLayout.addComponent(message); buttonLayout.setComponentAlignment(message, Alignment.MIDDLE_CENTER); final ButtonLink saveButtonLink = new ButtonLink("Save", null); saveButtonLink.setTargetName("_blank"); buttonLayout.addComponent(saveButtonLink); buttonLayout.setComponentAlignment(saveButtonLink, Alignment.MIDDLE_RIGHT); final Panel optionsPanel = new Panel(); optionsPanel.setSizeFull(); tabSheet.addTab(optionsPanel, "Options"); final FormLayout optionsLayout = new FormLayout(); optionsLayout.setMargin(true); optionsLayout.setSpacing(true); optionsPanel.setContent(optionsLayout); final ComboBox mimeTypeComboBox = new ComboBox(null, mimeTypeContainer); optionsLayout.addComponent(mimeTypeComboBox); mimeTypeComboBox.setItemCaptionPropertyId("mimeType"); mimeTypeComboBox.setNullSelectionAllowed(false); mimeTypeComboBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { MimeType mimeType = (MimeType) event.getProperty().getValue(); signatureField.setMimeType(mimeType); } }); mimeTypeComboBox.setValue(MimeType.PNG); mimeTypeComboBox.setCaption("Result MIME-Type"); final CheckBox immediateCheckBox = new CheckBox("immediate", false); optionsLayout.addComponent(immediateCheckBox); immediateCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean immediate = (Boolean) event.getProperty().getValue(); signatureField.setImmediate(immediate); } }); final CheckBox readOnlyCheckBox = new CheckBox("readOnly", false); optionsLayout.addComponent(readOnlyCheckBox); readOnlyCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean readOnly = (Boolean) event.getProperty().getValue(); signatureField.setReadOnly(readOnly); mimeTypeComboBox.setReadOnly(readOnly); clearButton.setEnabled(!readOnly); } }); final CheckBox requiredCheckBox = new CheckBox("required (causes bug that clears field)", false); optionsLayout.addComponent(requiredCheckBox); requiredCheckBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean required = (Boolean) event.getProperty().getValue(); signatureField.setRequired(required); } }); final CheckBox clearButtonEnabledButton = new CheckBox("clearButtonEnabled", false); optionsLayout.addComponent(clearButtonEnabledButton); clearButtonEnabledButton.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean clearButtonEnabled = (Boolean) event.getProperty().getValue(); signatureField.setClearButtonEnabled(clearButtonEnabled); } }); final Panel resultPanel = new Panel("Results:"); resultPanel.setWidth("100%"); layout.addComponent(resultPanel); final VerticalLayout resultLayout = new VerticalLayout(); resultLayout.setMargin(true); resultPanel.setContent(resultLayout); final Image stringPreviewImage = new Image("String preview image:"); stringPreviewImage.setWidth("500px"); resultLayout.addComponent(stringPreviewImage); final Image dataUrlPreviewImage = new Image("DataURL preview image:"); dataUrlPreviewImage.setWidth("500px"); resultLayout.addComponent(dataUrlPreviewImage); final TextArea textArea = new TextArea("DataURL:"); textArea.setWidth("100%"); textArea.setHeight("300px"); resultLayout.addComponent(textArea); final Label emptyLabel = new Label(); emptyLabel.setCaption("Is Empty:"); emptyLabel.setValue(String.valueOf(signatureField.isEmpty())); resultLayout.addComponent(emptyLabel); signatureField.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String signature = (String) event.getProperty().getValue(); stringPreviewImage.setSource(signature != null ? new ExternalResource(signature) : null); textArea.setValue(signature); emptyLabel.setValue(String.valueOf(signatureField.isEmpty())); } }); dataUrlProperty.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { try { final DataUrl signature = (DataUrl) event.getProperty().getValue(); dataUrlPreviewImage.setSource( signature != null ? new ExternalResource(serializer.serialize(signature)) : null); StreamResource streamResource = null; if (signature != null) { StreamSource streamSource = new StreamSource() { @Override public InputStream getStream() { return new ByteArrayInputStream(signature.getData()); } }; MimeType mimeType = MimeType.valueOfMimeType(signature.getMimeType()); String extension = null; switch (mimeType) { case JPEG: extension = "jpg"; break; case PNG: extension = "png"; break; } streamResource = new StreamResource(streamSource, "signature." + extension); streamResource.setMIMEType(signature.getMimeType()); streamResource.setCacheTime(0); } saveButtonLink.setResource(streamResource); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); } } }); }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatinterfaceUI.java
License:Open Source License
private void createTab_Sites() { VerticalLayout tab_site = new VerticalLayout(); tab_site.setCaption("Sites"); tabsheet.addTab(tab_site);//from w w w .j av a 2 s.c o m Panel p_project = new Panel("Create a sites"); p_project.setWidth("400"); HorizontalLayout hor_sites = new HorizontalLayout(); hor_sites.addComponent(sites_tree); final VerticalLayout project_browser4Sites = new VerticalLayout(); hor_sites.addComponent(project_browser4Sites); tab_site.addComponent(hor_sites); htmlView_Project(project_browser4Sites, "Structural"); sites_tree.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 7237016481874141615L; public void valueChange(ValueChangeEvent event) { if (!sites_tree.hasChildren(sites_tree.getValue())) { if (sites_tree.getValue() != null) htmlView_Project(project_browser4Sites, sites_tree.getValue().toString()); } } }); sites_tree.setImmediate(true); Button newRealEstate_button = new Button("Create", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { String realEstate_name = site_textField.getValue(); if (realEstate_name != null && realEstate_name.length() > 0) { marmotta_sparql.create_RealEstate(realEstate_name); listSites(); } } }); HorizontalLayout newproject_layout = new HorizontalLayout(); newproject_layout.setSizeUndefined(); site_textField.setImmediate(true); newproject_layout.addComponent(site_textField); newproject_layout.addComponent(newRealEstate_button); newproject_layout.setSpacing(true); p_project.setContent(newproject_layout); tab_site.addComponent(p_project); Button removeRealEstate_button = new Button("Remove the selected site", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { TreeNode realEstate = (TreeNode) sites_tree.getValue(); if (realEstate != null) { //Only real estates Object parent = sites_tree.getParent(realEstate); if (parent == null) { marmotta_sparql.remove_RealEstate(realEstate.getInternal_name()); listSites(); } } } }); tab_site.addComponent(removeRealEstate_button); }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatinterfaceUI.java
License:Open Source License
@SuppressWarnings("deprecation") private void createTab_Datasets() { VerticalLayout tab_datasets = new VerticalLayout(); tab_datasets.setCaption("Data sets"); tabsheet.addTab(tab_datasets);// w w w . j a v a 2s . c o m tab_datasets.addComponent(datasets_tree); Link void_link = new Link("Void description of the data sets", new ExternalResource("http://drumbeat.cs.hut.fi/void.ttl")); tab_datasets.addComponent(void_link); Panel p_model = new Panel("Upload and convert an IFC file"); p_model.setWidth("900"); tab_datasets.addComponent(p_model); HorizontalLayout hor1 = new HorizontalLayout(); hor1.setSizeFull(); // Use all available space hor1.setMargin(true); p_model.setContent(hor1); VerticalLayout upload_selections = new VerticalLayout(); hor1.addComponent(upload_selections); upload_selections.addComponent(sites_tree_4upload); VerticalLayout upload_panels = new VerticalLayout(); hor1.addComponent(upload_panels); Panel p_model_file = new Panel("Upload a file"); p_model_file.setWidth("400"); upload_panels.addComponent(p_model_file); Panel p_model_url = new Panel("Upload from a URL"); p_model_url.setWidth("400"); upload_panels.addComponent(p_model_url); // Create the upload with a caption and set receiver later Upload upload = new Upload("Select a file and press Upload", drumbeat_fileReceiver); upload.addSucceededListener(drumbeat_fileReceiver); upload.addFailedListener(drumbeat_fileReceiver); p_model_file.setContent(upload); url_textField.setImmediate(true); Button button = new Button("Upload from the URL", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { drumbeat_fileReceiver.receiveFileFromURL(url_textField.getValue()); } }); HorizontalLayout url_upload = new HorizontalLayout(); url_upload.setSizeUndefined(); url_upload.addComponent(url_textField); url_upload.addComponent(button); url_upload.setSpacing(true); p_model_url.setContent(url_upload); bim_projects_selection.setInvalidAllowed(false); bim_projects_selection.setNullSelectionAllowed(false); bim_projects_selection.setNewItemsAllowed(false); bim_projects_selection.setWidth("400"); final VerticalLayout project_browser = new VerticalLayout(); bim_projects_selection.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -5188369735622627751L; public void valueChange(ValueChangeEvent event) { if (bim_projects_selection.getValue() != null) { htmlView_BIMProject(project_browser, bim_projects.get(bim_projects_selection.getValue())); } } }); tab_datasets.addComponent(bim_projects_selection); tab_datasets.addComponent(project_browser); }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatinterfaceUI.java
License:Open Source License
@SuppressWarnings("deprecation") private void createTab_Queries() { VerticalLayout tab_queries = new VerticalLayout(); tab_queries.setCaption("Queries"); tabsheet.addTab(tab_queries);/* w w w . j a v a 2 s. c o m*/ Panel p_sparql = new Panel("Sparql query"); p_sparql.setWidth("900"); VerticalLayout sparql_layout = new VerticalLayout(); final ComboBox queries = new ComboBox("Select a query"); queries.setInvalidAllowed(false); queries.setNullSelectionAllowed(false); queries.setNewItemsAllowed(false); queries.addItem("Sites"); queries.setValue("Sites"); queries.addItem("Structural model links"); queries.addItem("Project name"); queries.addItem("List implements links"); queries.setWidth("400"); queries.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -5188369735622627751L; public void valueChange(ValueChangeEvent event) { if (queries.getValue() != null) { if (queries.getValue().equals("Sites")) sparql_query_area.setValue(DrumbeatConstants.query_sites); if (queries.getValue().equals("Structural model links")) sparql_query_area.setValue(DrumbeatConstants.query_structural_links); if (queries.getValue().equals("Project name")) sparql_query_area.setValue(DrumbeatConstants.query_structural_project); if (queries.getValue().equals("List implements links")) sparql_query_area.setValue(DrumbeatConstants.query_implemens); } } }); sparql_layout.addComponent(queries); sparql_layout.addComponent(sparql_query_area); sparql_query_area.setValue(DrumbeatConstants.query_sites); Button sparql_button = new Button("Query", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { sparql_result_rtarea.setValue(marmotta.httpGetQuery2html(sparql_query_area.getValue())); } }); Button sparql_button_json = new Button("Query and download JSON"); OnDemandFileDownloader jsonDownloader = new OnDemandFileDownloader(createOnDemandJSON_Resource(), "JSON", this); jsonDownloader.extend(sparql_button_json); Button sparql_button_xml = new Button("Query and download XML"); OnDemandFileDownloader xmlDownloader = new OnDemandFileDownloader(createOnDemandXMLResource(), "XML", this); xmlDownloader.extend(sparql_button_xml); HorizontalLayout hor_sparql_buttons = new HorizontalLayout(); hor_sparql_buttons.addComponent(sparql_button); hor_sparql_buttons.addComponent(sparql_button_json); hor_sparql_buttons.addComponent(sparql_button_xml); sparql_layout.addComponent(hor_sparql_buttons); sparql_layout.addComponent(sparql_result_rtarea); sparql_query_area.setWidth("800"); sparql_query_area.setHeight("400"); sparql_result_rtarea.setWidth("800"); p_sparql.setContent(sparql_layout); tab_queries.addComponent(p_sparql); }
From source file:fi.aalto.drumbeat.drumbeatUI.DrumbeatinterfaceUI.java
License:Open Source License
private void createTab_Links() { VerticalLayout tab_links = new VerticalLayout(); tab_links.setCaption("Links"); tabsheet.addTab(tab_links);/*from w w w . j ava 2 s .c o m*/ Panel p_links = new Panel("Implements query"); p_links.setWidth("900"); VerticalLayout links_layout = new VerticalLayout(); contexts_selection.setInvalidAllowed(false); contexts_selection.setNullSelectionAllowed(false); contexts_selection.setNewItemsAllowed(false); contexts_selection.setWidth("800"); links_layout.addComponent(contexts_selection); Button links_button = new Button("List links", new Button.ClickListener() { @SuppressWarnings("unchecked") @Override public void buttonClick(Button.ClickEvent event) { if (contexts_selection.getValue() != null && contexts_selection.getValue().toString().length() > 0) { String query = ToolkitString.strReplaceLike(DrumbeatConstants.querytemplate_links, "<context>", "<" + contexts_selection.getValue() + ">"); List<Pair> links = marmotta.httpGetLinks(query); links_table.removeAllItems(); generated_links.clear(); for (Pair p : links) { Object newItemId = links_table.addItem(); Item row = links_table.getItem(newItemId); String short_from = ToolkitString.strReplaceLike(p.getS1(), DrumbeatConstants.resource_baseurl, "resourse:"); String short_to = ToolkitString.strReplaceLike(p.getS2(), DrumbeatConstants.resource_baseurl, "resourse:"); row.getItemProperty("From").setValue(short_from); row.getItemProperty("property").setValue("ifc:implements"); row.getItemProperty("To").setValue(short_to); generated_links.add(p); } } } }); links_layout.addComponent(links_button); links_table.addContainerProperty("From", String.class, null); links_table.addContainerProperty("property", String.class, null); links_table.addContainerProperty("To", String.class, null); links_table.setSelectable(false); links_layout.addComponent(links_table); links_table.setWidth("800"); Button insert_links_button = new Button("Insert links to the RDF Store", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { marmotta_sparql.add_linkset2Model(generated_links); } }); Button remove_links_button = new Button("Remove links from the RDF Store", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { marmotta_sparql.remove_linksetFromModel(generated_links); } }); HorizontalLayout hor_links_buttons = new HorizontalLayout(); hor_links_buttons.addComponent(insert_links_button); hor_links_buttons.addComponent(remove_links_button); links_layout.addComponent(hor_links_buttons); p_links.setContent(links_layout); tab_links.addComponent(p_links); }
From source file:fi.jasoft.dragdroplayouts.demo.views.DragdropCaptionModeDemo.java
License:Apache License
@Override public Component getLayout() { // start-source // Create layout DDAbsoluteLayout layout = new DDAbsoluteLayout(); // Enable dragging components by their caption layout.setDragMode(LayoutDragMode.CAPTION); // Enable dropping components layout.setDropHandler(new DefaultAbsoluteLayoutDropHandler()); // Add some content to the layout layout.addComponent(new Label("This layout uses the LayoutDragMode.CAPTION " + "drag mode for dragging the components. This mode is useful " + "when you only want users to drag items by their captions. The Panels below are only draggable by their captions (<< Move >>).", ContentMode.HTML));/*from w w w. java 2 s . c o m*/ Panel chapter1 = new Panel("<< Move >>"); chapter1.setWidth("300px"); Label chapter1Content = new Label(new LoremIpsum().getParagraphs(1), ContentMode.TEXT); chapter1Content.setCaption("===== Chapter 1 - The beginning ======"); chapter1.setContent(chapter1Content); layout.addComponent(chapter1, "top:50px;left:10px"); Panel chapter2 = new Panel("<< Move >>"); chapter2.setWidth("300px"); Label chapter2Content = new Label(new LoremIpsum().getParagraphs(1), ContentMode.TEXT); chapter2Content.setCaption("===== Chapter 2 - The finale ======"); chapter2.setContent(chapter2Content); layout.addComponent(chapter2, "top:50px; left:320px"); // end-source return layout; }
From source file:fi.semantum.strategia.Utils.java
License:Open Source License
public static void manage(final Main main) { final Database database = main.getDatabase(); VerticalLayout content = new VerticalLayout(); content.setSizeFull();/*from w w w . jav a 2s. c o m*/ content.setSpacing(true); HorizontalLayout hl1 = new HorizontalLayout(); hl1.setSpacing(true); hl1.setWidth("100%"); final ComboBox users = new ComboBox(); users.setWidth("100%"); users.setNullSelectionAllowed(false); users.addStyleName(ValoTheme.COMBOBOX_SMALL); users.setCaption("Valitse kyttj:"); final Map<String, Account> accountMap = new HashMap<String, Account>(); makeAccountCombo(main, accountMap, users); for (Account a : Account.enumerate(database)) { accountMap.put(a.getId(database), a); users.addItem(a.getId(database)); users.select(a.getId(database)); } final Table table = new Table(); table.setSelectable(true); table.setMultiSelect(true); table.addStyleName(ValoTheme.TABLE_SMALL); table.addStyleName(ValoTheme.TABLE_SMALL); table.addStyleName(ValoTheme.TABLE_COMPACT); users.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 5036991262418844060L; @Override public void valueChange(ValueChangeEvent event) { users.removeValueChangeListener(this); makeAccountCombo(main, accountMap, users); makeAccountTable(database, users, accountMap, table); users.addValueChangeListener(this); } }); final TextField tf = new TextField(); Validator nameValidator = new Validator() { private static final long serialVersionUID = -4779239111120669168L; @Override public void validate(Object value) throws InvalidValueException { String s = (String) value; if (s.isEmpty()) throw new InvalidValueException("Nimi ei saa olla tyhj"); if (accountMap.containsKey(s)) throw new InvalidValueException("Nimi on jo kytss"); } }; final Button save = new Button("Luo", new Button.ClickListener() { private static final long serialVersionUID = -6053708137324681886L; public void buttonClick(ClickEvent event) { if (!tf.isValid()) return; String pass = Long.toString(Math.abs(UUID.randomUUID().getLeastSignificantBits()), 36); Account.create(database, tf.getValue(), "", Utils.hash(pass)); Updates.update(main, true); makeAccountCombo(main, accountMap, users); makeAccountTable(database, users, accountMap, table); Dialogs.infoDialog(main, "Uusi kyttj '" + tf.getValue() + "' luotu", "Kyttjn salasana on " + pass + "", null); } }); save.addStyleName(ValoTheme.BUTTON_SMALL); final Button remove = new Button("Poista", new Button.ClickListener() { private static final long serialVersionUID = -5359199320445328801L; public void buttonClick(ClickEvent event) { Object selection = users.getValue(); Account state = accountMap.get(selection); // System cannot be removed if ("System".equals(state.getId(database))) return; state.remove(database); Updates.update(main, true); makeAccountCombo(main, accountMap, users); makeAccountTable(database, users, accountMap, table); } }); remove.addStyleName(ValoTheme.BUTTON_SMALL); tf.setWidth("100%"); tf.addStyleName(ValoTheme.TEXTFIELD_SMALL); tf.setCaption("Luo uusi kyttj nimell:"); tf.setValue(findFreshUserName(nameValidator)); tf.setCursorPosition(tf.getValue().length()); tf.setValidationVisible(true); tf.setInvalidCommitted(true); tf.setImmediate(true); tf.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = -8274588731607481635L; @Override public void textChange(TextChangeEvent event) { tf.setValue(event.getText()); try { tf.validate(); } catch (InvalidValueException e) { save.setEnabled(false); return; } save.setEnabled(true); } }); tf.addValidator(nameValidator); if (!tf.isValid()) save.setEnabled(false); hl1.addComponent(users); hl1.setExpandRatio(users, 1.0f); hl1.setComponentAlignment(users, Alignment.BOTTOM_CENTER); hl1.addComponent(tf); hl1.setExpandRatio(tf, 1.0f); hl1.setComponentAlignment(tf, Alignment.BOTTOM_CENTER); hl1.addComponent(save); hl1.setExpandRatio(save, 0.0f); hl1.setComponentAlignment(save, Alignment.BOTTOM_CENTER); hl1.addComponent(remove); hl1.setExpandRatio(remove, 0.0f); hl1.setComponentAlignment(remove, Alignment.BOTTOM_CENTER); content.addComponent(hl1); content.setExpandRatio(hl1, 0.0f); table.addContainerProperty("Kartta", String.class, null); table.addContainerProperty("Oikeus", String.class, null); table.addContainerProperty("Laajuus", String.class, null); table.setWidth("100%"); table.setHeight("100%"); table.setNullSelectionAllowed(true); table.setMultiSelect(true); table.setCaption("Kyttjn oikeudet"); makeAccountTable(database, users, accountMap, table); content.addComponent(table); content.setExpandRatio(table, 1.0f); final Button removeRights = new Button("Poista valitut rivit", new Button.ClickListener() { private static final long serialVersionUID = 4699670345358079045L; public void buttonClick(ClickEvent event) { Object user = users.getValue(); Account state = accountMap.get(user); Object selection = table.getValue(); Collection<?> sel = (Collection<?>) selection; List<Right> toRemove = new ArrayList<Right>(); for (Object s : sel) { Integer index = (Integer) s; toRemove.add(state.rights.get(index - 1)); } for (Right r : toRemove) state.rights.remove(r); Updates.update(main, true); makeAccountTable(database, users, accountMap, table); } }); removeRights.addStyleName(ValoTheme.BUTTON_SMALL); table.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1188285609779556446L; @Override public void valueChange(ValueChangeEvent event) { Object selection = table.getValue(); Collection<?> sel = (Collection<?>) selection; if (sel.isEmpty()) removeRights.setEnabled(false); else removeRights.setEnabled(true); } }); final ComboBox mapSelect = new ComboBox(); mapSelect.setWidth("100%"); mapSelect.setNullSelectionAllowed(false); mapSelect.addStyleName(ValoTheme.COMBOBOX_SMALL); mapSelect.setCaption("Valitse kartta:"); for (Strategiakartta a : Strategiakartta.enumerate(database)) { mapSelect.addItem(a.uuid); mapSelect.setItemCaption(a.uuid, a.getText(database)); mapSelect.select(a.uuid); } final ComboBox rightSelect = new ComboBox(); rightSelect.setWidth("100px"); rightSelect.setNullSelectionAllowed(false); rightSelect.addStyleName(ValoTheme.COMBOBOX_SMALL); rightSelect.setCaption("Valitse oikeus:"); rightSelect.addItem("Muokkaus"); rightSelect.addItem("Luku"); rightSelect.select("Luku"); final ComboBox propagateSelect = new ComboBox(); propagateSelect.setWidth("130px"); propagateSelect.setNullSelectionAllowed(false); propagateSelect.addStyleName(ValoTheme.COMBOBOX_SMALL); propagateSelect.setCaption("Valitse laajuus:"); propagateSelect.addItem(VALITTU_KARTTA); propagateSelect.addItem(ALATASON_KARTAT); propagateSelect.select(VALITTU_KARTTA); final Button addRight = new Button("Lis rivi", new Button.ClickListener() { private static final long serialVersionUID = -4841787792917761055L; public void buttonClick(ClickEvent event) { Object user = users.getValue(); Account state = accountMap.get(user); String mapUUID = (String) mapSelect.getValue(); Strategiakartta map = database.find(mapUUID); String right = (String) rightSelect.getValue(); String propagate = (String) propagateSelect.getValue(); Right r = new Right(map, right.equals("Muokkaus"), propagate.equals(ALATASON_KARTAT)); state.rights.add(r); Updates.update(main, true); makeAccountTable(database, users, accountMap, table); } }); addRight.addStyleName(ValoTheme.BUTTON_SMALL); table.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 6439090862804667322L; @Override public void valueChange(ValueChangeEvent event) { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (!selected.isEmpty()) { removeRights.setEnabled(true); } else { removeRights.setEnabled(false); } } }); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.setWidth("100%"); hl2.addComponent(removeRights); hl2.setComponentAlignment(removeRights, Alignment.TOP_LEFT); hl2.setExpandRatio(removeRights, 0.0f); hl2.addComponent(addRight); hl2.setComponentAlignment(addRight, Alignment.BOTTOM_LEFT); hl2.setExpandRatio(addRight, 0.0f); hl2.addComponent(mapSelect); hl2.setComponentAlignment(mapSelect, Alignment.BOTTOM_LEFT); hl2.setExpandRatio(mapSelect, 1.0f); hl2.addComponent(rightSelect); hl2.setComponentAlignment(rightSelect, Alignment.BOTTOM_LEFT); hl2.setExpandRatio(rightSelect, 0.0f); hl2.addComponent(propagateSelect); hl2.setComponentAlignment(propagateSelect, Alignment.BOTTOM_LEFT); hl2.setExpandRatio(propagateSelect, 0.0f); content.addComponent(hl2); content.setComponentAlignment(hl2, Alignment.BOTTOM_LEFT); content.setExpandRatio(hl2, 0.0f); final VerticalLayout vl = new VerticalLayout(); final Panel p = new Panel(); p.setWidth("100%"); p.setHeight("200px"); p.setContent(vl); final TimeConfiguration tc = TimeConfiguration.getInstance(database); final TextField tf2 = new TextField(); tf2.setWidth("200px"); tf2.addStyleName(ValoTheme.TEXTFIELD_SMALL); tf2.setCaption("Strategiakartan mritysaika:"); tf2.setValue(tc.getRange()); tf2.setCursorPosition(tf.getValue().length()); tf2.setValidationVisible(true); tf2.setInvalidCommitted(true); tf2.setImmediate(true); tf2.addTextChangeListener(new TextChangeListener() { private static final long serialVersionUID = -8274588731607481635L; @Override public void textChange(TextChangeEvent event) { tf2.setValue(event.getText()); try { tf2.validate(); tc.setRange(event.getText()); updateYears(database, vl); Updates.update(main, true); } catch (InvalidValueException e) { return; } } }); tf2.addValidator(new Validator() { private static final long serialVersionUID = -4779239111120669168L; @Override public void validate(Object value) throws InvalidValueException { String s = (String) value; TimeInterval ti = TimeInterval.parse(s); long start = ti.startYear; long end = ti.endYear; if (start < 2015) throw new InvalidValueException("Alkuvuosi ei voi olla aikaisempi kuin 2015."); if (end > 2025) throw new InvalidValueException("Pttymisvuosi ei voi olla myhisempi kuin 2025."); if (end - start > 9) throw new InvalidValueException("Strategiakartta ei tue yli 10 vuoden tarkasteluja."); } }); content.addComponent(tf2); content.setComponentAlignment(tf2, Alignment.BOTTOM_LEFT); content.setExpandRatio(tf2, 0.0f); updateYears(database, vl); content.addComponent(p); content.setComponentAlignment(p, Alignment.BOTTOM_LEFT); content.setExpandRatio(p, 0.0f); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(false); Dialogs.makeDialog(main, main.dialogWidth(), main.dialogHeight(0.8), "Hallinnoi strategiakarttaa", "Sulje", content, buttons); }