Search in sources :

Example 1 with I_CmsWorkplaceAppConfiguration

use of org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration in project opencms-core by alkacon.

the class CmsQuickLaunchProvider method getQuickLaunchData.

/**
 * Gets the quick launch data for the current user and context.<p>
 *
 * The context is a string which identifies where the quick launch menu is located
 * @param cms the cms context
 * @param session  the user session
 *
 * @param params the quick launch parameters
 *
 * @return the list of available quick launch items
 */
public static List<CmsQuickLaunchData> getQuickLaunchData(CmsObject cms, HttpSession session, CmsQuickLaunchParams params) {
    List<CmsQuickLaunchData> result = Lists.newArrayList();
    Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms);
    List<I_CmsWorkplaceAppConfiguration> appConfigs = new ArrayList<I_CmsWorkplaceAppConfiguration>(OpenCms.getWorkplaceAppManager().getQuickLaunchConfigurations(cms));
    CmsResource currentPage = null;
    if (params.getPageId() != null) {
        try {
            currentPage = cms.readResource(params.getPageId(), CmsResourceFilter.ONLY_VISIBLE_NO_DELETED);
        } catch (CmsException e) {
            LOG.warn(e.getLocalizedMessage(), e);
        }
    }
    CmsQuickLaunchLocationCache locationCache = CmsQuickLaunchLocationCache.getLocationCache(session);
    for (I_CmsWorkplaceAppConfiguration config : appConfigs) {
        try {
            boolean reload = false;
            String link = null;
            String errorTitle = null;
            String errorMessage = null;
            boolean useLegacyButtonStyle = config instanceof CmsLegacyAppConfiguration;
            if (CmsFileExplorerConfiguration.APP_ID.equals(config.getId())) {
                String page = locationCache.getFileExplorerLocation(cms.getRequestContext().getSiteRoot());
                if (page != null) {
                    link = CmsCoreService.getVaadinWorkplaceLink(cms, cms.getRequestContext().addSiteRoot(page));
                } else {
                    if (cms.existsResource("/", CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
                        link = CmsCoreService.getVaadinWorkplaceLink(cms, cms.getRequestContext().getSiteRoot());
                    } else if (currentPage != null) {
                        link = CmsCoreService.getVaadinWorkplaceLink(cms, params.getPageId());
                    } else {
                        errorTitle = config.getName(locale);
                        errorMessage = Messages.get().getBundle(locale).key(Messages.GUI_QUICKLAUNCH_EXPLORER_NOT_ALLOWED_0);
                    }
                }
            } else if (CmsPageEditorConfiguration.APP_ID.equals(config.getId())) {
                if (params.isPageContext()) {
                    if ((currentPage != null) && CmsResourceTypeXmlContainerPage.MODEL_GROUP_TYPE_NAME.equals(OpenCms.getResourceManager().getResourceType(currentPage).getTypeName())) {
                        String page = locationCache.getPageEditorLocation(cms, cms.getRequestContext().getSiteRoot());
                        if (page != null) {
                            link = OpenCms.getLinkManager().substituteLink(cms, page);
                        } else {
                            reload = true;
                        }
                    } else {
                        reload = true;
                    }
                } else if (params.isSitemapContext()) {
                    String page = locationCache.getPageEditorLocation(cms, cms.getRequestContext().getSiteRoot());
                    if (page == null) {
                        page = locationCache.getSitemapEditorLocation(cms.getRequestContext().getSiteRoot());
                    }
                    if (page != null) {
                        link = OpenCms.getLinkManager().substituteLink(cms, page);
                    }
                }
            } else if (CmsSitemapEditorConfiguration.APP_ID.equals(config.getId())) {
                if (params.isSitemapContext()) {
                    reload = true;
                } else if (params.isPageContext()) {
                    String sitemapLink = OpenCms.getLinkManager().substituteLinkForUnknownTarget(cms, CmsADEManager.PATH_SITEMAP_EDITOR_JSP);
                    String page = locationCache.getPageEditorLocation(cms, cms.getRequestContext().getSiteRoot());
                    link = sitemapLink + "?path=" + page;
                }
            } else {
                link = CmsVaadinUtils.getWorkplaceLink(config.getId());
            }
            Resource icon = config.getIcon();
            String imageLink = "";
            if (icon instanceof ExternalResource) {
                imageLink = ((ExternalResource) icon).getURL();
            } else if (icon instanceof FontIcon) {
                imageLink = FONT_ICON_PREFIX + ((FontIcon) icon).getHtml();
            }
            String name = config.getName(OpenCms.getWorkplaceManager().getWorkplaceLocale(cms));
            CmsAppVisibilityStatus visibility = config.getVisibility(cms);
            if (!visibility.isActive()) {
                errorTitle = name;
                errorMessage = visibility.getHelpText();
            }
            CmsQuickLaunchData data = new CmsQuickLaunchData(link, name, imageLink, config.getButtonStyle(), errorTitle, errorMessage, useLegacyButtonStyle, reload);
            result.add(data);
        } catch (Exception e) {
            LOG.error(e.getLocalizedMessage(), e);
        }
    }
    return result;
}
Also used : Locale(java.util.Locale) CmsQuickLaunchLocationCache(org.opencms.ui.apps.CmsQuickLaunchLocationCache) CmsLegacyAppConfiguration(org.opencms.ui.apps.CmsLegacyAppConfiguration) ArrayList(java.util.ArrayList) Resource(com.vaadin.server.Resource) CmsResource(org.opencms.file.CmsResource) ExternalResource(com.vaadin.server.ExternalResource) FontIcon(com.vaadin.server.FontIcon) ExternalResource(com.vaadin.server.ExternalResource) CmsException(org.opencms.main.CmsException) CmsQuickLaunchData(org.opencms.gwt.shared.CmsQuickLaunchData) CmsResource(org.opencms.file.CmsResource) CmsException(org.opencms.main.CmsException) I_CmsWorkplaceAppConfiguration(org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration) CmsAppVisibilityStatus(org.opencms.ui.apps.CmsAppVisibilityStatus)

Example 2 with I_CmsWorkplaceAppConfiguration

use of org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration in project opencms-core by alkacon.

the class CmsProjectSelectDialog method changeSiteOrProject.

/**
 * Static method for actually changing the site/project.
 *
 * @param context the dialog context
 * @param projectId the project id (possibly null)
 * @param siteOption the option from the site selector
 */
public static void changeSiteOrProject(I_CmsDialogContext context, CmsUUID projectId, SiteSelectorOption siteOption) {
    String siteRoot = null;
    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 (siteOption != null) {
            siteRoot = siteOption.getSite();
            if (!context.getCms().getRequestContext().getSiteRoot().equals(siteRoot)) {
                A_CmsUI.get().changeSite(siteRoot);
            } else if (siteOption.getPath() == null) {
                siteRoot = null;
            }
        }
        if ((siteRoot != null) && CmsFileExplorerConfiguration.APP_ID.equals(context.getAppId())) {
            if (siteOption.getPath() != null) {
                CmsResource defaultFile = null;
                try {
                    defaultFile = A_CmsUI.getCmsObject().readDefaultFile(siteOption.getPath());
                } catch (Exception e) {
                // ignore
                }
                if (defaultFile != null) {
                    Page.getCurrent().setLocation(OpenCms.getLinkManager().substituteLinkForUnknownTarget(A_CmsUI.getCmsObject(), siteOption.getPath()));
                    return;
                } else {
                    Page.getCurrent().open(CmsCoreService.getFileExplorerLink(A_CmsUI.getCmsObject(), siteOption.getSite()) + siteOption.getPath(), "_top");
                }
            } else {
                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);
    }
}
Also used : CmsResource(org.opencms.file.CmsResource) CmsException(org.opencms.main.CmsException) I_CmsWorkplaceAppConfiguration(org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration) CmsProject(org.opencms.file.CmsProject) CmsException(org.opencms.main.CmsException)

Example 3 with I_CmsWorkplaceAppConfiguration

use of org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration in project opencms-core by alkacon.

the class CmsStartViewPreference method getViewSelectOptions.

/**
 * Gets the select options for the view selector.<p>
 *
 * @param cms the CMS context
 * @param value the current value
 * @return the select options
 */
public static SelectOptions getViewSelectOptions(CmsObject cms, String value) {
    Locale locale = OpenCms.getWorkplaceManager().getWorkplaceLocale(cms);
    List<String> options = new ArrayList<String>();
    List<String> values = new ArrayList<String>();
    int selectedIndex = 0;
    List<I_CmsWorkplaceAppConfiguration> apps = OpenCms.getWorkplaceAppManager().getDefaultQuickLaunchConfigurations();
    for (I_CmsWorkplaceAppConfiguration app : apps) {
        if (OpenCms.getRoleManager().hasRole(cms, cms.getRequestContext().getCurrentUser().getName(), app.getRequiredRole())) {
            values.add(app.getId());
            options.add(app.getName(locale));
        }
    }
    SelectOptions optionBean = new SelectOptions(options, values, selectedIndex);
    return optionBean;
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) I_CmsWorkplaceAppConfiguration(org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration)

Example 4 with I_CmsWorkplaceAppConfiguration

use of org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration in project opencms-core by alkacon.

the class CmsToolBar method createQuickLaunchDropDown.

/**
 * Creates the app select drop down.<p>
 *
 * @return the drop down component
 */
private Component createQuickLaunchDropDown() {
    PopupView pv = new PopupView(new PopupView.Content() {

        private static final long serialVersionUID = 1L;

        public String getMinimizedValueAsHTML() {
            return getDropDownButtonHtml(FontOpenCms.APPS);
        }

        public Component getPopupComponent() {
            CmsObject cms = A_CmsUI.getCmsObject();
            Locale locale = UI.getCurrent().getLocale();
            HorizontalLayout layout = new HorizontalLayout();
            layout.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
            layout.addStyleName(OpenCmsTheme.QUICK_LAUNCH);
            layout.setSpacing(false);
            layout.setMargin(true);
            for (I_CmsWorkplaceAppConfiguration config : OpenCms.getWorkplaceAppManager().getQuickLaunchConfigurations(cms)) {
                layout.addComponent(CmsDefaultAppButtonProvider.createAppButton(cms, config, locale));
            }
            return layout;
        }
    });
    pv.setDescription(CmsVaadinUtils.getMessageText(Messages.GUI_QUICK_LAUNCH_TITLE_0));
    pv.addStyleName(OpenCmsTheme.NAVIGATOR_DROPDOWN);
    pv.setHideOnMouseOut(false);
    return pv;
}
Also used : Locale(java.util.Locale) CmsObject(org.opencms.file.CmsObject) PopupView(com.vaadin.ui.PopupView) I_CmsWorkplaceAppConfiguration(org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration) Component(com.vaadin.ui.Component) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Example 5 with I_CmsWorkplaceAppConfiguration

use of org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration in project opencms-core by alkacon.

the class CmsUserEditDialog method getStartViewContainer.

/**
 * Returns the start view container.<p>
 *
 * @param caption of the container
 * @return indexed container
 */
private IndexedContainer getStartViewContainer(String caption) {
    List<I_CmsWorkplaceAppConfiguration> apps = OpenCms.getWorkplaceAppManager().getDefaultQuickLaunchConfigurations();
    IndexedContainer res = new IndexedContainer();
    res.addContainerProperty(caption, String.class, "");
    for (I_CmsWorkplaceAppConfiguration app : apps) {
        if (hasRoleForApp(app)) {
            Item item = res.addItem(app.getId());
            item.getItemProperty(caption).setValue(app.getName(A_CmsUI.get().getLocale()));
        }
    }
    return res;
}
Also used : Item(com.vaadin.v7.data.Item) IndexedContainer(com.vaadin.v7.data.util.IndexedContainer) I_CmsWorkplaceAppConfiguration(org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration)

Aggregations

I_CmsWorkplaceAppConfiguration (org.opencms.ui.apps.I_CmsWorkplaceAppConfiguration)5 Locale (java.util.Locale)3 ArrayList (java.util.ArrayList)2 CmsResource (org.opencms.file.CmsResource)2 CmsException (org.opencms.main.CmsException)2 ExternalResource (com.vaadin.server.ExternalResource)1 FontIcon (com.vaadin.server.FontIcon)1 Resource (com.vaadin.server.Resource)1 Component (com.vaadin.ui.Component)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 PopupView (com.vaadin.ui.PopupView)1 Item (com.vaadin.v7.data.Item)1 IndexedContainer (com.vaadin.v7.data.util.IndexedContainer)1 CmsObject (org.opencms.file.CmsObject)1 CmsProject (org.opencms.file.CmsProject)1 CmsQuickLaunchData (org.opencms.gwt.shared.CmsQuickLaunchData)1 CmsAppVisibilityStatus (org.opencms.ui.apps.CmsAppVisibilityStatus)1 CmsLegacyAppConfiguration (org.opencms.ui.apps.CmsLegacyAppConfiguration)1 CmsQuickLaunchLocationCache (org.opencms.ui.apps.CmsQuickLaunchLocationCache)1