be built if a build is launched. Also fixed a few buglets in the PropertyEditor. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268183 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -15,12 +15,12 @@ | |||
| <property name="src.etc.dir" value="etc"/> | |||
| <property name="src.dir" value="."/> | |||
| <property name="docs.dir" value="docs"/> | |||
| <property name="build.dir" value="../../../build/ant"/> | |||
| <property name="lib.dir" value="${build.dir}/lib"/> | |||
| <property name="bin.dir" value="${build.dir}/bin"/> | |||
| <property name="build.dir" value="../../../build/antidote"/> | |||
| <property name="ant.build.dir" value="../../../build/ant"/> | |||
| <property name="lib.dir" value="${ant.build.dir}/lib"/> | |||
| <property name="bin.dir" value="${ant.build.dir}/bin"/> | |||
| <property name="build.classes" value="${build.dir}/classes"/> | |||
| <property name="build.javadocs" value="${build.dir}/javadocs"/> | |||
| <property name="build.tests" value="${build.dir}/testcases"/> | |||
| <property name="ant.dist.dir" value="../../../dist/ant"/> | |||
| <path id="classpath"> | |||
| @@ -48,6 +48,7 @@ | |||
| <!-- =================================================================== --> | |||
| <target name="prepare"> | |||
| <mkdir dir="${build.dir}"/> | |||
| <mkdir dir="${ant.build.dir}"/> | |||
| <tstamp /> | |||
| </target> | |||
| @@ -97,6 +97,9 @@ public class Antidote extends JPanel { | |||
| add(BorderLayout.CENTER, splitter2); | |||
| splitter2.resetToPreferredSizes(); | |||
| add(BorderLayout.NORTH, populateEditors("top")); | |||
| setPreferredSize(new Dimension(640, 480)); | |||
| } | |||
| @@ -116,25 +116,38 @@ public class Console extends AntEditor { | |||
| return _filter; | |||
| } | |||
| /** | |||
| * Clear the contents of the console. | |||
| * | |||
| */ | |||
| private void clearDisplay() { | |||
| Document doc = _text.getDocument(); | |||
| try { | |||
| doc.remove(0, doc.getLength()); | |||
| } | |||
| catch(Exception ex) { | |||
| // Intentionally ignored. | |||
| } | |||
| } | |||
| /** | |||
| * Called when an event is to be posed to the member. | |||
| * | |||
| * @param event Event to post. | |||
| */ | |||
| public void eventPosted(EventObject event) { | |||
| if(event instanceof NewProjectEvent) { | |||
| clearDisplay(); | |||
| return; | |||
| } | |||
| AntBuildEvent buildEvent = (AntBuildEvent) event; | |||
| String text = null; | |||
| Document doc = _text.getDocument(); | |||
| switch(buildEvent.getType().getValue()) { | |||
| case BuildEventType.BUILD_STARTED_VAL: | |||
| try { | |||
| doc.remove(0, doc.getLength()); | |||
| } | |||
| catch(Exception ex) { | |||
| // Intentionally ignored. | |||
| } | |||
| clearDisplay(); | |||
| break; | |||
| case BuildEventType.TARGET_STARTED_VAL: | |||
| text = buildEvent.getEvent().getTarget().getName() + ":"; | |||
| @@ -154,6 +167,7 @@ public class Console extends AntEditor { | |||
| if(text != null) { | |||
| try { | |||
| Document doc = _text.getDocument(); | |||
| doc.insertString(doc.getLength(), text, null); | |||
| doc.insertString(doc.getLength(), "\n", null); | |||
| } | |||
| @@ -173,7 +187,8 @@ public class Console extends AntEditor { | |||
| * @return True if event should be given to BusMember, false otherwise. | |||
| */ | |||
| public boolean accept(EventObject event) { | |||
| return event instanceof AntBuildEvent; | |||
| return event instanceof AntBuildEvent || | |||
| event instanceof NewProjectEvent; | |||
| } | |||
| } | |||
| @@ -87,7 +87,7 @@ class ProjectNavigator extends AntEditor { | |||
| add(scroller); | |||
| setPreferredSize(new Dimension(150, 100)); | |||
| setMinimumSize(new Dimension(150, 100)); | |||
| } | |||
| /** Class for handling project events. */ | |||
| @@ -99,11 +99,12 @@ class PropertyEditor extends AntEditor { | |||
| _customizer = null; | |||
| } | |||
| if(items != null) { | |||
| if(items != null && items.length == 1) { | |||
| _customizer = new DynamicCustomizer(items[0].getClass()); | |||
| _customizer.setObject(items[0]); | |||
| _container.add(BorderLayout.CENTER, _customizer); | |||
| } | |||
| validate(); | |||
| } | |||
| @@ -0,0 +1,165 @@ | |||
| /* | |||
| * The Apache Software License, Version 1.1 | |||
| * | |||
| * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights | |||
| * reserved. | |||
| * | |||
| * Redistribution and use in source and binary forms, with or without | |||
| * modification, are permitted provided that the following conditions | |||
| * are met: | |||
| * | |||
| * 1. Redistributions of source code must retain the above copyright | |||
| * notice, this list of conditions and the following disclaimer. | |||
| * | |||
| * 2. Redistributions in binary form must reproduce the above copyright | |||
| * notice, this list of conditions and the following disclaimer in | |||
| * the documentation and/or other materials provided with the | |||
| * distribution. | |||
| * | |||
| * 3. The end-user documentation included with the redistribution, if | |||
| * any, must include the following acknowlegement: | |||
| * "This product includes software developed by the | |||
| * Apache Software Foundation (http://www.apache.org/)." | |||
| * Alternately, this acknowlegement may appear in the software itself, | |||
| * if and wherever such third-party acknowlegements normally appear. | |||
| * | |||
| * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software | |||
| * Foundation" must not be used to endorse or promote products derived | |||
| * from this software without prior written permission. For written | |||
| * permission, please contact apache@apache.org. | |||
| * | |||
| * 5. Products derived from this software may not be called "Apache" | |||
| * nor may "Apache" appear in their names without prior written | |||
| * permission of the Apache Group. | |||
| * | |||
| * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
| * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
| * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
| * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
| * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
| * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
| * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
| * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
| * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
| * SUCH DAMAGE. | |||
| * ==================================================================== | |||
| * | |||
| * This software consists of voluntary contributions made by many | |||
| * individuals on behalf of the Apache Software Foundation. For more | |||
| * information on the Apache Software Foundation, please see | |||
| * <http://www.apache.org/>. | |||
| */ | |||
| package org.apache.tools.ant.gui; | |||
| import org.apache.tools.ant.gui.event.*; | |||
| import org.apache.tools.ant.gui.acs.ACSTargetElement; | |||
| import javax.swing.*; | |||
| import javax.swing.plaf.ComponentUI; | |||
| import javax.swing.text.Document; | |||
| import java.awt.BorderLayout; | |||
| import java.awt.Insets; | |||
| import java.awt.Dimension; | |||
| import java.util.EventObject; | |||
| /** | |||
| * A widget for displaying the currently selected targets. | |||
| * | |||
| * @version $Revision$ | |||
| * @author Simeon Fitch | |||
| */ | |||
| public class TargetMonitor extends AntEditor { | |||
| /** Place to display selected targets. */ | |||
| private JLabel _text = null; | |||
| /** Default text. */ | |||
| private String _defText = null; | |||
| /** | |||
| * Standard ctor. | |||
| * | |||
| * @param context Application context; | |||
| */ | |||
| public TargetMonitor(AppContext context) { | |||
| super(context); | |||
| context.getEventBus().addMember(EventBus.RESPONDING, new Handler()); | |||
| setLayout(new BorderLayout()); | |||
| _text = new JLabel(); | |||
| _text.setForeground(UIManager.getColor("TextField.foreground")); | |||
| add(BorderLayout.NORTH, _text); | |||
| _defText = context.getResources().getString(getClass(), "defText"); | |||
| setText(_defText); | |||
| } | |||
| /** | |||
| * Set the displayed text. | |||
| * | |||
| * @param text Text to display. | |||
| */ | |||
| private void setText(String text) { | |||
| _text.setText("<html> " + text + "</html>"); | |||
| } | |||
| /** Class for handling project events. */ | |||
| private class Handler implements BusMember { | |||
| private final Filter _filter = new Filter(); | |||
| /** | |||
| * Get the filter to that is used to determine if an event should | |||
| * to to the member. | |||
| * | |||
| * @return Filter to use. | |||
| */ | |||
| public BusFilter getBusFilter() { | |||
| return _filter; | |||
| } | |||
| /** | |||
| * Called when an event is to be posed to the member. | |||
| * | |||
| * @param event Event to post. | |||
| */ | |||
| public void eventPosted(EventObject event) { | |||
| ElementSelectionEvent e = (ElementSelectionEvent) event; | |||
| String text = _defText; | |||
| ProjectProxy p = getAppContext().getProject(); | |||
| if(p != null) { | |||
| ElementSelectionModel selections = p.getTreeSelectionModel(); | |||
| ACSTargetElement[] targets = selections.getSelectedTargets(); | |||
| if(targets != null && targets.length > 0) { | |||
| StringBuffer buf = new StringBuffer(); | |||
| for(int i = 0; i < targets.length; i++) { | |||
| buf.append(targets[i].getName()); | |||
| if(i < targets.length - 1) { | |||
| buf.append(", "); | |||
| } | |||
| } | |||
| text = buf.toString(); | |||
| } | |||
| } | |||
| setText(text); | |||
| } | |||
| } | |||
| /** Class providing filtering for project events. */ | |||
| private static class Filter implements BusFilter { | |||
| /** | |||
| * Determines if the given event should be accepted. | |||
| * | |||
| * @param event Event to test. | |||
| * @return True if event should be given to BusMember, false otherwise. | |||
| */ | |||
| public boolean accept(EventObject event) { | |||
| return event instanceof ElementSelectionEvent; | |||
| } | |||
| } | |||
| } | |||
| @@ -96,6 +96,21 @@ public abstract class ACSElement extends ElementNode { | |||
| return toString(); | |||
| } | |||
| /** | |||
| * Set the given attribute. | |||
| * | |||
| * @param name Name of the attribute. | |||
| * @param value Value of the attribute. | |||
| */ | |||
| public void setAttribute(String name, String value) { | |||
| if(value == null || value.length() == 0) { | |||
| removeAttribute(name); | |||
| } | |||
| else { | |||
| super.setAttribute(name, value); | |||
| } | |||
| } | |||
| /** | |||
| * Add a change listener. | |||
| * | |||
| @@ -259,7 +259,7 @@ public class DynamicCustomizer extends JPanel { | |||
| return retval; | |||
| } | |||
| /** Class for receiving change events from teh PropertyEditor objects. */ | |||
| /** Class for receiving change events from the PropertyEditor objects. */ | |||
| private class EditorChangeListener implements PropertyChangeListener { | |||
| public void propertyChange(PropertyChangeEvent e) { | |||
| PropertyEditor editor = (PropertyEditor) e.getSource(); | |||
| @@ -270,6 +270,7 @@ public class DynamicCustomizer extends JPanel { | |||
| try { | |||
| Object[] params = { editor.getValue() }; | |||
| writer.invoke(_value, params); | |||
| setObject(_value); | |||
| //firePropertyChange( | |||
| //prop.getName(), null, editor.getValue()); | |||
| } | |||
| @@ -13,12 +13,20 @@ org.apache.tools.ant.gui.Antidote.left.editors=\ | |||
| org.apache.tools.ant.gui.Antidote.bottom.editors=\ | |||
| org.apache.tools.ant.gui.Console | |||
| # Configure the editors that appear on the top of the UI. | |||
| org.apache.tools.ant.gui.Antidote.top.editors=\ | |||
| org.apache.tools.ant.gui.TargetMonitor | |||
| # Set specific class properties. | |||
| org.apache.tools.ant.gui.SourceEditor.name=Source | |||
| org.apache.tools.ant.gui.PropertyEditor.name=Properties | |||
| org.apache.tools.ant.gui.ProjectNavigator.name=Project | |||
| org.apache.tools.ant.gui.TargetMonitor.name=Selected Target(s) | |||
| org.apache.tools.ant.gui.TargetMonitor.defText=[none] | |||
| org.apache.tools.ant.gui.Console.name=Console | |||
| org.apache.tools.ant.gui.Console.logLevel=Log message level: | |||