All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opencms.ui.apps.CmsExplorerDialogContext Maven / Gradle / Ivy

Go to download

OpenCms is an enterprise-ready, easy to use website content management system based on Java and XML technology. Offering a complete set of features, OpenCms helps content managers worldwide to create and maintain beautiful websites fast and efficiently.

There is a newer version: 18.0
Show newest version
/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) Alkacon Software GmbH (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.ui.apps;

import org.opencms.file.CmsObject;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.main.CmsException;
import org.opencms.main.OpenCms;
import org.opencms.ui.A_CmsDialogContext;
import org.opencms.ui.A_CmsUI;
import org.opencms.ui.I_CmsEditPropertyContext;
import org.opencms.ui.components.CmsErrorDialog;
import org.opencms.ui.components.CmsResourceTableProperty;
import org.opencms.util.CmsUUID;

import java.util.Collection;
import java.util.List;

import com.google.common.collect.Lists;

/**
 * Dialog context for the explorer.

*/ public class CmsExplorerDialogContext extends A_CmsDialogContext implements I_CmsEditPropertyContext { /** The explorer instance. */ private CmsFileExplorer m_explorer; /** * Creates a new instance.

* * @param appContext the app context * @param explorer the explorer app instance * @param resources the list of selected resources */ public CmsExplorerDialogContext( I_CmsAppUIContext appContext, CmsFileExplorer explorer, List resources) { super(appContext, resources); m_explorer = explorer; } /** * @see org.opencms.ui.I_CmsEditPropertyContext#editProperty(java.lang.Object) */ public void editProperty(Object propertyId) { m_explorer.editItemProperty(getResources().get(0).getStructureId(), (CmsResourceTableProperty)propertyId); } /** * @see org.opencms.ui.A_CmsDialogContext#finish(org.opencms.file.CmsProject, java.lang.String) */ @Override public void finish(CmsProject project, String siteRoot) { super.finish(null); m_explorer.onSiteOrProjectChange(project, siteRoot); } /** * @see org.opencms.ui.I_CmsDialogContext#finish(java.util.Collection) */ @Override public void finish(Collection ids) { super.finish(ids); if (ids == null) { ids = Lists.newArrayList(); for (CmsResource res : getResources()) { ids.add(res.getStructureId()); } } for (CmsUUID id : ids) { if (id.isNullUUID()) { m_explorer.updateAll(); } } m_explorer.update(ids); } /** * @see org.opencms.ui.I_CmsDialogContext#focus(org.opencms.util.CmsUUID) */ public void focus(CmsUUID cmsUUID) { try { CmsObject cms = A_CmsUI.getCmsObject(); CmsResource res = cms.readResource(cmsUUID, CmsResourceFilter.ALL); String rootPath = res.getRootPath(); String siteRoot = OpenCms.getSiteManager().getSiteRoot(rootPath); String sitePath = null; if (siteRoot == null) { if (OpenCms.getSiteManager().startsWithShared(rootPath)) { siteRoot = OpenCms.getSiteManager().getSharedFolder(); sitePath = CmsResource.getParentFolder( rootPath.substring(OpenCms.getSiteManager().getSharedFolder().length())); } else { sitePath = CmsResource.getParentFolder(rootPath); siteRoot = ""; } } else { CmsObject otherSiteCms = OpenCms.initCmsObject(cms); otherSiteCms.getRequestContext().setSiteRoot(siteRoot); sitePath = otherSiteCms.getRequestContext().removeSiteRoot(CmsResource.getParentFolder(rootPath)); } m_explorer.changeSite(siteRoot, sitePath, true); } catch (CmsException e) { CmsErrorDialog.showErrorDialog(e); } } /** * @see org.opencms.ui.I_CmsDialogContext#getAllStructureIdsInView() */ public List getAllStructureIdsInView() { return Lists.newArrayList(m_explorer.getAllIds()); } /** * @see org.opencms.ui.I_CmsEditPropertyContext#isPropertyEditable(java.lang.Object) */ public boolean isPropertyEditable(Object propertyId) { return (getResources().size() == 1) && (propertyId instanceof CmsResourceTableProperty) && m_explorer.isPropertyEditable((CmsResourceTableProperty)propertyId); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy