MCPcopy Index your code
hub / github.com/codenameone/CodenameOne / addCommand

Method addCommand

CodenameOne/src/com/codename1/ui/MenuBar.java:998–1041  ·  view source on GitHub ↗
(Command cmd)

Source from the content-addressed store, hash-verified

996 ///
997 /// - `cmd`: Command to add
998 public void addCommand(Command cmd) {
999 // prevent duplicate commands which might happen in some edge cases
1000 // with the select command
1001 if (commands.contains(cmd)) {
1002 return;
1003 }
1004
1005 if (getBackCommand() == cmd && UIManager.getInstance().isThemeConstant("hideBackCommandBool", false)) { //NOPMD CompareObjectsWithEquals
1006 return;
1007 }
1008
1009 // special case for default commands which are placed at the end and aren't overriden later
1010 if (soft.length > 2 && cmd == parent.getDefaultCommand()) { //NOPMD CompareObjectsWithEquals
1011 commands.addElement(cmd);
1012 } else {
1013 commands.insertElementAt(cmd, 0);
1014 }
1015
1016 if (!(parent instanceof Dialog)) {
1017 int behavior = getCommandBehavior();
1018 if (behavior == Display.COMMAND_BEHAVIOR_BUTTON_BAR || behavior == Display.COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK
1019 || behavior == Display.COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_RIGHT || behavior == Display.COMMAND_BEHAVIOR_ICS) {
1020 if (behavior == Display.COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK && (cmd == parent.getBackCommand() //NOPMD CompareObjectsWithEquals
1021 || findCommandComponent(cmd) != null)) {
1022 return;
1023 }
1024 if (parent.getBackCommand() != cmd) { //NOPMD CompareObjectsWithEquals
1025 if ((behavior == Display.COMMAND_BEHAVIOR_BUTTON_BAR_TITLE_BACK)
1026 && parent.getTitle() != null && parent.getTitle().length() > 0) {
1027 synchronizeCommandsWithButtonsInBackbutton();
1028 return;
1029 }
1030
1031 setLayout(new GridLayout(1, getCommandCount()));
1032 addComponent(createTouchCommandButton(cmd));
1033 } else {
1034 commands.removeElement(cmd);
1035 }
1036 return;
1037 }
1038 }
1039
1040 updateCommands();
1041 }
1042
1043 /// Returns the command occupying the given index
1044 ///

Callers 3

addSelectCommandMethod · 0.95
showMenuMethod · 0.45

Calls 15

getBackCommandMethod · 0.95
getInstanceMethod · 0.95
getCommandBehaviorMethod · 0.95
findCommandComponentMethod · 0.95
getCommandCountMethod · 0.95
updateCommandsMethod · 0.95
installMenuBarMethod · 0.95
minMethod · 0.95
isThemeConstantMethod · 0.80
containsMethod · 0.65

Tested by 1