001: /*
002: * Copyright (c) 2001-2007, Jean Tessier
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions
007: * are met:
008: *
009: * * Redistributions of source code must retain the above copyright
010: * notice, this list of conditions and the following disclaimer.
011: *
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: *
016: * * Neither the name of Jean Tessier nor the names of his contributors
017: * may be used to endorse or promote products derived from this software
018: * without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
021: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
022: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
023: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
024: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
027: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
028: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
029: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031: */
032:
033: package com.jeantessier.dependencyfinder.gui;
034:
035: import java.awt.event.*;
036: import java.util.*;
037:
038: import javax.swing.*;
039:
040: import org.apache.oro.text.perl.*;
041:
042: public class AllQueriesAction extends AbstractAction implements
043: Runnable {
044: private DependencyFinder model = null;
045:
046: public AllQueriesAction(DependencyFinder model) {
047: this .model = model;
048:
049: putValue(Action.LONG_DESCRIPTION,
050: "Compute graph, closure, and metrics");
051: putValue(Action.NAME, "Compute All");
052: putValue(Action.SMALL_ICON, new ImageIcon(getClass()
053: .getResource("icons/all-queries.gif")));
054: }
055:
056: public void actionPerformed(ActionEvent e) {
057: new Thread(this ).start();
058: }
059:
060: public void run() {
061: try {
062: model.getStatusLine()
063: .showInfo("Processing all queries ...");
064:
065: Date start = new Date();
066:
067: model.clearDependencyResult();
068: model.clearClosureResult();
069: model.clearMetricsResult();
070:
071: model.getStatusLine().showInfo(
072: "Processing dependency query ...");
073: model.doDependencyQuery();
074: model.getStatusLine().showInfo(
075: "Processing closure query ...");
076: model.doClosureQuery();
077: model.getStatusLine().showInfo(
078: "Processing metrics query ...");
079: model.doMetricsQuery();
080:
081: Date stop = new Date();
082:
083: model
084: .getStatusLine()
085: .showInfo(
086: "Done ("
087: + ((stop.getTime() - start
088: .getTime()) / (double) 1000)
089: + " secs).");
090: } catch (MalformedPerl5PatternException ex) {
091: JOptionPane.showMessageDialog(model, ex.getMessage(),
092: "Malformed pattern", JOptionPane.ERROR_MESSAGE);
093: model.getStatusLine().showInfo("Ready.");
094: } catch (Exception ex) {
095: JOptionPane.showMessageDialog(model, ex.getMessage(),
096: "Error", JOptionPane.ERROR_MESSAGE);
097: model.getStatusLine().showInfo("Ready.");
098: }
099: }
100: }
|