Package nz.co.abrahams.asithappens.uiutil

Examples of nz.co.abrahams.asithappens.uiutil.ProgressBar


    /** Creates a new flow graph. */
    private void flowGraphButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_flowGraphButtonActionPerformed
        String fileName;
        FlowOptions options;
        PacketTraceLoadTask task;
        ProgressBar progressBar;
        FlowData data;
        TimeSeriesContext context;
        DataGraph graphFrame;
        SimpleDateFormat dateFormat;
        long fromDate;
        long toDate;
       
        try {
            fileName = fileField.getText();
            dateFormat = new SimpleDateFormat("dd/MM/yyyy H:mm:ss");
            fromDate = dateFormat.parse(fromDateField.getText() + " " + fromTimeField.getText()).getTime();
            toDate = dateFormat.parse(toDateField.getText() + " " + toTimeField.getText()).getTime();
           
            options = new FlowOptions(ipProtocolCheckBox.isSelected(), sourceAddressCheckBox.isSelected(),
                    destinationAddressCheckBox.isSelected(), false, sourcePortCheckBox.isSelected(), destinationPortCheckBox.isSelected());
           
            // create an asynchronous thread to fetch data while freeing up GUI
            task = new PacketTraceLoadTask(this, fileName, fromDate, toDate, options);
            progressBar = new ProgressBar("Reading capture file", "Graph title: Packet capture for " + fileName, task);
           
            // Can block event dispatch thread for a long time
            /*
            data = new FlowData(fileField.getText(), "Flow Graph", DataSets.DIRECTION_NONE, fromDate, toDate, options);
            context = new TimeSeriesContext(data, TimeSeriesContext.ABSOLUTE_BOUNDARIES,
View Full Code Here


    /** Displays a graph based on stored information. */
    private void graphButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_graphButtonActionPerformed

        JOptionPane errorDialog;
        DataSetsLoadTask task;
        ProgressBar progressBar;
        DataSetsDAO dataSetsDAO;
        int sessionID;
        TimeSeriesContext.Aggregation aggregation;
        TimeSeriesContext.Interpolation interpolation;
        SimpleDateFormat dateFormat;
        SimpleDateFormat timeFormat;
        long sessionStartTime;
        long sessionFinishTime;
        long fromDate;
        long toDate;
        String graphTitle;
       
        sessionID = getSessionID();
        if ( sessionID == -1 )
            return;
       
        if ( ((JTable)(sessionsPane.getViewport().getView())).getSelectedRowCount() > 1 ) {
            errorDialog = new JOptionPane();
            errorDialog.showMessageDialog(this, "Please select a single session for graph display", "Multiple sessions selected", JOptionPane.ERROR_MESSAGE);
            return;
        }
       
        try {
            dataSetsDAO = DAOFactory.getDataSetsDAO();
           
            aggregation = TimeSeriesContext.Aggregation.values()[aggregationCombo.getSelectedIndex()];
            interpolation = TimeSeriesContext.Interpolation.values()[interpolationCombo.getSelectedIndex()];
            //dataTypeID = dba.getDataTypeID(sessionID);
           
            dateFormat = new SimpleDateFormat("dd/MM/yyyy H:mm:ss");
            fromDate = dateFormat.parse(fromDateField.getText() + " " + fromTimeField.getText()).getTime();
            toDate = dateFormat.parse(toDateField.getText() + " " + toTimeField.getText()).getTime();
            sessionStartTime = dataSetsDAO.retrieveSessionStartTime(sessionID);
            sessionFinishTime = dataSetsDAO.retrieveSessionFinishTime(sessionID);
            logger.debug("Creating session from " + fromDate + " to " + toDate);
           
            if ( fromDate < sessionStartTime - 1000 ) {
                errorDialog = new JOptionPane();
                errorDialog.showMessageDialog(this, "The \'From\' date/time must be within the session interval", "Can't display graph", JOptionPane.ERROR_MESSAGE);
                return;
            }
            if ( toDate > sessionFinishTime ) {
                errorDialog = new JOptionPane();
                errorDialog.showMessageDialog(this, "The \'To\' date/time must be within the session interval", "Can't display graph", JOptionPane.ERROR_MESSAGE);
                return;
            }
            if ( fromDate >= toDate ) {
                errorDialog = new JOptionPane();
                errorDialog.showMessageDialog(this, "The \'From\' date/time must be less than the \'To\' date/time", "Can't display graph", JOptionPane.ERROR_MESSAGE);
                return;
            }
           
            // Old - large blocking call to fetch data that freezes GUI
            //dataSets = new DataSets(sessionID, fromDate, toDate, aggregation);
           
            // Instead create an asynchronous thread to fetch data while freeing up GUI
            task = new DataSetsLoadTask(this, sessionID, fromDate, toDate, aggregation, interpolation);
            graphTitle = ((String)(((JTable)(sessionsPane.getViewport().getView())).getModel().getValueAt(getSelectedRow(), 0)));
            progressBar = new ProgressBar("Retrieving data", "Graph title: " + graphTitle, task);
           
        } catch (ParseException e) {
            ErrorHandler.modalError(this, "Unable to interpret given dates and times", "Can't display graph", e);
        } catch (DBException e) {
            ErrorHandler.modalError(this, "Cannot retrieve data from database", "Please check database connectivity", e);
View Full Code Here

TOP

Related Classes of nz.co.abrahams.asithappens.uiutil.ProgressBar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.