com.vaadin.ui.Button - java examples

Here are the examples of the java api com.vaadin.ui.Button taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : CmsSiteSelectDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * The site select dialog.<p>
 */
public clreplaced CmsSiteSelectDialog extends CmsBasicDialog {

    /**
     * Logger instance for this clreplaced.
     */
    static final Log LOG = CmsLog.getLog(CmsSiteSelectDialog.clreplaced);

    /**
     * The project name property.
     */
    private static final String CAPTION_PROPERTY = "caption";

    /**
     * The serial version id.
     */
    private static final long serialVersionUID = 4455901453008760434L;

    /**
     * The cancel button.
     */
    private Button m_cancelButton;

    /**
     * The dialog context.
     */
    private I_CmsDialogContext m_context;

    /**
     * The site select.
     */
    private ComboBox m_siteComboBox;

    /**
     * Constructor.<p>
     *
     * @param context the dialog context
     */
    public CmsSiteSelectDialog(I_CmsDialogContext context) {
        m_context = context;
        setContent(initForm());
        m_cancelButton = createButtonCancel();
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                cancel();
            }
        });
        addButton(m_cancelButton);
        setActionHandler(new CmsOkCancelActionHandler() {

            private static final long serialVersionUID = 1L;

            @Override
            protected void cancel() {
                CmsSiteSelectDialog.this.cancel();
            }

            @Override
            protected void ok() {
                submit();
            }
        });
    }

    /**
     * Actually changes the site.
     *
     * @param context the dialog context
     * @param siteRoot the site root
     */
    public static void changeSite(I_CmsDialogContext context, String siteRoot) {
        if (!context.getCms().getRequestContext().getSiteRoot().equals(siteRoot)) {
            A_CmsUI.get().changeSite(siteRoot);
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(siteRoot) || OpenCms.getSiteManager().isSharedFolder(siteRoot)) {
                // switch to explorer view when selecting shared or root site
                Page.getCurrent().open(CmsCoreService.getFileExplorerLink(A_CmsUI.getCmsObject(), siteRoot), "_top");
                return;
            }
        } else {
            siteRoot = null;
        }
        context.finish(null, siteRoot);
    }

    /**
     * Cancels the dialog action.<p>
     */
    void cancel() {
        m_context.finish(Collections.<CmsUUID>emptyList());
    }

    /**
     * Submits the dialog action.<p>
     */
    void submit() {
        String siteRoot = (String) m_siteComboBox.getValue();
        I_CmsDialogContext context = m_context;
        changeSite(context, siteRoot);
    }

    /**
     * Initializes the form component.<p>
     *
     * @return the form component
     */
    private FormLayout initForm() {
        FormLayout form = new FormLayout();
        form.setWidth("100%");
        IndexedContainer sites = CmsVaadinUtils.getAvailableSitesContainer(m_context.getCms(), CAPTION_PROPERTY);
        m_siteComboBox = prepareComboBox(sites, org.opencms.workplace.Messages.GUI_LABEL_SITE_0);
        m_siteComboBox.select(m_context.getCms().getRequestContext().getSiteRoot());
        form.addComponent(m_siteComboBox);
        ValueChangeListener changeListener = new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {
                submit();
            }
        };
        m_siteComboBox.addValueChangeListener(changeListener);
        return form;
    }

    /**
     * Prepares a combo box.<p>
     *
     * @param container the indexed item container
     * @param captionKey the caption message key
     *
     * @return the combo box
     */
    private ComboBox prepareComboBox(IndexedContainer container, String captionKey) {
        ComboBox result = new ComboBox(CmsVaadinUtils.getWpMessagesForCurrentLocale().key(captionKey), container);
        result.setTextInputAllowed(true);
        result.setNullSelectionAllowed(false);
        result.setWidth("100%");
        result.setInputPrompt(Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_CLICK_TO_EDIT_0));
        result.sereplacedemCaptionPropertyId(CAPTION_PROPERTY);
        result.setFilteringMode(FilteringMode.CONTAINS);
        return result;
    }
}

19 View Complete Implementation : CmsErrorDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog used to display error stack traces in the workplace.<p>
 */
public clreplaced CmsErrorDialog extends CmsBasicDialog {

    /**
     * Serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * Label to display.
     */
    private Label m_errorLabel;

    /**
     * Error message label.
     */
    private Label m_errorMessage;

    /**
     * Warning icon.
     */
    private Label m_icon;

    /**
     * Hidden stack trace element.
     */
    private Label m_hiddenStack;

    /**
     * The OK button.
     */
    private Button m_okButton;

    /**
     * The dialog context.
     */
    private Runnable m_onClose;

    /**
     * The dialog window.
     */
    private Window m_window;

    /**
     * The details component.
     */
    private CssLayout m_details;

    /**
     * The select text button.
     */
    private CmsCopyToClipboardButton m_copyText;

    /**
     * The toggle details button.
     */
    private Button m_detailsButton;

    /**
     * Creates a new instance.<p>
     *
     * @param message the error message
     * @param t the error to be displayed
     * @param onClose executed on close
     * @param window the dialog window if available
     */
    public CmsErrorDialog(String message, Throwable t, Runnable onClose, final Window window) {
        m_onClose = onClose;
        m_window = window;
        CmsVaadinUtils.readAndLocalizeDesign(this, OpenCms.getWorkplaceManager().getMessages(A_CmsUI.get().getLocale()), null);
        m_icon.setContentMode(ContentMode.HTML);
        m_icon.setValue(FontOpenCms.ERROR.getHtml());
        m_errorLabel.setContentMode(ContentMode.PREFORMATTED);
        final String labelId = "label" + new CmsUUID().toString();
        String stacktrace = message + "\n\n" + ExceptionUtils.getStackTrace(t);
        m_hiddenStack.setId(labelId);
        m_hiddenStack.setValue(stacktrace);
        m_errorLabel.setValue(stacktrace);
        m_errorLabel.addStyleName(OpenCmsTheme.FULL_WIDTH_PADDING);
        m_errorMessage.setContentMode(ContentMode.HTML);
        m_errorMessage.setValue(message);
        m_copyText.setSelector("#" + labelId);
        m_details.setVisible(false);
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                onClose();
            }
        });
        m_detailsButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                toggleDetails();
            }
        });
        if (m_window != null) {
            m_window.addCloseListener(new CloseListener() {

                private static final long serialVersionUID = 1L;

                public void windowClose(CloseEvent e) {
                    onClose();
                }
            });
        }
    }

    /**
     * Shows the error dialog.<p>
     *
     * @param message the error message
     * @param t the error to be displayed
     */
    public static void showErrorDialog(String message, Throwable t) {
        showErrorDialog(message, t, null);
    }

    /**
     * Shows the error dialog.<p>
     *
     * @param message the error message
     * @param t the error to be displayed
     * @param onClose executed on close
     */
    public static void showErrorDialog(String message, Throwable t, Runnable onClose) {
        Window window = prepareWindow(DialogWidth.wide);
        window.setCaption(Messages.get().getBundle(A_CmsUI.get().getLocale()).key(Messages.GUI_ERROR_0));
        window.setContent(new CmsErrorDialog(message, t, onClose, window));
        A_CmsUI.get().addWindow(window);
    }

    /**
     * Shows the error dialog.<p>
     *
     * @param t the error to be displayed
     */
    public static void showErrorDialog(Throwable t) {
        showErrorDialog(t.getLocalizedMessage(), t, null);
    }

    /**
     * Shows the error dialog.<p>
     *
     * @param t the error to be displayed
     * @param onClose executed on close
     */
    public static void showErrorDialog(Throwable t, Runnable onClose) {
        showErrorDialog(t.getLocalizedMessage(), t, onClose);
    }

    /**
     * Called on dialog close.<p>
     */
    void onClose() {
        if (m_onClose != null) {
            m_onClose.run();
        }
        if (m_window != null) {
            m_window.close();
        }
    }

    /**
     * Toggles the details visibility.<p>
     */
    void toggleDetails() {
        m_details.setVisible(!m_details.isVisible());
        if (m_window != null) {
            m_window.center();
        }
    }
}

19 View Complete Implementation : CmsShellScriptLayout.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Layout for shell script settings and input dialog.<p>
 */
public clreplaced CmsShellScriptLayout extends VerticalLayout {

    /**
     * The log instance for this clreplaced.
     */
    static final Log LOG = CmsLog.getLog(CmsShellScriptLayout.clreplaced);

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = -7284574557422737112L;

    /**
     * Vaadin component.
     */
    private ComboBox m_site;

    /**
     * Vaadin component.
     */
    private ComboBox m_project;

    /**
     * Vaadin component.
     */
    private TextArea m_script;

    /**
     * Vaadin component.
     */
    private Button m_ok;

    /**
     * public constructor.<p>
     */
    public CmsShellScriptLayout() {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_site.setContainerDataSource(CmsVaadinUtils.getAvailableSitesContainer(A_CmsUI.getCmsObject(), "caption"));
        m_site.sereplacedemCaptionPropertyId("caption");
        m_site.select(A_CmsUI.getCmsObject().getRequestContext().getSiteRoot());
        m_project.setContainerDataSource(CmsVaadinUtils.getProjectsContainer(A_CmsUI.getCmsObject(), "caption"));
        m_project.sereplacedemCaptionPropertyId("caption");
        m_project.select(A_CmsUI.getCmsObject().getRequestContext().getCurrentProject().getUuid());
        m_site.setNewItemsAllowed(false);
        m_site.setNullSelectionAllowed(false);
        m_project.setNewItemsAllowed(false);
        m_project.setNullSelectionAllowed(false);
        m_script.setValue(CmsVaadinUtils.getMessageText(Messages.GUI_SHELL_SCRIPT_APP_INI_COMMENT_0));
        m_ok.addClickListener(new Button.ClickListener() {

            private static final long serialVersionUID = 6836938102455627631L;

            public void buttonClick(ClickEvent event) {
                try {
                    Window window = CmsBasicDialog.prepareWindow(DialogWidth.wide);
                    CmsObject cms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
                    setupCms(cms);
                    CmsShellScriptThread thread = new CmsShellScriptThread(cms, getScript());
                    CmsShellScriptReportDialog dialog = new CmsShellScriptReportDialog(thread, window);
                    window.setContent(dialog);
                    A_CmsUI.get().addWindow(window);
                    thread.start();
                } catch (CmsException e) {
                    LOG.error("Unable to initialize CmsObject", e);
                }
            }
        });
    }

    /**
     * Gets the currently entered script.<p>
     *
     * @return String
     */
    protected String getScript() {
        return m_script.getValue();
    }

    /**
     * Sets up given CmsObject with currently set Project and Site.<p>
     *
     * @param cms CmsObject to gets adjusted to input fields
     */
    protected void setupCms(CmsObject cms) {
        cms.getRequestContext().setUri("/");
        cms.getRequestContext().setSiteRoot((String) m_site.getValue());
        try {
            cms.getRequestContext().setCurrentProject(cms.readProject((CmsUUID) m_project.getValue()));
        } catch (CmsException e) {
            LOG.error("Unable to read Project", e);
        }
    }
}

19 View Complete Implementation : CmsCategorySelectDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * The category select dialog.<p>
 */
public clreplaced CmsCategorySelectDialog extends CmsBasicDialog {

    /**
     * The serial version id.
     */
    private static final long serialVersionUID = 247205018045790127L;

    /**
     * The category filter field.
     */
    private TextField m_filter;

    /**
     * the OK button.
     */
    private Button m_okButton;

    /**
     * The selection handlers.
     */
    private List<I_CmsSelectionHandler<Collection<CmsCategory>>> m_selectionHandlers;

    /**
     * The category tree.
     */
    private CmsCategoryTree m_tree;

    /**
     * Constructor.<p>
     *
     * @param contextPath the context path to read the categories from
     */
    public CmsCategorySelectDialog(String contextPath) {
        m_selectionHandlers = new ArrayList<I_CmsSelectionHandler<Collection<CmsCategory>>>();
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_filter.setIcon(FontOpenCms.FILTER);
        m_filter.setInputPrompt(Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_FILTER_0));
        m_filter.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        m_filter.setWidth("200px");
        m_filter.addTextChangeListener(new TextChangeListener() {

            private static final long serialVersionUID = 1L;

            public void textChange(TextChangeEvent event) {
                filterTree(event.getText());
            }
        });
        m_tree.loadCategories(A_CmsUI.getCmsObject(), contextPath);
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                onOk();
            }
        });
    }

    /**
     * Adds a selection handler.<p>
     *
     * @param selectionHandler the selection handler to add
     */
    public void addSelectionHandler(I_CmsSelectionHandler<Collection<CmsCategory>> selectionHandler) {
        m_selectionHandlers.add(selectionHandler);
    }

    /**
     * Removes a selection handler.<p>
     *
     * @param selectionHandler the selection handler to remove
     */
    public void removeSelectionHandler(I_CmsSelectionHandler<Collection<CmsCategory>> selectionHandler) {
        m_selectionHandlers.remove(selectionHandler);
    }

    /**
     * Sets the selected categories.<p>
     *
     * @param categories the categories to select
     */
    public void setSelectedCategories(Collection<CmsCategory> categories) {
        m_tree.setSelectedCategories(categories);
    }

    /**
     * Adds a filter to the category tree container.<p>
     *
     * @param filter the filter to add
     */
    void filterTree(String filter) {
        HierarchicalContainer container = (HierarchicalContainer) m_tree.getContainerDataSource();
        container.removeAllContainerFilters();
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(filter)) {
            final String lowerCaseFilter = filter.toLowerCase();
            container.addContainerFilter(new Filter() {

                private static final long serialVersionUID = 1L;

                public boolean appliesToProperty(Object propertyId) {
                    return true;
                }

                public boolean preplacedesFilter(Object itemId, Item item) throws UnsupportedOperationException {
                    CmsCategory cat = (CmsCategory) itemId;
                    return cat.getPath().toLowerCase().contains(lowerCaseFilter) || ((cat.getreplacedle() != null) && cat.getreplacedle().toLowerCase().contains(lowerCaseFilter));
                }
            });
        }
    }

    /**
     * On OK click.<p>
     */
    void onOk() {
        if (!m_selectionHandlers.isEmpty()) {
            Collection<CmsCategory> categories = m_tree.getSelectedCategories();
            for (I_CmsSelectionHandler<Collection<CmsCategory>> handler : m_selectionHandlers) {
                handler.onSelection(categories);
            }
        }
    }
}

19 View Complete Implementation : CmsAddPropertyDefinitionDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for dialog to create property definition.<p>
 */
public clreplaced CmsAddPropertyDefinitionDialog extends CmsBasicDialog {

    /**
     * Validator for new Property name.
     */
    clreplaced PropertyExistValidator implements Validator {

        /**
         * vaadin serial id.
         */
        private static final long serialVersionUID = -2500052661735259675L;

        /**
         * @see com.vaadin.data.Validator#validate(java.lang.Object)
         */
        public void validate(Object value) throws InvalidValueException {
            if (value == null) {
                throw new InvalidValueException(CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_PROPERTY_VALIDATION_EMPTY_0));
            }
            String propName = (String) value;
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(propName)) {
                throw new InvalidValueException(CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_PROPERTY_VALIDATION_EMPTY_0));
            }
            try {
                if (A_CmsUI.getCmsObject().readPropertyDefinition(propName) != null) {
                    throw new InvalidValueException(CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_PROPERTY_VALIDATION_ALREADY_EXIST_0));
                }
            } catch (CmsException e) {
            // should not happen (non existing property leads to null, not throwing exception.)
            }
            try {
                CmsPropertyDefinition.checkPropertyName(propName);
            } catch (CmsIllegalArgumentException e) {
                throw new InvalidValueException(CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_PROPERTY_VALIDATION_NOTVALID_0));
            }
        }
    }

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = -5454565964997277536L;

    /**
     * New property name field.
     */
    protected TextField m_newProperty;

    /**
     * ok button.
     */
    private Button m_ok;

    /**
     * cancel button.
     */
    private Button m_cancel;

    /**
     * public constructor.<p>
     * @param window to be closed
     * @param table to be updated
     */
    public CmsAddPropertyDefinitionDialog(final Window window, final CmsPropertyTable table) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_ok.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -7356827828386377748L;

            public void buttonClick(ClickEvent event) {
                m_newProperty.removeAllValidators();
                m_newProperty.addValidator(new PropertyExistValidator());
                if (m_newProperty.isValid()) {
                    saveProperty();
                    table.init();
                    window.close();
                }
            }
        });
        m_cancel.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -3198675226086758775L;

            public void buttonClick(ClickEvent event) {
                window.close();
            }
        });
    }

    /**
     * saves the new property.<p>
     */
    protected void saveProperty() {
        try {
            A_CmsUI.getCmsObject().createPropertyDefinition(m_newProperty.getValue());
        } catch (CmsException e) {
        // 
        }
    }
}

19 View Complete Implementation : CmsSelectResourceTypeDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the resource type select dialog.<p>
 */
@DesignRoot
public clreplaced CmsSelectResourceTypeDialog extends A_CmsSelectResourceTypeDialog {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = -6944584336945436950L;

    /**
     * The cancel button.
     */
    protected Button m_cancelButton;

    /**
     * Container for the type list.
     */
    protected VerticalLayout m_typeContainer;

    /**
     * Element view selector.
     */
    protected ComboBox m_viewSelector;

    /**
     * public constructor.<p>
     *
     * @param folderResource resource
     * @param context dialog context
     */
    public CmsSelectResourceTypeDialog(CmsResource folderResource, I_CmsDialogContext context) {
        super(folderResource, context);
    }

    /**
     * @see org.opencms.ui.dialogs.A_CmsSelectResourceTypeDialog#getCancelButton()
     */
    @Override
    public Button getCancelButton() {
        return m_cancelButton;
    }

    /**
     * Returns selected resource type.<p>
     *
     * @return resource type name
     */
    public String getSelectedResource() {
        return m_selectedType == null ? "" : m_selectedType.getType();
    }

    /**
     * @see org.opencms.ui.dialogs.A_CmsSelectResourceTypeDialog#getVerticalLayout()
     */
    @Override
    public VerticalLayout getVerticalLayout() {
        return m_typeContainer;
    }

    /**
     * @see org.opencms.ui.dialogs.A_CmsSelectResourceTypeDialog#getViewSelector()
     */
    @Override
    public ComboBox getViewSelector() {
        return m_viewSelector;
    }

    /**
     * @see org.opencms.ui.dialogs.A_CmsSelectResourceTypeDialog#handleSelection(org.opencms.ade.galleries.shared.CmsResourceTypeBean)
     */
    @Override
    public void handleSelection(CmsResourceTypeBean selectedType) {
        m_selectedType = selectedType;
        finish(null);
    }

    /**
     * @see org.opencms.ui.dialogs.A_CmsSelectResourceTypeDialog#useDefault()
     */
    @Override
    public boolean useDefault() {
        return false;
    }
}

19 View Complete Implementation : A_CmsUpdateDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * The abstract clreplaced for the update dialogs.<p>
 */
public abstract clreplaced A_CmsUpdateDialog extends CmsBasicDialog {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * Ui.
     */
    protected CmsUpdateUI m_ui;

    /**
     * Continue button.
     */
    Button m_ok;

    /**
     * Back button.
     */
    Button m_back;

    /**
     * Returns the back button.<p>
     *
     * @return Button
     */
    public Button getBackButton() {
        return new Button("Back");
    }

    /**
     * Returns the continue button.<p>
     *
     * @return Button
     */
    public Button getOkButton() {
        return new Button("Continue");
    }

    /**
     * Creates a new HTML-formatted label with the given content.
     *
     * @param html the label content
     * @return Label
     */
    public Label htmlLabel(String html) {
        Label label = new Label();
        label.setContentMode(ContentMode.HTML);
        label.setValue(html);
        return label;
    }

    /**
     * Inits the dialog.<p>
     * (The constructor is empty)
     *
     * @param ui UI
     * @return true if dialog should be displayed
     */
    public abstract boolean init(CmsUpdateUI ui);

    /**
     * Init called from implementations of this clreplaced.<p>
     *
     * @param ui ui
     * @param hasPrev has preview dialog
     * @param hasNext has next dialog
     */
    public void init(CmsUpdateUI ui, boolean hasPrev, boolean hasNext) {
        m_ui = ui;
        if (hasPrev) {
            m_back = getBackButton();
            m_back.addClickListener(new ClickListener() {

                private static final long serialVersionUID = 1L;

                public void buttonClick(ClickEvent event) {
                    ui.displayDialog(getPreviousDialog());
                }
            });
            addButton(m_back, true);
        }
        if (hasNext) {
            m_ok = getOkButton();
            m_ok.addClickListener(new ClickListener() {

                private static final long serialVersionUID = 1L;

                public void buttonClick(ClickEvent event) {
                    if (submitDialog()) {
                        ui.displayDialog(getNextDialog());
                    }
                }
            });
            addButton(m_ok, true);
        }
    }

    /**
     * Reads an HTML snipped with the given name.
     * @param name name of file
     *
     * @return the HTML data
     */
    public String readSnippet(String name) {
        String path = CmsStringUtil.joinPaths(m_ui.getUpdateBean().getWebAppRfsPath(), CmsUpdateBean.FOLDER_UPDATE, "html", name);
        try (InputStream stream = new FileInputStream(path)) {
            byte[] data = CmsFileUtil.readFully(stream, false);
            String result = new String(data, "UTF-8");
            return result;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * En / Disables the continue button.<p>
     *
     * @param enable boolean
     */
    protected void enableOK(boolean enable) {
        m_ok.setEnabled(enable);
    }

    /**
     * Submit method.<p>
     *
     * @return true if next dialog should be loaded
     */
    protected boolean submitDialog() {
        return true;
    }

    /**
     * Returns next Dialog (not initialized).<p>
     *
     * @return A_CmsUpdateDialog
     */
    abstract A_CmsUpdateDialog getNextDialog();

    /**
     * Returns previous Dialog (not initialized).<p>
     *
     * @return A_CmsUpdateDialog
     */
    abstract A_CmsUpdateDialog getPreviousDialog();
}

19 View Complete Implementation : CmsSetupStep07ConfigNotes.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Setup step: Configuration notes.
 */
public clreplaced CmsSetupStep07ConfigNotes extends A_CmsSetupStep {

    /**
     * The forward button.
     */
    private Button m_forwardButton;

    /**
     * The main layout.
     */
    private VerticalLayout m_mainLayout;

    private VerticalLayout m_notesContainer;

    /**
     * Creates a new instance.
     *
     * @param context the setup context
     */
    public CmsSetupStep07ConfigNotes(I_SetupUiContext context) {
        super(context);
        CmsVaadinUtils.readAndLocalizeDesign(this, null, null);
        String name = "browser_config.html";
        Label label = htmlLabel(readSnippet(name));
        label.setWidth("100%");
        m_notesContainer.addComponent(label);
        m_forwardButton.addClickListener(evt -> forward());
    }

    /**
     * Proceed to next step.
     */
    public void forward() {
        m_context.getSetupBean().prepareStep10();
        CmsSetupBean bean = m_context.getSetupBean();
        VaadinServletRequest request = (VaadinServletRequest) (VaadinRequest.getCurrent());
        String servletMapping = bean.getServletMapping();
        String openLink = null;
        if (!servletMapping.startsWith("/")) {
            servletMapping = "/" + servletMapping;
        }
        if (servletMapping.endsWith("/*")) {
            // usually a mapping must be in the form "/opencms/*", cut off all slashes
            servletMapping = servletMapping.substring(0, servletMapping.length() - 2);
        }
        openLink = request.getContextPath() + servletMapping + (bean.hasIndexHtml() ? "/index.html" : "/system/login");
        A_CmsUI.get().getPage().setLocation(openLink);
    }
}

19 View Complete Implementation : CmsProjectSelectDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * The project select dialog.<p>
 */
public clreplaced CmsProjectSelectDialog extends CmsBasicDialog {

    /**
     * Logger instance for this clreplaced.
     */
    static final Log LOG = CmsLog.getLog(CmsProjectSelectDialog.clreplaced);

    /**
     * The project name property.
     */
    private static final String CAPTION_PROPERTY = "caption";

    /**
     * The serial version id.
     */
    private static final long serialVersionUID = 4455901453008760434L;

    /**
     * The cancel button.
     */
    private Button m_cancelButton;

    /**
     * The dialog context.
     */
    private I_CmsDialogContext m_context;

    /**
     * The project select.
     */
    private ComboBox m_projectComboBox;

    /**
     * The site select.
     */
    private ComboBox m_siteComboBox;

    /**
     * Constructor.<p>
     *
     * @param context the dialog context
     */
    public CmsProjectSelectDialog(I_CmsDialogContext context) {
        m_context = context;
        setContent(initForm());
        m_cancelButton = createButtonCancel();
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                cancel();
            }
        });
        addButton(m_cancelButton);
        setActionHandler(new CmsOkCancelActionHandler() {

            private static final long serialVersionUID = 1L;

            @Override
            protected void cancel() {
                CmsProjectSelectDialog.this.cancel();
            }

            @Override
            protected void ok() {
                submit();
            }
        });
    }

    /**
     * Static method for actually changing the site/project.
     *
     * @param context the dialog context
     * @param projectId the project id (possibly null)
     * @param siteRoot the site root (possibly null)
     */
    public static void changeSiteOrProject(I_CmsDialogContext context, CmsUUID projectId, String siteRoot) {
        try {
            CmsProject project = null;
            if (projectId != null) {
                project = context.getCms().readProject(projectId);
                if (!context.getCms().getRequestContext().getCurrentProject().equals(project)) {
                    A_CmsUI.get().changeProject(project);
                } else {
                    project = null;
                }
            }
            if (siteRoot != null) {
                if (!context.getCms().getRequestContext().getSiteRoot().equals(siteRoot)) {
                    A_CmsUI.get().changeSite(siteRoot);
                } else {
                    siteRoot = null;
                }
            }
            if ((siteRoot != null) && CmsFileExplorerConfiguration.APP_ID.equals(context.getAppId())) {
                I_CmsWorkplaceAppConfiguration editorConf = OpenCms.getWorkplaceAppManager().getAppConfiguration(CmsPageEditorConfiguration.APP_ID);
                if (editorConf.getVisibility(context.getCms()).isActive()) {
                    ((I_CmsHasAppLaunchCommand) editorConf).getAppLaunchCommand().run();
                    return;
                }
            }
            context.finish(project, siteRoot);
        } catch (CmsException e) {
            context.error(e);
        }
    }

    /**
     * Cancels the dialog action.<p>
     */
    void cancel() {
        m_context.finish(Collections.<CmsUUID>emptyList());
    }

    /**
     * Submits the dialog action.<p>
     */
    void submit() {
        I_CmsDialogContext context = m_context;
        CmsUUID projectId = (CmsUUID) m_projectComboBox.getValue();
        String siteRoot = (String) m_siteComboBox.getValue();
        changeSiteOrProject(context, projectId, siteRoot);
    }

    /**
     * Initializes the form component.<p>
     *
     * @return the form component
     */
    private FormLayout initForm() {
        FormLayout form = new FormLayout();
        form.setWidth("100%");
        IndexedContainer sites = CmsVaadinUtils.getAvailableSitesContainer(m_context.getCms(), CAPTION_PROPERTY);
        m_siteComboBox = prepareComboBox(sites, org.opencms.workplace.Messages.GUI_LABEL_SITE_0);
        m_siteComboBox.select(m_context.getCms().getRequestContext().getSiteRoot());
        form.addComponent(m_siteComboBox);
        ValueChangeListener changeListener = new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {
                submit();
            }
        };
        m_siteComboBox.addValueChangeListener(changeListener);
        IndexedContainer projects = CmsVaadinUtils.getProjectsContainer(m_context.getCms(), CAPTION_PROPERTY);
        m_projectComboBox = prepareComboBox(projects, org.opencms.workplace.Messages.GUI_LABEL_PROJECT_0);
        CmsUUID currentProjectId = m_context.getCms().getRequestContext().getCurrentProject().getUuid();
        if (projects.containsId(currentProjectId)) {
            m_projectComboBox.select(currentProjectId);
        } else {
            try {
                CmsUUID ouProject = OpenCms.getOrgUnitManager().readOrganizationalUnit(m_context.getCms(), m_context.getCms().getRequestContext().getOuFqn()).getProjectId();
                if (projects.containsId(ouProject)) {
                    m_projectComboBox.select(ouProject);
                }
            } catch (CmsException e) {
                LOG.error("Error while reading current OU.", e);
            }
        }
        form.addComponent(m_projectComboBox);
        m_projectComboBox.addValueChangeListener(changeListener);
        return form;
    }

    /**
     * Prepares a combo box.<p>
     *
     * @param container the indexed item container
     * @param captionKey the caption message key
     *
     * @return the combo box
     */
    private ComboBox prepareComboBox(IndexedContainer container, String captionKey) {
        ComboBox result = new ComboBox(CmsVaadinUtils.getWpMessagesForCurrentLocale().key(captionKey), container);
        result.setTextInputAllowed(true);
        result.setNullSelectionAllowed(false);
        result.setWidth("100%");
        result.setInputPrompt(Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_CLICK_TO_EDIT_0));
        result.sereplacedemCaptionPropertyId(CAPTION_PROPERTY);
        result.setFilteringMode(FilteringMode.CONTAINS);
        return result;
    }
}

19 View Complete Implementation : CmsPublishQueue.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the Publish queue app.<p>
 */
public clreplaced CmsPublishQueue extends A_CmsWorkplaceApp {

    /**
     * The file table filter input.
     */
    private TextField m_siteTableFilter;

    /**
     * Reload button.
     */
    private Button m_refreshButton;

    /**
     * Creates a new instance.
     */
    public CmsPublishQueue() {
        super();
        m_refreshButton = CmsToolBar.createButton(FontOpenCms.RESET, CmsVaadinUtils.getMessageText(Messages.GUI_APP_RELOAD_0));
        m_refreshButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                A_CmsUI.get().getPage().reload();
            }
        });
    }

    /**
     * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getBreadCrumbForState(java.lang.String)
     */
    @Override
    protected LinkedHashMap<String, String> getBreadCrumbForState(String state) {
        LinkedHashMap<String, String> crumbs = new LinkedHashMap<String, String>();
        // Check if state is empty -> start
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(state)) {
            crumbs.put("", CmsVaadinUtils.getMessageText(Messages.GUI_PQUEUE_replacedLE_0));
            return crumbs;
        }
        // size==1 & state was not empty -> state doesn't match to known path
        return new LinkedHashMap<String, String>();
    }

    /**
     * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getComponentForState(java.lang.String)
     */
    @Override
    protected Component getComponentForState(String state) {
        m_uiContext.addToolbarButton(m_refreshButton);
        // default ->
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(state)) {
            m_rootLayout.setMainHeightFull(true);
            return new CmsQueuedTable(this);
        }
        return null;
    }

    /**
     * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getSubNavEntries(java.lang.String)
     */
    @Override
    protected List<NavEntry> getSubNavEntries(String state) {
        return null;
    }
}

19 View Complete Implementation : CmsUnlinkDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog to confirm detaching a resource from a locale group.<p>
 */
public clreplaced CmsUnlinkDialog extends CmsBasicDialog {

    /**
     * The log instance for this clreplaced.
     */
    private static final Log LOG = CmsLog.getLog(CmsUnlinkDialog.clreplaced);

    /**
     * The serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * The cancel button.
     */
    protected Button m_cancelButton;

    /**
     * The dialog context.
     */
    protected I_CmsDialogContext m_context;

    /**
     * The locale comparison context.
     */
    protected I_CmsLocaleCompareContext m_localeContext;

    /**
     * The label with the confirmation message.
     */
    protected Label m_messageLabel;

    /**
     * The OK button.
     */
    protected Button m_okButton;

    /**
     * The other resource.
     */
    protected CmsResource m_otherResource;

    /**
     * The container for the resource boxes.
     */
    protected HorizontalLayout m_resourceBoxContainer;

    /**
     * Creates a new instance.<p>
     *
     * @param context the dialog context
     * @param otherResource the other resource
     */
    public CmsUnlinkDialog(I_CmsDialogContext context, CmsResource otherResource) {
        super();
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_context = context;
        m_otherResource = otherResource;
        CmsResource leftResource = m_context.getResources().get(0);
        try {
            if (leftResource.isFolder()) {
                CmsResource defaultFile = context.getCms().readDefaultFile(leftResource, CmsResourceFilter.IGNORE_EXPIRATION);
                if (defaultFile != null) {
                    leftResource = defaultFile;
                }
            }
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
        CmsResource rightResource = m_otherResource;
        CmsResourceInfo left = new CmsResourceInfo(leftResource);
        CmsResourceInfo right = new CmsResourceInfo(rightResource);
        Locale leftLocale = OpenCms.getLocaleManager().getDefaultLocale(context.getCms(), leftResource);
        Locale rightLocale = OpenCms.getLocaleManager().getDefaultLocale(context.getCms(), rightResource);
        left.getTopLine().setValue("[" + leftLocale.toString().toUpperCase() + "] " + left.getTopLine().getValue());
        right.getTopLine().setValue("[" + rightLocale.toString().toUpperCase() + "] " + right.getTopLine().getValue());
        m_resourceBoxContainer.addComponent(left);
        m_resourceBoxContainer.addComponent(right);
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                onClickOk();
            }
        });
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                onClickCancel();
            }
        });
    }

    /**
     * Called when the Cancel button is clicked.<p>
     */
    protected void onClickCancel() {
        m_context.finish(new ArrayList<CmsUUID>());
    }

    /**
     * Called when the OK button is clicked.<p>
     */
    protected void onClickOk() {
        CmsResource res1 = m_context.getResources().get(0);
        CmsResource res2 = m_otherResource;
        try {
            CmsObject cms = A_CmsUI.getCmsObject();
            CmsLocaleGroupService groupService = cms.getLocaleGroupService();
            groupService.detachLocaleGroup(res1, res2);
            m_context.finish(Arrays.asList(m_context.getResources().get(0).getStructureId()));
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage());
            m_context.error(e);
        }
    }
}

19 View Complete Implementation : CmsSendBroadcastDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the dialiog to send broadcasts.<p>
 */
public clreplaced CmsSendBroadcastDialog extends CmsBasicDialog {

    private static final Map<CmsUser, CmsBroadcast> USER_BROADCAST = new HashMap<CmsUser, CmsBroadcast>();

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = -7642289972554010162L;

    /**
     * cancel button.
     */
    private Button m_cancel;

    /**
     * Message text area.
     */
    private CmsRichTextAreaV7 m_message;

    /**
     * ok button.
     */
    private Button m_ok;

    private Button m_resetBroadcasts;

    private CheckBox m_repeat;

    /**
     * public constructor.<p>
     *
     * @param sessionIds to send broadcast to
     * @param closeRunnable called on cancel
     */
    public CmsSendBroadcastDialog(final Set<String> sessionIds, final Runnable closeRunnable) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        if (sessionIds != null) {
            displayResourceInfoDirectly(CmsSessionsApp.getUserInfos(sessionIds));
        } else {
            if (USER_BROADCAST.containsKey(A_CmsUI.getCmsObject().getRequestContext().getCurrentUser())) {
                m_message.setValue(USER_BROADCAST.get(A_CmsUI.getCmsObject().getRequestContext().getCurrentUser()).getMessage());
            }
        }
        m_resetBroadcasts.addClickListener(event -> removeAllBroadcasts(sessionIds));
        m_cancel.addClickListener(new Button.ClickListener() {

            private static final long serialVersionUID = 3105449865170606831L;

            public void buttonClick(ClickEvent event) {
                closeRunnable.run();
            }
        });
        m_ok.addClickListener(new Button.ClickListener() {

            private static final long serialVersionUID = -1148041995591262401L;

            public void buttonClick(ClickEvent event) {
                addValidator();
                if (isMessageValid()) {
                    sendBroadcast(sessionIds);
                    closeRunnable.run();
                }
            }
        });
    }

    /**
     * Adds validator to field.<p>
     */
    protected void addValidator() {
        m_message.removeAllValidators();
        m_message.addValidator(new MessageValidator());
    }

    /**
     * Checks if message is valid.<p>
     *
     * @return true if message is valid, false otherwise
     */
    protected boolean isMessageValid() {
        return m_message.isValid();
    }

    /**
     * Sends broadcast.<p>
     *
     * @param sessionIds to send broadcast to
     */
    protected void sendBroadcast(Set<String> sessionIds) {
        if (sessionIds == null) {
            OpenCms.getSessionManager().sendBroadcast(A_CmsUI.getCmsObject(), m_message.getValue(), m_repeat.getValue().booleanValue());
            USER_BROADCAST.put(A_CmsUI.getCmsObject().getRequestContext().getCurrentUser(), new CmsBroadcast(A_CmsUI.getCmsObject().getRequestContext().getCurrentUser(), m_message.getValue(), m_repeat.getValue().booleanValue()));
        } else {
            for (String id : sessionIds) {
                OpenCms.getSessionManager().sendBroadcast(A_CmsUI.getCmsObject(), m_message.getValue(), id, m_repeat.getValue().booleanValue());
            }
        }
    }

    /**
     * Removes all pending broadcasts
     *
     * @param sessionIds to remove broadcast for (or null for all sessions)
     */
    private void removeAllBroadcasts(Set<String> sessionIds) {
        if (sessionIds == null) {
            for (CmsSessionInfo info : OpenCms.getSessionManager().getSessionInfos()) {
                OpenCms.getSessionManager().getBroadcastQueue(info.getSessionId().getStringValue()).clear();
            }
            return;
        }
        for (String sessionId : sessionIds) {
            OpenCms.getSessionManager().getBroadcastQueue(sessionId).clear();
        }
    }
}

19 View Complete Implementation : CmsKillSessionDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the dialog to kill sessions.<p>
 */
public clreplaced CmsKillSessionDialog extends CmsBasicDialog {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = -7281930091176835024L;

    /**
     * The logger for this clreplaced.
     */
    static Log LOG = CmsLog.getLog(CmsKillSessionDialog.clreplaced.getName());

    /**
     * cancel button.
     */
    private Button m_cancelButton;

    /**
     * warning icon.
     */
    private Label m_icon;

    /**
     * vaadin component.
     */
    private Label m_label;

    /**
     * ok button.
     */
    private Button m_okButton;

    /**
     * public constructor. <p>
     *
     * @param sessionIds ids of sessions to be killed
     * @param canelRunnable runnable to be runned on cancel
     */
    public CmsKillSessionDialog(final Set<String> sessionIds, final Runnable canelRunnable) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        displayResourceInfoDirectly(CmsSessionsApp.getUserInfos(sessionIds));
        m_icon.setContentMode(ContentMode.HTML);
        m_icon.setValue(FontOpenCms.WARNING.getHtml());
        if (sessionIds.size() == 1) {
            m_label.setValue(CmsVaadinUtils.getMessageText(Messages.GUI_MESSAGES_CONFIRM_DESTROY_SESSION_SINGLE_0));
        }
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 5044360626122683306L;

            public void buttonClick(ClickEvent event) {
                for (String sessionId : sessionIds) {
                    try {
                        OpenCms.getSessionManager().killSession(A_CmsUI.getCmsObject(), new CmsUUID(sessionId));
                        LOG.info("Kill session of user with id '" + sessionId + "'");
                    } catch (NumberFormatException | CmsException e) {
                    // current session cannot be killed
                    }
                }
                canelRunnable.run();
            }
        });
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 6872628835561250226L;

            public void buttonClick(ClickEvent event) {
                canelRunnable.run();
            }
        });
    }
}

19 View Complete Implementation : CmsNewDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog for creating new resources.<p>
 */
@DesignRoot
public clreplaced CmsNewDialog extends A_CmsSelectResourceTypeDialog {

    /**
     * Element view selector.
     */
    protected ComboBox m_viewSelector;

    /**
     * Container for the type list.
     */
    protected VerticalLayout m_typeContainer;

    /**
     * Check box for enabling / disabling default creation folders.
     */
    protected CheckBox m_defaultLocationCheckbox;

    /**
     * The cancel button.
     */
    protected Button m_cancelButton;

    /**
     * Creates a new instance.<p>
     *
     * @param folderResource the folder resource
     * @param context the context
     */
    public CmsNewDialog(CmsResource folderResource, I_CmsDialogContext context) {
        super(folderResource, context);
        m_defaultLocationCheckbox.setValue(getInitialValueForUseDefaultLocationOption(folderResource));
        m_defaultLocationCheckbox.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {
                try {
                    init(m_currentView, ((Boolean) event.getProperty().getValue()).booleanValue());
                } catch (Exception e) {
                    m_dialogContext.error(e);
                }
            }
        });
    }

    @Override
    public Button getCancelButton() {
        return m_cancelButton;
    }

    @Override
    public VerticalLayout getVerticalLayout() {
        return m_typeContainer;
    }

    @Override
    public ComboBox getViewSelector() {
        return m_viewSelector;
    }

    /**
     * Handles selection of a type.<p>
     *
     * @param selectedType the selected type
     */
    @Override
    public void handleSelection(final CmsResourceTypeBean selectedType) {
        CmsObject cms = A_CmsUI.getCmsObject();
        m_selectedType = selectedType;
        try {
            CmsNewResourceBuilder builder = new CmsNewResourceBuilder(cms);
            builder.addCallback(new I_Callback() {

                public void onError(Exception e) {
                    m_dialogContext.error(e);
                }

                public void onResourceCreated(CmsNewResourceBuilder builderParam) {
                    finish(Lists.newArrayList(builderParam.getCreatedResource().getStructureId()));
                }
            });
            m_selectedType = selectedType;
            Boolean useDefaultLocation = m_defaultLocationCheckbox.getValue();
            if (useDefaultLocation.booleanValue() && (m_selectedType.getCreatePath() != null)) {
                try {
                    CmsADEConfigData configData = OpenCms.getADEManager().lookupConfiguration(cms, m_folderResource.getRootPath());
                    CmsResourceTypeConfig typeConfig = configData.getResourceType(m_selectedType.getType());
                    if (typeConfig != null) {
                        typeConfig.configureCreateNewElement(cms, m_folderResource.getRootPath(), builder);
                    }
                } catch (Exception e) {
                    m_dialogContext.error(e);
                }
            } else {
                boolean explorerNameGenerationMode = false;
                String sitePath = cms.getRequestContext().removeSiteRoot(m_folderResource.getRootPath());
                String namePattern = m_selectedType.getNamePattern();
                if (CmsStringUtil.isEmptyOrWhitespaceOnly(namePattern)) {
                    namePattern = OpenCms.getWorkplaceManager().getDefaultNamePattern(m_selectedType.getType());
                    explorerNameGenerationMode = true;
                }
                String fileName = CmsStringUtil.joinPaths(sitePath, namePattern);
                builder.setPatternPath(fileName);
                builder.setType(m_selectedType.getType());
                builder.setExplorerNameGeneration(explorerNameGenerationMode);
            }
            CmsPropertyDialogExtension ext = new CmsPropertyDialogExtension(A_CmsUI.get(), null);
            CmsAppWorkplaceUi.get().disableGlobalShortcuts();
            ext.editPropertiesForNewResource(builder);
            finish(new ArrayList<CmsUUID>());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public boolean useDefault() {
        return m_defaultLocationCheckbox.getValue().booleanValue();
    }

    /**
     * Gets the initial value for the 'default location' option.<p>
     *
     * @param folderResource the current folder
     *
     * @return the initial value for the option
     */
    private Boolean getInitialValueForUseDefaultLocationOption(CmsResource folderResource) {
        String rootPath = folderResource.getRootPath();
        return Boolean.valueOf(OpenCms.getSiteManager().getSiteForRootPath(rootPath) != null);
    }
}

19 View Complete Implementation : CmsSetupStep01License.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
public clreplaced CmsSetupStep01License extends A_CmsSetupStep {

    /**
     * Forward button.
     */
    private Button m_forwardButton;

    /**
     * License container.
     */
    private VerticalLayout m_licenseContainer;

    /**
     * Main layout.
     */
    private VerticalLayout m_mainLayout;

    /**
     * Creates a new instance.
     *
     * @param context the setup context
     *
     * @throws Exception if something goes wrong
     */
    public CmsSetupStep01License(I_SetupUiContext context) throws Exception {
        super(context);
        CmsVaadinUtils.readAndLocalizeDesign(this, null, null);
        CmsSetupBean setupBean = context.getSetupBean();
        m_forwardButton.setEnabled(false);
        if (setupBean == null) {
            m_mainLayout.addComponent(htmlLabel(readSnippet("notInitialized.html")));
        } else if (!setupBean.getWizardEnabled()) {
            m_mainLayout.addComponent(htmlLabel(readSnippet("wizardDisabled.html")));
        } else {
            Label label = htmlLabel(readSnippet("license.html"));
            label.setWidth("100%");
            m_licenseContainer.addComponent(label);
            CheckBox confirmation = new CheckBox();
            confirmation.setCaption("I accept all the terms of the preceeding license agreement");
            m_mainLayout.addComponent(confirmation);
            confirmation.addValueChangeListener(evt -> {
                m_forwardButton.setEnabled(evt.getValue().booleanValue());
            });
            m_forwardButton.addClickListener(evt -> m_context.stepForward());
        }
    }

    @Override
    protected boolean isEnableMaxHeight() {
        return false;
    }
}

19 View Complete Implementation : CmsSetupStep02ComponentCheck.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Setup step: component check.
 */
public clreplaced CmsSetupStep02ComponentCheck extends A_CmsSetupStep {

    /**
     * Test status enum.
     */
    enum TestColor {

        /**
         * Green.
         */
        green,
        /**
         * Red.
         */
        red,
        /**
         * Yellow.
         */
        yellow
    }

    /**
     * Message for green status.
     */
    public static final String STATUS_GREEN = "Your system uses components which have been tested to work properly with Alkacon OpenCms.";

    /**
     * Message for red status.
     */
    public static final String STATUS_RED = "Your system does not have the necessary components to use Alkacon OpenCms. It is replacedumed that OpenCms will not run on your system.";

    /**
     * Message for yellow status.
     */
    public static final String STATUS_YELLOW = "Your system uses components which have not been tested to work with Alkacon OpenCms. It is possible that OpenCms will not run on your system.";

    /**
     * Back button.
     */
    private Button m_backButton;

    /**
     * Confirmation checkbox.
     */
    private CheckBox m_confirmCheckbox;

    /**
     * Container for test failure notes.
     */
    private VerticalLayout m_failures;

    /**
     * Forward button.
     */
    private Button m_forwardButton;

    /**
     * Main layout.
     */
    private VerticalLayout m_mainLayout;

    /**
     * Status label.
     */
    private Label m_status;

    /**
     * Container for test results.
     */
    private VerticalLayout m_testContainer;

    /**
     * Creates a new instance.
     *
     * @param context the context
     */
    public CmsSetupStep02ComponentCheck(I_SetupUiContext context) {
        super(context);
        CmsVaadinUtils.readAndLocalizeDesign(this, null, null);
        // m_icon.setContentMode(ContentMode.HTML);
        CmsSetupTests tests = new CmsSetupTests();
        tests.runTests(context.getSetupBean());
        TestColor color = null;
        color = TestColor.green;
        if (tests.isRed()) {
            color = TestColor.red;
        } else if (tests.isYellow()) {
            color = TestColor.yellow;
        } else if (tests.isRed()) {
            color = TestColor.red;
        }
        m_confirmCheckbox.addValueChangeListener(evt -> m_forwardButton.setEnabled(evt.getValue().booleanValue()));
        updateColor(color);
        showTestResults(tests.getTestResults());
        m_forwardButton.addClickListener(evt -> m_context.stepForward());
        m_backButton.addClickListener(evt -> m_context.stepBack());
    }

    /**
     * Sets test status.
     */
    public void updateColor(TestColor color) {
        switch(color) {
            case green:
                m_forwardButton.setEnabled(true);
                m_confirmCheckbox.setVisible(false);
                m_status.setValue(STATUS_GREEN);
                break;
            case yellow:
                m_forwardButton.setEnabled(false);
                m_confirmCheckbox.setVisible(true);
                m_status.setValue(STATUS_YELLOW);
                break;
            case red:
                m_forwardButton.setEnabled(false);
                m_confirmCheckbox.setVisible(true);
                m_status.setValue(STATUS_RED);
                break;
            default:
                break;
        }
    }

    /**
     * Displays setup test results.
     *
     * @param testResults the test results
     */
    private void showTestResults(List<CmsSetupTestResult> testResults) {
        m_testContainer.removeAllComponents();
        VerticalLayout layout = new VerticalLayout();
        for (CmsSetupTestResult result : testResults) {
            Component resultWidget = new CmsSetupTestResultWidget(result);
            m_testContainer.addComponent(resultWidget);
            if (!result.isGreen()) {
                Label label = new Label(result.getInfo());
                label.setWidth("100%");
                m_failures.addComponent(label);
            }
        }
    }
}

19 View Complete Implementation : CmsServerModuleImportForm.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * The form for importing a module from the application server.<p>
 */
public clreplaced CmsServerModuleImportForm extends A_CmsModuleImportForm {

    /**
     * The log instance for this clreplaced.
     */
    private static final Log LOG = CmsLog.getLog(CmsServerModuleImportForm.clreplaced);

    /**
     * The Cancel button.
     */
    private Button m_cancel;

    /**
     * The select box used to select the module.
     */
    private ComboBox m_moduleSelect;

    /**
     * The OK button.
     */
    private Button m_ok;

    /**
     * The site selector.
     */
    private CmsAutoItemCreatingComboBox m_siteSelect;

    /**
     * Creates a new instance.<p>
     *
     * @param app the module manager app
     */
    public CmsServerModuleImportForm(CmsModuleApp app, VerticalLayout start, VerticalLayout report, Runnable run) {
        super(app, start, report, run);
        IndexedContainer options = new IndexedContainer();
        options.addContainerProperty("label", String.clreplaced, "");
        m_moduleSelect.setContainerDataSource(options);
        m_moduleSelect.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        m_moduleSelect.sereplacedemCaptionPropertyId("label");
        m_moduleSelect.setNullSelectionAllowed(false);
        String moduleDir = OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebInf("packages/modules");
        File moduleDirFile = new File(moduleDir);
        if (moduleDirFile.exists()) {
            List<File> files = Lists.newArrayList(moduleDirFile.listFiles());
            Collections.sort(files);
            for (File file : files) {
                if (file.isDirectory()) {
                    continue;
                }
                String path = file.getAbsolutePath();
                String name = file.getName();
                options.addItem(path).gereplacedemProperty("label").setValue(name);
            }
        }
        m_moduleSelect.addValueChangeListener(new ValueChangeListener() {

            public void valueChange(ValueChangeEvent event) {
                String path = (String) (event.getProperty().getValue());
                m_importFile = new CmsModuleImportFile(path);
                m_ok.setEnabled(false);
                validateModuleFile();
            }
        });
    }

    @Override
    protected Button getCancelButton() {
        return m_cancel;
    }

    @Override
    protected Button getOkButton() {
        return m_ok;
    }

    @Override
    protected CmsAutoItemCreatingComboBox getSiteSelector() {
        return m_siteSelect;
    }
}

19 View Complete Implementation : CmsForgotPasswordDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog to request a preplacedword reset link if you forgot your preplacedsword.<p>
 */
public clreplaced CmsForgotPreplacedwordDialog extends VerticalLayout implements I_CmsHasButtons {

    /**
     * The logger instance for this clreplaced.
     */
    private static final Log LOG = CmsLog.getLog(CmsForgotPreplacedwordDialog.clreplaced);

    /**
     * Serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * Field for the email address.
     */
    protected TextField m_emailField;

    /**
     * The user field.
     */
    protected TextField m_userField;

    /**
     * The OU selector.
     */
    protected CmsLoginOuSelector m_ouSelect;

    /**
     * Button to request the mail with the preplacedword reset link .
     */
    protected Button m_mailButton;

    /**
     * Button to cancel.
     */
    protected Button m_cancelButton;

    /**
     * Creates a new instance.<p>
     */
    public CmsForgotPreplacedwordDialog() {
        Locale locale = A_CmsUI.get().getLocale();
        CmsVaadinUtils.readAndLocalizeDesign(this, OpenCms.getWorkplaceManager().getMessages(locale), null);
        List<CmsOrganizationalUnit> ouList = CmsLoginHelper.getOrgUnitsForLoginDialog(A_CmsUI.getCmsObject(), null);
        m_ouSelect.initOrgUnits(ouList);
        String notEmptyMessage = CmsVaadinUtils.getMessageText(Messages.GUI_VALIDATION_FIELD_EMPTY_0);
        m_userField.setRequired(true);
        m_userField.setRequiredError(notEmptyMessage);
        m_emailField.setRequired(true);
        m_emailField.setRequiredError(notEmptyMessage);
        m_emailField.addValidator(new EmailValidator(Messages.get().getBundle(A_CmsUI.get().getLocale()).key(Messages.GUI_PWCHANGE_INVALID_EMAIL_0)));
        m_cancelButton.addClickListener(new Button.ClickListener() {

            /**
             * Serial version id.
             */
            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                cancel();
            }
        });
        m_mailButton.addClickListener(new Button.ClickListener() {

            /**
             * Serial version id.
             */
            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                boolean valid = true;
                for (AbstractField<?> field : Arrays.asList(m_userField, m_emailField)) {
                    try {
                        field.validate();
                    } catch (InvalidValueException e) {
                        valid = false;
                    }
                }
                if (!valid) {
                    return;
                }
                String selectedOu = m_ouSelect.getValue();
                selectedOu = (selectedOu != null) ? selectedOu : "";
                String fullName = CmsStringUtil.joinPaths(selectedOu, m_userField.getValue());
                if (sendPreplacedwordResetLink(CmsLoginUI.m_adminCms, fullName, m_emailField.getValue())) {
                    // Since we need to actually go to a different page here, we can't use a Vaadin notification,
                    // because we don't get notified on the server when the user clicks it.
                    CmsVaadinUtils.showAlert(Messages.get().getBundle(A_CmsUI.get().getLocale()).key(Messages.GUI_PWCHANGE_MAILSENT_HEADER_0), Messages.get().getBundle(A_CmsUI.get().getLocale()).key(Messages.GUI_PWCHANGE_MAILSENT_MESSAGE_0), new Runnable() {

                        public void run() {
                            A_CmsUI.get().getPage().setLocation(OpenCms.getLinkManager().subsreplaceduteLinkForUnknownTarget(CmsLoginUI.m_adminCms, CmsWorkplaceLoginHandler.LOGIN_HANDLER, false));
                        }
                    });
                }
            }
        });
    }

    /**
     * Tries to find a user with the given email address, and if one is found, sends a mail with the preplacedword reset link to them.<p>
     *
     * @param cms the CMS Context
     * @param fullUserName the full user name including OU
     * @param email the email address entered by the user
     * @return true if the mail could be sent
     */
    public static boolean sendPreplacedwordResetLink(CmsObject cms, String fullUserName, String email) {
        LOG.info("Trying to find user for email " + email);
        email = email.trim();
        try {
            CmsUser foundUser = null;
            try {
                foundUser = cms.readUser(fullUserName);
            } catch (CmsException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
            if ((foundUser == null) || CmsStringUtil.isEmptyOrWhitespaceOnly(email) || !email.equals(foundUser.getEmail()) || foundUser.isManaged() || foundUser.isWebuser()) {
                Notification.show(CmsVaadinUtils.getMessageText(Messages.GUI_PWCHANGE_EMAIL_MISMATCH_0), Type.ERROR_MESSAGE);
                return false;
            }
            long now = System.currentTimeMillis();
            long expiration = OpenCms.getLoginManager().getTokenLifetime() + now;
            String expirationStr = CmsVfsService.formatDateTime(cms, expiration);
            String token = CmsTokenValidator.createToken(cms, foundUser, now);
            String link = OpenCms.getLinkManager().getWorkplaceLink(cms, CmsWorkplaceLoginHandler.LOGIN_HANDLER, false) + "?at=" + token;
            LOG.info("Sending preplacedword reset link to user " + foundUser.getName() + ": " + link);
            CmsPreplacedwordChangeNotification notification = new CmsPreplacedwordChangeNotification(cms, foundUser, link, expirationStr);
            try {
                notification.send();
            } catch (EmailException e) {
                Notification.show(Messages.get().getBundle(A_CmsUI.get().getLocale()).key(Messages.GUI_PWCHANGE_MAIL_SEND_ERROR_0), Type.ERROR_MESSAGE);
                LOG.error(e.getLocalizedMessage(), e);
                return false;
            }
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
            Notification.show(e.getLocalizedMessage(), Type.ERROR_MESSAGE);
            return false;
        }
        return true;
    }

    /**
     * Cancels the dialog.<p>
     */
    public void cancel() {
        CmsObject cms = A_CmsUI.getCmsObject();
        String link = OpenCms.getLinkManager().subsreplaceduteLinkForUnknownTarget(cms, CmsWorkplaceLoginHandler.LOGIN_HANDLER, false);
        A_CmsUI.get().getPage().setLocation(link);
    }

    /**
     * @see org.opencms.ui.I_CmsHasButtons#getButtons()
     */
    public List<Button> getButtons() {
        return Arrays.asList(m_mailButton, m_cancelButton);
    }
}

19 View Complete Implementation : CmsInfoButton.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
public void setAdditionalButton(Button button) {
    m_addButton = button;
}

19 View Complete Implementation : CmsQuickLaunchEditor.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * App to edit the quick launch menu.<p>
 */
public clreplaced CmsQuickLaunchEditor extends VerticalLayout {

    /**
     * The sorting drop listener.<p>
     */
    protected clreplaced LayoutDropListener implements DropListener<CssLayout> {

        /**
         * The item height.
         */
        private static final int ITEM_HEIGHT = 88;

        /**
         * The item width.
         */
        private static final int ITEM_WIDTH = 176;

        /**
         * The layout width.
         */
        private static final int LAYOUT_WIDTH = 1158;

        /**
         * The serial version id.
         */
        private static final long serialVersionUID = 8420945711551716630L;

        /**
         * The drag target ordered layout.
         */
        private CssLayout m_layout;

        /**
         * Constructor.<p>
         *
         * @param layout the drop target layout
         */
        protected LayoutDropListener(CssLayout layout) {
            m_layout = layout;
        }

        /**
         * @see com.vaadin.ui.dnd.event.DropListener#drop(com.vaadin.ui.dnd.event.DropEvent)
         */
        public void drop(DropEvent<CssLayout> event) {
            // depending on the browser window width, different margins and paddings apply
            int layoutWidth = LAYOUT_WIDTH;
            int windowWidth = UI.getCurrent().getPage().getBrowserWindowWidth();
            if (windowWidth <= 983) {
                layoutWidth = windowWidth - 22;
            } else if (windowWidth <= 1220) {
                layoutWidth = windowWidth - 62;
            }
            int top = event.getMouseEventDetails().getRelativeY();
            int left = event.getMouseEventDetails().getRelativeX();
            int columnCount = layoutWidth / ITEM_WIDTH;
            int column = left / ITEM_WIDTH;
            int row = top / ITEM_HEIGHT;
            int index = (row * columnCount) + column;
            if (((column * ITEM_WIDTH) + (ITEM_WIDTH / 2)) < left) {
                index++;
            }
            Component sourceComponent = event.getDragSourceComponent().get();
            int currentIndex = m_layout.getComponentIndex(sourceComponent);
            if ((currentIndex != -1) && (currentIndex < index)) {
                index--;
            }
            if (currentIndex == index) {
                return;
            }
            // move component within the layout
            m_layout.removeComponent(sourceComponent);
            // avoid index out of bounds exceptions
            if (m_layout.getComponentCount() < index) {
                index = m_layout.getComponentCount();
            }
            m_layout.addComponent(sourceComponent, index);
        }
    }

    /**
     * The serial version id.
     */
    private static final long serialVersionUID = -6608352673763873030L;

    /**
     * The available apps drop target wrapper.
     */
    private CssLayout m_availableApps;

    /**
     * The cancel button.
     */
    private Button m_reset;

    /**
     * The standard apps layout.
     */
    private CssLayout m_standardApps;

    /**
     * The user apps drop target wrapper.
     */
    private CssLayout m_userApps;

    /**
     * Constructor.<p>
     */
    public CmsQuickLaunchEditor() {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        DropTargetExtension<CssLayout> userDrop = new DropTargetExtension<>(m_userApps);
        userDrop.addDropListener(new LayoutDropListener(m_userApps));
        m_userApps.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
        DropTargetExtension<CssLayout> availablesDrop = new DropTargetExtension<>(m_availableApps);
        availablesDrop.addDropListener(new LayoutDropListener(m_availableApps));
        m_reset.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                resetAppIcons();
            }
        });
    }

    /**
     * Initializes the app icon items.<p>
     */
    protected void resetAppIcons() {
        CmsObject cms = A_CmsUI.getCmsObject();
        Locale locale = UI.getCurrent().getLocale();
        m_standardApps.removeAllComponents();
        m_userApps.removeAllComponents();
        m_availableApps.removeAllComponents();
        Collection<I_CmsWorkplaceAppConfiguration> allApps = OpenCms.getWorkplaceAppManager().getWorkplaceApps();
        Collection<I_CmsWorkplaceAppConfiguration> standardApps = OpenCms.getWorkplaceAppManager().getDefaultQuickLaunchConfigurations();
        Collection<I_CmsWorkplaceAppConfiguration> userApps = OpenCms.getWorkplaceAppManager().getUserQuickLauchConfigurations(cms);
        for (I_CmsWorkplaceAppConfiguration config : standardApps) {
            CmsAppVisibilityStatus visibility = config.getVisibility(cms);
            if (visibility.isVisible()) {
                Button button = CmsDefaultAppButtonProvider.createAppIconButton(config, locale);
                m_standardApps.addComponent(button);
            }
        }
        for (I_CmsWorkplaceAppConfiguration config : userApps) {
            CmsAppVisibilityStatus visibility = config.getVisibility(cms);
            if (visibility.isVisible() && visibility.isActive()) {
                Button button = CmsDefaultAppButtonProvider.createAppIconButton(config, locale);
                // button.setWidth("166px");
                DragSourceExtension<Button> extButton = new DragSourceExtension<>(button);
                button.setData(config.getId());
                extButton.setDataTransferText(config.getId());
                m_userApps.addComponent(button);
            }
        }
        for (I_CmsWorkplaceAppConfiguration config : allApps) {
            CmsAppVisibilityStatus visibility = config.getVisibility(cms);
            if (!standardApps.contains(config) && !userApps.contains(config) && visibility.isVisible() && visibility.isActive()) {
                Button button = CmsDefaultAppButtonProvider.createAppIconButton(config, locale);
                // button.setWidth("166px");
                DragSourceExtension<Button> extButton = new DragSourceExtension<>(button);
                button.setData(config.getId());
                extButton.setDataTransferText(config.getId());
                m_availableApps.addComponent(button);
            }
        }
    }

    /**
     * Saves the changed apps setting.<p>
     */
    void saveToUser() {
        List<String> apps = new ArrayList<String>();
        int count = m_userApps.getComponentCount();
        for (int i = 0; i < count; i++) {
            Button button = (Button) m_userApps.getComponent(i);
            apps.add((String) button.getData());
        }
        try {
            OpenCms.getWorkplaceAppManager().setUserQuickLaunchApps(A_CmsUI.getCmsObject(), apps);
        } catch (Exception e) {
            CmsErrorDialog.showErrorDialog("Could not write user Quicklaunch apps", e);
        }
    }
}

19 View Complete Implementation : CmsSourceDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the dialog to show source information of a given index.<p>
 */
public clreplaced CmsSourceDialog extends CmsBasicDialog {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = 4302977301857481351L;

    /**
     * vaadin serial id.
     */
    private Button m_cancelButton;

    /**
     * vaadin serial id.
     */
    private FormLayout m_layout;

    /**
     * Manager app.
     */
    private I_CmsCRUDApp<I_CmsSearchIndex> m_manager;

    /**
     * public constructor.<p>
     * @param app calling app instance
     *
     * @param cancel runnable to be started when the dialog gets closed
     */
    public CmsSourceDialog(I_CmsCRUDApp<I_CmsSearchIndex> app, final Runnable cancel) {
        m_manager = app;
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_cancelButton.addClickListener(new Button.ClickListener() {

            private static final long serialVersionUID = -4321889329235244258L;

            public void buttonClick(ClickEvent event) {
                cancel.run();
            }
        });
    }

    /**
     * Sets the search index to show information about.<p>
     *
     * @param searchindex to be displayed
     */
    public void setSource(String searchindex) {
        Label label = new Label();
        label.setContentMode(ContentMode.HTML);
        label.setValue(getSources(searchindex));
        m_layout.removeAllComponents();
        m_layout.addComponent(label);
    }

    /**
     * Fills details of the index source into the given item. <p>
     *
     * @param indexName name of index
     * @return String representation of information about given index
     */
    private String getSources(String indexName) {
        StringBuffer html = new StringBuffer();
        // search for the corresponding A_CmsSearchIndex:
        I_CmsSearchIndex idx = m_manager.getElement(indexName);
        html.append("<ul>\n");
        // get the index sources (nice API)
        for (CmsSearchIndexSource idxSource : idx.getSources()) {
            html.append("  <li>\n").append("    ").append("name      : ").append(idxSource.getName()).append("\n");
            html.append("  </li>");
            html.append("  <li>\n").append("    ").append("indexer   : ").append(idxSource.getIndexerClreplacedName()).append("\n");
            html.append("  </li>");
            html.append("  <li>\n").append("    ").append("resources : ").append("\n");
            html.append("    <ul>\n");
            List<String> resources = idxSource.getResourcesNames();
            Iterator<String> itResources = resources.iterator();
            while (itResources.hasNext()) {
                html.append("    <li>\n").append("      ").append(itResources.next()).append("\n");
                html.append("    </li>\n");
            }
            html.append("    </ul>\n");
            html.append("  </li>");
            html.append("  <li>\n").append("    ").append("doctypes : ").append("\n");
            html.append("    <ul>\n");
            resources = idxSource.getDoreplacedentTypes();
            itResources = resources.iterator();
            while (itResources.hasNext()) {
                html.append("    <li>\n").append("      ").append(itResources.next()).append("\n");
                html.append("    </li>\n");
            }
            html.append("    </ul>\n");
            html.append("  </li>");
        }
        html.append("</ul>\n");
        return html.toString();
    }
}

19 View Complete Implementation : CmsDbImportServer.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the import from server option.<p>
 */
public clreplaced CmsDbImportServer extends A_CmsServerImportForm {

    /**
     * Vaadin serial id.
     */
    private static final long serialVersionUID = -1489144623755018754L;

    /**
     * vaadin component.
     */
    private CheckBox m_keepPermissions;

    /**
     * vaadin component.
     */
    private ComboBox m_moduleSelect;

    /**
     * vaadin component.
     */
    private Button m_ok;

    /**
     * vaadin component.
     */
    private ComboBox m_siteSelect;

    /**
     * vaadin component.
     */
    private ComboBox m_projectSelect;

    /**
     * Public constructor.<p>
     *
     * @param app which calls the form
     */
    public CmsDbImportServer(I_CmsReportApp app) {
        super(app, "packages", false);
    }

    /**
     * @see org.opencms.ui.apps.dbmanager.A_CmsServerImportForm#getImportSelect()
     */
    @Override
    public ComboBox getImportSelect() {
        return m_moduleSelect;
    }

    /**
     * @see org.opencms.ui.apps.dbmanager.A_CmsImportForm#getThread()
     */
    @Override
    public A_CmsReportThread getThread() {
        return new CmsDatabaseImportThread(getCmsObject(), m_importFile.getPath(), m_keepPermissions.getValue().booleanValue());
    }

    /**
     * @see org.opencms.ui.apps.dbmanager.A_CmsImportForm#getCancelButton()
     */
    @Override
    protected Button getCancelButton() {
        return null;
    }

    /**
     * @see org.opencms.ui.apps.dbmanager.A_CmsImportForm#getOkButton()
     */
    @Override
    protected Button getOkButton() {
        return m_ok;
    }

    @Override
    protected ComboBox getProjectSelector() {
        return m_projectSelect;
    }

    /**
     * @see org.opencms.ui.apps.dbmanager.A_CmsImportForm#getReportPath()
     */
    @Override
    protected String getReportPath() {
        return CmsDbImportApp.PATH_REPORT_SERVER;
    }

    /**
     * @see org.opencms.ui.apps.dbmanager.A_CmsImportForm#getSiteSelector()
     */
    @Override
    protected ComboBox getSiteSelector() {
        return m_siteSelect;
    }

    /**
     * @see org.opencms.ui.apps.dbmanager.A_CmsImportForm#getreplacedle()
     */
    @Override
    protected String getreplacedle() {
        return CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_IMPORTSERVER_ADMIN_TOOL_NAME_0);
    }
}

19 View Complete Implementation : CmsFlushButtonHolderDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog for the flush actions.<p>
 */
public clreplaced CmsFlushButtonHolderDialog extends CmsBasicDialog {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = -223664443814758803L;

    /**
     * vaadin component.
     */
    private Button m_cancelButton;

    /**
     * public constructor.<p>
     *
     * @param window window
     */
    public CmsFlushButtonHolderDialog(final Window window) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        VerticalLayout layout = CmsFlushCache.getButtonLayout(0, new Runnable() {

            public void run() {
                window.close();
                A_CmsUI.get().reload();
            }
        });
        layout.addStyleName("o-center");
        setContent(layout);
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 2203061285642153560L;

            public void buttonClick(ClickEvent event) {
                window.close();
            }
        });
        window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_CACHE_CLEAN_0));
    }
}

19 View Complete Implementation : CmsSetupStep04Modules.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Setup step: Selecting components (= module groups).
 */
public clreplaced CmsSetupStep04Modules extends A_CmsSetupStep {

    /**
     * Serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * Back button.
     */
    private Button m_backButton;

    /**
     * The list of check boxes for the components.
     */
    private List<CheckBox> m_componentCheckboxes = new ArrayList<>();

    /**
     * The map of components, with their ids as keys.
     */
    private Map<String, CmsSetupComponent> m_componentMap = new HashMap<>();

    /**
     * Panel for components.
     */
    private FormLayout m_components;

    /**
     * The forward button.
     */
    private Button m_forwardButton;

    /**
     * Creates a new instance.
     *
     * @param context the setup context
     */
    public CmsSetupStep04Modules(I_SetupUiContext context) {
        super(context);
        CmsVaadinUtils.readAndLocalizeDesign(this, null, null);
        CmsSetupBean bean = context.getSetupBean();
        bean.getAvailableModules();
        initComponents(bean.getComponents().elementList());
        m_forwardButton.addClickListener(evt -> forward());
        m_backButton.addClickListener(evt -> m_context.stepBack());
    }

    /**
     * Moves to the next step.
     */
    private void forward() {
        Set<String> selected = new HashSet<>();
        for (CheckBox checkbox : m_componentCheckboxes) {
            CmsSetupComponent component = (CmsSetupComponent) (checkbox.getData());
            if (checkbox.getValue().booleanValue()) {
                selected.add(component.getId());
            }
        }
        String error = null;
        for (String compId : selected) {
            CmsSetupComponent component = m_componentMap.get(compId);
            for (String dep : component.getDependencies()) {
                if (!selected.contains(dep)) {
                    error = "Unfulfilled dependency: The component " + component.getName() + " can not be installed because its dependency " + m_componentMap.get(dep).getName() + " is not selected";
                    break;
                }
            }
        }
        if (error == null) {
            Set<String> modules = new HashSet<>();
            for (CmsSetupComponent component : m_componentMap.values()) {
                if (selected.contains(component.getId())) {
                    for (CmsModule module : m_context.getSetupBean().getAvailableModules().values()) {
                        if (component.match(module.getName())) {
                            modules.add(module.getName());
                        }
                    }
                }
            }
            List<String> moduleList = new ArrayList<>(modules);
            m_context.getSetupBean().setInstallModules(CmsStringUtil.listreplacedtring(moduleList, "|"));
            m_context.stepForward();
        } else {
            CmsSetupErrorDialog.showErrorDialog(error, error);
        }
    }

    /**
     * Initializes the components.
     *
     * @param components the components
     */
    private void initComponents(List<CmsSetupComponent> components) {
        for (CmsSetupComponent component : components) {
            CheckBox checkbox = new CheckBox();
            checkbox.setValue(component.isChecked());
            checkbox.setCaption(component.getName() + " - " + component.getDescription());
            checkbox.setDescription(component.getDescription());
            checkbox.setData(component);
            checkbox.setWidth("100%");
            m_components.addComponent(checkbox);
            m_componentCheckboxes.add(checkbox);
            m_componentMap.put(component.getId(), component);
        }
    }
}

19 View Complete Implementation : CmsDataViewDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog used to select data items from an external data source.<p>
 */
public clreplaced CmsDataViewDialog extends CmsBasicDialog {

    /**
     * The serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * The container for the other widgets.
     */
    private VerticalLayout m_container;

    /**
     * The OK button.
     */
    private Button m_okButton;

    /**
     * The cancel button.
     */
    private Button m_cancelButton;

    /**
     * The dialog context.
     */
    private I_CmsDialogContext m_context;

    /**
     * Creates a new instance.<p>
     *
     * @param context the dialog context
     */
    public CmsDataViewDialog(I_CmsDialogContext context) {
        m_context = context;
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        final CmsDataViewParams params = new CmsDataViewParams(A_CmsUI.get().getPage().getLocation());
        I_CmsDataView example = params.createViewInstance(context.getCms(), A_CmsUI.get().getLocale());
        final CmsDataViewPanel panel = new CmsDataViewPanel(example, params.isMultiSelect());
        panel.setSizeFull();
        m_container.addComponent(panel);
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @SuppressWarnings("synthetic-access")
            public void buttonClick(ClickEvent event) {
                List<I_CmsDataViewItem> result = panel.getSelection();
                String script = params.prepareCallbackScript(result);
                JavaScript.eval(script);
                m_context.finish(null);
            }
        });
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @SuppressWarnings("synthetic-access")
            public void buttonClick(ClickEvent event) {
                m_context.finish(null);
            }
        });
    }
}

19 View Complete Implementation : CmsSiteSelectDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * The dialog for selecting a site when exporting / deleting a module without a module site.<p>
 */
public clreplaced CmsSiteSelectDialog extends CmsBasicDialog {

    /**
     * Callback for the code using the dialog.<p>
     */
    interface I_Callback {

        /**
         * Called when the user cancels the site select dialog.<p>
         */
        void onCancel();

        /**
         * Called when the user selects a site.<p>
         *
         * @param site the selected site root
         */
        void onSiteSelect(String site);
    }

    /**
     * The property id for the caption.
     */
    private static final String CAPTION_PROP = "caption";

    /**
     * Serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * The callback to call when the dialog finishes.
     */
    private I_Callback m_callback;

    /**
     * The Cancel button.
     */
    private Button m_cancelButton;

    /**
     * The OK button.
     */
    private Button m_okButton;

    /**
     * The site selector.
     */
    private ComboBox m_siteSelector;

    /**
     * Creates a new instance.<p>
     */
    public CmsSiteSelectDialog() {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        CmsObject cms = A_CmsUI.getCmsObject();
        IndexedContainer container = CmsVaadinUtils.getAvailableSitesContainer(cms, CAPTION_PROP);
        m_siteSelector.setContainerDataSource(container);
        m_siteSelector.sereplacedemCaptionPropertyId(CAPTION_PROP);
        m_siteSelector.setNullSelectionAllowed(false);
        m_siteSelector.setValue(cms.getRequestContext().getSiteRoot());
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @SuppressWarnings("synthetic-access")
            public void buttonClick(ClickEvent event) {
                m_callback.onSiteSelect(getSite());
            }
        });
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @SuppressWarnings("synthetic-access")
            public void buttonClick(ClickEvent event) {
                m_callback.onCancel();
            }
        });
    }

    /**
     * Opens the site selection dialog in a window.<p>
     *
     * @param callback the callback to call when the dialog finishes
     * @param windowCaption the window caption
     */
    public static void openDialogInWindow(final I_Callback callback, String windowCaption) {
        final Window window = CmsBasicDialog.prepareWindow();
        window.setCaption(windowCaption);
        CmsSiteSelectDialog dialog = new CmsSiteSelectDialog();
        window.setContent(dialog);
        dialog.setCallback(new I_Callback() {

            public void onCancel() {
                window.close();
                callback.onCancel();
            }

            public void onSiteSelect(String site) {
                window.close();
                callback.onSiteSelect(site);
            }
        });
        A_CmsUI.get().addWindow(window);
    }

    /**
     * Gets the selected site.<p>
     *
     * @return the selected site
     */
    public String getSite() {
        return (String) (m_siteSelector.getValue());
    }

    /**
     * Sets the callback that should be called when the dialog finishes.<p<
     *
     * @param callback the callback to call when the dialog finishes
     */
    public void setCallback(I_Callback callback) {
        m_callback = callback;
    }
}

19 View Complete Implementation : CmsUndeleteDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog used to change resource modification times.<p>
 */
public clreplaced CmsUndeleteDialog extends CmsBasicDialog {

    /**
     * Logger instance for this clreplaced.
     */
    private static final Log LOG = CmsLog.getLog(CmsUndeleteDialog.clreplaced);

    /**
     * Serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * The dialog context.
     */
    protected I_CmsDialogContext m_context;

    /**
     * The Cancel button.
     */
    private Button m_cancelButton;

    /**
     * The OK  button.
     */
    private Button m_okButton;

    /**
     * Creates a new instance.<p>
     *
     * @param context the dialog context
     */
    public CmsUndeleteDialog(I_CmsDialogContext context) {
        m_context = context;
        CmsVaadinUtils.readAndLocalizeDesign(this, OpenCms.getWorkplaceManager().getMessages(A_CmsUI.get().getLocale()), null);
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                cancel();
            }
        });
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                submit();
            }
        });
        setActionHandler(new CmsOkCancelActionHandler() {

            private static final long serialVersionUID = 1L;

            @Override
            protected void cancel() {
                CmsUndeleteDialog.this.cancel();
            }

            @Override
            protected void ok() {
                submit();
            }
        });
    }

    /**
     * Undeletes the selected files
     *
     * @return the ids of the modified resources
     *
     * @throws CmsException if something goes wrong
     */
    protected List<CmsUUID> undelete() throws CmsException {
        List<CmsUUID> modifiedResources = new ArrayList<CmsUUID>();
        CmsObject cms = m_context.getCms();
        for (CmsResource resource : m_context.getResources()) {
            CmsLockActionRecord actionRecord = null;
            try {
                actionRecord = CmsLockUtil.ensureLock(m_context.getCms(), resource);
                cms.undeleteResource(cms.getSitePath(resource), true);
                modifiedResources.add(resource.getStructureId());
            } finally {
                if ((actionRecord != null) && (actionRecord.getChange() == LockChange.locked)) {
                    try {
                        cms.unlockResource(resource);
                    } catch (CmsLockException e) {
                        LOG.warn(e.getLocalizedMessage(), e);
                    }
                }
            }
        }
        return modifiedResources;
    }

    /**
     * Cancels the dialog.<p>
     */
    void cancel() {
        m_context.finish(new ArrayList<CmsUUID>());
    }

    /**
     * Submits the dialog.<p>
     */
    void submit() {
        try {
            List<CmsUUID> modifiedResources = undelete();
            m_context.finish(modifiedResources);
        } catch (Exception e) {
            m_context.error(e);
        }
    }
}

19 View Complete Implementation : CmsLinkValidationExternal.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the external link validation.<p>
 */
public clreplaced CmsLinkValidationExternal extends VerticalLayout {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = 4901058101922988640L;

    /**
     * Button to start validation.
     */
    private Button m_exec;

    /**
     * Label showing last report.
     */
    private Label m_oldReport;

    /**
     * Vaadin component.
     */
    private FormLayout m_threadReport;

    /**
     * constructor.<p>
     */
    protected CmsLinkValidationExternal() {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_oldReport.setContentMode(ContentMode.HTML);
        m_oldReport.setHeight("500px");
        m_oldReport.addStyleName("v-scrollable");
        m_oldReport.addStyleName("o-report");
        CmsExternalLinksValidationResult result = OpenCms.getLinkManager().getPointerLinkValidationResult();
        if (result == null) {
            m_oldReport.setValue(CmsVaadinUtils.getMessageText(Messages.GUI_LINKVALIDATION_NO_VALIDATION_YET_0));
        } else {
            m_oldReport.setValue(result.toHtml(OpenCms.getWorkplaceManager().getWorkplaceLocale(A_CmsUI.getCmsObject())));
        }
        m_exec.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -3281073871585942686L;

            public void buttonClick(ClickEvent event) {
                startValidation();
            }
        });
    }

    /**
     * Enables the button to start the validation.<p>
     */
    void enableButton() {
        m_exec.setEnabled(true);
    }

    /**
     * Starts the validation.<p>
     */
    void startValidation() {
        m_oldReport.setVisible(false);
        m_threadReport.removeAllComponents();
        CmsExternalLinksValidatorThread thread = new CmsExternalLinksValidatorThread(A_CmsUI.getCmsObject(), new Runnable() {

            public void run() {
                enableButton();
            }
        });
        thread.start();
        CmsReportWidget reportWidget = new CmsReportWidget(thread);
        reportWidget.setHeight("500px");
        m_threadReport.addComponent(reportWidget);
        m_exec.setEnabled(false);
    }
}

19 View Complete Implementation : CmsSqlConsoleResultsForm.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Displays results from an SQL query.<p>
 */
public clreplaced CmsSqlConsoleResultsForm extends CmsBasicDialog {

    /**
     * CSV generator for the download button.
     */
    public clreplaced CsvSource implements StreamSource {

        /**
         * Serial version id.
         */
        private static final long serialVersionUID = 1L;

        /**
         * The results.
         */
        private CmsSqlConsoleResults m_results;

        /**
         * Creates a new instance.
         *
         * @param results the results
         */
        public CsvSource(CmsSqlConsoleResults results) {
            m_results = results;
        }

        /**
         * @see com.vaadin.server.StreamResource.StreamSource#getStream()
         */
        public InputStream getStream() {
            try {
                return new ByteArrayInputStream(m_results.getCsv().getBytes("UTF-8"));
            } catch (UnsupportedEncodingException e) {
                return null;
            }
        }
    }

    /**
     * Serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * The CSV download button.
     */
    protected Button m_csv;

    /**
     * The OK button.
     */
    protected Button m_ok;

    /**
     * The table container.
     */
    protected VerticalLayout m_tableContainer;

    /**
     * The label for displaying the report output.
     */
    private Label m_reportOutput;

    /**
     * Creates a new instance.<p>
     *
     * @param results the database results
     * @param reportOutput the report output
     */
    public CmsSqlConsoleResultsForm(CmsSqlConsoleResults results, String reportOutput) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_ok.addClickListener(evt -> CmsVaadinUtils.getWindow(CmsSqlConsoleResultsForm.this).close());
        if (results != null) {
            Table table = buildTable(results);
            m_tableContainer.addComponent(table);
            StreamResource res = new StreamResource(new CsvSource(results), "data.csv");
            res.setMIMEType("text/plain; charset=utf-8");
            FileDownloader downloader = new FileDownloader(res);
            downloader.extend(m_csv);
        } else {
            m_csv.setVisible(false);
        }
        m_reportOutput.setContentMode(ContentMode.PREFORMATTED);
        m_reportOutput.setValue(reportOutput);
    }

    /**
     * Builds the table for the database results.
     *
     * @param results the database results
     * @return the table
     */
    private Table buildTable(CmsSqlConsoleResults results) {
        IndexedContainer container = new IndexedContainer();
        int numCols = results.getColumns().size();
        for (int c = 0; c < numCols; c++) {
            container.addContainerProperty(Integer.valueOf(c), results.getColumnType(c), null);
        }
        int r = 0;
        for (List<Object> row : results.getData()) {
            Item item = container.addItem(Integer.valueOf(r));
            for (int c = 0; c < numCols; c++) {
                item.gereplacedemProperty(Integer.valueOf(c)).setValue(row.get(c));
            }
            r += 1;
        }
        Table table = new Table();
        table.setContainerDataSource(container);
        for (int c = 0; c < numCols; c++) {
            String col = (results.getColumns().get(c));
            table.setColumnHeader(Integer.valueOf(c), col);
        }
        table.setWidth("100%");
        table.setHeight("100%");
        table.setColumnCollapsingAllowed(true);
        return table;
    }
}

19 View Complete Implementation : CmsTemplateMapperDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog for running the template mapper report thread.<p>
 */
public clreplaced CmsTemplateMapperDialog extends CmsBasicDialog {

    /**
     * Serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * The start button.
     */
    private Button m_okButton;

    /**
     * The report thread.
     */
    private A_CmsReportThread m_report;

    /**
     * Creates a new instance.<p>
     *
     * @param context the dialog context
     */
    public CmsTemplateMapperDialog(I_CmsDialogContext context) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        displayResourceInfo(context.getResources());
        m_okButton.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_TEMPLATEMAPPER_START_0));
        VerticalLayout content = new VerticalLayout();
        content.setWidth("100%");
        content.setHeight("500px");
        setContent(content);
        m_okButton.addClickListener(event -> {
            CmsReportWidget reportWidget = new CmsReportWidget(m_report);
            reportWidget.setWidth("100%");
            reportWidget.setHeight("100%");
            content.addComponent(reportWidget);
            m_okButton.setEnabled(false);
            m_report.start();
        });
    }

    /**
     * Sets the report thread.<p>
     *
     * @param report the report thread
     */
    public void setReportThread(A_CmsReportThread report) {
        m_report = report;
    }
}

19 View Complete Implementation : CmsValueCompareBean.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Represents a row of the XML content value comparison table.<p>
 */
public clreplaced CmsValueCompareBean {

    /**
     * The CMS context.
     */
    private CmsObject m_cms;

    /**
     * The element comparison.
     */
    private CmsElementComparison m_elemComp;

    /**
     * The button representing the change type.
     */
    private Button m_getChangeTypeButton;

    /**
     * Creates a new instance.<p>
     *
     * @param cms the CMS context
     * @param elemComp the element comparison bean
     */
    public CmsValueCompareBean(CmsObject cms, CmsElementComparison elemComp) {
        m_cms = cms;
        m_elemComp = elemComp;
        String changeType = m_elemComp.getStatus();
        String key = null;
        String style = null;
        if (CmsResourceComparison.TYPE_ADDED.equals(changeType)) {
            key = org.opencms.workplace.comparison.Messages.GUI_COMPARE_ADDED_0;
            style = OpenCmsTheme.DIFF_TYPE_ADDED;
        } else if (CmsResourceComparison.TYPE_REMOVED.equals(changeType)) {
            key = org.opencms.workplace.comparison.Messages.GUI_COMPARE_REMOVED_0;
            style = OpenCmsTheme.DIFF_TYPE_DELETED;
        } else if (CmsResourceComparison.TYPE_CHANGED.equals(changeType)) {
            key = org.opencms.workplace.comparison.Messages.GUI_COMPARE_CHANGED_0;
            style = OpenCmsTheme.DIFF_TYPE_CHANGED;
        } else {
            key = org.opencms.workplace.comparison.Messages.GUI_COMPARE_UNCHANGED_0;
            style = OpenCmsTheme.DIFF_TYPE_UNCHANGED;
        }
        Button result = new Button();
        result.setCaption(CmsVaadinUtils.getMessageText(key));
        result.addStyleName(ValoTheme.BUTTON_LINK);
        result.addStyleName(style);
        m_getChangeTypeButton = result;
    }

    /**
     * Formats an xml content value string for display in the value comparison table.<p>
     *
     * @param cms the CMS context
     * @param comparison the element comparison
     * @param origValue the XML content value as a string
     *
     * @return the formatted string
     */
    public static String formatContentValueForDiffTable(CmsObject cms, CmsElementComparison comparison, String origValue) {
        String result = CmsStringUtil.subsreplacedute(CmsStringUtil.trimToSize(origValue, 60), "\n", "");
        // formatting DateTime
        if (comparison instanceof CmsXmlContentElementComparison) {
            if (((CmsXmlContentElementComparison) comparison).getType().equals(CmsXmlDateTimeValue.TYPE_NAME)) {
                if (CmsStringUtil.isNotEmpty(result)) {
                    result = CmsDateUtil.getDateTime(new Date(Long.parseLong(result)), DateFormat.SHORT, cms.getRequestContext().getLocale());
                }
            }
        }
        return result;
    }

    /**
     * Gets the change type, as a button.<p>
     *
     * @return the change type
     */
    @Column(header = Messages.GUI_HISTORY_DIALOG_COL_CHANGETYPE_0, order = 10)
    public Button getChangeType() {
        return m_getChangeTypeButton;
    }

    /**
     * Gets the locale.<p>
     *
     * @return the locale
     */
    @Column(header = Messages.GUI_HISTORY_DIALOG_COL_LOCALE_0, order = 20)
    public String getLocale() {
        return m_elemComp.getLocale().toString();
    }

    /**
     * Gets the value for the first version.<p>
     *
     * @return the value for the first version
     */
    @Column(header = "V1 (%(v1))", order = 40)
    public String getV1() {
        return CmsValueCompareBean.formatContentValueForDiffTable(m_cms, m_elemComp, m_elemComp.getVersion1());
    }

    /**
     * Gets the value for the second version.<p>
     *
     * @return the value for the second version
     */
    @Column(header = "V2 (%(v2))", order = 50)
    public String getV2() {
        return CmsValueCompareBean.formatContentValueForDiffTable(m_cms, m_elemComp, m_elemComp.getVersion2());
    }

    /**
     * Gets the element name.<p>
     *
     * @return the element name
     */
    @Column(header = Messages.GUI_HISTORY_DIALOG_COL_XPATH_0, order = 30)
    public String getXPath() {
        return m_elemComp.getName();
    }
}

19 View Complete Implementation : CmsDbSynchronizationApp.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the database synchronization app.<p>
 */
public clreplaced CmsDbSynchronizationApp extends A_CmsAttributeAwareApp {

    /**
     * vaadin component.
     */
    private Button m_refresh;

    /**
     * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getBreadCrumbForState(java.lang.String)
     */
    @Override
    protected LinkedHashMap<String, String> getBreadCrumbForState(String state) {
        LinkedHashMap<String, String> crumbs = new LinkedHashMap<String, String>();
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(state)) {
            crumbs.put("", CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_SYNC_NAME_0));
            return crumbs;
        }
        return new LinkedHashMap<String, String>();
    }

    /**
     * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getComponentForState(java.lang.String)
     */
    @Override
    protected Component getComponentForState(String state) {
        if (m_refresh == null) {
            m_refresh = CmsToolBar.createButton(FontAwesome.REFRESH, CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_SYNCH_RUN_0));
            m_refresh.addClickListener(new Button.ClickListener() {

                private static final long serialVersionUID = 4980773759687185944L;

                public void buttonClick(ClickEvent event) {
                    final Window window = CmsBasicDialog.prepareWindow(DialogWidth.wide);
                    window.setContent(new CmsDbSynchDialog(new Runnable() {

                        public void run() {
                            window.close();
                        }
                    }));
                    window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_SYNCH_RUN_0));
                    A_CmsUI.get().addWindow(window);
                }
            });
            m_uiContext.addToolbarButton(m_refresh);
        }
        CmsDbSynchronizationView view = new CmsDbSynchronizationView(this);
        if (CmsStringUtil.isEmptyOrWhitespaceOnly(state)) {
            return view;
        }
        return null;
    }

    /**
     * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getSubNavEntries(java.lang.String)
     */
    @Override
    protected List<NavEntry> getSubNavEntries(String state) {
        return null;
    }

    /**
     * Sets the visivility of the refresh button.<p>
     *
     * @param visible true -> button is visible
     */
    protected void setRefreshButton(boolean visible) {
        m_refresh.setVisible(visible);
    }
}

19 View Complete Implementation : CmsMacroResolverDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for a dialog to show macros of a sitemap folder and allow the user to edit them.<p>
 */
public clreplaced CmsMacroResolverDialog extends CmsBasicDialog {

    /**
     * generated vaadin serial id.
     */
    private static final long serialVersionUID = 4326570443207345219L;

    /**
     * Action to execute when cancelled.
     */
    Runnable m_cancelAction;

    /**
     * Action to execute when confirmed.
     */
    Runnable m_okAction;

    /**
     * Map for storing relations for Vaadin Components to related key values.
     */
    private Map<TextField, String> m_bundleComponentKeyMap = new HashMap<TextField, String>();

    /**
     * Form Layout for displaying the bundle valuse in.
     */
    private FormLayout m_bundleValues;

    /**
     * Cancel button.
     */
    private Button m_cancelButton;

    /**
     * OK button .
     */
    private Button m_okButton;

    /**
     * Public constructor.<p>
     *
     * @param okAction runnable for ok button.
     * @param cancelAction runnable for cancel button.
     * @param resource (folder) to resolve macros in.
     */
    public CmsMacroResolverDialog(Runnable okAction, Runnable cancelAction, CmsResource resource) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_okAction = okAction;
        m_cancelAction = cancelAction;
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                if (m_okAction != null) {
                    m_okAction.run();
                }
            }
        });
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                if (m_cancelAction != null) {
                    m_cancelAction.run();
                }
            }
        });
        CmsObject cms;
        try {
            cms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
            cms.getRequestContext().setSiteRoot("");
            // Read descriptor
            CmsResource descriptor = cms.readResource(resource.getRootPath() + CmsSiteManager.MACRO_FOLDER + "/" + CmsSiteManager.BUNDLE_NAME + "_desc");
            // Read related bundle
            Properties resourceBundle = getLocalizedBundle(cms, resource.getRootPath());
            Map<String, String[]> bundleKeyDescriptorMap = CmsMacroResolver.getBundleMapFromResources(resourceBundle, descriptor, cms);
            for (String key : bundleKeyDescriptorMap.keySet()) {
                // Create TextField
                TextField field = new TextField();
                field.setCaption(bundleKeyDescriptorMap.get(key)[0]);
                field.setValue(bundleKeyDescriptorMap.get(key)[1]);
                field.setWidth("100%");
                // Add vaadin component to UI and keep related key in HashMap
                m_bundleValues.addComponent(field);
                m_bundleComponentKeyMap.put(field, key);
            }
        } catch (CmsException | IOException e) {
        // 
        }
    }

    /**
     * Reads the entered values for the macro and returns them together with their keys.<p>
     *
     * @return Maps
     */
    public Map<String, String> getMacroMap() {
        Map<String, String> map = new HashMap<String, String>();
        if (m_bundleComponentKeyMap != null) {
            Set<TextField> fields = m_bundleComponentKeyMap.keySet();
            for (TextField field : fields) {
                map.put(m_bundleComponentKeyMap.get(field), field.getValue());
            }
        }
        return map;
    }

    /**
     * Returns the correct variant of a resource name according to locale.<p>
     *
     * @param cms CmsObject
     * @param path where the considered resource is.
     * @param baseName of the resource
     * @return localized name of resource
     */
    private String getAvailableLocalVariant(CmsObject cms, String path, String baseName) {
        A_CmsUI.get();
        List<String> localVariations = CmsLocaleManager.getLocaleVariants(baseName, UI.getCurrent().getLocale(), false, true);
        for (String name : localVariations) {
            if (cms.existsResource(path + name)) {
                return name;
            }
        }
        return null;
    }

    /**
     * Gets localized property object.<p>
     *
     * @param cms CmsObject
     * @param path of resource
     * @return Properties object
     * @throws CmsException exception
     * @throws IOException exception
     */
    private Properties getLocalizedBundle(CmsObject cms, String path) throws CmsException, IOException {
        CmsResource bundleResource = cms.readResource(path + CmsSiteManager.MACRO_FOLDER + "/" + getAvailableLocalVariant(cms, path + CmsSiteManager.MACRO_FOLDER + "/", CmsSiteManager.BUNDLE_NAME));
        Properties ret = new Properties();
        InputStreamReader reader = new InputStreamReader(new ByteArrayInputStream(cms.readFile(bundleResource).getContents()), StandardCharsets.UTF_8);
        ret.load(reader);
        return ret;
    }
}

19 View Complete Implementation : CmsAppViewLayout.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * @see org.opencms.ui.apps.I_CmsAppUIContext#addPublishButton(org.opencms.ui.I_CmsUpdateListener)
 */
public Button addPublishButton(final I_CmsUpdateListener<String> updateListener) {
    Button publishButton = createPublishButton(updateListener);
    addToolbarButton(publishButton);
    return publishButton;
}

19 View Complete Implementation : CmsNewElementDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog to create new element. (User, Group or OU).
 */
public clreplaced CmsNewElementDialog extends CmsBasicDialog {

    /**
     * ID for user.
     */
    private static String ID_USER = "user";

    /**
     * ID for group.
     */
    private static String ID_GROUP = "group";

    /**
     * ID for OU.
     */
    private static String ID_OU = "ou";

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = 2351253053915340926L;

    /**
     * vaadin component.
     */
    private VerticalLayout m_container;

    /**
     * vaadin component.
     */
    private Button m_cancelButton;

    /**
     * window.
     */
    private Window m_window;

    /**
     * The cms object.
     */
    private CmsObject m_cms;

    /**
     * vaadin component.
     */
    private Label m_ouLabel;

    /**
     * The ou.
     */
    private String m_ou;

    /**
     * Accounts app.
     */
    private CmsAccountsApp m_app;

    /**
     * public constructor.<p>
     * @param cms CmsObject
     * @param ou ou
     *
     * @param window window holding the dialog
     */
    public CmsNewElementDialog(CmsObject cms, String ou, final Window window, CmsAccountsApp app) {
        m_app = app;
        m_window = window;
        m_cms = cms;
        m_ou = ou;
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        try {
            displayResourceInfoDirectly(Collections.singletonList(CmsAccountsApp.getOUInfo(OpenCms.getOrgUnitManager().readOrganizationalUnit(A_CmsUI.getCmsObject(), ou))));
            m_ouLabel.setValue(OpenCms.getOrgUnitManager().readOrganizationalUnit(m_cms, ou).getDisplayName(m_cms.getRequestContext().getLocale()));
        } catch (CmsException e) {
        // 
        }
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -7494631798452339165L;

            public void buttonClick(ClickEvent event) {
                window.close();
            }
        });
        CmsResourceInfo newUser = new CmsResourceInfo(CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_USER_0), CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_USER_HELP_0), new CmsCssIcon(OpenCmsTheme.ICON_USER));
        newUser.setData(ID_USER);
        CmsResourceInfo newGroup = new CmsResourceInfo(CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_GROUP_0), CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_GROUP_HELP_0), new CmsCssIcon(OpenCmsTheme.ICON_GROUP));
        newGroup.setData(ID_GROUP);
        if (OpenCms.getRoleManager().hasRole(m_cms, CmsRole.ADMINISTRATOR.forOrgUnit(ou))) {
            CmsResourceInfo newOU = new CmsResourceInfo(CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_OU_0), CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_OU_HELP_0), new CmsCssIcon(OpenCmsTheme.ICON_OU));
            newOU.setData(ID_OU);
            m_container.addComponent(newOU);
        }
        m_container.addComponent(newUser);
        m_container.addComponent(newGroup);
        m_container.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 5189868437695349511L;

            public void layoutClick(LayoutClickEvent event) {
                AbstractComponent component = (AbstractComponent) event.getChildComponent();
                if (component != null) {
                    if (component.getData() instanceof String) {
                        openNewDialog((String) component.getData());
                    }
                }
            }
        });
    }

    /**
     * Opens the dialog.<p>
     *
     * @param id of selected item
     */
    protected void openNewDialog(String id) {
        CmsBasicDialog dialog = null;
        String caption = "";
        if (id.equals(ID_GROUP)) {
            dialog = new CmsGroupEditDialog(m_cms, m_window, m_ou, m_app);
            caption = CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_GROUP_0);
        }
        if (id.equals(ID_OU)) {
            dialog = new CmsOUEditDialog(m_cms, m_window, m_ou, m_app);
            caption = CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_OU_0);
        }
        if (id.equals(ID_USER)) {
            dialog = new CmsUserEditDialog(m_cms, m_window, m_ou, m_app);
            caption = CmsVaadinUtils.getMessageText(Messages.GUI_USERMANAGEMENT_ADD_USER_0);
        }
        if (dialog != null) {
            m_window.setContent(dialog);
            m_window.setCaption(caption);
            m_window.center();
        }
    }
}

19 View Complete Implementation : CmsConfirmSimpleFlushDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog to confirm flush without any options.<p>
 */
public clreplaced CmsConfirmSimpleFlushDialog extends CmsBasicDialog implements I_CloseableDialog {

    /**
     * Vaadin serial id.
     */
    private static final long serialVersionUID = 6454462284178282427L;

    /**
     * Runnable for close action.
     */
    Runnable m_closeRunnable;

    /**
     * Runnable for ok action.
     */
    Runnable m_okRunnable;

    /**
     * Vaadin button.
     */
    private Button m_cancelButton;

    /**
     * Vaadin label.
     */
    private Label m_icon;

    /**
     * Vaadin label.
     */
    private Label m_label;

    /**
     * Vaadin button.
     */
    private Button m_okButton;

    /**
     * Public constructor.<p>
     *
     * @param message to be shown
     */
    public CmsConfirmSimpleFlushDialog(String message) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_label.setValue(message);
        m_icon.setContentMode(ContentMode.HTML);
        m_icon.setValue(FontOpenCms.WARNING.getHtml());
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1336535963768785962L;

            public void buttonClick(ClickEvent event) {
                m_closeRunnable.run();
                if (m_okRunnable != null) {
                    m_okRunnable.run();
                }
            }
        });
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 3918008642649054392L;

            public void buttonClick(ClickEvent event) {
                m_closeRunnable.run();
            }
        });
    }

    /**
     * @see org.opencms.ui.apps.cacheadmin.CmsFlushCache.I_CloseableDialog#setCloseRunnable(java.lang.Runnable)
     */
    public void setCloseRunnable(Runnable closeRunnable) {
        m_closeRunnable = closeRunnable;
    }

    /**
     * @see org.opencms.ui.apps.cacheadmin.CmsFlushCache.I_CloseableDialog#setOkRunnable(java.lang.Runnable)
     */
    public void setOkRunnable(Runnable okRunnable) {
        m_okRunnable = okRunnable;
    }
}

19 View Complete Implementation : CmsDeleteSiteDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog for deleting Sites.<p>
 */
public clreplaced CmsDeleteSiteDialog extends CmsBasicDialog {

    /**
     * The logger for this clreplaced.
     */
    static Log LOG = CmsLog.getLog(CmsDeleteSiteDialog.clreplaced.getName());

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = 4861877088383896218L;

    /**
     * The site manager instance.
     */
    protected CmsSiteManager m_manager;

    /**
     * cancel button.
     */
    private Button m_cancelButton;

    /**
     * check box: should resources be deleted?
     */
    private CheckBox m_deleteResources;

    /**
     * ok button.
     */
    private Button m_okButton;

    /**
     * sites to delete.
     */
    protected final List<CmsSite> m_sitesToDelete = new ArrayList<CmsSite>();

    /**
     * Public constructor.<p>
     *
     * @param manager the site manager instance
     * @param data with values for siteroots to delete.
     */
    public CmsDeleteSiteDialog(CmsSiteManager manager, Set<String> data) {
        m_manager = manager;
        for (String site : data) {
            m_sitesToDelete.add(manager.getElement(site));
        }
        displayResourceInfoDirectly(getResourceInfos());
        setContent(getContent());
        m_okButton = new Button(CmsVaadinUtils.getMessageText(org.opencms.workplace.Messages.GUI_DIALOG_BUTTON_OK_0));
        m_cancelButton = new Button(CmsVaadinUtils.getMessageText(org.opencms.workplace.Messages.GUI_DIALOG_BUTTON_CANCEL_0));
        addButton(m_okButton);
        addButton(m_cancelButton);
        // Set Clicklistener
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -5769891739879269176L;

            public void buttonClick(ClickEvent event) {
                m_manager.closeDialogWindow(false);
            }
        });
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 6932464669055039855L;

            public void buttonClick(ClickEvent event) {
                submit();
                m_manager.closeDialogWindow(true);
            }
        });
    }

    /**
     * Creates content of dialog containing CheckBox if resources should be deleted and a messages.<p>
     *
     * @return vertical layout component.
     */
    protected VerticalLayout getContent() {
        String message;
        if (m_sitesToDelete.size() == 1) {
            message = CmsVaadinUtils.getMessageText(Messages.GUI_SITE_CONFIRM_DELETE_SITE_1, m_sitesToDelete.get(0).getreplacedle());
        } else {
            message = "";
            for (CmsSite site : m_sitesToDelete) {
                if (message.length() > 0) {
                    message += ", ";
                }
                message += site.getreplacedle();
            }
            message = CmsVaadinUtils.getMessageText(Messages.GUI_SITE_CONFIRM_DELETE_SITES_1, message);
        }
        VerticalLayout layout = new VerticalLayout();
        m_deleteResources = new CheckBox();
        m_deleteResources.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_SITE_DELETE_RESOURCES_0));
        m_deleteResources.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_SITE_DELETE_RESOURCES_HELP_0));
        layout.addComponent(m_deleteResources);
        Label label = new Label();
        label.setContentMode(ContentMode.HTML);
        label.setValue(message);
        layout.addComponent(label);
        return layout;
    }

    /**
     * delete sites.<p>
     */
    protected void submit() {
        List<String> siteRootsToDelete = new ArrayList<String>();
        for (CmsSite site : m_sitesToDelete) {
            String currentSite = A_CmsUI.getCmsObject().getRequestContext().getSiteRoot();
            if (currentSite.equals(site.getSiteRoot())) {
                A_CmsUI.getCmsObject().getRequestContext().setSiteRoot("");
            }
            siteRootsToDelete.add(site.getSiteRoot());
        }
        m_manager.deleteElements(siteRootsToDelete);
        if (m_deleteResources.getValue().booleanValue()) {
            for (CmsSite site : m_sitesToDelete) {
                try {
                    m_manager.getRootCmsObject().lockResource(site.getSiteRoot());
                } catch (CmsException e) {
                    LOG.error("unable to lock resource");
                }
                try {
                    m_manager.getRootCmsObject().deleteResource(site.getSiteRoot(), CmsResource.DELETE_PRESERVE_SIBLINGS);
                    try {
                        m_manager.getRootCmsObject().unlockResource(site.getSiteRoot());
                    } catch (CmsLockException e) {
                        LOG.info("Unlock failed.", e);
                    }
                } catch (CmsException e) {
                // ok, resource was not published and can not be unlocked anymore..
                }
            }
        }
    }

    /**
     * Returns a list of CmsResourceInfo objects.<p>
     *
     * @return list of cmsresourceinfo.
     */
    private List<CmsResourceInfo> getResourceInfos() {
        List<CmsResourceInfo> infos = new ArrayList<CmsResourceInfo>();
        for (CmsSite site : m_sitesToDelete) {
            infos.add(new CmsResourceInfo(site.getreplacedle(), site.getSiteRoot(), m_manager.getFavIcon(site.getSiteRoot())));
        }
        return infos;
    }
}

19 View Complete Implementation : CmsLockedResourcesList.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Widget used to display a list of locked resources.<p<
 */
public clreplaced CmsLockedResourcesList extends CmsBasicDialog {

    /**
     * Serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * The label used to display the message.
     */
    private Label m_messageLabel;

    /**
     * The box containing the individual widgets for locked resources.
     */
    private VerticalLayout m_resourceBox;

    /**
     * The OK button.
     */
    private Button m_okButton;

    /**
     * The cancel button.
     */
    private Button m_cancelButton;

    /**
     * Creates a new instance.<p>
     *
     * @param cms the CMS context
     * @param resources the locked resources to display
     * @param message the message to display
     * @param nextAction the action to execute after clicking the OK button
     * @param cancelAction the action to execute after clicking the Cancel button
     */
    public CmsLockedResourcesList(CmsObject cms, List<CmsResource> resources, String message, Runnable nextAction, Runnable cancelAction) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_messageLabel.setValue(message);
        if (nextAction != null) {
            m_okButton.addClickListener(CmsVaadinUtils.createClickListener(nextAction));
        } else {
            m_okButton.setVisible(false);
        }
        if (cancelAction != null) {
            m_cancelButton.addClickListener(CmsVaadinUtils.createClickListener(cancelAction));
        } else {
            m_cancelButton.setVisible(false);
        }
        for (CmsResource resource : resources) {
            m_resourceBox.addComponent(new CmsResourceInfo(resource));
        }
    }
}

19 View Complete Implementation : CmsGroupEditDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the dialog to edit or create a CmsGroup.<p>
 */
public clreplaced CmsGroupEditDialog extends CmsBasicDialog {

    /**
     * The logger for this clreplaced.
     */
    static Log LOG = CmsLog.getLog(CmsGroupEditDialog.clreplaced.getName());

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = 6633733627052633351L;

    /**
     * vaadin component.
     */
    Button m_ok;

    /**
     * The app instance.
     */
    private CmsAccountsApp m_app;

    /**
     * vaadin component.
     */
    private Button m_cancel;

    /**
     * CmsObject.
     */
    private CmsObject m_cms;

    /**
     * vaadin component.
     */
    private TextArea m_description;

    /**
     * vaadin component.
     */
    private CheckBox m_enabled;

    /**
     * CmsGroup.
     */
    private CmsGroup m_group;

    /**
     * The group edit parameters.
     */
    private CmsGroupEditParameters m_groupEditParameters = new CmsGroupEditParameters();

    /**
     * vaadin component.
     */
    private TextField m_name;

    /**
     * vaadin component.
     */
    private Label m_ou;

    /**
     * public constructor.<p>
     *
     * @param cms CmsObject
     * @param groupId id of group edit, null if groud should be created
     * @param window window holding the dialog
     * @param app the app instance
     */
    public CmsGroupEditDialog(CmsObject cms, CmsUUID groupId, final Window window, final CmsAccountsApp app) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_cms = cms;
        m_app = app;
        try {
            if (groupId != null) {
                m_group = m_cms.readGroup(groupId);
                m_groupEditParameters = m_app.getGroupEditParameters(m_group);
                displayResourceInfoDirectly(Collections.singletonList(CmsAccountsApp.getPrincipalInfo(m_group)));
                m_ou.setValue(m_group.getOuFqn());
                m_name.setValue(m_group.getSimpleName());
                m_name.setEnabled(false);
                m_description.setValue(m_group.getDescription());
                m_enabled.setValue(new Boolean(m_group.isEnabled()));
            }
        } catch (CmsException e) {
            LOG.error("unable to read group", e);
        }
        m_ok.setEnabled(false);
        m_ok.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 2337532424806798793L;

            public void buttonClick(ClickEvent event) {
                saveGroup();
                window.close();
                app.reload();
            }
        });
        m_cancel.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -6389260624197980323L;

            public void buttonClick(ClickEvent event) {
                window.close();
            }
        });
        ValueChangeListener listener = new ValueChangeListener() {

            private static final long serialVersionUID = -7480617292190495288L;

            public void valueChange(ValueChangeEvent event) {
                m_ok.setEnabled(true);
            }
        };
        m_enabled.addValueChangeListener(listener);
        m_description.addValueChangeListener(listener);
        m_name.addValueChangeListener(listener);
        if (!m_groupEditParameters.isEditable()) {
            m_description.setEnabled(false);
            m_enabled.setEnabled(false);
        }
    }

    /**
     * Constructor for dialog for new groups.
     *
     * @param cms CmsObject
     * @param window window holding dialog
     * @param ou to create group in
     * @param app the app instance
     */
    public CmsGroupEditDialog(CmsObject cms, Window window, String ou, CmsAccountsApp app) {
        this(cms, null, window, app);
        m_ou.setValue(ou);
        m_enabled.setValue(new Boolean(true));
    }

    /**
     * Save group.<p>
     */
    protected void saveGroup() {
        if (m_group == null) {
            m_group = new CmsGroup();
            String ou = m_ou.getValue();
            if (!ou.endsWith("/")) {
                ou += "/";
            }
            m_group.setName(m_name.getValue());
            try {
                m_cms.createGroup(ou + m_name.getValue(), m_description.getValue(), 0, null);
            } catch (CmsException e) {
            // 
            }
        }
        m_group.setDescription(m_description.getValue());
        m_group.setEnabled(m_enabled.getValue().booleanValue());
        try {
            m_cms.writeGroup(m_group);
        } catch (CmsException e) {
        // 
        }
    }
}

19 View Complete Implementation : CmsDbSynchDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the synchronization dialog.<p>
 */
public clreplaced CmsDbSynchDialog extends CmsBasicDialog {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = -1818182416175306822L;

    /**
     * cancel button.
     */
    Button m_cancelButton;

    /**
     * Runnable for close action.
     */
    Runnable m_closeRunnable;

    /**
     * Vaadin component.
     */
    HorizontalLayout m_confirm;

    /**
     * icon.
     */
    Label m_icon;

    /**
     * Ok button.
     */
    Button m_okButton;

    /**
     * Vaadin component.
     */
    VerticalLayout m_report;

    /**
     * public constructor.<p>
     *
     * @param closeRunnable gets called on cancel
     */
    public CmsDbSynchDialog(Runnable closeRunnable) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_report.setVisible(false);
        m_closeRunnable = closeRunnable;
        // Setup icon
        m_icon.setContentMode(ContentMode.HTML);
        m_icon.setValue(FontOpenCms.WARNING.getHtml());
        m_okButton.addClickListener(new Button.ClickListener() {

            private static final long serialVersionUID = 7329358907650680436L;

            public void buttonClick(ClickEvent event) {
                showReport();
            }
        });
        m_cancelButton.addClickListener(new Button.ClickListener() {

            private static final long serialVersionUID = 4143312166220501488L;

            public void buttonClick(ClickEvent event) {
                m_closeRunnable.run();
            }
        });
    }

    /**
     * shows the synchronization report.<p>
     */
    protected void showReport() {
        m_confirm.setVisible(false);
        m_report.setVisible(true);
        CmsSynchronizeThread thread = new CmsSynchronizeThread(A_CmsUI.getCmsObject());
        thread.start();
        CmsReportWidget widget = new CmsReportWidget(thread);
        widget.setHeight("500px");
        widget.setWidth("100%");
        m_report.addComponent(widget);
        m_okButton.setEnabled(false);
    }
}

19 View Complete Implementation : CmsHistoryRow.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Represents a row of the file history table.<p>
 */
public clreplaced CmsHistoryRow {

    /**
     * The history resource bean.
     */
    private CmsHistoryResourceBean m_bean;

    /**
     * The V1 check box.
     */
    private CheckBox m_checkbox1 = new CheckBox();

    /**
     * The V2 check box.
     */
    private CheckBox m_checkbox2 = new CheckBox();

    /**
     * The Preview button.
     */
    private Button m_previewButton = CmsTableUtil.createIconButton(FontAwesome.SEARCH, CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_BUTTON_PREVIEW_0));

    /**
     * The Restore button.
     */
    private Button m_restoreButton = CmsTableUtil.createIconButton(FontAwesome.CLOCK_O, CmsVaadinUtils.getMessageText(Messages.GUI_HISTORY_DIALOG_BUTTON_RESTORE_0));

    /**
     * Creates a new instance.<p>
     *
     * @param bean the history resource bean
     */
    public CmsHistoryRow(CmsHistoryResourceBean bean) {
        m_bean = bean;
    }

    /**
     * Formats the file version for display.<p>
     *
     * @param bean the history resource bean
     *
     * @return the formatted version
     */
    public static String formatVersion(CmsHistoryResourceBean bean) {
        CmsHistoryVersion hVersion = bean.getVersion();
        Integer v = hVersion.getVersionNumber();
        String result = "" + (v != null ? v.toString() : "-");
        String suffix = "";
        if (hVersion.isOnline()) {
            suffix = " (Online)";
        } else if (hVersion.isOffline()) {
            suffix = " (Offline)";
        }
        result += suffix;
        return result;
    }

    /**
     * Gets the V1 check box.<p>
     *
     * @return the V1 check box
     */
    @Column(header = "V1", order = 90)
    public CheckBox getCheckBoxV1() {
        return m_checkbox1;
    }

    /**
     * Gets the V2 check box.<p>
     *
     * @return the V2 check box
     */
    @Column(header = "V2", order = 100)
    public CheckBox getCheckBoxV2() {
        return m_checkbox2;
    }

    /**
     * Gets the modification date.<p>
     *
     * @return the modification date
     */
    @Column(header = Messages.GUI_HISTORY_DIALOG_COL_DATE_LASTMODIFIED_0, order = 60)
    public Date getModificationDate() {
        return new Date(m_bean.getModificationDate().getDate());
    }

    /**
     * Gets the path.<p>
     *
     * @return the path
     */
    @Column(header = Messages.GUI_HISTORY_DIALOG_COL_PATH_0, order = 40, expandRatio = 1.0f, view = "wide")
    public String getPath() {
        String rootPath = m_bean.getRootPath();
        CmsObject cms = A_CmsUI.getCmsObject();
        String result = cms.getRequestContext().removeSiteRoot(rootPath);
        return result;
    }

    /**
     * Gets the preview button.<p>
     *
     * @return the preview button
     */
    @Column(header = Messages.GUI_HISTORY_DIALOG_BUTTON_PREVIEW_0, order = 7)
    public Button getPreviewButton() {
        return m_previewButton;
    }

    /**
     * Gets the publish date.<p>
     *
     * @return the publish date
     */
    @Column(header = Messages.GUI_HISTORY_DIALOG_COL_DATE_PUBLISHED_0, order = 50)
    public Date getPublishDate() {
        if (m_bean.getPublishDate() == null) {
            return null;
        }
        return new Date(m_bean.getPublishDate().getDate());
    }

    /**
     * Gets the restore button.<p>
     *
     * @return the restore button
     */
    @Column(header = Messages.GUI_HISTORY_DIALOG_BUTTON_RESTORE_0, order = 6)
    public Button getRestoreButton() {
        if (m_bean.getVersion().getVersionNumber() == null) {
            return null;
        }
        return m_restoreButton;
    }

    /**
     * Gets the file size.<p>
     *
     * @return the file size
     */
    @Column(header = org.opencms.workplace.commons.Messages.GUI_LABEL_SIZE_0, order = 80)
    public Integer getSize() {
        return Integer.valueOf(m_bean.getSize());
    }

    /**
     * Gets the last modification user.<p>
     *
     * @return the last modification user
     */
    @Column(header = org.opencms.workplace.commons.Messages.GUI_LABEL_USER_LAST_MODIFIED_0, order = 70)
    public String getUserLastModified() {
        return m_bean.getUserLastModified();
    }

    /**
     * Gets the file version.<p>
     *
     * @return the file version
     */
    @Column(header = org.opencms.workplace.commons.Messages.GUI_LABEL_VERSION_0, order = 30)
    public String getVersion() {
        return formatVersion(m_bean);
    }
}

19 View Complete Implementation : A_CmsMenuItem.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * @see org.opencms.ui.apps.I_CmsMenuItem#gereplacedemComponent(java.util.Locale)
 */
public Component gereplacedemComponent(Locale locale) {
    Button b = new Button(getLabel(locale), m_icon);
    b.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            executeAction();
        }
    });
    return b;
}

19 View Complete Implementation : CmsUserDataDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog to edit the user data.<p>
 */
public clreplaced CmsUserDataDialog extends CmsBasicDialog implements I_CmsHasreplacedle {

    /**
     * The embedded dialog id.
     */
    public static final String DIALOG_ID = "edituserdata";

    /**
     * The serial version id.
     */
    private static final long serialVersionUID = 8907786853232656944L;

    /**
     * Logger instance for this clreplaced.
     */
    private static final Log LOG = CmsLog.getLog(CmsUserDataDialog.clreplaced);

    /**
     * The Cancel button.
     */
    private Button m_cancelButton;

    /**
     * The dialog context.
     */
    I_CmsDialogContext m_context;

    /**
     * The form layout.
     */
    private CmsUserDataFormLayout m_form;

    /**
     * The OK  button.
     */
    private Button m_okButton;

    /**
     * The edited user.
     */
    CmsUser m_user;

    /**
     * Creates a new instance.<p>
     *
     * @param context the dialog context
     */
    public CmsUserDataDialog(I_CmsDialogContext context) {
        m_context = context;
        CmsObject cms = context.getCms();
        m_user = cms.getRequestContext().getCurrentUser();
        if (m_user.isManaged()) {
            throw new CmsRuntimeException(Messages.get().container(Messages.ERR_USER_NOT_SELF_MANAGED_1, m_user.getName()));
        }
        CmsVaadinUtils.readAndLocalizeDesign(this, OpenCms.getWorkplaceManager().getMessages(A_CmsUI.get().getLocale()), null);
        displayResourceInfoDirectly(Collections.singletonList(CmsAccountsApp.getPrincipalInfo(m_user)));
        m_form.initFields(m_user);
        m_cancelButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                cancel();
            }
        });
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                submit();
            }
        });
        setActionHandler(new CmsOkCancelActionHandler() {

            private static final long serialVersionUID = 1L;

            @Override
            protected void cancel() {
                CmsUserDataDialog.this.cancel();
            }

            @Override
            protected void ok() {
                submit();
            }
        });
    }

    /**
     * Creates a new instance.<p>
     *
     * @param context the dialog context
     * @param forcedCheck <code>true</code> in case of a forced user data check after login
     */
    public CmsUserDataDialog(I_CmsDialogContext context, boolean forcedCheck) {
        this(context);
        if (forcedCheck) {
            addComponent(new Label(getUserDataCheckMessage()), 0);
            m_cancelButton.setVisible(false);
        }
    }

    /**
     * @see org.opencms.ui.dialogs.I_CmsHasreplacedle#getreplacedle(java.util.Locale)
     */
    public String getreplacedle(Locale locale) {
        return org.opencms.ui.components.Messages.get().getBundle(locale).key(org.opencms.ui.components.Messages.GUI_USER_EDIT_0);
    }

    /**
     * Returns the message to be displayed for the user data check dialog.<p>
     *
     * @return the message to display
     */
    protected String getUserDataCheckMessage() {
        ResourceBundle bundle = null;
        try {
            bundle = CmsResourceBundleLoader.getBundle("org.opencms.userdatacheck.custom", A_CmsUI.get().getLocale());
            return bundle.getString("userdatacheck.text");
        } catch (MissingResourceException e) {
            return CmsVaadinUtils.getMessageText(org.opencms.ui.dialogs.Messages.GUI_USER_DATA_CHECK_INFO_0);
        }
    }

    /**
     * Cancels the dialog.<p>
     */
    void cancel() {
        m_context.finish(Collections.<CmsUUID>emptyList());
        m_context.updateUserInfo();
    }

    /**
     * Submits the dialog.<p>
     */
    void submit() {
        try {
            // Special user info attributes may have been set since the time the dialog was instantiated,
            // and we don't want to overwrite them, so we read the user again.
            m_user = m_context.getCms().readUser(m_user.getId());
            m_form.submit(m_user, m_context.getCms(), new Runnable() {

                public void run() {
                    try {
                        m_context.getCms().writeUser(m_user);
                        m_context.finish(Collections.<CmsUUID>emptyList());
                        m_context.updateUserInfo();
                    } catch (CmsException e) {
                    // 
                    }
                }
            });
        } catch (CmsException e) {
            LOG.error("Unable to read user", e);
        }
    }

    /**
     * Updates the user info.<p>
     */
    void updateUserInfo() {
        try {
            m_user = m_context.getCms().readUser(m_user.getId());
            displayResourceInfoDirectly(Collections.singletonList(CmsAccountsApp.getPrincipalInfo(m_user)));
        } catch (CmsException e) {
            LOG.error("Error updating user info.", e);
        }
    }
}

19 View Complete Implementation : CmsShowResourcesDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog to show resources with permissions for principle.<p>
 */
public clreplaced CmsShowResourcesDialog extends CmsBasicDialog {

    /**
     * Type of Dialog.
     */
    protected enum DialogType {

        Group, User, Error
    }

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = -1744033403586325260L;

    /**
     * Log instance for this clreplaced.
     */
    private static final Log LOG = CmsLog.getLog(CmsShowResourcesDialog.clreplaced);

    /**
     * vaadin component.
     */
    private Button m_cancel;

    /**
     * vaadin component.
     */
    private VerticalLayout m_layout;

    /**
     * CmsPrincipal.
     */
    private CmsPrincipal m_principal;

    /**
     * CmsObject.
     */
    private CmsObject m_cms;

    /**
     * Type of dialog.
     */
    private DialogType m_type;

    /**
     * public constructor.<p>
     *
     * @param id of principal
     * @param window holding dialog
     */
    public CmsShowResourcesDialog(String id, final Window window) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        iniCmsObject();
        try {
            m_principal = A_CmsUI.getCmsObject().readUser(new CmsUUID(id));
            m_type = DialogType.User;
        } catch (CmsException e) {
            try {
                m_principal = A_CmsUI.getCmsObject().readGroup(new CmsUUID(id));
                m_type = DialogType.Group;
            } catch (CmsException e1) {
                m_type = DialogType.Error;
            }
        }
        displayResourceInfoDirectly(Collections.singletonList(CmsAccountsApp.getPrincipalInfo(m_principal)));
        CmsShowResourceTable table = new CmsShowResourceTable(m_cms, m_principal.getId(), m_type);
        if (table.hasNoEntries()) {
            m_layout.addComponent(CmsVaadinUtils.getInfoLayout(org.opencms.ui.apps.Messages.GUI_USERMANAGEMENT_NO_RESOURCES_WITH_PERMISSIONS_0));
        } else {
            m_layout.addComponent(table);
        }
        m_cancel.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -2117164384116082079L;

            public void buttonClick(ClickEvent event) {
                window.close();
            }
        });
    }

    /**
     * Initializes CmsObject.<p>
     */
    private void iniCmsObject() {
        try {
            m_cms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
            m_cms.getRequestContext().setSiteRoot("");
        } catch (CmsException e) {
            LOG.error("Unable to clone CmsObject", e);
        }
    }
}

19 View Complete Implementation : CmsLogFileViewSettings.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the log file view settings dialog.<p>
 */
public clreplaced CmsLogFileViewSettings extends CmsBasicDialog {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = 3564444938636162445L;

    /**
     * Vaadin component.
     */
    ComboBox m_charset;

    /**
     * Vaadin component.
     */
    TextField m_size;

    /**
     * Vaadin component.
     */
    private Button m_cancel;

    /**
     * Vaadin component.
     */
    private Button m_ok;

    /**
     * public constructor.<p>
     *
     * @param window where the dialog is shown in
     */
    public CmsLogFileViewSettings(final Window window) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_size.setValue((String) CmsVaadinUtils.getRequest().getSession().getAttribute(CmsLogFileView.ATTR_FILE_VIEW_SIZE));
        SortedMap<String, Charset> csMap = Charset.availableCharsets();
        Charset cs;
        Iterator<Charset> it = csMap.values().iterator();
        while (it.hasNext()) {
            cs = it.next();
            m_charset.addItem(cs);
        }
        m_charset.select(CmsVaadinUtils.getRequest().getSession().getAttribute(CmsLogFileView.ATTR_FILE_VIEW_CHARSET));
        m_cancel.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -3277236106838992809L;

            public void buttonClick(ClickEvent event) {
                window.close();
            }
        });
        m_ok.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 3179892867228610166L;

            public void buttonClick(ClickEvent event) {
                HttpSession session = CmsVaadinUtils.getRequest().getSession();
                session.setAttribute(CmsLogFileView.ATTR_FILE_VIEW_CHARSET, m_charset.getValue());
                session.setAttribute(CmsLogFileView.ATTR_FILE_VIEW_SIZE, m_size.getValue());
                window.close();
            }
        });
    }
}

19 View Complete Implementation : CmsPagingControls.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Updates the button state, i.e. enables/disables the buttons depending on whether we are on the first or last page or not.<p>
 */
public void updateButtons() {
    for (Button button : new Button[] { m_forward, m_fastForward }) {
        button.setEnabled(m_page < m_lastPage);
    }
    for (Button button : new Button[] { m_back, m_fastBack }) {
        button.setEnabled(m_page > 0);
    }
}

19 View Complete Implementation : CmsResourceListDialog.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Dialog to show list of resources.<p>
 */
public clreplaced CmsResourceListDialog extends CmsBasicDialog {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = 4057378669920436467L;

    /**
     * The close button.
     */
    private Button m_cancel;

    /**
     * Public constructor.<p>
     *
     * @param resources List of resources
     */
    public CmsResourceListDialog(List<CmsResource> resources) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        if (resources.size() < 50) {
            displayResourceInfo(resources, null);
            setContentVisibility(false);
        }
        m_cancel.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 8446069481164202478L;

            public void buttonClick(ClickEvent event) {
                CmsVaadinUtils.getWindow(CmsResourceListDialog.this).close();
            }
        });
    }
}

19 View Complete Implementation : CmsImageCacheInput.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * clreplaced for the input dialog to search for cached images.<p>
 */
public clreplaced CmsImageCacheInput extends VerticalLayout {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = 1021439352252805506L;

    /**
     * vaadin component.
     */
    private TextField m_searchString;

    /**
     * vaadin component.
     */
    private Button m_okButton;

    /**
     * public constructor.<p>
     *
     * @param table to be updated after user input
     */
    public CmsImageCacheInput(final CmsImageCacheTable table) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        String siteRoot = A_CmsUI.getCmsObject().getRequestContext().getSiteRoot();
        if (!siteRoot.endsWith("/")) {
            siteRoot += "/";
        }
        siteRoot += "*";
        m_searchString.setValue(siteRoot);
        m_okButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = -2309066076096393602L;

            public void buttonClick(ClickEvent event) {
                table.load(getSearchPattern());
            }
        });
    }

    /**
     * Reads the search field out.<p>
     *
     * @return search pattern
     */
    protected String getSearchPattern() {
        return m_searchString.getValue();
    }
}

19 View Complete Implementation : CmsSetupStep05ServerSettings.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Setup step: Other settings.
 */
public clreplaced CmsSetupStep05ServerSettings extends A_CmsSetupStep {

    /**
     * Back button.
     */
    private Button m_backButton;

    /**
     * Forward button.
     */
    private Button m_forwardButton;

    /**
     * MAC address.
     */
    private TextField m_macAddress;

    /**
     * Server id.
     */
    private TextField m_serverId;

    /**
     * Workplace server.
     */
    private TextField m_serverUrl;

    /**
     * Creates a new instance.
     *
     * @param context the setup context
     */
    public CmsSetupStep05ServerSettings(I_SetupUiContext context) {
        super(context);
        CmsVaadinUtils.readAndLocalizeDesign(this, null, null);
        m_serverId.setValue(m_context.getSetupBean().getServerName());
        m_macAddress.setValue(m_context.getSetupBean().getEthernetAddress());
        VaadinServletRequest request = (VaadinServletRequest) (VaadinRequest.getCurrent());
        String serverUrl = request.getScheme() + "://" + request.getServerName();
        int serverPort = request.getServerPort();
        if (serverPort != 80) {
            serverUrl += ":" + serverPort;
        }
        m_serverUrl.setValue(serverUrl);
        m_forwardButton.addClickListener(evt -> forward());
        m_backButton.addClickListener(evt -> m_context.stepBack());
    }

    /**
     * Proceed to next step.
     */
    private void forward() {
        try {
            String macAddress = m_macAddress.getValue();
            String serverId = m_serverId.getValue();
            String serverUrl = m_serverUrl.getValue();
            CmsSetupBean setupBean = m_context.getSetupBean();
            setupBean.setEthernetAddress(macAddress);
            setupBean.setServerName(serverId);
            setupBean.setWorkplaceSite(serverUrl);
            setupBean.prepareStep8();
            m_context.stepForward();
        } catch (Exception e) {
            CmsSetupErrorDialog.showErrorDialog(e);
        }
    }
}

19 View Complete Implementation : CmsInternalResources.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Clreplaced for the layout for choosing the resources.<p>
 */
public clreplaced CmsInternalResources extends VerticalLayout {

    /**
     * vaadin serial id.
     */
    private static final long serialVersionUID = 6880701403593873461L;

    /**
     * Editable resource group.
     */
    CmsEditableGroup m_resourcesGroup;

    /**
     * Button to update table.
     */
    Button m_okButton;

    /**
     * Layout holding the text components for resources.
     */
    VerticalLayout m_resources;

    /**
     * Public constructor.<p>
     *
     * @param table linked table to be updated if button was pressed
     */
    public CmsInternalResources(final I_CmsUpdatableComponent table) {
        setHeightUndefined();
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_okButton.addClickListener(new Button.ClickListener() {

            private static final long serialVersionUID = -5668840121832993312L;

            public void buttonClick(ClickEvent event) {
                table.update(getResources());
            }
        });
        m_resourcesGroup = new CmsEditableGroup(m_resources, new Supplier<Component>() {

            public Component get() {
                return getResourceComponent(null);
            }
        }, CmsVaadinUtils.getMessageText(Messages.GUI_LINKVALIDATION_LINKS_ADDRESOURCES_0));
        m_resourcesGroup.init();
        m_resourcesGroup.addRow(getResourceComponent(null));
    }

    /**
     * Adds a resource to the form.<p>
     *
     * @param resource to be added
     */
    public void addResource(String resource) {
        m_resourcesGroup.addRow(getResourceComponent(resource));
    }

    /**
     * Clear resources.<p>
     */
    public void clearResources() {
        for (I_CmsEditableGroupRow row : m_resourcesGroup.getRows()) {
            m_resourcesGroup.remove(row);
        }
    }

    /**
     * Reads out resource paths from Layout.<p>
     *
     * @return List of Strings with all entered paths
     */
    public List<String> getResources() {
        List<String> res = new ArrayList<String>();
        for (I_CmsEditableGroupRow row : m_resourcesGroup.getRows()) {
            res.add(((CmsPathSelectField) row.getComponent()).getValue());
        }
        return res;
    }

    /**
     * Get vaadin component with given path.<p>
     *
     * @param path of resource
     * @return Vaadin component
     */
    protected Component getResourceComponent(String path) {
        try {
            CmsPathSelectField field = new CmsPathSelectField();
            field.setUseRootPaths(true);
            CmsObject cms = OpenCms.initCmsObject(A_CmsUI.getCmsObject());
            cms.getRequestContext().setSiteRoot("");
            field.setCmsObject(cms);
            if (path != null) {
                field.setValue(path);
            }
            return field;
        } catch (CmsException e) {
        // 
        }
        return null;
    }

    /**
     * Adds an empty path field to layout.<p>
     *
     * @param defaultValue of new field
     */
    void addEmptyPathFieldToLayout(String defaultValue) {
        m_resourcesGroup.addRow(getResourceComponent(defaultValue));
    }
}