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

org.opencms.gwt.client.property.definition.CmsPropertyDefinitionButton 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 (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.gwt.client.property.definition;

import org.opencms.gwt.client.CmsCoreProvider;
import org.opencms.gwt.client.rpc.CmsRpcAction;
import org.opencms.gwt.client.ui.CmsPushButton;
import org.opencms.gwt.client.ui.I_CmsButton.ButtonStyle;
import org.opencms.gwt.client.ui.css.I_CmsLayoutBundle;
import org.opencms.gwt.client.ui.input.form.CmsFormDialog;

import java.util.ArrayList;

import com.google.gwt.dom.client.Style;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.CloseEvent;
import com.google.gwt.event.logical.shared.CloseHandler;
import com.google.gwt.user.client.ui.PopupPanel;

/**
 * Button for defining new properties from the property dialog.

*/ public class CmsPropertyDefinitionButton extends CmsPushButton { /** The dialog instance. */ private CmsFormDialog m_dialog; /** * Gets the dialog which this button is used for.

* * @return the dialog for this button */ public CmsFormDialog getDialog() { return m_dialog; } /** * Creates a new instance of the button.

*/ public CmsPropertyDefinitionButton() { super(I_CmsLayoutBundle.INSTANCE.propertiesCss().propertyDefinitionButton()); setTitle(CmsPropertyDefinitionMessages.messageDialogCaption()); setButtonStyle(ButtonStyle.TRANSPARENT, null); getElement().getStyle().setFloat(Style.Float.LEFT); addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { onBeforeEditPropertyDefinition(); editPropertyDefinition(); } }); } /** * Installs the button on a dialog if the user has sufficient permissions.

* * @param dialog the dialog to which the button should be added */ public void installOnDialog(CmsFormDialog dialog) { if (CmsCoreProvider.get().getUserInfo().isDeveloper()) { setDialog(dialog); dialog.addButton(this); } } /** * Method which is called directly before the property definition dialog is opened.

*/ public void onBeforeEditPropertyDefinition() { // do nothing in the default implementation } /** * Method which is called when the property definition dialog is closed.

*/ public void onClosePropertyDefinitionDialog() { // do nothing in the default implementation } /** * Sets the dialog instance.

* * @param dialog the dialog instance */ public void setDialog(CmsFormDialog dialog) { m_dialog = dialog; } /** * Opens the dialog for creating new property definitions.

*/ protected void editPropertyDefinition() { CmsRpcAction> action = new CmsRpcAction>() { @Override public void execute() { start(200, true); CmsCoreProvider.getVfsService().getDefinedProperties(this); } @Override protected void onResponse(ArrayList result) { stop(false); CmsPropertyDefinitionDialog dialog = new CmsPropertyDefinitionDialog(result); dialog.center(); dialog.addCloseHandler(new CloseHandler() { public void onClose(CloseEvent event) { onClosePropertyDefinitionDialog(); } }); } }; action.execute(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy