Example usage for com.vaadin.ui Button setIcon

List of usage examples for com.vaadin.ui Button setIcon

Introduction

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

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

From source file:com.esspl.datagen.ui.TableDataView.java

License:Open Source License

public TableDataView(final JdbcTable table, final Connection connection, final DataGenApplication dataApp) {
    log.debug("TableDataView - constructor start");
    setCaption("Data");
    dataGenApplication = dataApp;//ww  w  .j ava2  s  . com
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    setCompositionRoot(vl);

    HorizontalLayout hBar = new HorizontalLayout();
    hBar.setWidth("98%");
    hBar.setHeight("40px");

    rows = new TextField();
    rows.setWidth("50px");
    rows.setImmediate(true);
    rows.addValidator(new IntegerValidator("Rows must be an Integer"));
    Label lbl = new Label("Generate ");

    content = new HorizontalLayout();
    content.setHeight("40px");
    content.setMargin(false, false, false, true);
    content.setSpacing(true);
    content.addComponent(lbl);
    content.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER);
    content.addComponent(rows);
    content.setComponentAlignment(rows, Alignment.MIDDLE_CENTER);

    Button addDataButton = new Button("Row(S) Data", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("TableDataView - Generate Data Button clicked");
            populateGenerator(table);
        }
    });
    addDataButton.addStyleName("small");
    addDataButton.setIcon(DataGenConstant.ADD_SMALL);
    content.addComponent(addDataButton);
    content.setComponentAlignment(addDataButton, Alignment.MIDDLE_CENTER);

    Button refreshButton = new Button("Refresh", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("TableDataView - Refresh Button clicked");
            refreshDataView(table, connection);
        }
    });
    refreshButton.addStyleName("small");
    refreshButton.setIcon(DataGenConstant.RESET);
    content.addComponent(refreshButton);
    content.setComponentAlignment(refreshButton, Alignment.MIDDLE_CENTER);

    //Tapas:10/08/2012 - Export feature implementation started
    HorizontalLayout expContainer = new HorizontalLayout();
    expContainer.setSpacing(true);

    PopupButton exportButton = new PopupButton("Export");
    exportButton.setComponent(new DataExportView());
    exportButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //dataApp.getMainWindow().showNotification("Export Button clicked!");
        }
    });
    exportButton.setIcon(DataGenConstant.DATAEXPORT_ICON);
    expContainer.addComponent(exportButton);
    expContainer.setComponentAlignment(exportButton, Alignment.MIDDLE_LEFT);

    //Tapas:10/08/2012 - Import feature implementation started
    PopupButton importButton = new PopupButton("Import");
    importButton.setComponent(new DataImportView());
    importButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //dataApp.getMainWindow().showNotification("Import Button clicked!");
        }
    });
    importButton.setIcon(DataGenConstant.DATAIMPORT_ICON);
    expContainer.addComponent(importButton);
    expContainer.setComponentAlignment(importButton, Alignment.MIDDLE_RIGHT);

    tableContainer = new VerticalLayout();
    tableContainer.setSizeFull();
    hBar.addComponent(content);
    hBar.setComponentAlignment(content, Alignment.MIDDLE_LEFT);
    hBar.addComponent(expContainer);
    hBar.setComponentAlignment(expContainer, Alignment.MIDDLE_RIGHT);
    vl.addComponent(hBar);
    vl.addComponent(tableContainer);
    vl.setExpandRatio(tableContainer, 1f);

    refreshDataView(table, connection);
    log.debug("TableDataView - constructor end");
}

From source file:com.esspl.datagen.ui.ToolBar.java

License:Open Source License

public ToolBar(final DataGenApplication dataGenApplication) {
    log.debug("ToolBar constructor start");
    List<ConnectionProfile> profileList = SettingsManager.get().getConfiguration().getProfiles();
    profiles = new Select(null, new BeanItemContainer<ConnectionProfile>(ConnectionProfile.class, profileList));
    profiles.setImmediate(true);//from  w  ww  .j a v  a2 s .c o m
    profiles.setNewItemsAllowed(false);
    profiles.setNullSelectionAllowed(false);
    addComponent(profiles);
    setComponentAlignment(profiles, Alignment.MIDDLE_RIGHT);
    setStyleName("toolbar");
    setSpacing(true);

    //Connect button
    connect = new Button("Connect", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("ToolBar - Connect button clicked");
            ConnectionProfile cp = (ConnectionProfile) profiles.getValue();
            if (cp == null) {
                getApplication().getMainWindow().showNotification("Select a Connection profile to connect.",
                        Notification.TYPE_ERROR_MESSAGE);
                return;
            }
            try {
                dataGenApplication.databaseSessionManager.connect(cp);
            } catch (Exception ex) {
                getApplication().getMainWindow().showNotification("Failed to connect<br/>", ex.getMessage(),
                        Notification.TYPE_ERROR_MESSAGE);
                return;
            }
            profiles.setVisible(false);
            connect.setVisible(false);
            disConnect.setVisible(true);
            dataGenApplication.connectedString.setVisible(true);
            dataGenApplication.connectedString.setValue("Connected to - " + cp.getName());
            boolean isExplorerSelected = dataGenApplication.tabSheet.getSelectedTab() instanceof ExplorerView;
            dataGenApplication.tabSheet.removeComponent(dataGenApplication.explorer);
            dataGenApplication.explorer = new ExplorerView(dataGenApplication,
                    dataGenApplication.databaseSessionManager);
            dataGenApplication.tabSheet.addTab(dataGenApplication.explorer, "Explorer",
                    DataGenConstant.EXPLORER_ICON, 2);
            if (isExplorerSelected) {
                dataGenApplication.tabSheet.setSelectedTab(dataGenApplication.explorer);
            }
        }
    });
    connect.setIcon(DataGenConstant.DB_CONNECT_ICON);
    addComponent(connect);
    setComponentAlignment(connect, Alignment.MIDDLE_RIGHT);

    //Disconnect button
    disConnect = new Button("Disconnect", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("ToolBar - Disconnect button clicked");
            dataGenApplication.databaseSessionManager.disconnect();
            profiles.setVisible(true);
            connect.setVisible(true);
            disConnect.setVisible(false);
            dataGenApplication.connectedString.setVisible(false);
            dataGenApplication.connectedString.setValue("");
            boolean isExplorerSelected = dataGenApplication.tabSheet.getSelectedTab() instanceof ExplorerView;
            dataGenApplication.tabSheet.removeComponent(dataGenApplication.explorer);
            dataGenApplication.explorer = new ExplorerView(dataGenApplication,
                    dataGenApplication.databaseSessionManager);
            dataGenApplication.tabSheet.addTab(dataGenApplication.explorer, "Explorer",
                    DataGenConstant.EXPLORER_ICON, 2);
            if (isExplorerSelected) {
                dataGenApplication.tabSheet.setSelectedTab(dataGenApplication.explorer);
            }
        }
    });
    disConnect.setIcon(DataGenConstant.DB_DISCONNECT_ICON);
    disConnect.setVisible(false);
    addComponent(disConnect);
    setComponentAlignment(disConnect, Alignment.MIDDLE_RIGHT);

    //Settings button
    Button settings = new Button("Settings", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("ToolBar - Settings button clicked");
            SettingsView settingsManagerView = new SettingsView(dataGenApplication);
            getWindow().addWindow(settingsManagerView);
        }
    });
    settings.setIcon(DataGenConstant.DB_SETTING_ICON);
    addComponent(settings);
    setComponentAlignment(settings, Alignment.MIDDLE_RIGHT);

    //Reload button
    Button reset = new Button("Reset", new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("ToolBar - Reset button clicked");
            dataGenApplication.getMainWindow().getApplication().close();
        }
    });
    reset.setIcon(DataGenConstant.RESET);
    addComponent(reset);
    setComponentAlignment(reset, Alignment.MIDDLE_RIGHT);
    log.debug("ToolBar constructor end");
}

From source file:com.etest.view.notification.NotificationMainUI.java

Table populateNoficationTable() {
    notificationTable.removeAllItems();/*  ww  w. j av  a2  s .co m*/
    int i = 0;
    for (EtestNotification en : ns.getAllNotificationByUser(
            CommonUtilities.convertStringToInt(VaadinSession.getCurrent().getAttribute("userId").toString()))) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button read = new Button();
        read.setWidthUndefined();
        read.setCaption((en.getStatus() == 0) ? "unread" : "read");
        read.setData(en.getNotificationId());
        read.setIcon(FontAwesome.VIDEO_CAMERA);
        read.addStyleName(ValoTheme.BUTTON_LINK);
        read.addStyleName(ValoTheme.BUTTON_TINY);
        read.addStyleName(ValoTheme.BUTTON_QUIET);
        read.addStyleName("button-container");
        read.addClickListener(buttonClickListener);
        v.addComponent(read);
        v.setComponentAlignment(read, Alignment.MIDDLE_LEFT);

        message.setContentMode(ContentMode.HTML);

        String[] split = en.getNotice().split(" ");
        int cellCaseId;
        if (split[0].equals("CellCaseID")) {
            message.setCaption(en.getRemarks() + en.getNotice());
            cellCaseId = CommonUtilities.convertStringToInt(split[1].replace("#", ""));
        } else {
            cellCaseId = cis.getCellItemById(CommonUtilities.convertStringToInt(split[1].replace("#", "")))
                    .getCellCaseId();
            message.setCaption(en.getRemarks() + en.getNotice() + " from CellCaseID #" + cellCaseId);
        }

        Button approve = new Button("status");
        approve.setSizeFull();
        approve.addStyleName(ValoTheme.BUTTON_LINK);
        approve.addStyleName(ValoTheme.BUTTON_TINY);
        approve.addStyleName(ValoTheme.BUTTON_QUIET);
        approve.addStyleName("button-container");
        v.addComponent(approve);
        v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT);

        if (ccs.getCellCaseById(cellCaseId).getApprovalStatus() == 0) {
            approve.setIcon(FontAwesome.THUMBS_DOWN);
        } else {
            approve.setIcon(FontAwesome.THUMBS_UP);
        }

        notificationTable.addItem(new Object[] { message.getCaption().toString(),
                ss.getUsernameById(en.getSenderId()), en.getNoteDate(), v }, i);
        i++;
    }
    notificationTable.setPageLength(0);
    notificationTable.setHeight("100%");

    return notificationTable;
}

From source file:com.etest.view.systemadministration.curriculum.CurriculumFormWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setMargin(true);//from  w w w .ja va 2 s  . c om

    yearLevel.setWidth("75%");
    form.addComponent(yearLevel);

    subjectField.setWidth("75%");
    form.addComponent(subjectField);

    normCourseOffering.setWidth("75%");
    form.addComponent(normCourseOffering);

    descriptiveTitleField.setWidth("100%");
    descriptiveTitleField.setRows(3);
    descriptiveTitleField.setInputPrompt("Descriptive Title..");
    form.addComponent(descriptiveTitleField);

    Button save = new Button("SAVE");
    save.setWidth("100%");
    save.setIcon(FontAwesome.SAVE);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addStyleName(ValoTheme.BUTTON_SMALL);
    save.addClickListener(buttonClickListener);

    Button update = new Button("UPDATE");
    update.setWidth("100%");
    update.setIcon(FontAwesome.ADJUST);
    update.addStyleName(ValoTheme.BUTTON_PRIMARY);
    update.addStyleName(ValoTheme.BUTTON_SMALL);
    update.addClickListener(buttonClickListener);

    Button delete = new Button("DELETE");
    delete.setWidth("100%");
    delete.setIcon(FontAwesome.ERASER);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.addClickListener(buttonClickListener);

    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.setWidth("100%");
    hlayout.setSpacing(true);

    if (getCurriculumId() != 0) {
        hlayout.addComponent(update);
        hlayout.addComponent(delete);
        Curriculum c = cs.getCurriculumById(getCurriculumId());
        yearLevel.setValue(c.getYearLevel());
        subjectField.setValue(c.getSubject());
        normCourseOffering.setValue(c.getNormCourseOffering());
        descriptiveTitleField.setValue(c.getDescriptiveTitle());

        if (getButtonCaption().equals("edit")) {
            delete.setVisible(false);
        } else {
            update.setVisible(false);
        }
    } else {
        hlayout.addComponent(save);
    }

    form.addComponent(hlayout);

    return form;
}

From source file:com.etest.view.systemadministration.CurriculumMainUI.java

public CurriculumMainUI() {
    setSizeFull();/*  w w  w  .j a  v  a2 s  . com*/
    setMargin(true);
    setSpacing(true);

    //        addComponent(buildForms());
    //        populateDataGrid();

    Button newBtn = new Button("ADD NEW CURRICULUM");
    newBtn.setWidth("220px");
    newBtn.setIcon(FontAwesome.OPENID);
    newBtn.addStyleName(ValoTheme.BUTTON_LINK);
    newBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    newBtn.addClickListener(buttonClickListener);

    addComponent(newBtn);
    addComponent(dataGridPanel());
}

From source file:com.etest.view.systemadministration.CurriculumMainUI.java

Table populateDataTable() {
    table.removeAllItems();/* w w  w. j  av  a  2s  .c  om*/
    int i = 0;
    for (Curriculum c : cs.getAllCurriculum()) {
        HorizontalLayout h = new HorizontalLayout();
        h.setWidth("100%");

        Button edit = new Button("edit");
        edit.setSizeFull();
        edit.setIcon(FontAwesome.PENCIL);
        edit.setData(c.getCurriculumId());
        edit.addStyleName(ValoTheme.BUTTON_LINK);
        edit.addStyleName(ValoTheme.BUTTON_TINY);
        edit.addStyleName("button-container");
        edit.addClickListener(buttonClickListener);
        h.addComponent(edit);

        Button delete = new Button("del");
        delete.setSizeFull();
        delete.setIcon(FontAwesome.TRASH_O);
        delete.setData(c.getCurriculumId());
        delete.addStyleName(ValoTheme.BUTTON_LINK);
        delete.addStyleName(ValoTheme.BUTTON_TINY);
        delete.addStyleName("button-container");
        delete.addClickListener(buttonClickListener);
        h.addComponent(delete);

        table.addItem(new Object[] {
                //                c.getCurriculumId(),
                CommonVariableMap.getYearLevel(c.getYearLevel()), c.getSubject(), c.getDescriptiveTitle(),
                CommonVariableMap.getNormCourseOffering(c.getNormCourseOffering()), h }, i);
        i++;
    }
    table.setPageLength(table.size());

    //        table.getListeners(ItemClickEvent.class).stream().forEach((listener) -> {
    //            table.removeListener(ItemClickEvent.class, listener);
    //        });
    //        
    //        table.addItemClickListener((ItemClickEvent event) -> {
    //            Property itemProperty = event.getItem().getItemProperty("id");
    //            
    //            Window sub = new CurriculumFormWindow(CommonUtilities.convertStringToInt(itemProperty.getValue().toString()));
    //            if(sub.getParent() == null){
    //                UI.getCurrent().addWindow(sub);
    //            }
    //            sub.addCloseListener((Window.CloseEvent e) -> {
    //                populateDataTable();
    //            });
    //        });

    return table;
}

From source file:com.etest.view.systemadministration.FacultyMainUI.java

public FacultyMainUI() {
    setSizeFull();// w w  w . j  a v  a 2 s  .c  om
    setSpacing(true);
    setMargin(true);

    Button formBtn = new Button("NEW FACULTY FORM");
    formBtn.setWidth("230px");
    formBtn.setIcon(FontAwesome.OPENID);
    formBtn.addStyleName(ValoTheme.BUTTON_LINK);
    formBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    formBtn.addClickListener(formBtnClickListener);
    addComponent(formBtn);

    addComponent(getDataTablePanel());
}

From source file:com.etest.view.systemadministration.FacultyMainUI.java

Table populateDataTable() {
    table.removeAllItems();//www  .ja  va2  s. com
    int i = 0;
    for (Users u : fs.getAllFaculty()) {
        HorizontalLayout hlayout = new HorizontalLayout();
        hlayout.setWidth("100%");

        Button edit = new Button("edit");
        edit.setWidth("100%");
        edit.setData(u.getFacultyId());
        edit.setIcon(FontAwesome.PENCIL);
        edit.addStyleName(ValoTheme.BUTTON_LINK);
        edit.addStyleName(ValoTheme.BUTTON_TINY);
        edit.addStyleName("button-container");
        edit.addClickListener(modifyBtnClickListener);
        hlayout.addComponent(edit);

        Button delete = new Button("del");
        delete.setWidth("100%");
        delete.setData(u.getFacultyId());
        delete.setIcon(FontAwesome.TRASH_O);
        delete.addStyleName(ValoTheme.BUTTON_LINK);
        delete.addStyleName(ValoTheme.BUTTON_TINY);
        delete.addStyleName("button-container");
        delete.addClickListener(modifyBtnClickListener);
        hlayout.addComponent(delete);

        table.addItem(new Object[] { u.getName().toUpperCase(), u.getUsername_(), u.getUserType(), hlayout },
                new Integer(i));
        i++;
    }
    table.setPageLength(table.size());

    //        table.getListeners(ItemClickEvent.class).stream().forEach((listener) -> {
    //            table.removeListener(ItemClickEvent.class, listener);
    //        });

    //        table.addItemClickListener((ItemClickEvent event) -> {
    //            Property itemProperty = event.getItem().getItemProperty("name");
    //            facultyId = fs.getFacultyIdByName(itemProperty.getValue().toString());
    //            
    //            Window sub = new FacultyFormWindow(facultyId);
    //            if(sub.getParent() == null){
    //                UI.getCurrent().addWindow(sub);
    //            }
    //        });

    return table;
}

From source file:com.etest.view.systemadministration.HousekeepingMainUI.java

Table populateDataTable() {
    table.removeAllItems();/*from   www.j a v a2  s .  c  o m*/
    int i = 0;
    for (CellItem ci : hs.getAllItemsFromArchive()) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button recycle = new Button("recycle");
        recycle.setWidthUndefined();
        recycle.setData(ci.getCellItemId());
        recycle.setIcon(FontAwesome.RECYCLE);
        recycle.addStyleName(ValoTheme.BUTTON_LINK);
        recycle.addStyleName(ValoTheme.BUTTON_TINY);
        recycle.addStyleName(ValoTheme.BUTTON_QUIET);
        recycle.addStyleName("button-container");
        v.addComponent(recycle);
        v.setComponentAlignment(recycle, Alignment.MIDDLE_LEFT);

        Button view = new Button("view");
        view.setWidthUndefined();
        view.setData(ci.getCellItemId());
        view.setIcon(FontAwesome.COFFEE);
        view.addStyleName(ValoTheme.BUTTON_LINK);
        view.addStyleName(ValoTheme.BUTTON_TINY);
        view.addStyleName(ValoTheme.BUTTON_QUIET);
        view.addStyleName("button-container");
        view.addClickListener(buttonClickListener);
        v.addComponent(view);
        v.setComponentAlignment(view, Alignment.MIDDLE_LEFT);

        table.addItem(new Object[] { ci.getCellItemId(), ci.getItem(), v }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}

From source file:com.etest.view.systemadministration.SemestralTeam.AddSemestralTeamMembersWindow.java

Table populateDataTable() {
    table.removeAllItems();// w  ww  .j a  v  a2  s  .  c  o  m
    int i = 0;
    for (TeamTeach tt : tts.getAllMembersFromTeam(getTeamTeachId())) {
        String position;
        boolean isFacultyTeamLeader = tts.isFacultyTeamLeader(getTeamTeachId(), tt.getFacultyId());
        if (isFacultyTeamLeader) {
            position = "Team Leader";
        } else {
            position = "Member";
        }

        HorizontalLayout hlayout = new HorizontalLayout();
        hlayout.setWidth("100%");

        Button editPositionBtn = new Button("edit");
        editPositionBtn.setWidthUndefined();
        editPositionBtn.setData(tt.getFacultyId());
        editPositionBtn.setIcon(FontAwesome.EDIT);
        editPositionBtn.addStyleName(ValoTheme.BUTTON_LINK);
        editPositionBtn.addStyleName(ValoTheme.BUTTON_TINY);
        editPositionBtn.addClickListener(modifyBtnClickListener);
        hlayout.addComponent(editPositionBtn);

        Button removeMemberBtn = new Button("del");
        removeMemberBtn.setWidthUndefined();
        removeMemberBtn.setData(tt.getFacultyId());
        removeMemberBtn.setIcon(FontAwesome.TRASH_O);
        removeMemberBtn.addStyleName(ValoTheme.BUTTON_LINK);
        removeMemberBtn.addStyleName(ValoTheme.BUTTON_TINY);
        removeMemberBtn.addClickListener(modifyBtnClickListener);
        hlayout.addComponent(removeMemberBtn);

        if (!position.equals("Member")) {
            editPositionBtn.setEnabled(false);
            removeMemberBtn.setEnabled(false);
        }

        table.addItem(new Object[] { tt.getFacultyId(), tt.getName(), position, hlayout }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}