Search in sources :

Example 1 with CmsInfoButton

use of org.opencms.ui.components.CmsInfoButton in project opencms-core by alkacon.

the class CmsCacheViewApp method getImageStatisticButton.

/**
 * Creates in info button for image cache statistics.<p>
 *
 * @return CmsInfoButton
 */
protected static CmsInfoButton getImageStatisticButton() {
    long size = 0L;
    if (new File(CmsImageLoader.getImageRepositoryPath()).exists()) {
        size = FileUtils.sizeOfDirectory(new File(CmsImageLoader.getImageRepositoryPath()));
    }
    Map<String, String> infoMap = new LinkedHashMap<String, String>();
    infoMap.put(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_IMAGECACHE_LABEL_MEMORY_BLOCK_0), CmsFileUtil.formatFilesize(size, A_CmsUI.getCmsObject().getRequestContext().getLocale()));
    CmsInfoButton info = new CmsInfoButton(infoMap);
    info.setWindowCaption(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_IMAGE_0));
    info.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_IMAGE_0));
    return info;
}
Also used : File(java.io.File) LinkedHashMap(java.util.LinkedHashMap) CmsInfoButton(org.opencms.ui.components.CmsInfoButton)

Example 2 with CmsInfoButton

use of org.opencms.ui.components.CmsInfoButton in project opencms-core by alkacon.

the class CmsCacheViewApp method getJavaStatisticButton.

/**
 * Creates in info button for java cache statistics.<p>
 * @param memory memory object
 *
 * @return CmsInfoButton
 */
public static CmsInfoButton getJavaStatisticButton(CmsMemoryStatus memory) {
    Map<String, String> infoMap = new LinkedHashMap<String, String>();
    infoMap.put(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_JAVA_HEAP_MAX_0), CmsFileUtil.formatFilesize(memory.getMaxMemory() * 1048576, A_CmsUI.getCmsObject().getRequestContext().getLocale()));
    infoMap.put(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_JAVA_HEAP_TOTAL_0), CmsFileUtil.formatFilesize(memory.getTotalMemory() * 1048576, A_CmsUI.getCmsObject().getRequestContext().getLocale()));
    infoMap.put(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_JAVA_HEAP_USED_0), CmsFileUtil.formatFilesize(memory.getUsedMemory() * 1048576, A_CmsUI.getCmsObject().getRequestContext().getLocale()));
    infoMap.put(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_JAVA_HEAP_FREE_0), CmsFileUtil.formatFilesize(memory.getFreeMemory() * 1048576, A_CmsUI.getCmsObject().getRequestContext().getLocale()));
    CmsInfoButton info = new CmsInfoButton(infoMap);
    VerticalLayout prog = new VerticalLayout();
    Label label = new Label();
    label.setContentMode(ContentMode.HTML);
    label.setValue("<p>" + CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEXCACHE_LABEL_MEMORY_BLOCK_0) + "</p>");
    prog.addComponent(label);
    prog.addComponent(getProgressBar((((float) memory.getUsage() / 100))));
    info.addAdditionalElement(prog, 0);
    info.setWindowCaption(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEX_0));
    info.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEX_0));
    return info;
}
Also used : Label(com.vaadin.v7.ui.Label) VerticalLayout(com.vaadin.v7.ui.VerticalLayout) LinkedHashMap(java.util.LinkedHashMap) CmsInfoButton(org.opencms.ui.components.CmsInfoButton)

Example 3 with CmsInfoButton

use of org.opencms.ui.components.CmsInfoButton in project opencms-core by alkacon.

the class CmsAccountsApp method iniButtons.

/**
 * Initializes the toolbar buttons.<p>
 */
private void iniButtons() {
    m_newButton = CmsToolBar.createButton(FontOpenCms.WAND, CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_ELEMENT_0));
    m_newButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            openNewDialog();
        }
    });
    m_infoButton = new CmsInfoButton();
    Button csvButton = new Button(CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_EXPORT_ONLY_USER_0));
    csvButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 5472430305539438757L;

        public void buttonClick(ClickEvent event) {
            boolean includeTechnicalFields = false;
            try {
                OpenCms.getRoleManager().checkRole(m_cms, CmsRole.ADMINISTRATOR);
                includeTechnicalFields = true;
            } catch (CmsRoleViolationException e) {
            // ok
            }
            Window window = CmsBasicDialog.prepareWindow(DialogWidth.wide);
            CmsUserCsvExportDialog dialog = new CmsUserCsvExportDialog(getFullUser(getVisibleUser()), m_stateBean.getPath(), m_stateBean.getType(), getElementName(m_stateBean), CmsVaadinUtils.isButtonPressed(getToggleButton(m_stateBean)), window, includeTechnicalFields);
            window.setContent(dialog);
            A_CmsUI.get().addWindow(window);
        }
    });
    m_infoButton.setAdditionalButton(csvButton);
    m_addElementButton = CmsToolBar.createButton(FontAwesome.PLUS, CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_USER_TO_GROUP_0));
    m_addElementButton.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1859694635385726953L;

        public void buttonClick(ClickEvent event) {
            openAddUserDialog();
        }
    });
    m_toggleButtonRole = CmsToolBar.createButton(FontOpenCms.USERS, CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ROLES_TOGGLE_0));
    m_toggleButtonRole.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 8265075332953321274L;

        public void buttonClick(ClickEvent event) {
            toggleTable(m_toggleButtonRole);
        }
    });
    m_toggleButtonUser = CmsToolBar.createButton(FontOpenCms.USERS, CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_USER_TOGGLE_0));
    m_toggleButtonUser.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 8265075332953321274L;

        public void buttonClick(ClickEvent event) {
            toggleTable(m_toggleButtonUser);
        }
    });
    m_toggleButtonGroups = CmsToolBar.createButton(FontOpenCms.USERS, CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_GROUPS_TOGGLE_0));
    m_toggleButtonGroups.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 8265075332953321274L;

        public void buttonClick(ClickEvent event) {
            toggleTable(m_toggleButtonGroups);
        }
    });
    m_uiContext.addToolbarButton(m_newButton);
    m_uiContext.addToolbarButton(m_addElementButton);
    m_uiContext.addToolbarButton(m_infoButton);
    m_uiContext.addToolbarButton(m_toggleButtonRole);
    m_uiContext.addToolbarButton(m_toggleButtonUser);
    m_uiContext.addToolbarButton(m_toggleButtonGroups);
    for (Button button : getAdditionalButtons()) {
        m_uiContext.addToolbarButton(button);
    }
    m_filter = CmsVaadinUtils.getOUComboBox(m_cms, m_baseOU, LOG);
    m_filter.setWidth("379px");
    m_infoLayout.addComponent(m_filter, 0);
    m_filterTable = new TextField();
    m_filterTable.setIcon(FontOpenCms.FILTER);
    m_filterTable.setInputPrompt(Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_FILTER_0));
    m_filterTable.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    // m_filterTable.setWidth("200px");
    m_filterTable.addTextChangeListener(new TextChangeListener() {

        private static final long serialVersionUID = 1L;

        public void textChange(TextChangeEvent event) {
            filterTable(event.getText());
        }
    });
    m_filterTable.setWidth("200px");
    m_infoLayout.addComponent(m_filterTable);
    m_infoLayout.addStyleName("o-many-elements");
    m_filter.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            if ((m_stateBean.getType() != null) & !m_doNotChange) {
                update((String) event.getProperty().getValue(), CmsOuTreeType.OU, null);
            } else {
            // 
            }
        }
    });
    if (!m_ouHandler.isOUManagable(m_stateBean.getPath())) {
        boolean change = m_doNotChange;
        m_doNotChange = false;
        m_filter.select(m_filter.getItemIds().iterator().next());
        m_doNotChange = change;
    }
}
Also used : Window(com.vaadin.ui.Window) ClickEvent(com.vaadin.ui.Button.ClickEvent) ValueChangeEvent(com.vaadin.v7.data.Property.ValueChangeEvent) CmsRoleViolationException(org.opencms.security.CmsRoleViolationException) ValueChangeListener(com.vaadin.v7.data.Property.ValueChangeListener) Button(com.vaadin.ui.Button) CmsInfoButton(org.opencms.ui.components.CmsInfoButton) TextChangeEvent(com.vaadin.v7.event.FieldEvents.TextChangeEvent) TextField(com.vaadin.v7.ui.TextField) TextChangeListener(com.vaadin.v7.event.FieldEvents.TextChangeListener) ClickListener(com.vaadin.ui.Button.ClickListener) CmsInfoButton(org.opencms.ui.components.CmsInfoButton)

Example 4 with CmsInfoButton

use of org.opencms.ui.components.CmsInfoButton in project opencms-core by alkacon.

the class CmsProjectManager method showNavButtons.

/**
 * Shows the sub navigation buttons.<p>
 */
private void showNavButtons() {
    if (m_navButtons.isEmpty()) {
        Button addProject = CmsToolBar.createButton(FontOpenCms.WAND, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_ADD_0));
        addProject.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                Window window = CmsBasicDialog.prepareWindow(DialogWidth.wide);
                CmsEditProjectForm form = new CmsEditProjectForm(m_projectsTable, window);
                window.setContent(form);
                window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_ADD_0));
                A_CmsUI.get().addWindow(window);
                window.center();
            }
        });
        m_uiContext.addToolbarButton(addProject);
        m_navButtons.add(addProject);
        Button history = CmsToolBar.createButton(FontOpenCms.CLIPBOARD, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_HISTORY_0));
        history.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                openSubView(CmsProjectManager.PATH_NAME_HISTORY, true);
            }
        });
        m_uiContext.addToolbarButton(history);
        m_navButtons.add(history);
        try {
            Map<String, String> infos = new LinkedHashMap<String, String>();
            infos.put(CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_STATISTICS_COUNT_0), String.valueOf(OpenCms.getOrgUnitManager().getAllManageableProjects(A_CmsUI.getCmsObject(), "", true).size()));
            CmsInfoButton infoButton = new CmsInfoButton(infos);
            infoButton.setWindowCaption(CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_STATISTICS_0));
            infoButton.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_STATISTICS_0));
            m_uiContext.addToolbarButton(infoButton);
        } catch (CmsException e) {
            LOG.error("unable to get orgunit manager", e);
        }
    } else {
        for (Component button : m_navButtons) {
            button.setVisible(true);
        }
    }
}
Also used : Window(com.vaadin.ui.Window) Button(com.vaadin.ui.Button) CmsInfoButton(org.opencms.ui.components.CmsInfoButton) ClickEvent(com.vaadin.ui.Button.ClickEvent) CmsException(org.opencms.main.CmsException) Component(com.vaadin.ui.Component) ClickListener(com.vaadin.ui.Button.ClickListener) LinkedHashMap(java.util.LinkedHashMap) CmsInfoButton(org.opencms.ui.components.CmsInfoButton)

Example 5 with CmsInfoButton

use of org.opencms.ui.components.CmsInfoButton in project opencms-core by alkacon.

the class CmsCacheViewApp method getFlexStatisticButton.

/**
 * Creates in info button for flex cache statistics.<p>
 *
 * @return CmsInfoButton
 */
protected static CmsInfoButton getFlexStatisticButton() {
    Map<String, String> infoMap = new LinkedHashMap<String, String>();
    CmsFlexCache cache = OpenCms.getFlexCache();
    CmsLruCache entryLruCache = cache.getEntryLruCache();
    infoMap.put(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEXCACHE_LABEL_STATS_KEYS_0), String.valueOf(cache.keySize()));
    infoMap.put(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEXCACHE_LABEL_STATS_VARIATIONS_0), String.valueOf(cache.size()));
    infoMap.put(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEXCACHE_LABEL_MEMORY_MAXSIZE_0), CmsFileUtil.formatFilesize(entryLruCache.getMaxCacheCosts(), A_CmsUI.getCmsObject().getRequestContext().getLocale()));
    infoMap.put(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEXCACHE_LABEL_MEMORY_CURSIZE_0), CmsFileUtil.formatFilesize(entryLruCache.getObjectCosts(), A_CmsUI.getCmsObject().getRequestContext().getLocale()));
    CmsInfoButton info = new CmsInfoButton(infoMap);
    VerticalLayout prog = new VerticalLayout();
    Label label = new Label();
    label.setContentMode(ContentMode.HTML);
    label.setValue("<p>" + CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEXCACHE_LABEL_MEMORY_BLOCK_0) + "</p>");
    prog.addComponent(label);
    prog.addComponent(getProgressBar((float) entryLruCache.getObjectCosts() / (float) entryLruCache.getMaxCacheCosts()));
    info.addAdditionalElement(prog, 0);
    info.setWindowCaption(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEX_0));
    info.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_FLEX_0));
    return info;
}
Also used : Label(com.vaadin.v7.ui.Label) VerticalLayout(com.vaadin.v7.ui.VerticalLayout) CmsFlexCache(org.opencms.flex.CmsFlexCache) CmsLruCache(org.opencms.cache.CmsLruCache) LinkedHashMap(java.util.LinkedHashMap) CmsInfoButton(org.opencms.ui.components.CmsInfoButton)

Aggregations

CmsInfoButton (org.opencms.ui.components.CmsInfoButton)7 LinkedHashMap (java.util.LinkedHashMap)4 Button (com.vaadin.ui.Button)3 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 ClickListener (com.vaadin.ui.Button.ClickListener)3 Window (com.vaadin.ui.Window)2 Label (com.vaadin.v7.ui.Label)2 VerticalLayout (com.vaadin.v7.ui.VerticalLayout)2 Component (com.vaadin.ui.Component)1 ValueChangeEvent (com.vaadin.v7.data.Property.ValueChangeEvent)1 ValueChangeListener (com.vaadin.v7.data.Property.ValueChangeListener)1 TextChangeEvent (com.vaadin.v7.event.FieldEvents.TextChangeEvent)1 TextChangeListener (com.vaadin.v7.event.FieldEvents.TextChangeListener)1 TextField (com.vaadin.v7.ui.TextField)1 File (java.io.File)1 CmsLruCache (org.opencms.cache.CmsLruCache)1 CmsFlexCache (org.opencms.flex.CmsFlexCache)1 CmsException (org.opencms.main.CmsException)1 CmsRoleViolationException (org.opencms.security.CmsRoleViolationException)1