Example usage for com.vaadin.ui NativeButton NativeButton

List of usage examples for com.vaadin.ui NativeButton NativeButton

Introduction

In this page you can find the example usage for com.vaadin.ui NativeButton NativeButton.

Prototype

public NativeButton(String caption) 

Source Link

Usage

From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    final VaadinTestApplication app = (VaadinTestApplication) getApplication();
    logger.info("Getting attached to. Displaying " + processingStatus);
    final Processing processing = processingStatus.getProcessing();
    if (processingStatus == null || processing == null) {
        return;/*from   w w  w  .j  a  v a 2 s. co  m*/
    }

    setDataSource(processingStatus);
    setData(processingStatus);
    logger.info("Continuing being attached to. Displaying " + processingStatus.getStatus() + " for "
            + processing.getDescription() + " with status " + processing.getStatus());

    removeAllComponents();

    addLabelField("processing.description", "Description");
    addLabelField("processing.date", "Creation date");
    final String processingUpdateDate = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")
            .format(userDataService.getLastestUpdate(processing)); // when the status is last updated

    //dataelements
    if (processingStatus.getSubmissionIOs().size() != 0) {
        Label space = new Label("<div>&nbsp;</div>", Label.CONTENT_XHTML);
        space.setWidth("100%");
        space.setHeight("10px");
        getLayout().addComponent(space);
        submissionTable = new Table();
        submissionTable.setWidth("100%");
        submissionTable.setHeight("300px");
        submissionTable.setSelectable(true);
        submissionTable.setMultiSelect(true);
        submissionTable.setImmediate(true);
        submissionTable.addContainerProperty("input", Label.class, null);
        submissionTable.addContainerProperty("output", Label.class, null);
        submissionTable.addContainerProperty("view history", VerticalLayout.class, null);
        submissionTable.addContainerProperty("status", VerticalLayout.class, null);
        submissionTable.setColumnExpandRatio("input", 30f);
        submissionTable.setColumnExpandRatio("output", 20f);
        submissionTable.setColumnExpandRatio("view history", 20f);
        submissionTable.setColumnExpandRatio("status", 30f);

        for (Map<List<SubmissionIO>, List<SubmissionIO>> map : processingStatus.getSubmissionIOs()) {
            for (List<SubmissionIO> submissionIOinputs : map.keySet()) {
                if (submissionIOinputs.isEmpty()) {
                    logger.error("Skipping a submission with no inputs in processing: "
                            + processingStatus.getProcessing().getDbId());

                    continue;
                }

                //inputs
                StringBuffer inputValue = new StringBuffer();

                for (SubmissionIO submissionIOinput : submissionIOinputs) {
                    DataElement inputElement = submissionIOinput.getDataElement();

                    inputValue.append("<a href='" + userDataService.getDownloadURI(inputElement.getDbId())
                            + "' target='_blank'>" + inputElement.getName() + "</a><br />");
                }

                Label input = new Label(inputValue.toString(), Label.CONTENT_XHTML);
                input.setWidth("-1px");

                //outputs
                VerticalLayout historyLayout = new VerticalLayout();
                historyLayout.setWidth("100%");

                StringBuffer downloadValue = new StringBuffer();
                Label download = null;

                final List<SubmissionIO> outputs = map.get(submissionIOinputs);

                if (outputs.isEmpty()) {
                    download = new Label("No output available", Label.CONTENT_XHTML);
                } else {
                    for (SubmissionIO submissionIOoutput : outputs) {
                        final DataElement outputElement = submissionIOoutput.getDataElement();

                        if (submissionIOoutput.getDataElement().getExisting()) {
                            downloadValue.append("<a href='")
                                    .append(userDataService.getDownloadURI(outputElement.getDbId()))
                                    .append("' target='_blank'>download output</a><br />");
                        }

                        NativeButton viewHistoryButton = new NativeButton("history");

                        viewHistoryButton.addListener(new Button.ClickListener() {
                            private static final long serialVersionUID = 4280267926508263057L;

                            @Override
                            public void buttonClick(ClickEvent event) {
                                final String htmlContent = userDataService
                                        .getDataHistory(outputElement.getDbId());
                                showHTML(htmlContent, app);
                            }
                        });

                        historyLayout.addComponent(viewHistoryButton);
                    }

                    download = new Label(downloadValue.toString(), Label.CONTENT_XHTML);
                    download.setWidth("-1px");
                }

                // status
                VerticalLayout statusLayout = makeSubmissionStatusLayout(submissionIOinputs, processing, app);

                //add table item
                submissionTable.addItem(new Object[] { input, download, historyLayout, statusLayout }, null);
            }
        }

        getLayout().addComponent(submissionTable);
    }

    //total status
    Label space = new Label("<div>&nbsp;</div>", Label.CONTENT_XHTML);

    space.setWidth("100%");
    space.setHeight("10px");

    getLayout().addComponent(space);

    LabelField f = new LabelField();
    LabelField lastUpdateDateFieled = new LabelField();

    lastUpdateDateFieled.setLabelValue("<span style='font-size: 12px'><b>Last updated on:</b>&nbsp;</span>",
            processingUpdateDate);
    f.setLabelValue("<span style='font-size: 12px'><b>Overall status:</b>&nbsp;</span>",
            getStatus(processingStatus.getStatus(), null, false));

    getLayout().addComponent(f);
    getLayout().addComponent(lastUpdateDateFieled);
}

From source file:nl.amc.biolab.nsg.display.component.ProcessingStatusForm.java

License:Open Source License

private void createSubmissionButtons(final VaadinTestApplication app, final SubmissionIO submissionIO,
        final nl.amc.biolab.datamodel.objects.Error error) {
    final Link statusLink = new Link("download", new StreamResource(new StreamSource() {
        private static final long serialVersionUID = 2010850543250392280L;

        public InputStream getStream() {
            String status;/*from  w  w w  .j  av a 2 s. c  om*/
            if (error != null) {
                status = error.getCode() + "\n" + error.getMessage() + "\n" + error.getDescription();
            } else {
                status = "No message";
            }
            return new ByteArrayInputStream(status.getBytes());
        }
    }, "status", getApplication()), "", 400, 300, 2);

    viewStatusButton = new NativeButton("Details");
    viewStatusButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -8337533736203519683L;

        @Override
        public void buttonClick(ClickEvent event) {
            app.getMainWindow().addWindow(new Window() {
                private static final long serialVersionUID = 1520192489661790818L;

                {
                    center();
                    setWidth("700px");
                    setHeight("500px");
                    VerticalLayout vl = new VerticalLayout();
                    vl.addComponent(statusLink);
                    String status;
                    if (error != null) {
                        status = error.getCode() + "\n" + error.getMessage() + "\n" + error.getDescription();
                    } else {
                        status = "No message";
                    }
                    //status += "<img src=\"images/prov.png\"";
                    vl.addComponent(new Label(status, Label.CONTENT_PREFORMATTED));
                    addComponent(vl);
                }
            });
        }
    });

    resubmitButton = new NativeButton("Resume");
    resubmitButton.setData(processingStatusForm);
    resubmitButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -6410875548044234734L;

        @Override
        public void buttonClick(ClickEvent event) {
            long dbId = processingStatus.getProcessing().getDbId();
            long liferayID = app.getLiferayId(processingStatus.getProcessing().getUser().getLiferayID());
            processingService.resubmit(dbId, submissionIO.getSubmission().getDbId(),
                    userDataService.getUserId(), liferayID);
            processingStatusForm.attach();
        }
    });

    markFailButton = new NativeButton("Abort");
    markFailButton.setData(processingStatusForm);
    markFailButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -5019762936706219454L;

        @Override
        public void buttonClick(ClickEvent event) {
            app.getMainWindow().addWindow(new Window() {
                private static final long serialVersionUID = 3852384470521127702L;

                {
                    final Window window = this;
                    center();
                    setWidth("500px");
                    setHeight("300px");
                    VerticalLayout vl = new VerticalLayout();

                    final TextField text = new TextField("Remarks to the user");
                    text.setWidth("97%");
                    text.setHeight("150px");
                    vl.addComponent(text);

                    final Button okButton = new NativeButton();
                    okButton.setCaption("Save");
                    okButton.setImmediate(true);
                    okButton.setWidth("-1px");
                    okButton.setHeight("-1px");
                    okButton.addListener(new Button.ClickListener() {
                        private static final long serialVersionUID = 1754437322024958253L;

                        public void buttonClick(ClickEvent event) {
                            long dbId = processingStatus.getProcessing().getDbId();
                            long userID = processingStatus.getProcessing().getUser().getDbId();
                            long liferayID = app
                                    .getLiferayId(processingStatus.getProcessing().getUser().getLiferayID());
                            processingService.markFailed(submissionIO.getSubmission().getDbId(),
                                    (String) text.getValue());
                            processingStatus = processingService.getProcessingStatus(
                                    userDataService.getProcessing(dbId), userID, liferayID, false);
                            refreshButton.setData(processingStatus);
                            processingStatusForm.fireValueChange(false);//fireEvent(new Event(refreshButton));
                            window.getParent().removeWindow(window);
                        }
                    });
                    vl.addComponent(okButton);
                    addComponent(vl);
                }
            });
        }
    });
    //      }

    remarksButton = new NativeButton("Why?");
    remarksButton.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -267778012100029422L;

        @Override
        public void buttonClick(ClickEvent event) {
            app.getMainWindow().addWindow(new Window() {
                private static final long serialVersionUID = -5026454769214596711L;

                {
                    List<nl.amc.biolab.datamodel.objects.Error> temp = submissionIO.getSubmission().getErrors();

                    center();
                    setWidth("700px");
                    setHeight("500px");
                    VerticalLayout vl = new VerticalLayout();
                    vl.addComponent(
                            new Label(temp.get(temp.size() - 1).getMessage(), Label.CONTENT_PREFORMATTED));
                    addComponent(vl);
                }
            });
        }
    });
}

From source file:org.lunifera.examples.ecview.model.ui.PersonUI.java

License:Apache License

@SuppressWarnings("restriction")
@Override/*  ww  w .  j a v  a  2  s.  c om*/
protected void init(VaadinRequest request) {

    VerticalLayout spanningLayout = new VerticalLayout();
    spanningLayout.setSizeFull();
    setContent(spanningLayout);

    dtoService = DtoServiceAccess.getService(PersonDto.class);
    VerticalLayout layout = new VerticalLayout();
    spanningLayout.addComponent(layout);
    layout.setSizeUndefined();
    layout.setWidth("100%");

    HorizontalLayout buttonBar = new HorizontalLayout();
    layout.addComponent(buttonBar);
    buttonBar.setMargin(true);
    buttonBar.setSpacing(true);
    NativeButton setupDB = new NativeButton("Setup DB");
    setupDB.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            Activator.INSTANCE.setupDB();
        }
    });
    buttonBar.addComponent(setupDB);

    YView yView = findViewModel("org.lunifera.examples.ecview.model.jpa.services.PersonView");
    if (yView == null) {
        Notification.show("PersonView could not be found!", Type.ERROR_MESSAGE);
        return;
    }

    // render the Vaadin UI
    VaadinRenderer renderer = new VaadinRenderer();
    try {
        viewContext = renderer.render(layout, yView, null);
    } catch (ContextException e) {
        e.printStackTrace();
    }

    II18nService service = viewContext.getService(II18nService.ID);
    for (YExposedAction action : yView.getExposedActions()) {
        Button temp = new Button();
        buttonBar.addComponent(temp);
        temp.setCaption(service.getValue(action.getLabelI18nKey(), getLocale()));
        temp.setIcon(new ThemeResource(action.getIcon()));
        if (action.getId().equals("org.lunifera.actions.load")) {
            reloadAction = temp;
            reloadAction.setEnabled(false);
            temp.addClickListener(new LoadHandler());
        } else if (action.getId().equals("org.lunifera.actions.save")) {
            saveAction = temp;
            saveAction.setEnabled(false);
            temp.addClickListener(new SaveHandler());
        } else if (action.getId().equals("org.lunifera.actions.delete")) {
            deleteAction = temp;
            deleteAction.setEnabled(false);
            temp.addClickListener(new DeleteHandler());
        } else if (action.getId().equals("org.lunifera.actions.find")) {
            searchAction = temp;
            temp.addClickListener(new SearchHandler());
        }
    }
}

From source file:org.opennms.features.topology.app.internal.TopologyUI.java

License:Open Source License

private Component createMapLayout() {
    final Property<Double> scale = m_graphContainer.getScaleProperty();

    m_lastUpdatedTimeLabel = new LastUpdatedLabel();
    m_lastUpdatedTimeLabel.setImmediate(true);

    m_zoomLevelLabel.setHeight(20, Unit.PIXELS);
    m_zoomLevelLabel.setWidth(22, Unit.PIXELS);
    m_zoomLevelLabel.addStyleName("center-text");
    m_zoomLevelLabel.addTextChangeListener(new FieldEvents.TextChangeListener() {
        @Override//from w  ww.  j  a  va  2 s.  com
        public void textChange(FieldEvents.TextChangeEvent event) {
            try {
                int zoomLevel = Integer.parseInt(event.getText());
                setSemanticZoomLevel(zoomLevel);
            } catch (NumberFormatException e) {
                setSemanticZoomLevel(m_graphContainer.getSemanticZoomLevel());
            }

        }
    });

    m_topologyComponent = new TopologyComponent(m_graphContainer, m_iconRepositoryManager, this);
    m_topologyComponent.setSizeFull();
    m_topologyComponent.addMenuItemStateListener(this);
    m_topologyComponent.addVertexUpdateListener(this);

    final Slider slider = new Slider(0, 1);
    slider.setPropertyDataSource(scale);
    slider.setResolution(1);
    slider.setHeight("200px");
    slider.setOrientation(SliderOrientation.VERTICAL);

    slider.setImmediate(true);

    final NativeButton showFocusVerticesBtn = new NativeButton(FontAwesomeIcons.Icon.eye_open.variant());
    showFocusVerticesBtn.setDescription("Toggle Highlight Focus Nodes");
    showFocusVerticesBtn.setHtmlContentAllowed(true);
    showFocusVerticesBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (showFocusVerticesBtn.getCaption().equals(FontAwesomeIcons.Icon.eye_close.variant())) {
                showFocusVerticesBtn.setCaption(FontAwesomeIcons.Icon.eye_open.variant());
            } else {
                showFocusVerticesBtn.setCaption(FontAwesomeIcons.Icon.eye_close.variant());
            }
            m_topologyComponent.getState()
                    .setHighlightFocus(!m_topologyComponent.getState().isHighlightFocus());
            m_topologyComponent.updateGraph();
        }
    });

    final NativeButton magnifyBtn = new NativeButton();
    magnifyBtn.setHtmlContentAllowed(true);
    magnifyBtn.setCaption("<i class=\"" + FontAwesomeIcons.Icon.zoom_in.stylename() + "\" ></i>");
    magnifyBtn.setStyleName("icon-button");
    magnifyBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (slider.getValue() < 1) {
                slider.setValue(Math.min(1, slider.getValue() + 0.25));
            }
        }
    });

    final NativeButton demagnifyBtn = new NativeButton();
    demagnifyBtn.setHtmlContentAllowed(true);
    demagnifyBtn.setCaption("<i class=\"" + FontAwesomeIcons.Icon.zoom_out.stylename() + "\" ></i>");
    demagnifyBtn.setStyleName("icon-button");
    demagnifyBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (slider.getValue() != 0) {
                slider.setValue(Math.max(0, slider.getValue() - 0.25));
            }
        }
    });

    VerticalLayout sliderLayout = new VerticalLayout();
    sliderLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    sliderLayout.addComponent(magnifyBtn);
    sliderLayout.addComponent(slider);
    sliderLayout.addComponent(demagnifyBtn);

    m_szlOutBtn = new Button();
    m_szlOutBtn.setHtmlContentAllowed(true);
    m_szlOutBtn.setCaption(FontAwesomeIcons.Icon.arrow_down.variant());
    m_szlOutBtn.setDescription("Collapse Semantic Zoom Level");
    m_szlOutBtn.setEnabled(m_graphContainer.getSemanticZoomLevel() > 0);
    m_szlOutBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            int szl = m_graphContainer.getSemanticZoomLevel();
            if (szl > 0) {
                szl--;
                setSemanticZoomLevel(szl);
                saveHistory();
            }
        }
    });

    final Button szlInBtn = new Button();
    szlInBtn.setHtmlContentAllowed(true);
    szlInBtn.setCaption(FontAwesomeIcons.Icon.arrow_up.variant());
    szlInBtn.setDescription("Expand Semantic Zoom Level");
    szlInBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            int szl = m_graphContainer.getSemanticZoomLevel();
            szl++;
            setSemanticZoomLevel(szl);
            saveHistory();
        }
    });

    m_panBtn = new Button();
    m_panBtn.setIcon(FontAwesome.ARROWS);
    m_panBtn.setDescription("Pan Tool");
    m_panBtn.setStyleName("toolbar-button down");

    m_selectBtn = new Button();
    m_selectBtn.setIcon(new ThemeResource("images/selection.png"));
    m_selectBtn.setDescription("Selection Tool");
    m_selectBtn.setStyleName("toolbar-button");
    m_selectBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            m_selectBtn.setStyleName("toolbar-button down");
            m_panBtn.setStyleName("toolbar-button");
            m_topologyComponent.setActiveTool("select");
        }
    });

    m_panBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            m_panBtn.setStyleName("toolbar-button down");
            m_selectBtn.setStyleName("toolbar-button");
            m_topologyComponent.setActiveTool("pan");
        }
    });

    final Button historyBackBtn = new Button(FontAwesomeIcons.Icon.arrow_left.variant());
    historyBackBtn.setHtmlContentAllowed(true);
    historyBackBtn.setDescription("Click to go back");
    historyBackBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            com.vaadin.ui.JavaScript.getCurrent().execute("window.history.back()");
        }
    });

    final Button historyForwardBtn = new Button(FontAwesomeIcons.Icon.arrow_right.variant());
    historyForwardBtn.setHtmlContentAllowed(true);
    historyForwardBtn.setDescription("Click to go forward");
    historyForwardBtn.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            com.vaadin.ui.JavaScript.getCurrent().execute("window.history.forward()");
        }
    });

    m_searchBox = new SearchBox(m_serviceManager, new CommandManager.DefaultOperationContext(this,
            m_graphContainer, OperationContext.DisplayLocation.SEARCH));

    //History Button Layout
    HorizontalLayout historyButtonLayout = new HorizontalLayout();
    historyButtonLayout.setSpacing(true);
    historyButtonLayout.addComponent(historyBackBtn);
    historyButtonLayout.addComponent(historyForwardBtn);

    //Semantic Controls Layout
    HorizontalLayout semanticLayout = new HorizontalLayout();
    semanticLayout.setSpacing(true);
    semanticLayout.addComponent(szlInBtn);
    semanticLayout.addComponent(m_zoomLevelLabel);
    semanticLayout.addComponent(m_szlOutBtn);
    semanticLayout.setComponentAlignment(m_zoomLevelLabel, Alignment.MIDDLE_CENTER);

    VerticalLayout historyCtrlLayout = new VerticalLayout();
    historyCtrlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    historyCtrlLayout.addComponent(historyButtonLayout);

    HorizontalLayout controlLayout = new HorizontalLayout();
    controlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    controlLayout.addComponent(m_panBtn);
    controlLayout.addComponent(m_selectBtn);

    VerticalLayout semanticCtrlLayout = new VerticalLayout();
    semanticCtrlLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    semanticCtrlLayout.addComponent(semanticLayout);

    HorizontalLayout locationToolLayout = createLocationToolLayout();

    //Vertical Layout for all tools on right side
    VerticalLayout toollayout = new VerticalLayout();
    toollayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    toollayout.setSpacing(true);

    toollayout.addComponent(historyCtrlLayout);
    toollayout.addComponent(locationToolLayout);
    toollayout.addComponent(showFocusVerticesBtn);
    toollayout.addComponent(sliderLayout);
    toollayout.addComponent(controlLayout);
    toollayout.addComponent(semanticCtrlLayout);

    AbsoluteLayout mapLayout = new AbsoluteLayout();
    mapLayout.addComponent(m_topologyComponent, "top:0px; left: 0px; right: 0px; bottom: 0px;");
    mapLayout.addComponent(m_lastUpdatedTimeLabel, "top: 5px; right: 10px;");
    mapLayout.addComponent(toollayout, "top: 25px; right: 10px;");
    mapLayout.setSizeFull();

    m_infoPanel = new InfoPanel(m_searchBox, mapLayout);
    return m_infoPanel;
}

From source file:org.rdflivenews.annotator.gui.AnnotatorGuiApplication.java

License:Apache License

@Override
public void init() {
    setMainWindow(main);/*  w  ww .  ja  v  a2  s .  c  om*/
    setTheme("mytheme");

    if (!patterns.isEmpty()) {

        mainLayout.removeAllComponents();
        main.removeAllComponents();

        this.pattern = patterns.remove(0);
        this.writeTodoPatterns();

        GridLayout grid = new GridLayout(4, 6);
        grid.setSpacing(true);

        HorizontalLayout labels = new HorizontalLayout();
        labels.setSizeFull();

        subject = new Label("<span style=\"font-size:130%\">" + this.pattern.entityOne + "</span>");
        subject.setContentMode(Label.CONTENT_XHTML);
        subject.setSizeFull();
        patternLabel = new Label("<span style=\"font-size:130%;color:red;\">" + this.pattern.nlr + "</span>");
        patternLabel.setContentMode(Label.CONTENT_XHTML);
        patternLabel.setSizeFull();
        patternLabel.setStyleName("center");
        object = new Label(
                "<span style=\"font-size:130%;text-align:right;\">" + this.pattern.entityTwo + "</span>");
        object.setContentMode(Label.CONTENT_XHTML);
        object.setSizeFull();
        object.setStyleName("right");

        String sentenceLabel = "<a href=\"" + this.pattern.url + "\">" + "<span style=\"font-size:130%\">"
                + this.pattern.sentence
                        .replace(this.pattern.entityOne,
                                "<span style=\"font-weight:bold\">" + this.pattern.entityOne + "</span>")
                        .replace(this.pattern.entityTwo,
                                "<span style=\"font-weight:bold\">" + this.pattern.entityTwo + "</span>")
                        .replace(this.pattern.nlr, "<span style=\"color:red\">" + this.pattern.nlr + "</span>")
                + "</span></a>";

        sentence = new Label(sentenceLabel);
        sentence.setContentMode(Label.CONTENT_XHTML);

        grid.addComponent(sentence, 0, 0, 3, 0);
        labels.addComponent(subject);
        labels.addComponent(patternLabel);
        labels.addComponent(object);
        //            grid.addComponent(subject, 0, 1);
        //            grid.addComponent(patternLabel, 1, 1, 2, 1);
        //            grid.addComponent(object, 3, 1);
        labels.setComponentAlignment(subject, Alignment.MIDDLE_LEFT);
        labels.setComponentAlignment(patternLabel, Alignment.MIDDLE_CENTER);
        labels.setComponentAlignment(object, Alignment.MIDDLE_RIGHT);
        grid.addComponent(labels, 0, 1, 3, 1);

        AutocompleteWidget subject = new AutocompleteWidget(index);
        subject.addSelectionListener(new SelectionListener() {

            @Override
            public void itemSelected(SolrItem item) {
                subjectUri.setValue(item.getUri());
            }
        });
        grid.addComponent(subject, 0, 2, 1, 2);
        AutocompleteWidget object = new AutocompleteWidget(index);
        object.addSelectionListener(new SelectionListener() {

            @Override
            public void itemSelected(SolrItem item) {
                objectUri.setValue(item.getUri());
            }
        });
        grid.addComponent(object, 2, 2, 3, 2);

        saidObject = new TextArea("Say Cluster Object Value");
        saidObject.setWidth("100%");
        grid.addComponent(saidObject, 0, 5, 1, 5);

        comment = new TextArea("Comments");
        comment.setWidth("100%");
        grid.addComponent(comment, 2, 5, 3, 5);

        HorizontalLayout urisAndCluster = new HorizontalLayout();
        subjectUri = new TextField("Subject URI");
        objectUri = new TextField("Object URI");
        subjectUri.setSizeFull();
        objectUri.setSizeFull();

        //cluster category combobox
        clusterCategoriesBox = new ComboBox();
        clusterCategoriesBox.setWidth("40%");
        clusterCategoriesBox.setCaption("Cluster Category");
        clusterCategoriesBox.addContainerProperty("name", String.class, null);
        clusterCategoriesBox.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_ITEM);
        for (ClusterCategory cat : ClusterCategory.values()) {
            clusterCategoriesBox.addItem(cat).getItemProperty("name").setValue(cat.getName());
        }
        clusterCategoriesBox.setImmediate(true);
        clusterCategoriesBox.setValue(ClusterCategory.UNKNOWN);
        clusterCategoriesBox.setNullSelectionAllowed(false);

        urisAndCluster.setSizeFull();
        urisAndCluster.addComponent(subjectUri);
        urisAndCluster.addComponent(clusterCategoriesBox);
        urisAndCluster.addComponent(objectUri);
        urisAndCluster.setComponentAlignment(subjectUri, Alignment.MIDDLE_LEFT);
        urisAndCluster.setComponentAlignment(clusterCategoriesBox, Alignment.MIDDLE_CENTER);
        urisAndCluster.setComponentAlignment(objectUri, Alignment.MIDDLE_RIGHT);

        grid.addComponent(urisAndCluster, 0, 3, 3, 3);

        //            grid.addComponent(clusterCategoriesBox, 1, 3, 2, 3);
        //            grid.setComponentAlignment(clusterCategoriesBox, Alignment.BOTTOM_CENTER);

        mainLayout.addComponent(grid);

        HorizontalLayout submitButtonslayout = new HorizontalLayout();

        nextButton = new NativeButton("Next");
        trashButton = new NativeButton("Trash");
        stopButton = new NativeButton("Stop");
        nextButton.addListener(this);
        trashButton.addListener(this);
        stopButton.addListener(this);
        submitButtonslayout.setSpacing(true);
        submitButtonslayout.setWidth("100%");
        submitButtonslayout.addComponent(trashButton);
        submitButtonslayout.addComponent(stopButton);
        submitButtonslayout.addComponent(nextButton);
        submitButtonslayout.setComponentAlignment(nextButton, Alignment.MIDDLE_RIGHT);
        submitButtonslayout.setComponentAlignment(stopButton, Alignment.MIDDLE_RIGHT);

        mainLayout.addComponent(submitButtonslayout);
        mainLayout.setSpacing(true);
        mainLayout.setWidth(null);
        mainLayout.setHeight("100%");
        Panel panel = new Panel();
        panel.setWidth(null);
        panel.addComponent(mainLayout);

        main.addComponent(panel);
        ((VerticalLayout) main.getContent()).setHeight("100%");
        ((VerticalLayout) main.getContent()).setComponentAlignment(panel, Alignment.MIDDLE_CENTER);

        //force URI search with given labels
        subject.setSearchTerm(this.pattern.entityOne);
        object.setSearchTerm(this.pattern.entityTwo);
    } else
        getMainWindow().showNotification("No patterns anymore...");

}

From source file:org.vaadin.jefferson.content.ButtonControl.java

License:Open Source License

@Override
public Button createFallback() {
    return new NativeButton(getName());
}

From source file:org.vaadin.training.fundamentals.happening.ui.NavigationComponent.java

License:Apache License

@SuppressWarnings("serial")
private void buildLayout() {
    HorizontalLayout header = new HorizontalLayout();
    header.setWidth("100%");
    header.setHeight("50px");
    Label appName = new Label("Happening Application Header");
    header.addComponent(appName);//from w  w w  . java 2  s  .c  om
    NativeButton listButton = new NativeButton("List");
    listButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            setCurrentView(ListHappeningsView.class, null);
        }
    });

    NativeButton addButton = new NativeButton("Add");
    addButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            setCurrentView(AddNewView.class, null);
        }
    });

    NativeButton logoutButton = new NativeButton("Logout");
    logoutButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getApplication().close();
        }
    });
    header.addComponent(listButton);
    header.addComponent(addButton);
    header.addComponent(logoutButton);
    addComponent(header);
}

From source file:pl.exsio.frameset.vaadin.account.menu.presenter.AccountMenuPresenterImpl.java

License:Open Source License

protected Button getSettingsButton(final User user) {
    final AccountWindowPresenter.AccountEditionListener listener = this;
    Button accountSettings = new NativeButton(t("core.account.settings"));
    accountSettings.setIconAlternateText(t("core.account.settings"));
    accountSettings.setIcon(FontAwesome.COG);
    accountSettings.setStyleName("account-settings");
    accountSettings.addClickListener(new Button.ClickListener() {

        @Override//from  w  w  w . jav a 2  s.  c  o m
        public void buttonClick(Button.ClickEvent event) {
            AccountWindowPresenter window = ctx.getBean(AccountWindowPresenter.class);
            window.addAccountEditionListener(listener);
            window.show();
        }
    });

    return accountSettings;
}

From source file:pl.exsio.frameset.vaadin.account.menu.presenter.AccountMenuPresenterImpl.java

License:Open Source License

protected Button getLogoutButton() {
    Button logout = new NativeButton(t("core.logout"));
    logout.setIconAlternateText(t("core.logout"));
    logout.setIcon(FontAwesome.TIMES);//from   w w  w .j a v  a 2s . c  o  m
    logout.setStyleName("logout");
    logout.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            ConfirmationDialog.show(t("core.logout.confirm"), new ConfirmationDialog.Handler() {

                @Override
                public void handle(Button.ClickEvent event) {
                    UI.getCurrent().getSession().close();
                    UI.getCurrent().getPage().setLocation(logoutPath);
                }
            }, null);

        }
    });

    return logout;
}

From source file:pl.exsio.frameset.vaadin.navigation.menu.AccordionMenu.java

License:Open Source License

private VerticalLayout initPanel(VerticalLayout panel, MenuItem category, Tab tab) {

    for (final MenuItem item : category.getChildren()) {
        final VaadinFrame frame = (VaadinFrame) item.getFrame();
        final Button b = new NativeButton(t(frame.getMenuLabel()));
        b.setIcon(frame.getIcon());/*from w w w  . j a va2s. co  m*/
        b.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                ((FramesetUI) getUI()).getFramesetNavigator().navigateTo(frame, true);
                MenuSelectionChangeEvent e = new MenuSelectionChangeEvent(item, b);
                for (MenuSelectionChangeListener listener : listeners) {
                    listener.onSelectionChange(e);
                }
            }
        });
        b.setStyleName("button-" + frame.getSlug());
        this.buttonsMap.put(frame, b);
        this.frameMap.put(frame, tab);
        this.buttons.add(b);
        panel.addComponent(b);
    }
    panel.setStyleName("panel-" + category.getFrame().getSlug());
    return panel;
}