Added a SIPCommFrame constructor indicating if we should save size and location. Added some javadoc comments.

cusax-fix
Yana Stamcheva 16 years ago
parent e2c20d0644
commit dd91828b7d

@ -28,11 +28,25 @@ public abstract class SIPCommDialog
*/
private static final Logger logger = Logger.getLogger(SIPCommDialog.class);
/**
* The action map of this dialog.
*/
private ActionMap amap;
/**
* The input map of this dialog.
*/
private InputMap imap;
/**
* Indicates if the size and location of this dialog are stored after
* closing.
*/
private boolean isSaveSizeAndLocation = true;
/**
* Creates an instance of <tt>SIPCommDialog</tt>.
*/
public SIPCommDialog()
{
super();
@ -40,13 +54,23 @@ public SIPCommDialog()
this.init();
}
/**
* Creates an instance of <tt>SIPCommDialog</tt> by specifying the
* <tt>Dialog</tt>owner of this dialog.
* @param owner the owner of this dialog
*/
public SIPCommDialog(Dialog owner)
{
super(owner);
this.init();
}
/**
* Creates an instance of <tt>SIPCommDialog</tt> by specifying the
* <tt>Frame</tt> owner.
* @param owner the owner of this dialog
*/
public SIPCommDialog(Frame owner)
{
super(owner);
@ -54,6 +78,13 @@ public SIPCommDialog(Frame owner)
this.init();
}
/**
* Creates an instance of <tt>SIPCommDialog</tt> by specifying explicitly
* if the size and location properties are saved. By default size and
* location are stored.
* @param isSaveSizeAndLocation indicates whether to save the size and
* location of this dialog
*/
public SIPCommDialog(boolean isSaveSizeAndLocation)
{
this();
@ -61,6 +92,14 @@ public SIPCommDialog(boolean isSaveSizeAndLocation)
this.isSaveSizeAndLocation = isSaveSizeAndLocation;
}
/**
* Creates an instance of <tt>SIPCommDialog</tt> by specifying the owner
* of this dialog and indicating whether to save the size and location
* properties.
* @param owner the owner of this dialog
* @param isSaveSizeAndLocation indicates whether to save the size and
* location of this dialog
*/
public SIPCommDialog(Dialog owner, boolean isSaveSizeAndLocation)
{
this(owner);
@ -68,6 +107,14 @@ public SIPCommDialog(Dialog owner, boolean isSaveSizeAndLocation)
this.isSaveSizeAndLocation = isSaveSizeAndLocation;
}
/**
* Creates an instance of <tt>SIPCommDialog</tt> by specifying the owner
* of this dialog and indicating whether to save the size and location
* properties.
* @param owner the owner of this dialog
* @param isSaveSizeAndLocation indicates whether to save the size and
* location of this dialog
*/
public SIPCommDialog(Frame owner, boolean isSaveSizeAndLocation)
{
this(owner);
@ -112,7 +159,7 @@ public void actionPerformed(ActionEvent e)
close(true);
}
}
/**
* Adds a key - action pair for this frame.
*
@ -135,6 +182,10 @@ protected void addKeyBinding(KeyStroke keyStroke, Action action)
*/
public class DialogWindowAdapter extends WindowAdapter
{
/**
* Invoked when this window is in the process of being closed.
* @param e the <tt>WindowEvent</tt> that notified us
*/
public void windowClosing(WindowEvent e)
{
if(isSaveSizeAndLocation)
@ -160,7 +211,7 @@ private void saveSizeAndLocation()
+ "represents an unacceptable value");
}
}
/**
* Sets window size and position.
*/
@ -168,7 +219,7 @@ private void setSizeAndLocation()
{
ConfigurationService config = UtilActivator.getConfigurationService();
String className = this.getClass().getName().replaceAll("\\$", "_");
int width = config.getInt(className + ".width", 0);
int height = config.getInt(className + ".height", 0);
@ -177,7 +228,7 @@ private void setSizeAndLocation()
if(width > 0 && height > 0)
this.setSize(width, height);
if(xString != null && yString != null)
this.setLocation(
Integer.parseInt(xString),
@ -197,7 +248,7 @@ private void setCenterLocation()
screenSize.width/2 - this.getWidth()/2,
screenSize.height/2 - this.getHeight()/2);
}
/**
* Checks whether the current component will
* exceeds the screen size and if it do will set a default size
@ -206,7 +257,7 @@ private void ensureOnScreenLocationAndSize()
{
int x = this.getX();
int y = this.getY();
int width = this.getWidth();
int height = this.getHeight();
@ -307,13 +358,14 @@ private void ensureOnScreenLocationAndSize()
this.setLocation(x, y);
}
}
/**
* Overwrites the setVisible method in order to set the size and the
* position of this window before showing it.
* @param isVisible indicates if the dialog should be visible
*/
public void setVisible(boolean isVisible)
{
{
if(isVisible)
{
this.pack();
@ -333,10 +385,9 @@ public void setVisible(boolean isVisible)
if(button != null)
button.requestFocus();
}
super.setVisible(isVisible);
}
/**
* Overwrites the dispose method in order to save the size and the position
* of this window before closing it.
@ -345,13 +396,15 @@ public void dispose()
{
if(isSaveSizeAndLocation)
this.saveSizeAndLocation();
super.dispose();
}
/**
* All functions implemented in this method will be invoked when user
* presses the Escape key.
* presses the Escape key.
* @param isEscaped indicates if this dialog has been closed by pressing
* the Esc key
*/
protected abstract void close(boolean isEscaped);
}

@ -30,22 +30,39 @@ public abstract class SIPCommFrame
extends JFrame
implements Observer
{
/**
* The <tt>Logger</tt> used by the <tt>SIPCommFrame</tt> class and its
* instances for logging output.
*/
private static final Logger logger = Logger.getLogger(SIPCommFrame.class);
private static final String SIP_COMMUNICATOR_LOGO =
"service.gui.SIP_COMMUNICATOR_LOGO";
/**
* The logo icon.
*/
private static final String SIP_COMMUNICATOR_LOGO
= "service.gui.SIP_COMMUNICATOR_LOGO";
private final ActionMap amap;
/**
* The action map of this dialog.
*/
private ActionMap amap;
private final InputMap imap;
/**
* The input map of this dialog.
*/
private InputMap imap;
/**
* The key bindings set.
*/
private KeybindingSet bindings = null;
/**
* Indicates if the size and location of this dialog are stored after
* closing. By default we store window size and location.
*/
private boolean isSaveSizeAndLocation = true;
/**
* Creates a <tt>SIPCommFrame</tt>.
*/
@ -65,8 +82,22 @@ public SIPCommFrame()
amap = rootPane.getActionMap();
amap.put("close", new CloseAction());
imap
= rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
imap = rootPane.getInputMap(
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}
/**
* Creates an instance of <tt>SIPCommFrame</tt> by specifying explicitly
* if the size and location properties are saved. By default size and
* location are stored.
* @param isSaveSizeAndLocation indicates whether to save the size and
* location of this dialog
*/
public SIPCommFrame(boolean isSaveSizeAndLocation)
{
this();
this.isSaveSizeAndLocation = isSaveSizeAndLocation;
}
/**
@ -77,7 +108,8 @@ private class CloseAction
{
public void actionPerformed(ActionEvent e)
{
saveSizeAndLocation();
if (isSaveSizeAndLocation)
saveSizeAndLocation();
close(true);
}
}
@ -136,8 +168,7 @@ public void windowClosing(WindowEvent e)
/**
* Invoked when this window is in the process of being closed. The close
* operation can be overridden at this point.
*
* @param e
* @param e the <tt>WindowEvent</tt> that notified us
*/
protected void windowClosing(WindowEvent e)
{
@ -145,7 +176,8 @@ protected void windowClosing(WindowEvent e)
* Before closing the application window save the current size and
* position through the ConfigurationService.
*/
saveSizeAndLocation();
if(isSaveSizeAndLocation)
saveSizeAndLocation();
close(false);
}
@ -368,6 +400,7 @@ else if (y > virtualBounds.y)
/**
* Overwrites the setVisible method in order to set the size and the
* position of this window before showing it.
* @param isVisible indicates if this frame should be visible
*/
public void setVisible(boolean isVisible)
{
@ -413,7 +446,8 @@ public void setVisible(boolean isVisible, boolean isPackEnabled)
*/
public void dispose()
{
this.saveSizeAndLocation();
if (isSaveSizeAndLocation)
this.saveSizeAndLocation();
/*
* The keybinding service will outlive us so don't let us retain our
@ -433,7 +467,8 @@ private void resetInputMap()
/**
* Listens for changes in binding sets so they can be reflected in the input
* map
* map.
* @param obs the <tt>KeybindingSet</tt> from which to update
*/
public void update(Observable obs, Object arg)
{
@ -450,6 +485,9 @@ public void update(Observable obs, Object arg)
}
}
/**
* The main content pane.
*/
public static class MainContentPane
extends JPanel
{
@ -465,6 +503,9 @@ public static class MainContentPane
private TexturePaint texture = null;
/**
* Creates an instance of <tt>MainContentPane</tt>.
*/
public MainContentPane()
{
super(new BorderLayout());
@ -517,6 +558,10 @@ public MainContentPane()
}
}
/**
* Paints this content pane.
* @param g the <tt>Graphics</tt> object used for painting
*/
public void paintComponent(Graphics g)
{
super.paintComponent(g);
@ -537,6 +582,11 @@ public void paintComponent(Graphics g)
}
}
/**
* Provides a custom paint if the color or image background properties
* are enabled.
* @param g the <tt>Graphics</tt> object used for painting
*/
private void internalPaintComponent(Graphics g)
{
AntialiasingManager.activateAntialiasing(g);
@ -573,6 +623,8 @@ private void internalPaintComponent(Graphics g)
/**
* All functions implemented in this method will be invoked when user
* presses the Escape key.
* @param isEscaped indicates if this frame has been closed by pressing the
* Esc key
*/
protected abstract void close(boolean isEscaped);
}

Loading…
Cancel
Save