Merge pull request #639 from ejoerns/pull-req/cooja-plugin-pos
[Cooja] Set location of newly created plugins relative to second last activated plugin
This commit is contained in:
commit
d3b9954342
|
@ -1659,7 +1659,6 @@ public class Cooja extends Observable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nrFrames = myDesktopPane.getAllFrames().length;
|
|
||||||
myDesktopPane.add(pluginFrame);
|
myDesktopPane.add(pluginFrame);
|
||||||
|
|
||||||
/* Set size if not already specified by plugin */
|
/* Set size if not already specified by plugin */
|
||||||
|
@ -1667,11 +1666,9 @@ public class Cooja extends Observable {
|
||||||
pluginFrame.setSize(FRAME_STANDARD_WIDTH, FRAME_STANDARD_HEIGHT);
|
pluginFrame.setSize(FRAME_STANDARD_WIDTH, FRAME_STANDARD_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set location if not already visible */
|
/* Set location if not already set */
|
||||||
if (pluginFrame.getLocation().x <= 0 && pluginFrame.getLocation().y <= 0) {
|
if (pluginFrame.getLocation().x <= 0 && pluginFrame.getLocation().y <= 0) {
|
||||||
pluginFrame.setLocation(
|
pluginFrame.setLocation(determineNewPluginLocation());
|
||||||
nrFrames * FRAME_NEW_OFFSET,
|
|
||||||
nrFrames * FRAME_NEW_OFFSET);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pluginFrame.setVisible(true);
|
pluginFrame.setVisible(true);
|
||||||
|
@ -1690,6 +1687,29 @@ public class Cooja extends Observable {
|
||||||
}.invokeAndWait();
|
}.invokeAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines suitable location for placing new plugin.
|
||||||
|
* <p>
|
||||||
|
* If possible, this is below right of the second last activated
|
||||||
|
* internfal frame (offset is determined by FRAME_NEW_OFFSET).
|
||||||
|
*
|
||||||
|
* @return Resulting placement position
|
||||||
|
*/
|
||||||
|
private Point determineNewPluginLocation() {
|
||||||
|
Point topFrameLoc;
|
||||||
|
JInternalFrame[] iframes = myDesktopPane.getAllFrames();
|
||||||
|
if (iframes.length > 1) {
|
||||||
|
topFrameLoc = iframes[1].getLocation();
|
||||||
|
} else {
|
||||||
|
topFrameLoc = new Point(
|
||||||
|
myDesktopPane.getSize().width / 2,
|
||||||
|
myDesktopPane.getSize().height / 2);
|
||||||
|
}
|
||||||
|
return new Point(
|
||||||
|
topFrameLoc.x + FRAME_NEW_OFFSET,
|
||||||
|
topFrameLoc.y + FRAME_NEW_OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close all mote plugins for given mote.
|
* Close all mote plugins for given mote.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue