aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin/desktoputil
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2015-04-03 12:51:30 +0300
committerDamian Minkov <damencho@jitsi.org>2015-04-03 12:51:30 +0300
commitc89234744b6dc5ca45cf8e0ebf91b2565317be2a (patch)
tree7df182f7940103bcdcf67078df8022ba59b26fc1 /src/net/java/sip/communicator/plugin/desktoputil
parentc9bf2f4b04007c5ad30b3b79515d23bb38b7803a (diff)
downloadjitsi-c89234744b6dc5ca45cf8e0ebf91b2565317be2a.zip
jitsi-c89234744b6dc5ca45cf8e0ebf91b2565317be2a.tar.gz
jitsi-c89234744b6dc5ca45cf8e0ebf91b2565317be2a.tar.bz2
Saves only the call dialog location, skipping the size. And restores it if available.
Diffstat (limited to 'src/net/java/sip/communicator/plugin/desktoputil')
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/SIPCommDialog.java2
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/SIPCommFrame.java124
2 files changed, 80 insertions, 46 deletions
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/SIPCommDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/SIPCommDialog.java
index d787ee4..b81d39b 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/SIPCommDialog.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/SIPCommDialog.java
@@ -262,7 +262,7 @@ public class SIPCommDialog
{
try
{
- SIPCommFrame.saveSizeAndLocation(this);
+ SIPCommFrame.saveSizeAndLocation(this, true, true);
}
catch (ConfigPropertyVetoException e1)
{
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/SIPCommFrame.java b/src/net/java/sip/communicator/plugin/desktoputil/SIPCommFrame.java
index 24b862a..58a74fb 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/SIPCommFrame.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/SIPCommFrame.java
@@ -71,10 +71,16 @@ public class SIPCommFrame
private KeybindingSet bindings = null;
/**
- * Indicates if the size and location of this dialog are stored after
+ * Indicates if the size of this dialog is stored after
* closing. By default we store window size and location.
*/
- private boolean isSaveSizeAndLocation = true;
+ private boolean saveSize = true;
+
+ /**
+ * Indicates if the location of this dialog is stored after
+ * closing. By default we store window size and location.
+ */
+ private boolean saveLocation = true;
/**
* Creates a <tt>SIPCommFrame</tt>.
@@ -166,14 +172,28 @@ public class SIPCommFrame
* 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
+ * @param saveSizeAndLocation indicates whether to save the size and
+ * location of this dialog
+ */
+ public SIPCommFrame(boolean saveSizeAndLocation)
+ {
+ this(saveSizeAndLocation, saveSizeAndLocation);
+ }
+
+ /**
+ * 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 saveLocation indicates whether to save the
* location of this dialog
+ * @param saveSize indicates whether to save the size of this dialog
*/
- public SIPCommFrame(boolean isSaveSizeAndLocation)
+ public SIPCommFrame(boolean saveLocation, boolean saveSize)
{
this();
- this.isSaveSizeAndLocation = isSaveSizeAndLocation;
+ this.saveLocation = saveLocation;
+ this.saveSize = saveSize;
}
/**
@@ -189,7 +209,7 @@ public class SIPCommFrame
public void actionPerformed(ActionEvent e)
{
- if (isSaveSizeAndLocation)
+ if (saveLocation || saveSize)
saveSizeAndLocation();
close(false);
}
@@ -208,7 +228,7 @@ public class SIPCommFrame
public void actionPerformed(ActionEvent e)
{
- if (isSaveSizeAndLocation)
+ if (saveLocation || saveSize)
saveSizeAndLocation();
close(true);
}
@@ -278,7 +298,7 @@ public class SIPCommFrame
* Before closing the application window save the current size and
* position through the ConfigurationService.
*/
- if(isSaveSizeAndLocation)
+ if(saveLocation || saveSize)
saveSizeAndLocation();
close(false);
@@ -302,7 +322,7 @@ public class SIPCommFrame
{
try
{
- saveSizeAndLocation(this);
+ saveSizeAndLocation(this, saveSize, saveLocation);
}
catch (ConfigPropertyVetoException e)
{
@@ -323,17 +343,26 @@ public class SIPCommFrame
* does not accept the saving because of objections from its
* <tt>PropertyVetoListener</tt>s.
*/
- static void saveSizeAndLocation(Component component)
+ static void saveSizeAndLocation(Component component,
+ boolean saveSize,
+ boolean saveLocation)
throws ConfigPropertyVetoException
{
Map<String, Object> props = new HashMap<String, Object>();
String className
= component.getClass().getName().replaceAll("\\$", "_");
- props.put(className + ".width", component.getWidth());
- props.put(className + ".height", component.getHeight());
- props.put(className + ".x", component.getX());
- props.put(className + ".y", component.getY());
+ if(saveSize)
+ {
+ props.put(className + ".width", component.getWidth());
+ props.put(className + ".height", component.getHeight());
+ }
+
+ if(saveLocation)
+ {
+ props.put(className + ".x", component.getX());
+ props.put(className + ".y", component.getY());
+ }
DesktopUtilActivator.getConfigurationService().setProperties(props);
}
@@ -342,7 +371,7 @@ public class SIPCommFrame
*/
public void setSizeAndLocation()
{
- if (!isSaveSizeAndLocation)
+ if (!(saveLocation || saveSize))
{
return;
}
@@ -350,48 +379,53 @@ public class SIPCommFrame
ConfigurationService configService =
DesktopUtilActivator.getConfigurationService();
String className = this.getClass().getName();
- String widthString = configService.getString(className + ".width");
- String heightString = configService.getString(className + ".height");
- String xString = configService.getString(className + ".x");
- String yString = configService.getString(className + ".y");
- int width = 0;
- int height = 0;
-
- if (widthString != null && heightString != null)
+ if(saveSize)
{
- width = Integer.parseInt(widthString);
- height = Integer.parseInt(heightString);
+ String widthString
+ = configService.getString(className + ".width");
+ String heightString
+ = configService.getString(className + ".height");
- if (width > 0 && height > 0)
+ if(widthString != null && heightString != null)
{
- Dimension screenSize =
- Toolkit.getDefaultToolkit().getScreenSize();
- if (width <= screenSize.width && height <= screenSize.height)
- this.setSize(width, height);
+ int width = Integer.parseInt(widthString);
+ int height = Integer.parseInt(heightString);
+
+ if(width > 0 && height > 0)
+ {
+ Dimension screenSize =
+ Toolkit.getDefaultToolkit().getScreenSize();
+ if(width <= screenSize.width && height <= screenSize.height)
+ this.setSize(width, height);
+ }
}
}
- int x = 0;
- int y = 0;
-
- if (xString != null && yString != null)
+ if(saveLocation)
{
- x = Integer.parseInt(xString);
- y = Integer.parseInt(yString);
+ String xString = configService.getString(className + ".x");
+ String yString = configService.getString(className + ".y");
- if(ScreenInformation.
- isTitleOnScreen(new Rectangle(x, y, width, height))
- || configService.getBoolean(
+ if(xString != null && yString != null)
+ {
+ int x = Integer.parseInt(xString);
+ int y = Integer.parseInt(yString);
+
+ if(ScreenInformation.
+ isTitleOnScreen(
+ new Rectangle(x, y, this.getWidth(), this.getHeight()))
+ || configService.getBoolean(
SIPCommFrame.PNAME_CALCULATED_POSITIONING, true))
+ {
+ this.setLocation(x, y);
+ }
+ }
+ else
{
- this.setLocation(x, y);
+ this.setCenterLocation();
}
}
- else
- {
- this.setCenterLocation();
- }
}
/**
@@ -575,7 +609,7 @@ public class SIPCommFrame
@Override
public void dispose()
{
- if (isSaveSizeAndLocation)
+ if (saveLocation || saveSize)
saveSizeAndLocation();
/*