added support for gui standard plugin
This commit is contained in:
parent
67048e9ea0
commit
76bb1dbd5f
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: GUI.java,v 1.11 2006/12/01 14:12:50 fros4943 Exp $
|
* $Id: GUI.java,v 1.12 2006/12/13 11:57:04 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
@ -198,6 +198,16 @@ public class GUI extends JDesktopPane {
|
|||||||
|
|
||||||
// Load extendable parts (using current platform config)
|
// Load extendable parts (using current platform config)
|
||||||
reparsePlatformConfig();
|
reparsePlatformConfig();
|
||||||
|
|
||||||
|
// EXPERIMENTAL: Start all standard GUI plugins
|
||||||
|
for (Class<? extends VisPlugin> visPluginClass : pluginClasses) {
|
||||||
|
int pluginType = visPluginClass.getAnnotation(VisPluginType.class)
|
||||||
|
.value();
|
||||||
|
if (pluginType == VisPluginType.GUI_STANDARD_PLUGIN) {
|
||||||
|
startPlugin(visPluginClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JMenuBar createMenuBar() {
|
private JMenuBar createMenuBar() {
|
||||||
@ -1207,6 +1217,14 @@ public class GUI extends JDesktopPane {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newPlugin = pluginClass.getConstructor(new Class[]{GUI.class})
|
||||||
|
.newInstance(currentGUI);
|
||||||
|
} else if (pluginType == VisPluginType.GUI_STANDARD_PLUGIN) {
|
||||||
|
if (currentGUI == null) {
|
||||||
|
logger.fatal("Can't start GUI plugin (no GUI)");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
newPlugin = pluginClass.getConstructor(new Class[]{GUI.class})
|
newPlugin = pluginClass.getConstructor(new Class[]{GUI.class})
|
||||||
.newInstance(currentGUI);
|
.newInstance(currentGUI);
|
||||||
}
|
}
|
||||||
@ -1321,6 +1339,8 @@ public class GUI extends JDesktopPane {
|
|||||||
newPluginClass.getConstructor(new Class[]{Simulation.class});
|
newPluginClass.getConstructor(new Class[]{Simulation.class});
|
||||||
} else if (pluginType == VisPluginType.GUI_PLUGIN) {
|
} else if (pluginType == VisPluginType.GUI_PLUGIN) {
|
||||||
newPluginClass.getConstructor(new Class[]{GUI.class});
|
newPluginClass.getConstructor(new Class[]{GUI.class});
|
||||||
|
} else if (pluginType == VisPluginType.GUI_STANDARD_PLUGIN) {
|
||||||
|
newPluginClass.getConstructor(new Class[]{GUI.class});
|
||||||
} else {
|
} else {
|
||||||
logger.fatal("Could not find valid plugin type annotation in class "
|
logger.fatal("Could not find valid plugin type annotation in class "
|
||||||
+ newPluginClass);
|
+ newPluginClass);
|
||||||
@ -1388,7 +1408,7 @@ public class GUI extends JDesktopPane {
|
|||||||
|
|
||||||
// // GUI CONTROL METHODS ////
|
// // GUI CONTROL METHODS ////
|
||||||
|
|
||||||
private void setSimulation(Simulation sim) {
|
public void setSimulation(Simulation sim) {
|
||||||
if (sim != null) {
|
if (sim != null) {
|
||||||
doRemoveSimulation(false);
|
doRemoveSimulation(false);
|
||||||
}
|
}
|
||||||
@ -1469,7 +1489,8 @@ public class GUI extends JDesktopPane {
|
|||||||
if (pluginClasses.contains(frameClass)) {
|
if (pluginClasses.contains(frameClass)) {
|
||||||
int pluginType = ((Class<? extends VisPlugin>) frameClass)
|
int pluginType = ((Class<? extends VisPlugin>) frameClass)
|
||||||
.getAnnotation(VisPluginType.class).value();
|
.getAnnotation(VisPluginType.class).value();
|
||||||
if (pluginType != VisPluginType.GUI_PLUGIN)
|
if (pluginType != VisPluginType.GUI_PLUGIN &&
|
||||||
|
pluginType != VisPluginType.GUI_STANDARD_PLUGIN)
|
||||||
removePlugin((VisPlugin) openededFrame, false);
|
removePlugin((VisPlugin) openededFrame, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: Simulation.java,v 1.5 2006/12/07 15:14:19 fros4943 Exp $
|
* $Id: Simulation.java,v 1.6 2006/12/13 11:58:02 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
@ -184,6 +184,7 @@ public class Simulation extends Observable implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public void startSimulation() {
|
public void startSimulation() {
|
||||||
if (!isRunning()) {
|
if (!isRunning()) {
|
||||||
|
isRunning = true;
|
||||||
thread = new Thread(this);
|
thread = new Thread(this);
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
@ -376,7 +377,8 @@ public class Simulation extends Observable implements Runnable {
|
|||||||
pluginElement.setText(openedPlugin.getClass().getName());
|
pluginElement.setText(openedPlugin.getClass().getName());
|
||||||
|
|
||||||
pluginSubElement = new Element("constructor");
|
pluginSubElement = new Element("constructor");
|
||||||
if (pluginType == VisPluginType.GUI_PLUGIN) {
|
if (pluginType == VisPluginType.GUI_PLUGIN ||
|
||||||
|
pluginType == VisPluginType.GUI_STANDARD_PLUGIN) {
|
||||||
pluginSubElement.setText("gui");
|
pluginSubElement.setText("gui");
|
||||||
pluginElement.addContent(pluginSubElement);
|
pluginElement.addContent(pluginSubElement);
|
||||||
} else if (pluginType == VisPluginType.SIM_PLUGIN ||
|
} else if (pluginType == VisPluginType.SIM_PLUGIN ||
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: VisPluginType.java,v 1.1 2006/08/21 12:12:57 fros4943 Exp $
|
* $Id: VisPluginType.java,v 1.2 2006/12/13 11:58:28 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
@ -104,6 +104,16 @@ public @interface VisPluginType {
|
|||||||
*/
|
*/
|
||||||
public static final int SIM_STANDARD_PLUGIN = 4;
|
public static final int SIM_STANDARD_PLUGIN = 4;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GUI Standard Plugin
|
||||||
|
*
|
||||||
|
* This is treated exactly like a GUI Plugin, with the
|
||||||
|
* only difference that this will automatically be opened
|
||||||
|
* when a GUI is created.
|
||||||
|
*/
|
||||||
|
public static final int GUI_STANDARD_PLUGIN = 5;
|
||||||
|
|
||||||
int value();
|
int value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user