home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Languages Suite
/
ProgLangD.iso
/
VCAFE.3.0A
/
Sample.bin
/
ReplaceDialog.java
< prev
next >
Wrap
Text File
|
1999-01-14
|
6KB
|
192 lines
/*
A basic extension of the java.awt.Dialog class
*/
import java.awt.*;
public class ReplaceDialog extends Dialog {
Frame theJavaPadFrame;
public ReplaceDialog(Frame parent, boolean modal)
{
super(parent, modal);
theJavaPadFrame = parent;
// 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(278,107);
setVisible(false);
label1.setText("Find");
add(label1);
label1.setBounds(7,12,28,24);
add(m_findText);
m_findText.setBounds(60,14,124,25);
add(m_replaceText);
m_replaceText.setBounds(60,46,124,25);
label2.setText("Replace");
add(label2);
label2.setBounds(3,47,48,21);
m_caseSencb.setLabel("Case Sensitive");
add(m_caseSencb);
m_caseSencb.setBounds(1,77,113,24);
m_replacebtn.setActionCommand("button");
m_replacebtn.setLabel("Replace");
add(m_replacebtn);
m_replacebtn.setBounds(196,5,66,21);
m_repAllbtn.setActionCommand("button");
m_repAllbtn.setLabel("Replace All");
add(m_repAllbtn);
m_repAllbtn.setBounds(196,42,66,21);
m_cancelbtn.setActionCommand("button");
m_cancelbtn.setLabel("Cancel");
add(m_cancelbtn);
m_cancelbtn.setBounds(196,79,66,21);
setTitle("Dialog2");
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
m_replacebtn.addActionListener(lSymAction);
m_repAllbtn.addActionListener(lSymAction);
m_cancelbtn.addActionListener(lSymAction);
//}}
}
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;
}
// Used for addNotify check.
boolean fComponentsAdjusted = false;
public ReplaceDialog(Frame parent, String title, boolean modal, FindReplace fr)
{
this(parent, modal);
setTitle(title);
m_replace = fr;
m_findText.setText(m_replace.getFind());
m_replaceText.setText(m_replace.getReplace());
m_caseSencb.setState(m_replace.isCase());
}
//{{DECLARE_CONTROLS
java.awt.Label label1 = new java.awt.Label();
java.awt.TextField m_findText = new java.awt.TextField();
java.awt.TextField m_replaceText = new java.awt.TextField();
java.awt.Label label2 = new java.awt.Label();
java.awt.Checkbox m_caseSencb = new java.awt.Checkbox();
java.awt.Button m_replacebtn = new java.awt.Button();
java.awt.Button m_repAllbtn = new java.awt.Button();
java.awt.Button m_cancelbtn = new java.awt.Button();
//}}
FindReplace m_replace;
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == ReplaceDialog.this)
ReplaceDialog_WindowClosing(event);
}
}
void ReplaceDialog_WindowClosing(java.awt.event.WindowEvent event)
{
ReplaceDialog_WindowClosing_Interaction1(event);
}
void ReplaceDialog_WindowClosing_Interaction1(java.awt.event.WindowEvent event)
{
try {
this.dispose();
} catch (Exception e) {
}
}
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
if (object == m_replacebtn)
mReplacebtn_ActionPerformed(event);
else if (object == m_repAllbtn)
mRepAllbtn_ActionPerformed(event);
else if (object == m_cancelbtn)
mCancelbtn_ActionPerformed(event);
}
}
void mReplacebtn_ActionPerformed(java.awt.event.ActionEvent event)
{
m_replace.setReplace(m_replaceText.getText().trim());
m_replace.setFind(m_findText.getText().trim());
m_replace.setCase(m_caseSencb.getState());
m_replace.setReplaceAll(false);
m_replace.setReplaceIt(false);
m_replace.setIndex(m_replace.getBody().getSelectionStart());
dispose();
try{Thread.sleep(250);}catch(InterruptedException ie){}
(new ReplaceConfirmDialog(theJavaPadFrame, "Replace Confirm", true, m_replace)).show();
}
void mRepAllbtn_ActionPerformed(java.awt.event.ActionEvent event)
{
FindReplaceEngine fre;
fre = new FindReplaceEngine(m_replace);
m_replace.setReplace(m_replaceText.getText());
m_replace.setFind(m_findText.getText());
m_replace.setReplaceAll(true);
m_replace.setReplaceIt(true);
m_replace.setCase(m_caseSencb.getState());
dispose();
fre.ReplaceAll();
}
void mCancelbtn_ActionPerformed(java.awt.event.ActionEvent event)
{
mCancelbtn_ActionPerformed_Interaction1(event);
}
void mCancelbtn_ActionPerformed_Interaction1(java.awt.event.ActionEvent event)
{
try {
this.dispose();
} catch (Exception e) {
}
}
}