Example usage for com.vaadin.server FontAwesome REFRESH

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

Introduction

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

Prototype

FontAwesome REFRESH

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

Click Source Link

Usage

From source file:com.toptal.ui.CrudToolbar.java

License:Open Source License

/**
 * Ctor./*from w  w  w  .  j av a2s .c om*/
 * @param crud Crud implementation.
 * @param components Additional components.
 */
public CrudToolbar(final Crud crud, final Component... components) {
    super();
    this.add = new MButton(FontAwesome.PLUS_CIRCLE, e -> crud.add());
    this.edit = new MButton(FontAwesome.PENCIL_SQUARE_O, e -> crud.edit());
    this.delete = new MButton(FontAwesome.MINUS_CIRCLE, e -> crud.delete());
    this.refresh = new MButton(FontAwesome.REFRESH, e -> crud.update());
    this.addComponents(this.add, this.edit, this.delete, this.refresh);
    this.addComponents(components);
    this.setEditAndDeleteEnabled(false);
}

From source file:com.yoncabt.ebr.ui.ReportStatusWindow.java

@PostConstruct
private void init() {
    grid = makeGrid();/* w w  w  . j  av  a2  s . c  o m*/
    Button btnReload = new Button(FontAwesome.REFRESH);
    btnReload.addClickListener((Button.ClickEvent event) -> {
        fillTheGrid();
    });
    Button btnExport = YoncaGridXLSExporter.createDownloadButton(grid, "raporlar.xls");

    setContent(new VerticalLayout(new HorizontalLayout(btnExport, btnReload), grid));

    fillTheGrid();
    setWidth(100, Unit.PERCENTAGE);
}

From source file:facs.components.BookAdmin.java

License:Open Source License

public BookAdmin(User user) {

    Date dNow = new Date();
    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
    System.out.println(ft.format(dNow) + "  INFO  Calendar Admin accessed! - User: "
            + LiferayAndVaadinUtils.getUser().getScreenName());

    Label infoLabel = new Label(
            DBManager.getDatabaseInstance().getUserNameByUserID(LiferayAndVaadinUtils.getUser().getScreenName())
                    + "  " + LiferayAndVaadinUtils.getUser().getScreenName());
    infoLabel.addStyleName("h4");

    String buttonRefreshTitle = "Refresh";
    Button refresh = new Button(buttonRefreshTitle);
    refresh.setIcon(FontAwesome.REFRESH);
    refresh.setSizeFull();/*from w w w .  j a v  a2s .  c  om*/
    refresh.setDescription("Click here to reload the data from the database!");
    refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    String buttonUpdateTitle = "Update";
    Button updateUser = new Button(buttonUpdateTitle);
    updateUser.setIcon(FontAwesome.WRENCH);
    updateUser.setSizeFull();
    updateUser.setDescription("Click here to update your user role and group!");

    userDevice = new ListSelect("Select a device");
    userDevice.addItems(DBManager.getDatabaseInstance().getDeviceNames());
    userDevice.setRows(6);
    userDevice.setNullSelectionAllowed(false);
    userDevice.setSizeFull();
    userDevice.setImmediate(true);
    /*
     * userDevice.addValueChangeListener(e -> Notification.show("Device:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    userGroup = new ListSelect("Select a user group");
    userGroup.addItems(DBManager.getDatabaseInstance().getUserGroups());
    userGroup.setRows(6);
    userGroup.setNullSelectionAllowed(false);
    userGroup.setSizeFull();
    userGroup.setImmediate(true);
    /*
     * userGroup.addValueChangeListener(e -> Notification.show("User Group:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    userRole = new ListSelect("Select a user role");
    userRole.addItems(DBManager.getDatabaseInstance().getUserRoles());
    userRole.setRows(6);
    userRole.setNullSelectionAllowed(false);
    userRole.setSizeFull();
    userRole.setImmediate(true);
    /*
     * userRole.addValueChangeListener(e -> Notification.show("User Role:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    refresh.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496269L;

        @Override
        public void buttonClick(ClickEvent event) {
            refreshDataSources();
        }
    });

    updateUser.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496909L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                if (userDevice.getValue().equals(null) || userRole.getValue().equals(null)
                        || userGroup.getValue().equals(null)) {
                    showErrorNotification("Something's missing!",
                            "Please make sure that you selected a Device, a Role and a Group! Each list has to have one highligthed option.'.");
                    // System.out.println("Device: "+userDevice.getValue()+" Group: "+userGroup.getValue()+" Role: "+userRole.getValue());
                } else {
                    DBManager.getDatabaseInstance().getShitDone(
                            DBManager.getDatabaseInstance().getUserRoleIDbyDesc(userRole.getValue().toString()),
                            DBManager.getDatabaseInstance()
                                    .getUserIDbyLDAPID(LiferayAndVaadinUtils.getUser().getScreenName()),
                            DBManager.getDatabaseInstance()
                                    .getDeviceIDByName(userDevice.getValue().toString()));

                    DBManager.getDatabaseInstance().getShitDoneAgain(
                            DBManager.getDatabaseInstance()
                                    .getUserGroupIDByName(userGroup.getValue().toString()),
                            LiferayAndVaadinUtils.getUser().getScreenName());

                }
            } catch (Exception e) {
                showErrorNotification("Something's missing!",
                        "Please make sure that you selected a Device, a Role and a Group! Each list has to have one highligthed option.'.");
            }
            refreshDataSources();
        }
    });

    // only admins are allowed to see the admin panel ;)
    if (!DBManager.getDatabaseInstance()
            .getUserAdminPanelAccessByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName()).equals("1")) {
        VerticalLayout errorLayout = new VerticalLayout();
        infoLabel.setValue("ACCESS DENIED");
        errorLayout.addComponent(infoLabel);
        showErrorNotification("Access Denied!",
                "Sorry, you're not allowed to see anything here, at least your username told us so. Do you need assistance? Please contact 'info@qbic.uni-tuebingen.de'.");
        setCompositionRoot(errorLayout);
        return;
    }

    this.setCaption("Admin");

    final TabSheet bookAdmin = new TabSheet();
    bookAdmin.addStyleName(ValoTheme.TABSHEET_FRAMED);
    bookAdmin.addStyleName(ValoTheme.TABSHEET_EQUAL_WIDTH_TABS);

    ArrayList<String> deviceNames = new ArrayList<String>();
    deviceNames = DBManager.getDatabaseInstance().getDeviceNames();

    bookAdmin.addTab(awaitingRequestsGrid());

    for (int i = 0; i < deviceNames.size(); i++) {
        bookAdmin.addTab(newDeviceGrid(deviceNames.get(i)));
    }

    bookAdmin.addTab(deletedBookingsGrid());

    bookAdmin.addSelectedTabChangeListener(new SelectedTabChangeListener() {

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

        @Override
        public void selectedTabChange(SelectedTabChangeEvent event) {
            userDevice.select(bookAdmin.getSelectedTab().getCaption());
            userRole.select(DBManager.getDatabaseInstance()
                    .getUserGroupDescriptionByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName(), DBManager
                            .getDatabaseInstance().getDeviceIDByName(bookAdmin.getSelectedTab().getCaption())));
            userGroup.select(DBManager.getDatabaseInstance()
                    .getUserRoleNameByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName()));

        }
    });

    gridLayout.setWidth("100%");

    // add components to the grid layout
    // gridLayout.addComponent(infoLabel, 0, 0, 3, 0);
    gridLayout.addComponent(bookAdmin, 0, 1, 5, 1);
    gridLayout.addComponent(refresh, 0, 2);
    gridLayout.addComponent(userDevice, 0, 4, 1, 4);
    gridLayout.addComponent(userRole, 2, 4, 3, 4);
    gridLayout.addComponent(userGroup, 4, 4, 5, 4);
    gridLayout.addComponent(updateUser, 0, 5, 5, 5);
    gridLayout.setSizeFull();

    gridLayout.setSpacing(true);
    setCompositionRoot(gridLayout);

    /*
     * JavaScript to update the Grid try { JDBCConnectionPool connectionPool = new
     * SimpleJDBCConnectionPool("com.mysql.jdbc.Driver",
     * "jdbc:mysql://localhost:8889/facs_facility", "facs", "facs"); QueryDelegate qd = new
     * FreeformQuery("select * from facs_facility", connectionPool, "id"); final SQLContainer c =
     * new SQLContainer(qd); bookAdmin.setContainerDataSource(c); }
     * 
     * JavaScript.getCurrent().execute("setInterval(function(){refreshTable();},5000);");
     * JavaScript.getCurrent().addFunction("refreshTable", new JavaScriptFunction() {
     * 
     * @Override public void call(JsonArray arguments) { // TODO Auto-generated method stub
     * 
     * } });
     */

}

From source file:facs.components.Booking.java

License:Open Source License

public Booking(final BookingModel bookingModel, Date referenceDate) {

    String[] sayHello = { "Kon'nichiwa", "Hello", "Halo", "Hiya", "Hej", "Hallo", "Hola", "Grezi", "Servus",
            "Merhaba", "Bonjour", "Ahoj", "Moi", "Ciao", "Buongiorno" };

    this.bookingModel = bookingModel;
    this.referenceDate = referenceDate;

    Label infoLabel = new Label();
    infoLabel.addStyleName("h4");

    Label selectDeviceLabel = new Label();
    selectDeviceLabel.addStyleName("h4");
    selectDeviceLabel.setValue("Please Select a Device");

    final Label versionLabel = new Label();
    versionLabel.addStyleName("h4");
    versionLabel.setValue("Version 0.1.160727");

    // showSuccessfulNotification(sayHello[(int) (Math.random() * sayHello.length)] + ", "
    // + bookingModel.userName() + "!", "");

    Date dNow = new Date();
    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
    System.out.println(ft.format(dNow) + "  INFO  Calendar initiated! - User: " + bookingModel.getLDAP() + " "
            + versionLabel);//w  w w. j  a va 2s  .  co  m

    // only users who are allowed to book devices will be able to do so
    if (bookingModel.isNotAllowed()) {
        VerticalLayout errorLayout = new VerticalLayout();
        infoLabel.setValue("ACCESS DENIED");
        errorLayout.addComponent(infoLabel);
        showErrorNotification("Access Denied!",
                "Sorry, you're not allowed to see anything here, at least your username told us so. Do you need assistance? Please contact 'info@qbic.uni-tuebingen.de'.");
        setCompositionRoot(errorLayout);
        return;
    }

    Panel book = new Panel();
    book.addStyleName(ValoTheme.PANEL_BORDERLESS);

    DBManager.getDatabaseInstance();
    db = Database.Instance;
    db.userLogin(bookingModel.getLDAP());
    selectedDevice = initCalendars(bookingModel.getDevicesNames());

    selectedService = new NativeSelect("Please select a service:");
    selectedService.setDescription("Please select the service you would like to receive!");

    selectedKostenstelle = new NativeSelect("Please select konstenstelle:");
    selectedKostenstelle.setDescription("Please select the Kostenstelle you would like to use!");

    selectedDevice.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 8153818693511960689L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            versionLabel.setValue(db.getUserRoleDescByLDAPId(bookingModel.getLDAP(), getCurrentDevice()));

            selectedKostenstelle.setVisible(true);

            if (bookMap.containsKey(getCurrentDevice())) {
                cal.removeAllComponents();
                setCalendar();

                if (selectedDevice.getValue().equals("Aria")) {
                    selectedService.removeAllItems();
                    selectedService.addItems("Full Service", "Partial Service", "Self Service");
                    selectedService.setValue("Full Service");
                    selectedService.setVisible(true);
                } else if (selectedDevice.getValue().equals("Mac")) {
                    selectedService.removeAllItems();
                    selectedService.addItems("Self", "Service");
                    selectedService.setValue("Service");
                    selectedService.setVisible(true);
                } else {
                    selectedService.setValue(null);
                    selectedService.setVisible(false);
                }

            } else {

                bookMap.put(getCurrentDevice(), initCal(bookingModel, getCurrentDevice()));
                cal.removeAllComponents();
                setCalendar();

                if (selectedDevice.getValue().equals("Aria")) {
                    selectedService.removeAllItems();
                    selectedService.addItems("Full Service", "Partial Service", "Self Service");
                    selectedService.setValue("Full Service");
                    selectedService.setVisible(true);
                } else if (selectedDevice.getValue().equals("Mac")) {
                    selectedService.removeAllItems();
                    selectedService.addItems("Self", "Service");
                    selectedService.setValue("Service");
                    selectedService.setVisible(true);
                } else {
                    selectedService.setValue(null);
                    selectedService.setVisible(false);
                }
            }
        }
    });

    if (bookingModel.getProject().isEmpty()) {
        infoLabel.setValue(bookingModel.userName() + "  Kostenstelle: " + bookingModel.getKostenstelle()
                + "  Institute: " + bookingModel.getInstitute());

    } else {
        infoLabel.setValue(bookingModel.userName() + "  Kostenstelle: " + bookingModel.getKostenstelle()
                + "  Project: " + bookingModel.getProject() + "  Institute: "
                + bookingModel.getInstitute());
    }

    // bookDeviceLayout.addComponent(infoLabel);
    cal.setLocale(Locale.getDefault());
    cal.setImmediate(true);
    selectedService.setImmediate(true);
    cal.setSizeFull();

    String submitTitle = "Book";
    Button submit = new Button(submitTitle);
    submit.setIcon(FontAwesome.CALENDAR);
    submit.setDescription("Please select a device and a time frame at first then click 'BOOK'!");
    submit.setSizeFull();

    // submit.setVisible(false);

    submit.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496269L;

        @Override
        public void buttonClick(ClickEvent event) {
            submit(bookingModel.getLDAP(), getCurrentDevice());
            newEvents.clear();
            refreshDataSources();
        }
    });

    String buttonTitle = "Refresh";
    Button refresh = new Button(buttonTitle);
    refresh.setIcon(FontAwesome.REFRESH);
    refresh.setSizeFull();
    refresh.setDescription("Click here to reload the data from the database!");
    refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    refresh.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496269L;

        @Override
        public void buttonClick(ClickEvent event) {

            refreshDataSources();

        }
    });

    gridLayout.setWidth("100%");
    // add components to the grid layout
    gridLayout.addComponent(infoLabel, 0, 4, 3, 4);
    gridLayout.addComponent(versionLabel, 4, 4, 5, 4);

    // gridLayout.addComponent(selectDeviceLabel,0,1);
    gridLayout.addComponent(selectedDevice, 0, 0);
    gridLayout.addComponent(selectedService, 1, 0);
    gridLayout.addComponent(selectedKostenstelle, 2, 0);
    selectedService.setVisible(false);

    gridLayout.addComponent(cal, 0, 2, 5, 2);

    gridLayout.addComponent(refresh, 0, 3);
    gridLayout.addComponent(submit, 1, 3, 5, 3);

    // gridLayout.addComponent(myBookings(), 0, 5, 5, 5);

    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    gridLayout.setSizeFull();

    book.setContent(gridLayout);

    booking = new TabSheet();

    booking.addStyleName(ValoTheme.TABSHEET_FRAMED);
    booking.addTab(book).setCaption("Calendar");
    booking.addTab(myNext24HoursBookings()).setCaption("Next 24 Hours");
    booking.addTab(myUpcomingBookings()).setCaption("Upcoming");
    booking.addTab(myPastBookings()).setCaption("Past Bookings");
    // booking.addTab(myUpcomingBookingsSQLContainer()).setCaption("Test");
    setCompositionRoot(booking);

}

From source file:facs.components.Statistics.java

License:Open Source License

private Component initialGrid() {

    VerticalLayout gridLayout = new VerticalLayout();

    createInvoice.setEnabled(false);/* w w  w  . j a  v a2s  .  co  m*/
    downloadInvoice.setEnabled(false);

    String buttonRefreshTitle = "Refresh";
    Button refresh = new Button(buttonRefreshTitle);
    refresh.setIcon(FontAwesome.REFRESH);
    refresh.setDescription("Click here to reload the data from the database!");
    refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    refresh.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496269L;

        @Override
        public void buttonClick(ClickEvent event) {
            refreshDataSources();

        }
    });

    Date dNow = new Date();
    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
    System.out.println(ft.format(dNow) + "  INFO  Statistics accessed! - User: "
            + LiferayAndVaadinUtils.getUser().getScreenName());

    // Add some generated properties
    IndexedContainer container = getEmptyContainer();
    gpcontainer = new GeneratedPropertyContainer(container);

    Grid grid = new Grid(gpcontainer);

    grid.setWidth("100%");
    setRenderers(grid);
    fillRows(grid);

    // compute total costs
    float totalCosts = 0.0f;
    for (Object itemId : gpcontainer.getItemIds())
        totalCosts += ((Number) gpcontainer.getContainerProperty(itemId, costCaption).getValue()).floatValue();

    // compute total time in milliseconds
    long total = 0;
    for (Object itemId : gpcontainer.getItemIds()) {
        long s = ((Date) gpcontainer.getContainerProperty(itemId, startCaption).getValue()).getTime();
        long e = ((Date) gpcontainer.getContainerProperty(itemId, endCaption).getValue()).getTime();
        total += e - s;
    }

    // set footer to contain total cost and time in hours:minutes
    FooterRow footer = grid.appendFooterRow();
    FooterCell footerCellCost = footer.getCell(costCaption);
    footerCellCost.setText(String.format("%1$.2f  total", totalCosts));

    FooterCell footerCellEnd = footer.getCell(endCaption);
    footerCellEnd.setText(Formatter.toHoursAndMinutes(total)); // "%1$.0f hours"

    // Set up a filter for all columns
    HeaderRow filterRow = grid.appendHeaderRow();
    addRowFilter(filterRow, deviceCaption, container, footer, gpcontainer);
    addRowFilter(filterRow, kostenstelleCaption, container, footer, gpcontainer);

    Label infoLabel = new Label(
            DBManager.getDatabaseInstance().getUserNameByUserID(LiferayAndVaadinUtils.getUser().getScreenName())
                    + "  " + LiferayAndVaadinUtils.getUser().getScreenName());
    infoLabel.addStyleName("h4");

    // createInvoice.setSizeFull();
    // downloadInvoice.setSizeFull();

    gridLayout.setWidth("100%");
    gridLayout.setCaption("Statistics");
    // add components to the grid layout
    // gridLayout.addComponent(infoLabel, 0, 0, 3, 0);
    // gridLayout.addComponent(grid, 0, 1, 5, 1);
    // gridLayout.addComponent(createInvoice, 0, 3);
    // gridLayout.addComponent(downloadInvoice, 1, 3);

    gridLayout.addComponent(grid);
    gridLayout.addComponent(refresh);
    gridLayout.addComponent(createInvoice);
    gridLayout.addComponent(downloadInvoice);

    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);

    // grid.setEditorEnabled(true);
    grid.setSelectionMode(SelectionMode.SINGLE);
    grid.addSelectionListener(new SelectionListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -2683274060620429050L;

        @Override
        public void select(SelectionEvent event) {
            // Notification.show("Select row: " + grid.getSelectedRow() + " Name: "
            // + gpcontainer.getContainerProperty(grid.getSelectedRow(), nameCaption).getValue());
            downloadInvoice.setEnabled(false);
            ReceiverPI = (String) gpcontainer.getContainerProperty(grid.getSelectedRow(), nameCaption)
                    .getValue();
            createInvoice.setEnabled(true);
        }
    });

    createInvoice.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 5512585967145932560L;
        private File bill;
        private FileDownloader fileDownloader;

        @Override
        public void buttonClick(ClickEvent event) {
            String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();

            Paths.get(basepath, "WEB-INF/billingTemplates");

            // System.out.println("Basepath: " + basepath);

            try {

                int setUserId = DBManager.getDatabaseInstance().findUserByFullName(ReceiverPI);

                if (setUserId > 0) {

                    Billing billing = new Billing(Paths.get(basepath, "WEB-INF/billingTemplates").toFile(),
                            "Angebot.tex");

                    UserBean user = setUserId > 0 ? DBManager.getDatabaseInstance().getUserById(setUserId)
                            : null;

                    billing.setReceiverPI(ReceiverPI);
                    billing.setReceiverInstitution(user.getInstitute());
                    billing.setReceiverStreet(user.getStreet());
                    billing.setReceiverPostalCode(user.getPostcode());
                    billing.setReceiverCity(user.getCity());

                    billing.setSenderName("Dr. rer. nat. Stella Autenrieth");
                    billing.setSenderFunction("Leiterin");
                    billing.setSenderPostalCode("72076");
                    billing.setSenderCity("Tbingen");
                    billing.setSenderStreet("Otfried-Mller-Strae 10");
                    billing.setSenderPhone("+49 (0) 7071 29-83156");
                    billing.setSenderEmail("stella.autenrieth@med.uni-tuebingen.de");
                    billing.setSenderUrl("www.medizin.uni-tuebingen.de");
                    billing.setSenderFaculty("Medizinischen Fakultt");

                    if (user.getKostenstelle() != null)
                        billing.setProjectDescription("Kostenstelle: " + user.getKostenstelle());
                    else
                        billing.setProjectDescription("Keine kostenstelle verfgbar.");

                    billing.setProjectShortDescription("Dieses Angebot beinhaltet jede Menge Extras.");

                    if (user.getProject() != null)
                        billing.setProjectNumber("Kostenstelle: " + user.getKostenstelle());
                    else
                        billing.setProjectNumber("Keine project nummer verfgbar.");

                    float cost = ((Number) gpcontainer.getContainerProperty(grid.getSelectedRow(), costCaption)
                            .getValue()).floatValue();
                    long s = ((Date) gpcontainer.getContainerProperty(grid.getSelectedRow(), startCaption)
                            .getValue()).getTime();
                    long e = ((Date) gpcontainer.getContainerProperty(grid.getSelectedRow(), endCaption)
                            .getValue()).getTime();
                    long timeFrame = e - s;
                    Date start = ((Date) gpcontainer.getContainerProperty(grid.getSelectedRow(), startCaption)
                            .getValue());
                    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy");
                    String date = ft.format(start);
                    String description = "No Description is Available";
                    String time_frame = Formatter.toHoursAndMinutes(timeFrame);

                    ArrayList<CostEntry> entries = new ArrayList<CostEntry>();
                    entries.add(billing.new CostEntry(date, time_frame, description, cost));
                    billing.setCostEntries(entries);
                    float totalCosts = 0.0f;

                    // calculates the total cost of items
                    // for (Object itemId : gpcontainer.getItemIds()) {
                    // totalCosts +=
                    // ((Number) gpcontainer.getContainerProperty(itemId, costCaption).getValue())
                    // .floatValue();
                    // }

                    totalCosts = ((Number) gpcontainer.getContainerProperty(grid.getSelectedRow(), costCaption)
                            .getValue()).floatValue();

                    billing.setTotalCost(String.format("%1$.2f", totalCosts));

                    bill = billing.createPdf();
                    // System.out.println(bill.getAbsolutePath());
                    if (fileDownloader != null)
                        downloadInvoice.removeExtension(fileDownloader);
                    fileDownloader = new FileDownloader(new FileResource(bill));
                    fileDownloader.extend(downloadInvoice);
                    downloadInvoice.setEnabled(true);
                    showSuccessfulNotification("Congratulations!",
                            "Invoice is created and available for download.");
                    downloadInvoice.setEnabled(true);
                } else {
                    createInvoice.setEnabled(false);
                    downloadInvoice.setEnabled(false);
                    showErrorNotification("No such user found!",
                            "An error occured while trying to create the invoice. The common problem occurs to be: this no such user in the database.");
                }
            }

            catch (Exception e) {
                showErrorNotification("What the heck!",
                        "An error occured while trying to create the invoice. The common problem occurs to be: this no such user or it can not run program 'pdflatex'.");
                e.printStackTrace();
            }

            // for all entries
            /*
             * try { Billing billing = new Billing(Paths.get(basepath,
             * "WEB-INF/billingTemplates").toFile(), "Angebot.tex");
             * billing.setRecieverInstitution("BER - Berliner Flughafen");
             * billing.setRecieverPI("Klaus Something");
             * billing.setRecieverStreet("am berliner flughafen 12");
             * billing.setRecieverPostalCode("D-12345"); billing.setRecieverCity("Berlin");
             * 
             * billing.setSenderName("Dr. rer. nat. Stella Autenrieth");
             * billing.setSenderFunction("Leiterin"); billing.setSenderPostalCode("72076");
             * billing.setSenderCity("Tbingen"); billing.setSenderStreet("Otfried-Mller-Strae 10");
             * billing.setSenderPhone("+49 (0) 7071 29-83156");
             * billing.setSenderEmail("stella.autenrieth@med.uni-tuebingen.de");
             * billing.setSenderUrl("www.medizin.uni-tuebingen.de");
             * billing.setSenderFaculty("Medizinischen Fakultt");
             * 
             * billing.setProjectDescription("Dieses Angebot beinhaltet jede Menge Extras.");
             * billing.setProjectShortDescription("jede Menge Extras.");
             * billing.setProjectNumber("QA2014016");
             * 
             * ArrayList<CostEntry> entries = new ArrayList<CostEntry>(); for (Object itemId :
             * gpcontainer.getItemIds()) { float cost = ((Number)
             * gpcontainer.getContainerProperty(itemId, costCaption).getValue()) .floatValue(); long s =
             * ((Date) gpcontainer.getContainerProperty(itemId, startCaption).getValue()) .getTime();
             * long e = ((Date) gpcontainer.getContainerProperty(itemId,
             * endCaption).getValue()).getTime(); long timeFrame = e - s; Date start = ((Date)
             * gpcontainer.getContainerProperty(itemId, startCaption).getValue()); SimpleDateFormat ft =
             * new SimpleDateFormat("dd.MM.yyyy"); String date = ft.format(start); String description =
             * "No Description is Available"; String time_frame =
             * Formatter.toHoursAndMinutes(timeFrame); entries.add(billing.new CostEntry(date,
             * time_frame, description, cost)); } billing.setCostEntries(entries); float totalCosts =
             * 0.0f; for (Object itemId : gpcontainer.getItemIds()) { totalCosts += ((Number)
             * gpcontainer.getContainerProperty(itemId, costCaption).getValue()) .floatValue(); }
             * 
             * billing.setTotalCost(String.format("%1$.2f", totalCosts));
             * 
             * bill = billing.createPdf(); System.out.println(bill.getAbsolutePath()); if
             * (fileDownloader != null) downloadBill.removeExtension(fileDownloader); fileDownloader =
             * new FileDownloader(new FileResource(bill)); fileDownloader.extend(downloadBill);
             * downloadBill.setEnabled(true); showSuccessfulNotification("Congratulations!",
             * "Invoice is created and available for download."); } catch (Exception e) {
             * showErrorNotification( "What the heck!",
             * "An error occured while trying to create the invoice. The common problem occurs to be: cannot run program 'pdflatex'"
             * ); e.printStackTrace(); }
             */

        }

    });

    return gridLayout;

}

From source file:facs.components.Statistics.java

License:Open Source License

private Component newMatchedGrid() {

    Button createInvoiceMatched = new Button("Create Invoice");
    Button downloadInvoiceMatched = new Button("Download Invoice");

    String buttonRefreshTitle = "Refresh";
    Button refreshMatched = new Button(buttonRefreshTitle);
    refreshMatched.setIcon(FontAwesome.REFRESH);
    refreshMatched.setDescription("Click here to reload the data from the database!");
    refreshMatched.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    createInvoiceMatched.setEnabled(false);
    downloadInvoiceMatched.setEnabled(false);

    Grid matchedGrid;/* w  w w .j  ava 2  s  .com*/

    refreshMatched.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496269L;

        @Override
        public void buttonClick(ClickEvent event) {
            refreshDataSources();

        }
    });

    IndexedContainer mcontainer = getEmptyContainer();

    GeneratedPropertyContainer mpc = new GeneratedPropertyContainer(mcontainer);

    VerticalLayout matchedLayout = new VerticalLayout();

    matchedGrid = new Grid(mpc);

    setRenderers(matchedGrid);
    fillMatchedRows(matchedGrid);

    // compute total costs
    float totalCosts = 0.0f;
    for (Object itemId : mpc.getItemIds())
        totalCosts += ((Number) mpc.getContainerProperty(itemId, costCaption).getValue()).floatValue();

    // compute total time in milliseconds
    long total = 0;
    for (Object itemId : mpc.getItemIds()) {
        long s = ((Date) mpc.getContainerProperty(itemId, startCaption).getValue()).getTime();
        long e = ((Date) mpc.getContainerProperty(itemId, endCaption).getValue()).getTime();
        total += e - s;
    }

    // set footer to contain total cost and time in hours:minutes
    FooterRow footer = matchedGrid.appendFooterRow();
    FooterCell footerCellCost = footer.getCell(costCaption);
    footerCellCost.setText(String.format("%1$.2f  total", totalCosts));

    FooterCell footerCellEnd = footer.getCell(endCaption);
    footerCellEnd.setText(Formatter.toHoursAndMinutes(total)); // "%1$.0f hours"

    // Set up a filter for all columns
    HeaderRow filterRow = matchedGrid.appendHeaderRow();
    addRowFilter(filterRow, deviceCaption, mcontainer, footer, mpc);
    addRowFilter(filterRow, kostenstelleCaption, mcontainer, footer, mpc);

    matchedLayout.setMargin(true);
    matchedLayout.setSpacing(true);

    // devicesGrid.setWidth("100%");
    matchedGrid.setSizeFull();
    matchedGrid.setSelectionMode(SelectionMode.SINGLE);
    matchedLayout.addComponent(matchedGrid);

    matchedGrid.setSelectionMode(SelectionMode.SINGLE);
    matchedGrid.addSelectionListener(new SelectionListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -2683274060620429050L;

        @Override
        public void select(SelectionEvent event) {
            // Notification.show("Select row: " + grid.getSelectedRow() + " Name: "
            // + gpcontainer.getContainerProperty(grid.getSelectedRow(), nameCaption).getValue());
            downloadInvoiceMatched.setEnabled(false);
            ReceiverPI = (String) mpc.getContainerProperty(matchedGrid.getSelectedRow(), nameCaption)
                    .getValue();
            createInvoiceMatched.setEnabled(true);
        }
    });
    createInvoiceMatched.addClickListener(new ClickListener() {

        private File bill;
        private FileDownloader fileDownloader;

        @Override
        public void buttonClick(ClickEvent event) {
            String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();

            Paths.get(basepath, "WEB-INF/billingTemplates");

            // System.out.println("Basepath: " + basepath);

            try {

                int setUserId = DBManager.getDatabaseInstance().findUserByFullName(ReceiverPI);

                if (setUserId > 0) {

                    Billing billing = new Billing(Paths.get(basepath, "WEB-INF/billingTemplates").toFile(),
                            "Angebot.tex");

                    UserBean user = setUserId > 0 ? DBManager.getDatabaseInstance().getUserById(setUserId)
                            : null;

                    billing.setReceiverPI(ReceiverPI);
                    billing.setReceiverInstitution(user.getInstitute());
                    billing.setReceiverStreet(user.getStreet());
                    billing.setReceiverPostalCode(user.getPostcode());
                    billing.setReceiverCity(user.getCity());

                    billing.setSenderName("Dr. rer. nat. Stella Autenrieth");
                    billing.setSenderFunction("Leiterin");
                    billing.setSenderPostalCode("72076");
                    billing.setSenderCity("Tbingen");
                    billing.setSenderStreet("Otfried-Mller-Strae 10");
                    billing.setSenderPhone("+49 (0) 7071 29-83156");
                    billing.setSenderEmail("stella.autenrieth@med.uni-tuebingen.de");
                    billing.setSenderUrl("www.medizin.uni-tuebingen.de");
                    billing.setSenderFaculty("Medizinischen Fakultt");

                    if (user.getKostenstelle() != null)
                        billing.setProjectDescription("Kostenstelle: " + user.getKostenstelle());
                    else
                        billing.setProjectDescription("Keine kostenstelle verfgbar.");

                    billing.setProjectShortDescription("Dieses Angebot beinhaltet jede Menge Extras.");

                    if (user.getProject() != null)
                        billing.setProjectNumber("Kostenstelle: " + user.getKostenstelle());
                    else
                        billing.setProjectNumber("Keine project nummer verfgbar.");

                    float cost = ((Number) mpc.getContainerProperty(matchedGrid.getSelectedRow(), costCaption)
                            .getValue()).floatValue();
                    long s = ((Date) mpc.getContainerProperty(matchedGrid.getSelectedRow(), startCaption)
                            .getValue()).getTime();
                    long e = ((Date) mpc.getContainerProperty(matchedGrid.getSelectedRow(), endCaption)
                            .getValue()).getTime();
                    long timeFrame = e - s;
                    Date start = ((Date) mpc.getContainerProperty(matchedGrid.getSelectedRow(), startCaption)
                            .getValue());
                    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy");
                    String date = ft.format(start);
                    String description = "No Description is Available";
                    String time_frame = Formatter.toHoursAndMinutes(timeFrame);

                    ArrayList<CostEntry> entries = new ArrayList<CostEntry>();
                    entries.add(billing.new CostEntry(date, time_frame, description, cost));
                    billing.setCostEntries(entries);

                    float totalCosts = 0.0f;

                    totalCosts = ((Number) mpc.getContainerProperty(matchedGrid.getSelectedRow(), costCaption)
                            .getValue()).floatValue();

                    billing.setTotalCost(String.format("%1$.2f", totalCosts));

                    bill = billing.createPdf();
                    // System.out.println(bill.getAbsolutePath());
                    if (fileDownloader != null)
                        downloadInvoiceMatched.removeExtension(fileDownloader);
                    fileDownloader = new FileDownloader(new FileResource(bill));
                    fileDownloader.extend(downloadInvoiceMatched);
                    downloadInvoiceMatched.setEnabled(true);
                    showSuccessfulNotification("Congratulations!",
                            "Invoice is created and available for download.");
                    downloadInvoiceMatched.setEnabled(true);
                } else {
                    createInvoiceMatched.setEnabled(false);
                    downloadInvoiceMatched.setEnabled(false);
                    showErrorNotification("No such user found!",
                            "An error occured while trying to create the invoice. The common problem occurs to be: this no such user in the database.");
                }
            }

            catch (Exception e) {
                showErrorNotification("What the heck!",
                        "An error occured while trying to create the invoice. The common problem occurs to be: this no such user or it can not run program 'pdflatex'.");
                e.printStackTrace();
            }

        }

    });

    matchedLayout.addComponent(refreshMatched);
    matchedLayout.addComponent(createInvoiceMatched);
    matchedLayout.addComponent(downloadInvoiceMatched);

    return matchedLayout;
}

From source file:facs.components.UserAdmin.java

License:Open Source License

public UserAdmin(User user) {

    Date dNow = new Date();
    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss");
    System.out.println(ft.format(dNow) + "  INFO  Calendar User Manager accessed! - User: "
            + LiferayAndVaadinUtils.getUser().getScreenName());

    Label infoLabel = new Label(
            DBManager.getDatabaseInstance().getUserNameByUserID(LiferayAndVaadinUtils.getUser().getScreenName())
                    + "  " + LiferayAndVaadinUtils.getUser().getScreenName());
    infoLabel.addStyleName("h4");

    CheckBox isAdmin = new CheckBox("user has admin panel access");
    isAdmin.setEnabled(false);//from  w w w .  j  ava 2 s  .  c om

    String buttonGroupUpdateTitle = "Edit Group";
    Button updateUserGroup = new Button(buttonGroupUpdateTitle);
    updateUserGroup.setIcon(FontAwesome.EDIT);
    updateUserGroup.setSizeFull();
    updateUserGroup.setDescription("Click here to update the group of the user!");

    String buttonWorkgroupUpdateTitle = "Edit Workgroup";
    Button updateUserWorkgroup = new Button(buttonWorkgroupUpdateTitle);
    updateUserWorkgroup.setIcon(FontAwesome.EDIT);
    updateUserWorkgroup.setSizeFull();
    updateUserWorkgroup.setDescription("Click here to update the workgroup of the user!");

    String buttonUpdateTitle = "Update (user role & group for device)";
    Button updateUserRightsAndRoles = new Button(buttonUpdateTitle);
    updateUserRightsAndRoles.setIcon(FontAwesome.WRENCH);
    updateUserRightsAndRoles.setSizeFull();
    updateUserRightsAndRoles.setDescription("Click here to update the user's role and group for a device!");

    String buttonTitle = "Refresh";
    Button refresh = new Button(buttonTitle);
    refresh.setIcon(FontAwesome.REFRESH);
    refresh.setSizeFull();
    refresh.setDescription("Click here to reload the data from the database!");
    refresh.addStyleName(ValoTheme.BUTTON_FRIENDLY);

    // String buttonTitleSave = "Save";
    // Button save = new Button(buttonTitleSave);
    // save.setIcon(FontAwesome.SAVE);
    // save.setSizeFull();
    // save.setDescription("Click here to save all changes!");
    // save.addStyleName(ValoTheme.BUTTON_BORDERLESS);

    userDevice = new ListSelect("Devices");
    userDevice.addItems(DBManager.getDatabaseInstance().getDeviceNames());
    userDevice.setRows(6);
    userDevice.setNullSelectionAllowed(false);
    userDevice.setSizeFull();
    userDevice.setImmediate(true);
    /*
     * userDevice.addValueChangeListener(e -> Notification.show("Device:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    userGroup = new ListSelect("User Groups");
    userGroup.addItems(DBManager.getDatabaseInstance().getUserGroups());
    userGroup.addItem("N/A");
    userGroup.setRows(6);
    userGroup.setNullSelectionAllowed(false);
    userGroup.setSizeFull();
    userGroup.setImmediate(true);
    /*
     * userGroup.addValueChangeListener(e -> Notification.show("User Group:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    userRole = new ListSelect("User Roles");
    userRole.addItems(DBManager.getDatabaseInstance().getUserRoles());
    userRole.addItem("N/A");
    userRole.setRows(6);
    userRole.setNullSelectionAllowed(false);
    userRole.setSizeFull();
    userRole.setImmediate(true);
    /*
     * userRole.addValueChangeListener(e -> Notification.show("User Role:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */
    userWorkgroup = new ListSelect("Workgroups");
    userWorkgroup.addItems(DBManager.getDatabaseInstance().getUserWorkgroups());
    userWorkgroup.setRows(6);
    userWorkgroup.setNullSelectionAllowed(false);
    userWorkgroup.setSizeFull();
    userWorkgroup.setImmediate(true);
    /*
     * userRole.addValueChangeListener(e -> Notification.show("User Role:",
     * String.valueOf(e.getProperty().getValue()), Type.TRAY_NOTIFICATION));
     */

    Button updateUser = new Button(buttonTitle);
    updateUser.setIcon(FontAwesome.WRENCH);
    updateUser.setDescription("Click here to update your user role and group!");

    refresh.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496269L;

        @Override
        public void buttonClick(ClickEvent event) {
            refreshDataSources();
        }
    });

    updateUser.addClickListener(new ClickListener() {
        private static final long serialVersionUID = -3610721151565496909L;

        @Override
        public void buttonClick(ClickEvent event) {
            refreshDataSources();
        }
    });

    updateUserWorkgroup.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -295434651623561492L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                Object selectedRow = ((SingleSelectionModel) usersGrid.getSelectionModel()).getSelectedRow();

                if (selectedRow == null || userWorkgroup.getValue().equals(null)) {
                    Notification("Something's missing!",
                            "Please make sure that you selected the user and workgroup! Make sure they are highligthed.",
                            "error");
                } else {
                    DBManager.getDatabaseInstance().adminUpdatesUserWorkgroup(
                            DBManager.getDatabaseInstance()
                                    .getUserGroupIDByName(userWorkgroup.getValue().toString()),
                            DBManager.getDatabaseInstance().getUserLDAPIDbyID(selectedRow.toString()));

                    // log changes in 'user_log' table
                    DBManager.getDatabaseInstance().logEverything(
                            LiferayAndVaadinUtils.getUser().getScreenName(), "Admin edited Workgroup");

                    Notification("Successfully Updated",
                            "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.",
                            "success");

                }
            } catch (Exception e) {
                Notification("Something's missing!",
                        "Please make sure that you selected the user and workgroup! Make sure they are highligthed.",
                        "error");
            }
            refreshDataSources();
        }
    });

    updateUserGroup.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -5539382755814626288L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                Object selectedRow = ((SingleSelectionModel) usersGrid.getSelectionModel()).getSelectedRow();

                if (selectedRow == null || userWorkgroup.getValue().equals(null)) {
                    Notification("Something's missing!",
                            "Please make sure that you selected the user and group! Make sure they are highligthed.",
                            "error");
                } else {
                    DBManager.getDatabaseInstance().adminUpdatesUserGroup(
                            DBManager.getDatabaseInstance()
                                    .getUserGroupIDByName(userGroup.getValue().toString()),
                            DBManager.getDatabaseInstance().getUserIDbyLDAPID(selectedRow.toString()));

                    // log changes in 'user_log' table
                    DBManager.getDatabaseInstance().logEverything(
                            LiferayAndVaadinUtils.getUser().getScreenName(), "Admin edited User Group");

                    Notification("Successfully Updated",
                            "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.",
                            "success");

                }
            } catch (Exception e) {
                Notification("Something's missing!",
                        "Please make sure that you selected the user and group! Make sure they are highligthed.",
                        "error");
            }
            refreshDataSources();
        }
    });

    updateUserRightsAndRoles.addClickListener(new ClickListener() {

        /**
         * 
         */
        private static final long serialVersionUID = -295434651623561492L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                Object selectedRow = ((SingleSelectionModel) usersGrid.getSelectionModel()).getSelectedRow();

                if (selectedRow == null || userDevice.getValue().equals(null)
                        || userRole.getValue().equals(null)) {
                    Notification("Something's missing!",
                            "Please make sure that you selected the user, device and role! Each list has to have one highligthed option.",
                            "error");
                } else {
                    DBManager.getDatabaseInstance().adminUpdatesUserRoleForDevice(
                            DBManager.getDatabaseInstance().getUserRoleIDbyDesc(userRole.getValue().toString()),
                            DBManager.getDatabaseInstance().getUserIDbyLDAPID(
                                    DBManager.getDatabaseInstance().getUserLDAPIDbyID(selectedRow.toString())),
                            DBManager.getDatabaseInstance()
                                    .getDeviceIDByName(userDevice.getValue().toString()));

                    // log changes in 'user_log' table
                    DBManager.getDatabaseInstance().logEverything(
                            LiferayAndVaadinUtils.getUser().getScreenName(),
                            "Admin edited Device, Role, Group");

                    Notification("Successfully Updated",
                            "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.",
                            "success");

                }
            } catch (Exception e) {
                Notification("Something's missing!",
                        "Please make sure that you selected the user, device and role! Each list has to have one highligthed option.",
                        "error");
            }
            refreshDataSources();
        }
    });

    try {
        TableQuery tq = new TableQuery("user", DBManager.getDatabaseInstanceAlternative());
        tq.setVersionColumn("OPTLOCK");
        SQLContainer container = new SQLContainer(tq);

        // System.out.println("Print Container: " + container.size());
        container.setAutoCommit(isEnabled());

        usersGrid = new Grid(container);

        FieldGroup fieldGroup = usersGrid.getEditorFieldGroup();
        fieldGroup.addCommitHandler(new FieldGroup.CommitHandler() {
            /**
             * 
             */
            private static final long serialVersionUID = 3799806709907688919L;

            @Override
            public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {

            }

            @Override
            public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {

                Notification("Successfully Updated",
                        "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.",
                        "success");

                refreshGrid();
            }

            private void refreshGrid() {
                container.refresh();
            }

        });

        usersGrid.addSelectionListener(selectionEvent -> { // Java 8
            // Get selection from the selection model
            Object selected = ((SingleSelectionModel) usersGrid.getSelectionModel()).getSelectedRow();

            if (selected != null) {

                // userDevice.select(bookAdmin.getSelectedTab().getCaption());
                userWorkgroup.select(DBManager.getDatabaseInstance().getUserWorkgroupByUserId(usersGrid
                        .getContainerDataSource().getItem(selected).getItemProperty("user_id").toString()));
                userGroup.select(DBManager.getDatabaseInstance().getUserRoleByUserId(usersGrid
                        .getContainerDataSource().getItem(selected).getItemProperty("user_id").toString()));

                userDevice.addValueChangeListener(new ValueChangeListener() {

                    /**
                     * 
                     */
                    private static final long serialVersionUID = -8696555155016720475L;

                    @Override
                    public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
                        userRole.select(
                                DBManager.getDatabaseInstance().getUserGroupDescriptionByUserID(
                                        usersGrid.getContainerDataSource().getItem(selected)
                                                .getItemProperty("user_id").toString(),
                                        userDevice.getValue().toString()));

                    }
                });

                isAdmin.setValue(DBManager.getDatabaseInstance().hasAdminPanelAccess(usersGrid
                        .getContainerDataSource().getItem(selected).getItemProperty("user_id").toString()));

                Notification.show("Selected "
                        + usersGrid.getContainerDataSource().getItem(selected).getItemProperty("user_id"));
            } else
                Notification.show("Nothing selected");
        });

    } catch (Exception e) {
        // TODO Auto-generated catch block
        Notification("Something went wrong!",
                "Unable to update/connect the database. There may be a connection problem, please check your internet connection settings then try it again.",
                "error");
        e.printStackTrace();
    }

    /*
     * // only admins are allowed to see the admin panel ;) if (!DBManager.getDatabaseInstance()
     * .getUserAdminPanelAccessByLDAPId(LiferayAndVaadinUtils.getUser().getScreenName())
     * .equals("1")) { VerticalLayout errorLayout = new VerticalLayout();
     * infoLabel.setValue("ACCESS DENIED"); errorLayout.addComponent(infoLabel);
     * showErrorNotification( "Access Denied!",
     * "Sorry, you're not allowed to see anything here, at least your username told us so. Do you need assistance? Please contact 'info@qbic.uni-tuebingen.de'."
     * ); setCompositionRoot(errorLayout); return; }
     */

    this.setCaption("User Manager");

    final TabSheet userAdmin = new TabSheet();
    userAdmin.addStyleName(ValoTheme.TABSHEET_FRAMED);
    userAdmin.addTab(usersGrid());
    /*
     * userAdmin.addSelectedTabChangeListener(new SelectedTabChangeListener() {
     * 
     * @Override public void selectedTabChange(SelectedTabChangeEvent event) {
     * 
     * } });
     */

    gridLayout.setWidth("100%");

    // add components to the grid layout
    // gridLayout.addComponent(infoLabel, 0, 0, 3, 0);
    gridLayout.addComponent(userAdmin, 0, 1, 5, 1);
    gridLayout.addComponent(refresh, 0, 2);
    gridLayout.addComponent(isAdmin, 5, 2);
    // gridLayout.addComponent(save);

    gridLayout.addComponent(userWorkgroup, 0, 4);
    gridLayout.addComponent(userDevice, 1, 4);
    gridLayout.addComponent(userRole, 2, 4, 4, 4);
    gridLayout.addComponent(userGroup, 5, 4);
    gridLayout.addComponent(updateUserWorkgroup, 0, 5);
    gridLayout.addComponent(updateUserRightsAndRoles, 1, 5, 4, 5);
    gridLayout.addComponent(updateUserGroup, 5, 5);
    // gridLayout.addComponent(newContainerGrid, 1, 4);

    gridLayout.setSpacing(true);
    gridLayout.setSizeFull();
    setCompositionRoot(gridLayout);

}

From source file:gov.va.ehtac.appsonfhir.ui.HCSLogs.java

public HCSLogs() {
    session = ((HealthElementsTouchKitUI) UI.getCurrent()).getSessionAttributes();
    setCaption("Standards Log Output");
    final VerticalComponentGroup content = new VerticalComponentGroup();

    createTable();//  w  w w  .  j a  v a  2 s .  com

    content.addComponent(logTable);

    Button refresh = new Button();
    refresh.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                logTable.removeAllItems();
                logTable.setContainerDataSource(populateHCSLogs());
                logTable.setColumnReorderingAllowed(true);
                logTable.setColumnCollapsingAllowed(false);
                logTable.setVisibleColumns(new Object[] { "date", "purposeofuse", "resourceType", "id" });
                logTable.setColumnHeaders(new String[] { "Date", "POU", "Resource Requested", "Resource ID" });

            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

    });

    refresh.setImmediate(true);
    refresh.setIcon(FontAwesome.REFRESH);
    setRightComponent(refresh);

    HorizontalButtonGroup hGroup = new HorizontalButtonGroup();
    hGroup.setCaption("Click Button View Std Area");
    hGroup.setWidth("100%");

    Button resourceBtn = new Button("FHIR Resource");
    Button slsRulesExecBtn = new Button("SLS Rules");
    Button slsOutputBtn = new Button("SLS Actions");
    Button ppsRulesExecBtn = new Button("PPS Rules");
    Button ppsOutputBtn = new Button("PPS Actions");
    Button consentBtn = new Button("Consent");
    Button labeledResourceBtn = new Button("HCS Results");

    resourceBtn.setImmediate(true);
    slsRulesExecBtn.setImmediate(true);
    slsOutputBtn.setImmediate(true);
    ppsRulesExecBtn.setImmediate(true);
    ppsOutputBtn.setImmediate(true);
    consentBtn.setImmediate(true);
    labeledResourceBtn.setImmediate(true);

    resourceBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Object rowId = logTable.getValue();
                if (rowId != null) {
                    String obj = (String) logTable.getContainerProperty(rowId, "resource").getValue();
                    Popover popover = getPopoverTextArea(obj, "FHIR Resource");
                    popover.showRelativeTo(getNavigationBar());
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });

    slsRulesExecBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Object rowId = logTable.getValue();
                if (rowId != null) {
                    String obj = (String) logTable.getContainerProperty(rowId, "slsrules").getValue();
                    Popover popover = getPopoverTextArea(obj, "SLS Rules");
                    popover.showRelativeTo(getNavigationBar());
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });

    slsOutputBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Object rowId = logTable.getValue();
                if (rowId != null) {
                    String obj = (String) logTable.getContainerProperty(rowId, "slsresults").getValue();
                    Popover popover = getPopoverTextArea(obj, "SLS Actions");
                    popover.showRelativeTo(getNavigationBar());
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });

    ppsRulesExecBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Object rowId = logTable.getValue();
                if (rowId != null) {
                    String obj = (String) logTable.getContainerProperty(rowId, "ppsrules").getValue();
                    Popover popover = getPopoverTextArea(obj, "PPS Rules");
                    popover.showRelativeTo(getNavigationBar());
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });

    ppsOutputBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Object rowId = logTable.getValue();
                if (rowId != null) {
                    String obj = (String) logTable.getContainerProperty(rowId, "ppsresults").getValue();
                    Popover popover = getPopoverTextArea(obj, "PPS Actions");
                    popover.showRelativeTo(getNavigationBar());
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });

    consentBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Object rowId = logTable.getValue();
                if (rowId != null) {
                    String obj = (String) logTable.getContainerProperty(rowId, "consent").getValue();
                    Popover popover = getPopoverTextArea(obj, "Consent");
                    popover.showRelativeTo(getNavigationBar());
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });

    labeledResourceBtn.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                Object rowId = logTable.getValue();
                if (rowId != null) {
                    String obj = (String) logTable.getContainerProperty(rowId, "labeledresource").getValue();
                    Popover popover = getPopoverTextArea(obj, "HCS Results");
                    popover.showRelativeTo(getNavigationBar());
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });

    hGroup.addComponent(resourceBtn);
    hGroup.addComponent(slsRulesExecBtn);
    hGroup.addComponent(slsOutputBtn);
    hGroup.addComponent(consentBtn);
    hGroup.addComponent(ppsRulesExecBtn);
    hGroup.addComponent(ppsOutputBtn);
    hGroup.addComponent(labeledResourceBtn);
    content.addComponent(hGroup);

    setContent(new CssLayout(content));
}

From source file:gov.va.ehtac.myappsonfhir.ui.FitnessWellness.java

public FitnessWellness() {
    session = ((HealthElementsForPatientTouchKitUI) UI.getCurrent()).getSessionAttributes();
    setCaption("My Health Apps");
    content = new VerticalComponentGroup();
    this.setWidth("100%");
    this.setHeight("100%");

    if (dRequest.equals("chart")) {
        content.addComponent(getChartLayout());
    } else if (dRequest.equals("raw")) {
        content.addComponent(getRawData());
    } else {//from   w w  w. ja  v  a2 s  . com
        //this is a problem
        content.addComponent(new Panel());
    }

    Button refresh = new Button();
    refresh.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            try {
                dRequest = "chart";
                refresh();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

    });

    refresh.setImmediate(true);
    refresh.setIcon(FontAwesome.REFRESH);
    setRightComponent(refresh);

    setContent(new CssLayout(content));

}

From source file:org.eclipse.hawkbit.ui.management.targettable.TargetDetails.java

License:Open Source License

private Button buildRequestAttributesUpdateButton(final String controllerId,
        final boolean isRequestAttributes) {
    final Button requestAttributesUpdateButton = SPUIComponentProvider.getButton(
            UIComponentIdProvider.TARGET_ATTRIBUTES_UPDATE, "", "", "", false, FontAwesome.REFRESH,
            SPUIButtonStyleNoBorder.class);

    requestAttributesUpdateButton// w  w  w.  j a  v a2 s  .  co m
            .addClickListener(e -> targetManagement.requestControllerAttributes(controllerId));

    if (isRequestAttributes) {
        requestAttributesUpdateButton
                .setDescription(getI18n().getMessage("tooltip.target.attributes.update.requested"));
        requestAttributesUpdateButton.setEnabled(false);
    } else {
        requestAttributesUpdateButton
                .setDescription(getI18n().getMessage("tooltip.target.attributes.update.request"));
        requestAttributesUpdateButton.setEnabled(true);
    }

    return requestAttributesUpdateButton;
}