List of usage examples for com.vaadin.ui Alignment MIDDLE_RIGHT
Alignment MIDDLE_RIGHT
To view the source code for com.vaadin.ui Alignment MIDDLE_RIGHT.
Click Source Link
From source file:edu.nps.moves.mmowgli.modules.administration.AddCardClassDialog.java
License:Open Source License
public AddCardClassDialog(CardClass cls, String title) { super(title); this.cls = cls; VerticalLayout vl = new VerticalLayout(); setContent(vl);// w w w . jav a2s . co m vl.setSpacing(true); vl.setMargin(true); vl.setSizeUndefined(); vl.addComponent(titleTF = new TextField("Title")); titleTF.setValue("title goes here"); titleTF.setColumns(35); vl.addComponent(summTF = new TextField("Summary")); summTF.setValue("summary goes here"); summTF.setColumns(35); vl.addComponent(promptTF = new TextField("Prompt")); promptTF.setValue("prompt goes here"); promptTF.setColumns(35); vl.addComponent(colorCombo = new NativeSelect("Color")); fillCombo(); HorizontalLayout buttHL = new HorizontalLayout(); buttHL.setSpacing(true); buttHL.addComponent(cancelButt = new Button("Cancel")); cancelButt.addClickListener(new CancelListener()); buttHL.addComponent(saveButt = new Button("Save")); saveButt.addClickListener(new SaveListener()); vl.addComponent(buttHL); vl.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT); }
From source file:edu.nps.moves.mmowgli.modules.administration.AddCardTypeDialog.java
License:Open Source License
public AddCardTypeDialog(int descType, String title) { super(title); this.typ = descType; VerticalLayout vl = new VerticalLayout(); setContent(vl);/* w ww. jav a2s . co m*/ vl.setSizeUndefined(); vl.setMargin(true); vl.setSpacing(true); vl.addComponent(titleTF = new TextField("Title")); titleTF.setValue("title goes here"); titleTF.setColumns(35); vl.addComponent(summTF = new TextField("Summary")); summTF.setValue("summary goes here"); summTF.setColumns(35); vl.addComponent(promptTF = new TextField("Prompt")); promptTF.setValue("prompt goes here"); promptTF.setColumns(35); vl.addComponent(colorCombo = new NativeSelect("Color")); fillCombo(); HorizontalLayout buttHL = new HorizontalLayout(); buttHL.setSpacing(true); buttHL.addComponent(cancelButt = new Button("Cancel")); cancelButt.addClickListener(new CancelListener()); buttHL.addComponent(saveButt = new Button("Save")); saveButt.addClickListener(new SaveListener()); vl.addComponent(buttHL); vl.setComponentAlignment(buttHL, Alignment.MIDDLE_RIGHT); }
From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java
License:Open Source License
private void showAddDialogOrCancel(final DoneListener lis) { dialog = new Window("Add to VIP list"); dialog.setModal(true);// w w w . jav a 2 s.co m dialog.setWidth("400px"); dialog.setHeight("350px"); VerticalLayout layout = new VerticalLayout(); dialog.setContent(layout); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); List<String> rtypes = Arrays.asList(new String[] { EMAILTYPE, DOMAINTYPE }); radios = new OptionGroup("Select type", rtypes); radios.setNullSelectionAllowed(false); // user can not 'unselect' radios.select("Emails"); // select this by default radios.setImmediate(false); // don't send the change to the server at once layout.addComponent(radios); final TextArea ta = new TextArea(); //ta.setColumns(40); ta.setSizeFull(); ta.setInputPrompt( "Type or paste a tab-, comma- or space-separated list of emails or domains. For domains, " + "use forms such as \"army.mil\", \"nmci.navy.mil\", \"ucla.edu\", \"gov\", etc."); layout.addComponent(ta); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); @SuppressWarnings("serial") Button cancelButt = new Button("Cancel", new Button.ClickListener() { public void buttonClick(ClickEvent event) { dialog.close(); lis.continueOrCancel(null); } }); @SuppressWarnings("serial") Button addButt = new Button("Add", new Button.ClickListener() { public void buttonClick(ClickEvent event) { String[] returnArr = null; String result = ta.getValue().toString(); if (result == null || result.length() <= 0) returnArr = null; else if ((returnArr = parseIt(result)) == null) return; dialog.close(); lis.continueOrCancel(returnArr); } }); hl.addComponent(cancelButt); hl.addComponent(addButt); hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT); hl.setExpandRatio(cancelButt, 1.0f); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.addComponent(hl); hl.setWidth("100%"); ta.setWidth("100%"); ta.setHeight("100%"); layout.setExpandRatio(ta, 1.0f); UI.getCurrent().addWindow(dialog); dialog.center(); }
From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java
License:Open Source License
@SuppressWarnings({ "unchecked", "serial" }) private void showViewOrDelete(final DeleteListener lis) { dialog = new Window("View / Delete VIPs"); dialog.setModal(true);/*from ww w.ja va 2 s . co m*/ VerticalLayout layout = new VerticalLayout(); dialog.setContent(layout); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); List<VipPii> vLis = VHibPii.getAllVips(); vipListSelect = new ListSelect("Select items to delete"); StringBuffer sb = new StringBuffer(); // for popup vipListSelect.addStyleName("m-greyborder"); String lf = System.getProperty("line.separator"); for (int i = 0; i < vLis.size(); i++) { VipPii v; vipListSelect.addItem(v = vLis.get(i)); sb.append(v.getEntry()); sb.append(lf); } if (sb.length() > 0) sb.setLength(sb.length() - 1); // last space vipListSelect.setNullSelectionAllowed(true); vipListSelect.setMultiSelect(true); vipListSelect.setImmediate(true); vipListSelect.addValueChangeListener(new VipSelectListener()); layout.addComponent(vipListSelect); Label copyPopupList = new HtmlLabel("<pre>" + sb.toString() + "</pre>"); Panel p = new Panel(); VerticalLayout lay = new VerticalLayout(); p.setContent(lay); lay.addComponent(copyPopupList); p.setWidth("400px"); p.setHeight("300px"); PopupView popup = new PopupView("Display list as copyable text", p); popup.setHideOnMouseOut(false); if (sb.length() <= 0) popup.setEnabled(false); layout.addComponent(popup); layout.setComponentAlignment(popup, Alignment.MIDDLE_CENTER); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Button cancelButt = new Button("Cancel", new Button.ClickListener() { public void buttonClick(ClickEvent event) { dialog.close(); lis.continueOrCancel(null); } }); deleteButt = new Button("Delete & Close", new Button.ClickListener() { public void buttonClick(ClickEvent event) { Set<VipPii> set = (Set<VipPii>) vipListSelect.getValue(); if (set.size() <= 0) set = null; dialog.close(); lis.continueOrCancel(set); } }); deleteButt.setEnabled(false); hl.addComponent(cancelButt); hl.addComponent(deleteButt); hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT); hl.setExpandRatio(cancelButt, 1.0f); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.addComponent(hl); dialog.setWidth("300px"); dialog.setHeight("350px"); hl.setWidth("100%"); vipListSelect.setWidth("99%"); vipListSelect.setHeight("99%"); layout.setExpandRatio(vipListSelect, 1.0f); UI.getCurrent().addWindow(dialog); dialog.center(); }
From source file:edu.vcu.csbc.vahmpexplorer.main.VaHMPExplorer.java
public Component createToolBar(boolean loggedIn) { HorizontalLayout h = new HorizontalLayout(); h.setMargin(true);// w ww. j a v a 2s.com h.setWidth("100%"); Embedded headerImg = new Embedded(null, new ThemeResource("../vahmpexplorer/img/header.png")); headerImg.setWidth(311, Embedded.UNITS_PIXELS); headerImg.setHeight(45, Embedded.UNITS_PIXELS); headerImg.setType(Embedded.TYPE_IMAGE); headerImg.setStyleName(BaseTheme.BUTTON_LINK); headerImg.setDescription("Version " + HelpMessages.VERSION); h.addComponent(headerImg); if (loggedIn) { Panel panel = new Panel(); Label loggedInUser = new Label( "Welcome: " + user.getFirstName() + " " + user.getLastName() + " (" + user.getLogin() + ")"); changePassword = new Button("Change Password"); changePassword.setStyleName(BaseTheme.BUTTON_LINK); changePassword.addListener((Button.ClickListener) this); logout = new Button("Logout"); logout.setStyleName(BaseTheme.BUTTON_LINK); logout.addListener((Button.ClickListener) this); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.addComponent(changePassword); hl.addComponent(logout); panel.addComponent(loggedInUser); panel.addComponent(hl); h.addComponent(panel); h.setComponentAlignment(panel, Alignment.MIDDLE_RIGHT); } PopupView help = new PopupView(new MainHelpPopup()); h.addComponent(help); h.setComponentAlignment(help, Alignment.MIDDLE_RIGHT); h.setComponentAlignment(headerImg, Alignment.MIDDLE_LEFT); return h; }
From source file:eu.eco2clouds.portal.component.MainMenu.java
License:Apache License
public MainMenu() { this.setHeight("50px"); this.setSpacing(true); this.setMargin(true); this.setWidth("100%"); Label spaceLabel = new Label(" "); this.addComponent(spaceLabel); Button homePageBtn = new Button(""); homePageBtn.setIcon(new ThemeResource("img/homepage.png")); homePageBtn.setDescription("Home page"); homePageBtn.setStyleName(Reindeer.BUTTON_LINK); homePageBtn.addClickListener(new Button.ClickListener() { @Override//from ww w. jav a2 s . c o m public void buttonClick(ClickEvent event) { int status = ((E2CPortal) UI.getCurrent()).getSessionStatus().getStatus(); if (status != SessionStatus.HOME) { ((E2CPortal) UI.getCurrent()).getSessionStatus().setStatus(SessionStatus.HOME); ((E2CPortal) UI.getCurrent()).render(); } } }); this.addComponent(homePageBtn); Button addExperimentBtn = new Button(""); addExperimentBtn.setIcon(new ThemeResource("img/add.png")); addExperimentBtn.setDescription("Add new experiment"); addExperimentBtn.setStyleName(Reindeer.BUTTON_LINK); addExperimentBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { int status = ((E2CPortal) UI.getCurrent()).getSessionStatus().getStatus(); if (status != SessionStatus.SUBMITAP) { ((E2CPortal) UI.getCurrent()).getSessionStatus().setStatus(SessionStatus.SUBMITAP); ((E2CPortal) UI.getCurrent()).render(); } } }); this.addComponent(addExperimentBtn); Button notificationBtn = new Button("Notifications"); notificationBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { int status = ((E2CPortal) UI.getCurrent()).getSessionStatus().getStatus(); if (status != SessionStatus.NOTIFICATIONS) { ((E2CPortal) UI.getCurrent()).getSessionStatus().setStatus(SessionStatus.NOTIFICATIONS); ((E2CPortal) UI.getCurrent()).render(); } } }); //this.addComponent(notificationBtn); Button logoutBtn = new Button(""); logoutBtn.setIcon(new ThemeResource("img/logout.png")); logoutBtn.setDescription("Logout"); logoutBtn.setStyleName(Reindeer.BUTTON_LINK); logoutBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ((E2CPortal) UI.getCurrent()).getSessionStatus().setStatus(SessionStatus.UNLOGGED); ((E2CPortal) UI.getCurrent()).render(); } }); this.addComponent(logoutBtn); /*Button refreshBtn = new Button(" "); if (Configuration.refreshUIActive) { refreshBtn.setCaption("Disable autorefresh"); } else { refreshBtn.setCaption("Enable autorefresh"); } refreshBtn.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { ((E2CPortal) UI.getCurrent()).toggleRefresh(); Configuration.refreshUIActive = !Configuration.refreshUIActive; if (Configuration.refreshUIActive) { event.getButton().setCaption("Disable autorefresh"); } else { event.getButton().setCaption("Enable autorefresh"); } } }); this.addComponent(refreshBtn);*/ this.setExpandRatio(spaceLabel, 20.0f); this.setComponentAlignment(homePageBtn, Alignment.MIDDLE_RIGHT); this.setComponentAlignment(addExperimentBtn, Alignment.MIDDLE_RIGHT); //this.setComponentAlignment(notificationBtn, Alignment.MIDDLE_LEFT); this.setComponentAlignment(logoutBtn, Alignment.MIDDLE_RIGHT); //this.setComponentAlignment(refreshBtn, Alignment.MIDDLE_RIGHT); }
From source file:eu.maxschuster.vaadin.buttonlink.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { final VerticalLayout wrapper = new VerticalLayout(); wrapper.setSizeFull();//from ww w .java 2s . c o m setContent(wrapper); // Show it in the middle of the screen final VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setSizeUndefined(); wrapper.addComponent(layout); wrapper.setComponentAlignment(layout, Alignment.MIDDLE_CENTER); final Label themeName = new Label(); themeName.setCaption("Current Theme:"); themeName.addStyleName("h1"); layout.addComponent(themeName); Label waring = new Label("<strong>Attention:</strong><br />\nChanging the theme may take a few seconds!"); waring.setContentMode(ContentMode.HTML); layout.addComponent(waring); getPage().addUriFragmentChangedListener(new UriFragmentChangedListener() { @Override public void uriFragmentChanged(UriFragmentChangedEvent event) { String fragment = event.getUriFragment().replace("!", ""); if (fragment.isEmpty()) { fragment = defaultTheme; } loadTheme(fragment); } }); themeSelect.setSizeFull(); themeSelect.setNullSelectionAllowed(false); themeSelect.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String fragment = "!" + themeSelect.getValue(); getPage().setUriFragment(fragment); } }); layout.addComponent(themeSelect); layout.setComponentAlignment(themeSelect, Alignment.BOTTOM_CENTER); final CheckBox useIcon = new CheckBox("Use icons"); useIcon.setValue(false); layout.addComponent(useIcon); final HorizontalLayout comparsionLayout = new HorizontalLayout(); comparsionLayout.setSpacing(true); layout.addComponent(comparsionLayout); layout.setComponentAlignment(comparsionLayout, Alignment.TOP_CENTER); final Button button = new Button("This is a \"normal\" Button", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Notification.show("Hello World!"); } }); comparsionLayout.addComponent(button); comparsionLayout.setComponentAlignment(button, Alignment.MIDDLE_RIGHT); // Initialize our new UI component final ButtonLink buttonLink = new ButtonLink("This is a ButtonLink", new ExternalResource("https://vaadin.com")); buttonLink.setTargetName("_blank"); buttonLink.setDescription("Visit vaadin.com in a new tab or window."); buttonLink.addStyleName("test-stylename"); comparsionLayout.addComponent(buttonLink); comparsionLayout.setComponentAlignment(buttonLink, Alignment.MIDDLE_LEFT); themeName.setPropertyDataSource(themeSelect); useIcon.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { boolean b = (Boolean) event.getProperty().getValue(); if (b) { button.setIcon(vaadinIcon, "Vaadin Logo"); buttonLink.setIcon(vaadinIcon, "Vaadin Logo"); } else { button.setIcon(null); buttonLink.setIcon(null); } } }); String fragment = getPage().getUriFragment(); loadTheme( fragment == null || fragment.replace("!", "").isEmpty() ? defaultTheme : fragment.replace("!", "")); }
From source file:eu.maxschuster.vaadin.signaturefield.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { getPage().setTitle(pageTitle);/* www.jav a2s . c om*/ 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.semantum.strategia.widget.Tag.java
License:Open Source License
public static void updateRelatedTags(final Main main, boolean canWrite) { final Database database = main.getDatabase(); final Base base = main.getUIState().currentItem; Collection<Tag> tags = base.getRelatedTags(database); if (!tags.isEmpty() || canWrite) { HorizontalLayout tagHeader = new HorizontalLayout(); tagHeader.setSpacing(true);//from w ww . java2s. c om Label header2 = new Label("Aihetunnisteet"); header2.setHeight("32px"); header2.addStyleName(ValoTheme.LABEL_HUGE); header2.addStyleName(ValoTheme.LABEL_BOLD); tagHeader.addComponent(header2); tagHeader.setComponentAlignment(header2, Alignment.BOTTOM_CENTER); if (canWrite) { final Image editTags = new Image("", new ThemeResource("tag_blue_edit.png")); editTags.setHeight("24px"); editTags.setWidth("24px"); editTags.addClickListener(new MouseEvents.ClickListener() { private static final long serialVersionUID = -6140867347404571880L; @Override public void click(com.vaadin.event.MouseEvents.ClickEvent event) { Utils.loseFocus(editTags); Utils.editTags(main, "Muokkaa aihetunnisteita", main.getUIState().currentItem); } }); tagHeader.addComponent(editTags); tagHeader.setComponentAlignment(editTags, Alignment.BOTTOM_CENTER); } main.properties.addComponent(tagHeader); main.properties.setComponentAlignment(tagHeader, Alignment.MIDDLE_CENTER); HorizontalLayout divider = new HorizontalLayout(); main.properties.addComponent(divider); main.properties.setComponentAlignment(divider, Alignment.MIDDLE_CENTER); VerticalLayout left = new VerticalLayout(); left.setSpacing(true); left.setWidth("400px"); left.setMargin(true); divider.addComponent(left); VerticalLayout right = new VerticalLayout(); right.setSpacing(true); right.setWidth("400px"); right.setMargin(true); divider.addComponent(right); Set<Tag> monitoredTags = getMonitoredTags(database, base); int i = 0; for (final Tag tag : tags) { final boolean monitor = base.hasMonitorTag(database, tag); String tagId = tag.getId(database); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.setHeight("37px"); Button tagButton = Utils.tagButton(database, "list", tagId, i++); left.addComponent(tagButton); left.setComponentAlignment(tagButton, Alignment.MIDDLE_RIGHT); if (canWrite) { Button b = new Button(); b.addStyleName(ValoTheme.BUTTON_BORDERLESS); b.setIcon(FontAwesome.TIMES_CIRCLE); b.addClickListener(new ClickListener() { private static final long serialVersionUID = -4473258383318654850L; @Override public void buttonClick(ClickEvent event) { base.removeRelatedTags(database, tag); Utils.loseFocus(main.properties); Updates.update(main, true); } }); hl.addComponent(b); hl.setComponentAlignment(b, Alignment.MIDDLE_LEFT); } if (base instanceof Strategiakartta) { Button tagButton2 = new Button(); tagButton2.setCaption(monitor ? "Seurataan toteutuksessa" : "Ei seurata toteutuksessa"); tagButton2.addStyleName(monitor ? "greenButton" : "redButton"); tagButton2.addStyleName(ValoTheme.BUTTON_SMALL); tagButton2.setWidth("200px"); if (canWrite) { tagButton2.addClickListener(new ClickListener() { private static final long serialVersionUID = -1769769368034323594L; @Override public void buttonClick(ClickEvent event) { if (monitor) { base.removeMonitorTags(database, tag); } else { base.assertMonitorTags(database, tag); } Utils.loseFocus(main.properties); Updates.update(main, true); } }); tagButton2.setEnabled(true); } else { tagButton2.setEnabled(false); } hl.addComponent(tagButton2); hl.setComponentAlignment(tagButton2, Alignment.MIDDLE_LEFT); } else { if (monitoredTags.contains(tag)) { Label l = new Label(" toteuttaa seurattavaa aihetta "); hl.addComponent(l); hl.setComponentAlignment(l, Alignment.MIDDLE_LEFT); } } right.addComponent(hl); right.setComponentAlignment(hl, Alignment.MIDDLE_LEFT); } } }
From source file:fi.semantum.strategia.widget.Tag.java
License:Open Source License
public static void updateMonitoredTags(final Main main, boolean canWrite) { final Database database = main.getDatabase(); final Base base = main.getUIState().currentItem; if (!(base instanceof Tavoite || base instanceof Painopiste)) return;/*www . j a va 2 s. c o m*/ Set<Tag> monitoredTags = getMonitoredTags(database, base); monitoredTags.removeAll(base.getRelatedTags(database)); Map<String, Base> implementors = new HashMap<String, Base>(); for (Base impl : Utils.getImplementationSet(database, base)) { for (Tag i : impl.getRelatedTags(database)) { if (monitoredTags.contains(i)) { implementors.put(i.uuid, impl); } } } if (!monitoredTags.isEmpty() || canWrite) { HorizontalLayout tagHeader = new HorizontalLayout(); tagHeader.setSpacing(true); Label header2 = new Label("Seurattavat aihetunnisteet"); header2.setHeight("32px"); header2.addStyleName(ValoTheme.LABEL_HUGE); header2.addStyleName(ValoTheme.LABEL_BOLD); tagHeader.addComponent(header2); tagHeader.setComponentAlignment(header2, Alignment.BOTTOM_CENTER); main.properties.addComponent(tagHeader); main.properties.setComponentAlignment(tagHeader, Alignment.MIDDLE_CENTER); HorizontalLayout divider = new HorizontalLayout(); main.properties.addComponent(divider); main.properties.setComponentAlignment(divider, Alignment.MIDDLE_CENTER); VerticalLayout left = new VerticalLayout(); left.setSpacing(true); left.setWidth("400px"); left.setMargin(true); divider.addComponent(left); VerticalLayout right = new VerticalLayout(); right.setSpacing(true); right.setWidth("400px"); right.setMargin(true); divider.addComponent(right); int i = 0; for (final Tag tag : monitoredTags) { String tagId = tag.getId(database); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); hl.setHeight("37px"); Button tagButton = Utils.tagButton(database, "inferred", tagId, i++); left.addComponent(tagButton); left.setComponentAlignment(tagButton, Alignment.MIDDLE_RIGHT); Base implementor = implementors.get(tag.uuid); if (implementor != null) { String desc = implementor.getId(database); if (desc.isEmpty()) desc = implementor.getText(database); Label tagLabel = new Label("Toteutetaan ylemmll tasolla: " + desc); hl.addComponent(tagLabel); hl.setComponentAlignment(tagLabel, Alignment.MIDDLE_LEFT); } else { Button tagButton2 = new Button(); tagButton2.setCaption("Merkitse toteuttajaksi"); tagButton2.addStyleName("redButton"); tagButton2.addStyleName(ValoTheme.BUTTON_SMALL); tagButton2.setWidth("200px"); if (canWrite) { tagButton2.addClickListener(new ClickListener() { private static final long serialVersionUID = -1769769368034323594L; @Override public void buttonClick(ClickEvent event) { base.assertRelatedTags(database, tag); Utils.loseFocus(main.properties); Updates.update(main, true); } }); tagButton2.setEnabled(true); } else { tagButton2.setEnabled(false); } hl.addComponent(tagButton2); hl.setComponentAlignment(tagButton2, Alignment.MIDDLE_LEFT); } right.addComponent(hl); right.setComponentAlignment(hl, Alignment.MIDDLE_LEFT); } } }