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

org.opencms.util.ant.CmsAntTaskSelectionPrompt 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.

The 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 GmbH, 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.util.ant;

import javax.swing.UIManager;

/**
 * Ant task for a highly configurable Swing GUI based selection dialog.

* * Task that prompts user for selection to allow interactive builds.

* * @since 6.0.0 */ public class CmsAntTaskSelectionPrompt extends org.apache.tools.ant.Task { /** Options list separator constant. */ public static final String LIST_SEPARATOR = ","; /** List of all options. */ private String m_allValues; // required /** The amount of columns to use for display of selection elements. */ private int m_columns = 2; /** List of by default selected options. */ private String m_defaultValue = ""; /** Prompt message. */ private String m_prompt = "Please make your choice:"; /** Destination property. */ private String m_property; // required /** Mode flag. */ private boolean m_singleSelection; /** Title message. */ private String m_title = "Selection Dialog"; /** * Default constructor.

*/ public CmsAntTaskSelectionPrompt() { super(); } /** * Run the task.

* * Sets the given property to __ABORT__ if canceled, or to a list of selected * modules if not.

* * @throws org.apache.tools.ant.BuildException in case something goes wrong * * @see org.apache.tools.ant.Task#execute() */ @Override public void execute() throws org.apache.tools.ant.BuildException { log("Prompting user for " + m_property); String value = new CmsAntTaskSelectionDialog(this).getSelection(); if (value == null) { value = "__ABORT__"; } else { log("user selection: " + value); } getProject().setProperty(m_property, value); } /** * Returns the {@link #LIST_SEPARATOR} separated list of all available modules.

* * @return Returns the all-modules list */ public String getAllValues() { return m_allValues; } /** * Returns the columns.

* * @return the columns. */ public int getColumns() { return m_columns; } /** * Returns the {@link #LIST_SEPARATOR} separated list of pre-selected modules.

* * @return Returns the pre-selected module list */ public String getDefaultValue() { return m_defaultValue; } /** * Returns the prompt.

* * @return the prompt */ public String getPrompt() { return m_prompt; } /** * Returns the property to store the user selection.

* * @return Returns the m_propertyName. */ public String getProperty() { return m_property; } /** * Returns the title.

* * @return the title */ public String getTitle() { return m_title; } /** * Initializes this task.

*/ @Override public void init() { super.init(); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { // noop } } /** * Returns the Single Selection flag.

* * @return the single Selection flag */ public boolean isSingleSelection() { return m_singleSelection; } /** * Sets the {@link #LIST_SEPARATOR} separated list of all available modules.

* * @param allValues all-modules list to set */ public void setAllValues(String allValues) { m_allValues = allValues; } /** * Sets the columns.

* * @param cols the columns to set */ public void setColumns(String cols) { m_columns = Integer.parseInt(cols); } /** * Sets the {@link #LIST_SEPARATOR} separated list of pre-selected modules.

* * @param defaultValue the pre-selected module list to set */ public void setDefaultValue(String defaultValue) { m_defaultValue = defaultValue; } /** * Sets the prompt.

* * @param prompt the prompt to set */ public void setPrompt(String prompt) { m_prompt = prompt; } /** * Sets the property for storing the selected value. * * @param property The property to set. */ public void setProperty(String property) { m_property = property; } /** * Sets the single Selection flag.

* * @param singleSelection the single Selection flag to set */ public void setSingleSelection(boolean singleSelection) { m_singleSelection = singleSelection; } /** * Sets the title.

* * @param title the title to set */ public void setTitle(String title) { m_title = title; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy