You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by me...@locus.apache.org on 2000/11/14 20:48:05 UTC
cvs commit: jakarta-ant/src/antidote/org/apache/tools/ant/gui TargetMonitor.java Antidote.java Console.java ProjectNavigator.java PropertyEditor.java
metasim 00/11/14 11:48:05
Modified: src/antidote/org/apache/tools/ant/gui Antidote.java
Console.java ProjectNavigator.java
PropertyEditor.java
Added: src/antidote/org/apache/tools/ant/gui TargetMonitor.java
Log:
Added TargetMonitor widget which gives a better indication of what targets will
be built if a build is launched. Also fixed a few buglets in the PropertyEditor.
Revision Changes Path
1.3 +4 -1 jakarta-ant/src/antidote/org/apache/tools/ant/gui/Antidote.java
Index: Antidote.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/Antidote.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Antidote.java 2000/11/06 12:52:42 1.2
+++ Antidote.java 2000/11/14 19:47:58 1.3
@@ -62,7 +62,7 @@
* The root class for the Ant GUI. Assembles all the graphical components
* based on the configuration files.
*
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
* @author Simeon Fitch
*/
public class Antidote extends JPanel {
@@ -97,6 +97,9 @@
add(BorderLayout.CENTER, splitter2);
splitter2.resetToPreferredSizes();
+
+ add(BorderLayout.NORTH, populateEditors("top"));
+
setPreferredSize(new Dimension(640, 480));
}
1.5 +25 -10 jakarta-ant/src/antidote/org/apache/tools/ant/gui/Console.java
Index: Console.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/Console.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Console.java 2000/11/10 20:41:09 1.4
+++ Console.java 2000/11/14 19:48:02 1.5
@@ -64,7 +64,7 @@
/**
* Logging console display.
*
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
* @author Simeon Fitch
*/
public class Console extends AntEditor {
@@ -117,24 +117,37 @@
}
/**
+ * 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 @@
if(text != null) {
try {
+ Document doc = _text.getDocument();
doc.insertString(doc.getLength(), text, null);
doc.insertString(doc.getLength(), "\n", null);
}
@@ -173,7 +187,8 @@
* @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;
}
}
1.5 +2 -2 jakarta-ant/src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java
Index: ProjectNavigator.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ProjectNavigator.java 2000/11/09 23:14:10 1.4
+++ ProjectNavigator.java 2000/11/14 19:48:02 1.5
@@ -61,7 +61,7 @@
/**
* AntEditor for displaying the project target in a
*
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
* @author Simeon Fitch
*/
class ProjectNavigator extends AntEditor {
@@ -87,7 +87,7 @@
add(scroller);
setPreferredSize(new Dimension(150, 100));
-
+ setMinimumSize(new Dimension(150, 100));
}
/** Class for handling project events. */
1.6 +3 -2 jakarta-ant/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java
Index: PropertyEditor.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PropertyEditor.java 2000/11/11 04:52:20 1.5
+++ PropertyEditor.java 2000/11/14 19:48:02 1.6
@@ -65,7 +65,7 @@
/**
* Stub for a property editor.
*
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
* @author Simeon H.K. Fitch
*/
class PropertyEditor extends AntEditor {
@@ -99,11 +99,12 @@
_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();
}
1.1 jakarta-ant/src/antidote/org/apache/tools/ant/gui/TargetMonitor.java
Index: TargetMonitor.java
===================================================================
/*
* 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: 1.1 $
* @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;
}
}
}