home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Sample.bin
/
AnalyzeDialog.java
< prev
next >
Wrap
Text File
|
1998-11-05
|
9KB
|
278 lines
// Copyright (c) 1997, 1998 Symantec, Inc. All Rights Reserved.
import java.awt.*;
import symantec.itools.multimedia.ImageViewer;
import symantec.itools.awt.WrappingLabel;
import symantec.itools.awt.util.ProgressBar;
/**
* This dialog added to this project by dragging a Dialog form component into the
* project.
* It was then customized with Cafe's visual tools, including the Interaction
* Wizard.
* Then it was manually customized a small amount to implement the
* TrackProgress interface (that code is at the start of the class), and to
* start and stop the Analyzer thread.
* <p>
* When this dialog opens, it automatically starts the thread that reads and
* analyzes the appropriate log file. The analyzer thread ends when its done
* with the log or the user presses Cancel or closes the dialog.
*/
public class AnalyzeDialog extends Dialog implements TrackProgress {
// Custom fields
Analyzer analyzer;
// -- INTERFACE IMPLEMENTATION: TrackProgress
/**
A TrackProgress interface method.
This method is called to update the message and progressBar that
keeps the user informed of the thread's progress
*/
public void step(String stepMsg, int progressPercent) {
stepText.setText(stepMsg);
try {
stepProgressBar.setValue(progressPercent);
} catch(java.beans.PropertyVetoException x) {
}
}
/**
A TrackProgress interface method.
This method is called when the thread is done.
Often the dialog will switch a "Cancel" button to an "OK" button.
Before calling this method, the thread calls the step method with
a "done 100%" status.
*/
public void done() {
okCancelButton.setLabel("Done");
}
/**
A TrackProgress interface method.
This method is called to display an "OK or Cancel" alert dialog.
It returns true if the alert was OK'd.
*/
public boolean okCancelAlert(String msg) {
// Show alert
new AlertDialog((Frame)getParent(), msg);
// Return true if OKd
return WebLogAnalyzer.theWLA.alertOKd;
}
/**
A TrackProgress interface method.
This method is called to display an Alert Dialog with only an OK button.
*/
public void okAlert(String msg) {
new AlertDialog((Frame)getParent(), false, msg);
}
// -- Standard dialog code
/**
* Constructs this dialog.
* Initializes components the components.
* Registers component listeners.
* All of the code in this routine are automatically generated/maintained
* by Visual Cafe.
*/
public AnalyzeDialog(Frame parent, boolean modal)
{
super(parent, modal);
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setBackground(java.awt.Color.lightGray);
setSize(434,305);
setVisible(false);
okCancelButton.setLabel("Cancel");
add(okCancelButton);
okCancelButton.setBounds(355,253,66,27);
try {
imageViewer1.setImageURL(symantec.itools.net.RelativeURL.getURL("images/wl-inprogress.gif"));
}
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
try {
imageViewer1.setStyle(symantec.itools.multimedia.ImageViewer.IMAGE_NORMAL);
}
catch(java.beans.PropertyVetoException e) { }
add(imageViewer1);
imageViewer1.setBounds(187,2,245,170);
titleLabel1.setText("Web Log Analysis");
add(titleLabel1);
titleLabel1.setFont(new Font("Dialog", Font.PLAIN, 18));
titleLabel1.setBounds(14,32,157,33);
titleLabel2.setText("In Progress...");
add(titleLabel2);
titleLabel2.setFont(new Font("Dialog", Font.PLAIN, 18));
titleLabel2.setBounds(14,59,157,33);
stepText.setText("Initializing");
add(stepText);
stepText.setBounds(14,166,162,21);
try {
stepProgressBar.setBevelStyle(symantec.itools.awt.util.ProgressBar.BEVEL_RAISED);
}
catch(java.beans.PropertyVetoException e) { }
add(stepProgressBar);
stepProgressBar.setBounds(14,211,396,28);
stepLabel.setText("Step:");
add(stepLabel);
stepLabel.setFont(new Font("Dialog", Font.BOLD, 12));
stepLabel.setBounds(14,141,162,21);
setTitle("Analyze Dialog");
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
okCancelButton.addActionListener(lSymAction);
//}}
// Center this dialog within its parent's bounds
WLAUtil.centerInParent(this);
}
/**
* Constructs this Dialog with the given title.
* This routine was automatically generated by Visual Cafe, and is not
* actually used.
*/
public AnalyzeDialog(Frame parent, String title, boolean modal)
{
this(parent, modal);
setTitle(title);
}
/**
* Tells this component that it has been added to a container.
* This is a standard Java AWT method which gets called by the AWT when
* this component is added to a container.
* Typically, it is used to create this component's peer. <br>
* It has been OVERRIDDEN here to adjust the position of components as needed
* for the container's insets. <br>
* This method is automatically generated by Visual Cafe.
*/
public void addNotify()
{
// Record the size of the window prior to calling parents addNotify.
Dimension d = getSize();
super.addNotify();
if (fComponentsAdjusted)
return;
// Adjust components according to the insets
Insets insets = getInsets();
setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
Component components[] = getComponents();
for (int i = 0; i < components.length; i++)
{
Point p = components[i].getLocation();
p.translate(insets.left, insets.top);
components[i].setLocation(p);
}
fComponentsAdjusted = true;
}
//{{DECLARE_CONTROLS
java.awt.Button okCancelButton = new java.awt.Button();
symantec.itools.multimedia.ImageViewer imageViewer1 = new symantec.itools.multimedia.ImageViewer();
java.awt.Label titleLabel1 = new java.awt.Label();
java.awt.Label titleLabel2 = new java.awt.Label();
java.awt.Label stepText = new java.awt.Label();
symantec.itools.awt.util.ProgressBar stepProgressBar = new symantec.itools.awt.util.ProgressBar();
java.awt.Label stepLabel = new java.awt.Label();
//}}
// Used for addNotify redundency check.
boolean fComponentsAdjusted = false;
/**
* This is an event listener created by Visual Cafe to handle WindowEvents.
*/
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowOpened(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == AnalyzeDialog.this)
AnalyzeDialog_WindowOpen(event);
}
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == AnalyzeDialog.this)
AnalyzeDialog_WindowClosing(event);
}
}
/**
* Handles the WINDOW_OPENING WindowEvent.
* It was created by the Interaction Wizard.
* The specified CONNECTION was replaced by code to start the analyzer.
*/
void AnalyzeDialog_WindowOpen(java.awt.event.WindowEvent event)
{
// Create and run the analyzer
analyzer = new Analyzer(this);
analyzer.start();
}
/**
* Handles the WINDOW_CLOSING WindowEvent.
* This method is automatically added when the Dialog form was added to
* this project.
*/
void AnalyzeDialog_WindowClosing(java.awt.event.WindowEvent event)
{
// Stop the analyzer
Analyzer.cancel(analyzer);
// get rid of this dialog
dispose();
}
/**
* This is an event listener created by Visual Cafe to handle ActionEvents.
* It was created by the Interaction Wizard.
*/
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == okCancelButton)
okCancelButton_Clicked(event);
}
}
/**
* This handles the ActionEvent generated by the okCancel button.
* It was created by the Interaction Wizard.
*/
void okCancelButton_Clicked(java.awt.event.ActionEvent event)
{
// Stop the analyzer
Analyzer.cancel(analyzer);
// Get main program
WebLogAnalyzer wla = (WebLogAnalyzer)getParent();
wla.updateCurrentReportInList();
//{{CONNECTION
// Clicked from cancelButton Hide the Dialog
setVisible(false);
//}}
}
}