Example usage for com.vaadin.server ExternalResource ExternalResource

List of usage examples for com.vaadin.server ExternalResource ExternalResource

Introduction

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

Prototype

public ExternalResource(String sourceURL) 

Source Link

Document

Creates a new download component for downloading directly from given URL.

Usage

From source file:org.opencms.ui.apps.CmsPageEditorConfiguration.java

License:Open Source License

/**
 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getIcon()
 *///from  ww  w  . ja  v  a  2  s  . c om
public Resource getIcon() {

    return new ExternalResource(OpenCmsTheme.getImageLink("apps/editor.png"));
}

From source file:org.opencms.ui.apps.CmsQuickLaunchEditorConfiguration.java

License:Open Source License

/**
 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getIcon()
 *///from  ww  w . j a  va 2 s.c om
public Resource getIcon() {

    return new ExternalResource(OpenCmsTheme.getImageLink("apps/quicklaunch-editor.png"));
}

From source file:org.opencms.ui.apps.CmsSitemapEditorConfiguration.java

License:Open Source License

/**
 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getIcon()
 *//*from   www.  j ava 2  s . c  o m*/
public Resource getIcon() {

    return new ExternalResource(OpenCmsTheme.getImageLink("apps/sitemap.png"));
}

From source file:org.opencms.ui.apps.CmsTraditionalWorkplaceConfiguration.java

License:Open Source License

/**
 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getIcon()
 *///from w  w  w.  j  av a  2 s .  c  o m
public Resource getIcon() {

    return new ExternalResource(OpenCmsTheme.getImageLink("apps/workplace-traditional.png"));
}

From source file:org.opencms.ui.apps.projects.CmsProjectManager.java

License:Open Source License

/**
 * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getSubNavEntries(java.lang.String)
 *///from   w ww  .  j  a  v a  2s  .c o  m
@Override
protected List<NavEntry> getSubNavEntries(String state) {

    if (CmsStringUtil.isEmptyOrWhitespaceOnly(state)) {
        List<NavEntry> subNav = new ArrayList<NavEntry>();
        subNav.add(new NavEntry(CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_ADD_0),
                CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_ADD_DESCRIPTION_0),
                new ExternalResource(OpenCmsTheme.getImageLink(ICON_ADD)), PATH_NAME_ADD));
        subNav.add(new NavEntry(CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_HISTORY_0),
                CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_HISTORY_DESCRIPTION_0),
                new ExternalResource(OpenCmsTheme.getImageLink(ICON_HISTORY)), PATH_NAME_HISTORY));
        return subNav;
    }
    return null;
}

From source file:org.opencms.ui.apps.projects.CmsProjectManagerConfiguration.java

License:Open Source License

/**
 * @see org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration#getIcon()
 *///  ww  w .  j  a va2 s.co  m
public Resource getIcon() {

    return new ExternalResource(OpenCmsTheme.getImageLink("apps/project.png"));
}

From source file:org.opencms.ui.apps.projects.CmsProjectsTable.java

License:Open Source License

/**
 * Constructor.<p>/* w w  w  .  j a  v  a 2 s  . c o  m*/
 *
 * @param manager the project manager
 */
public CmsProjectsTable(CmsProjectManager manager) {
    m_manager = manager;

    m_container = new IndexedContainer();
    m_container.addContainerProperty(PROP_ID, CmsUUID.class, null);
    m_container.addContainerProperty(PROP_ICON, Resource.class,
            new ExternalResource(OpenCmsTheme.getImageLink(CmsProjectManager.ICON_PROJECT_SMALL)));
    m_container.addContainerProperty(PROP_NAME, String.class, "");
    m_container.addContainerProperty(PROP_DESCRIPTION, String.class, "");
    m_container.addContainerProperty(PROP_ORG_UNIT, String.class, "");
    m_container.addContainerProperty(PROP_OWNER, String.class, "");
    m_container.addContainerProperty(PROP_MANAGER, String.class, "");
    m_container.addContainerProperty(PROP_USER, String.class, "");
    m_container.addContainerProperty(PROP_DATE_CREATED, Date.class, "");
    m_container.addContainerProperty(PROP_RESOURCES, Label.class, "");

    setContainerDataSource(m_container);
    setItemIconPropertyId(PROP_ICON);
    setRowHeaderMode(RowHeaderMode.ICON_ONLY);
    setColumnHeader(PROP_NAME, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_NAME_0));
    setColumnHeader(PROP_DESCRIPTION, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_DESCRIPTION_0));
    setColumnHeader(PROP_ORG_UNIT, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_ORG_UNIT_0));
    setColumnHeader(PROP_OWNER, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_OWNER_0));
    setColumnHeader(PROP_MANAGER, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_MANAGER_GROUP_0));
    setColumnHeader(PROP_USER, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_USER_GROUP_0));
    setColumnHeader(PROP_DATE_CREATED, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_DATE_CREATED_0));
    setColumnHeader(PROP_RESOURCES, CmsVaadinUtils.getMessageText(Messages.GUI_PROJECTS_RESOURCES_0));
    setColumnWidth(null, 40);
    setColumnExpandRatio(PROP_NAME, 2);
    setColumnExpandRatio(PROP_DESCRIPTION, 2);
    setColumnExpandRatio(PROP_RESOURCES, 2);
    setSelectable(true);
    setMultiSelect(true);
    m_menu = new CmsContextMenu();
    m_menu.setAsTableContextMenu(this);
    addItemClickListener(new ItemClickListener() {

        private static final long serialVersionUID = 1L;

        public void itemClick(ItemClickEvent event) {

            onItemClick(event);
        }
    });
    setCellStyleGenerator(new CellStyleGenerator() {

        private static final long serialVersionUID = 1L;

        public String getStyle(Table source, Object itemId, Object propertyId) {

            if (PROP_NAME.equals(propertyId)) {
                return OpenCmsTheme.HOVER_COLUMN;
            }
            return null;
        }
    });
}

From source file:org.opencms.ui.apps.scheduler.CmsJobMainView.java

License:Open Source License

/**
 * Creates a new instance.<p>/*from  w ww .  ja  v  a 2  s .  c  o m*/
 *
 * @param context the app context.
 */
public CmsJobMainView(I_CmsAppUIContext context) {

    m_appContext = context;
    CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
    m_jobTable.setJobEditHandler(this);
    m_buttonAddJob.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
    m_buttonAddJob.addStyleName(ValoTheme.BUTTON_BORDERLESS);
    m_buttonAddJob.setIcon(new ExternalResource(OpenCmsTheme.getImageLink("scheduler/scheduler_big_add.png")));
    m_buttonAddJob.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {

            CmsScheduledJobInfo jobInfo = new CmsScheduledJobInfo();
            jobInfo.setContextInfo(new CmsContextInfo());
            editJob(jobInfo,
                    CmsVaadinUtils.getMessageText(org.opencms.ui.Messages.GUI_SCHEDULER_TITLE_CREATE_0));

        }
    });

}

From source file:org.opencms.ui.apps.scheduler.CmsJobManagerApp.java

License:Open Source License

/**
 * @see org.opencms.ui.apps.A_CmsWorkplaceApp#getSubNavEntries(java.lang.String)
 *//*  www  .j  a va2s . co m*/
@Override
protected List<NavEntry> getSubNavEntries(String state) {

    if (CmsStringUtil.isEmptyOrWhitespaceOnly(state)) {
        List<NavEntry> subNav = new ArrayList<NavEntry>();
        subNav.add(new NavEntry(
                CmsVaadinUtils.getMessageText(
                        org.opencms.workplace.tools.scheduler.Messages.GUI_NEWJOB_ADMIN_TOOL_NAME_0),
                CmsVaadinUtils.getMessageText(
                        org.opencms.workplace.tools.scheduler.Messages.GUI_NEWJOB_ADMIN_TOOL_HELP_0),
                new ExternalResource(OpenCmsTheme.getImageLink("scheduler/scheduler_big_add.png")),
                PATH_NAME_EDIT));
        return subNav;
    }
    return null;
}

From source file:org.opencms.ui.apps.scheduler.CmsJobTable.java

License:Open Source License

/**
 * @see com.vaadin.ui.Table.ColumnGenerator#generateCell(com.vaadin.ui.Table, java.lang.Object, java.lang.Object)
 *//*  w ww .j  a  va2s . c om*/
public Object generateCell(Table source, Object itemId, Object columnId) {

    final Action action = (Action) columnId;
    CmsJobBean jobBean = (CmsJobBean) itemId;
    final CmsScheduledJobInfo job = jobBean.getJob();
    final CmsScheduledJobInfo jobClone = (CmsScheduledJobInfo) job.clone();

    Resource resource = null;
    String resPath = null;
    switch (action) {
    case activation:
        resource = job.isActive() ? FontOpenCms.CIRCLE_CHECK : FontOpenCms.CIRCLE_PAUSE;
        break;
    case copy:
        resource = FontOpenCms.CIRCLE_PLUS;
        break;
    case delete:
        resource = FontOpenCms.CIRCLE_MINUS;
        break;
    case edit:
        resPath = OpenCmsTheme.getImageLink("scheduler/scheduler.png");
        break;
    case run:
        resource = FontOpenCms.CIRCLE_PLAY;
        break;
    default:
    }
    if ((resource == null) && (resPath != null)) {
        resource = new ExternalResource(resPath);
    }

    Button button = CmsTableUtil.createIconButton(resource,
            CmsVaadinUtils.getMessageText(action.getMessageKey()));
    button.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @SuppressWarnings("synthetic-access")
        public void buttonClick(ClickEvent event) {

            try {
                switch (action) {
                case activation:
                    jobClone.setActive(!job.isActive());
                    writeChangedJob(jobClone);
                    break;
                case copy:
                    String stateCopy = CmsScheduledJobsAppConfig.APP_ID + "/" + CmsJobManagerApp.PATH_NAME_EDIT;
                    stateCopy = A_CmsWorkplaceApp.addParamToState(stateCopy, CmsJobManagerApp.PARAM_JOB_ID,
                            job.getId());
                    stateCopy = A_CmsWorkplaceApp.addParamToState(stateCopy, CmsJobManagerApp.PARAM_COPY,
                            Boolean.TRUE.toString());
                    CmsAppWorkplaceUi.get().getNavigator().navigateTo(stateCopy);
                    //                            jobClone.setActive(job.isActive());
                    //                            jobClone.clearId();
                    //                            String title = CmsVaadinUtils.getMessageText(
                    //                                org.opencms.ui.Messages.GUI_SCHEDULER_TITLE_COPY_1,
                    //                                jobClone.getJobName());
                    //                            m_jobEditHandler.editJob(jobClone, title);

                    break;

                case delete:
                    CmsConfirmationDialog.show(
                            CmsVaadinUtils.getMessageText(action.getMessageKey()), CmsVaadinUtils
                                    .getMessageText(Messages.GUI_SCHEDULER_CONFIRM_DELETE_1, job.getJobName()),
                            new Runnable() {

                                public void run() {

                                    try {
                                        OpenCms.getScheduleManager().unscheduleJob(A_CmsUI.getCmsObject(),
                                                job.getId());
                                        OpenCms.writeConfiguration(CmsSystemConfiguration.class);
                                        reloadJobs();
                                    } catch (CmsRoleViolationException e) {
                                        CmsErrorDialog.showErrorDialog(e);
                                    }

                                }
                            });
                    break;

                case edit:
                    String stateEdit = CmsScheduledJobsAppConfig.APP_ID + "/" + CmsJobManagerApp.PATH_NAME_EDIT;
                    stateEdit = A_CmsWorkplaceApp.addParamToState(stateEdit, CmsJobManagerApp.PARAM_JOB_ID,
                            job.getId());
                    CmsAppWorkplaceUi.get().getNavigator().navigateTo(stateEdit);

                    //                            if (m_jobEditHandler == null) {
                    //                                break;
                    //                            }
                    //                            m_jobEditHandler.editJob(
                    //                                job,
                    //                                CmsVaadinUtils.getMessageText(
                    //                                    org.opencms.workplace.tools.scheduler.Messages.GUI_JOBS_LIST_ACTION_EDIT_NAME_0));

                    break;
                case run:
                    CmsConfirmationDialog.show(
                            CmsVaadinUtils.getMessageText(action.getMessageKey()), CmsVaadinUtils
                                    .getMessageText(Messages.GUI_SCHEDULER_CONFIRM_EXECUTE_1, job.getJobName()),
                            new Runnable() {

                                public void run() {

                                    CmsScheduleManager scheduler = OpenCms.getScheduleManager();
                                    scheduler.executeDirectly(job.getId());
                                }
                            });

                    break;
                default:
                }
            } catch (CmsException e) {
                LOG.error(e.getLocalizedMessage(), e);
                CmsErrorDialog.showErrorDialog(e, new Runnable() {

                    public void run() {
                        // do nothing

                    }
                });

            }

        }
    });
    return button;
}