Search in sources :

Example 1 with OneClickButton

use of fr.univlorraine.ecandidat.vaadin.components.OneClickButton in project esup-ecandidat by EsupPortail.

the class AdminCacheView method init.

/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setSizeFull();
    setMargin(true);
    setSpacing(true);
    /* Titre */
    Label titleNom = new Label(applicationContext.getMessage("adminCacheView.title", null, UI.getCurrent().getLocale()));
    titleNom.addStyleName(StyleConstants.VIEW_TITLE);
    addComponent(titleNom);
    /*Label*/
    CustomPanel cp = new CustomPanel(applicationContext.getMessage("cache.panel.caption", null, UI.getCurrent().getLocale()), applicationContext.getMessage("cache.panel.label", null, UI.getCurrent().getLocale()), FontAwesome.WARNING);
    cp.setMargin(true);
    addComponent(cp);
    /*Reload ALL*/
    OneClickButton button = new OneClickButton(applicationContext.getMessage("cache.action.btn.all", null, UI.getCurrent().getLocale()), FontAwesome.REFRESH);
    button.addClickListener(e -> {
        cacheController.askToReloadData(null);
        reloadContainer();
    });
    addComponent(button);
    cacheTable.addGeneratedColumn(SimpleTablePresentation.CHAMPS_ACTION, new ColumnGenerator() {

        private static final long serialVersionUID = 7461290324017459118L;

        @Override
        public Object generateCell(Table source, Object itemId, Object columnId) {
            final SimpleTablePresentation bean = (SimpleTablePresentation) itemId;
            OneClickButton button = new OneClickButton(applicationContext.getMessage("cache.action.btn", null, UI.getCurrent().getLocale()), FontAwesome.REFRESH);
            button.addClickListener(e -> {
                cacheController.askToReloadData(bean.getCode());
                reloadContainer();
            });
            return button;
        }
    });
    cacheTable.setVisibleColumns((Object[]) FIELDS_ORDER);
    for (String fieldName : FIELDS_ORDER) {
        cacheTable.setColumnHeader(fieldName, applicationContext.getMessage("cache." + fieldName, null, UI.getCurrent().getLocale()));
    }
    cacheTable.setSortContainerPropertyId(SimpleTablePresentation.CHAMPS_TITLE);
    cacheTable.setColumnCollapsingAllowed(false);
    cacheTable.setColumnReorderingAllowed(false);
    cacheTable.setSelectable(false);
    cacheTable.setImmediate(true);
    cacheTable.setCellStyleGenerator((components, itemId, columnId) -> {
        if (columnId != null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)) {
            return (ValoTheme.LABEL_BOLD);
        }
        return null;
    });
    cacheTable.setSizeFull();
    addComponent(cacheTable);
    setExpandRatio(cacheTable, 1);
}
Also used : ValoTheme(com.vaadin.ui.themes.ValoTheme) SimpleTablePresentation(fr.univlorraine.ecandidat.utils.bean.presentation.SimpleTablePresentation) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) ConstanteUtils(fr.univlorraine.ecandidat.utils.ConstanteUtils) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) VerticalLayout(com.vaadin.ui.VerticalLayout) Resource(javax.annotation.Resource) UI(com.vaadin.ui.UI) StyleConstants(fr.univlorraine.ecandidat.StyleConstants) ApplicationContext(org.springframework.context.ApplicationContext) BeanItemContainer(com.vaadin.data.util.BeanItemContainer) CustomPanel(fr.univlorraine.ecandidat.vaadin.components.CustomPanel) FontAwesome(com.vaadin.server.FontAwesome) Table(com.vaadin.ui.Table) CacheController(fr.univlorraine.ecandidat.controllers.CacheController) Label(com.vaadin.ui.Label) PostConstruct(javax.annotation.PostConstruct) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) TableFormating(fr.univlorraine.ecandidat.vaadin.components.TableFormating) View(com.vaadin.navigator.View) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) SpringView(com.vaadin.spring.annotation.SpringView) Table(com.vaadin.ui.Table) SimpleTablePresentation(fr.univlorraine.ecandidat.utils.bean.presentation.SimpleTablePresentation) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) Label(com.vaadin.ui.Label) CustomPanel(fr.univlorraine.ecandidat.vaadin.components.CustomPanel) PostConstruct(javax.annotation.PostConstruct)

Example 2 with OneClickButton

use of fr.univlorraine.ecandidat.vaadin.components.OneClickButton in project esup-ecandidat by EsupPortail.

the class AdminVersionView method init.

/**
 * Initialise la vue
 */
@PostConstruct
public void init() {
    /* Style */
    setSizeFull();
    setMargin(true);
    setSpacing(true);
    /* Titre */
    final Label titleNom = new Label(applicationContext.getMessage("adminVersionView.title", null, UI.getCurrent().getLocale()));
    titleNom.addStyleName(StyleConstants.VIEW_TITLE);
    addComponent(titleNom);
    versionTable.addGeneratedColumn(SimpleTablePresentation.CHAMPS_ACTION, new ColumnGenerator() {

        private static final long serialVersionUID = 7461290324017459118L;

        @Override
        public Object generateCell(final Table source, final Object itemId, final Object columnId) {
            final SimpleTablePresentation bean = (SimpleTablePresentation) itemId;
            final OneClickButton btnCheck = new OneClickButton(applicationContext.getMessage("btnCheck", null, UI.getCurrent().getLocale()), FontAwesome.ROTATE_RIGHT);
            switch(bean.getCode()) {
                case NomenclatureUtils.VERSION_DEMAT:
                    btnCheck.addClickListener(e -> {
                        fileController.testDemat(true);
                    });
                    return btnCheck;
                case NomenclatureUtils.VERSION_SI_SCOL_COD:
                    btnCheck.addClickListener(e -> {
                        siScolController.testSiScolConnnexion();
                    });
                    return btnCheck;
                case NomenclatureUtils.VERSION_WS:
                    btnCheck.addClickListener(e -> {
                        siScolController.testWSSiScolConnnexion();
                    });
                    return btnCheck;
                case NomenclatureUtils.VERSION_WS_PJ:
                    btnCheck.addClickListener(e -> {
                        if (demoController.getDemoMode()) {
                            return;
                        }
                        final AdminWsPjWindow window = new AdminWsPjWindow();
                        UI.getCurrent().addWindow(window);
                    });
                    return btnCheck;
                case NomenclatureUtils.VERSION_LS:
                    btnCheck.addClickListener(e -> {
                        formulaireController.testConnexionLS();
                    });
                    return btnCheck;
                case NomenclatureUtils.VERSION_INES:
                    btnCheck.addClickListener(e -> {
                        final AdminInesWindow window = new AdminInesWindow();
                        UI.getCurrent().addWindow(window);
                    });
                    return btnCheck;
                default:
                    return null;
            }
        }
    });
    versionTable.setVisibleColumns((Object[]) FIELDS_ORDER);
    for (final String fieldName : FIELDS_ORDER) {
        versionTable.setColumnHeader(fieldName, applicationContext.getMessage("version." + fieldName, null, UI.getCurrent().getLocale()));
    }
    versionTable.setSortContainerPropertyId(SimpleTablePresentation.CHAMPS_ORDER);
    versionTable.setColumnCollapsingAllowed(false);
    versionTable.setColumnReorderingAllowed(false);
    versionTable.setSelectable(false);
    versionTable.setImmediate(true);
    versionTable.setColumnWidth(SimpleTablePresentation.CHAMPS_TITLE, 300);
    versionTable.setCellStyleGenerator((components, itemId, columnId) -> {
        if (columnId != null && columnId.equals(SimpleTablePresentation.CHAMPS_TITLE)) {
            return (ValoTheme.LABEL_BOLD);
        }
        return null;
    });
    addComponent(versionTable);
    setExpandRatio(versionTable, 1);
}
Also used : FormulaireController(fr.univlorraine.ecandidat.controllers.FormulaireController) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) VerticalLayout(com.vaadin.ui.VerticalLayout) UI(com.vaadin.ui.UI) SiScolController(fr.univlorraine.ecandidat.controllers.SiScolController) DemoController(fr.univlorraine.ecandidat.controllers.DemoController) AdminInesWindow(fr.univlorraine.ecandidat.views.windows.AdminInesWindow) FontAwesome(com.vaadin.server.FontAwesome) NomenclatureUtils(fr.univlorraine.ecandidat.utils.NomenclatureUtils) Label(com.vaadin.ui.Label) ViewChangeEvent(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent) NomenclatureController(fr.univlorraine.ecandidat.controllers.NomenclatureController) SpringView(com.vaadin.spring.annotation.SpringView) ValoTheme(com.vaadin.ui.themes.ValoTheme) SimpleTablePresentation(fr.univlorraine.ecandidat.utils.bean.presentation.SimpleTablePresentation) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) ConstanteUtils(fr.univlorraine.ecandidat.utils.ConstanteUtils) Resource(javax.annotation.Resource) StyleConstants(fr.univlorraine.ecandidat.StyleConstants) FileController(fr.univlorraine.ecandidat.controllers.FileController) AdminWsPjWindow(fr.univlorraine.ecandidat.views.windows.AdminWsPjWindow) ApplicationContext(org.springframework.context.ApplicationContext) BeanItemContainer(com.vaadin.data.util.BeanItemContainer) List(java.util.List) Table(com.vaadin.ui.Table) PostConstruct(javax.annotation.PostConstruct) TableFormating(fr.univlorraine.ecandidat.vaadin.components.TableFormating) View(com.vaadin.navigator.View) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) Table(com.vaadin.ui.Table) SimpleTablePresentation(fr.univlorraine.ecandidat.utils.bean.presentation.SimpleTablePresentation) AdminInesWindow(fr.univlorraine.ecandidat.views.windows.AdminInesWindow) ColumnGenerator(com.vaadin.ui.Table.ColumnGenerator) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) Label(com.vaadin.ui.Label) AdminWsPjWindow(fr.univlorraine.ecandidat.views.windows.AdminWsPjWindow) PostConstruct(javax.annotation.PostConstruct)

Example 3 with OneClickButton

use of fr.univlorraine.ecandidat.vaadin.components.OneClickButton in project esup-ecandidat by EsupPortail.

the class AssistanceView method getButton.

/**
 * @param  caption
 * @param  bwo
 * @param  icon
 * @return         un bouton pour l'assistance
 */
private OneClickButton getButton(final String caption, final String bwo, final com.vaadin.server.Resource icon) {
    final BrowserWindowOpener browser = new BrowserWindowOpener(new ExternalResource(bwo));
    final OneClickButton btn = new OneClickButton(caption, icon);
    btn.addStyleName(ValoTheme.BUTTON_LINK);
    browser.extend(btn);
    return btn;
}
Also used : BrowserWindowOpener(com.vaadin.server.BrowserWindowOpener) OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) ExternalResource(com.vaadin.server.ExternalResource)

Example 4 with OneClickButton

use of fr.univlorraine.ecandidat.vaadin.components.OneClickButton in project esup-ecandidat by EsupPortail.

the class I18nField method getLangueLayout.

/**
 * Renvoie un layout contenant un choix de langue et une traduction
 *
 * @param traductionOther
 * @return le layout
 */
private HorizontalLayout getLangueLayout(final I18nTraduction traductionOther) {
    /* Le layout renvoyé */
    HorizontalLayout hlLangueOther = new HorizontalLayout();
    listLayoutTraductions.add(hlLangueOther);
    hlLangueOther.setSpacing(true);
    hlLangueOther.setWidth(100, Unit.PERCENTAGE);
    /* La combobox avec les icones de drapeaux */
    ComboBoxLangue cbLangue = new ComboBoxLangue(listeLangueEnService, false);
    cbLangue.selectLangue((traductionOther == null ? null : traductionOther.getLangue()));
    cbLangue.setWidth(75, Unit.PIXELS);
    hlLangueOther.addComponent(cbLangue);
    /* Le textField... ou */
    AbstractField<String> tfValOther = getNewValueComponent();
    tfValOther.setWidth(100, Unit.PERCENTAGE);
    if (traductionOther != null) {
        tfValOther.setValue(traductionOther.getValTrad());
    }
    hlLangueOther.addComponent(tfValOther);
    hlLangueOther.setExpandRatio(tfValOther, 1);
    /* Le bouton de suppression de la langue */
    OneClickButton removeLangue = new OneClickButton(FontAwesome.MINUS_SQUARE_O);
    removeLangue.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    removeLangue.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    removeLangue.addClickListener(e -> {
        layoutLangue.removeComponent(hlLangueOther);
        listLayoutTraductions.remove(hlLangueOther);
        checkVisibleAddLangue();
        centerWindow();
    });
    hlLangueOther.addComponent(removeLangue);
    return hlLangueOther;
}
Also used : OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) ComboBoxLangue(fr.univlorraine.ecandidat.vaadin.form.combo.ComboBoxLangue) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 5 with OneClickButton

use of fr.univlorraine.ecandidat.vaadin.components.OneClickButton in project esup-ecandidat by EsupPortail.

the class MainUI method focusCurrentMenu.

/**
 * Focus le menu courant
 * @param viewName
 */
private void focusCurrentMenu(final String viewName) {
    if (viewName != null) {
        final Menu menu = viewButtons.get(viewName);
        if (menu != null && menu.getBtn() instanceof OneClickButton) {
            menu.getBtn().addStyleName(SELECTED_ITEM);
            menu.getBtn().focus();
        }
    }
}
Also used : OneClickButton(fr.univlorraine.ecandidat.vaadin.components.OneClickButton) AccordionMenu(fr.univlorraine.ecandidat.vaadin.menu.AccordionMenu) Menu(fr.univlorraine.ecandidat.vaadin.menu.Menu) AccordionItemMenu(fr.univlorraine.ecandidat.vaadin.menu.AccordionItemMenu) SubMenu(fr.univlorraine.ecandidat.vaadin.menu.SubMenu)

Aggregations

OneClickButton (fr.univlorraine.ecandidat.vaadin.components.OneClickButton)48 PostConstruct (javax.annotation.PostConstruct)31 Label (com.vaadin.ui.Label)28 HorizontalLayout (com.vaadin.ui.HorizontalLayout)23 Table (com.vaadin.ui.Table)15 ColumnGenerator (com.vaadin.ui.Table.ColumnGenerator)15 BeanItemContainer (com.vaadin.data.util.BeanItemContainer)13 VerticalLayout (com.vaadin.ui.VerticalLayout)13 FontAwesome (com.vaadin.server.FontAwesome)9 UI (com.vaadin.ui.UI)8 ValoTheme (com.vaadin.ui.themes.ValoTheme)8 StyleConstants (fr.univlorraine.ecandidat.StyleConstants)8 ConstanteUtils (fr.univlorraine.ecandidat.utils.ConstanteUtils)8 TableFormating (fr.univlorraine.ecandidat.vaadin.components.TableFormating)8 List (java.util.List)8 Resource (javax.annotation.Resource)8 OnDemandFile (fr.univlorraine.ecandidat.vaadin.components.OnDemandFile)7 OnDemandStreamFile (fr.univlorraine.ecandidat.vaadin.components.OnDemandFileUtils.OnDemandStreamFile)7 ApplicationContext (org.springframework.context.ApplicationContext)7 View (com.vaadin.navigator.View)5