Example usage for com.vaadin.server FontAwesome FLASK

List of usage examples for com.vaadin.server FontAwesome FLASK

Introduction

In this page you can find the example usage for com.vaadin.server FontAwesome FLASK.

Prototype

FontAwesome FLASK

To view the source code for com.vaadin.server FontAwesome FLASK.

Click Source Link

Usage

From source file:com.esofthead.mycollab.module.crm.view.lead.LeadReadViewImpl.java

License:Open Source License

@Override
protected ComponentContainer createButtonControls() {
    CrmPreviewFormControlsGenerator<SimpleLead> controlsButton = new CrmPreviewFormControlsGenerator<>(
            previewForm);/*  w w w. j  a v a  2 s.  c o m*/

    Button convertButton = new Button(AppContext.getMessage(LeadI18nEnum.BUTTON_CONVERT_LEAD),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    previewForm.fireExtraAction("convert", beanItem);
                }
            });
    convertButton.setStyleName(UIConstants.THEME_GREEN_LINK);
    convertButton.setIcon(FontAwesome.FLASK);
    controlsButton.insertToControlBlock(convertButton);

    return controlsButton.createButtonControls(RolePermissionCollections.CRM_LEAD);
}

From source file:com.mycollab.module.crm.view.lead.LeadReadViewImpl.java

License:Open Source License

@Override
protected ComponentContainer createButtonControls() {
    CrmPreviewFormControlsGenerator<SimpleLead> controlsButton = new CrmPreviewFormControlsGenerator<>(
            previewForm);/*from  ww  w. j  av a 2  s  . co m*/

    if (UserUIContext.canWrite(RolePermissionCollections.CRM_LEAD)) {
        MButton convertButton = new MButton(UserUIContext.getMessage(LeadI18nEnum.BUTTON_CONVERT_LEAD),
                clickEvent -> previewForm.fireExtraAction("convert", beanItem)).withIcon(FontAwesome.FLASK)
                        .withStyleName(WebThemes.BUTTON_ACTION);
        controlsButton.insertToControlBlock(convertButton);
    }

    return controlsButton.createButtonControls(RolePermissionCollections.CRM_LEAD);
}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.DatasetView.java

License:Open Source License

/**
 * Precondition: {DatasetView#table} has to be initialized. e.g. with
 * {DatasetView#buildFilterTable} If it is not, strange behaviour has to be expected. builds the
 * Layout of this view.//  w  w w  . ja va 2 s.  c o m
 */
private void buildLayout() {
    this.vert.removeAllComponents();

    int browserWidth = UI.getCurrent().getPage().getBrowserWindowWidth();
    int browserHeight = UI.getCurrent().getPage().getBrowserWindowHeight();

    this.vert.setWidth("100%");
    this.setWidth(String.format("%spx", (browserWidth * 0.6)));
    // this.setHeight(String.format("%spx", (browserHeight * 0.8)));

    VerticalLayout statistics = new VerticalLayout();
    HorizontalLayout statContent = new HorizontalLayout();
    statContent.setCaption("Statistics");
    statContent.setIcon(FontAwesome.BAR_CHART_O);
    statContent.addComponent(new Label(String.format("%s registered dataset(s).", numberOfDatasets)));
    statContent.setMargin(true);
    statContent.setSpacing(true);
    statistics.addComponent(statContent);
    statistics.setMargin(true);
    this.vert.addComponent(statistics);

    // Table (containing datasets) section
    VerticalLayout tableSection = new VerticalLayout();
    HorizontalLayout tableSectionContent = new HorizontalLayout();

    tableSectionContent.setCaption("Registered Datasets");
    tableSectionContent.setIcon(FontAwesome.FLASK);
    tableSectionContent.addComponent(this.table);

    tableSectionContent.setMargin(true);
    tableSection.setMargin(true);

    tableSection.addComponent(tableSectionContent);
    this.vert.addComponent(tableSection);

    table.setWidth("100%");
    tableSection.setWidth("100%");
    tableSectionContent.setWidth("100%");

    // this.table.setSizeFull();

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setHeight(null);
    buttonLayout.setWidth("100%");
    buttonLayout.setSpacing(false);

    final Button visualize = new Button(VISUALIZE_BUTTON_CAPTION);
    buttonLayout.addComponent(this.download);
    buttonLayout.addComponent(visualize);

    Button checkAll = new Button("Select all datasets");
    checkAll.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Object itemId : table.getItemIds()) {
                ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(true);
            }
        }
    });

    Button uncheckAll = new Button("Unselect all datasets");
    uncheckAll.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            for (Object itemId : table.getItemIds()) {
                ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(false);
            }
        }
    });

    buttonLayout.addComponent(checkAll);
    buttonLayout.addComponent(uncheckAll);
    /**
     * prepare download.
     */
    download.setResource(new ExternalResource("javascript:"));
    download.setEnabled(false);
    visualize.setEnabled(false);

    for (final Object itemId : this.table.getItemIds()) {
        setCheckedBox(itemId, (String) this.table.getItem(itemId).getItemProperty("CODE").getValue());
    }

    /*
     * Update the visualize button. It is only enabled, if the files can be visualized.
     */
    this.table.addValueChangeListener(new ValueChangeListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -4875903343717437913L;

        /**
         * check for what selection can be visualized. If so, enable the button. TODO change to
         * checked.
         */
        @Override
        public void valueChange(ValueChangeEvent event) {
            // Nothing selected or more than one selected.
            Set<Object> selectedValues = (Set<Object>) event.getProperty().getValue();
            if (selectedValues == null || selectedValues.size() == 0 || selectedValues.size() > 1) {
                visualize.setEnabled(false);
                return;
            }
            // if one selected check whether its dataset type is either fastqc or qcml.
            // For now we only visulize these two file types.
            Iterator<Object> iterator = selectedValues.iterator();
            Object next = iterator.next();
            String datasetType = (String) table.getItem(next).getItemProperty("Dataset Type").getValue();
            String fileName = (String) table.getItem(next).getItemProperty("File Name").getValue();
            // TODO: No hardcoding!!
            // if (datasetType.equals("FASTQC") || datasetType.equals("QCML") ||
            // datasetType.equals("BAM")
            // || datasetType.equals("VCF")) {
            if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_RESULTS")
                    && (fileName.endsWith(".html") || fileName.endsWith(".qcML"))) {
                visualize.setEnabled(true);
            } else if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_LOGS")
                    && (fileName.endsWith(".err") || fileName.endsWith(".out"))) {
                visualize.setEnabled(true);
            } else {
                visualize.setEnabled(false);
            }
        }
    });

    // TODO Workflow Views should get those data and be happy
    /*
     * Send message that in datasetview the following was selected. WorkflowViews get those messages
     * and save them, if it is valid information for them.
     */
    this.table.addValueChangeListener(new ValueChangeListener() {
        /**
         * 
         */
        private static final long serialVersionUID = -3554627008191389648L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            // Nothing selected or more than one selected.
            Set<Object> selectedValues = (Set<Object>) event.getProperty().getValue();
            State state = (State) UI.getCurrent().getSession().getAttribute("state");
            ArrayList<String> message = new ArrayList<String>();
            message.add("DataSetView");
            if (selectedValues != null && selectedValues.size() == 1) {
                Iterator<Object> iterator = selectedValues.iterator();
                Object next = iterator.next();
                String datasetType = (String) table.getItem(next).getItemProperty("Dataset Type").getValue();
                message.add(datasetType);
                String project = (String) table.getItem(next).getItemProperty("Project").getValue();

                String space = datahandler.getOpenBisClient().getProjectByCode(project).getSpaceCode();// .getIdentifier().split("/")[1];
                message.add(project);
                message.add((String) table.getItem(next).getItemProperty("Sample").getValue());
                // message.add((String) table.getItem(next).getItemProperty("Sample Type").getValue());
                message.add((String) table.getItem(next).getItemProperty("dl_link").getValue());
                message.add((String) table.getItem(next).getItemProperty("File Name").getValue());
                message.add(space);
                // state.notifyObservers(message);
            } else {
                message.add("null");
            } // TODO
              // state.notifyObservers(message);

        }
    });

    // TODO get the GV to work here. Together with reverse proxy
    // Assumes that table Value Change listner is enabling or disabling the button if preconditions
    // are not fullfilled
    visualize.addClickListener(new ClickListener() {
        /**
         * 
         */
        private static final long serialVersionUID = 9015273307461506369L;

        @Override
        public void buttonClick(ClickEvent event) {
            Set<Object> selectedValues = (Set<Object>) table.getValue();
            Iterator<Object> iterator = selectedValues.iterator();
            Object next = iterator.next();
            String datasetCode = (String) table.getItem(next).getItemProperty("CODE").getValue();
            String datasetFileName = (String) table.getItem(next).getItemProperty("File Name").getValue();
            URL url;
            try {
                Object parent = table.getParent(next);
                if (parent != null) {
                    String parentDatasetFileName = (String) table.getItem(parent).getItemProperty("File Name")
                            .getValue();
                    url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode,
                            parentDatasetFileName + "/" + datasetFileName);
                } else {
                    url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, datasetFileName);
                }

                Window subWindow = new Window(
                        "QC of Sample: " + (String) table.getItem(next).getItemProperty("Sample").getValue());
                VerticalLayout subContent = new VerticalLayout();
                subContent.setMargin(true);
                subWindow.setContent(subContent);
                QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent();
                // Put some components in it
                Resource res = null;
                String datasetType = (String) table.getItem(next).getItemProperty("Dataset Type").getValue();
                final RequestHandler rh = new ProxyForGenomeViewerRestApi();
                boolean rhAttached = false;
                if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_RESULTS") && datasetFileName.endsWith(".qcML")) {
                    QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                    StreamResource streamres = new StreamResource(re, datasetFileName);
                    streamres.setMIMEType("application/xml");
                    res = streamres;
                } else if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_RESULTS")
                        && datasetFileName.endsWith(".html")) {
                    QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                    StreamResource streamres = new StreamResource(re, datasetFileName);
                    streamres.setMIMEType("text/html");
                    res = streamres;
                } else if (datasetType.equals("Q_WF_MS_QUALITYCONTROL_LOGS")
                        && (datasetFileName.endsWith(".err") || datasetFileName.endsWith(".out"))) {
                    QcMlOpenbisSource re = new QcMlOpenbisSource(url);
                    StreamResource streamres = new StreamResource(re, datasetFileName);
                    streamres.setMIMEType("text/plain");
                    res = streamres;
                } else if (datasetType.equals("FASTQC")) {
                    res = new ExternalResource(url);
                } else if (datasetType.equals("BAM") || datasetType.equals("VCF")) {
                    String filePath = (String) table.getItem(next).getItemProperty("dl_link").getValue();
                    filePath = String.format("/store%s", filePath.split("store")[1]);
                    String fileId = (String) table.getItem(next).getItemProperty("File Name").getValue();
                    // fileId = "control.1kg.panel.samples.vcf.gz";
                    // UI.getCurrent().getSession().addRequestHandler(rh);
                    rhAttached = true;
                    ThemeDisplay themedisplay = (ThemeDisplay) VaadinService.getCurrentRequest()
                            .getAttribute(WebKeys.THEME_DISPLAY);
                    String hostTmp = "http://localhost:7778/vizrest/rest";// "http://localhost:8080/web/guest/mainportlet?p_p_id=QbicmainportletApplicationPortlet_WAR_QBiCMainPortlet_INSTANCE_5pPd5JQ8uGOt&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&p_p_col_id=column-1&p_p_col_count=1";
                    // hostTmp +=
                    // "&qbicsession=" + UI.getCurrent().getSession().getAttribute("gv-restapi-session")
                    // + "&someblabla=";
                    // String hostTmp = themedisplay.getURLPortal() +
                    // UI.getCurrent().getPage().getLocation().getPath() + "?qbicsession=" +
                    // UI.getCurrent().getSession().getAttribute("gv-restapi-session") + "&someblabla=" ;
                    // String host = Base64.encode(hostTmp.getBytes());
                    String title = (String) table.getItem(next).getItemProperty("Sample").getValue();
                    // res =
                    // new ExternalResource(
                    // String
                    // .format(
                    // "http://localhost:7778/genomeviewer/?host=%s&title=%s&fileid=%s&featuretype=alignments&filepath=%s&removeZeroGenotypes=false",
                    // host, title, fileId, filePath));
                }
                BrowserFrame frame = new BrowserFrame("", res);
                if (rhAttached) {
                    frame.addDetachListener(new DetachListener() {

                        /**
                         * 
                         */
                        private static final long serialVersionUID = 1534523447730906543L;

                        @Override
                        public void detach(DetachEvent event) {
                            UI.getCurrent().getSession().removeRequestHandler(rh);
                        }

                    });
                }

                frame.setSizeFull();
                subContent.addComponent(frame);

                // Center it in the browser window
                subWindow.center();
                subWindow.setModal(true);
                subWindow.setSizeFull();

                frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.8), Unit.PIXELS);
                // Open it in the UI
                ui.addWindow(subWindow);
            } catch (MalformedURLException e) {
                LOGGER.error(String.format("Visualization failed because of malformedURL for dataset: %s",
                        datasetCode));
                Notification.show(
                        "Given dataset has no file attached to it!! Please Contact your project manager. Or check whether it already has some data",
                        Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    this.vert.addComponent(buttonLayout);

}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.PatientView.java

License:Open Source License

/**
 * init this view. builds the layout skeleton Menubar Description and others Statisitcs Experiment
 * Table Graph/*  www  .j  av a  2 s . c  o  m*/
 */
void initView() {
    patientViewContent = new VerticalLayout();
    patientViewContent.setMargin(new MarginInfo(true, false, false, false));
    // patientViewContent.setMargin(true);

    headerLabel = "";

    patientViewTab = new TabSheet();
    patientViewTab.setHeight("100%");
    patientViewTab.setWidth("100%");

    datasetComponent = new DatasetComponent(datahandler, state, resourceUrl);
    biologicalSamplesComponent = new BiologicalSamplesComponent(datahandler, state, resourceUrl,
            "Biological Samples");
    measuredSamplesComponent = new LevelComponent(datahandler, state, resourceUrl, "Raw Data");
    resultsComponent = new LevelComponent(datahandler, state, resourceUrl, "Results");
    statusComponent = new PatientStatusComponent(datahandler, state, resourceUrl);
    workflowComponent = new WorkflowComponent(wfController);
    uploadComponent = new AttachmentUploadComponent();
    projectInformation = new ProjInformationComponent(datahandler, state, resourceUrl);
    experimentComponent = new ExperimentComponent(datahandler, state, resourceUrl);

    patientViewTab.addStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS);
    patientViewTab.addStyleName(ValoTheme.TABSHEET_FRAMED);
    patientViewTab.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);

    // patientViewTab.addTab(initDescription()).setIcon(FontAwesome.INFO_CIRCLE);
    patientViewTab.addTab(projectInformation).setIcon(FontAwesome.INFO_CIRCLE);
    patientViewTab.addTab(statusComponent).setIcon(FontAwesome.CHECK_CIRCLE);
    patientViewTab.addTab(initGraphs()).setIcon(FontAwesome.SITEMAP);
    // patientViewTab.addTab(initMemberSection()).setIcon(FontAwesome.USERS);
    // patientViewTab.addTab(initHLALayout()).setIcon(FontAwesome.BARCODE);
    // patientViewTab.addTab(initTable()).setIcon(FontAwesome.FLASK);

    patientViewTab.addTab(experimentComponent).setIcon(FontAwesome.FLASK);
    patientViewTab.addTab(datasetComponent).setIcon(FontAwesome.DATABASE);
    patientViewTab.addTab(biologicalSamplesComponent).setIcon(FontAwesome.TINT);
    patientViewTab.addTab(measuredSamplesComponent).setIcon(FontAwesome.SIGNAL);
    patientViewTab.addTab(resultsComponent).setIcon(FontAwesome.TH_LARGE);
    patientViewTab.addTab(workflowComponent).setIcon(FontAwesome.COGS);
    patientViewTab.addTab(uploadComponent).setIcon(FontAwesome.UPLOAD);

    patientViewTab.setImmediate(true);

    patientViewTab.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            TabSheet tab = (TabSheet) event.getSource();

            if (event.getTabSheet().getSelectedTab().getCaption().equals("Project Graph")) {
                loadGraph();
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Exp. Steps")) {
                experimentComponent.updateUI(getCurrentBean());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Datasets")) {
                datasetComponent.updateUI("project", getCurrentBean().getId());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Raw Data")) {
                measuredSamplesComponent.updateUI("project", getCurrentBean().getId(), "measured");
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Biological Samples")) {
                biologicalSamplesComponent.updateUI(getCurrentBean().getId());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Results")) {
                resultsComponent.updateUI("project", getCurrentBean().getId(), "results");
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Status")) {
                statusComponent.updateUI(getCurrentBean());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Workflows")) {
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", getCurrentBean().getId());
                args.put("type", "project");
                workflowComponent.update(args);
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Upload Files")) {
                // (get space from currentBean)
                uploadComponent.updateUI(manager, getCurrentBean().getCode(), currentBean.getId().split("/")[1],
                        datahandler.getOpenBisClient());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("")) {
                projectInformation.updateUI(getCurrentBean(), "patient");
            }
        }
    });

    patientViewContent.addComponent(patientViewTab);
    this.addComponent(patientViewContent);

}

From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjectView.java

License:Open Source License

/**
 * init this view. builds the layout skeleton Menubar Description and others Statisitcs Experiment
 * Table Graph//  w  w w .j  a v a  2s.  c  o  m
 */
void initView() {
    projectview_content = new VerticalLayout();
    projectview_content.setMargin(new MarginInfo(true, false, false, false));

    // labelContent = new VerticalLayout();
    // labelContent.setMargin(new MarginInfo(true, false, true, false));

    headerLabel = "";

    // labelContent.addComponent(headerLabel);
    // projectview_content.addComponent(labelContent);

    projectview_tab = new TabSheet();
    projectview_tab.setWidth("100%");
    projectview_tab.setHeight("100%");

    datasetComponent = new DatasetComponent(datahandler, state, resourceUrl);
    biologicalSamplesComponent = new BiologicalSamplesComponent(datahandler, state, resourceUrl,
            "Biological Samples");
    measuredSamplesComponent = new LevelComponent(datahandler, state, resourceUrl, "Raw Data");
    resultsComponent = new LevelComponent(datahandler, state, resourceUrl, "Results");
    workflowComponent = new WorkflowComponent(wfController);
    uploadComponent = new AttachmentUploadComponent();
    projectInformation = new ProjInformationComponent(datahandler, state, resourceUrl);
    experimentComponent = new ExperimentComponent(datahandler, state, resourceUrl);

    // add styles to tab sheet
    projectview_tab.addStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS);
    projectview_tab.addStyleName(ValoTheme.TABSHEET_FRAMED);
    // projectview_tab.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);

    // add tabs to tabsheet
    projectview_tab.addTab(projectInformation).setIcon(FontAwesome.INFO_CIRCLE);
    projectview_tab.addTab(initGraphs()).setIcon(FontAwesome.SITEMAP);
    // projectview_tab.addTab(initMemberSection()).setIcon(FontAwesome.USERS);

    projectview_tab.addTab(experimentComponent).setIcon(FontAwesome.FLASK);
    projectview_tab.addTab(datasetComponent).setIcon(FontAwesome.DATABASE);
    projectview_tab.addTab(biologicalSamplesComponent).setIcon(FontAwesome.TINT);
    projectview_tab.addTab(measuredSamplesComponent).setIcon(FontAwesome.SIGNAL);
    projectview_tab.addTab(resultsComponent).setIcon(FontAwesome.TH_LARGE);
    projectview_tab.addTab(workflowComponent).setIcon(FontAwesome.COGS);
    projectview_tab.addTab(uploadComponent).setIcon(FontAwesome.UPLOAD);

    projectview_tab.setImmediate(true);

    projectview_tab.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            if (event.getTabSheet().getSelectedTab().getCaption().equals("Project Graph")) {
                loadGraph();
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Exp. Steps")) {
                experimentComponent.updateUI(getCurrentBean());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Datasets")) {
                datasetComponent.updateUI(navigateToLabel, getCurrentBean().getId());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Raw Data")) {
                measuredSamplesComponent.updateUI(navigateToLabel, getCurrentBean().getId(), "measured");
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Biological Samples")) {
                biologicalSamplesComponent.updateUI(getCurrentBean().getId());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Results")) {
                resultsComponent.updateUI(navigateToLabel, getCurrentBean().getId(), "results");
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Workflows")) {
                Map<String, String> args = new HashMap<String, String>();
                args.put("id", getCurrentBean().getId());
                args.put("type", navigateToLabel);
                workflowComponent.update(args);
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("Upload Files")) {
                // (get space from currentBean)
                uploadComponent.updateUI(manager, getCurrentBean().getCode(), currentBean.getId().split("/")[1],
                        datahandler.getOpenBisClient());
            } else if (event.getTabSheet().getSelectedTab().getCaption().equals("")) {
                projectInformation.updateUI(getCurrentBean(), "project");
            }
        }
    });

    // projectview_content.addComponent(initMenuBar());
    projectview_content.addComponent(projectview_tab);
    // projectview_content.addComponent(initDescription());
    // projectview_content.addComponent(initStatistics());
    // projectview_content.addComponent(initTable());
    // projectview_content.addComponent(initButtonLayout());

    // projectview_content.addComponent(initGraph());

    // use the component that is returned by initTable
    // projectview_content.setComponentAlignment(this.table, Alignment.TOP_CENTER);
    // projectview_content.setWidth("100%");
    this.addComponent(projectview_content);
}

From source file:main.ProjectwizardUI.java

License:Open Source License

private void initView(final DBManager dbm, final DBVocabularies vocabularies, final String user) {
    tabs.removeAllComponents();/*from w  ww .  j a  v a  2s .  com*/
    AttachmentConfig attachConfig = new AttachmentConfig(Integer.parseInt(config.getAttachmentMaxSize()),
            config.getAttachmentURI(), config.getAttachmentUser(), config.getAttachmenPassword());
    WizardController c = new WizardController(openbis, dbm, vocabularies, attachConfig);
    c.init(user);
    Wizard w = c.getWizard();
    WizardProgressListener wl = new WizardProgressListener() {

        @Override
        public void activeStepChanged(WizardStepActivationEvent event) {
        }

        @Override
        public void stepSetChanged(WizardStepSetChangedEvent event) {
        }

        @Override
        public void wizardCompleted(WizardCompletedEvent event) {
            vocabularies.setPeople(dbm.fetchPeople());
            vocabularies.setSpaces(openbis.getUserSpaces(user));
            initView(dbm, vocabularies, user);
        }

        @Override
        public void wizardCancelled(WizardCancelledEvent event) {
            vocabularies.setPeople(dbm.fetchPeople());
            vocabularies.setSpaces(openbis.getUserSpaces(user));
            initView(dbm, vocabularies, user);
        }

    };
    w.addListener(wl);
    VerticalLayout wLayout = new VerticalLayout();
    wLayout.addComponent(w);
    wLayout.setMargin(true);

    tabs.addTab(wLayout, "Create Project").setIcon(FontAwesome.FLASK);
    // TODO barcode tab, remove once new portlet is online
    // BarcodeConfig bcConf = new BarcodeConfig(config.getBarcodeScriptsFolder(), tmpFolder,
    // config.getBarcodeResultsFolder(), config.getBarcodePathVariable());
    // SampleFilterGenerator gen = new SampleFilterGenerator();
    // BarcodeController bc = new BarcodeController(openbis, bcConf, dbm);
    // gen.addObserver(bc);
    // final WizardBarcodeView bw = new WizardBarcodeView(vocabularies.getSpaces(), isAdmin, gen);
    // bw.initControl(bc);
    // tabs.addTab(bw, "Create Barcodes").setIcon(FontAwesome.BARCODE);
    // tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() {
    //
    // @Override
    // public void selectedTabChange(SelectedTabChangeEvent event) {
    // bw.resetSpace();
    // }
    // });

    OpenbisCreationController creationController = new OpenbisCreationController(openbis);// will
                                                                                          // not
                                                                                          // work
                                                                                          // when
                                                                                          // openbis
                                                                                          // is down

    ExperimentImportController uc = new ExperimentImportController(creationController, vocabularies, openbis,
            dbm);
    uc.init(user);
    tabs.addTab(uc.getView(), "Import Project").setIcon(FontAwesome.FILE);

    boolean overwriteAllowed = isAdmin || canOverwrite();
    tabs.addTab(new MetadataUploadView(openbis, vocabularies, overwriteAllowed), "Update Metadata")
            .setIcon(FontAwesome.PENCIL);
    ;
    if (isAdmin) {
        logger.info("User is " + user + " and can see admin panel.");
        VerticalLayout padding = new VerticalLayout();
        padding.setMargin(true);
        padding.addComponent(new AdminView(openbis, vocabularies, creationController, user));
        tabs.addTab(padding, "Admin Functions").setIcon(FontAwesome.WRENCH);
    }
    if (overwriteAllowed)
        logger.info("User can overwrite existing metadata for their project.");
}

From source file:uicomponents.MSSampleMultiplicationTable.java

License:Open Source License

protected void createEnzymeSelectionWindow(String row) {
    Window subWindow = new Window(" Enzyme selection");
    subWindow.setWidth("400px");

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);//  www .  java2 s .  com
    layout.setMargin(true);
    EnzymePanel pan = new EnzymePanel(enzymes);
    Button ok = new Button("Okay.");
    ok.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            List<String> enzymes = pan.getEnzymes();
            ComboBox b = parseBoxRow(row, "Enzyme");
            if (enzymes.isEmpty()) {
                Styles.notification("No enzymes selected", "Please select at least one enzyme!",
                        NotificationType.ERROR);
            } else if (enzymes.size() == 1) {
                b.setValue(enzymes.get(0));
                subWindow.close();
            } else {
                b.addItem("Custom");
                b.setValue("Custom");
                enzymeMap.put(row, enzymes);
                subWindow.close();
            }
        }
    });
    layout.addComponent(pan);
    layout.addComponent(ok);

    subWindow.setContent(layout);
    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setIcon(FontAwesome.FLASK);
    subWindow.setResizable(false);
    ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent();
    ui.addWindow(subWindow);
}

From source file:views.MetadataUploadView.java

License:Open Source License

protected void createVocabularySelectWindow(ComboBox selected, String propName, List<Label> entries) {
    Window subWindow = new Window(" " + propName);
    subWindow.setWidth("300px");

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*from  ww  w.jav  a  2  s.c o  m*/
    layout.setSpacing(true);

    // create combobox per unique value for this column to find a mapping to the source vocabulary
    Map<String, String> entriesToVocabValues = new HashMap<String, String>();
    Set<String> uniqueEntries = new HashSet<String>();
    // keep these old values in case user chooses different property afterwards
    List<String> oldEntries = new ArrayList<String>();
    ValueChangeListener resetSelectionListener = new ValueChangeListener() {
        @Override
        public void valueChange(ValueChangeEvent event) {
            // reset labels to what they were before
            for (int i = 0; i < entries.size(); i++) {
                entries.get(i).setValue(oldEntries.get(i));
            }
            // remove reset listener, it won't be needed until a vocabulary field is selected again
            selected.removeValueChangeListener(this);
        }
    };
    selected.addValueChangeListener(resetSelectionListener);

    List<ComboBox> boxes = new ArrayList<ComboBox>();
    Set<String> vocabOptions = propToVocabulary.get(propNameToCode.get(propName)).keySet();
    for (Label l : entries) {
        String val = l.getValue();
        oldEntries.add(val);
        if (!uniqueEntries.contains(val)) {
            ComboBox b = new ComboBox(val);
            b.addItems(vocabOptions);
            b.setNullSelectionAllowed(false);
            b.setStyleName(Styles.boxTheme);
            b.setFilteringMode(FilteringMode.CONTAINS);
            layout.addComponent(b);
            boxes.add(b);
            uniqueEntries.add(val);
            val = StringUtils.capitalize(val);
            if (vocabOptions.contains(val)) {
                b.setValue(val);
                b.setEnabled(false);
            }
        }
    }
    Button send = new Button("Ok");
    send.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            boolean valid = true;
            for (ComboBox b : boxes) {
                if (b.getValue() != null) {
                    String newVal = b.getValue().toString();
                    entriesToVocabValues.put(b.getCaption(), newVal);
                } else
                    valid = false;
            }
            if (valid) {
                for (Label l : entries) {
                    l.setValue(entriesToVocabValues.get(l.getValue()));
                }
                subWindow.close();

                // check for collisions now that values have changed
                reactToTableChange();
            } else {
                String error = "Please select a value for each entry.";
                Styles.notification("Missing Input", error, NotificationType.DEFAULT);
            }
        }
    });
    layout.addComponent(send);

    subWindow.setContent(layout);
    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setIcon(FontAwesome.FLASK);
    subWindow.setResizable(false);

    ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent();
    ui.addWindow(subWindow);
}

From source file:views.MetadataUploadView.java

License:Open Source License

protected void createConditionWindow(ComboBox selectionBox) {
    String val = (String) selectionBox.getValue();

    // val.equals("[Experimental Condition]")
    String header = " Experimental Condition Name";
    String prefix = "Condition";
    Resource icon = FontAwesome.FLASK;

    if (val.equals("[Other Property]")) {
        header = " Property Name";
        prefix = "Property";
        icon = FontAwesome.FILE_TEXT;//from   ww  w . ja  va 2 s  . c o m
    }
    final String category = prefix;

    Window subWindow = new Window(header);
    subWindow.setWidth("300px");

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    TextField label = new TextField();
    label.setRequired(true);
    label.setStyleName(Styles.fieldTheme);
    RegexpValidator factorLabelValidator = new RegexpValidator("([a-z]+_?[a-z]*)+([a-z]|[0-9]*)",
            "Name must start with a lower case letter and contain only lower case letter words, which can be connected by underscores ('_'). It can end with one or more numbers.");
    label.addValidator(factorLabelValidator);
    label.setValidationVisible(true);
    label.setImmediate(true);

    ComboBox unitSelect = new ComboBox("Unit");
    unitSelect.setNullSelectionAllowed(false);
    unitSelect.addItems(properties.Unit.values());
    String nullItem = "[None]";
    unitSelect.addItem(nullItem);
    unitSelect.select(nullItem);
    unitSelect.setStyleName(Styles.boxTheme);
    unitSelect.setImmediate(true);

    Button send = new Button("Ok");
    send.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (label.isValid()) {
                String unit = "";
                if (!unitSelect.getValue().equals(nullItem))
                    unit = " [" + unitSelect.getValue() + "]";
                String name = category + ": " + label.getValue() + unit;
                selectionBox.addItem(name);
                selectionBox.select(name);
                subWindow.close();
            } else {
                String error = "Please input a name for this " + category + ".";
                if (!label.isEmpty())
                    error = factorLabelValidator.getErrorMessage();
                Styles.notification("Missing Input", error, NotificationType.DEFAULT);
            }
        }
    });
    layout.addComponent(label);
    layout.addComponent(unitSelect);
    layout.addComponent(send);

    subWindow.setContent(layout);
    // Center it in the browser window
    subWindow.center();
    subWindow.setModal(true);
    subWindow.setIcon(icon);
    subWindow.setResizable(false);
    ProjectwizardUI ui = (ProjectwizardUI) UI.getCurrent();
    ui.addWindow(subWindow);
}