diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java deleted file mode 100644 index fbaddc07d..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import com.ibm.ivj.util.base.Project; -import com.ibm.ivj.util.base.ToolData; -import org.apache.myrmidon.api.TaskException; - -/** - * This class is the equivalent to org.apache.tools.ant.Main for the VAJ tool - * environment. It's main is called when the user selects Tools->Ant Build from - * the VAJ project menu. Additionally this class provides methods to save build - * info for a project in the repository and load it from the repository - * - * @author RT - * @author: Wolf Siberski - */ -public class VAJAntTool -{ - private final static String TOOL_DATA_KEY = "AntTool"; - - /** - * Loads the BuildInfo for the specified VAJ project from the tool data for - * this project. If there is no build info stored for that project, a new - * default BuildInfo is returned - * - * @param projectName String project name - * @return BuildInfo buildInfo build info for the specified project - */ - public static VAJBuildInfo loadBuildData( String projectName ) - { - VAJBuildInfo result = null; - try - { - Project project = - VAJLocalUtil.getWorkspace().loadedProjectNamed( projectName ); - if( project.testToolRepositoryData( TOOL_DATA_KEY ) ) - { - ToolData td = project.getToolRepositoryData( TOOL_DATA_KEY ); - String data = (String)td.getData(); - result = VAJBuildInfo.parse( data ); - } - else - { - result = new VAJBuildInfo(); - } - result.setVAJProjectName( projectName ); - } - catch( Throwable t ) - { - throw new TaskException( "BuildInfo for Project " - + projectName + " could not be loaded" + t ); - } - return result; - } - - /** - * Starts the application. - * - * @param args an array of command-line arguments. VAJ puts the VAJ project - * name into args[1] when starting the tool from the project context - * menu - */ - public static void main( java.lang.String[] args ) - { - try - { - VAJBuildInfo info; - if( args.length >= 2 && args[ 1 ] instanceof String ) - { - String projectName = (String)args[ 1 ]; - info = loadBuildData( projectName ); - } - else - { - info = new VAJBuildInfo(); - } - - VAJAntToolGUI mainFrame = new VAJAntToolGUI( info ); - mainFrame.show(); - } - catch( Throwable t ) - { - // if all error handling fails, output at least - // something on the console - t.printStackTrace(); - } - } - - /** - * Saves the BuildInfo for a project in the VAJ repository. - * - * @param info BuildInfo build info to save - */ - public static void saveBuildData( VAJBuildInfo info ) - { - String data = info.asDataString(); - try - { - ToolData td = new ToolData( TOOL_DATA_KEY, data ); - VAJLocalUtil.getWorkspace().loadedProjectNamed( - info.getVAJProjectName() ).setToolRepositoryData( td ); - } - catch( Throwable t ) - { - throw new TaskException( "BuildInfo for Project " - + info.getVAJProjectName() + " could not be saved", t ); - } - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java deleted file mode 100644 index 37e25c0f1..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java +++ /dev/null @@ -1,1852 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.awt.BorderLayout; -import java.awt.Button; -import java.awt.Choice; -import java.awt.Dialog; -import java.awt.FileDialog; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.Label; -import java.awt.List; -import java.awt.Menu; -import java.awt.MenuBar; -import java.awt.MenuItem; -import java.awt.Panel; -import java.awt.SystemColor; -import java.awt.TextArea; -import java.awt.TextField; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.TextEvent; -import java.awt.event.TextListener; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import org.apache.avalon.framework.ExceptionUtil; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.BuildEvent; -import org.apache.tools.ant.BuildListener; -import org.apache.tools.ant.Project; - -/** - * This is a simple grafical user interface to provide the information needed by - * ANT and to start the build-process within IBM VisualAge for Java.

- * - * I was using AWT to make it independent from the JDK-version. Please don't ask - * me for a Swing-version:I am very familiar with Swing and I really think that - * it's not necessary for such a simple gui!

- * - * It is completely developed in VAJ using the visual composition editor. About - * 90% of the code is generated by VAJ, but in fact I did a lot of - * code-beautification ;-).

- * - * - * - * @author RT - * @version 1.0 h - * @author: Christoph Wilhelms, TUI Infotec GmbH - */ -public class VAJAntToolGUI extends Frame -{ - private final static String lineSeparator = "\r\n"; - /** - * Members - */ - private VAJBuildLogger logger = new VAJBuildLogger(); - private PrivateEventHandler iEventHandler = new PrivateEventHandler(); - - /** - * Members of the main-window - */ - // main model - private VAJBuildInfo iBuildInfo = null; - // Menue - private MenuBar iAntMakeMenuBar = null; - private Menu iFileMenu = null; - private MenuItem iSaveMenuItem = null; - private MenuItem iMenuSeparator = null; - private MenuItem iShowLogMenuItem = null; - private Menu iHelpMenu = null; - private MenuItem iAboutMenuItem = null; - // Container - private Panel iContentsPane = null; - private Panel iOptionenPanel = null; - private Panel iCommandButtonPanel = null; - private FlowLayout iCommandButtonPanelFlowLayout = null; - // Project name - private Label iProjectLabel = null; - private Label iProjectText = null; - // XML-file - private Label iBuildFileLabel = null; - private TextField iBuildFileTextField = null; - private boolean iConnPtoP2Aligning = false; - private Button iBrowseButton = null; - private FileDialog iFileDialog = null; - // Options - private Choice iMessageOutputLevelChoice = null; - private Label iMessageOutputLevelLabel = null; - private Label iTargetLabel = null; - private List iTargetList = null; - // Command-buttons - private Button iBuildButton = null; - private Button iReloadButton = null; - private Button iCloseButton = null; - /** - * log-Window - */ - // Container - private Frame iMessageFrame = null; - private Panel iMessageCommandPanel = null; - private Panel iMessageContentPanel = null; - // Components - private TextArea iMessageTextArea = null; - private Button iMessageOkButton = null; - private Button iMessageClearLogButton = null; - /** - * About-dialog - */ - // Container - private Dialog iAboutDialog = null; - private Panel iAboutDialogContentPanel = null; - private Panel iAboutInfoPanel = null; - private Panel iAboutCommandPanel = null; - // Labels - private Label iAboutTitleLabel = null; - private Label iAboutDevLabel = null; - private Label iAboutContactLabel = null; - // Buttons - private Button iAboutOkButton = null; - - private Button iStopButton = null; - - /** - * AntMake constructor called by VAJAntTool integration. - * - * @param newBuildInfo Description of Parameter - */ - - public VAJAntToolGUI( VAJBuildInfo newBuildInfo ) - { - super(); - setBuildInfo( newBuildInfo ); - initialize(); - } - - /** - * AntMake default-constructor. - */ - private VAJAntToolGUI() - { - super(); - initialize(); - } - - /** - * This method is used to center dialogs. - * - * @param dialog Description of Parameter - */ - public static void centerDialog( Dialog dialog ) - { - dialog.setLocation( ( Toolkit.getDefaultToolkit().getScreenSize().width / 2 ) - ( dialog.getSize().width / 2 ), ( java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2 ) - ( dialog.getSize().height / 2 ) ); - } - - /** - * Copied from DefaultLogger to provide the same time-format. - * - * @param millis Description of Parameter - * @return Description of the Returned Value - */ - public static String formatTime( long millis ) - { - long seconds = millis / 1000; - long minutes = seconds / 60; - - if( minutes > 0 ) - { - return Long.toString( minutes ) + " minute" - + ( minutes == 1 ? " " : "s " ) - + Long.toString( seconds % 60 ) + " second" - + ( seconds % 60 == 1 ? "" : "s" ); - } - else - { - return Long.toString( seconds ) + " second" - + ( seconds % 60 == 1 ? "" : "s" ); - } - } - - /** - * Set the BuildInfo to a new value. - * - * @param newValue org.apache.tools.ant.taskdefs.optional.vaj.VAJBuildInfo - */ - private void setBuildInfo( VAJBuildInfo newValue ) - { - if( iBuildInfo != newValue ) - { - try - { - /* - * Stop listening for events from the current object - */ - if( iBuildInfo != null ) - { - iBuildInfo.removePropertyChangeListener( iEventHandler ); - } - iBuildInfo = newValue; - - /* - * Listen for events from the new object - */ - if( iBuildInfo != null ) - { - iBuildInfo.addPropertyChangeListener( iEventHandler ); - } - connectProjectNameToLabel(); - connectBuildFileNameToTextField(); - - // Select the log-level given by BuildInfo - getMessageOutputLevelChoice().select( iBuildInfo.getOutputMessageLevel() ); - fillList(); - // BuildInfo can conly be saved to a VAJ project if tool API is called via the projects context-menu - if( ( iBuildInfo.getVAJProjectName() == null ) || ( iBuildInfo.getVAJProjectName().equals( "" ) ) ) - { - getSaveMenuItem().setEnabled( false ); - } - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - } - - /** - * Return the AboutCommandPanel property value. - * - * @return java.awt.Panel - */ - private Panel getAboutCommandPanel() - { - if( iAboutCommandPanel == null ) - { - try - { - iAboutCommandPanel = new Panel(); - iAboutCommandPanel.setName( "AboutCommandPanel" ); - iAboutCommandPanel.setLayout( new java.awt.FlowLayout() ); - getAboutCommandPanel().add( getAboutOkButton(), getAboutOkButton().getName() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutCommandPanel; - } - - /** - * Return the AboutContactLabel property value. - * - * @return java.awt.Label - */ - private Label getAboutContactLabel() - { - if( iAboutContactLabel == null ) - { - try - { - iAboutContactLabel = new Label(); - iAboutContactLabel.setName( "AboutContactLabel" ); - iAboutContactLabel.setAlignment( java.awt.Label.CENTER ); - iAboutContactLabel.setText( "contact: wolf.siberski@tui.de or christoph.wilhelms@tui.de" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutContactLabel; - } - - /** - * Return the AboutDevLabel property value. - * - * @return java.awt.Label - */ - private Label getAboutDevLabel() - { - if( iAboutDevLabel == null ) - { - try - { - iAboutDevLabel = new Label(); - iAboutDevLabel.setName( "AboutDevLabel" ); - iAboutDevLabel.setAlignment( java.awt.Label.CENTER ); - iAboutDevLabel.setText( "developed by Wolf Siberski & Christoph Wilhelms" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutDevLabel; - } - - /** - * Return the AboutDialog property value. - * - * @return java.awt.Dialog - */ - private Dialog getAboutDialog() - { - if( iAboutDialog == null ) - { - try - { - iAboutDialog = new Dialog( this ); - iAboutDialog.setName( "AboutDialog" ); - iAboutDialog.setResizable( false ); - iAboutDialog.setLayout( new java.awt.BorderLayout() ); - iAboutDialog.setBounds( 550, 14, 383, 142 ); - iAboutDialog.setModal( true ); - iAboutDialog.setTitle( "About..." ); - getAboutDialog().add( getAboutDialogContentPanel(), "Center" ); - iAboutDialog.pack(); - centerDialog( iAboutDialog ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutDialog; - } - - /** - * Return the AboutDialogContentPanel property value. - * - * @return java.awt.Panel - */ - private Panel getAboutDialogContentPanel() - { - if( iAboutDialogContentPanel == null ) - { - try - { - iAboutDialogContentPanel = new Panel(); - iAboutDialogContentPanel.setName( "AboutDialogContentPanel" ); - iAboutDialogContentPanel.setLayout( new java.awt.BorderLayout() ); - getAboutDialogContentPanel().add( getAboutCommandPanel(), "South" ); - getAboutDialogContentPanel().add( getAboutInfoPanel(), "Center" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutDialogContentPanel; - } - - /** - * Return the AboutInfoPanel property value. - * - * @return java.awt.Panel - */ - private Panel getAboutInfoPanel() - { - if( iAboutInfoPanel == null ) - { - try - { - iAboutInfoPanel = new Panel(); - iAboutInfoPanel.setName( "AboutInfoPanel" ); - iAboutInfoPanel.setLayout( new GridBagLayout() ); - - GridBagConstraints constraintsAboutTitleLabel = new GridBagConstraints(); - constraintsAboutTitleLabel.gridx = 0; - constraintsAboutTitleLabel.gridy = 0; - constraintsAboutTitleLabel.fill = GridBagConstraints.HORIZONTAL; - constraintsAboutTitleLabel.weightx = 1.0; - constraintsAboutTitleLabel.weighty = 1.0; - constraintsAboutTitleLabel.insets = new Insets( 4, 0, 4, 0 ); - getAboutInfoPanel().add( getAboutTitleLabel(), constraintsAboutTitleLabel ); - - GridBagConstraints constraintsAboutDevLabel = new GridBagConstraints(); - constraintsAboutDevLabel.gridx = 0; - constraintsAboutDevLabel.gridy = 1; - constraintsAboutDevLabel.fill = GridBagConstraints.HORIZONTAL; - constraintsAboutDevLabel.weightx = 1.0; - constraintsAboutDevLabel.insets = new Insets( 4, 0, 0, 0 ); - getAboutInfoPanel().add( getAboutDevLabel(), constraintsAboutDevLabel ); - - GridBagConstraints constraintsAboutContactLabel = new GridBagConstraints(); - constraintsAboutContactLabel.gridx = 0; - constraintsAboutContactLabel.gridy = 2; - constraintsAboutContactLabel.fill = GridBagConstraints.HORIZONTAL; - constraintsAboutContactLabel.weightx = 1.0; - constraintsAboutContactLabel.insets = new Insets( 2, 0, 4, 0 ); - getAboutInfoPanel().add( getAboutContactLabel(), constraintsAboutContactLabel ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutInfoPanel; - } - - /** - * Return the AboutMenuItem property value. - * - * @return java.awt.MenuItem - */ - private MenuItem getAboutMenuItem() - { - if( iAboutMenuItem == null ) - { - try - { - iAboutMenuItem = new MenuItem(); - iAboutMenuItem.setLabel( "About..." ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutMenuItem; - } - - /** - * Return the AboutOkButton property value. - * - * @return java.awt.Button - */ - private Button getAboutOkButton() - { - if( iAboutOkButton == null ) - { - try - { - iAboutOkButton = new Button(); - iAboutOkButton.setName( "AboutOkButton" ); - iAboutOkButton.setLabel( "OK" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutOkButton; - } - - /** - * Return the AboutTitleLabel property value. - * - * @return java.awt.Label - */ - private Label getAboutTitleLabel() - { - if( iAboutTitleLabel == null ) - { - try - { - iAboutTitleLabel = new Label(); - iAboutTitleLabel.setName( "AboutTitleLabel" ); - iAboutTitleLabel.setFont( new Font( "Arial", 1, 12 ) ); - iAboutTitleLabel.setAlignment( Label.CENTER ); - iAboutTitleLabel.setText( "Ant VisualAge for Java Tool-Integration" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutTitleLabel; - } - - /** - * Return the AntMakeMenuBar property value. - * - * @return java.awt.MenuBar - */ - private MenuBar getAntMakeMenuBar() - { - if( iAntMakeMenuBar == null ) - { - try - { - iAntMakeMenuBar = new MenuBar(); - iAntMakeMenuBar.add( getFileMenu() ); - iAntMakeMenuBar.add( getHelpMenu() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAntMakeMenuBar; - } - - /** - * Return the BrowseButton property value. - * - * @return Button - */ - private Button getBrowseButton() - { - if( iBrowseButton == null ) - { - try - { - iBrowseButton = new Button(); - iBrowseButton.setName( "BrowseButton" ); - iBrowseButton.setLabel( "..." ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iBrowseButton; - } - - /** - * Return the BuildButton property value. - * - * @return java.awt.Button - */ - private Button getBuildButton() - { - if( iBuildButton == null ) - { - try - { - iBuildButton = new Button(); - iBuildButton.setName( "BuildButton" ); - iBuildButton.setLabel( "Execute" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iBuildButton; - } - - /** - * Return the BuildFileLabel property value. - * - * @return java.awt.Label - */ - private Label getBuildFileLabel() - { - if( iBuildFileLabel == null ) - { - try - { - iBuildFileLabel = new Label(); - iBuildFileLabel.setName( "BuildFileLabel" ); - iBuildFileLabel.setText( "Ant-Buildfile:" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iBuildFileLabel; - } - - /** - * Return the BuildFileTextField property value. - * - * @return java.awt.TextField - */ - private TextField getBuildFileTextField() - { - if( iBuildFileTextField == null ) - { - try - { - iBuildFileTextField = new TextField(); - iBuildFileTextField.setName( "BuildFileTextField" ); - iBuildFileTextField.setBackground( SystemColor.textHighlightText ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iBuildFileTextField; - } - - /** - * Return the BuildInfo property value. - * - * @return org.apache.tools.ant.taskdefs.optional.ide.VAJBuildInfo - */ - private VAJBuildInfo getBuildInfo() - { - return iBuildInfo; - } - - /** - * Return the CloseButton property value. - * - * @return java.awt.Button - */ - private Button getCloseButton() - { - if( iCloseButton == null ) - { - try - { - iCloseButton = new Button(); - iCloseButton.setName( "CloseButton" ); - iCloseButton.setLabel( "Close" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iCloseButton; - } - - /** - * Return the CommandButtonPanel property value. - * - * @return java.awt.Panel - */ - private Panel getCommandButtonPanel() - { - if( iCommandButtonPanel == null ) - { - try - { - iCommandButtonPanel = new Panel(); - iCommandButtonPanel.setName( "CommandButtonPanel" ); - iCommandButtonPanel.setLayout( getCommandButtonPanelFlowLayout() ); - iCommandButtonPanel.setBackground( SystemColor.control ); - iCommandButtonPanel.add( getReloadButton() ); - iCommandButtonPanel.add( getBuildButton() ); - iCommandButtonPanel.add( getStopButton() ); - iCommandButtonPanel.add( getCloseButton() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iCommandButtonPanel; - } - - /** - * Return the CommandButtonPanelFlowLayout property value. - * - * @return java.awt.FlowLayout - */ - private FlowLayout getCommandButtonPanelFlowLayout() - { - FlowLayout iCommandButtonPanelFlowLayout = null; - try - { - /* - * Create part - */ - iCommandButtonPanelFlowLayout = new FlowLayout(); - iCommandButtonPanelFlowLayout.setAlignment( FlowLayout.RIGHT ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - ; - return iCommandButtonPanelFlowLayout; - } - - /** - * Return the ContentsPane property value. - * - * @return java.awt.Panel - */ - private Panel getContentsPane() - { - if( iContentsPane == null ) - { - try - { - iContentsPane = new Panel(); - iContentsPane.setName( "ContentsPane" ); - iContentsPane.setLayout( new BorderLayout() ); - getContentsPane().add( getCommandButtonPanel(), "South" ); - getContentsPane().add( getOptionenPanel(), "Center" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iContentsPane; - } - - /** - * Return the FileDialog property value. - * - * @return java.awt.FileDialog - */ - private FileDialog getFileDialog() - { - if( iFileDialog == null ) - { - try - { - iFileDialog = new FileDialog( this ); - iFileDialog.setName( "FileDialog" ); - iFileDialog.setLayout( null ); - centerDialog( iFileDialog ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iFileDialog; - } - - /** - * Return the FileMenu property value. - * - * @return java.awt.Menu - */ - private Menu getFileMenu() - { - if( iFileMenu == null ) - { - try - { - iFileMenu = new Menu(); - iFileMenu.setLabel( "File" ); - iFileMenu.add( getSaveMenuItem() ); - iFileMenu.add( getMenuSeparator() ); - iFileMenu.add( getShowLogMenuItem() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iFileMenu; - } - - /** - * Return the HelpMenu property value. - * - * @return java.awt.Menu - */ - private Menu getHelpMenu() - { - if( iHelpMenu == null ) - { - try - { - iHelpMenu = new Menu(); - iHelpMenu.setLabel( "Help" ); - iHelpMenu.add( getAboutMenuItem() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iHelpMenu; - } - - /** - * Return the MenuSeparator1 property value. - * - * @return java.awt.MenuItem - */ - private MenuItem getMenuSeparator() - { - if( iMenuSeparator == null ) - { - try - { - iMenuSeparator = new MenuItem(); - iMenuSeparator.setLabel( "-" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMenuSeparator; - } - - /** - * Return the MessageClearLogButton property value. - * - * @return java.awt.Button - */ - private Button getMessageClearLogButton() - { - if( iMessageClearLogButton == null ) - { - try - { - iMessageClearLogButton = new Button(); - iMessageClearLogButton.setName( "MessageClearLogButton" ); - iMessageClearLogButton.setLabel( "Clear Log" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageClearLogButton; - } - - /** - * Return the MessageCommandPanel property value. - * - * @return java.awt.Panel - */ - private Panel getMessageCommandPanel() - { - if( iMessageCommandPanel == null ) - { - try - { - iMessageCommandPanel = new Panel(); - iMessageCommandPanel.setName( "MessageCommandPanel" ); - iMessageCommandPanel.setLayout( new FlowLayout() ); - getMessageCommandPanel().add( getMessageClearLogButton(), getMessageClearLogButton().getName() ); - getMessageCommandPanel().add( getMessageOkButton(), getMessageOkButton().getName() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageCommandPanel; - } - - /** - * Return the MessageContentPanel property value. - * - * @return java.awt.Panel - */ - private Panel getMessageContentPanel() - { - if( iMessageContentPanel == null ) - { - try - { - iMessageContentPanel = new Panel(); - iMessageContentPanel.setName( "MessageContentPanel" ); - iMessageContentPanel.setLayout( new BorderLayout() ); - iMessageContentPanel.setBackground( SystemColor.control ); - getMessageContentPanel().add( getMessageTextArea(), "Center" ); - getMessageContentPanel().add( getMessageCommandPanel(), "South" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageContentPanel; - } - - /** - * Return the MessageFrame property value. - * - * @return java.awt.Frame - */ - private Frame getMessageFrame() - { - if( iMessageFrame == null ) - { - try - { - iMessageFrame = new Frame(); - iMessageFrame.setName( "MessageFrame" ); - iMessageFrame.setLayout( new BorderLayout() ); - iMessageFrame.setBounds( 0, 0, 750, 250 ); - iMessageFrame.setTitle( "Message Log" ); - iMessageFrame.add( getMessageContentPanel(), "Center" ); - iMessageFrame.setLocation( ( Toolkit.getDefaultToolkit().getScreenSize().width / 2 ) - ( iMessageFrame.getSize().width / 2 ), ( java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2 ) ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageFrame; - } - - /** - * Return the MessageOkButton property value. - * - * @return java.awt.Button - */ - private Button getMessageOkButton() - { - if( iMessageOkButton == null ) - { - try - { - iMessageOkButton = new Button(); - iMessageOkButton.setName( "MessageOkButton" ); - iMessageOkButton.setLabel( "Close" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageOkButton; - } - - /** - * Return the MessageOutputLevelChoice property value. - * - * @return java.awt.Choice - */ - private Choice getMessageOutputLevelChoice() - { - if( iMessageOutputLevelChoice == null ) - { - try - { - iMessageOutputLevelChoice = new Choice(); - iMessageOutputLevelChoice.setName( "MessageOutputLevelChoice" ); - iMessageOutputLevelChoice.add( "Error" ); - iMessageOutputLevelChoice.add( "Warning" ); - iMessageOutputLevelChoice.add( "Info" ); - iMessageOutputLevelChoice.add( "Verbose" ); - iMessageOutputLevelChoice.add( "Debug" ); - iMessageOutputLevelChoice.select( 2 ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageOutputLevelChoice; - } - - /** - * Return the MessageOutputLevelLabel property value. - * - * @return java.awt.Label - */ - private Label getMessageOutputLevelLabel() - { - if( iMessageOutputLevelLabel == null ) - { - try - { - iMessageOutputLevelLabel = new Label(); - iMessageOutputLevelLabel.setName( "MessageOutputLevelLabel" ); - iMessageOutputLevelLabel.setText( "Message Level:" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageOutputLevelLabel; - } - - /** - * Return the MessageTextArea property value. - * - * @return java.awt.TextArea - */ - private TextArea getMessageTextArea() - { - if( iMessageTextArea == null ) - { - try - { - iMessageTextArea = new TextArea(); - iMessageTextArea.setName( "MessageTextArea" ); - iMessageTextArea.setFont( new Font( "monospaced", 0, 12 ) ); - iMessageTextArea.setText( "" ); - iMessageTextArea.setEditable( false ); - iMessageTextArea.setEnabled( true ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageTextArea; - } - - /** - * Return the Panel1 property value. - * - * @return java.awt.Panel - */ - private Panel getOptionenPanel() - { - if( iOptionenPanel == null ) - { - try - { - iOptionenPanel = new Panel(); - iOptionenPanel.setName( "OptionenPanel" ); - iOptionenPanel.setLayout( new GridBagLayout() ); - iOptionenPanel.setBackground( SystemColor.control ); - - GridBagConstraints constraintsProjectLabel = new GridBagConstraints(); - constraintsProjectLabel.gridx = 0; - constraintsProjectLabel.gridy = 0; - constraintsProjectLabel.anchor = GridBagConstraints.WEST; - constraintsProjectLabel.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getProjectLabel(), constraintsProjectLabel ); - - GridBagConstraints constraintsBuildFileLabel = new GridBagConstraints(); - constraintsBuildFileLabel.gridx = 0; - constraintsBuildFileLabel.gridy = 1; - constraintsBuildFileLabel.anchor = GridBagConstraints.WEST; - constraintsBuildFileLabel.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getBuildFileLabel(), constraintsBuildFileLabel ); - - GridBagConstraints constraintsTargetLabel = new GridBagConstraints(); - constraintsTargetLabel.gridx = 0; - constraintsTargetLabel.gridy = 2; - constraintsTargetLabel.anchor = GridBagConstraints.NORTHWEST; - constraintsTargetLabel.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getTargetLabel(), constraintsTargetLabel ); - - GridBagConstraints constraintsProjectText = new GridBagConstraints(); - constraintsProjectText.gridx = 1; - constraintsProjectText.gridy = 0; - constraintsProjectText.gridwidth = 2; - constraintsProjectText.fill = GridBagConstraints.HORIZONTAL; - constraintsProjectText.anchor = GridBagConstraints.WEST; - constraintsProjectText.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getProjectText(), constraintsProjectText ); - - GridBagConstraints constraintsBuildFileTextField = new GridBagConstraints(); - constraintsBuildFileTextField.gridx = 1; - constraintsBuildFileTextField.gridy = 1; - constraintsBuildFileTextField.fill = GridBagConstraints.HORIZONTAL; - constraintsBuildFileTextField.anchor = GridBagConstraints.WEST; - constraintsBuildFileTextField.weightx = 1.0; - constraintsBuildFileTextField.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getBuildFileTextField(), constraintsBuildFileTextField ); - - GridBagConstraints constraintsBrowseButton = new GridBagConstraints(); - constraintsBrowseButton.gridx = 2; - constraintsBrowseButton.gridy = 1; - constraintsBrowseButton.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getBrowseButton(), constraintsBrowseButton ); - - GridBagConstraints constraintsTargetList = new GridBagConstraints(); - constraintsTargetList.gridx = 1; - constraintsTargetList.gridy = 2; - constraintsTargetList.gridheight = 2; - constraintsTargetList.fill = GridBagConstraints.BOTH; - constraintsTargetList.weightx = 1.0; - constraintsTargetList.weighty = 1.0; - constraintsTargetList.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getTargetList(), constraintsTargetList ); - - GridBagConstraints constraintsMessageOutputLevelLabel = new GridBagConstraints(); - constraintsMessageOutputLevelLabel.gridx = 0; - constraintsMessageOutputLevelLabel.gridy = 4; - constraintsMessageOutputLevelLabel.anchor = GridBagConstraints.WEST; - constraintsMessageOutputLevelLabel.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getMessageOutputLevelLabel(), constraintsMessageOutputLevelLabel ); - - GridBagConstraints constraintsMessageOutputLevelChoice = new GridBagConstraints(); - constraintsMessageOutputLevelChoice.gridx = 1; - constraintsMessageOutputLevelChoice.gridy = 4; - constraintsMessageOutputLevelChoice.fill = GridBagConstraints.HORIZONTAL; - constraintsMessageOutputLevelChoice.anchor = GridBagConstraints.WEST; - constraintsMessageOutputLevelChoice.weightx = 1.0; - constraintsMessageOutputLevelChoice.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getMessageOutputLevelChoice(), constraintsMessageOutputLevelChoice ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iOptionenPanel; - } - - /** - * Return the ProjectLabel property value. - * - * @return java.awt.Label - */ - private Label getProjectLabel() - { - if( iProjectLabel == null ) - { - try - { - iProjectLabel = new Label(); - iProjectLabel.setName( "ProjectLabel" ); - iProjectLabel.setText( "Projectname:" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iProjectLabel; - } - - /** - * Return the ProjectText property value. - * - * @return java.awt.Label - */ - private Label getProjectText() - { - if( iProjectText == null ) - { - try - { - iProjectText = new Label(); - iProjectText.setName( "ProjectText" ); - iProjectText.setText( " " ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iProjectText; - } - - /** - * Return the ReloadButton property value. - * - * @return java.awt.Button - */ - private Button getReloadButton() - { - if( iReloadButton == null ) - { - try - { - iReloadButton = new Button(); - iReloadButton.setName( "ReloadButton" ); - iReloadButton.setLabel( "(Re)Load" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iReloadButton; - } - - /** - * Return the SaveMenuItem property value. - * - * @return java.awt.MenuItem - */ - private MenuItem getSaveMenuItem() - { - if( iSaveMenuItem == null ) - { - try - { - iSaveMenuItem = new MenuItem(); - iSaveMenuItem.setLabel( "Save BuildInfo To Repository" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iSaveMenuItem; - } - - /** - * Return the ShowLogMenuItem property value. - * - * @return java.awt.MenuItem - */ - private MenuItem getShowLogMenuItem() - { - if( iShowLogMenuItem == null ) - { - try - { - iShowLogMenuItem = new MenuItem(); - iShowLogMenuItem.setLabel( "Log" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iShowLogMenuItem; - } - - /** - * Return the StopButton property value. - * - * @return java.awt.Button - */ - private Button getStopButton() - { - if( iStopButton == null ) - { - try - { - iStopButton = new Button(); - iStopButton.setName( "StopButton" ); - iStopButton.setLabel( "Stop" ); - iStopButton.setEnabled( false ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iStopButton; - } - - /** - * Return the TargetLabel property value. - * - * @return java.awt.Label - */ - private Label getTargetLabel() - { - if( iTargetLabel == null ) - { - try - { - iTargetLabel = new Label(); - iTargetLabel.setName( "TargetLabel" ); - iTargetLabel.setText( "Target:" ); - iTargetLabel.setEnabled( true ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iTargetLabel; - } - - /** - * Return the TargetList property value. - * - * @return java.awt.List - */ - private List getTargetList() - { - if( iTargetList == null ) - { - try - { - iTargetList = new List(); - iTargetList.setName( "TargetList" ); - iTargetList.setEnabled( true ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iTargetList; - } - - /** - * connectBuildFileNameToTextField: (BuildInfo.buildFileName <--> - * BuildFileTextField.text) - */ - private void connectBuildFileNameToTextField() - { - /* - * Set the target from the source - */ - try - { - if( iConnPtoP2Aligning == false ) - { - iConnPtoP2Aligning = true; - if( ( getBuildInfo() != null ) ) - { - getBuildFileTextField().setText( getBuildInfo().getBuildFileName() ); - } - iConnPtoP2Aligning = false; - } - } - catch( Throwable iExc ) - { - iConnPtoP2Aligning = false; - handleException( iExc ); - } - } - - /** - * connectProjectNameToLabel: (BuildInfo.vajProjectName <--> - * ProjectText.text) - */ - private void connectProjectNameToLabel() - { - /* - * Set the target from the source - */ - try - { - if( ( getBuildInfo() != null ) ) - { - getProjectText().setText( getBuildInfo().getVAJProjectName() ); - } - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - - /** - * connectTextFieldToBuildFileName: (BuildInfo.buildFileName <--> - * BuildFileTextField.text) - */ - private void connectTextFieldToBuildFileName() - { - /* - * Set the source from the target - */ - try - { - if( iConnPtoP2Aligning == false ) - { - iConnPtoP2Aligning = true; - if( ( getBuildInfo() != null ) ) - { - getBuildInfo().setBuildFileName( getBuildFileTextField().getText() ); - } - iConnPtoP2Aligning = false; - } - } - catch( Throwable iExc ) - { - iConnPtoP2Aligning = false; - handleException( iExc ); - } - } - - /** - * external build of a .jar-file - */ - private void executeTarget() - { - try - { - getMessageFrame().show(); - getBuildInfo().executeProject( logger ); - } - catch( Throwable exc ) - { - logger.logException( exc ); - } - return; - } - - /** - * Fills the taget-list with project-targets - */ - private void fillList() - { - getTargetList().removeAll(); - ArrayList targets = getBuildInfo().getProjectTargets(); - for( int i = 0; i < targets.size(); i++ ) - { - getTargetList().add( targets.get( i ).toString() ); - } - getTargetList().select( iBuildInfo.getProjectTargets().indexOf( iBuildInfo.getTarget() ) ); - if( getTargetList().getSelectedIndex() >= 0 ) - { - getBuildButton().setEnabled( true ); - } - } - - /** - * Called whenever the part throws an exception. - * - * @param exception Throwable - */ - private void handleException( Throwable exception ) - { - // Write exceptions to the log-window - String trace = ExceptionUtil.printStackTrace( exception ); - - getMessageTextArea().append( lineSeparator + lineSeparator + trace ); - getMessageFrame().show(); - - } - - /** - * Initializes connections - * - * @exception Exception The exception description. - */ - private void initConnections() - throws Exception - { - this.addWindowListener( iEventHandler ); - getBrowseButton().addActionListener( iEventHandler ); - getCloseButton().addActionListener( iEventHandler ); - getBuildButton().addActionListener( iEventHandler ); - getStopButton().addActionListener( iEventHandler ); - getSaveMenuItem().addActionListener( iEventHandler ); - getAboutOkButton().addActionListener( iEventHandler ); - getAboutMenuItem().addActionListener( iEventHandler ); - getMessageOkButton().addActionListener( iEventHandler ); - getMessageClearLogButton().addActionListener( iEventHandler ); - getMessageOkButton().addActionListener( iEventHandler ); - getShowLogMenuItem().addActionListener( iEventHandler ); - getAboutDialog().addWindowListener( iEventHandler ); - getMessageFrame().addWindowListener( iEventHandler ); - getReloadButton().addActionListener( iEventHandler ); - getTargetList().addItemListener( iEventHandler ); - getMessageOutputLevelChoice().addItemListener( iEventHandler ); - getBuildFileTextField().addTextListener( iEventHandler ); - connectProjectNameToLabel(); - connectBuildFileNameToTextField(); - } - - /** - * Initialize the class. - */ - private void initialize() - { - try - { - setName( "AntMake" ); - setMenuBar( getAntMakeMenuBar() ); - setLayout( new java.awt.BorderLayout() ); - setSize( 389, 222 ); - setTitle( "Ant VisualAge for Java Tool-Integration" ); - add( getContentsPane(), "Center" ); - initConnections(); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - setLocation( ( Toolkit.getDefaultToolkit().getScreenSize().width / 2 ) - ( getSize().width / 2 ), ( java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2 ) - ( getSize().height ) ); - if( ( getTargetList().getItemCount() == 0 ) || ( getTargetList().getSelectedIndex() < 0 ) ) - { - getBuildButton().setEnabled( false ); - } - } - - /** - * Saves the build-informations to repository - */ - private void saveBuildInfo() - { - try - { - VAJAntTool.saveBuildData( getBuildInfo() ); - } - catch( Throwable exc ) - { - // This Exception occurs when you try to write into a versioned project - handleException( exc ); - } - return; - } - - /** - * Eventhandler to handle all AWT-events - * - * @author RT - */ - private class PrivateEventHandler implements ActionListener, ItemListener, TextListener, WindowListener, PropertyChangeListener - { - /** - * ActionListener method - * - * @param e Description of Parameter - */ - public void actionPerformed( ActionEvent e ) - { - try - { - /* - * #### Main App-Frame #### - */ - // browse XML-File with filechooser - if( e.getSource() == VAJAntToolGUI.this.getBrowseButton() ) - { - getFileDialog().setDirectory( getBuildFileTextField().getText().substring( 0, getBuildFileTextField().getText().lastIndexOf( '\\' ) + 1 ) ); - getFileDialog().setFile( "*.xml" ); - getFileDialog().show(); - if( !getFileDialog().getFile().equals( "" ) ) - { - getBuildFileTextField().setText( getFileDialog().getDirectory() + getFileDialog().getFile() ); - } - } - // dispose and exit application - if( e.getSource() == VAJAntToolGUI.this.getCloseButton() ) - { - dispose(); - System.exit( 0 ); - } - // start build-process - if( e.getSource() == VAJAntToolGUI.this.getBuildButton() ) - { - executeTarget(); - } - if( e.getSource() == VAJAntToolGUI.this.getStopButton() ) - { - getBuildInfo().cancelBuild(); - } - if( e.getSource() == VAJAntToolGUI.this.getReloadButton() ) - { - try - { - getBuildInfo().updateTargetList(); - fillList(); - } - catch( Throwable fileNotFound ) - { - handleException( fileNotFound ); - getTargetList().removeAll(); - getBuildButton().setEnabled( false ); - } - } - // MenuItems - if( e.getSource() == VAJAntToolGUI.this.getSaveMenuItem() ) - { - saveBuildInfo(); - } - if( e.getSource() == VAJAntToolGUI.this.getAboutMenuItem() ) - { - getAboutDialog().show(); - } - if( e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem() ) - { - getMessageFrame().show(); - } - /* - * #### About dialog #### - */ - if( e.getSource() == VAJAntToolGUI.this.getAboutOkButton() ) - { - getAboutDialog().dispose(); - } - /* - * #### Log frame #### - */ - if( e.getSource() == VAJAntToolGUI.this.getMessageOkButton() ) - { - getMessageFrame().dispose(); - } - if( e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton() ) - { - getMessageTextArea().setText( "" ); - } - if( e.getSource() == VAJAntToolGUI.this.getMessageOkButton() ) - { - getMessageFrame().dispose(); - } - } - catch( Throwable exc ) - { - handleException( exc ); - } - } - - /** - * ItemListener method - * - * @param e Description of Parameter - */ - public void itemStateChanged( ItemEvent e ) - { - try - { - if( e.getSource() == VAJAntToolGUI.this.getTargetList() ) - { - getBuildButton().setEnabled( true ); - } - if( e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice() ) - { - getBuildInfo().setOutputMessageLevel( getMessageOutputLevelChoice().getSelectedIndex() ); - } - if( e.getSource() == VAJAntToolGUI.this.getTargetList() ) - { - getBuildInfo().setTarget( getTargetList().getSelectedItem() ); - } - } - catch( Throwable exc ) - { - handleException( exc ); - } - } - - /** - * PropertyChangeListener method - * - * @param evt Description of Parameter - */ - public void propertyChange( java.beans.PropertyChangeEvent evt ) - { - if( evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && ( evt.getPropertyName().equals( "projectName" ) ) ) - { - connectProjectNameToLabel(); - } - if( evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && ( evt.getPropertyName().equals( "buildFileName" ) ) ) - { - connectBuildFileNameToTextField(); - } - } - - /** - * TextListener method - * - * @param e Description of Parameter - */ - public void textValueChanged( TextEvent e ) - { - if( e.getSource() == VAJAntToolGUI.this.getBuildFileTextField() ) - { - connectTextFieldToBuildFileName(); - } - } - - public void windowActivated( WindowEvent e ) - { - } - - public void windowClosed( WindowEvent e ) - { - } - - /** - * WindowListener methods - * - * @param e Description of Parameter - */ - public void windowClosing( WindowEvent e ) - { - try - { - if( e.getSource() == VAJAntToolGUI.this ) - { - dispose(); - System.exit( 0 ); - } - if( e.getSource() == VAJAntToolGUI.this.getAboutDialog() ) - { - getAboutDialog().dispose(); - } - if( e.getSource() == VAJAntToolGUI.this.getMessageFrame() ) - { - getMessageFrame().dispose(); - } - } - catch( Throwable exc ) - { - handleException( exc ); - } - } - - public void windowDeactivated( WindowEvent e ) - { - } - - public void windowDeiconified( WindowEvent e ) - { - } - - public void windowIconified( WindowEvent e ) - { - } - - public void windowOpened( WindowEvent e ) - { - } - } - - /** - * This internal BuildLogger, to be honest, is just a BuildListener. It does - * nearly the same as the DefaultLogger, but uses the Loggin-Window for - * output. - * - * @author RT - */ - private class VAJBuildLogger implements BuildListener - { - private long startTime = System.currentTimeMillis(); - - /** - * VAJBuildLogger constructor comment. - */ - public VAJBuildLogger() - { - super(); - } - - /** - * Fired after the last target has finished. This event will still be - * thrown if an error occured during the build. - * - * @param event Description of Parameter - * @see BuildEvent#getException() - */ - public void buildFinished( BuildEvent event ) - { - getStopButton().setEnabled( false ); - getBuildButton().setEnabled( true ); - getBuildButton().requestFocus(); - - Throwable error = event.getException(); - - if( error == null ) - { - getMessageTextArea().append( lineSeparator + "BUILD SUCCESSFUL" ); - } - else - { - logException( error ); - } - - getMessageTextArea().append( lineSeparator + "Total time: " + formatTime( System.currentTimeMillis() - startTime ) ); - } - - /** - * Fired before any targets are started. - * - * @param event Description of Parameter - */ - public void buildStarted( BuildEvent event ) - { - getStopButton().setEnabled( true ); - getBuildButton().setEnabled( false ); - getStopButton().requestFocus(); - - startTime = System.currentTimeMillis(); - getMessageTextArea().append( lineSeparator ); - } - - /** - * Outputs an exception. - * - * @param error Description of Parameter - */ - public void logException( Throwable error ) - { - getMessageTextArea().append( lineSeparator + "BUILD FAILED" + lineSeparator ); - - if( error instanceof TaskException ) - { - getMessageTextArea().append( error.toString() ); - - Throwable nested = ( (TaskException)error ).getCause(); - if( nested != null ) - { - nested.printStackTrace( System.err ); - } - } - else - { - error.printStackTrace( System.err ); - } - } - - /** - * Fired whenever a message is logged. - * - * @param event Description of Parameter - * @see BuildEvent#getMessage() - * @see BuildEvent#getPriority() - */ - public void messageLogged( BuildEvent event ) - { - if( event.getPriority() <= getBuildInfo().getOutputMessageLevel() ) - { - String msg = ""; - final String task = event.getTask(); - if( task != null ) - { - msg = "[" + task + "] "; - } - getMessageTextArea().append( lineSeparator + msg + event.getMessage() ); - } - } - - /** - * Fired when a target has finished. This event will still be thrown if - * an error occured during the build. - * - * @param event Description of Parameter - * @see BuildEvent#getException() - */ - public void targetFinished( BuildEvent event ) - { - } - - /** - * Fired when a target is started. - * - * @param event Description of Parameter - * @see BuildEvent#getTarget() - */ - public void targetStarted( BuildEvent event ) - { - if( getBuildInfo().getOutputMessageLevel() <= Project.MSG_INFO ) - { - getMessageTextArea().append( lineSeparator + event.getTarget() + ":" ); - } - } - - /** - * Fired when a task has finished. This event will still be throw if an - * error occured during the build. - * - * @param event Description of Parameter - * @see BuildEvent#getException() - */ - public void taskFinished( BuildEvent event ) - { - } - - /** - * Fired when a task is started. - * - * @param event Description of Parameter - * @see BuildEvent#getTask() - */ - public void taskStarted( BuildEvent event ) - { - } - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java deleted file mode 100644 index b3526dcc3..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.StringTokenizer; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.BuildEvent; -import org.apache.tools.ant.BuildListener; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Target; - -/** - * This class wraps the Ant project information needed to start Ant from Visual - * Age. It serves the following purposes: - acts as model for AntMakeFrame - - * converts itself to/from String (to store the information as ToolData in the - * VA repository) - wraps Project functions for the GUI (get target list, - * execute target) - manages a seperate thread for Ant project execution this - * allows interrupting a running build from a GUI - * - * @author Wolf Siberski, TUI Infotec GmbH - */ - -class VAJBuildInfo implements Runnable -{ - - // name of the VA project this BuildInfo belongs to - private String vajProjectName = ""; - - // name of the Ant build file - private String buildFileName = ""; - - // main targets found in the build file - private ArrayList projectTargets = new ArrayList(); - - // target selected for execution - private java.lang.String target = ""; - - // log level - private int outputMessageLevel = Project.MSG_INFO; - - // is true if Project initialization was successful - private transient boolean projectInitialized = false; - - // Support for bound properties - protected transient PropertyChangeSupport propertyChange; - - // thread for Ant build execution - private Thread buildThread; - - // Ant Project created from build file - private transient Project project; - - // the listener used to log output. - private BuildListener projectLogger; - - /** - * Creates a BuildInfo object from a String The String must be in the format - * outputMessageLevel'|'buildFileName'|'defaultTarget'|'(project target'|')* - * - * @param data java.lang.String - * @return org.apache.tools.ant.taskdefs.optional.vaj.BuildInfo - */ - public static VAJBuildInfo parse( String data ) - { - VAJBuildInfo result = new VAJBuildInfo(); - - try - { - StringTokenizer tok = new StringTokenizer( data, "|" ); - result.setOutputMessageLevel( tok.nextToken() ); - result.setBuildFileName( tok.nextToken() ); - result.setTarget( tok.nextToken() ); - while( tok.hasMoreTokens() ) - { - result.projectTargets.add( tok.nextToken() ); - } - } - catch( Throwable t ) - { - // if parsing the info fails, just return - // an empty VAJBuildInfo - } - return result; - } - - /** - * Search for the insert position to keep names a sorted list of Strings - * This method has been copied from org.apache.tools.ant.Main - * - * @param names Description of Parameter - * @param name Description of Parameter - * @return Description of the Returned Value - */ - private static int findTargetPosition( ArrayList names, String name ) - { - int res = names.size(); - for( int i = 0; i < names.size() && res == names.size(); i++ ) - { - if( name.compareTo( (String)names.get( i ) ) < 0 ) - { - res = i; - } - } - return res; - } - - /** - * Sets the build file name - * - * @param newBuildFileName The new BuildFileName value - */ - public void setBuildFileName( String newBuildFileName ) - { - String oldValue = buildFileName; - buildFileName = newBuildFileName; - setProjectInitialized( false ); - firePropertyChange( "buildFileName", oldValue, buildFileName ); - } - - /** - * Sets the log level (value must be one of the constants in Project) - * - * @param newOutputMessageLevel The new OutputMessageLevel value - */ - public void setOutputMessageLevel( int newOutputMessageLevel ) - { - int oldValue = outputMessageLevel; - outputMessageLevel = newOutputMessageLevel; - firePropertyChange( "outputMessageLevel", - new Integer( oldValue ), new Integer( outputMessageLevel ) ); - } - - /** - * Sets the target to execute when executeBuild is called - * - * @param newTarget build target - */ - public void setTarget( String newTarget ) - { - String oldValue = target; - target = newTarget; - firePropertyChange( "target", oldValue, target ); - } - - /** - * Sets the name of the Visual Age for Java project where this BuildInfo - * belongs to - * - * @param newVAJProjectName The new VAJProjectName value - */ - public void setVAJProjectName( String newVAJProjectName ) - { - String oldValue = vajProjectName; - vajProjectName = newVAJProjectName; - firePropertyChange( "VAJProjectName", oldValue, vajProjectName ); - } - - /** - * Returns the build file name. - * - * @return build file name. - */ - public String getBuildFileName() - { - return buildFileName; - } - - /** - * Returns the log level - * - * @return log level. - */ - public int getOutputMessageLevel() - { - return outputMessageLevel; - } - - /** - * return a list of all targets in the current buildfile - * - * @return The ProjectTargets value - */ - public ArrayList getProjectTargets() - { - return projectTargets; - } - - /** - * returns the selected target. - * - * @return The Target value - */ - public java.lang.String getTarget() - { - return target; - } - - /** - * returns the VA project name - * - * @return The VAJProjectName value - */ - public String getVAJProjectName() - { - return vajProjectName; - } - - /** - * Returns true, if the Ant project is initialized (i.e. buildfile loaded) - * - * @return The ProjectInitialized value - */ - public boolean isProjectInitialized() - { - return projectInitialized; - } - - /** - * The addPropertyChangeListener method was generated to support the - * propertyChange field. - * - * @param listener The feature to be added to the PropertyChangeListener - * attribute - */ - public synchronized void addPropertyChangeListener( PropertyChangeListener listener ) - { - getPropertyChange().addPropertyChangeListener( listener ); - } - - /** - * Returns the BuildInfo information as String. The BuildInfo can be rebuilt - * from that String by calling parse(). - * - * @return java.lang.String - */ - public String asDataString() - { - String result = getOutputMessageLevel() + "|" + getBuildFileName() - + "|" + getTarget(); - for( Iterator e = getProjectTargets().iterator(); - e.hasNext(); ) - { - result = result + "|" + e.next(); - } - - return result; - } - - /** - * cancels a build. - */ - public void cancelBuild() - { - buildThread.interrupt(); - } - - /** - * Executes the target set by setTarget(). - * - * @param logger Description of Parameter - */ - public void executeProject( BuildListener logger ) - { - Throwable error; - projectLogger = logger; - try - { - buildThread = new Thread( this ); - buildThread.setPriority( Thread.MIN_PRIORITY ); - buildThread.start(); - } - catch( RuntimeException exc ) - { - error = exc; - throw exc; - } - catch( Error err ) - { - error = err; - throw err; - } - } - - /** - * The firePropertyChange method was generated to support the propertyChange - * field. - * - * @param propertyName Description of Parameter - * @param oldValue Description of Parameter - * @param newValue Description of Parameter - */ - public void firePropertyChange( java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue ) - { - getPropertyChange().firePropertyChange( propertyName, oldValue, newValue ); - } - - /** - * The removePropertyChangeListener method was generated to support the - * propertyChange field. - * - * @param listener Description of Parameter - */ - public synchronized void removePropertyChangeListener( PropertyChangeListener listener ) - { - getPropertyChange().removePropertyChangeListener( listener ); - } - - /** - * Executes a build. This method is executed by the Ant execution thread - */ - public void run() - { - try - { - InterruptedChecker ic = new InterruptedChecker( projectLogger ); - BuildEvent e = new BuildEvent( getProject() ); - try - { - ic.buildStarted( e ); - - if( !isProjectInitialized() ) - { - initProject(); - } - - project.addBuildListener( ic ); - project.executeTarget( target ); - - ic.buildFinished( e ); - } - catch( Throwable t ) - { - e.setException( t ); - ic.buildFinished( e ); - } - finally - { - project.removeBuildListener( ic ); - } - } - catch( Throwable t2 ) - { - System.out.println( "unexpected exception!" ); - t2.printStackTrace(); - } - } - - /** - * reloads the build file and updates the target list - */ - public void updateTargetList() - { - project = new Project(); - initProject(); - projectTargets.clear(); - Iterator ptargets = project.getTargets().iterator(); - while( ptargets.hasNext() ) - { - Target currentTarget = (Target)ptargets.next(); - if( currentTarget.getDescription() != null ) - { - String targetName = currentTarget.getName(); - int pos = findTargetPosition( projectTargets, targetName ); - projectTargets.insertElementAt( targetName, pos ); - } - } - } - - /** - * Accessor for the propertyChange field. - * - * @return The PropertyChange value - */ - protected PropertyChangeSupport getPropertyChange() - { - if( propertyChange == null ) - { - propertyChange = new PropertyChangeSupport( this ); - } - return propertyChange; - } - - /** - * Sets the log level (value must be one of the constants in Project) - * - * @param outputMessageLevel log level as String. - */ - private void setOutputMessageLevel( String outputMessageLevel ) - { - int level = Integer.parseInt( outputMessageLevel ); - setOutputMessageLevel( level ); - } - - /** - * sets the initialized flag - * - * @param initialized The new ProjectInitialized value - */ - private void setProjectInitialized( boolean initialized ) - { - Boolean oldValue = new Boolean( projectInitialized ); - projectInitialized = initialized; - firePropertyChange( "projectInitialized", oldValue, new Boolean( projectInitialized ) ); - } - - /** - * Returns the Ant project - * - * @return org.apache.tools.ant.Project - */ - private Project getProject() - { - if( project == null ) - { - project = new Project(); - } - return project; - } - - /** - * Initializes the Ant project. Assumes that the project attribute is - * already set. - */ - private void initProject() - { - try - { - project.init(); - File buildFile = new File( getBuildFileName() ); - project.setUserProperty( "ant.file", buildFile.getAbsolutePath() ); - - //FIXME: Need to convert to Myrmidon style - //ProjectHelper.configureProject( project, buildFile ); - setProjectInitialized( true ); - } - catch( RuntimeException exc ) - { - setProjectInitialized( false ); - throw exc; - } - catch( Error err ) - { - setProjectInitialized( false ); - throw err; - } - } - - /** - * This exception is thrown when a build is interrupted - * - * @author RT - */ - public static class BuildInterruptedException extends TaskException - { - public String toString() - { - return "BUILD INTERRUPTED"; - } - } - - /** - * BuildListener which checks for interruption and throws Exception if build - * process is interrupted. This class is a wrapper around a 'real' listener. - * - * @author RT - */ - private class InterruptedChecker implements BuildListener - { - // the real listener - BuildListener wrappedListener; - - /** - * Can only be constructed as wrapper around a real listener - * - * @param listener the real listener - */ - public InterruptedChecker( BuildListener listener ) - { - super(); - wrappedListener = listener; - } - - /** - * Fired after the last target has finished. This event will still be - * thrown if an error occured during the build. - * - * @param event Description of Parameter - */ - public void buildFinished( BuildEvent event ) - { - wrappedListener.buildFinished( event ); - checkInterrupted(); - } - - /** - * Fired before any targets are started. - * - * @param event Description of Parameter - */ - public void buildStarted( BuildEvent event ) - { - wrappedListener.buildStarted( event ); - checkInterrupted(); - } - - /** - * Fired whenever a message is logged. - * - * @param event Description of Parameter - */ - public void messageLogged( BuildEvent event ) - { - wrappedListener.messageLogged( event ); - checkInterrupted(); - } - - /** - * Fired when a target has finished. This event will still be thrown if - * an error occured during the build. - * - * @param event Description of Parameter - */ - public void targetFinished( BuildEvent event ) - { - wrappedListener.targetFinished( event ); - checkInterrupted(); - } - - /** - * Fired when a target is started. - * - * @param event Description of Parameter - */ - public void targetStarted( BuildEvent event ) - { - wrappedListener.targetStarted( event ); - checkInterrupted(); - } - - /** - * Fired when a task has finished. This event will still be throw if an - * error occured during the build. - * - * @param event Description of Parameter - */ - public void taskFinished( BuildEvent event ) - { - wrappedListener.taskFinished( event ); - checkInterrupted(); - } - - /** - * Fired when a task is started. - * - * @param event Description of Parameter - */ - public void taskStarted( BuildEvent event ) - { - wrappedListener.taskStarted( event ); - checkInterrupted(); - } - - /** - * checks if the thread was interrupted. When an interrupt occured, - * throw an Exception to stop the execution. - */ - protected void checkInterrupted() - { - if( buildThread.isInterrupted() ) - { - throw new BuildInterruptedException(); - } - } - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java deleted file mode 100644 index e9592a5c4..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.File; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.Pattern; -import org.apache.myrmidon.framework.PatternSet; -import org.apache.myrmidon.framework.PatternUtil; - -/** - * Export packages from the Visual Age for Java workspace. The packages are - * specified similar to all other MatchingTasks. Since the VA Workspace is not - * file based, this task is simulating a directory hierarchy for the workspace: - * The 'root' contains all project 'dir's, and the projects contain their - * respective package 'dir's. Example:

<vajexport - * destdir="C:/builddir/source">  <include - * name="/MyVAProject/org/foo/subsystem1/**" />  <exclude - * name="/MyVAProject/org/foo/subsystem1/test/**"/> </vajexport> - *
exports all packages in the project MyVAProject which start - * with 'org.foo.subsystem1' except of these starting with - * 'org.foo.subsystem1.test'. There are flags to choose which items to export: - * exportSources: export Java sources exportResources: export project resources - * exportClasses: export class files exportDebugInfo: export class files with - * debug info (use with exportClasses) default is exporting Java files and - * resources. - * - * @author Wolf Siberski, TUI Infotec GmbH - */ - -public class VAJExport extends VAJTask -{ - protected boolean exportSources = true; - protected boolean exportResources = true; - protected boolean exportClasses = false; - protected boolean exportDebugInfo = false; - protected boolean useDefaultExcludes = true; - protected boolean overwrite = true; - - protected PatternSet patternSet = new PatternSet(); - //set set... method comments for description - protected File destDir; - - /** - * Sets whether default exclusions should be used or not. - * - * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions - * should be used, "false"|"off"|"no" when they shouldn't be used. - */ - public void setDefaultexcludes( boolean useDefaultExcludes ) - { - this.useDefaultExcludes = useDefaultExcludes; - } - - /** - * Set the destination directory into which the selected items should be - * exported - * - * @param destDir The new Destdir value - */ - public void setDestdir( File destDir ) - { - this.destDir = destDir; - } - - /** - * Sets the set of exclude patterns. Patterns may be separated by a comma or - * a space. Currently only patterns denoting packages are supported - * - * @param excludes the string containing the exclude patterns - */ - public void setExcludes( String excludes ) - { - patternSet.setExcludes( excludes ); - } - - /** - * if exportClasses is set, class files are exported - * - * @param doExport The new ExportClasses value - */ - public void setExportClasses( boolean doExport ) - { - exportClasses = doExport; - } - - /** - * if exportDebugInfo is set, the exported class files contain debug info - * - * @param doExport The new ExportDebugInfo value - */ - public void setExportDebugInfo( boolean doExport ) - { - exportDebugInfo = doExport; - } - - /** - * if exportResources is set, resource file will be exported - * - * @param doExport The new ExportResources value - */ - public void setExportResources( boolean doExport ) - { - exportResources = doExport; - } - - /** - * if exportSources is set, java files will be exported - * - * @param doExport The new ExportSources value - */ - public void setExportSources( boolean doExport ) - { - exportSources = doExport; - } - - /** - * Sets the set of include patterns. Patterns may be separated by a comma or - * a space.Currently only patterns denoting packages are supported - * - * @param includes the string containing the include patterns - */ - public void setIncludes( String includes ) - { - patternSet.setIncludes( includes ); - } - - /** - * if Overwrite is set, files will be overwritten during export - * - * @param doOverwrite The new Overwrite value - */ - public void setOverwrite( boolean doOverwrite ) - { - overwrite = doOverwrite; - } - - /** - * add a name entry on the exclude list - * - * @return Description of the Returned Value - */ - public void addExclude( final Pattern pattern ) - { - patternSet.addExclude( pattern ); - } - - /** - * add a name entry on the include list - */ - public void addInclude( final Pattern pattern ) - { - patternSet.addInclude( pattern ); - } - - /** - * do the export - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - // first off, make sure that we've got a destdir - if( destDir == null ) - { - throw new TaskException( "destdir attribute must be set!" ); - } - - // delegate the export to the VAJUtil object. - final TaskContext context = getContext(); - final TaskContext context1 = getContext(); - getUtil().exportPackages( destDir, - PatternUtil.getIncludePatterns( patternSet, context ), - PatternUtil.getExcludePatterns( patternSet, context1 ), - exportClasses, exportDebugInfo, - exportResources, exportSources, - useDefaultExcludes, overwrite ); - } - -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java deleted file mode 100644 index 579453070..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.File; - -/** - * A Remote Access to Tools Servlet to extract package sets from the Workbench - * to the local file system. The following table describes the servlet - * parameters. - * - * - * - * - * - * Parameter - * - * - * - * Values - * - * - * - * Description - * - * - * - * - * - * - * - * dir - * - * - * - * Any valid directory name on the server. - * - * - * - * The directory to export the files to on the machine where the servlet - * is being run. If the directory doesn't exist, it will be created.

- * - * Relative paths are relative to IBMVJava/ide/tools/com-ibm-ivj-toolserver, - * where IBMVJava is the VisualAge for Java installation directory. - * - * - * - * - * - * - * - * include - * - * - * - * See below. - * - * - * - * The pattern used to indicate which projects and packages to export. - * - * - * - * - * - * - * - * - * exclude - * - * - * - * See below - * - * - * - * The pattern used to indicate which projects and packages not - * to export. - * - * - * - * - * - * - * - * cls - * - * - * - * "yes" or "no" (without the quotes) - * - * - * - * Export class files. Defaults to "no". - * - * - * - * - * - * - * - * src - * - * - * - * "yes" or "no" (without the quotes) - * - * - * - * Export source files. Defaults to "yes". - * - * - * - * - * - * - * - * res - * - * - * - * "yes" or "no" (without the quotes) - * - * - * - * Export resource files associated with the included project(s). Defaults - * to "yes". - * - * - * - * - * - * - * - * dex - * - * - * - * "yes" or "no" (without the quotes) - * - * - * - * Use the default exclusion patterns. Defaults to "yes". See below for an - * explanation of default excludes. - * - * - * - * - * - * - * - * owr - * - * - * - * "yes" or "no" (without the quotes) - * - * - * - * Overwrite any existing files. Defaults to "yes". - * - * - * - * - * - *

- * - * The vajexport servlet uses include and exclude parameters to form the - * criteria for selecting packages to export. The parameter is broken up into - * ProjectName/packageNameSegments, where ProjectName is what you expect, and - * packageNameSegments is a partial (or complete) package name, separated by - * forward slashes, rather than periods. Each packageNameSegment can have - * wildcard characters.

- * - * - * - * - * - * Wildcard Characters - * - * - * - * Description - * - * - * - * - * - * - * - * * - * - * - * - * Match zero or more characters in that segment. - * - * - * - * - * - * - * - * ? - * - * - * - * Match one character in that segment. - * - * - * - * - * - * - * - * ** - * - * - * - * Matches all characters in zero or more segments. - * - * - * - * - * - * - * - * @author Wolf Siberski, based on servlets written by Glenn McAllister - */ -public class VAJExportServlet extends VAJToolsServlet -{ - // constants for servlet param names - public final static String WITH_DEBUG_INFO = "deb"; - public final static String OVERWRITE_PARAM = "owr"; - - /** - * Respond to a request to export packages from the Workbench. - */ - protected void executeRequest() - { - getUtil().exportPackages( - new File( getFirstParamValueString( DIR_PARAM ) ), - getParamValues( INCLUDE_PARAM ), - getParamValues( EXCLUDE_PARAM ), - getBooleanParam( CLASSES_PARAM, false ), - getBooleanParam( WITH_DEBUG_INFO, false ), - getBooleanParam( RESOURCES_PARAM, true ), - getBooleanParam( SOURCES_PARAM, true ), - getBooleanParam( DEFAULT_EXCLUDES_PARAM, true ), - getBooleanParam( OVERWRITE_PARAM, true ) - ); - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java deleted file mode 100644 index 56c20bf3d..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Iterator; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.types.DirectoryScanner; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.types.ScannerUtil; - -/** - * Import source, class files, and resources to the Visual Age for Java - * workspace using FileSets.

- * - * Example:

- * <vajimport project="MyVAProject">
- *   <fileset dir="src">
- *     <include name="org/foo/subsystem1/**" />
- *     <exclude name="/org/foo/subsystem1/test/**" />
- *  </fileset>
- * </vajexport>
- * 
import all source and resource files from the "src" directory which - * start with 'org.foo.subsystem1', except of these starting with - * 'org.foo.subsystem1.test' into the project MyVAProject.

- * - * If MyVAProject isn't loaded into the Workspace, a new edition is created in - * the repository and automatically loaded into the Workspace. There has to be - * at least one nested FileSet element.

- * - * There are attributes to choose which items to export: - * - * - * - * - * - * Attribute - * - * - * - * Description - * - * - * - * Required - * - * - * - * - * - * - * - * project - * - * - * - * the name of the Project to import to - * - * - * - * Yes - * - * - * - * - * - * - * - * importSources - * - * - * - * import Java sources, defaults to "yes" - * - * - * - * No - * - * - * - * - * - * - * - * importResources - * - * - * - * import resource files (anything that doesn't end with .java or .class), - * defaults to "yes" - * - * - * - * No - * - * - * - * - * - * - * - * importClasses - * - * - * - * import class files, defaults to "no" - * - * - * - * No - * - * - * - * - * - * - * - * @author RT - * @author: Glenn McAllister, inspired by a similar task written by Peter Kelley - */ -public class VAJImport extends VAJTask -{ - protected ArrayList filesets = new ArrayList(); - protected boolean importSources = true; - protected boolean importResources = true; - protected boolean importClasses = false; - protected String importProject = null; - protected boolean useDefaultExcludes = true; - - /** - * Sets whether default exclusions should be used or not. - * - * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions - * should be used, "false"|"off"|"no" when they shouldn't be used. - */ - public void setDefaultexcludes( boolean useDefaultExcludes ) - { - this.useDefaultExcludes = useDefaultExcludes; - } - - /** - * Import .class files. - * - * @param importClasses The new ImportClasses value - */ - public void setImportClasses( boolean importClasses ) - { - this.importClasses = importClasses; - } - - /** - * Import resource files (anything that doesn't end in .class or .java) - * - * @param importResources The new ImportResources value - */ - public void setImportResources( boolean importResources ) - { - this.importResources = importResources; - } - - /** - * Import .java files - * - * @param importSources The new ImportSources value - */ - public void setImportSources( boolean importSources ) - { - this.importSources = importSources; - } - - /** - * The VisualAge for Java Project name to import into. - * - * @param projectName The new Project value - */ - public void setProject( String projectName ) - { - this.importProject = projectName; - } - - /** - * Adds a set of files (nested fileset attribute). - * - * @param set The feature to be added to the Fileset attribute - */ - public void addFileset( FileSet set ) - { - filesets.add( set ); - } - - /** - * Do the import. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - if( filesets.size() == 0 ) - { - throw new TaskException( "At least one fileset is required!" ); - } - - if( importProject == null || "".equals( importProject ) ) - { - throw new TaskException( "The VisualAge for Java Project name is required!" ); - } - - for( Iterator e = filesets.iterator(); e.hasNext(); ) - { - importFileset( (FileSet)e.next() ); - } - } - - /** - * Import all files from the fileset into the Project in the Workspace. - * - * @param fileset Description of Parameter - */ - protected void importFileset( FileSet fileset ) - { - DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fileset ); - if( ds.getIncludedFiles().length == 0 ) - { - return; - } - - String[] includes = null; - String[] excludes = null; - - // Hack to get includes and excludes. We could also use getIncludedFiles, - // but that would result in very long HTTP-requests. - // Therefore we want to send the patterns only to the remote tool server - // and let him figure out the files. - try - { - Class directoryScanner = ds.getClass(); - - Field includesField = directoryScanner.getDeclaredField( "includes" ); - includesField.setAccessible( true ); - includes = (String[])includesField.get( ds ); - - Field excludesField = directoryScanner.getDeclaredField( "excludes" ); - excludesField.setAccessible( true ); - excludes = (String[])excludesField.get( ds ); - } - catch( NoSuchFieldException nsfe ) - { - throw new TaskException( - "DirectoryScanner.includes or .excludes missing" + nsfe.getMessage() ); - } - catch( IllegalAccessException iae ) - { - throw new TaskException( - "Access to DirectoryScanner.includes or .excludes not allowed" ); - } - - getUtil().importFiles( importProject, ds.getBasedir(), - includes, excludes, - importClasses, importResources, importSources, - useDefaultExcludes ); - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java deleted file mode 100644 index 0e87e5ae1..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.File; - -/** - * A Remote Access to Tools Servlet to import a Project from files into the - * Repository. The following table describes the servlet parameters. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
- * Parameter - * - * Description - *
- * project - * - * The name of the project where you want the imported items to go. - *
- * dir - * - * The directory you want to import from. - *
- * - * - * @author Wolf Siberski, based on servlets written by Glenn McAllister - */ -public class VAJImportServlet extends VAJToolsServlet -{ - /** - * Respond to a request to import files to the Repository - */ - protected void executeRequest() - { - getUtil().importFiles( - getFirstParamValueString( PROJECT_NAME_PARAM ), - new File( getFirstParamValueString( DIR_PARAM ) ), - getParamValues( INCLUDE_PARAM ), - getParamValues( EXCLUDE_PARAM ), - getBooleanParam( CLASSES_PARAM, false ), - getBooleanParam( RESOURCES_PARAM, true ), - getBooleanParam( SOURCES_PARAM, true ), - false// no default excludes, because they - // are already added on client side - // getBooleanParam(DEFAULT_EXCLUDES_PARAM, true) - ); - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java deleted file mode 100644 index 055ddb02c..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.util.ArrayList; - -/** - * Load specific project versions into the Visual Age for Java workspace. Each - * project and version name has to be specified completely. Example: - *

<vajload>  <project name="MyVAProject" - * version="2.1"/>  <project name="Apache Xerces" version="1.2.0"/> - * </vajload>
- * - * @author Wolf Siberski, TUI Infotec GmbH - */ - -public class VAJLoad extends VAJTask -{ - ArrayList projectDescriptions = new ArrayList(); - - /** - * Add a project description entry on the project list. - * - * @return Description of the Returned Value - */ - public VAJProjectDescription createVAJProject() - { - VAJProjectDescription d = new VAJProjectDescription(); - projectDescriptions.add( d ); - return d; - } - - /** - * Load specified projects. - */ - public void execute() - { - getUtil().loadProjects( projectDescriptions ); - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java deleted file mode 100644 index 051a9f20a..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -/** - * This is only there for backward compatibility with the default task list and - * will be removed soon - * - * @author Wolf Siberski, TUI Infotec GmbH - */ - -public class VAJLoadProjects extends VAJLoad -{ -} - - - - - - diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java deleted file mode 100644 index ba1953df6..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.util.ArrayList; - -/** - * A Remote Access to Tools Servlet to load a Project from the Repository into - * the Workbench. The following table describes the servlet parameters. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
- * Parameter - * - * Description - *
- * project - * - * The name of the Project you want to load into the Workbench. - *
- * version - * - * The version of the package you want to load into the Workbench. - *
- * - * - * @author Wolf Siberski, based on servlets written by Glenn McAllister - */ -public class VAJLoadServlet extends VAJToolsServlet -{ - - // constants for servlet param names - public final static String VERSION_PARAM = "version"; - - /** - * Respond to a request to load a project from the Repository into the - * Workbench. - */ - protected void executeRequest() - { - String[] projectNames = getParamValues( PROJECT_NAME_PARAM ); - String[] versionNames = getParamValues( VERSION_PARAM ); - - ArrayList projectDescriptions = new ArrayList( projectNames.length ); - for( int i = 0; i < projectNames.length && i < versionNames.length; i++ ) - { - VAJProjectDescription desc = new VAJProjectDescription(); - desc.setName( projectNames[ i ] ); - desc.setVersion( versionNames[ i ] ); - projectDescriptions.add( desc ); - } - - util.loadProjects( projectDescriptions ); - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalToolUtil.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalToolUtil.java deleted file mode 100644 index 07322397a..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalToolUtil.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -/** - * Adaption of VAJLocalUtil to Task context. - */ -class VAJLocalToolUtil - extends VAJLocalUtil -{ - private VAJTask m_task; - - public VAJLocalToolUtil( final VAJTask task ) - { - m_task = task; - } - - public void log( final String msg, final int level ) - { - m_task.log( msg, level ); - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java deleted file mode 100644 index 02d25adb1..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import com.ibm.ivj.util.base.ExportCodeSpec; -import com.ibm.ivj.util.base.ImportCodeSpec; -import com.ibm.ivj.util.base.IvjException; -import com.ibm.ivj.util.base.Package; -import com.ibm.ivj.util.base.Project; -import com.ibm.ivj.util.base.ProjectEdition; -import com.ibm.ivj.util.base.ToolEnv; -import com.ibm.ivj.util.base.Type; -import com.ibm.ivj.util.base.Workspace; -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.types.DirectoryScanner; - -/** - * Helper class for VAJ tasks. Holds Workspace singleton and wraps IvjExceptions - * into TaskExceptions - * - * @author Wolf Siberski, TUI Infotec GmbH - */ -abstract class VAJLocalUtil - implements VAJUtil -{ - // singleton containing the VAJ workspace - private static Workspace workspace; - - /** - * get a project from the Workspace. - * - * @param importProject Description of Parameter - * @return The VAJProject value - */ - static Project getVAJProject( String importProject ) - { - Project found = null; - Project[] currentProjects = getWorkspace().getProjects(); - - for( int i = 0; i < currentProjects.length; i++ ) - { - Project p = currentProjects[ i ]; - if( p.getName().equals( importProject ) ) - { - found = p; - break; - } - } - - if( found == null ) - { - try - { - found = getWorkspace().createProject( importProject, true ); - } - catch( IvjException e ) - { - throw createTaskException( "Error while creating Project " - + importProject + ": ", e ); - } - } - - return found; - } - - /** - * returns the current VAJ workspace. - * - * @return com.ibm.ivj.util.base.Workspace - */ - static Workspace getWorkspace() - { - if( workspace == null ) - { - workspace = ToolEnv.connectToWorkspace(); - if( workspace == null ) - { - throw new TaskException( - "Unable to connect to Workspace! " - + "Make sure you are running in VisualAge for Java." ); - } - } - - return workspace; - } - - /** - * Wraps IvjException into a TaskException - * - * @param errMsg Additional error message - * @param e IvjException which is wrapped - * @return org.apache.tools.ant.TaskException - */ - static TaskException createTaskException( - String errMsg, IvjException e ) - { - errMsg = errMsg + "\n" + e.getMessage(); - String[] errors = e.getErrors(); - if( errors != null ) - { - for( int i = 0; i < errors.length; i++ ) - { - errMsg = errMsg + "\n" + errors[ i ]; - } - } - return new TaskException( errMsg, e ); - } - - - //----------------------------------------------------------- - // export - //----------------------------------------------------------- - - /** - * export packages - * - * @param dest Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param exportClasses Description of Parameter - * @param exportDebugInfo Description of Parameter - * @param exportResources Description of Parameter - * @param exportSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - * @param overwrite Description of Parameter - */ - public void exportPackages( - File dest, - String[] includePatterns, String[] excludePatterns, - boolean exportClasses, boolean exportDebugInfo, - boolean exportResources, boolean exportSources, - boolean useDefaultExcludes, boolean overwrite ) - { - if( includePatterns == null || includePatterns.length == 0 ) - { - log( "You must specify at least one include attribute. " - + "Not exporting", MSG_ERR ); - } - else - { - try - { - VAJWorkspaceScanner scanner = new VAJWorkspaceScanner(); - scanner.setIncludes( includePatterns ); - scanner.setExcludes( excludePatterns ); - if( useDefaultExcludes ) - { - scanner.addDefaultExcludes(); - } - scanner.scan(); - - Package[] packages = scanner.getIncludedPackages(); - - log( "Exporting " + packages.length + " package(s) to " - + dest, MSG_INFO ); - for( int i = 0; i < packages.length; i++ ) - { - getLogger().debug( " " + packages[ i ].getName() ); - } - - ExportCodeSpec exportSpec = new ExportCodeSpec(); - exportSpec.setPackages( packages ); - exportSpec.includeJava( exportSources ); - exportSpec.includeClass( exportClasses ); - exportSpec.includeResources( exportResources ); - exportSpec.includeClassDebugInfo( exportDebugInfo ); - exportSpec.useSubdirectories( true ); - exportSpec.overwriteFiles( overwrite ); - exportSpec.setExportDirectory( dest.getAbsolutePath() ); - - getWorkspace().exportData( exportSpec ); - } - catch( IvjException ex ) - { - throw createTaskException( "Exporting failed!", ex ); - } - } - } - - - //----------------------------------------------------------- - // import - //----------------------------------------------------------- - - - /** - * Do the import. - * - * @param importProject Description of Parameter - * @param srcDir Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param importClasses Description of Parameter - * @param importResources Description of Parameter - * @param importSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - * @exception TaskException Description of Exception - */ - public void importFiles( - String importProject, File srcDir, - String[] includePatterns, String[] excludePatterns, - boolean importClasses, boolean importResources, - boolean importSources, boolean useDefaultExcludes ) - throws TaskException - { - - if( importProject == null || "".equals( importProject ) ) - { - throw new TaskException( "The VisualAge for Java project " - + "name is required!" ); - } - - ImportCodeSpec importSpec = new ImportCodeSpec(); - importSpec.setDefaultProject( getVAJProject( importProject ) ); - - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir( srcDir ); - ds.setIncludes( includePatterns ); - ds.setExcludes( excludePatterns ); - if( useDefaultExcludes ) - { - ds.addDefaultExcludes(); - } - ds.scan(); - - ArrayList classes = new ArrayList(); - ArrayList sources = new ArrayList(); - ArrayList resources = new ArrayList(); - - scanForImport( srcDir, ds.getIncludedFiles(), classes, sources, resources ); - - StringBuffer summaryLog = new StringBuffer( "Importing " ); - addFilesToImport( importSpec, importClasses, classes, "Class", summaryLog ); - addFilesToImport( importSpec, importSources, sources, "Java", summaryLog ); - addFilesToImport( importSpec, importResources, resources, "Resource", summaryLog ); - importSpec.setResourcePath( srcDir.getAbsolutePath() ); - - summaryLog.append( " into the project '" ); - summaryLog.append( importProject ); - summaryLog.append( "'." ); - - getLogger().info( summaryLog.toString() ); - - try - { - Type[] importedTypes = getWorkspace().importData( importSpec ); - if( importedTypes == null ) - { - throw new TaskException( "Unable to import into Workspace!" ); - } - else - { - getLogger().debug( importedTypes.length + " types imported" ); - for( int i = 0; i < importedTypes.length; i++ ) - { - log( importedTypes[ i ].getPackage().getName() - + "." + importedTypes[ i ].getName() - + " into " + importedTypes[ i ].getProject().getName(), - MSG_DEBUG ); - } - } - } - catch( IvjException ivje ) - { - throw createTaskException( "Error while importing into workspace: ", - ivje ); - } - } - - - //----------------------------------------------------------- - // load - //----------------------------------------------------------- - - /** - * Load specified projects. - * - * @param projectDescriptions Description of Parameter - */ - public void loadProjects( ArrayList projectDescriptions ) - { - ArrayList expandedDescs = getExpandedDescriptions( projectDescriptions ); - - // output warnings for projects not found - for( Iterator e = projectDescriptions.iterator(); e.hasNext(); ) - { - VAJProjectDescription d = (VAJProjectDescription)e.next(); - if( !d.projectFound() ) - { - getLogger().warn( "No Projects match the name " + d.getName() ); - } - } - - log( "Loading " + expandedDescs.size() - + " project(s) into workspace", MSG_INFO ); - - for( Iterator e = expandedDescs.iterator(); - e.hasNext(); ) - { - VAJProjectDescription d = (VAJProjectDescription)e.next(); - - ProjectEdition pe = findProjectEdition( d.getName(), d.getVersion() ); - try - { - log( "Loading '" + d.getName() + "', Version '" + d.getVersion() - + "', into Workspace", MSG_VERBOSE ); - pe.loadIntoWorkspace(); - } - catch( IvjException ex ) - { - throw createTaskException( "Project '" + d.getName() - + "' could not be loaded.", ex ); - } - } - } - - /** - * return project descriptions containing full project names instead of - * patterns with wildcards. - * - * @param projectDescs Description of Parameter - * @return The ExpandedDescriptions value - */ - private ArrayList getExpandedDescriptions( ArrayList projectDescs ) - { - ArrayList expandedDescs = new ArrayList( projectDescs.size() ); - try - { - String[] projectNames = - getWorkspace().getRepository().getProjectNames(); - for( int i = 0; i < projectNames.length; i++ ) - { - for( Iterator e = projectDescs.iterator(); - e.hasNext(); ) - { - VAJProjectDescription d = (VAJProjectDescription)e.next(); - String pattern = d.getName(); - if( VAJWorkspaceScanner.match( pattern, projectNames[ i ] ) ) - { - d.setProjectFound(); - expandedDescs.add( new VAJProjectDescription( - projectNames[ i ], d.getVersion() ) ); - break; - } - } - } - } - catch( IvjException e ) - { - throw createTaskException( "VA Exception occured: ", e ); - } - - return expandedDescs; - } - - /** - * Adds files to an import specification. Helper method for importFiles() - * - * @param spec import specification - * @param doImport only add files if doImport is true - * @param files the files to add - * @param fileType type of files (Source/Class/Resource) - * @param summaryLog buffer for logging - */ - private void addFilesToImport( - ImportCodeSpec spec, boolean doImport, - ArrayList files, String fileType, - StringBuffer summaryLog ) - { - - if( doImport ) - { - String[] fileArr = new String[ files.size() ]; - files.copyInto( fileArr ); - try - { - // here it is assumed that fileType is one of the - // following strings: // "Java", "Class", "Resource" - String methodName = "set" + fileType + "Files"; - Class[] methodParams = new Class[]{fileArr.getClass()}; - java.lang.reflect.Method method = - spec.getClass().getDeclaredMethod( methodName, methodParams ); - method.invoke( spec, new Object[]{fileArr} ); - } - catch( Exception e ) - { - throw new TaskException( "Error", e ); - } - if( files.size() > 0 ) - { - logFiles( files, fileType ); - summaryLog.append( files.size() ); - summaryLog.append( " " + fileType.toLowerCase() + " file" ); - summaryLog.append( files.size() > 1 ? "s, " : ", " ); - } - } - } - - /** - * returns a list of project names matching the given pattern - * - * @param pattern Description of Parameter - * @return Description of the Returned Value - */ - private ArrayList findMatchingProjects( String pattern ) - { - String[] projectNames; - try - { - projectNames = getWorkspace().getRepository().getProjectNames(); - } - catch( IvjException e ) - { - throw createTaskException( "VA Exception occured: ", e ); - } - - ArrayList matchingProjects = new ArrayList(); - for( int i = 0; i < projectNames.length; i++ ) - { - if( VAJWorkspaceScanner.match( pattern, projectNames[ i ] ) ) - { - matchingProjects.add( projectNames[ i ] ); - } - } - - return matchingProjects; - } - - /** - * Finds a specific project edition in the repository. - * - * @param name project name - * @param versionName project version name - * @return com.ibm.ivj.util.base.ProjectEdition the specified edition - */ - private ProjectEdition findProjectEdition( - String name, String versionName ) - { - try - { - ProjectEdition[] editions = null; - editions = getWorkspace().getRepository().getProjectEditions( name ); - - if( editions == null ) - { - throw new TaskException( "Project " + name + " doesn't exist" ); - } - - ProjectEdition pe = null; - for( int i = 0; i < editions.length && pe == null; i++ ) - { - if( versionName.equals( editions[ i ].getVersionName() ) ) - { - pe = editions[ i ]; - } - } - if( pe == null ) - { - throw new TaskException( "Version " + versionName - + " of Project " + name + " doesn't exist" ); - } - return pe; - } - catch( IvjException e ) - { - throw createTaskException( "VA Exception occured: ", e ); - } - - } - - /** - * Logs a list of file names to the message log - * - * @param fileNames java.util.ArrayList file names to be logged - * @param fileType Description of Parameter - */ - private void logFiles( ArrayList fileNames, String fileType ) - { - getLogger().debug( fileType + " files found for import:" ); - for( Iterator e = fileNames.iterator(); e.hasNext(); ) - { - getLogger().debug( " " + e.next() ); - } - } - - /** - * Sort the files into classes, sources, and resources. - * - * @param dir Description of Parameter - * @param files Description of Parameter - * @param classes Description of Parameter - * @param sources Description of Parameter - * @param resources Description of Parameter - */ - private void scanForImport( - File dir, - String[] files, - ArrayList classes, - ArrayList sources, - ArrayList resources ) - { - for( int i = 0; i < files.length; i++ ) - { - String file = ( new File( dir, files[ i ] ) ).getAbsolutePath(); - if( file.endsWith( ".java" ) || file.endsWith( ".JAVA" ) ) - { - sources.add( file ); - } - else if( file.endsWith( ".class" ) || file.endsWith( ".CLASS" ) ) - { - classes.add( file ); - } - else - { - // for resources VA expects the path relative to the resource path - resources.add( files[ i ] ); - } - } - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java deleted file mode 100644 index 4e742dd43..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import org.apache.myrmidon.api.TaskException; - -/** - * Type class. Holds information about a project edition. - * - * @author RT - * @author: Wolf Siberski - */ -public class VAJProjectDescription -{ - private String name; - private boolean projectFound; - private String version; - - public VAJProjectDescription() - { - } - - public VAJProjectDescription( String n, String v ) - { - name = n; - version = v; - } - - public void setName( String newName ) - { - if( newName == null || newName.equals( "" ) ) - { - throw new TaskException( "name attribute must be set" ); - } - name = newName; - } - - public void setProjectFound() - { - projectFound = true; - } - - public void setVersion( String newVersion ) - { - if( newVersion == null || newVersion.equals( "" ) ) - { - throw new TaskException( "version attribute must be set" ); - } - version = newVersion; - } - - public String getName() - { - return name; - } - - public String getVersion() - { - return version; - } - - public boolean projectFound() - { - return projectFound; - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java deleted file mode 100644 index 709271293..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Task; - -/** - * Helper class for VAJ tasks. Holds Workspace singleton and wraps IvjExceptions - * into TaskExceptions - * - * @author Wolf Siberski, TUI Infotec GmbH - */ -class VAJRemoteUtil implements VAJUtil -{ - // calling task - Task caller; - - // VAJ remote tool server - String remoteServer; - - public VAJRemoteUtil( Task caller, String remote ) - { - this.caller = caller; - this.remoteServer = remote; - } - - /** - * export the array of Packages - * - * @param destDir Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param exportClasses Description of Parameter - * @param exportDebugInfo Description of Parameter - * @param exportResources Description of Parameter - * @param exportSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - * @param overwrite Description of Parameter - */ - public void exportPackages( File destDir, - String[] includePatterns, String[] excludePatterns, - boolean exportClasses, boolean exportDebugInfo, boolean exportResources, - boolean exportSources, boolean useDefaultExcludes, boolean overwrite ) - { - try - { - String request = "http://" + remoteServer + "/servlet/vajexport?" - + VAJExportServlet.WITH_DEBUG_INFO + "=" + exportDebugInfo + "&" - + VAJExportServlet.OVERWRITE_PARAM + "=" + overwrite + "&" - + assembleImportExportParams( destDir, - includePatterns, excludePatterns, - exportClasses, exportResources, - exportSources, useDefaultExcludes ); - sendRequest( request ); - } - catch( Exception ex ) - { - throw new TaskException( "Error", ex ); - } - } - - /** - * Do the import. - * - * @param importProject Description of Parameter - * @param srcDir Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param importClasses Description of Parameter - * @param importResources Description of Parameter - * @param importSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - */ - public void importFiles( - String importProject, File srcDir, - String[] includePatterns, String[] excludePatterns, - boolean importClasses, boolean importResources, - boolean importSources, boolean useDefaultExcludes ) - { - try - { - String request = "http://" + remoteServer + "/servlet/vajimport?" - + VAJImportServlet.PROJECT_NAME_PARAM + "=" - + importProject + "&" - + assembleImportExportParams( srcDir, - includePatterns, excludePatterns, - importClasses, importResources, - importSources, useDefaultExcludes ); - sendRequest( request ); - } - catch( Exception ex ) - { - throw new TaskException( "Error", ex ); - } - - } - - /** - * Load specified projects. - * - * @param projectDescriptions Description of Parameter - */ - public void loadProjects( ArrayList projectDescriptions ) - { - try - { - String request = "http://" + remoteServer + "/servlet/vajload?"; - String delimiter = ""; - for( Iterator e = projectDescriptions.iterator(); e.hasNext(); ) - { - VAJProjectDescription pd = (VAJProjectDescription)e.next(); - request = request - + delimiter + VAJLoadServlet.PROJECT_NAME_PARAM - + "=" + pd.getName().replace( ' ', '+' ) - + "&" + VAJLoadServlet.VERSION_PARAM - + "=" + pd.getVersion().replace( ' ', '+' ); - //the first param needs no delimiter, but all other - delimiter = "&"; - } - sendRequest( request ); - } - catch( Exception ex ) - { - throw new TaskException( "Error", ex ); - } - } - - /** - * logs a message. - * - * @param msg Description of Parameter - * @param level Description of Parameter - */ - public void log( String msg, int level ) - { - caller.log( msg, level ); - } - - /** - * Assemble string for parameters common for import and export Helper method - * to remove double code. - * - * @param dir Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param includeClasses Description of Parameter - * @param includeResources Description of Parameter - * @param includeSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - * @return Description of the Returned Value - */ - private String assembleImportExportParams( - File dir, - String[] includePatterns, String[] excludePatterns, - boolean includeClasses, boolean includeResources, - boolean includeSources, boolean useDefaultExcludes ) - { - String result = - VAJToolsServlet.DIR_PARAM + "=" - + dir.getAbsolutePath().replace( '\\', '/' ) + "&" - + VAJToolsServlet.CLASSES_PARAM + "=" + includeClasses + "&" - + VAJToolsServlet.RESOURCES_PARAM + "=" + includeResources + "&" - + VAJToolsServlet.SOURCES_PARAM + "=" + includeSources + "&" - + VAJToolsServlet.DEFAULT_EXCLUDES_PARAM + "=" + useDefaultExcludes; - - if( includePatterns != null ) - { - for( int i = 0; i < includePatterns.length; i++ ) - { - result = result + "&" + VAJExportServlet.INCLUDE_PARAM + "=" - + includePatterns[ i ].replace( ' ', '+' ).replace( '\\', '/' ); - } - } - if( excludePatterns != null ) - { - for( int i = 0; i < excludePatterns.length; i++ ) - { - result = result + "&" + VAJExportServlet.EXCLUDE_PARAM + "=" - + excludePatterns[ i ].replace( ' ', '+' ).replace( '\\', '/' ); - } - } - - return result; - } - - /** - * Sends a servlet request. - * - * @param request Description of Parameter - */ - private void sendRequest( String request ) - { - boolean requestFailed = false; - try - { - getLogger().debug( "Request: " + request ); - - //must be HTTP connection - URL requestUrl = new URL( request ); - HttpURLConnection connection = - (HttpURLConnection)requestUrl.openConnection(); - - InputStream is = null; - // retry three times - for( int i = 0; i < 3; i++ ) - { - try - { - is = connection.getInputStream(); - break; - } - catch( IOException ex ) - { - } - } - if( is == null ) - { - getLogger().error( "Can't get " + request ); - throw new TaskException( "Couldn't execute " + request ); - } - - // log the response - BufferedReader br = new BufferedReader( new InputStreamReader( is ) ); - String line = br.readLine(); - while( line != null ) - { - int level = MSG_ERR; - try - { - // the first char of each line contains the log level - level = Integer.parseInt( line.substring( 0, 1 ) ); - if( level == MSG_ERR ) - { - requestFailed = true; - } - } - catch( Exception e ) - { - getLogger().error( "Response line doesn't contain log level!" ); - } - log( line.substring( 2 ), level ); - line = br.readLine(); - } - - } - catch( IOException ex ) - { - getLogger().error( "Error sending tool request to VAJ" + ex ); - throw new TaskException( "Couldn't execute " + request ); - } - if( requestFailed ) - { - throw new TaskException( "VAJ tool request failed" ); - } - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java deleted file mode 100644 index 362ad0ef9..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -/** - * Super class for all VAJ tasks. Contains common attributes (remoteServer) and - * util methods - * - * @author: Wolf Siberski - */ - -import org.apache.tools.ant.Task; - -public class VAJTask extends Task -{ - - // server name / port of VAJ remote tool api server - protected String remoteServer = null; - - // holds the appropriate VAJUtil implementation - private VAJUtil util = null; - - /** - * Set remote server attribute - * - * @param remoteServer The new Remote value - */ - public void setRemote( String remoteServer ) - { - this.remoteServer = remoteServer; - } - - /** - * returns the VAJUtil implementation - * - * @return The Util value - */ - protected VAJUtil getUtil() - { - if( util == null ) - { - if( remoteServer == null ) - { - util = new VAJLocalToolUtil( this ); - } - else - { - util = new VAJRemoteUtil( this, remoteServer ); - } - } - return util; - } - -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java deleted file mode 100644 index 14f54541c..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.apache.avalon.framework.ExceptionUtil; -import org.apache.myrmidon.api.TaskException; - -/** - * Abstract base class to provide common services for the VAJ tool API servlets - * - * @author Wolf Siberski, based on servlets written by Glenn McAllister - */ -public abstract class VAJToolsServlet - extends HttpServlet -{ - // constants for servlet param names - public final static String DIR_PARAM = "dir"; - public final static String INCLUDE_PARAM = "include"; - public final static String EXCLUDE_PARAM = "exclude"; - public final static String CLASSES_PARAM = "cls"; - public final static String SOURCES_PARAM = "src"; - public final static String RESOURCES_PARAM = "res"; - public final static String DEFAULT_EXCLUDES_PARAM = "dex"; - public final static String PROJECT_NAME_PARAM = "project"; - - // current request - HttpServletRequest request; - - // response to current request - HttpServletResponse response; - - // implementation of VAJUtil used by the servlet - VAJUtil util; - - /** - * Respond to a HTTP request. This method initializes the servlet and - * handles errors. The real work is done in the abstract method - * executeRequest() - * - * @param req Description of Parameter - * @param res Description of Parameter - * @exception ServletException Description of Exception - * @exception IOException Description of Exception - */ - public void doGet( HttpServletRequest req, HttpServletResponse res ) - throws ServletException, IOException - { - try - { - response = res; - request = req; - initRequest(); - executeRequest(); - } - catch( TaskException e ) - { - util.getLogger().error( "Error occured: " + e.getMessage() ); - } - catch( Exception e ) - { - try - { - if( !( e instanceof TaskException ) ) - { - String trace = ExceptionUtil.printStackTrace( e ); - util.log( "Program error in " + this.getClass().getName() - + ":\n" + trace, VAJUtil.MSG_ERR ); - } - } - catch( Throwable t ) - { - t.printStackTrace(); - } - finally - { - if( !( e instanceof TaskException ) ) - { - throw new ServletException( e.getMessage() ); - } - } - } - } - - /** - * Get the boolean value of a parameter. - * - * @param param Description of Parameter - * @return The BooleanParam value - */ - protected boolean getBooleanParam( String param ) - { - return getBooleanParam( param, false ); - } - - /** - * Get the boolean value of a parameter, with a default value if the - * parameter hasn't been passed to the servlet. - * - * @param param Description of Parameter - * @param defaultValue Description of Parameter - * @return The BooleanParam value - */ - protected boolean getBooleanParam( String param, boolean defaultValue ) - { - String value = getFirstParamValueString( param ); - if( value != null ) - { - return toBoolean( value ); - } - else - { - return defaultValue; - } - } - - /** - * Returns the first encountered value for a parameter. - * - * @param param Description of Parameter - * @return The FirstParamValueString value - */ - protected String getFirstParamValueString( String param ) - { - String[] paramValuesArray = request.getParameterValues( param ); - if( paramValuesArray == null ) - { - return null; - } - return paramValuesArray[ 0 ]; - } - - /** - * Returns all values for a parameter. - * - * @param param Description of Parameter - * @return The ParamValues value - */ - protected String[] getParamValues( String param ) - { - return request.getParameterValues( param ); - } - - /** - * Execute the request by calling the appropriate VAJ tool API methods. This - * method must be implemented by the concrete servlets - */ - protected abstract void executeRequest(); - - /** - * initialize the servlet. - * - * @exception IOException Description of Exception - */ - protected void initRequest() - throws IOException - { - response.setContentType( "text/ascii" ); - if( util == null ) - { - util = new VAJLocalServletUtil(); - } - } - - /** - * A utility method to translate the strings "yes", "true", and "ok" to - * boolean true, and everything else to false. - * - * @param string Description of Parameter - * @return Description of the Returned Value - */ - protected boolean toBoolean( String string ) - { - String lower = string.toLowerCase(); - return ( lower.equals( "yes" ) || lower.equals( "true" ) || lower.equals( "ok" ) ); - } - - /** - * Get the VAJUtil implementation - * - * @return The Util value - */ - VAJUtil getUtil() - { - return util; - } - - /** - * Adaptation of VAJUtil for servlet context. - */ - class VAJLocalServletUtil - extends VAJLocalUtil - { - public void log( String msg, int level ) - { - try - { - if( msg != null ) - { - msg = msg.replace( '\r', ' ' ); - int i = 0; - while( i < msg.length() ) - { - int nlPos = msg.indexOf( '\n', i ); - if( nlPos == -1 ) - { - nlPos = msg.length(); - } - response.getWriter().println( Integer.toString( level ) - + " " + msg.substring( i, nlPos ) ); - i = nlPos + 1; - } - } - } - catch( IOException e ) - { - throw new TaskException( "logging failed. msg was: " - + e.getMessage() ); - } - } - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java deleted file mode 100644 index 510123375..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.File; -import java.util.ArrayList; - -/** - * Helper interface for VAJ tasks. Encapsulates the interface to the VAJ tool - * API. - * - * @author Wolf Siberski, TUI Infotec GmbH - */ -interface VAJUtil -{ - // log levels - public final static int MSG_DEBUG = 4; - public final static int MSG_ERR = 0; - public final static int MSG_INFO = 2; - public final static int MSG_VERBOSE = 3; - public final static int MSG_WARN = 1; - - /** - * export the array of Packages - * - * @param dest Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param exportClasses Description of Parameter - * @param exportDebugInfo Description of Parameter - * @param exportResources Description of Parameter - * @param exportSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - * @param overwrite Description of Parameter - */ - void exportPackages( - File dest, - String[] includePatterns, String[] excludePatterns, - boolean exportClasses, boolean exportDebugInfo, - boolean exportResources, boolean exportSources, - boolean useDefaultExcludes, boolean overwrite ); - - /** - * Do the import. - * - * @param importProject Description of Parameter - * @param srcDir Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param importClasses Description of Parameter - * @param importResources Description of Parameter - * @param importSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - */ - void importFiles( - String importProject, File srcDir, - String[] includePatterns, String[] excludePatterns, - boolean importClasses, boolean importResources, - boolean importSources, boolean useDefaultExcludes ); - - /** - * Load specified projects. - * - * @param projectDescriptions Description of Parameter - */ - void loadProjects( ArrayList projectDescriptions ); - - /** - * Logs a message with the specified log level. - * - * @param msg Description of Parameter - * @param level Description of Parameter - */ - void log( String msg, int level ); -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java deleted file mode 100644 index d429e467e..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import com.ibm.ivj.util.base.IvjException; -import com.ibm.ivj.util.base.Package; -import com.ibm.ivj.util.base.Project; -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.StringTokenizer; -import org.apache.tools.ant.types.DirectoryScanner; -import org.apache.tools.ant.types.ScannerUtil; - -/** - * Class for scanning a Visual Age for Java workspace for packages matching a - * certain criteria.

- * - * These criteria consist of a set of include and exclude patterns. With these - * patterns, you can select which packages you want to have included, and which - * packages you want to have excluded. You can add patterns to be excluded by - * default with the addDefaultExcludes method. The patters that are excluded by - * default include - *

- *

- * - * This class works like DirectoryScanner. - * - * @author Wolf Siberski, TUI Infotec (based on Arnout J. Kuipers - * DirectoryScanner) - * @see org.apache.tools.ant.DirectoryScanner - */ -class VAJWorkspaceScanner extends DirectoryScanner -{ - - // Patterns that should be excluded by default. - private final static String[] DEFAULTEXCLUDES = - { - "IBM*/**", - "Java class libraries/**", - "Sun class libraries*/**", - "JSP Page Compile Generated Code/**", - "VisualAge*/**", - }; - - // The packages that where found and matched at least - // one includes, and matched no excludes. - private ArrayList packagesIncluded = new ArrayList(); - - /** - * Matches a string against a pattern. The pattern contains two special - * characters: '*' which means zero or more characters, '?' which means one - * and only one character. - * - * @param pattern the (non-null) pattern to match against - * @param str the (non-null) string that must be matched against the pattern - * @return true when the string matches against the pattern, - * false otherwise. - */ - protected static boolean match( String pattern, String str ) - { - return ScannerUtil.match( pattern, str ); - } - - /** - * Get the names of the packages that matched at least one of the include - * patterns, and didn't match one of the exclude patterns. - * - * @return the matching packages - */ - public Package[] getIncludedPackages() - { - int count = packagesIncluded.size(); - Package[] packages = new Package[ count ]; - for( int i = 0; i < count; i++ ) - { - packages[ i ] = (Package)packagesIncluded.get( i ); - } - return packages; - } - - /** - * Adds the array with default exclusions to the current exclusions set. - */ - public void addDefaultExcludes() - { - int excludesLength = getExcludes() == null ? 0 : getExcludes().length; - String[] newExcludes; - newExcludes = new String[ excludesLength + DEFAULTEXCLUDES.length ]; - if( excludesLength > 0 ) - { - System.arraycopy( getExcludes(), 0, newExcludes, 0, excludesLength ); - } - for( int i = 0; i < DEFAULTEXCLUDES.length; i++ ) - { - newExcludes[ i + excludesLength ] = DEFAULTEXCLUDES[ i ]. - replace( '/', File.separatorChar ). - replace( '\\', File.separatorChar ); - } - setExcludes( newExcludes ); - } - - /** - * Finds all Projects specified in include patterns. - * - * @return the projects - */ - public ArrayList findMatchingProjects() - { - Project[] projects = VAJLocalUtil.getWorkspace().getProjects(); - - ArrayList matchingProjects = new ArrayList(); - - boolean allProjectsMatch = false; - for( int i = 0; i < projects.length; i++ ) - { - Project project = projects[ i ]; - for( int j = 0; j < getIncludes().length && !allProjectsMatch; j++ ) - { - StringTokenizer tok = - new StringTokenizer( getIncludes()[ j ], File.separator ); - String projectNamePattern = tok.nextToken(); - if( projectNamePattern.equals( "**" ) ) - { - // if an include pattern starts with '**', - // all projects match - allProjectsMatch = true; - } - else if( match( projectNamePattern, project.getName() ) ) - { - matchingProjects.add( project ); - break; - } - } - } - - if( allProjectsMatch ) - { - matchingProjects = new ArrayList(); - for( int i = 0; i < projects.length; i++ ) - { - matchingProjects.add( projects[ i ] ); - } - } - - return matchingProjects; - } - - /** - * Scans the workspace for packages that match at least one include pattern, - * and don't match any exclude patterns. - */ - public void scan() - { - if( getIncludes() == null ) - { - // No includes supplied, so set it to 'matches all' - setIncludes( new String[ 1 ] ); - getIncludes()[ 0 ] = "**"; - } - if( getExcludes() == null ) - { - setExcludes( new String[ 0 ] ); - } - - // only scan projects which are included in at least one include pattern - ArrayList matchingProjects = findMatchingProjects(); - for( Iterator e = matchingProjects.iterator(); e.hasNext(); ) - { - Project project = (Project)e.next(); - scanProject( project ); - } - } - - /** - * Scans a project for packages that match at least one include pattern, and - * don't match any exclude patterns. - * - * @param project Description of Parameter - */ - public void scanProject( Project project ) - { - try - { - Package[] packages = project.getPackages(); - if( packages != null ) - { - for( int i = 0; i < packages.length; i++ ) - { - Package item = packages[ i ]; - // replace '.' by file seperator because the patterns are - // using file seperator syntax (and we can use the match - // methods this way). - String name = - project.getName() - + File.separator - + item.getName().replace( '.', File.separatorChar ); - if( isIncluded( name ) && !isExcluded( name ) ) - { - packagesIncluded.add( item ); - } - } - } - } - catch( IvjException e ) - { - throw VAJLocalUtil.createTaskException( "VA Exception occured: ", e ); - } - } -} diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/default.ini b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/default.ini deleted file mode 100644 index 1ccb8944f..000000000 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ide/default.ini +++ /dev/null @@ -1,4 +0,0 @@ -Name=Ant -Version=0.1 -Help-Item=Ant Help,doc/VAJAntTool.html -Menu-Items=Ant Build,org.apache.tools.ant.taskdefs.optional.ide.VAJAntTool,-P; diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java deleted file mode 100644 index fbaddc07d..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import com.ibm.ivj.util.base.Project; -import com.ibm.ivj.util.base.ToolData; -import org.apache.myrmidon.api.TaskException; - -/** - * This class is the equivalent to org.apache.tools.ant.Main for the VAJ tool - * environment. It's main is called when the user selects Tools->Ant Build from - * the VAJ project menu. Additionally this class provides methods to save build - * info for a project in the repository and load it from the repository - * - * @author RT - * @author: Wolf Siberski - */ -public class VAJAntTool -{ - private final static String TOOL_DATA_KEY = "AntTool"; - - /** - * Loads the BuildInfo for the specified VAJ project from the tool data for - * this project. If there is no build info stored for that project, a new - * default BuildInfo is returned - * - * @param projectName String project name - * @return BuildInfo buildInfo build info for the specified project - */ - public static VAJBuildInfo loadBuildData( String projectName ) - { - VAJBuildInfo result = null; - try - { - Project project = - VAJLocalUtil.getWorkspace().loadedProjectNamed( projectName ); - if( project.testToolRepositoryData( TOOL_DATA_KEY ) ) - { - ToolData td = project.getToolRepositoryData( TOOL_DATA_KEY ); - String data = (String)td.getData(); - result = VAJBuildInfo.parse( data ); - } - else - { - result = new VAJBuildInfo(); - } - result.setVAJProjectName( projectName ); - } - catch( Throwable t ) - { - throw new TaskException( "BuildInfo for Project " - + projectName + " could not be loaded" + t ); - } - return result; - } - - /** - * Starts the application. - * - * @param args an array of command-line arguments. VAJ puts the VAJ project - * name into args[1] when starting the tool from the project context - * menu - */ - public static void main( java.lang.String[] args ) - { - try - { - VAJBuildInfo info; - if( args.length >= 2 && args[ 1 ] instanceof String ) - { - String projectName = (String)args[ 1 ]; - info = loadBuildData( projectName ); - } - else - { - info = new VAJBuildInfo(); - } - - VAJAntToolGUI mainFrame = new VAJAntToolGUI( info ); - mainFrame.show(); - } - catch( Throwable t ) - { - // if all error handling fails, output at least - // something on the console - t.printStackTrace(); - } - } - - /** - * Saves the BuildInfo for a project in the VAJ repository. - * - * @param info BuildInfo build info to save - */ - public static void saveBuildData( VAJBuildInfo info ) - { - String data = info.asDataString(); - try - { - ToolData td = new ToolData( TOOL_DATA_KEY, data ); - VAJLocalUtil.getWorkspace().loadedProjectNamed( - info.getVAJProjectName() ).setToolRepositoryData( td ); - } - catch( Throwable t ) - { - throw new TaskException( "BuildInfo for Project " - + info.getVAJProjectName() + " could not be saved", t ); - } - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java deleted file mode 100644 index 37e25c0f1..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java +++ /dev/null @@ -1,1852 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.awt.BorderLayout; -import java.awt.Button; -import java.awt.Choice; -import java.awt.Dialog; -import java.awt.FileDialog; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Frame; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.Label; -import java.awt.List; -import java.awt.Menu; -import java.awt.MenuBar; -import java.awt.MenuItem; -import java.awt.Panel; -import java.awt.SystemColor; -import java.awt.TextArea; -import java.awt.TextField; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.TextEvent; -import java.awt.event.TextListener; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.beans.PropertyChangeListener; -import java.util.ArrayList; -import org.apache.avalon.framework.ExceptionUtil; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.BuildEvent; -import org.apache.tools.ant.BuildListener; -import org.apache.tools.ant.Project; - -/** - * This is a simple grafical user interface to provide the information needed by - * ANT and to start the build-process within IBM VisualAge for Java.

- * - * I was using AWT to make it independent from the JDK-version. Please don't ask - * me for a Swing-version:I am very familiar with Swing and I really think that - * it's not necessary for such a simple gui!

- * - * It is completely developed in VAJ using the visual composition editor. About - * 90% of the code is generated by VAJ, but in fact I did a lot of - * code-beautification ;-).

- * - * - * - * @author RT - * @version 1.0 h - * @author: Christoph Wilhelms, TUI Infotec GmbH - */ -public class VAJAntToolGUI extends Frame -{ - private final static String lineSeparator = "\r\n"; - /** - * Members - */ - private VAJBuildLogger logger = new VAJBuildLogger(); - private PrivateEventHandler iEventHandler = new PrivateEventHandler(); - - /** - * Members of the main-window - */ - // main model - private VAJBuildInfo iBuildInfo = null; - // Menue - private MenuBar iAntMakeMenuBar = null; - private Menu iFileMenu = null; - private MenuItem iSaveMenuItem = null; - private MenuItem iMenuSeparator = null; - private MenuItem iShowLogMenuItem = null; - private Menu iHelpMenu = null; - private MenuItem iAboutMenuItem = null; - // Container - private Panel iContentsPane = null; - private Panel iOptionenPanel = null; - private Panel iCommandButtonPanel = null; - private FlowLayout iCommandButtonPanelFlowLayout = null; - // Project name - private Label iProjectLabel = null; - private Label iProjectText = null; - // XML-file - private Label iBuildFileLabel = null; - private TextField iBuildFileTextField = null; - private boolean iConnPtoP2Aligning = false; - private Button iBrowseButton = null; - private FileDialog iFileDialog = null; - // Options - private Choice iMessageOutputLevelChoice = null; - private Label iMessageOutputLevelLabel = null; - private Label iTargetLabel = null; - private List iTargetList = null; - // Command-buttons - private Button iBuildButton = null; - private Button iReloadButton = null; - private Button iCloseButton = null; - /** - * log-Window - */ - // Container - private Frame iMessageFrame = null; - private Panel iMessageCommandPanel = null; - private Panel iMessageContentPanel = null; - // Components - private TextArea iMessageTextArea = null; - private Button iMessageOkButton = null; - private Button iMessageClearLogButton = null; - /** - * About-dialog - */ - // Container - private Dialog iAboutDialog = null; - private Panel iAboutDialogContentPanel = null; - private Panel iAboutInfoPanel = null; - private Panel iAboutCommandPanel = null; - // Labels - private Label iAboutTitleLabel = null; - private Label iAboutDevLabel = null; - private Label iAboutContactLabel = null; - // Buttons - private Button iAboutOkButton = null; - - private Button iStopButton = null; - - /** - * AntMake constructor called by VAJAntTool integration. - * - * @param newBuildInfo Description of Parameter - */ - - public VAJAntToolGUI( VAJBuildInfo newBuildInfo ) - { - super(); - setBuildInfo( newBuildInfo ); - initialize(); - } - - /** - * AntMake default-constructor. - */ - private VAJAntToolGUI() - { - super(); - initialize(); - } - - /** - * This method is used to center dialogs. - * - * @param dialog Description of Parameter - */ - public static void centerDialog( Dialog dialog ) - { - dialog.setLocation( ( Toolkit.getDefaultToolkit().getScreenSize().width / 2 ) - ( dialog.getSize().width / 2 ), ( java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2 ) - ( dialog.getSize().height / 2 ) ); - } - - /** - * Copied from DefaultLogger to provide the same time-format. - * - * @param millis Description of Parameter - * @return Description of the Returned Value - */ - public static String formatTime( long millis ) - { - long seconds = millis / 1000; - long minutes = seconds / 60; - - if( minutes > 0 ) - { - return Long.toString( minutes ) + " minute" - + ( minutes == 1 ? " " : "s " ) - + Long.toString( seconds % 60 ) + " second" - + ( seconds % 60 == 1 ? "" : "s" ); - } - else - { - return Long.toString( seconds ) + " second" - + ( seconds % 60 == 1 ? "" : "s" ); - } - } - - /** - * Set the BuildInfo to a new value. - * - * @param newValue org.apache.tools.ant.taskdefs.optional.vaj.VAJBuildInfo - */ - private void setBuildInfo( VAJBuildInfo newValue ) - { - if( iBuildInfo != newValue ) - { - try - { - /* - * Stop listening for events from the current object - */ - if( iBuildInfo != null ) - { - iBuildInfo.removePropertyChangeListener( iEventHandler ); - } - iBuildInfo = newValue; - - /* - * Listen for events from the new object - */ - if( iBuildInfo != null ) - { - iBuildInfo.addPropertyChangeListener( iEventHandler ); - } - connectProjectNameToLabel(); - connectBuildFileNameToTextField(); - - // Select the log-level given by BuildInfo - getMessageOutputLevelChoice().select( iBuildInfo.getOutputMessageLevel() ); - fillList(); - // BuildInfo can conly be saved to a VAJ project if tool API is called via the projects context-menu - if( ( iBuildInfo.getVAJProjectName() == null ) || ( iBuildInfo.getVAJProjectName().equals( "" ) ) ) - { - getSaveMenuItem().setEnabled( false ); - } - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - } - - /** - * Return the AboutCommandPanel property value. - * - * @return java.awt.Panel - */ - private Panel getAboutCommandPanel() - { - if( iAboutCommandPanel == null ) - { - try - { - iAboutCommandPanel = new Panel(); - iAboutCommandPanel.setName( "AboutCommandPanel" ); - iAboutCommandPanel.setLayout( new java.awt.FlowLayout() ); - getAboutCommandPanel().add( getAboutOkButton(), getAboutOkButton().getName() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutCommandPanel; - } - - /** - * Return the AboutContactLabel property value. - * - * @return java.awt.Label - */ - private Label getAboutContactLabel() - { - if( iAboutContactLabel == null ) - { - try - { - iAboutContactLabel = new Label(); - iAboutContactLabel.setName( "AboutContactLabel" ); - iAboutContactLabel.setAlignment( java.awt.Label.CENTER ); - iAboutContactLabel.setText( "contact: wolf.siberski@tui.de or christoph.wilhelms@tui.de" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutContactLabel; - } - - /** - * Return the AboutDevLabel property value. - * - * @return java.awt.Label - */ - private Label getAboutDevLabel() - { - if( iAboutDevLabel == null ) - { - try - { - iAboutDevLabel = new Label(); - iAboutDevLabel.setName( "AboutDevLabel" ); - iAboutDevLabel.setAlignment( java.awt.Label.CENTER ); - iAboutDevLabel.setText( "developed by Wolf Siberski & Christoph Wilhelms" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutDevLabel; - } - - /** - * Return the AboutDialog property value. - * - * @return java.awt.Dialog - */ - private Dialog getAboutDialog() - { - if( iAboutDialog == null ) - { - try - { - iAboutDialog = new Dialog( this ); - iAboutDialog.setName( "AboutDialog" ); - iAboutDialog.setResizable( false ); - iAboutDialog.setLayout( new java.awt.BorderLayout() ); - iAboutDialog.setBounds( 550, 14, 383, 142 ); - iAboutDialog.setModal( true ); - iAboutDialog.setTitle( "About..." ); - getAboutDialog().add( getAboutDialogContentPanel(), "Center" ); - iAboutDialog.pack(); - centerDialog( iAboutDialog ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutDialog; - } - - /** - * Return the AboutDialogContentPanel property value. - * - * @return java.awt.Panel - */ - private Panel getAboutDialogContentPanel() - { - if( iAboutDialogContentPanel == null ) - { - try - { - iAboutDialogContentPanel = new Panel(); - iAboutDialogContentPanel.setName( "AboutDialogContentPanel" ); - iAboutDialogContentPanel.setLayout( new java.awt.BorderLayout() ); - getAboutDialogContentPanel().add( getAboutCommandPanel(), "South" ); - getAboutDialogContentPanel().add( getAboutInfoPanel(), "Center" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutDialogContentPanel; - } - - /** - * Return the AboutInfoPanel property value. - * - * @return java.awt.Panel - */ - private Panel getAboutInfoPanel() - { - if( iAboutInfoPanel == null ) - { - try - { - iAboutInfoPanel = new Panel(); - iAboutInfoPanel.setName( "AboutInfoPanel" ); - iAboutInfoPanel.setLayout( new GridBagLayout() ); - - GridBagConstraints constraintsAboutTitleLabel = new GridBagConstraints(); - constraintsAboutTitleLabel.gridx = 0; - constraintsAboutTitleLabel.gridy = 0; - constraintsAboutTitleLabel.fill = GridBagConstraints.HORIZONTAL; - constraintsAboutTitleLabel.weightx = 1.0; - constraintsAboutTitleLabel.weighty = 1.0; - constraintsAboutTitleLabel.insets = new Insets( 4, 0, 4, 0 ); - getAboutInfoPanel().add( getAboutTitleLabel(), constraintsAboutTitleLabel ); - - GridBagConstraints constraintsAboutDevLabel = new GridBagConstraints(); - constraintsAboutDevLabel.gridx = 0; - constraintsAboutDevLabel.gridy = 1; - constraintsAboutDevLabel.fill = GridBagConstraints.HORIZONTAL; - constraintsAboutDevLabel.weightx = 1.0; - constraintsAboutDevLabel.insets = new Insets( 4, 0, 0, 0 ); - getAboutInfoPanel().add( getAboutDevLabel(), constraintsAboutDevLabel ); - - GridBagConstraints constraintsAboutContactLabel = new GridBagConstraints(); - constraintsAboutContactLabel.gridx = 0; - constraintsAboutContactLabel.gridy = 2; - constraintsAboutContactLabel.fill = GridBagConstraints.HORIZONTAL; - constraintsAboutContactLabel.weightx = 1.0; - constraintsAboutContactLabel.insets = new Insets( 2, 0, 4, 0 ); - getAboutInfoPanel().add( getAboutContactLabel(), constraintsAboutContactLabel ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutInfoPanel; - } - - /** - * Return the AboutMenuItem property value. - * - * @return java.awt.MenuItem - */ - private MenuItem getAboutMenuItem() - { - if( iAboutMenuItem == null ) - { - try - { - iAboutMenuItem = new MenuItem(); - iAboutMenuItem.setLabel( "About..." ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutMenuItem; - } - - /** - * Return the AboutOkButton property value. - * - * @return java.awt.Button - */ - private Button getAboutOkButton() - { - if( iAboutOkButton == null ) - { - try - { - iAboutOkButton = new Button(); - iAboutOkButton.setName( "AboutOkButton" ); - iAboutOkButton.setLabel( "OK" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutOkButton; - } - - /** - * Return the AboutTitleLabel property value. - * - * @return java.awt.Label - */ - private Label getAboutTitleLabel() - { - if( iAboutTitleLabel == null ) - { - try - { - iAboutTitleLabel = new Label(); - iAboutTitleLabel.setName( "AboutTitleLabel" ); - iAboutTitleLabel.setFont( new Font( "Arial", 1, 12 ) ); - iAboutTitleLabel.setAlignment( Label.CENTER ); - iAboutTitleLabel.setText( "Ant VisualAge for Java Tool-Integration" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAboutTitleLabel; - } - - /** - * Return the AntMakeMenuBar property value. - * - * @return java.awt.MenuBar - */ - private MenuBar getAntMakeMenuBar() - { - if( iAntMakeMenuBar == null ) - { - try - { - iAntMakeMenuBar = new MenuBar(); - iAntMakeMenuBar.add( getFileMenu() ); - iAntMakeMenuBar.add( getHelpMenu() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iAntMakeMenuBar; - } - - /** - * Return the BrowseButton property value. - * - * @return Button - */ - private Button getBrowseButton() - { - if( iBrowseButton == null ) - { - try - { - iBrowseButton = new Button(); - iBrowseButton.setName( "BrowseButton" ); - iBrowseButton.setLabel( "..." ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iBrowseButton; - } - - /** - * Return the BuildButton property value. - * - * @return java.awt.Button - */ - private Button getBuildButton() - { - if( iBuildButton == null ) - { - try - { - iBuildButton = new Button(); - iBuildButton.setName( "BuildButton" ); - iBuildButton.setLabel( "Execute" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iBuildButton; - } - - /** - * Return the BuildFileLabel property value. - * - * @return java.awt.Label - */ - private Label getBuildFileLabel() - { - if( iBuildFileLabel == null ) - { - try - { - iBuildFileLabel = new Label(); - iBuildFileLabel.setName( "BuildFileLabel" ); - iBuildFileLabel.setText( "Ant-Buildfile:" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iBuildFileLabel; - } - - /** - * Return the BuildFileTextField property value. - * - * @return java.awt.TextField - */ - private TextField getBuildFileTextField() - { - if( iBuildFileTextField == null ) - { - try - { - iBuildFileTextField = new TextField(); - iBuildFileTextField.setName( "BuildFileTextField" ); - iBuildFileTextField.setBackground( SystemColor.textHighlightText ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iBuildFileTextField; - } - - /** - * Return the BuildInfo property value. - * - * @return org.apache.tools.ant.taskdefs.optional.ide.VAJBuildInfo - */ - private VAJBuildInfo getBuildInfo() - { - return iBuildInfo; - } - - /** - * Return the CloseButton property value. - * - * @return java.awt.Button - */ - private Button getCloseButton() - { - if( iCloseButton == null ) - { - try - { - iCloseButton = new Button(); - iCloseButton.setName( "CloseButton" ); - iCloseButton.setLabel( "Close" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iCloseButton; - } - - /** - * Return the CommandButtonPanel property value. - * - * @return java.awt.Panel - */ - private Panel getCommandButtonPanel() - { - if( iCommandButtonPanel == null ) - { - try - { - iCommandButtonPanel = new Panel(); - iCommandButtonPanel.setName( "CommandButtonPanel" ); - iCommandButtonPanel.setLayout( getCommandButtonPanelFlowLayout() ); - iCommandButtonPanel.setBackground( SystemColor.control ); - iCommandButtonPanel.add( getReloadButton() ); - iCommandButtonPanel.add( getBuildButton() ); - iCommandButtonPanel.add( getStopButton() ); - iCommandButtonPanel.add( getCloseButton() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iCommandButtonPanel; - } - - /** - * Return the CommandButtonPanelFlowLayout property value. - * - * @return java.awt.FlowLayout - */ - private FlowLayout getCommandButtonPanelFlowLayout() - { - FlowLayout iCommandButtonPanelFlowLayout = null; - try - { - /* - * Create part - */ - iCommandButtonPanelFlowLayout = new FlowLayout(); - iCommandButtonPanelFlowLayout.setAlignment( FlowLayout.RIGHT ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - ; - return iCommandButtonPanelFlowLayout; - } - - /** - * Return the ContentsPane property value. - * - * @return java.awt.Panel - */ - private Panel getContentsPane() - { - if( iContentsPane == null ) - { - try - { - iContentsPane = new Panel(); - iContentsPane.setName( "ContentsPane" ); - iContentsPane.setLayout( new BorderLayout() ); - getContentsPane().add( getCommandButtonPanel(), "South" ); - getContentsPane().add( getOptionenPanel(), "Center" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iContentsPane; - } - - /** - * Return the FileDialog property value. - * - * @return java.awt.FileDialog - */ - private FileDialog getFileDialog() - { - if( iFileDialog == null ) - { - try - { - iFileDialog = new FileDialog( this ); - iFileDialog.setName( "FileDialog" ); - iFileDialog.setLayout( null ); - centerDialog( iFileDialog ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iFileDialog; - } - - /** - * Return the FileMenu property value. - * - * @return java.awt.Menu - */ - private Menu getFileMenu() - { - if( iFileMenu == null ) - { - try - { - iFileMenu = new Menu(); - iFileMenu.setLabel( "File" ); - iFileMenu.add( getSaveMenuItem() ); - iFileMenu.add( getMenuSeparator() ); - iFileMenu.add( getShowLogMenuItem() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iFileMenu; - } - - /** - * Return the HelpMenu property value. - * - * @return java.awt.Menu - */ - private Menu getHelpMenu() - { - if( iHelpMenu == null ) - { - try - { - iHelpMenu = new Menu(); - iHelpMenu.setLabel( "Help" ); - iHelpMenu.add( getAboutMenuItem() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iHelpMenu; - } - - /** - * Return the MenuSeparator1 property value. - * - * @return java.awt.MenuItem - */ - private MenuItem getMenuSeparator() - { - if( iMenuSeparator == null ) - { - try - { - iMenuSeparator = new MenuItem(); - iMenuSeparator.setLabel( "-" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMenuSeparator; - } - - /** - * Return the MessageClearLogButton property value. - * - * @return java.awt.Button - */ - private Button getMessageClearLogButton() - { - if( iMessageClearLogButton == null ) - { - try - { - iMessageClearLogButton = new Button(); - iMessageClearLogButton.setName( "MessageClearLogButton" ); - iMessageClearLogButton.setLabel( "Clear Log" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageClearLogButton; - } - - /** - * Return the MessageCommandPanel property value. - * - * @return java.awt.Panel - */ - private Panel getMessageCommandPanel() - { - if( iMessageCommandPanel == null ) - { - try - { - iMessageCommandPanel = new Panel(); - iMessageCommandPanel.setName( "MessageCommandPanel" ); - iMessageCommandPanel.setLayout( new FlowLayout() ); - getMessageCommandPanel().add( getMessageClearLogButton(), getMessageClearLogButton().getName() ); - getMessageCommandPanel().add( getMessageOkButton(), getMessageOkButton().getName() ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageCommandPanel; - } - - /** - * Return the MessageContentPanel property value. - * - * @return java.awt.Panel - */ - private Panel getMessageContentPanel() - { - if( iMessageContentPanel == null ) - { - try - { - iMessageContentPanel = new Panel(); - iMessageContentPanel.setName( "MessageContentPanel" ); - iMessageContentPanel.setLayout( new BorderLayout() ); - iMessageContentPanel.setBackground( SystemColor.control ); - getMessageContentPanel().add( getMessageTextArea(), "Center" ); - getMessageContentPanel().add( getMessageCommandPanel(), "South" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageContentPanel; - } - - /** - * Return the MessageFrame property value. - * - * @return java.awt.Frame - */ - private Frame getMessageFrame() - { - if( iMessageFrame == null ) - { - try - { - iMessageFrame = new Frame(); - iMessageFrame.setName( "MessageFrame" ); - iMessageFrame.setLayout( new BorderLayout() ); - iMessageFrame.setBounds( 0, 0, 750, 250 ); - iMessageFrame.setTitle( "Message Log" ); - iMessageFrame.add( getMessageContentPanel(), "Center" ); - iMessageFrame.setLocation( ( Toolkit.getDefaultToolkit().getScreenSize().width / 2 ) - ( iMessageFrame.getSize().width / 2 ), ( java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2 ) ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageFrame; - } - - /** - * Return the MessageOkButton property value. - * - * @return java.awt.Button - */ - private Button getMessageOkButton() - { - if( iMessageOkButton == null ) - { - try - { - iMessageOkButton = new Button(); - iMessageOkButton.setName( "MessageOkButton" ); - iMessageOkButton.setLabel( "Close" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageOkButton; - } - - /** - * Return the MessageOutputLevelChoice property value. - * - * @return java.awt.Choice - */ - private Choice getMessageOutputLevelChoice() - { - if( iMessageOutputLevelChoice == null ) - { - try - { - iMessageOutputLevelChoice = new Choice(); - iMessageOutputLevelChoice.setName( "MessageOutputLevelChoice" ); - iMessageOutputLevelChoice.add( "Error" ); - iMessageOutputLevelChoice.add( "Warning" ); - iMessageOutputLevelChoice.add( "Info" ); - iMessageOutputLevelChoice.add( "Verbose" ); - iMessageOutputLevelChoice.add( "Debug" ); - iMessageOutputLevelChoice.select( 2 ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageOutputLevelChoice; - } - - /** - * Return the MessageOutputLevelLabel property value. - * - * @return java.awt.Label - */ - private Label getMessageOutputLevelLabel() - { - if( iMessageOutputLevelLabel == null ) - { - try - { - iMessageOutputLevelLabel = new Label(); - iMessageOutputLevelLabel.setName( "MessageOutputLevelLabel" ); - iMessageOutputLevelLabel.setText( "Message Level:" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageOutputLevelLabel; - } - - /** - * Return the MessageTextArea property value. - * - * @return java.awt.TextArea - */ - private TextArea getMessageTextArea() - { - if( iMessageTextArea == null ) - { - try - { - iMessageTextArea = new TextArea(); - iMessageTextArea.setName( "MessageTextArea" ); - iMessageTextArea.setFont( new Font( "monospaced", 0, 12 ) ); - iMessageTextArea.setText( "" ); - iMessageTextArea.setEditable( false ); - iMessageTextArea.setEnabled( true ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iMessageTextArea; - } - - /** - * Return the Panel1 property value. - * - * @return java.awt.Panel - */ - private Panel getOptionenPanel() - { - if( iOptionenPanel == null ) - { - try - { - iOptionenPanel = new Panel(); - iOptionenPanel.setName( "OptionenPanel" ); - iOptionenPanel.setLayout( new GridBagLayout() ); - iOptionenPanel.setBackground( SystemColor.control ); - - GridBagConstraints constraintsProjectLabel = new GridBagConstraints(); - constraintsProjectLabel.gridx = 0; - constraintsProjectLabel.gridy = 0; - constraintsProjectLabel.anchor = GridBagConstraints.WEST; - constraintsProjectLabel.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getProjectLabel(), constraintsProjectLabel ); - - GridBagConstraints constraintsBuildFileLabel = new GridBagConstraints(); - constraintsBuildFileLabel.gridx = 0; - constraintsBuildFileLabel.gridy = 1; - constraintsBuildFileLabel.anchor = GridBagConstraints.WEST; - constraintsBuildFileLabel.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getBuildFileLabel(), constraintsBuildFileLabel ); - - GridBagConstraints constraintsTargetLabel = new GridBagConstraints(); - constraintsTargetLabel.gridx = 0; - constraintsTargetLabel.gridy = 2; - constraintsTargetLabel.anchor = GridBagConstraints.NORTHWEST; - constraintsTargetLabel.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getTargetLabel(), constraintsTargetLabel ); - - GridBagConstraints constraintsProjectText = new GridBagConstraints(); - constraintsProjectText.gridx = 1; - constraintsProjectText.gridy = 0; - constraintsProjectText.gridwidth = 2; - constraintsProjectText.fill = GridBagConstraints.HORIZONTAL; - constraintsProjectText.anchor = GridBagConstraints.WEST; - constraintsProjectText.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getProjectText(), constraintsProjectText ); - - GridBagConstraints constraintsBuildFileTextField = new GridBagConstraints(); - constraintsBuildFileTextField.gridx = 1; - constraintsBuildFileTextField.gridy = 1; - constraintsBuildFileTextField.fill = GridBagConstraints.HORIZONTAL; - constraintsBuildFileTextField.anchor = GridBagConstraints.WEST; - constraintsBuildFileTextField.weightx = 1.0; - constraintsBuildFileTextField.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getBuildFileTextField(), constraintsBuildFileTextField ); - - GridBagConstraints constraintsBrowseButton = new GridBagConstraints(); - constraintsBrowseButton.gridx = 2; - constraintsBrowseButton.gridy = 1; - constraintsBrowseButton.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getBrowseButton(), constraintsBrowseButton ); - - GridBagConstraints constraintsTargetList = new GridBagConstraints(); - constraintsTargetList.gridx = 1; - constraintsTargetList.gridy = 2; - constraintsTargetList.gridheight = 2; - constraintsTargetList.fill = GridBagConstraints.BOTH; - constraintsTargetList.weightx = 1.0; - constraintsTargetList.weighty = 1.0; - constraintsTargetList.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getTargetList(), constraintsTargetList ); - - GridBagConstraints constraintsMessageOutputLevelLabel = new GridBagConstraints(); - constraintsMessageOutputLevelLabel.gridx = 0; - constraintsMessageOutputLevelLabel.gridy = 4; - constraintsMessageOutputLevelLabel.anchor = GridBagConstraints.WEST; - constraintsMessageOutputLevelLabel.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getMessageOutputLevelLabel(), constraintsMessageOutputLevelLabel ); - - GridBagConstraints constraintsMessageOutputLevelChoice = new GridBagConstraints(); - constraintsMessageOutputLevelChoice.gridx = 1; - constraintsMessageOutputLevelChoice.gridy = 4; - constraintsMessageOutputLevelChoice.fill = GridBagConstraints.HORIZONTAL; - constraintsMessageOutputLevelChoice.anchor = GridBagConstraints.WEST; - constraintsMessageOutputLevelChoice.weightx = 1.0; - constraintsMessageOutputLevelChoice.insets = new Insets( 4, 4, 4, 4 ); - getOptionenPanel().add( getMessageOutputLevelChoice(), constraintsMessageOutputLevelChoice ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iOptionenPanel; - } - - /** - * Return the ProjectLabel property value. - * - * @return java.awt.Label - */ - private Label getProjectLabel() - { - if( iProjectLabel == null ) - { - try - { - iProjectLabel = new Label(); - iProjectLabel.setName( "ProjectLabel" ); - iProjectLabel.setText( "Projectname:" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iProjectLabel; - } - - /** - * Return the ProjectText property value. - * - * @return java.awt.Label - */ - private Label getProjectText() - { - if( iProjectText == null ) - { - try - { - iProjectText = new Label(); - iProjectText.setName( "ProjectText" ); - iProjectText.setText( " " ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iProjectText; - } - - /** - * Return the ReloadButton property value. - * - * @return java.awt.Button - */ - private Button getReloadButton() - { - if( iReloadButton == null ) - { - try - { - iReloadButton = new Button(); - iReloadButton.setName( "ReloadButton" ); - iReloadButton.setLabel( "(Re)Load" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iReloadButton; - } - - /** - * Return the SaveMenuItem property value. - * - * @return java.awt.MenuItem - */ - private MenuItem getSaveMenuItem() - { - if( iSaveMenuItem == null ) - { - try - { - iSaveMenuItem = new MenuItem(); - iSaveMenuItem.setLabel( "Save BuildInfo To Repository" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iSaveMenuItem; - } - - /** - * Return the ShowLogMenuItem property value. - * - * @return java.awt.MenuItem - */ - private MenuItem getShowLogMenuItem() - { - if( iShowLogMenuItem == null ) - { - try - { - iShowLogMenuItem = new MenuItem(); - iShowLogMenuItem.setLabel( "Log" ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iShowLogMenuItem; - } - - /** - * Return the StopButton property value. - * - * @return java.awt.Button - */ - private Button getStopButton() - { - if( iStopButton == null ) - { - try - { - iStopButton = new Button(); - iStopButton.setName( "StopButton" ); - iStopButton.setLabel( "Stop" ); - iStopButton.setEnabled( false ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iStopButton; - } - - /** - * Return the TargetLabel property value. - * - * @return java.awt.Label - */ - private Label getTargetLabel() - { - if( iTargetLabel == null ) - { - try - { - iTargetLabel = new Label(); - iTargetLabel.setName( "TargetLabel" ); - iTargetLabel.setText( "Target:" ); - iTargetLabel.setEnabled( true ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iTargetLabel; - } - - /** - * Return the TargetList property value. - * - * @return java.awt.List - */ - private List getTargetList() - { - if( iTargetList == null ) - { - try - { - iTargetList = new List(); - iTargetList.setName( "TargetList" ); - iTargetList.setEnabled( true ); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - return iTargetList; - } - - /** - * connectBuildFileNameToTextField: (BuildInfo.buildFileName <--> - * BuildFileTextField.text) - */ - private void connectBuildFileNameToTextField() - { - /* - * Set the target from the source - */ - try - { - if( iConnPtoP2Aligning == false ) - { - iConnPtoP2Aligning = true; - if( ( getBuildInfo() != null ) ) - { - getBuildFileTextField().setText( getBuildInfo().getBuildFileName() ); - } - iConnPtoP2Aligning = false; - } - } - catch( Throwable iExc ) - { - iConnPtoP2Aligning = false; - handleException( iExc ); - } - } - - /** - * connectProjectNameToLabel: (BuildInfo.vajProjectName <--> - * ProjectText.text) - */ - private void connectProjectNameToLabel() - { - /* - * Set the target from the source - */ - try - { - if( ( getBuildInfo() != null ) ) - { - getProjectText().setText( getBuildInfo().getVAJProjectName() ); - } - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - } - - /** - * connectTextFieldToBuildFileName: (BuildInfo.buildFileName <--> - * BuildFileTextField.text) - */ - private void connectTextFieldToBuildFileName() - { - /* - * Set the source from the target - */ - try - { - if( iConnPtoP2Aligning == false ) - { - iConnPtoP2Aligning = true; - if( ( getBuildInfo() != null ) ) - { - getBuildInfo().setBuildFileName( getBuildFileTextField().getText() ); - } - iConnPtoP2Aligning = false; - } - } - catch( Throwable iExc ) - { - iConnPtoP2Aligning = false; - handleException( iExc ); - } - } - - /** - * external build of a .jar-file - */ - private void executeTarget() - { - try - { - getMessageFrame().show(); - getBuildInfo().executeProject( logger ); - } - catch( Throwable exc ) - { - logger.logException( exc ); - } - return; - } - - /** - * Fills the taget-list with project-targets - */ - private void fillList() - { - getTargetList().removeAll(); - ArrayList targets = getBuildInfo().getProjectTargets(); - for( int i = 0; i < targets.size(); i++ ) - { - getTargetList().add( targets.get( i ).toString() ); - } - getTargetList().select( iBuildInfo.getProjectTargets().indexOf( iBuildInfo.getTarget() ) ); - if( getTargetList().getSelectedIndex() >= 0 ) - { - getBuildButton().setEnabled( true ); - } - } - - /** - * Called whenever the part throws an exception. - * - * @param exception Throwable - */ - private void handleException( Throwable exception ) - { - // Write exceptions to the log-window - String trace = ExceptionUtil.printStackTrace( exception ); - - getMessageTextArea().append( lineSeparator + lineSeparator + trace ); - getMessageFrame().show(); - - } - - /** - * Initializes connections - * - * @exception Exception The exception description. - */ - private void initConnections() - throws Exception - { - this.addWindowListener( iEventHandler ); - getBrowseButton().addActionListener( iEventHandler ); - getCloseButton().addActionListener( iEventHandler ); - getBuildButton().addActionListener( iEventHandler ); - getStopButton().addActionListener( iEventHandler ); - getSaveMenuItem().addActionListener( iEventHandler ); - getAboutOkButton().addActionListener( iEventHandler ); - getAboutMenuItem().addActionListener( iEventHandler ); - getMessageOkButton().addActionListener( iEventHandler ); - getMessageClearLogButton().addActionListener( iEventHandler ); - getMessageOkButton().addActionListener( iEventHandler ); - getShowLogMenuItem().addActionListener( iEventHandler ); - getAboutDialog().addWindowListener( iEventHandler ); - getMessageFrame().addWindowListener( iEventHandler ); - getReloadButton().addActionListener( iEventHandler ); - getTargetList().addItemListener( iEventHandler ); - getMessageOutputLevelChoice().addItemListener( iEventHandler ); - getBuildFileTextField().addTextListener( iEventHandler ); - connectProjectNameToLabel(); - connectBuildFileNameToTextField(); - } - - /** - * Initialize the class. - */ - private void initialize() - { - try - { - setName( "AntMake" ); - setMenuBar( getAntMakeMenuBar() ); - setLayout( new java.awt.BorderLayout() ); - setSize( 389, 222 ); - setTitle( "Ant VisualAge for Java Tool-Integration" ); - add( getContentsPane(), "Center" ); - initConnections(); - } - catch( Throwable iExc ) - { - handleException( iExc ); - } - setLocation( ( Toolkit.getDefaultToolkit().getScreenSize().width / 2 ) - ( getSize().width / 2 ), ( java.awt.Toolkit.getDefaultToolkit().getScreenSize().height / 2 ) - ( getSize().height ) ); - if( ( getTargetList().getItemCount() == 0 ) || ( getTargetList().getSelectedIndex() < 0 ) ) - { - getBuildButton().setEnabled( false ); - } - } - - /** - * Saves the build-informations to repository - */ - private void saveBuildInfo() - { - try - { - VAJAntTool.saveBuildData( getBuildInfo() ); - } - catch( Throwable exc ) - { - // This Exception occurs when you try to write into a versioned project - handleException( exc ); - } - return; - } - - /** - * Eventhandler to handle all AWT-events - * - * @author RT - */ - private class PrivateEventHandler implements ActionListener, ItemListener, TextListener, WindowListener, PropertyChangeListener - { - /** - * ActionListener method - * - * @param e Description of Parameter - */ - public void actionPerformed( ActionEvent e ) - { - try - { - /* - * #### Main App-Frame #### - */ - // browse XML-File with filechooser - if( e.getSource() == VAJAntToolGUI.this.getBrowseButton() ) - { - getFileDialog().setDirectory( getBuildFileTextField().getText().substring( 0, getBuildFileTextField().getText().lastIndexOf( '\\' ) + 1 ) ); - getFileDialog().setFile( "*.xml" ); - getFileDialog().show(); - if( !getFileDialog().getFile().equals( "" ) ) - { - getBuildFileTextField().setText( getFileDialog().getDirectory() + getFileDialog().getFile() ); - } - } - // dispose and exit application - if( e.getSource() == VAJAntToolGUI.this.getCloseButton() ) - { - dispose(); - System.exit( 0 ); - } - // start build-process - if( e.getSource() == VAJAntToolGUI.this.getBuildButton() ) - { - executeTarget(); - } - if( e.getSource() == VAJAntToolGUI.this.getStopButton() ) - { - getBuildInfo().cancelBuild(); - } - if( e.getSource() == VAJAntToolGUI.this.getReloadButton() ) - { - try - { - getBuildInfo().updateTargetList(); - fillList(); - } - catch( Throwable fileNotFound ) - { - handleException( fileNotFound ); - getTargetList().removeAll(); - getBuildButton().setEnabled( false ); - } - } - // MenuItems - if( e.getSource() == VAJAntToolGUI.this.getSaveMenuItem() ) - { - saveBuildInfo(); - } - if( e.getSource() == VAJAntToolGUI.this.getAboutMenuItem() ) - { - getAboutDialog().show(); - } - if( e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem() ) - { - getMessageFrame().show(); - } - /* - * #### About dialog #### - */ - if( e.getSource() == VAJAntToolGUI.this.getAboutOkButton() ) - { - getAboutDialog().dispose(); - } - /* - * #### Log frame #### - */ - if( e.getSource() == VAJAntToolGUI.this.getMessageOkButton() ) - { - getMessageFrame().dispose(); - } - if( e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton() ) - { - getMessageTextArea().setText( "" ); - } - if( e.getSource() == VAJAntToolGUI.this.getMessageOkButton() ) - { - getMessageFrame().dispose(); - } - } - catch( Throwable exc ) - { - handleException( exc ); - } - } - - /** - * ItemListener method - * - * @param e Description of Parameter - */ - public void itemStateChanged( ItemEvent e ) - { - try - { - if( e.getSource() == VAJAntToolGUI.this.getTargetList() ) - { - getBuildButton().setEnabled( true ); - } - if( e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice() ) - { - getBuildInfo().setOutputMessageLevel( getMessageOutputLevelChoice().getSelectedIndex() ); - } - if( e.getSource() == VAJAntToolGUI.this.getTargetList() ) - { - getBuildInfo().setTarget( getTargetList().getSelectedItem() ); - } - } - catch( Throwable exc ) - { - handleException( exc ); - } - } - - /** - * PropertyChangeListener method - * - * @param evt Description of Parameter - */ - public void propertyChange( java.beans.PropertyChangeEvent evt ) - { - if( evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && ( evt.getPropertyName().equals( "projectName" ) ) ) - { - connectProjectNameToLabel(); - } - if( evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && ( evt.getPropertyName().equals( "buildFileName" ) ) ) - { - connectBuildFileNameToTextField(); - } - } - - /** - * TextListener method - * - * @param e Description of Parameter - */ - public void textValueChanged( TextEvent e ) - { - if( e.getSource() == VAJAntToolGUI.this.getBuildFileTextField() ) - { - connectTextFieldToBuildFileName(); - } - } - - public void windowActivated( WindowEvent e ) - { - } - - public void windowClosed( WindowEvent e ) - { - } - - /** - * WindowListener methods - * - * @param e Description of Parameter - */ - public void windowClosing( WindowEvent e ) - { - try - { - if( e.getSource() == VAJAntToolGUI.this ) - { - dispose(); - System.exit( 0 ); - } - if( e.getSource() == VAJAntToolGUI.this.getAboutDialog() ) - { - getAboutDialog().dispose(); - } - if( e.getSource() == VAJAntToolGUI.this.getMessageFrame() ) - { - getMessageFrame().dispose(); - } - } - catch( Throwable exc ) - { - handleException( exc ); - } - } - - public void windowDeactivated( WindowEvent e ) - { - } - - public void windowDeiconified( WindowEvent e ) - { - } - - public void windowIconified( WindowEvent e ) - { - } - - public void windowOpened( WindowEvent e ) - { - } - } - - /** - * This internal BuildLogger, to be honest, is just a BuildListener. It does - * nearly the same as the DefaultLogger, but uses the Loggin-Window for - * output. - * - * @author RT - */ - private class VAJBuildLogger implements BuildListener - { - private long startTime = System.currentTimeMillis(); - - /** - * VAJBuildLogger constructor comment. - */ - public VAJBuildLogger() - { - super(); - } - - /** - * Fired after the last target has finished. This event will still be - * thrown if an error occured during the build. - * - * @param event Description of Parameter - * @see BuildEvent#getException() - */ - public void buildFinished( BuildEvent event ) - { - getStopButton().setEnabled( false ); - getBuildButton().setEnabled( true ); - getBuildButton().requestFocus(); - - Throwable error = event.getException(); - - if( error == null ) - { - getMessageTextArea().append( lineSeparator + "BUILD SUCCESSFUL" ); - } - else - { - logException( error ); - } - - getMessageTextArea().append( lineSeparator + "Total time: " + formatTime( System.currentTimeMillis() - startTime ) ); - } - - /** - * Fired before any targets are started. - * - * @param event Description of Parameter - */ - public void buildStarted( BuildEvent event ) - { - getStopButton().setEnabled( true ); - getBuildButton().setEnabled( false ); - getStopButton().requestFocus(); - - startTime = System.currentTimeMillis(); - getMessageTextArea().append( lineSeparator ); - } - - /** - * Outputs an exception. - * - * @param error Description of Parameter - */ - public void logException( Throwable error ) - { - getMessageTextArea().append( lineSeparator + "BUILD FAILED" + lineSeparator ); - - if( error instanceof TaskException ) - { - getMessageTextArea().append( error.toString() ); - - Throwable nested = ( (TaskException)error ).getCause(); - if( nested != null ) - { - nested.printStackTrace( System.err ); - } - } - else - { - error.printStackTrace( System.err ); - } - } - - /** - * Fired whenever a message is logged. - * - * @param event Description of Parameter - * @see BuildEvent#getMessage() - * @see BuildEvent#getPriority() - */ - public void messageLogged( BuildEvent event ) - { - if( event.getPriority() <= getBuildInfo().getOutputMessageLevel() ) - { - String msg = ""; - final String task = event.getTask(); - if( task != null ) - { - msg = "[" + task + "] "; - } - getMessageTextArea().append( lineSeparator + msg + event.getMessage() ); - } - } - - /** - * Fired when a target has finished. This event will still be thrown if - * an error occured during the build. - * - * @param event Description of Parameter - * @see BuildEvent#getException() - */ - public void targetFinished( BuildEvent event ) - { - } - - /** - * Fired when a target is started. - * - * @param event Description of Parameter - * @see BuildEvent#getTarget() - */ - public void targetStarted( BuildEvent event ) - { - if( getBuildInfo().getOutputMessageLevel() <= Project.MSG_INFO ) - { - getMessageTextArea().append( lineSeparator + event.getTarget() + ":" ); - } - } - - /** - * Fired when a task has finished. This event will still be throw if an - * error occured during the build. - * - * @param event Description of Parameter - * @see BuildEvent#getException() - */ - public void taskFinished( BuildEvent event ) - { - } - - /** - * Fired when a task is started. - * - * @param event Description of Parameter - * @see BuildEvent#getTask() - */ - public void taskStarted( BuildEvent event ) - { - } - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java deleted file mode 100644 index b3526dcc3..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.beans.PropertyChangeListener; -import java.beans.PropertyChangeSupport; -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.StringTokenizer; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.BuildEvent; -import org.apache.tools.ant.BuildListener; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Target; - -/** - * This class wraps the Ant project information needed to start Ant from Visual - * Age. It serves the following purposes: - acts as model for AntMakeFrame - - * converts itself to/from String (to store the information as ToolData in the - * VA repository) - wraps Project functions for the GUI (get target list, - * execute target) - manages a seperate thread for Ant project execution this - * allows interrupting a running build from a GUI - * - * @author Wolf Siberski, TUI Infotec GmbH - */ - -class VAJBuildInfo implements Runnable -{ - - // name of the VA project this BuildInfo belongs to - private String vajProjectName = ""; - - // name of the Ant build file - private String buildFileName = ""; - - // main targets found in the build file - private ArrayList projectTargets = new ArrayList(); - - // target selected for execution - private java.lang.String target = ""; - - // log level - private int outputMessageLevel = Project.MSG_INFO; - - // is true if Project initialization was successful - private transient boolean projectInitialized = false; - - // Support for bound properties - protected transient PropertyChangeSupport propertyChange; - - // thread for Ant build execution - private Thread buildThread; - - // Ant Project created from build file - private transient Project project; - - // the listener used to log output. - private BuildListener projectLogger; - - /** - * Creates a BuildInfo object from a String The String must be in the format - * outputMessageLevel'|'buildFileName'|'defaultTarget'|'(project target'|')* - * - * @param data java.lang.String - * @return org.apache.tools.ant.taskdefs.optional.vaj.BuildInfo - */ - public static VAJBuildInfo parse( String data ) - { - VAJBuildInfo result = new VAJBuildInfo(); - - try - { - StringTokenizer tok = new StringTokenizer( data, "|" ); - result.setOutputMessageLevel( tok.nextToken() ); - result.setBuildFileName( tok.nextToken() ); - result.setTarget( tok.nextToken() ); - while( tok.hasMoreTokens() ) - { - result.projectTargets.add( tok.nextToken() ); - } - } - catch( Throwable t ) - { - // if parsing the info fails, just return - // an empty VAJBuildInfo - } - return result; - } - - /** - * Search for the insert position to keep names a sorted list of Strings - * This method has been copied from org.apache.tools.ant.Main - * - * @param names Description of Parameter - * @param name Description of Parameter - * @return Description of the Returned Value - */ - private static int findTargetPosition( ArrayList names, String name ) - { - int res = names.size(); - for( int i = 0; i < names.size() && res == names.size(); i++ ) - { - if( name.compareTo( (String)names.get( i ) ) < 0 ) - { - res = i; - } - } - return res; - } - - /** - * Sets the build file name - * - * @param newBuildFileName The new BuildFileName value - */ - public void setBuildFileName( String newBuildFileName ) - { - String oldValue = buildFileName; - buildFileName = newBuildFileName; - setProjectInitialized( false ); - firePropertyChange( "buildFileName", oldValue, buildFileName ); - } - - /** - * Sets the log level (value must be one of the constants in Project) - * - * @param newOutputMessageLevel The new OutputMessageLevel value - */ - public void setOutputMessageLevel( int newOutputMessageLevel ) - { - int oldValue = outputMessageLevel; - outputMessageLevel = newOutputMessageLevel; - firePropertyChange( "outputMessageLevel", - new Integer( oldValue ), new Integer( outputMessageLevel ) ); - } - - /** - * Sets the target to execute when executeBuild is called - * - * @param newTarget build target - */ - public void setTarget( String newTarget ) - { - String oldValue = target; - target = newTarget; - firePropertyChange( "target", oldValue, target ); - } - - /** - * Sets the name of the Visual Age for Java project where this BuildInfo - * belongs to - * - * @param newVAJProjectName The new VAJProjectName value - */ - public void setVAJProjectName( String newVAJProjectName ) - { - String oldValue = vajProjectName; - vajProjectName = newVAJProjectName; - firePropertyChange( "VAJProjectName", oldValue, vajProjectName ); - } - - /** - * Returns the build file name. - * - * @return build file name. - */ - public String getBuildFileName() - { - return buildFileName; - } - - /** - * Returns the log level - * - * @return log level. - */ - public int getOutputMessageLevel() - { - return outputMessageLevel; - } - - /** - * return a list of all targets in the current buildfile - * - * @return The ProjectTargets value - */ - public ArrayList getProjectTargets() - { - return projectTargets; - } - - /** - * returns the selected target. - * - * @return The Target value - */ - public java.lang.String getTarget() - { - return target; - } - - /** - * returns the VA project name - * - * @return The VAJProjectName value - */ - public String getVAJProjectName() - { - return vajProjectName; - } - - /** - * Returns true, if the Ant project is initialized (i.e. buildfile loaded) - * - * @return The ProjectInitialized value - */ - public boolean isProjectInitialized() - { - return projectInitialized; - } - - /** - * The addPropertyChangeListener method was generated to support the - * propertyChange field. - * - * @param listener The feature to be added to the PropertyChangeListener - * attribute - */ - public synchronized void addPropertyChangeListener( PropertyChangeListener listener ) - { - getPropertyChange().addPropertyChangeListener( listener ); - } - - /** - * Returns the BuildInfo information as String. The BuildInfo can be rebuilt - * from that String by calling parse(). - * - * @return java.lang.String - */ - public String asDataString() - { - String result = getOutputMessageLevel() + "|" + getBuildFileName() - + "|" + getTarget(); - for( Iterator e = getProjectTargets().iterator(); - e.hasNext(); ) - { - result = result + "|" + e.next(); - } - - return result; - } - - /** - * cancels a build. - */ - public void cancelBuild() - { - buildThread.interrupt(); - } - - /** - * Executes the target set by setTarget(). - * - * @param logger Description of Parameter - */ - public void executeProject( BuildListener logger ) - { - Throwable error; - projectLogger = logger; - try - { - buildThread = new Thread( this ); - buildThread.setPriority( Thread.MIN_PRIORITY ); - buildThread.start(); - } - catch( RuntimeException exc ) - { - error = exc; - throw exc; - } - catch( Error err ) - { - error = err; - throw err; - } - } - - /** - * The firePropertyChange method was generated to support the propertyChange - * field. - * - * @param propertyName Description of Parameter - * @param oldValue Description of Parameter - * @param newValue Description of Parameter - */ - public void firePropertyChange( java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue ) - { - getPropertyChange().firePropertyChange( propertyName, oldValue, newValue ); - } - - /** - * The removePropertyChangeListener method was generated to support the - * propertyChange field. - * - * @param listener Description of Parameter - */ - public synchronized void removePropertyChangeListener( PropertyChangeListener listener ) - { - getPropertyChange().removePropertyChangeListener( listener ); - } - - /** - * Executes a build. This method is executed by the Ant execution thread - */ - public void run() - { - try - { - InterruptedChecker ic = new InterruptedChecker( projectLogger ); - BuildEvent e = new BuildEvent( getProject() ); - try - { - ic.buildStarted( e ); - - if( !isProjectInitialized() ) - { - initProject(); - } - - project.addBuildListener( ic ); - project.executeTarget( target ); - - ic.buildFinished( e ); - } - catch( Throwable t ) - { - e.setException( t ); - ic.buildFinished( e ); - } - finally - { - project.removeBuildListener( ic ); - } - } - catch( Throwable t2 ) - { - System.out.println( "unexpected exception!" ); - t2.printStackTrace(); - } - } - - /** - * reloads the build file and updates the target list - */ - public void updateTargetList() - { - project = new Project(); - initProject(); - projectTargets.clear(); - Iterator ptargets = project.getTargets().iterator(); - while( ptargets.hasNext() ) - { - Target currentTarget = (Target)ptargets.next(); - if( currentTarget.getDescription() != null ) - { - String targetName = currentTarget.getName(); - int pos = findTargetPosition( projectTargets, targetName ); - projectTargets.insertElementAt( targetName, pos ); - } - } - } - - /** - * Accessor for the propertyChange field. - * - * @return The PropertyChange value - */ - protected PropertyChangeSupport getPropertyChange() - { - if( propertyChange == null ) - { - propertyChange = new PropertyChangeSupport( this ); - } - return propertyChange; - } - - /** - * Sets the log level (value must be one of the constants in Project) - * - * @param outputMessageLevel log level as String. - */ - private void setOutputMessageLevel( String outputMessageLevel ) - { - int level = Integer.parseInt( outputMessageLevel ); - setOutputMessageLevel( level ); - } - - /** - * sets the initialized flag - * - * @param initialized The new ProjectInitialized value - */ - private void setProjectInitialized( boolean initialized ) - { - Boolean oldValue = new Boolean( projectInitialized ); - projectInitialized = initialized; - firePropertyChange( "projectInitialized", oldValue, new Boolean( projectInitialized ) ); - } - - /** - * Returns the Ant project - * - * @return org.apache.tools.ant.Project - */ - private Project getProject() - { - if( project == null ) - { - project = new Project(); - } - return project; - } - - /** - * Initializes the Ant project. Assumes that the project attribute is - * already set. - */ - private void initProject() - { - try - { - project.init(); - File buildFile = new File( getBuildFileName() ); - project.setUserProperty( "ant.file", buildFile.getAbsolutePath() ); - - //FIXME: Need to convert to Myrmidon style - //ProjectHelper.configureProject( project, buildFile ); - setProjectInitialized( true ); - } - catch( RuntimeException exc ) - { - setProjectInitialized( false ); - throw exc; - } - catch( Error err ) - { - setProjectInitialized( false ); - throw err; - } - } - - /** - * This exception is thrown when a build is interrupted - * - * @author RT - */ - public static class BuildInterruptedException extends TaskException - { - public String toString() - { - return "BUILD INTERRUPTED"; - } - } - - /** - * BuildListener which checks for interruption and throws Exception if build - * process is interrupted. This class is a wrapper around a 'real' listener. - * - * @author RT - */ - private class InterruptedChecker implements BuildListener - { - // the real listener - BuildListener wrappedListener; - - /** - * Can only be constructed as wrapper around a real listener - * - * @param listener the real listener - */ - public InterruptedChecker( BuildListener listener ) - { - super(); - wrappedListener = listener; - } - - /** - * Fired after the last target has finished. This event will still be - * thrown if an error occured during the build. - * - * @param event Description of Parameter - */ - public void buildFinished( BuildEvent event ) - { - wrappedListener.buildFinished( event ); - checkInterrupted(); - } - - /** - * Fired before any targets are started. - * - * @param event Description of Parameter - */ - public void buildStarted( BuildEvent event ) - { - wrappedListener.buildStarted( event ); - checkInterrupted(); - } - - /** - * Fired whenever a message is logged. - * - * @param event Description of Parameter - */ - public void messageLogged( BuildEvent event ) - { - wrappedListener.messageLogged( event ); - checkInterrupted(); - } - - /** - * Fired when a target has finished. This event will still be thrown if - * an error occured during the build. - * - * @param event Description of Parameter - */ - public void targetFinished( BuildEvent event ) - { - wrappedListener.targetFinished( event ); - checkInterrupted(); - } - - /** - * Fired when a target is started. - * - * @param event Description of Parameter - */ - public void targetStarted( BuildEvent event ) - { - wrappedListener.targetStarted( event ); - checkInterrupted(); - } - - /** - * Fired when a task has finished. This event will still be throw if an - * error occured during the build. - * - * @param event Description of Parameter - */ - public void taskFinished( BuildEvent event ) - { - wrappedListener.taskFinished( event ); - checkInterrupted(); - } - - /** - * Fired when a task is started. - * - * @param event Description of Parameter - */ - public void taskStarted( BuildEvent event ) - { - wrappedListener.taskStarted( event ); - checkInterrupted(); - } - - /** - * checks if the thread was interrupted. When an interrupt occured, - * throw an Exception to stop the execution. - */ - protected void checkInterrupted() - { - if( buildThread.isInterrupted() ) - { - throw new BuildInterruptedException(); - } - } - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java deleted file mode 100644 index e9592a5c4..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.File; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.Pattern; -import org.apache.myrmidon.framework.PatternSet; -import org.apache.myrmidon.framework.PatternUtil; - -/** - * Export packages from the Visual Age for Java workspace. The packages are - * specified similar to all other MatchingTasks. Since the VA Workspace is not - * file based, this task is simulating a directory hierarchy for the workspace: - * The 'root' contains all project 'dir's, and the projects contain their - * respective package 'dir's. Example:

<vajexport - * destdir="C:/builddir/source">  <include - * name="/MyVAProject/org/foo/subsystem1/**" />  <exclude - * name="/MyVAProject/org/foo/subsystem1/test/**"/> </vajexport> - *
exports all packages in the project MyVAProject which start - * with 'org.foo.subsystem1' except of these starting with - * 'org.foo.subsystem1.test'. There are flags to choose which items to export: - * exportSources: export Java sources exportResources: export project resources - * exportClasses: export class files exportDebugInfo: export class files with - * debug info (use with exportClasses) default is exporting Java files and - * resources. - * - * @author Wolf Siberski, TUI Infotec GmbH - */ - -public class VAJExport extends VAJTask -{ - protected boolean exportSources = true; - protected boolean exportResources = true; - protected boolean exportClasses = false; - protected boolean exportDebugInfo = false; - protected boolean useDefaultExcludes = true; - protected boolean overwrite = true; - - protected PatternSet patternSet = new PatternSet(); - //set set... method comments for description - protected File destDir; - - /** - * Sets whether default exclusions should be used or not. - * - * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions - * should be used, "false"|"off"|"no" when they shouldn't be used. - */ - public void setDefaultexcludes( boolean useDefaultExcludes ) - { - this.useDefaultExcludes = useDefaultExcludes; - } - - /** - * Set the destination directory into which the selected items should be - * exported - * - * @param destDir The new Destdir value - */ - public void setDestdir( File destDir ) - { - this.destDir = destDir; - } - - /** - * Sets the set of exclude patterns. Patterns may be separated by a comma or - * a space. Currently only patterns denoting packages are supported - * - * @param excludes the string containing the exclude patterns - */ - public void setExcludes( String excludes ) - { - patternSet.setExcludes( excludes ); - } - - /** - * if exportClasses is set, class files are exported - * - * @param doExport The new ExportClasses value - */ - public void setExportClasses( boolean doExport ) - { - exportClasses = doExport; - } - - /** - * if exportDebugInfo is set, the exported class files contain debug info - * - * @param doExport The new ExportDebugInfo value - */ - public void setExportDebugInfo( boolean doExport ) - { - exportDebugInfo = doExport; - } - - /** - * if exportResources is set, resource file will be exported - * - * @param doExport The new ExportResources value - */ - public void setExportResources( boolean doExport ) - { - exportResources = doExport; - } - - /** - * if exportSources is set, java files will be exported - * - * @param doExport The new ExportSources value - */ - public void setExportSources( boolean doExport ) - { - exportSources = doExport; - } - - /** - * Sets the set of include patterns. Patterns may be separated by a comma or - * a space.Currently only patterns denoting packages are supported - * - * @param includes the string containing the include patterns - */ - public void setIncludes( String includes ) - { - patternSet.setIncludes( includes ); - } - - /** - * if Overwrite is set, files will be overwritten during export - * - * @param doOverwrite The new Overwrite value - */ - public void setOverwrite( boolean doOverwrite ) - { - overwrite = doOverwrite; - } - - /** - * add a name entry on the exclude list - * - * @return Description of the Returned Value - */ - public void addExclude( final Pattern pattern ) - { - patternSet.addExclude( pattern ); - } - - /** - * add a name entry on the include list - */ - public void addInclude( final Pattern pattern ) - { - patternSet.addInclude( pattern ); - } - - /** - * do the export - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - // first off, make sure that we've got a destdir - if( destDir == null ) - { - throw new TaskException( "destdir attribute must be set!" ); - } - - // delegate the export to the VAJUtil object. - final TaskContext context = getContext(); - final TaskContext context1 = getContext(); - getUtil().exportPackages( destDir, - PatternUtil.getIncludePatterns( patternSet, context ), - PatternUtil.getExcludePatterns( patternSet, context1 ), - exportClasses, exportDebugInfo, - exportResources, exportSources, - useDefaultExcludes, overwrite ); - } - -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java deleted file mode 100644 index 579453070..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJExportServlet.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.File; - -/** - * A Remote Access to Tools Servlet to extract package sets from the Workbench - * to the local file system. The following table describes the servlet - * parameters. - * - * - * - * - * - * Parameter - * - * - * - * Values - * - * - * - * Description - * - * - * - * - * - * - * - * dir - * - * - * - * Any valid directory name on the server. - * - * - * - * The directory to export the files to on the machine where the servlet - * is being run. If the directory doesn't exist, it will be created.

- * - * Relative paths are relative to IBMVJava/ide/tools/com-ibm-ivj-toolserver, - * where IBMVJava is the VisualAge for Java installation directory. - * - * - * - * - * - * - * - * include - * - * - * - * See below. - * - * - * - * The pattern used to indicate which projects and packages to export. - * - * - * - * - * - * - * - * - * exclude - * - * - * - * See below - * - * - * - * The pattern used to indicate which projects and packages not - * to export. - * - * - * - * - * - * - * - * cls - * - * - * - * "yes" or "no" (without the quotes) - * - * - * - * Export class files. Defaults to "no". - * - * - * - * - * - * - * - * src - * - * - * - * "yes" or "no" (without the quotes) - * - * - * - * Export source files. Defaults to "yes". - * - * - * - * - * - * - * - * res - * - * - * - * "yes" or "no" (without the quotes) - * - * - * - * Export resource files associated with the included project(s). Defaults - * to "yes". - * - * - * - * - * - * - * - * dex - * - * - * - * "yes" or "no" (without the quotes) - * - * - * - * Use the default exclusion patterns. Defaults to "yes". See below for an - * explanation of default excludes. - * - * - * - * - * - * - * - * owr - * - * - * - * "yes" or "no" (without the quotes) - * - * - * - * Overwrite any existing files. Defaults to "yes". - * - * - * - * - * - *

- * - * The vajexport servlet uses include and exclude parameters to form the - * criteria for selecting packages to export. The parameter is broken up into - * ProjectName/packageNameSegments, where ProjectName is what you expect, and - * packageNameSegments is a partial (or complete) package name, separated by - * forward slashes, rather than periods. Each packageNameSegment can have - * wildcard characters.

- * - * - * - * - * - * Wildcard Characters - * - * - * - * Description - * - * - * - * - * - * - * - * * - * - * - * - * Match zero or more characters in that segment. - * - * - * - * - * - * - * - * ? - * - * - * - * Match one character in that segment. - * - * - * - * - * - * - * - * ** - * - * - * - * Matches all characters in zero or more segments. - * - * - * - * - * - * - * - * @author Wolf Siberski, based on servlets written by Glenn McAllister - */ -public class VAJExportServlet extends VAJToolsServlet -{ - // constants for servlet param names - public final static String WITH_DEBUG_INFO = "deb"; - public final static String OVERWRITE_PARAM = "owr"; - - /** - * Respond to a request to export packages from the Workbench. - */ - protected void executeRequest() - { - getUtil().exportPackages( - new File( getFirstParamValueString( DIR_PARAM ) ), - getParamValues( INCLUDE_PARAM ), - getParamValues( EXCLUDE_PARAM ), - getBooleanParam( CLASSES_PARAM, false ), - getBooleanParam( WITH_DEBUG_INFO, false ), - getBooleanParam( RESOURCES_PARAM, true ), - getBooleanParam( SOURCES_PARAM, true ), - getBooleanParam( DEFAULT_EXCLUDES_PARAM, true ), - getBooleanParam( OVERWRITE_PARAM, true ) - ); - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java deleted file mode 100644 index 56c20bf3d..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Iterator; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.types.DirectoryScanner; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.types.ScannerUtil; - -/** - * Import source, class files, and resources to the Visual Age for Java - * workspace using FileSets.

- * - * Example:

- * <vajimport project="MyVAProject">
- *   <fileset dir="src">
- *     <include name="org/foo/subsystem1/**" />
- *     <exclude name="/org/foo/subsystem1/test/**" />
- *  </fileset>
- * </vajexport>
- * 
import all source and resource files from the "src" directory which - * start with 'org.foo.subsystem1', except of these starting with - * 'org.foo.subsystem1.test' into the project MyVAProject.

- * - * If MyVAProject isn't loaded into the Workspace, a new edition is created in - * the repository and automatically loaded into the Workspace. There has to be - * at least one nested FileSet element.

- * - * There are attributes to choose which items to export: - * - * - * - * - * - * Attribute - * - * - * - * Description - * - * - * - * Required - * - * - * - * - * - * - * - * project - * - * - * - * the name of the Project to import to - * - * - * - * Yes - * - * - * - * - * - * - * - * importSources - * - * - * - * import Java sources, defaults to "yes" - * - * - * - * No - * - * - * - * - * - * - * - * importResources - * - * - * - * import resource files (anything that doesn't end with .java or .class), - * defaults to "yes" - * - * - * - * No - * - * - * - * - * - * - * - * importClasses - * - * - * - * import class files, defaults to "no" - * - * - * - * No - * - * - * - * - * - * - * - * @author RT - * @author: Glenn McAllister, inspired by a similar task written by Peter Kelley - */ -public class VAJImport extends VAJTask -{ - protected ArrayList filesets = new ArrayList(); - protected boolean importSources = true; - protected boolean importResources = true; - protected boolean importClasses = false; - protected String importProject = null; - protected boolean useDefaultExcludes = true; - - /** - * Sets whether default exclusions should be used or not. - * - * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions - * should be used, "false"|"off"|"no" when they shouldn't be used. - */ - public void setDefaultexcludes( boolean useDefaultExcludes ) - { - this.useDefaultExcludes = useDefaultExcludes; - } - - /** - * Import .class files. - * - * @param importClasses The new ImportClasses value - */ - public void setImportClasses( boolean importClasses ) - { - this.importClasses = importClasses; - } - - /** - * Import resource files (anything that doesn't end in .class or .java) - * - * @param importResources The new ImportResources value - */ - public void setImportResources( boolean importResources ) - { - this.importResources = importResources; - } - - /** - * Import .java files - * - * @param importSources The new ImportSources value - */ - public void setImportSources( boolean importSources ) - { - this.importSources = importSources; - } - - /** - * The VisualAge for Java Project name to import into. - * - * @param projectName The new Project value - */ - public void setProject( String projectName ) - { - this.importProject = projectName; - } - - /** - * Adds a set of files (nested fileset attribute). - * - * @param set The feature to be added to the Fileset attribute - */ - public void addFileset( FileSet set ) - { - filesets.add( set ); - } - - /** - * Do the import. - * - * @exception TaskException Description of Exception - */ - public void execute() - throws TaskException - { - if( filesets.size() == 0 ) - { - throw new TaskException( "At least one fileset is required!" ); - } - - if( importProject == null || "".equals( importProject ) ) - { - throw new TaskException( "The VisualAge for Java Project name is required!" ); - } - - for( Iterator e = filesets.iterator(); e.hasNext(); ) - { - importFileset( (FileSet)e.next() ); - } - } - - /** - * Import all files from the fileset into the Project in the Workspace. - * - * @param fileset Description of Parameter - */ - protected void importFileset( FileSet fileset ) - { - DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fileset ); - if( ds.getIncludedFiles().length == 0 ) - { - return; - } - - String[] includes = null; - String[] excludes = null; - - // Hack to get includes and excludes. We could also use getIncludedFiles, - // but that would result in very long HTTP-requests. - // Therefore we want to send the patterns only to the remote tool server - // and let him figure out the files. - try - { - Class directoryScanner = ds.getClass(); - - Field includesField = directoryScanner.getDeclaredField( "includes" ); - includesField.setAccessible( true ); - includes = (String[])includesField.get( ds ); - - Field excludesField = directoryScanner.getDeclaredField( "excludes" ); - excludesField.setAccessible( true ); - excludes = (String[])excludesField.get( ds ); - } - catch( NoSuchFieldException nsfe ) - { - throw new TaskException( - "DirectoryScanner.includes or .excludes missing" + nsfe.getMessage() ); - } - catch( IllegalAccessException iae ) - { - throw new TaskException( - "Access to DirectoryScanner.includes or .excludes not allowed" ); - } - - getUtil().importFiles( importProject, ds.getBasedir(), - includes, excludes, - importClasses, importResources, importSources, - useDefaultExcludes ); - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java deleted file mode 100644 index 0e87e5ae1..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.File; - -/** - * A Remote Access to Tools Servlet to import a Project from files into the - * Repository. The following table describes the servlet parameters. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
- * Parameter - * - * Description - *
- * project - * - * The name of the project where you want the imported items to go. - *
- * dir - * - * The directory you want to import from. - *
- * - * - * @author Wolf Siberski, based on servlets written by Glenn McAllister - */ -public class VAJImportServlet extends VAJToolsServlet -{ - /** - * Respond to a request to import files to the Repository - */ - protected void executeRequest() - { - getUtil().importFiles( - getFirstParamValueString( PROJECT_NAME_PARAM ), - new File( getFirstParamValueString( DIR_PARAM ) ), - getParamValues( INCLUDE_PARAM ), - getParamValues( EXCLUDE_PARAM ), - getBooleanParam( CLASSES_PARAM, false ), - getBooleanParam( RESOURCES_PARAM, true ), - getBooleanParam( SOURCES_PARAM, true ), - false// no default excludes, because they - // are already added on client side - // getBooleanParam(DEFAULT_EXCLUDES_PARAM, true) - ); - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java deleted file mode 100644 index 055ddb02c..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoad.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.util.ArrayList; - -/** - * Load specific project versions into the Visual Age for Java workspace. Each - * project and version name has to be specified completely. Example: - *

<vajload>  <project name="MyVAProject" - * version="2.1"/>  <project name="Apache Xerces" version="1.2.0"/> - * </vajload>
- * - * @author Wolf Siberski, TUI Infotec GmbH - */ - -public class VAJLoad extends VAJTask -{ - ArrayList projectDescriptions = new ArrayList(); - - /** - * Add a project description entry on the project list. - * - * @return Description of the Returned Value - */ - public VAJProjectDescription createVAJProject() - { - VAJProjectDescription d = new VAJProjectDescription(); - projectDescriptions.add( d ); - return d; - } - - /** - * Load specified projects. - */ - public void execute() - { - getUtil().loadProjects( projectDescriptions ); - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java deleted file mode 100644 index 051a9f20a..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadProjects.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -/** - * This is only there for backward compatibility with the default task list and - * will be removed soon - * - * @author Wolf Siberski, TUI Infotec GmbH - */ - -public class VAJLoadProjects extends VAJLoad -{ -} - - - - - - diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java deleted file mode 100644 index ba1953df6..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLoadServlet.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.util.ArrayList; - -/** - * A Remote Access to Tools Servlet to load a Project from the Repository into - * the Workbench. The following table describes the servlet parameters. - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
- * Parameter - * - * Description - *
- * project - * - * The name of the Project you want to load into the Workbench. - *
- * version - * - * The version of the package you want to load into the Workbench. - *
- * - * - * @author Wolf Siberski, based on servlets written by Glenn McAllister - */ -public class VAJLoadServlet extends VAJToolsServlet -{ - - // constants for servlet param names - public final static String VERSION_PARAM = "version"; - - /** - * Respond to a request to load a project from the Repository into the - * Workbench. - */ - protected void executeRequest() - { - String[] projectNames = getParamValues( PROJECT_NAME_PARAM ); - String[] versionNames = getParamValues( VERSION_PARAM ); - - ArrayList projectDescriptions = new ArrayList( projectNames.length ); - for( int i = 0; i < projectNames.length && i < versionNames.length; i++ ) - { - VAJProjectDescription desc = new VAJProjectDescription(); - desc.setName( projectNames[ i ] ); - desc.setVersion( versionNames[ i ] ); - projectDescriptions.add( desc ); - } - - util.loadProjects( projectDescriptions ); - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalToolUtil.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalToolUtil.java deleted file mode 100644 index 07322397a..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalToolUtil.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -/** - * Adaption of VAJLocalUtil to Task context. - */ -class VAJLocalToolUtil - extends VAJLocalUtil -{ - private VAJTask m_task; - - public VAJLocalToolUtil( final VAJTask task ) - { - m_task = task; - } - - public void log( final String msg, final int level ) - { - m_task.log( msg, level ); - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java deleted file mode 100644 index 02d25adb1..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJLocalUtil.java +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import com.ibm.ivj.util.base.ExportCodeSpec; -import com.ibm.ivj.util.base.ImportCodeSpec; -import com.ibm.ivj.util.base.IvjException; -import com.ibm.ivj.util.base.Package; -import com.ibm.ivj.util.base.Project; -import com.ibm.ivj.util.base.ProjectEdition; -import com.ibm.ivj.util.base.ToolEnv; -import com.ibm.ivj.util.base.Type; -import com.ibm.ivj.util.base.Workspace; -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.types.DirectoryScanner; - -/** - * Helper class for VAJ tasks. Holds Workspace singleton and wraps IvjExceptions - * into TaskExceptions - * - * @author Wolf Siberski, TUI Infotec GmbH - */ -abstract class VAJLocalUtil - implements VAJUtil -{ - // singleton containing the VAJ workspace - private static Workspace workspace; - - /** - * get a project from the Workspace. - * - * @param importProject Description of Parameter - * @return The VAJProject value - */ - static Project getVAJProject( String importProject ) - { - Project found = null; - Project[] currentProjects = getWorkspace().getProjects(); - - for( int i = 0; i < currentProjects.length; i++ ) - { - Project p = currentProjects[ i ]; - if( p.getName().equals( importProject ) ) - { - found = p; - break; - } - } - - if( found == null ) - { - try - { - found = getWorkspace().createProject( importProject, true ); - } - catch( IvjException e ) - { - throw createTaskException( "Error while creating Project " - + importProject + ": ", e ); - } - } - - return found; - } - - /** - * returns the current VAJ workspace. - * - * @return com.ibm.ivj.util.base.Workspace - */ - static Workspace getWorkspace() - { - if( workspace == null ) - { - workspace = ToolEnv.connectToWorkspace(); - if( workspace == null ) - { - throw new TaskException( - "Unable to connect to Workspace! " - + "Make sure you are running in VisualAge for Java." ); - } - } - - return workspace; - } - - /** - * Wraps IvjException into a TaskException - * - * @param errMsg Additional error message - * @param e IvjException which is wrapped - * @return org.apache.tools.ant.TaskException - */ - static TaskException createTaskException( - String errMsg, IvjException e ) - { - errMsg = errMsg + "\n" + e.getMessage(); - String[] errors = e.getErrors(); - if( errors != null ) - { - for( int i = 0; i < errors.length; i++ ) - { - errMsg = errMsg + "\n" + errors[ i ]; - } - } - return new TaskException( errMsg, e ); - } - - - //----------------------------------------------------------- - // export - //----------------------------------------------------------- - - /** - * export packages - * - * @param dest Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param exportClasses Description of Parameter - * @param exportDebugInfo Description of Parameter - * @param exportResources Description of Parameter - * @param exportSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - * @param overwrite Description of Parameter - */ - public void exportPackages( - File dest, - String[] includePatterns, String[] excludePatterns, - boolean exportClasses, boolean exportDebugInfo, - boolean exportResources, boolean exportSources, - boolean useDefaultExcludes, boolean overwrite ) - { - if( includePatterns == null || includePatterns.length == 0 ) - { - log( "You must specify at least one include attribute. " - + "Not exporting", MSG_ERR ); - } - else - { - try - { - VAJWorkspaceScanner scanner = new VAJWorkspaceScanner(); - scanner.setIncludes( includePatterns ); - scanner.setExcludes( excludePatterns ); - if( useDefaultExcludes ) - { - scanner.addDefaultExcludes(); - } - scanner.scan(); - - Package[] packages = scanner.getIncludedPackages(); - - log( "Exporting " + packages.length + " package(s) to " - + dest, MSG_INFO ); - for( int i = 0; i < packages.length; i++ ) - { - getLogger().debug( " " + packages[ i ].getName() ); - } - - ExportCodeSpec exportSpec = new ExportCodeSpec(); - exportSpec.setPackages( packages ); - exportSpec.includeJava( exportSources ); - exportSpec.includeClass( exportClasses ); - exportSpec.includeResources( exportResources ); - exportSpec.includeClassDebugInfo( exportDebugInfo ); - exportSpec.useSubdirectories( true ); - exportSpec.overwriteFiles( overwrite ); - exportSpec.setExportDirectory( dest.getAbsolutePath() ); - - getWorkspace().exportData( exportSpec ); - } - catch( IvjException ex ) - { - throw createTaskException( "Exporting failed!", ex ); - } - } - } - - - //----------------------------------------------------------- - // import - //----------------------------------------------------------- - - - /** - * Do the import. - * - * @param importProject Description of Parameter - * @param srcDir Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param importClasses Description of Parameter - * @param importResources Description of Parameter - * @param importSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - * @exception TaskException Description of Exception - */ - public void importFiles( - String importProject, File srcDir, - String[] includePatterns, String[] excludePatterns, - boolean importClasses, boolean importResources, - boolean importSources, boolean useDefaultExcludes ) - throws TaskException - { - - if( importProject == null || "".equals( importProject ) ) - { - throw new TaskException( "The VisualAge for Java project " - + "name is required!" ); - } - - ImportCodeSpec importSpec = new ImportCodeSpec(); - importSpec.setDefaultProject( getVAJProject( importProject ) ); - - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir( srcDir ); - ds.setIncludes( includePatterns ); - ds.setExcludes( excludePatterns ); - if( useDefaultExcludes ) - { - ds.addDefaultExcludes(); - } - ds.scan(); - - ArrayList classes = new ArrayList(); - ArrayList sources = new ArrayList(); - ArrayList resources = new ArrayList(); - - scanForImport( srcDir, ds.getIncludedFiles(), classes, sources, resources ); - - StringBuffer summaryLog = new StringBuffer( "Importing " ); - addFilesToImport( importSpec, importClasses, classes, "Class", summaryLog ); - addFilesToImport( importSpec, importSources, sources, "Java", summaryLog ); - addFilesToImport( importSpec, importResources, resources, "Resource", summaryLog ); - importSpec.setResourcePath( srcDir.getAbsolutePath() ); - - summaryLog.append( " into the project '" ); - summaryLog.append( importProject ); - summaryLog.append( "'." ); - - getLogger().info( summaryLog.toString() ); - - try - { - Type[] importedTypes = getWorkspace().importData( importSpec ); - if( importedTypes == null ) - { - throw new TaskException( "Unable to import into Workspace!" ); - } - else - { - getLogger().debug( importedTypes.length + " types imported" ); - for( int i = 0; i < importedTypes.length; i++ ) - { - log( importedTypes[ i ].getPackage().getName() - + "." + importedTypes[ i ].getName() - + " into " + importedTypes[ i ].getProject().getName(), - MSG_DEBUG ); - } - } - } - catch( IvjException ivje ) - { - throw createTaskException( "Error while importing into workspace: ", - ivje ); - } - } - - - //----------------------------------------------------------- - // load - //----------------------------------------------------------- - - /** - * Load specified projects. - * - * @param projectDescriptions Description of Parameter - */ - public void loadProjects( ArrayList projectDescriptions ) - { - ArrayList expandedDescs = getExpandedDescriptions( projectDescriptions ); - - // output warnings for projects not found - for( Iterator e = projectDescriptions.iterator(); e.hasNext(); ) - { - VAJProjectDescription d = (VAJProjectDescription)e.next(); - if( !d.projectFound() ) - { - getLogger().warn( "No Projects match the name " + d.getName() ); - } - } - - log( "Loading " + expandedDescs.size() - + " project(s) into workspace", MSG_INFO ); - - for( Iterator e = expandedDescs.iterator(); - e.hasNext(); ) - { - VAJProjectDescription d = (VAJProjectDescription)e.next(); - - ProjectEdition pe = findProjectEdition( d.getName(), d.getVersion() ); - try - { - log( "Loading '" + d.getName() + "', Version '" + d.getVersion() - + "', into Workspace", MSG_VERBOSE ); - pe.loadIntoWorkspace(); - } - catch( IvjException ex ) - { - throw createTaskException( "Project '" + d.getName() - + "' could not be loaded.", ex ); - } - } - } - - /** - * return project descriptions containing full project names instead of - * patterns with wildcards. - * - * @param projectDescs Description of Parameter - * @return The ExpandedDescriptions value - */ - private ArrayList getExpandedDescriptions( ArrayList projectDescs ) - { - ArrayList expandedDescs = new ArrayList( projectDescs.size() ); - try - { - String[] projectNames = - getWorkspace().getRepository().getProjectNames(); - for( int i = 0; i < projectNames.length; i++ ) - { - for( Iterator e = projectDescs.iterator(); - e.hasNext(); ) - { - VAJProjectDescription d = (VAJProjectDescription)e.next(); - String pattern = d.getName(); - if( VAJWorkspaceScanner.match( pattern, projectNames[ i ] ) ) - { - d.setProjectFound(); - expandedDescs.add( new VAJProjectDescription( - projectNames[ i ], d.getVersion() ) ); - break; - } - } - } - } - catch( IvjException e ) - { - throw createTaskException( "VA Exception occured: ", e ); - } - - return expandedDescs; - } - - /** - * Adds files to an import specification. Helper method for importFiles() - * - * @param spec import specification - * @param doImport only add files if doImport is true - * @param files the files to add - * @param fileType type of files (Source/Class/Resource) - * @param summaryLog buffer for logging - */ - private void addFilesToImport( - ImportCodeSpec spec, boolean doImport, - ArrayList files, String fileType, - StringBuffer summaryLog ) - { - - if( doImport ) - { - String[] fileArr = new String[ files.size() ]; - files.copyInto( fileArr ); - try - { - // here it is assumed that fileType is one of the - // following strings: // "Java", "Class", "Resource" - String methodName = "set" + fileType + "Files"; - Class[] methodParams = new Class[]{fileArr.getClass()}; - java.lang.reflect.Method method = - spec.getClass().getDeclaredMethod( methodName, methodParams ); - method.invoke( spec, new Object[]{fileArr} ); - } - catch( Exception e ) - { - throw new TaskException( "Error", e ); - } - if( files.size() > 0 ) - { - logFiles( files, fileType ); - summaryLog.append( files.size() ); - summaryLog.append( " " + fileType.toLowerCase() + " file" ); - summaryLog.append( files.size() > 1 ? "s, " : ", " ); - } - } - } - - /** - * returns a list of project names matching the given pattern - * - * @param pattern Description of Parameter - * @return Description of the Returned Value - */ - private ArrayList findMatchingProjects( String pattern ) - { - String[] projectNames; - try - { - projectNames = getWorkspace().getRepository().getProjectNames(); - } - catch( IvjException e ) - { - throw createTaskException( "VA Exception occured: ", e ); - } - - ArrayList matchingProjects = new ArrayList(); - for( int i = 0; i < projectNames.length; i++ ) - { - if( VAJWorkspaceScanner.match( pattern, projectNames[ i ] ) ) - { - matchingProjects.add( projectNames[ i ] ); - } - } - - return matchingProjects; - } - - /** - * Finds a specific project edition in the repository. - * - * @param name project name - * @param versionName project version name - * @return com.ibm.ivj.util.base.ProjectEdition the specified edition - */ - private ProjectEdition findProjectEdition( - String name, String versionName ) - { - try - { - ProjectEdition[] editions = null; - editions = getWorkspace().getRepository().getProjectEditions( name ); - - if( editions == null ) - { - throw new TaskException( "Project " + name + " doesn't exist" ); - } - - ProjectEdition pe = null; - for( int i = 0; i < editions.length && pe == null; i++ ) - { - if( versionName.equals( editions[ i ].getVersionName() ) ) - { - pe = editions[ i ]; - } - } - if( pe == null ) - { - throw new TaskException( "Version " + versionName - + " of Project " + name + " doesn't exist" ); - } - return pe; - } - catch( IvjException e ) - { - throw createTaskException( "VA Exception occured: ", e ); - } - - } - - /** - * Logs a list of file names to the message log - * - * @param fileNames java.util.ArrayList file names to be logged - * @param fileType Description of Parameter - */ - private void logFiles( ArrayList fileNames, String fileType ) - { - getLogger().debug( fileType + " files found for import:" ); - for( Iterator e = fileNames.iterator(); e.hasNext(); ) - { - getLogger().debug( " " + e.next() ); - } - } - - /** - * Sort the files into classes, sources, and resources. - * - * @param dir Description of Parameter - * @param files Description of Parameter - * @param classes Description of Parameter - * @param sources Description of Parameter - * @param resources Description of Parameter - */ - private void scanForImport( - File dir, - String[] files, - ArrayList classes, - ArrayList sources, - ArrayList resources ) - { - for( int i = 0; i < files.length; i++ ) - { - String file = ( new File( dir, files[ i ] ) ).getAbsolutePath(); - if( file.endsWith( ".java" ) || file.endsWith( ".JAVA" ) ) - { - sources.add( file ); - } - else if( file.endsWith( ".class" ) || file.endsWith( ".CLASS" ) ) - { - classes.add( file ); - } - else - { - // for resources VA expects the path relative to the resource path - resources.add( files[ i ] ); - } - } - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java deleted file mode 100644 index 4e742dd43..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJProjectDescription.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import org.apache.myrmidon.api.TaskException; - -/** - * Type class. Holds information about a project edition. - * - * @author RT - * @author: Wolf Siberski - */ -public class VAJProjectDescription -{ - private String name; - private boolean projectFound; - private String version; - - public VAJProjectDescription() - { - } - - public VAJProjectDescription( String n, String v ) - { - name = n; - version = v; - } - - public void setName( String newName ) - { - if( newName == null || newName.equals( "" ) ) - { - throw new TaskException( "name attribute must be set" ); - } - name = newName; - } - - public void setProjectFound() - { - projectFound = true; - } - - public void setVersion( String newVersion ) - { - if( newVersion == null || newVersion.equals( "" ) ) - { - throw new TaskException( "version attribute must be set" ); - } - version = newVersion; - } - - public String getName() - { - return name; - } - - public String getVersion() - { - return version; - } - - public boolean projectFound() - { - return projectFound; - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java deleted file mode 100644 index 709271293..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJRemoteUtil.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.BufferedReader; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.Task; - -/** - * Helper class for VAJ tasks. Holds Workspace singleton and wraps IvjExceptions - * into TaskExceptions - * - * @author Wolf Siberski, TUI Infotec GmbH - */ -class VAJRemoteUtil implements VAJUtil -{ - // calling task - Task caller; - - // VAJ remote tool server - String remoteServer; - - public VAJRemoteUtil( Task caller, String remote ) - { - this.caller = caller; - this.remoteServer = remote; - } - - /** - * export the array of Packages - * - * @param destDir Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param exportClasses Description of Parameter - * @param exportDebugInfo Description of Parameter - * @param exportResources Description of Parameter - * @param exportSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - * @param overwrite Description of Parameter - */ - public void exportPackages( File destDir, - String[] includePatterns, String[] excludePatterns, - boolean exportClasses, boolean exportDebugInfo, boolean exportResources, - boolean exportSources, boolean useDefaultExcludes, boolean overwrite ) - { - try - { - String request = "http://" + remoteServer + "/servlet/vajexport?" - + VAJExportServlet.WITH_DEBUG_INFO + "=" + exportDebugInfo + "&" - + VAJExportServlet.OVERWRITE_PARAM + "=" + overwrite + "&" - + assembleImportExportParams( destDir, - includePatterns, excludePatterns, - exportClasses, exportResources, - exportSources, useDefaultExcludes ); - sendRequest( request ); - } - catch( Exception ex ) - { - throw new TaskException( "Error", ex ); - } - } - - /** - * Do the import. - * - * @param importProject Description of Parameter - * @param srcDir Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param importClasses Description of Parameter - * @param importResources Description of Parameter - * @param importSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - */ - public void importFiles( - String importProject, File srcDir, - String[] includePatterns, String[] excludePatterns, - boolean importClasses, boolean importResources, - boolean importSources, boolean useDefaultExcludes ) - { - try - { - String request = "http://" + remoteServer + "/servlet/vajimport?" - + VAJImportServlet.PROJECT_NAME_PARAM + "=" - + importProject + "&" - + assembleImportExportParams( srcDir, - includePatterns, excludePatterns, - importClasses, importResources, - importSources, useDefaultExcludes ); - sendRequest( request ); - } - catch( Exception ex ) - { - throw new TaskException( "Error", ex ); - } - - } - - /** - * Load specified projects. - * - * @param projectDescriptions Description of Parameter - */ - public void loadProjects( ArrayList projectDescriptions ) - { - try - { - String request = "http://" + remoteServer + "/servlet/vajload?"; - String delimiter = ""; - for( Iterator e = projectDescriptions.iterator(); e.hasNext(); ) - { - VAJProjectDescription pd = (VAJProjectDescription)e.next(); - request = request - + delimiter + VAJLoadServlet.PROJECT_NAME_PARAM - + "=" + pd.getName().replace( ' ', '+' ) - + "&" + VAJLoadServlet.VERSION_PARAM - + "=" + pd.getVersion().replace( ' ', '+' ); - //the first param needs no delimiter, but all other - delimiter = "&"; - } - sendRequest( request ); - } - catch( Exception ex ) - { - throw new TaskException( "Error", ex ); - } - } - - /** - * logs a message. - * - * @param msg Description of Parameter - * @param level Description of Parameter - */ - public void log( String msg, int level ) - { - caller.log( msg, level ); - } - - /** - * Assemble string for parameters common for import and export Helper method - * to remove double code. - * - * @param dir Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param includeClasses Description of Parameter - * @param includeResources Description of Parameter - * @param includeSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - * @return Description of the Returned Value - */ - private String assembleImportExportParams( - File dir, - String[] includePatterns, String[] excludePatterns, - boolean includeClasses, boolean includeResources, - boolean includeSources, boolean useDefaultExcludes ) - { - String result = - VAJToolsServlet.DIR_PARAM + "=" - + dir.getAbsolutePath().replace( '\\', '/' ) + "&" - + VAJToolsServlet.CLASSES_PARAM + "=" + includeClasses + "&" - + VAJToolsServlet.RESOURCES_PARAM + "=" + includeResources + "&" - + VAJToolsServlet.SOURCES_PARAM + "=" + includeSources + "&" - + VAJToolsServlet.DEFAULT_EXCLUDES_PARAM + "=" + useDefaultExcludes; - - if( includePatterns != null ) - { - for( int i = 0; i < includePatterns.length; i++ ) - { - result = result + "&" + VAJExportServlet.INCLUDE_PARAM + "=" - + includePatterns[ i ].replace( ' ', '+' ).replace( '\\', '/' ); - } - } - if( excludePatterns != null ) - { - for( int i = 0; i < excludePatterns.length; i++ ) - { - result = result + "&" + VAJExportServlet.EXCLUDE_PARAM + "=" - + excludePatterns[ i ].replace( ' ', '+' ).replace( '\\', '/' ); - } - } - - return result; - } - - /** - * Sends a servlet request. - * - * @param request Description of Parameter - */ - private void sendRequest( String request ) - { - boolean requestFailed = false; - try - { - getLogger().debug( "Request: " + request ); - - //must be HTTP connection - URL requestUrl = new URL( request ); - HttpURLConnection connection = - (HttpURLConnection)requestUrl.openConnection(); - - InputStream is = null; - // retry three times - for( int i = 0; i < 3; i++ ) - { - try - { - is = connection.getInputStream(); - break; - } - catch( IOException ex ) - { - } - } - if( is == null ) - { - getLogger().error( "Can't get " + request ); - throw new TaskException( "Couldn't execute " + request ); - } - - // log the response - BufferedReader br = new BufferedReader( new InputStreamReader( is ) ); - String line = br.readLine(); - while( line != null ) - { - int level = MSG_ERR; - try - { - // the first char of each line contains the log level - level = Integer.parseInt( line.substring( 0, 1 ) ); - if( level == MSG_ERR ) - { - requestFailed = true; - } - } - catch( Exception e ) - { - getLogger().error( "Response line doesn't contain log level!" ); - } - log( line.substring( 2 ), level ); - line = br.readLine(); - } - - } - catch( IOException ex ) - { - getLogger().error( "Error sending tool request to VAJ" + ex ); - throw new TaskException( "Couldn't execute " + request ); - } - if( requestFailed ) - { - throw new TaskException( "VAJ tool request failed" ); - } - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java deleted file mode 100644 index 362ad0ef9..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJTask.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -/** - * Super class for all VAJ tasks. Contains common attributes (remoteServer) and - * util methods - * - * @author: Wolf Siberski - */ - -import org.apache.tools.ant.Task; - -public class VAJTask extends Task -{ - - // server name / port of VAJ remote tool api server - protected String remoteServer = null; - - // holds the appropriate VAJUtil implementation - private VAJUtil util = null; - - /** - * Set remote server attribute - * - * @param remoteServer The new Remote value - */ - public void setRemote( String remoteServer ) - { - this.remoteServer = remoteServer; - } - - /** - * returns the VAJUtil implementation - * - * @return The Util value - */ - protected VAJUtil getUtil() - { - if( util == null ) - { - if( remoteServer == null ) - { - util = new VAJLocalToolUtil( this ); - } - else - { - util = new VAJRemoteUtil( this, remoteServer ); - } - } - return util; - } - -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java deleted file mode 100644 index 14f54541c..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJToolsServlet.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.apache.avalon.framework.ExceptionUtil; -import org.apache.myrmidon.api.TaskException; - -/** - * Abstract base class to provide common services for the VAJ tool API servlets - * - * @author Wolf Siberski, based on servlets written by Glenn McAllister - */ -public abstract class VAJToolsServlet - extends HttpServlet -{ - // constants for servlet param names - public final static String DIR_PARAM = "dir"; - public final static String INCLUDE_PARAM = "include"; - public final static String EXCLUDE_PARAM = "exclude"; - public final static String CLASSES_PARAM = "cls"; - public final static String SOURCES_PARAM = "src"; - public final static String RESOURCES_PARAM = "res"; - public final static String DEFAULT_EXCLUDES_PARAM = "dex"; - public final static String PROJECT_NAME_PARAM = "project"; - - // current request - HttpServletRequest request; - - // response to current request - HttpServletResponse response; - - // implementation of VAJUtil used by the servlet - VAJUtil util; - - /** - * Respond to a HTTP request. This method initializes the servlet and - * handles errors. The real work is done in the abstract method - * executeRequest() - * - * @param req Description of Parameter - * @param res Description of Parameter - * @exception ServletException Description of Exception - * @exception IOException Description of Exception - */ - public void doGet( HttpServletRequest req, HttpServletResponse res ) - throws ServletException, IOException - { - try - { - response = res; - request = req; - initRequest(); - executeRequest(); - } - catch( TaskException e ) - { - util.getLogger().error( "Error occured: " + e.getMessage() ); - } - catch( Exception e ) - { - try - { - if( !( e instanceof TaskException ) ) - { - String trace = ExceptionUtil.printStackTrace( e ); - util.log( "Program error in " + this.getClass().getName() - + ":\n" + trace, VAJUtil.MSG_ERR ); - } - } - catch( Throwable t ) - { - t.printStackTrace(); - } - finally - { - if( !( e instanceof TaskException ) ) - { - throw new ServletException( e.getMessage() ); - } - } - } - } - - /** - * Get the boolean value of a parameter. - * - * @param param Description of Parameter - * @return The BooleanParam value - */ - protected boolean getBooleanParam( String param ) - { - return getBooleanParam( param, false ); - } - - /** - * Get the boolean value of a parameter, with a default value if the - * parameter hasn't been passed to the servlet. - * - * @param param Description of Parameter - * @param defaultValue Description of Parameter - * @return The BooleanParam value - */ - protected boolean getBooleanParam( String param, boolean defaultValue ) - { - String value = getFirstParamValueString( param ); - if( value != null ) - { - return toBoolean( value ); - } - else - { - return defaultValue; - } - } - - /** - * Returns the first encountered value for a parameter. - * - * @param param Description of Parameter - * @return The FirstParamValueString value - */ - protected String getFirstParamValueString( String param ) - { - String[] paramValuesArray = request.getParameterValues( param ); - if( paramValuesArray == null ) - { - return null; - } - return paramValuesArray[ 0 ]; - } - - /** - * Returns all values for a parameter. - * - * @param param Description of Parameter - * @return The ParamValues value - */ - protected String[] getParamValues( String param ) - { - return request.getParameterValues( param ); - } - - /** - * Execute the request by calling the appropriate VAJ tool API methods. This - * method must be implemented by the concrete servlets - */ - protected abstract void executeRequest(); - - /** - * initialize the servlet. - * - * @exception IOException Description of Exception - */ - protected void initRequest() - throws IOException - { - response.setContentType( "text/ascii" ); - if( util == null ) - { - util = new VAJLocalServletUtil(); - } - } - - /** - * A utility method to translate the strings "yes", "true", and "ok" to - * boolean true, and everything else to false. - * - * @param string Description of Parameter - * @return Description of the Returned Value - */ - protected boolean toBoolean( String string ) - { - String lower = string.toLowerCase(); - return ( lower.equals( "yes" ) || lower.equals( "true" ) || lower.equals( "ok" ) ); - } - - /** - * Get the VAJUtil implementation - * - * @return The Util value - */ - VAJUtil getUtil() - { - return util; - } - - /** - * Adaptation of VAJUtil for servlet context. - */ - class VAJLocalServletUtil - extends VAJLocalUtil - { - public void log( String msg, int level ) - { - try - { - if( msg != null ) - { - msg = msg.replace( '\r', ' ' ); - int i = 0; - while( i < msg.length() ) - { - int nlPos = msg.indexOf( '\n', i ); - if( nlPos == -1 ) - { - nlPos = msg.length(); - } - response.getWriter().println( Integer.toString( level ) - + " " + msg.substring( i, nlPos ) ); - i = nlPos + 1; - } - } - } - catch( IOException e ) - { - throw new TaskException( "logging failed. msg was: " - + e.getMessage() ); - } - } - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java deleted file mode 100644 index 510123375..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJUtil.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import java.io.File; -import java.util.ArrayList; - -/** - * Helper interface for VAJ tasks. Encapsulates the interface to the VAJ tool - * API. - * - * @author Wolf Siberski, TUI Infotec GmbH - */ -interface VAJUtil -{ - // log levels - public final static int MSG_DEBUG = 4; - public final static int MSG_ERR = 0; - public final static int MSG_INFO = 2; - public final static int MSG_VERBOSE = 3; - public final static int MSG_WARN = 1; - - /** - * export the array of Packages - * - * @param dest Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param exportClasses Description of Parameter - * @param exportDebugInfo Description of Parameter - * @param exportResources Description of Parameter - * @param exportSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - * @param overwrite Description of Parameter - */ - void exportPackages( - File dest, - String[] includePatterns, String[] excludePatterns, - boolean exportClasses, boolean exportDebugInfo, - boolean exportResources, boolean exportSources, - boolean useDefaultExcludes, boolean overwrite ); - - /** - * Do the import. - * - * @param importProject Description of Parameter - * @param srcDir Description of Parameter - * @param includePatterns Description of Parameter - * @param excludePatterns Description of Parameter - * @param importClasses Description of Parameter - * @param importResources Description of Parameter - * @param importSources Description of Parameter - * @param useDefaultExcludes Description of Parameter - */ - void importFiles( - String importProject, File srcDir, - String[] includePatterns, String[] excludePatterns, - boolean importClasses, boolean importResources, - boolean importSources, boolean useDefaultExcludes ); - - /** - * Load specified projects. - * - * @param projectDescriptions Description of Parameter - */ - void loadProjects( ArrayList projectDescriptions ); - - /** - * Logs a message with the specified log level. - * - * @param msg Description of Parameter - * @param level Description of Parameter - */ - void log( String msg, int level ); -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java deleted file mode 100644 index d429e467e..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/VAJWorkspaceScanner.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) The Apache Software Foundation. All rights reserved. - * - * This software is published under the terms of the Apache Software License - * version 1.1, a copy of which has been included with this distribution in - * the LICENSE.txt file. - */ -package org.apache.tools.ant.taskdefs.optional.ide; - -import com.ibm.ivj.util.base.IvjException; -import com.ibm.ivj.util.base.Package; -import com.ibm.ivj.util.base.Project; -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.StringTokenizer; -import org.apache.tools.ant.types.DirectoryScanner; -import org.apache.tools.ant.types.ScannerUtil; - -/** - * Class for scanning a Visual Age for Java workspace for packages matching a - * certain criteria.

- * - * These criteria consist of a set of include and exclude patterns. With these - * patterns, you can select which packages you want to have included, and which - * packages you want to have excluded. You can add patterns to be excluded by - * default with the addDefaultExcludes method. The patters that are excluded by - * default include - *

    - *
  • IBM*\**
  • - *
  • Java class libraries\**
  • - *
  • Sun class libraries*\**
  • - *
  • JSP Page Compile Generated Code\**
  • - *
  • VisualAge*\**
  • - *
- *

- * - * This class works like DirectoryScanner. - * - * @author Wolf Siberski, TUI Infotec (based on Arnout J. Kuipers - * DirectoryScanner) - * @see org.apache.tools.ant.DirectoryScanner - */ -class VAJWorkspaceScanner extends DirectoryScanner -{ - - // Patterns that should be excluded by default. - private final static String[] DEFAULTEXCLUDES = - { - "IBM*/**", - "Java class libraries/**", - "Sun class libraries*/**", - "JSP Page Compile Generated Code/**", - "VisualAge*/**", - }; - - // The packages that where found and matched at least - // one includes, and matched no excludes. - private ArrayList packagesIncluded = new ArrayList(); - - /** - * Matches a string against a pattern. The pattern contains two special - * characters: '*' which means zero or more characters, '?' which means one - * and only one character. - * - * @param pattern the (non-null) pattern to match against - * @param str the (non-null) string that must be matched against the pattern - * @return true when the string matches against the pattern, - * false otherwise. - */ - protected static boolean match( String pattern, String str ) - { - return ScannerUtil.match( pattern, str ); - } - - /** - * Get the names of the packages that matched at least one of the include - * patterns, and didn't match one of the exclude patterns. - * - * @return the matching packages - */ - public Package[] getIncludedPackages() - { - int count = packagesIncluded.size(); - Package[] packages = new Package[ count ]; - for( int i = 0; i < count; i++ ) - { - packages[ i ] = (Package)packagesIncluded.get( i ); - } - return packages; - } - - /** - * Adds the array with default exclusions to the current exclusions set. - */ - public void addDefaultExcludes() - { - int excludesLength = getExcludes() == null ? 0 : getExcludes().length; - String[] newExcludes; - newExcludes = new String[ excludesLength + DEFAULTEXCLUDES.length ]; - if( excludesLength > 0 ) - { - System.arraycopy( getExcludes(), 0, newExcludes, 0, excludesLength ); - } - for( int i = 0; i < DEFAULTEXCLUDES.length; i++ ) - { - newExcludes[ i + excludesLength ] = DEFAULTEXCLUDES[ i ]. - replace( '/', File.separatorChar ). - replace( '\\', File.separatorChar ); - } - setExcludes( newExcludes ); - } - - /** - * Finds all Projects specified in include patterns. - * - * @return the projects - */ - public ArrayList findMatchingProjects() - { - Project[] projects = VAJLocalUtil.getWorkspace().getProjects(); - - ArrayList matchingProjects = new ArrayList(); - - boolean allProjectsMatch = false; - for( int i = 0; i < projects.length; i++ ) - { - Project project = projects[ i ]; - for( int j = 0; j < getIncludes().length && !allProjectsMatch; j++ ) - { - StringTokenizer tok = - new StringTokenizer( getIncludes()[ j ], File.separator ); - String projectNamePattern = tok.nextToken(); - if( projectNamePattern.equals( "**" ) ) - { - // if an include pattern starts with '**', - // all projects match - allProjectsMatch = true; - } - else if( match( projectNamePattern, project.getName() ) ) - { - matchingProjects.add( project ); - break; - } - } - } - - if( allProjectsMatch ) - { - matchingProjects = new ArrayList(); - for( int i = 0; i < projects.length; i++ ) - { - matchingProjects.add( projects[ i ] ); - } - } - - return matchingProjects; - } - - /** - * Scans the workspace for packages that match at least one include pattern, - * and don't match any exclude patterns. - */ - public void scan() - { - if( getIncludes() == null ) - { - // No includes supplied, so set it to 'matches all' - setIncludes( new String[ 1 ] ); - getIncludes()[ 0 ] = "**"; - } - if( getExcludes() == null ) - { - setExcludes( new String[ 0 ] ); - } - - // only scan projects which are included in at least one include pattern - ArrayList matchingProjects = findMatchingProjects(); - for( Iterator e = matchingProjects.iterator(); e.hasNext(); ) - { - Project project = (Project)e.next(); - scanProject( project ); - } - } - - /** - * Scans a project for packages that match at least one include pattern, and - * don't match any exclude patterns. - * - * @param project Description of Parameter - */ - public void scanProject( Project project ) - { - try - { - Package[] packages = project.getPackages(); - if( packages != null ) - { - for( int i = 0; i < packages.length; i++ ) - { - Package item = packages[ i ]; - // replace '.' by file seperator because the patterns are - // using file seperator syntax (and we can use the match - // methods this way). - String name = - project.getName() - + File.separator - + item.getName().replace( '.', File.separatorChar ); - if( isIncluded( name ) && !isExcluded( name ) ) - { - packagesIncluded.add( item ); - } - } - } - } - catch( IvjException e ) - { - throw VAJLocalUtil.createTaskException( "VA Exception occured: ", e ); - } - } -} diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/default.ini b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/default.ini deleted file mode 100644 index 1ccb8944f..000000000 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/optional/ide/default.ini +++ /dev/null @@ -1,4 +0,0 @@ -Name=Ant -Version=0.1 -Help-Item=Ant Help,doc/VAJAntTool.html -Menu-Items=Ant Build,org.apache.tools.ant.taskdefs.optional.ide.VAJAntTool,-P;