sorting plugin menu according to plugin type
This commit is contained in:
parent
11734b3c3b
commit
264529708e
|
@ -24,7 +24,7 @@
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: GUI.java,v 1.104 2009/02/18 10:35:31 fros4943 Exp $
|
* $Id: GUI.java,v 1.105 2009/02/18 17:25:14 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
@ -321,6 +321,11 @@ public class GUI extends Observable {
|
||||||
myDesktopPane = desktop;
|
myDesktopPane = desktop;
|
||||||
if (menuPlugins == null) {
|
if (menuPlugins == null) {
|
||||||
menuPlugins = new JMenu("Plugins");
|
menuPlugins = new JMenu("Plugins");
|
||||||
|
menuPlugins.removeAll();
|
||||||
|
|
||||||
|
/* COOJA/GUI plugins at top, simulation plugins in middle, mote plugins at bottom */
|
||||||
|
menuPlugins.addSeparator();
|
||||||
|
menuPlugins.addSeparator();
|
||||||
}
|
}
|
||||||
if (menuMotePluginClasses == null) {
|
if (menuMotePluginClasses == null) {
|
||||||
menuMotePluginClasses = new Vector<Class<? extends Plugin>>();
|
menuMotePluginClasses = new Vector<Class<? extends Plugin>>();
|
||||||
|
@ -801,6 +806,11 @@ public class GUI extends Observable {
|
||||||
// Plugins menu
|
// Plugins menu
|
||||||
if (menuPlugins == null) {
|
if (menuPlugins == null) {
|
||||||
menuPlugins = new JMenu("Plugins");
|
menuPlugins = new JMenu("Plugins");
|
||||||
|
menuPlugins.removeAll();
|
||||||
|
|
||||||
|
/* COOJA/GUI plugins at top, simulation plugins in middle, mote plugins at bottom */
|
||||||
|
menuPlugins.addSeparator();
|
||||||
|
menuPlugins.addSeparator();
|
||||||
} else {
|
} else {
|
||||||
menuPlugins.setText("Plugins");
|
menuPlugins.setText("Plugins");
|
||||||
}
|
}
|
||||||
|
@ -2034,14 +2044,37 @@ public class GUI extends Observable {
|
||||||
menuItem.putClientProperty("class", newPluginClass);
|
menuItem.putClientProperty("class", newPluginClass);
|
||||||
menuItem.addActionListener(guiEventHandler);
|
menuItem.addActionListener(guiEventHandler);
|
||||||
|
|
||||||
menuPlugins.add(menuItem);
|
/* Sort menu according to plugin type */
|
||||||
|
int itemIndex=0;
|
||||||
if (pluginType == PluginType.MOTE_PLUGIN) {
|
if (pluginType == PluginType.COOJA_PLUGIN || pluginType == PluginType.COOJA_STANDARD_PLUGIN) {
|
||||||
|
for (; itemIndex < menuPlugins.getItemCount(); itemIndex++) {
|
||||||
|
if (menuPlugins.getItem(itemIndex) == null /* separator */) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menuItem.setToolTipText("COOJA plugin: " + newPluginClass.getName());
|
||||||
|
} else if (pluginType == PluginType.SIM_PLUGIN || pluginType == PluginType.SIM_STANDARD_PLUGIN) {
|
||||||
|
for (; itemIndex < menuPlugins.getItemCount(); itemIndex++) {
|
||||||
|
if (menuPlugins.getItem(itemIndex) == null /* separator */) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itemIndex++;
|
||||||
|
for (; itemIndex < menuPlugins.getItemCount(); itemIndex++) {
|
||||||
|
if (menuPlugins.getItem(itemIndex) == null /* separator */) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menuItem.setToolTipText("Simulation plugin: " + newPluginClass.getName());
|
||||||
|
} else if (pluginType == PluginType.MOTE_PLUGIN) {
|
||||||
// Disable previous menu item and add new item to mote plugins menu
|
// Disable previous menu item and add new item to mote plugins menu
|
||||||
menuItem.setEnabled(false);
|
menuItem.setEnabled(false);
|
||||||
menuItem.setToolTipText("Mote plugin");
|
menuItem.setToolTipText("Mote plugin: " + newPluginClass.getName());
|
||||||
menuMotePluginClasses.add(newPluginClass);
|
menuMotePluginClasses.add(newPluginClass);
|
||||||
|
itemIndex = menuPlugins.getItemCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menuPlugins.add(menuItem, itemIndex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}.invokeAndWait();
|
}.invokeAndWait();
|
||||||
|
@ -2057,6 +2090,10 @@ public class GUI extends Observable {
|
||||||
public void unregisterPlugins() {
|
public void unregisterPlugins() {
|
||||||
if (menuPlugins != null) {
|
if (menuPlugins != null) {
|
||||||
menuPlugins.removeAll();
|
menuPlugins.removeAll();
|
||||||
|
|
||||||
|
/* COOJA/GUI plugins at top, simulation plugins in middle, mote plugins at bottom */
|
||||||
|
menuPlugins.addSeparator();
|
||||||
|
menuPlugins.addSeparator();
|
||||||
}
|
}
|
||||||
if (menuMotePluginClasses != null) {
|
if (menuMotePluginClasses != null) {
|
||||||
menuMotePluginClasses.clear();
|
menuMotePluginClasses.clear();
|
||||||
|
|
Loading…
Reference in a new issue