List of usage examples for com.vaadin.ui.themes ValoTheme COMBOBOX_TINY
String COMBOBOX_TINY
To view the source code for com.vaadin.ui.themes ValoTheme COMBOBOX_TINY.
Click Source Link
From source file:com.dungnv.streetfood.ui.CommonSearchPagedUI.java
private final void init() { setWidth("100%"); setStyleName("item-search-box"); HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true);// w ww . j a v a 2 s. com this.addComponent(layout); FormLayout form = new FormLayout(); // form.setWidth("100%"); form.setMargin(false); layout.addComponent(form); layout.setComponentAlignment(form, Alignment.MIDDLE_CENTER); cbRecordPerPage = new ComboBox(); cbRecordPerPage.setWidth("65px"); cbRecordPerPage.setStyleName(ValoTheme.COMBOBOX_TINY); cbRecordPerPage.setCaption(BundleUtils.getLanguage("lbl.recordsPerPage")); cbRecordPerPage.setTextInputAllowed(false); cbRecordPerPage.addItem(10); cbRecordPerPage.addItem(20); cbRecordPerPage.addItem(30); cbRecordPerPage.addItem(50); cbRecordPerPage.addItem(100); cbRecordPerPage.addItem(200); cbRecordPerPage.select(10); form.addComponent(cbRecordPerPage); cbRecordPerPage.setNullSelectionAllowed(false); btnFastBackward = new Button(); btnFastBackward.addStyleName(ValoTheme.BUTTON_ICON_ONLY); btnFastBackward.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); btnFastBackward.setIcon(FontAwesome.FAST_BACKWARD); layout.addComponent(btnFastBackward); layout.setComponentAlignment(btnFastBackward, Alignment.MIDDLE_CENTER); btnBackward = new Button(); btnBackward.addStyleName(ValoTheme.BUTTON_ICON_ONLY); btnBackward.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); btnBackward.setIcon(FontAwesome.BACKWARD); layout.addComponent(btnBackward); layout.setComponentAlignment(btnBackward, Alignment.MIDDLE_CENTER); cbPaged = new ComboBox(); cbPaged.setTextInputAllowed(false); for (int i = 1; i <= pageCount; i++) { cbPaged.addItem(i); } cbPaged.setNullSelectionAllowed(false); cbPaged.select(1); cbPaged.addStyleName(ValoTheme.COMBOBOX_TINY); cbPaged.setWidth("60px"); layout.addComponent(cbPaged); layout.setComponentAlignment(cbPaged, Alignment.MIDDLE_CENTER); btnFoward = new Button(); btnFoward.addStyleName(ValoTheme.BUTTON_ICON_ONLY); btnFoward.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); btnFoward.setIcon(FontAwesome.FORWARD); layout.addComponent(btnFoward); layout.setComponentAlignment(btnFoward, Alignment.MIDDLE_CENTER); btnFastFoward = new Button(); btnFastFoward.addStyleName(ValoTheme.BUTTON_ICON_ONLY); btnFastFoward.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); btnFastFoward.setIcon(FontAwesome.FAST_FORWARD); layout.addComponent(btnFastFoward); layout.setComponentAlignment(btnFastFoward, Alignment.MIDDLE_CENTER); enableComponent(); }
From source file:com.mechanicshop.components.DataEntryLayout.java
private void buildLayout() { FormLayout formLayout1 = new FormLayout(); formLayout1.setMargin(new MarginInfo(false, false, false, true)); formLayout1.setSpacing(true);/* w w w .j av a 2 s .com*/ FormLayout formLayout2 = new FormLayout(); formLayout2.setMargin(new MarginInfo(false, false, false, true)); formLayout2.setSpacing(true); FormLayout formLayout3 = new FormLayout(); formLayout3.setMargin(new MarginInfo(false, true, false, true)); formLayout3.setSpacing(true); tfTag.setStyleName(ValoTheme.TEXTFIELD_TINY); tfTag.setWidth("180px"); tfTag.setMaxLength(3); tfTag.setNullRepresentation(""); tfPhone.setStyleName(ValoTheme.TEXTFIELD_TINY); tfPhone.setWidth("180px"); tfPhone.setNullRepresentation(""); tfPhone.setMaxLength(11); tfName.setStyleName(ValoTheme.TEXTFIELD_TINY); tfName.setWidth("180px"); tfName.setMaxLength(50); tfName.setNullRepresentation(""); tfVehicle.setWidth("180px"); tfVehicle.setStyleName(ValoTheme.TEXTFIELD_TINY); tfVehicle.setMaxLength(75); tfVehicle.setNullRepresentation(""); tfLicensePlate.setStyleName(ValoTheme.TEXTFIELD_TINY); tfLicensePlate.setWidth("180px"); tfLicensePlate.setMaxLength(10); tfLicensePlate.setNullRepresentation(""); tfVin.setWidth("180px"); tfVin.setStyleName(ValoTheme.TEXTFIELD_TINY); tfVin.setMaxLength(17); tfVin.setNullRepresentation(""); dfInShop.setImmediate(true); dfInShop.addStyleName(ValoTheme.DATEFIELD_TINY); dfInShop.setInputPrompt("Select"); dfInShop.setWidth("120px"); dfOutShop.setImmediate(true); dfOutShop.addStyleName(ValoTheme.DATEFIELD_TINY); dfOutShop.setInputPrompt("Select"); dfOutShop.setWidth("120px"); nsStatus.addItems("In", "Out", "Pending", "Ready", "Comeback"); nsStatus.setImmediate(true); nsStatus.setWidth("120px"); nsStatus.setStyleName(ValoTheme.COMBOBOX_TINY); nsStatus.setValue("In"); tfMileage.setWidth("120px"); tfMileage.setStyleName(ValoTheme.TEXTFIELD_TINY); tfMileage.setMaxLength(6); tfMileage.setNullRepresentation(""); tfPicked.setWidth("120px"); tfPicked.setStyleName(ValoTheme.TEXTFIELD_TINY); tfPicked.setMaxLength(3); tfPicked.setNullRepresentation(""); tfPayment.setWidth("180px"); tfPayment.setStyleName(ValoTheme.TEXTFIELD_TINY); tfPayment.setMaxLength(50); tfPayment.setNullRepresentation(""); taRemarks.setWidth("500px"); taRemarks.setStyleName(ValoTheme.TEXTFIELD_TINY); taRemarks.setMaxLength(500); taRemarks.setNullRepresentation(""); tfRebuilder.setWidth("180px"); tfRebuilder.setStyleName(ValoTheme.TEXTFIELD_TINY); tfRebuilder.setMaxLength(20); tfRebuilder.setNullRepresentation(""); tfInstaller.setWidth("180px"); tfInstaller.setStyleName(ValoTheme.TEXTFIELD_TINY); tfInstaller.setMaxLength(20); tfInstaller.setNullRepresentation(""); tfFirstCheckBy.setWidth("500px"); tfFirstCheckBy.setStyleName(ValoTheme.TEXTFIELD_TINY); tfFirstCheckBy.setMaxLength(100); tfFirstCheckBy.setNullRepresentation(""); tfSecondCheckBy.setWidth("500px"); tfSecondCheckBy.setStyleName(ValoTheme.TEXTFIELD_TINY); tfSecondCheckBy.setMaxLength(100); tfSecondCheckBy.setNullRepresentation(""); dfFirstCheckDate.setImmediate(true); dfFirstCheckDate.addStyleName(ValoTheme.DATEFIELD_TINY); dfFirstCheckDate.setInputPrompt("Select"); dfFirstCheckDate.setWidth("120px"); dfSecondCheckDate.setImmediate(true); dfSecondCheckDate.addStyleName(ValoTheme.DATEFIELD_TINY); dfSecondCheckDate.setInputPrompt("Select"); dfSecondCheckDate.setWidth("120px"); taMedia.setWidth("500px"); taMedia.setStyleName(ValoTheme.TEXTFIELD_TINY); taMedia.setNullRepresentation(""); taMedia2.setWidth("500px"); taMedia2.setStyleName(ValoTheme.TEXTFIELD_TINY); taMedia2.setNullRepresentation(""); tfReferedBy.setWidth("180px"); tfReferedBy.setStyleName(ValoTheme.TEXTFIELD_TINY); tfReferedBy.setMaxLength(20); tfReferedBy.setNullRepresentation(""); tfWarrantyLimit.setWidth("180px"); tfWarrantyLimit.setStyleName(ValoTheme.TEXTFIELD_TINY); tfWarrantyLimit.setMaxLength(5); tfWarrantyLimit.setNullRepresentation(""); nsWarranty.setWidth("120px"); nsWarranty.setStyleName(ValoTheme.TEXTFIELD_TINY); nsWarranty.addItems("YES", "NO"); nsWarranty.setValue("NO"); nsWarranty.setStyleName(ValoTheme.COMBOBOX_TINY); nsSMS.setWidth("120px"); nsSMS.setStyleName(ValoTheme.TEXTFIELD_TINY); nsSMS.addItems("YES", "NO"); nsSMS.setValue("NO"); nsComeback.setWidth("120px"); nsComeback.setStyleName(ValoTheme.TEXTFIELD_TINY); nsComeback.addItems("YES", "NO"); nsComeback.setValue("NO"); nsComeback.setStyleName(ValoTheme.COMBOBOX_TINY); formLayout1.addComponents(tfTag, tfPhone, tfName, tfVehicle, tfPayment, tfRebuilder, tfInstaller, tfLicensePlate, tfVin, tfReferedBy, tfWarrantyLimit); formLayout2.addComponents(nsWarranty, dfInShop, dfOutShop, nsStatus, nsSMS, nsComeback, tfMileage, tfPicked, dfFirstCheckDate, dfSecondCheckDate); formLayout3.addComponents(tfFirstCheckBy, tfSecondCheckBy, taRemarks, taMedia, taMedia2); HorizontalLayout layoutButtons = new HorizontalLayout(); layoutButtons.setMargin(new MarginInfo(false, true, false, true)); sendBtn.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { Integer tag = null; Integer mileage = null; if (tfTag.getValue() != null) if (!tfTag.getValue().isEmpty()) { tag = (Integer.parseInt(tfTag.getValue())); } else tag = null; if (tfMileage.getValue() != null) if (!tfMileage.getValue().isEmpty()) { mileage = (Integer.parseInt(tfMileage.getValue())); } else mileage = null; Object[] args = new Object[] { tag, tfPhone.getValue(), tfName.getValue(), tfVehicle.getValue(), tfLicensePlate.getValue(), tfVin.getValue(), dfInShop.getValue(), dfOutShop.getValue(), nsStatus.getValue(), mileage, tfPicked.getValue(), tfPayment.getValue(), taRemarks.getValue(), tfRebuilder.getValue(), tfInstaller.getValue(), tfFirstCheckBy.getValue(), tfSecondCheckBy.getValue(), dfFirstCheckDate.getValue(), dfSecondCheckDate.getValue(), taMedia.getValue(), taMedia2.getValue(), tfReferedBy.getValue(), tfWarrantyLimit.getValue(), nsWarranty.getValue(), nsSMS.getValue(), nsComeback.getValue() }; if (sendBtn.getCaption().equals("Add")) { try { String status = nsStatus.getValue().toString(); searchService.insertCar(args, status); Notification.show("Entry inserted succesfully"); close(); } catch (Exception e) { e.printStackTrace(); Notification.show("An error has occurred", Notification.Type.ERROR_MESSAGE); } } else { try { searchService.editCar(args, tableName, no); Notification.show("Entry edited succesfully"); close(); } catch (Exception e) { e.printStackTrace(); Notification.show("An error has occurred", Notification.Type.ERROR_MESSAGE); } } } }); sendBtn.setImmediate(true); sendBtn.setStyleName(ValoTheme.BUTTON_TINY); sendBtn.addStyleName(ValoTheme.BUTTON_FRIENDLY); layoutButtons.setSizeUndefined(); layoutButtons.setSpacing(true); layoutButtons.addComponents(sendBtn); hLayoutForms.addComponents(formLayout1, formLayout2, formLayout3); mainLayout.addComponent(hLayoutForms); mainLayout.addComponent(layoutButtons); mainLayout.setComponentAlignment(hLayoutForms, Alignment.MIDDLE_CENTER); mainLayout.setComponentAlignment(layoutButtons, Alignment.MIDDLE_LEFT); mainLayout.setExpandRatio(hLayoutForms, 3); }
From source file:fi.semantum.strategia.Main.java
License:Open Source License
@Override protected void init(VaadinRequest request) { getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() { public void uriFragmentChanged(UriFragmentChangedEvent source) { applyFragment(source.getUriFragment(), true); }/*from w w w.j a va 2 s .com*/ }); String pathInfo = request.getPathInfo(); if (pathInfo.startsWith("/")) pathInfo = pathInfo.substring(1); if (pathInfo.endsWith("/")) pathInfo = pathInfo.substring(0, pathInfo.length() - 1); String databaseId = validatePathInfo(pathInfo); setWindowWidth(Page.getCurrent().getBrowserWindowWidth(), Page.getCurrent().getBrowserWindowHeight()); // Find the application directory String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath(); // Image as a file resource redResource = new FileResource(new File(basepath + "/WEB-INF/images/bullet_red.png")); greenResource = new FileResource(new File(basepath + "/WEB-INF/images/bullet_green.png")); blackResource = new FileResource(new File(basepath + "/WEB-INF/images/bullet_black.png")); mapMagnify = new FileResource(new File(basepath + "/WEB-INF/images/map_magnify.png")); abs = new AbsoluteLayout(); final VerticalLayout vs = new VerticalLayout(); vs.setSizeFull(); abs.addComponent(vs); setContent(abs); // This will set the login cookie Wiki.login(this); // Make sure that the printing directory exists new File(Main.baseDirectory(), "printing").mkdirs(); database = Database.load(this, databaseId); database.getOrCreateTag("Tavoite"); database.getOrCreateTag("Painopiste"); for (Strategiakartta map : Strategiakartta.enumerate(database)) { Strategiakartta parent = map.getPossibleParent(database); if (parent == null) uiState.setCurrentMap(parent); } if (uiState.getCurrentMap() == null) uiState.setCurrentMap(database.getRoot()); uiState.currentPosition = uiState.getCurrentMap(); uiState.currentItem = uiState.getCurrentMap(); setPollInterval(10000); addPollListener(new PollListener() { @Override public void poll(PollEvent event) { if (database.checkChanges()) { String curr = uiState.getCurrentMap().uuid; database = Database.load(Main.this, database.getDatabaseId()); uiState.setCurrentMap((Strategiakartta) database.find(curr)); Updates.updateJS(Main.this, false); } } }); js.addListener(new MapListener(this, false)); js2.addListener(new MapListener(this, true)); browser_.addListener(new BrowserListener() { @Override public void select(double x, double y, String uuid) { Base b = database.find(uuid); Actions.selectAction(Main.this, x, y, null, b); } @Override public void save(String name, Map<String, BrowserNodeState> states) { UIState state = getUIState().duplicate(name); state.browserStates = states; account.uiStates.add(state); Updates.update(Main.this, true); } }); Page.getCurrent().addBrowserWindowResizeListener(new BrowserWindowResizeListener() { @Override public void browserWindowResized(BrowserWindowResizeEvent event) { setWindowWidth(event.getWidth(), event.getHeight()); Updates.updateJS(Main.this, false); } }); modeLabel = new Label("Katselutila"); modeLabel.setWidth("95px"); modeLabel.addStyleName("viewMode"); mode = new Button(); mode.setDescription("Siirry tiedon sytttilaan"); mode.setIcon(FontAwesome.EYE); mode.addStyleName(ValoTheme.BUTTON_TINY); mode.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if ("Siirry tiedon sytttilaan".equals(mode.getDescription())) { mode.setDescription("Siirry katselutilaan"); mode.setIcon(FontAwesome.PENCIL); modeLabel.setValue("Sytttila"); modeLabel.removeStyleName("viewMode"); modeLabel.addStyleName("editMode"); UIState s = uiState.duplicate(Main.this); s.input = true; setFragment(s, true); } else { mode.setDescription("Siirry tiedon sytttilaan"); mode.setIcon(FontAwesome.EYE); modeLabel.setValue("Katselutila"); modeLabel.removeStyleName("editMode"); modeLabel.addStyleName("viewMode"); UIState s = uiState.duplicate(Main.this); s.input = false; setFragment(s, true); } } }); meterMode = new Button(); meterMode.setDescription("Vaihda toteumamittareihin"); meterMode.setCaption("Ennuste"); meterMode.addStyleName(ValoTheme.BUTTON_TINY); meterMode.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if ("Vaihda toteumamittareihin".equals(meterMode.getDescription())) { meterMode.setDescription("Vaihda ennustemittareihin"); meterMode.setCaption("Toteuma"); UIState s = uiState.duplicate(Main.this); s.setActualMeters(); setFragment(s, true); } else { meterMode.setDescription("Vaihda toteumamittareihin"); meterMode.setCaption("Ennuste"); UIState s = uiState.duplicate(Main.this); s.setForecastMeters(); setFragment(s, true); } } }); pdf = new PDFButton(); pdf.setDescription("Tallenna kartta PDF-muodossa"); pdf.setIcon(FontAwesome.PRINT); pdf.addStyleName(ValoTheme.BUTTON_TINY); pdf.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { Utils.print(Main.this); } }); propertyExcelButton = new Button(); propertyExcelButton.setDescription("Tallenna tiedot Excel-tiedostona"); propertyExcelButton.setIcon(FontAwesome.PRINT); propertyExcelButton.addStyleName(ValoTheme.BUTTON_TINY); OnDemandFileDownloader dl = new OnDemandFileDownloader(new OnDemandStreamSource() { private static final long serialVersionUID = 981769438054780731L; File f; Date date = new Date(); @Override public InputStream getStream() { String uuid = UUID.randomUUID().toString(); File printing = new File(Main.baseDirectory(), "printing"); f = new File(printing, uuid + ".xlsx"); Workbook w = new XSSFWorkbook(); Sheet sheet = w.createSheet("Sheet1"); int row = 1; for (List<String> cells : propertyCells) { Row r = sheet.createRow(row++); for (int i = 0; i < cells.size(); i++) { String value = cells.get(i); r.createCell(i).setCellValue(value); } } try { FileOutputStream s = new FileOutputStream(f); w.write(s); s.close(); } catch (Exception e) { e.printStackTrace(); } try { return new FileInputStream(f); } catch (FileNotFoundException e) { e.printStackTrace(); } throw new IllegalStateException(); } @Override public void onRequest() { } @Override public long getFileSize() { return f.length(); } @Override public String getFileName() { return "Strategiakartta_" + Utils.dateString(date) + ".xlsx"; } }); dl.getResource().setCacheTime(0); dl.extend(propertyExcelButton); states = new ComboBox(); states.setWidth("250px"); states.addStyleName(ValoTheme.COMBOBOX_TINY); states.setInvalidAllowed(false); states.setNullSelectionAllowed(false); states.addValueChangeListener(statesListener); saveState = new Button(); saveState.setEnabled(false); saveState.setDescription("Tallenna nykyinen nkym"); saveState.setIcon(FontAwesome.BOOKMARK); saveState.addStyleName(ValoTheme.BUTTON_TINY); saveState.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { Utils.saveCurrentState(Main.this); } }); class SearchTextField extends TextField { public boolean hasFocus = false; } final SearchTextField search = new SearchTextField(); search.setWidth("100%"); search.addStyleName(ValoTheme.TEXTFIELD_TINY); search.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS); search.setInputPrompt("hae vapaasanahaulla valitun asian alta"); search.setId("searchTextField"); search.addShortcutListener(new ShortcutListener("Shortcut Name", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { if (!search.hasFocus) return; String text = search.getValue().toLowerCase(); try { Map<String, String> content = new HashMap<String, String>(); List<String> hits = Lucene.search(database.getDatabaseId(), text + "*"); for (String uuid : hits) { Base b = database.find(uuid); if (b != null) { String report = ""; Map<String, String> map = b.searchMap(database); for (Map.Entry<String, String> e : map.entrySet()) { if (e.getValue().contains(text)) { if (!report.isEmpty()) report += ", "; report += e.getKey(); } } if (!report.isEmpty()) content.put(uuid, report); } } uiState.setCurrentFilter(new SearchFilter(Main.this, content)); Updates.updateJS(Main.this, false); switchToBrowser(); } catch (IOException e) { e.printStackTrace(); } } }); search.addFocusListener(new FocusListener() { @Override public void focus(FocusEvent event) { search.hasFocus = true; } }); search.addBlurListener(new BlurListener() { @Override public void blur(BlurEvent event) { search.hasFocus = false; } }); hallinnoi = new Button("Hallinnoi"); hallinnoi.setWidthUndefined(); hallinnoi.setVisible(false); hallinnoi.addStyleName(ValoTheme.BUTTON_TINY); hallinnoi.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (account != null) { if (account.isAdmin()) { Utils.manage(Main.this); } } } }); tili = new Button("Kyttjtili"); tili.setWidthUndefined(); tili.setVisible(false); tili.addStyleName(ValoTheme.BUTTON_TINY); tili.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (account != null) { Utils.modifyAccount(Main.this); } } }); duplicate = new Button("Avaa ikkunassa"); duplicate2 = new Button("Avaa alas"); duplicate.setWidthUndefined(); duplicate.addStyleName(ValoTheme.BUTTON_TINY); duplicate.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { MapVis model = js2.getModel(); if (model == null) { UIState s = uiState.duplicate(Main.this); s.reference = s.current; mapDialog = new Window(s.reference.getText(database), new VerticalLayout()); mapDialog.setWidth(dialogWidth()); mapDialog.setHeight(dialogHeight()); mapDialog.setResizable(true); mapDialog.setContent(js2Container); mapDialog.setVisible(true); mapDialog.setResizeLazy(false); mapDialog.addCloseListener(new CloseListener() { @Override public void windowClose(CloseEvent e) { duplicate.setCaption("Avaa ikkunassa"); duplicate2.setVisible(true); UIState s = uiState.duplicate(Main.this); mapDialog.close(); mapDialog = null; s.reference = null; setFragment(s, true); } }); mapDialog.addResizeListener(new ResizeListener() { @Override public void windowResized(ResizeEvent e) { Updates.updateJS(Main.this, false); } }); setFragment(s, true); addWindow(mapDialog); duplicate.setCaption("Sulje referenssi"); duplicate2.setVisible(false); } else { UIState s = uiState.duplicate(Main.this); if (mapDialog != null) { mapDialog.close(); mapDialog = null; } panelLayout.removeComponent(js2Container); s.reference = null; setFragment(s, true); duplicate.setCaption("Avaa ikkunassa"); duplicate2.setVisible(true); } } }); duplicate2.setWidthUndefined(); duplicate2.addStyleName(ValoTheme.BUTTON_TINY); duplicate2.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { MapVis model = js2.getModel(); assert (model == null); UIState s = uiState.duplicate(Main.this); s.reference = s.current; setFragment(s, true); panelLayout.addComponent(js2Container); duplicate.setCaption("Sulje referenssi"); duplicate2.setVisible(false); } }); login = new Button("Kirjaudu"); login.setWidthUndefined(); login.addStyleName(ValoTheme.BUTTON_TINY); login.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (account != null) { account = null; hallinnoi.setVisible(false); tili.setVisible(false); Updates.update(Main.this, true); login.setCaption("Kirjaudu"); } else { Login.login(Main.this); } } }); times = new ComboBox(); times.setWidth("130px"); times.addStyleName(ValoTheme.COMBOBOX_SMALL); times.addItem(Property.AIKAVALI_KAIKKI); times.addItem("2016"); times.addItem("2017"); times.addItem("2018"); times.addItem("2019"); times.select("2016"); times.setInvalidAllowed(false); times.setNullSelectionAllowed(false); times.addValueChangeListener(timesListener); final HorizontalLayout hl0 = new HorizontalLayout(); hl0.setWidth("100%"); hl0.setHeight("32px"); hl0.setSpacing(true); hl0.addComponent(pdf); hl0.setComponentAlignment(pdf, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(pdf, 0.0f); hl0.addComponent(propertyExcelButton); hl0.setComponentAlignment(propertyExcelButton, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(propertyExcelButton, 0.0f); hl0.addComponent(states); hl0.setComponentAlignment(states, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(states, 0.0f); hl0.addComponent(saveState); hl0.setComponentAlignment(saveState, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(saveState, 0.0f); hl0.addComponent(times); hl0.setComponentAlignment(times, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(times, 0.0f); hl0.addComponent(search); hl0.setComponentAlignment(search, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(search, 1.0f); hl0.addComponent(modeLabel); hl0.setComponentAlignment(modeLabel, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(modeLabel, 0.0f); hl0.addComponent(mode); hl0.setComponentAlignment(mode, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(mode, 0.0f); hl0.addComponent(meterMode); hl0.setComponentAlignment(meterMode, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(meterMode, 0.0f); hl0.addComponent(hallinnoi); hl0.setComponentAlignment(hallinnoi, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(hallinnoi, 0.0f); hl0.addComponent(tili); hl0.setComponentAlignment(tili, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(tili, 0.0f); hl0.addComponent(duplicate); hl0.setComponentAlignment(duplicate, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(duplicate, 0.0f); hl0.addComponent(duplicate2); hl0.setComponentAlignment(duplicate2, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(duplicate2, 0.0f); hl0.addComponent(login); hl0.setComponentAlignment(login, Alignment.MIDDLE_LEFT); hl0.setExpandRatio(login, 0.0f); propertiesPanel = new Panel(); propertiesPanel.setSizeFull(); properties = new VerticalLayout(); properties.setSpacing(true); properties.setMargin(true); propertiesPanel.setContent(properties); propertiesPanel.setVisible(false); tags = new VerticalLayout(); tags.setSpacing(true); Updates.updateTags(this); AbsoluteLayout tabs = new AbsoluteLayout(); tabs.setSizeFull(); { panel = new Panel(); panel.addStyleName(ValoTheme.PANEL_BORDERLESS); panel.setSizeFull(); panel.setId("mapContainer1"); panelLayout = new VerticalLayout(); panelLayout.addComponent(js); panelLayout.setHeight("100%"); js2Container = new VerticalLayout(); js2Container.setHeight("100%"); js2Container.addComponent(new Label("<hr />", ContentMode.HTML)); js2Container.addComponent(js2); panel.setContent(panelLayout); tabs.addComponent(panel); } wiki = new BrowserFrame(); wiki.setSource(new ExternalResource(Wiki.wikiAddress() + "/")); wiki.setWidth("100%"); wiki.setHeight("100%"); { wiki_ = new VerticalLayout(); wiki_.setSizeFull(); Button b = new Button("Palaa sovellukseen"); b.setWidth("100%"); b.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { applyFragment(backFragment, true); String content = Wiki.get(wikiPage); if (content == null) return; int first = content.indexOf("<rev contentformat"); if (first == -1) return; content = content.substring(first); int term = content.indexOf(">"); content = content.substring(term + 1); int end = content.indexOf("</rev>"); content = content.substring(0, end); if (wikiBase.modifyMarkup(Main.this, content)) { Updates.update(Main.this, true); } } }); wiki_.addComponent(b); wiki_.addComponent(wiki); wiki_.setVisible(false); wiki_.setExpandRatio(b, 0.0f); wiki_.setExpandRatio(wiki, 1.0f); tabs.addComponent(wiki_); } hs = new HorizontalSplitPanel(); hs.setSplitPosition(0, Unit.PIXELS); hs.setHeight("100%"); hs.setWidth("100%"); browser = new VerticalLayout(); browser.setSizeFull(); HorizontalLayout browserWidgets = new HorizontalLayout(); browserWidgets.setWidth("100%"); hori = new Button(); hori.setDescription("Nyt asiat taulukkona"); hori.setEnabled(true); hori.setIcon(FontAwesome.ARROW_RIGHT); hori.addStyleName(ValoTheme.BUTTON_TINY); hori.addClickListener(new ClickListener() { boolean right = false; @Override public void buttonClick(ClickEvent event) { if (right) { hs.setSplitPosition(0, Unit.PIXELS); hori.setIcon(FontAwesome.ARROW_RIGHT); hori.setDescription("Nyt asiat taulukkona"); right = false; } else { hs.setSplitPosition(windowWidth / 2, Unit.PIXELS); hori.setIcon(FontAwesome.ARROW_LEFT); hori.setDescription("Piilota taulukko"); right = true; } } }); more = new Button(); more.setDescription("Laajenna nytettvien asioiden joukkoa"); more.setIcon(FontAwesome.PLUS_SQUARE); more.addStyleName(ValoTheme.BUTTON_TINY); more.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { uiState.level++; Updates.updateJS(Main.this, false); if (uiState.level >= 2) less.setEnabled(true); } }); less = new Button(); less.setDescription("Supista nytettvien asioiden joukkoa"); less.setIcon(FontAwesome.MINUS_SQUARE); less.addStyleName(ValoTheme.BUTTON_TINY); less.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (uiState.level > 1) { uiState.level--; Updates.updateJS(Main.this, false); } if (uiState.level <= 1) less.setEnabled(false); } }); reportAllButton = new Button(); reportAllButton.setCaption("Nkyvt tulokset"); reportAllButton.addStyleName(ValoTheme.BUTTON_TINY); reportAllButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (uiState.reportAll) { reportAllButton.setCaption("Nkyvt tulokset"); uiState.reportAll = false; } else { reportAllButton.setCaption("Kaikki tulokset"); uiState.reportAll = true; } Updates.updateJS(Main.this, false); } }); reportStatus = new Label("0 tulosta."); reportStatus.setWidth("100px"); filter = new ComboBox(); filter.setWidth("100%"); filter.addStyleName(ValoTheme.COMBOBOX_SMALL); filter.setInvalidAllowed(false); filter.setNullSelectionAllowed(false); filter.addValueChangeListener(filterListener); browserWidgets.addComponent(hori); browserWidgets.setComponentAlignment(hori, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(hori, 0.0f); browserWidgets.addComponent(more); browserWidgets.setComponentAlignment(more, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(more, 0.0f); browserWidgets.addComponent(less); browserWidgets.setComponentAlignment(less, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(less, 0.0f); browserWidgets.addComponent(reportAllButton); browserWidgets.setComponentAlignment(reportAllButton, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(reportAllButton, 0.0f); browserWidgets.addComponent(reportStatus); browserWidgets.setComponentAlignment(reportStatus, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(reportStatus, 0.0f); browserWidgets.addComponent(filter); browserWidgets.setComponentAlignment(filter, Alignment.MIDDLE_LEFT); browserWidgets.setExpandRatio(filter, 1.0f); browser.addComponent(browserWidgets); browser.addComponent(hs); browser.setExpandRatio(browserWidgets, 0.0f); browser.setExpandRatio(hs, 1.0f); browser.setVisible(false); tabs.addComponent(browser); { gridPanelLayout = new VerticalLayout(); gridPanelLayout.setMargin(false); gridPanelLayout.setSpacing(false); gridPanelLayout.setSizeFull(); hs.addComponent(gridPanelLayout); } CssLayout browserLayout = new CssLayout(); browserLayout.setSizeFull(); browserLayout.addComponent(browser_); hs.addComponent(browserLayout); tabs.addComponent(propertiesPanel); vs.addComponent(hl0); vs.addComponent(tabs); vs.setExpandRatio(hl0, 0.0f); vs.setExpandRatio(tabs, 1.0f); // Ground state fragments.put("", uiState); setCurrentItem(uiState.currentItem, (Strategiakartta) uiState.currentItem); }
From source file:fi.semantum.strategia.widget.EnumerationDatatype.java
License:Open Source License
@Override public AbstractField<?> getEditor(final Main main, final Base base, final Indicator indicator, final boolean forecast, final CommentCallback callback) { final Object value = forecast ? indicator.getForecast() : indicator.getValue(); final ComboBox combo = new ComboBox(); for (String s : enumeration) { combo.addItem(s);//from w w w . ja va2 s.c o m } combo.setStyleName(ValoTheme.COMBOBOX_TINY); combo.select(value); combo.setNullSelectionAllowed(false); combo.setWidth("100%"); if (main.canWrite(base)) { combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 3547126051252580446L; @Override public void valueChange(ValueChangeEvent event) { indicator.updateWithComment(main, base, combo.getValue(), forecast, new AbstractCommentCallback() { @Override public void canceled() { combo.select(value); if (callback != null) callback.canceled(); } @Override public void runWithComment(String shortComment, String comment) { if (callback != null) callback.runWithComment(shortComment, comment); } }); } }); } else { combo.setReadOnly(true); } return combo; }
From source file:fi.semantum.strategia.widget.Indicator.java
License:Open Source License
public static void manageIndicators(final Main main, final Base base) { String currentTime = main.getUIState().time; boolean showYears = currentTime.equals(Property.AIKAVALI_KAIKKI); final Database database = main.getDatabase(); VerticalLayout content = new VerticalLayout(); content.setSizeFull();/* w w w. j a v a 2s . co m*/ content.setSpacing(true); final Table table = new Table(); table.setSelectable(true); table.setMultiSelect(true); table.addStyleName(ValoTheme.TABLE_SMALL); table.addStyleName(ValoTheme.TABLE_COMPACT); table.addContainerProperty("Indikaattori", Label.class, null); if (showYears) table.addContainerProperty("Vuosi", String.class, null); table.setWidth("100%"); table.setHeight("100%"); table.setNullSelectionAllowed(true); table.setEditable(false); table.setColumnExpandRatio("Indikaattori", 2.0f); if (showYears) table.setColumnExpandRatio("Vuosi", 0.0f); makeIndicatorTable(main, base, table); content.addComponent(table); content.setExpandRatio(table, 1.0f); abstract class IndicatorButtonListener implements Button.ClickListener { private static final long serialVersionUID = -7551250112503063540L; protected Indicator getPossibleSelection() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (selected.size() != 1) return null; return (Indicator) selected.iterator().next(); } @SuppressWarnings("unchecked") protected Collection<Indicator> getSelection() { return (Collection<Indicator>) table.getValue(); } protected Map<Base, List<Indicator>> getSelectionByParent(Database database) { return indicatorsByParent(database, getSelection()); } } final Button removeIndicators = new Button("Poista", new IndicatorButtonListener() { private static final long serialVersionUID = -2538054127519468282L; public void buttonClick(ClickEvent event) { Collection<Indicator> selection = getSelection(); for (Indicator i : selection) { Base owner = i.getOwner(database); if (owner == null) continue; owner.removeIndicator(i); } final Set<Base> bases = new HashSet<Base>(); final Strategiakartta map = database.getMap(base); bases.add(map); for (Tavoite t : map.tavoitteet) { bases.add(t); for (Painopiste p : t.painopisteet) { bases.add(p); } } for (Base b : bases) { for (Meter meter : b.getMeters(database)) { Indicator indicator = meter.getPossibleIndicator(database); if (selection.contains(indicator)) { b.removeMeter(meter); } } } makeIndicatorTable(main, base, table); Updates.update(main, true); } }); removeIndicators.addStyleName(ValoTheme.BUTTON_TINY); final Button moveUp = new Button("Siirr ylemms", new IndicatorButtonListener() { private static final long serialVersionUID = -635232943884881464L; public void buttonClick(ClickEvent event) { for (Map.Entry<Base, List<Indicator>> entry : getSelectionByParent(database).entrySet()) { entry.getKey().moveIndicatorsUp(entry.getValue()); } makeIndicatorTable(main, base, table); Updates.update(main, true); } }); moveUp.addStyleName(ValoTheme.BUTTON_TINY); final Button moveDown = new Button("Siirr alemmas", new IndicatorButtonListener() { private static final long serialVersionUID = 2779521990166604444L; public void buttonClick(ClickEvent event) { for (Map.Entry<Base, List<Indicator>> entry : getSelectionByParent(database).entrySet()) { entry.getKey().moveIndicatorsDown(entry.getValue()); } makeIndicatorTable(main, base, table); Updates.update(main, true); } }); moveDown.addStyleName(ValoTheme.BUTTON_TINY); final Button modify = new Button("Mrit"); modify.addClickListener(new IndicatorButtonListener() { private static final long serialVersionUID = 5149432436059288486L; public void buttonClick(ClickEvent event) { Indicator indicator = getPossibleSelection(); if (indicator == null) return; editIndicator(main, base, indicator); } }); modify.addStyleName(ValoTheme.BUTTON_TINY); final TextField indicatorText = new TextField(); indicatorText.setWidth("100%"); indicatorText.addStyleName(ValoTheme.TEXTFIELD_TINY); indicatorText.setCaption("Tunniste"); List<Datatype> types = Datatype.enumerate(database); final ComboBox datatypeSelect = new ComboBox(); datatypeSelect.setWidth("100%"); datatypeSelect.setNullSelectionAllowed(false); datatypeSelect.addStyleName(ValoTheme.COMBOBOX_TINY); datatypeSelect.setCaption("Tietotyyppi"); for (Datatype dt : types) datatypeSelect.addItem(dt); final Button addIndicator = new Button("Lis ptasolle", new Button.ClickListener() { private static final long serialVersionUID = -2395147866745115337L; public void buttonClick(ClickEvent event) { String text = indicatorText.getValue(); Object dt = datatypeSelect.getValue(); if (text.isEmpty() || dt == null || dt.equals(datatypeSelect.getNullSelectionItemId())) return; base.addIndicator(Indicator.create(database, text, (Datatype) dt)); makeIndicatorTable(main, base, table); Updates.update(main, true); } }); addIndicator.addStyleName(ValoTheme.BUTTON_TINY); final Button addSubIndicator = new Button("Lis valitun alle", new IndicatorButtonListener() { private static final long serialVersionUID = -2395147866745115337L; public void buttonClick(ClickEvent event) { Indicator indicator = getPossibleSelection(); if (indicator == null) return; String text = indicatorText.getValue(); Object dt = datatypeSelect.getValue(); if (text.isEmpty() || dt == null || dt.equals(datatypeSelect.getNullSelectionItemId())) return; indicator.addIndicator(Indicator.create(database, text, (Datatype) dt)); makeIndicatorTable(main, base, table); Updates.update(main, true); } }); addSubIndicator.addStyleName(ValoTheme.BUTTON_TINY); final Runnable setStates = new Runnable() { @Override public void run() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (!selected.isEmpty()) { removeIndicators.setEnabled(true); moveUp.setEnabled(true); moveDown.setEnabled(true); if (selected.size() == 1) { modify.setEnabled(true); addSubIndicator.setEnabled(true); } else { addSubIndicator.setEnabled(false); modify.setEnabled(false); } } else { moveUp.setEnabled(false); moveDown.setEnabled(false); removeIndicators.setEnabled(false); addSubIndicator.setEnabled(false); modify.setEnabled(false); } } }; table.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1188285609779556446L; @Override public void valueChange(ValueChangeEvent event) { setStates.run(); } }); setStates.run(); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.setWidthUndefined(); hl2.addComponent(modify); hl2.setComponentAlignment(modify, Alignment.BOTTOM_LEFT); hl2.setExpandRatio(modify, 0.0f); hl2.addComponent(removeIndicators); hl2.setComponentAlignment(removeIndicators, Alignment.BOTTOM_LEFT); hl2.setExpandRatio(removeIndicators, 0.0f); hl2.addComponent(moveUp); hl2.setComponentAlignment(moveUp, Alignment.TOP_LEFT); hl2.setExpandRatio(moveUp, 0.0f); hl2.addComponent(moveDown); hl2.setComponentAlignment(moveDown, Alignment.TOP_LEFT); hl2.setExpandRatio(moveDown, 0.0f); HorizontalLayout hl3 = new HorizontalLayout(); hl3.setSpacing(true); hl3.setWidth("100%"); hl3.addComponent(addIndicator); hl3.setComponentAlignment(addIndicator, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addIndicator, 0.0f); hl3.addComponent(addSubIndicator); hl3.setComponentAlignment(addSubIndicator, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addSubIndicator, 0.0f); hl3.addComponent(indicatorText); hl3.setComponentAlignment(indicatorText, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(indicatorText, 1.0f); hl3.addComponent(datatypeSelect); hl3.setComponentAlignment(datatypeSelect, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(datatypeSelect, 2.0f); content.addComponent(hl2); content.setComponentAlignment(hl2, Alignment.BOTTOM_LEFT); content.setExpandRatio(hl2, 0.0f); content.addComponent(hl3); content.setComponentAlignment(hl3, Alignment.BOTTOM_LEFT); content.setExpandRatio(hl3, 0.0f); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(false); final Window dialog = Dialogs.makeDialog(main, "650px", "800px", "Hallitse indikaattoreita", "Sulje", content, buttons); }
From source file:fi.semantum.strategia.widget.Meter.java
License:Open Source License
public static void manageMeters(final Main main, final Base base) { String currentTime = main.getUIState().time; boolean showYears = currentTime.equals(Property.AIKAVALI_KAIKKI); final Database database = main.getDatabase(); VerticalLayout content = new VerticalLayout(); content.setSizeFull();/* ww w . j ava 2 s .c om*/ content.setSpacing(true); final Table table = new Table(); table.setSelectable(true); table.setMultiSelect(true); table.addStyleName(ValoTheme.TABLE_SMALL); table.addStyleName(ValoTheme.TABLE_COMPACT); table.addContainerProperty("Mittari", Label.class, null); if (showYears) table.addContainerProperty("Vuosi", String.class, null); table.setWidth("100%"); table.setHeight("100%"); table.setNullSelectionAllowed(true); table.setEditable(false); table.setColumnExpandRatio("Mittari", 2.0f); if (showYears) table.setColumnExpandRatio("Vuosi", 0.0f); makeMeterTable(main, base, table); content.addComponent(table); content.setExpandRatio(table, 1.0f); abstract class MeterButtonListener implements Button.ClickListener { private static final long serialVersionUID = -6640950006518632633L; protected Meter getPossibleSelection() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (selected.size() != 1) return null; return (Meter) selected.iterator().next(); } @SuppressWarnings("unchecked") protected Collection<Meter> getSelection() { return (Collection<Meter>) table.getValue(); } protected Map<Base, List<Meter>> getSelectionByParent(Database database) { return metersByParent(database, getSelection()); } } final Button removeMeters = new Button("Poista", new MeterButtonListener() { private static final long serialVersionUID = 2957964892664902859L; public void buttonClick(ClickEvent event) { for (Meter r : getSelection()) { Base owner = r.getOwner(database); if (owner != null) owner.removeMeter(r); } makeMeterTable(main, base, table); Updates.update(main, true); } }); removeMeters.addStyleName(ValoTheme.BUTTON_TINY); final Button moveUp = new Button("Siirr ylemms", new MeterButtonListener() { private static final long serialVersionUID = 8434251773337788784L; public void buttonClick(ClickEvent event) { Map<Base, List<Meter>> sel = getSelectionByParent(database); if (sel == null) return; for (Map.Entry<Base, List<Meter>> entry : sel.entrySet()) { entry.getKey().moveMetersUp(entry.getValue()); } makeMeterTable(main, base, table); Updates.update(main, true); } }); moveUp.addStyleName(ValoTheme.BUTTON_TINY); final Button moveDown = new Button("Siirr alemmas", new MeterButtonListener() { private static final long serialVersionUID = -5382367112305541842L; public void buttonClick(ClickEvent event) { for (Map.Entry<Base, List<Meter>> entry : getSelectionByParent(database).entrySet()) { entry.getKey().moveMetersDown(entry.getValue()); } makeMeterTable(main, base, table); Updates.update(main, true); } }); moveDown.addStyleName(ValoTheme.BUTTON_TINY); final Button modify = new Button("Mrit"); modify.addClickListener(new MeterButtonListener() { private static final long serialVersionUID = -7109999546516429095L; public void buttonClick(ClickEvent event) { Meter meter = getPossibleSelection(); if (meter == null) return; editMeter(main, base, meter); } }); modify.addStyleName(ValoTheme.BUTTON_TINY); final ComboBox indicatorSelect = new ComboBox(); indicatorSelect.setWidth("100%"); indicatorSelect.setNullSelectionAllowed(false); indicatorSelect.addStyleName(ValoTheme.COMBOBOX_TINY); indicatorSelect.setCaption("Mrittj"); final Strategiakartta map = database.getMap(base); // Indikaattorit for (Indicator i : map.getIndicators(database)) { MeterSpec spec = new MeterSpec(database, i); indicatorSelect.addItem(spec); indicatorSelect.select(spec); } // Enumeraatiot for (Datatype enu : Datatype.enumerate(database)) { if (enu instanceof EnumerationDatatype) { MeterSpec spec = new MeterSpec(database, enu); indicatorSelect.addItem(spec); indicatorSelect.select(spec); } } // Sisnrakennetut { MeterSpec spec = new MeterSpec(database, MeterSpec.IMPLEMENTATION); indicatorSelect.addItem(spec); indicatorSelect.select(spec); } indicatorSelect.setTextInputAllowed(false); final Button addMeter = new Button("Lis ptasolle", new Button.ClickListener() { private static final long serialVersionUID = -5178621686299637238L; public void buttonClick(ClickEvent event) { MeterSpec spec = (MeterSpec) indicatorSelect.getValue(); Object source = spec.getSource(); if (source instanceof Indicator) { Indicator ind = (Indicator) source; Meter.addIndicatorMeter(main, base, ind, Property.AIKAVALI_KAIKKI); } else if (source instanceof EnumerationDatatype) { EnumerationDatatype dt = (EnumerationDatatype) source; Indicator ind = Indicator.create(database, "Uusi " + dt.getId(database), dt); ind.update(main, base, dt.getDefaultValue(), false, "", "Alkuarvo"); ind.update(main, base, dt.getDefaultForecast(), true, "", "Alkuarvo"); Meter.addIndicatorMeter(main, base, ind, Property.AIKAVALI_KAIKKI); } makeMeterTable(main, base, table); Updates.update(main, true); } }); addMeter.addStyleName(ValoTheme.BUTTON_TINY); final Button addSubmeter = new Button("Lis valitun alle", new MeterButtonListener() { private static final long serialVersionUID = -1250285092312682737L; public void buttonClick(ClickEvent event) { Meter meter = getPossibleSelection(); if (meter == null) return; MeterSpec spec = (MeterSpec) indicatorSelect.getValue(); Object source = spec.getSource(); if (source instanceof Indicator) { Indicator ind = (Indicator) source; Meter.addIndicatorMeter(main, meter, ind, Property.AIKAVALI_KAIKKI); } else if (source instanceof EnumerationDatatype) { EnumerationDatatype dt = (EnumerationDatatype) source; Indicator ind = Indicator.create(database, "Uusi " + dt.getId(database), dt); ind.update(main, base, dt.getDefaultValue(), false, "", "Alkuarvo"); ind.update(main, base, dt.getDefaultForecast(), true, "", "Alkuarvo"); Meter.addIndicatorMeter(main, meter, ind, Property.AIKAVALI_KAIKKI); } makeMeterTable(main, base, table); Updates.update(main, true); } }); addSubmeter.addStyleName(ValoTheme.BUTTON_TINY); final Runnable setStates = new Runnable() { @Override public void run() { Object selection = table.getValue(); Collection<?> selected = (Collection<?>) selection; if (!selected.isEmpty()) { removeMeters.setEnabled(true); moveUp.setEnabled(true); moveDown.setEnabled(true); if (selected.size() == 1) { modify.setEnabled(true); addSubmeter.setEnabled(true); } else { addSubmeter.setEnabled(false); modify.setEnabled(false); } } else { moveUp.setEnabled(false); moveDown.setEnabled(false); removeMeters.setEnabled(false); addSubmeter.setEnabled(false); modify.setEnabled(false); } } }; table.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 6439090862804667322L; @Override public void valueChange(ValueChangeEvent event) { setStates.run(); } }); setStates.run(); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); hl2.setWidthUndefined(); hl2.addComponent(modify); hl2.setComponentAlignment(modify, Alignment.TOP_LEFT); hl2.setExpandRatio(modify, 0.0f); hl2.addComponent(removeMeters); hl2.setComponentAlignment(removeMeters, Alignment.TOP_LEFT); hl2.setExpandRatio(removeMeters, 0.0f); hl2.addComponent(moveUp); hl2.setComponentAlignment(moveUp, Alignment.TOP_LEFT); hl2.setExpandRatio(moveUp, 0.0f); hl2.addComponent(moveDown); hl2.setComponentAlignment(moveDown, Alignment.TOP_LEFT); hl2.setExpandRatio(moveDown, 0.0f); HorizontalLayout hl3 = new HorizontalLayout(); hl3.setSpacing(true); hl3.setWidth("100%"); hl3.addComponent(addMeter); hl3.setComponentAlignment(addMeter, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addMeter, 0.0f); hl3.addComponent(addSubmeter); hl3.setComponentAlignment(addSubmeter, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(addSubmeter, 0.0f); hl3.addComponent(indicatorSelect); hl3.setComponentAlignment(indicatorSelect, Alignment.BOTTOM_LEFT); hl3.setExpandRatio(indicatorSelect, 1.0f); content.addComponent(hl2); content.setComponentAlignment(hl2, Alignment.MIDDLE_CENTER); content.setExpandRatio(hl2, 0.0f); content.addComponent(hl3); content.setComponentAlignment(hl3, Alignment.BOTTOM_LEFT); content.setExpandRatio(hl3, 0.0f); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.setMargin(false); final Window dialog = Dialogs.makeDialog(main, "450px", "600px", "Hallitse mittareita", "Sulje", content, buttons); }
From source file:fi.semantum.strategia.widget.NumberTrafficValuation.java
License:Open Source License
@Override public Runnable getEditor(VerticalLayout layout, final Main main, final Meter meter) { Indicator indicator = meter.getPossibleIndicator(main.getDatabase()); String unit = indicator.getUnit(); final ComboBox combo = new ComboBox("Valitse mittarin mritystapa"); combo.addItem(State.INCREASE3); combo.addItem(State.DECREASE3); combo.addItem(State.INCREASE2); combo.addItem(State.DECREASE2); combo.setInvalidAllowed(false);/*from w ww . j a v a 2 s. com*/ combo.setNullSelectionAllowed(false); combo.setWidth("100%"); combo.addStyleName(ValoTheme.COMBOBOX_TINY); layout.addComponent(combo); layout.setComponentAlignment(combo, Alignment.TOP_CENTER); layout.setExpandRatio(combo, 0.0f); final VerticalLayout vl1 = new VerticalLayout(); vl1.setHeight("50px"); vl1.setWidth("100%"); vl1.setStyleName("redBlock"); layout.addComponent(vl1); layout.setComponentAlignment(vl1, Alignment.TOP_CENTER); layout.setExpandRatio(vl1, 0.0f); final Label l1 = new Label(" > " + df.format(greenLimit.doubleValue()) + " " + unit); l1.setSizeUndefined(); l1.addStyleName(ValoTheme.LABEL_LARGE); vl1.addComponent(l1); vl1.setComponentAlignment(l1, Alignment.MIDDLE_CENTER); HorizontalLayout hl1 = new HorizontalLayout(); hl1.setSpacing(true); layout.addComponent(hl1); layout.setComponentAlignment(hl1, Alignment.TOP_LEFT); final TextField tf1 = new TextField(); tf1.setValue(df.format(greenLimit.doubleValue())); tf1.setWidth("150px"); tf1.setCaption("Suurempi raja-arvo"); tf1.setStyleName(ValoTheme.TEXTFIELD_TINY); tf1.setValidationVisible(true); hl1.addComponent(tf1); Label unit1 = new Label(); unit1.setSizeUndefined(); unit1.setCaption(""); unit1.setValue(unit); hl1.addComponent(unit1); hl1.setComponentAlignment(unit1, Alignment.MIDDLE_LEFT); final VerticalLayout vl2 = new VerticalLayout(); vl2.setHeight("50px"); vl2.setWidth("100%"); vl2.addStyleName("yellowBlock"); layout.addComponent(vl2); layout.setComponentAlignment(vl2, Alignment.TOP_CENTER); layout.setExpandRatio(vl2, 0.0f); final Label l2 = new Label(); l2.setSizeUndefined(); l2.addStyleName(ValoTheme.LABEL_LARGE); vl2.addComponent(l2); vl2.setComponentAlignment(l2, Alignment.MIDDLE_CENTER); HorizontalLayout hl2 = new HorizontalLayout(); hl2.setSpacing(true); layout.addComponent(hl2); layout.setComponentAlignment(hl2, Alignment.TOP_LEFT); final TextField tf2 = new TextField(); tf2.setWidth("150px"); tf2.setCaption("Pienempi raja-arvo"); tf2.setStyleName(ValoTheme.TEXTFIELD_TINY); tf2.setValidationVisible(true); hl2.addComponent(tf2); hl2.setComponentAlignment(tf2, Alignment.TOP_CENTER); Label unit2 = new Label(); unit2.setSizeUndefined(); unit2.setCaption(""); unit2.setValue("" + unit); hl2.addComponent(unit2); hl2.setComponentAlignment(unit2, Alignment.MIDDLE_LEFT); final VerticalLayout vl3 = new VerticalLayout(); vl3.setHeight("50px"); vl3.setWidth("100%"); vl3.addStyleName("greenBlock"); layout.addComponent(vl3); layout.setComponentAlignment(vl3, Alignment.TOP_CENTER); layout.setExpandRatio(vl3, 0.0f); final Label l3 = new Label(); l3.setSizeUndefined(); l3.addStyleName(ValoTheme.LABEL_LARGE); vl3.addComponent(l3); vl3.setComponentAlignment(l3, Alignment.MIDDLE_CENTER); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); combo.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 8396168732300003038L; @Override public void valueChange(ValueChangeEvent event) { if (inApply) return; State currentState = getState(); if (currentState.equals(combo.getValue())) return; if (State.DECREASE3.equals(combo.getValue())) { makeThree = true; if (State.INCREASE3.equals(currentState)) { swap(); } else if (State.INCREASE2.equals(currentState)) { redLimit = greenLimit; greenLimit = null; } } else if (State.INCREASE3.equals(combo.getValue())) { makeThree = true; if (State.DECREASE3.equals(currentState)) { swap(); } else if (State.DECREASE2.equals(currentState)) { greenLimit = redLimit; redLimit = null; } } else if (State.INCREASE2.equals(combo.getValue())) { if (State.DECREASE3.equals(currentState)) { greenLimit = redLimit; } else if (State.DECREASE2.equals(currentState)) { greenLimit = redLimit; } redLimit = null; makeThree = false; } else if (State.DECREASE2.equals(combo.getValue())) { if (State.INCREASE3.equals(currentState)) { redLimit = greenLimit; } else if (State.INCREASE2.equals(currentState)) { redLimit = greenLimit; } greenLimit = null; makeThree = false; } updateMakeThree(); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); } }); tf1.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = -5484608577999300097L; @Override public void valueChange(ValueChangeEvent event) { if (inApply) return; if (State.DECREASE3.equals(combo.getValue())) { if (makeThree) greenLimit = redLimit; redLimit = new BigDecimal(tf1.getValue()); } else if (State.INCREASE3.equals(combo.getValue())) { if (makeThree) redLimit = greenLimit; greenLimit = new BigDecimal(tf1.getValue()); } else if (State.INCREASE2.equals(combo.getValue())) { greenLimit = new BigDecimal(tf1.getValue()); } else if (State.DECREASE2.equals(combo.getValue())) { redLimit = new BigDecimal(tf1.getValue()); } updateMakeThree(); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); } }); tf2.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 5825320869230527588L; @Override public void valueChange(ValueChangeEvent event) { if (inApply) return; // This should not happen! if (State.INCREASE2.equals(combo.getValue()) || State.DECREASE2.equals(combo.getValue())) return; if (State.DECREASE3.equals(combo.getValue())) { greenLimit = new BigDecimal(tf2.getValue()); } else if (State.INCREASE3.equals(combo.getValue())) { redLimit = new BigDecimal(tf2.getValue()); } updateMakeThree(); applyValues(main, meter, combo, vl1, l1, vl2, l2, vl3, l3, tf1, tf2); } }); return null; }
From source file:org.eclipse.hawkbit.ui.artifacts.smtable.SoftwareModuleAddUpdateWindow.java
License:Open Source License
private void createRequiredComponents() { nameTextField = createTextField("textfield.name", UIComponentIdProvider.SOFT_MODULE_NAME, SoftwareModule.NAME_MAX_SIZE); versionTextField = createTextField("textfield.version", UIComponentIdProvider.SOFT_MODULE_VERSION, SoftwareModule.VERSION_MAX_SIZE); vendorTextField = new TextFieldBuilder(SoftwareModule.VENDOR_MAX_SIZE) .caption(i18n.getMessage("textfield.vendor")).id(UIComponentIdProvider.SOFT_MODULE_VENDOR) .buildTextComponent();/* www. j a v a 2s . c o m*/ descTextArea = new TextAreaBuilder(SoftwareModule.DESCRIPTION_MAX_SIZE) .caption(i18n.getMessage("textfield.description")).style("text-area-style") .id(UIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION).buildTextComponent(); typeComboBox = SPUIComponentProvider.getComboBox( i18n.getMessage(UIMessageIdProvider.CAPTION_ARTIFACT_SOFTWARE_MODULE_TYPE), "", null, null, true, null, i18n.getMessage(UIMessageIdProvider.CAPTION_ARTIFACT_SOFTWARE_MODULE_TYPE)); typeComboBox.setId(UIComponentIdProvider.SW_MODULE_TYPE); typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY); typeComboBox.setNewItemsAllowed(Boolean.FALSE); typeComboBox.setImmediate(Boolean.TRUE); }
From source file:org.eclipse.hawkbit.ui.common.tagdetails.AbstractTagToken.java
License:Open Source License
private void createTokenField() { final Container tokenContainer = createContainer(); tokenField = createTokenField(tokenContainer); tokenField.setContainerDataSource(tokenContainer); tokenField.setNewTokensAllowed(false); tokenField.setFilteringMode(FilteringMode.CONTAINS); tokenField.setInputPrompt(getTokenInputPrompt()); tokenField.setTokenInsertPosition(InsertPosition.AFTER); tokenField.setImmediate(true);/*from w ww . j a v a 2s . c o m*/ tokenField.addStyleName(ValoTheme.COMBOBOX_TINY); tokenField.setSizeFull(); tokenField.setTokenCaptionPropertyId(NAME_PROPERTY); }
From source file:org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator.java
License:Open Source License
/** * Decorate.// ww w. j a v a2s . c o m * * @param caption * caption of the combobox * @param height * as H * @param width * as W * @param style * as style * @param styleName * as style name * @param required * as T|F * @param data * as data * @param prompt * as promt * @return ComboBox as comp */ public static ComboBox decorate(final String caption, final String width, final String style, final String styleName, final boolean required, final String data, final String prompt) { final ComboBox spUICombo = new ComboBox(); // Default settings spUICombo.setRequired(required); spUICombo.addStyleName(ValoTheme.COMBOBOX_TINY); if (!StringUtils.isEmpty(caption)) { spUICombo.setCaption(caption); } // Add style if (!StringUtils.isEmpty(style)) { spUICombo.setStyleName(style); } // Add style Name if (!StringUtils.isEmpty(styleName)) { spUICombo.addStyleName(styleName); } // AddWidth if (!StringUtils.isEmpty(width)) { spUICombo.setWidth(width); } // Set prompt if (!StringUtils.isEmpty(prompt)) { spUICombo.setInputPrompt(prompt); } // Set Data if (!StringUtils.isEmpty(data)) { spUICombo.setData(data); } return spUICombo; }