Override method for creating FormBaseNewWithMenu form
351522
def create(self):
        
        try:
            self.api_action = System()
        except DockerException as de:  # pragma: no cover
            notify_confirm(str(de),
                           title='Docker Error',
                           form_color='DANGER',
                           wrap=True)
            MainForm.exit()

        self.add_handlers({'^T': self.help_form, '^Q': MainForm.exit})
        # all forms that can toggle view by group
        self.view_togglable = ['inventory', 'remove']

        #######################
        # MAIN SCREEN WIDGETS #
        #######################

        self.addfield = self.add(npyscreen.TitleFixedText, name='Date:',
                                 labelColor='DEFAULT', value=Timestamp())
        self.addfield2 = self.add(npyscreen.TitleFixedText, name='Uptime:',
                                  labelColor='DEFAULT', value=Uptime())
        self.cpufield = self.add(npyscreen.TitleFixedText,
                                 name='Logical CPUs:',
                                 labelColor='DEFAULT', value=Cpu())
        self.gpufield = self.add(npyscreen.TitleFixedText, name='GPUs:',
                                 labelColor='DEFAULT', value=Gpu()[1])
        self.location = self.add(npyscreen.TitleFixedText,
                                 name='User Data:',
                                 value=PathDirs().meta_dir,
                                 labelColor='DEFAULT')
        self.file_drop = self.add(npyscreen.TitleFixedText,
                                  name='File Drop:',
                                  value=DropLocation()[1],
                                  labelColor='DEFAULT')
        self.addfield3 = self.add(npyscreen.TitleFixedText, name='Containers:',
                                  labelColor='DEFAULT',
                                  value='0 '+' running')
        self.multifield1 = self.add(npyscreen.MultiLineEdit, max_height=22,
                                    editable=False, value="""

            '.,
              'b      *
               '$    #.
                $:   #:
                *#  @):
                :@,@):   ,.**:'
      ,         :@@*: ..**'
       '#o.    .:(@'.@*"'
          'bq,..:,@@*'   ,*
          ,p$q8,:@)'  .p*'
         '    '@@Pp@@*'
               Y7'.'
              :@):.
             .:@:'.
           .::(@:.
                       _
      __   _____ _ __ | |_
      \ \ / / _ \ '_ \| __|
       \ V /  __/ | | | |_
        \_/ \___|_| |_|\__|
                           """)

        ################
        # MENU OPTIONS #
        ################

        # Tool Menu Items
        self.m3 = self.add_menu(name='Tools', shortcut='p')
        self.m3.addItem(text='Add New Tool',
                        onSelect=self.perform_action,
                        arguments=['add'], shortcut='a')
        self.m3.addItem(text='Configure Tools',
                        onSelect=self.perform_action,
                        arguments=['configure'], shortcut='t')
        self.m3.addItem(text='Inventory',
                        onSelect=self.perform_action,
                        arguments=['inventory'], shortcut='i')
        self.m3.addItem(text='Remove Tools',
                        onSelect=self.perform_action,
                        arguments=['remove'], shortcut='r')
        self.m3.addItem(text='Start Tools',
                        onSelect=self.perform_action,
                        arguments=['start'], shortcut='s')
        self.m3.addItem(text='Stop Tools',
                        onSelect=self.perform_action,
                        arguments=['stop'], shortcut='p')

        # Services Menu Items
        self.m5 = self.add_menu(name='Services Running', shortcut='s')
        self.m5.addItem(text='External Services', onSelect=self.perform_action,
                        arguments=['services_external'], shortcut='e')
        self.m5.addItem(text='Tool Services',
                        onSelect=self.perform_action,
                        arguments=['services'], shortcut='t')

        # System Commands Menu Items
        self.m6 = self.add_menu(name='System Commands', shortcut='y')
        self.m6.addItem(text='Backup', onSelect=self.system_commands,
                        arguments=['backup'], shortcut='b')
        self.m6.addItem(text='Change Vent Configuration',
                        onSelect=self.system_commands, arguments=['configure'],
                        shortcut='c')
        self.m6.addItem(text='Detect GPUs', onSelect=self.system_commands,
                        arguments=['gpu'], shortcut='g')
        self.m6.addItem(text='Factory Reset', onSelect=self.system_commands,
                        arguments=['reset'], shortcut='r')
        self.m6.addItem(text='Restore (To Be Implemented...', onSelect=self.system_commands,
                        arguments=['restore'], shortcut='t')

        # TODO this should be either or depending on whether or not it's running already
        self.m6.addItem(text='Start', onSelect=self.system_commands,
                        arguments=['start'], shortcut='s')
        self.m6.addItem(text='Stop', onSelect=self.system_commands,
                        arguments=['stop'], shortcut='o')

        self.m6.addItem(text='Upgrade (To Be Implemented...)',
                        onSelect=self.system_commands,
                        arguments=['upgrade'], shortcut='u')

        # Tutorial Menu Items
        self.m7 = self.add_menu(name='Tutorials', shortcut='t')
        self.s1 = self.m7.addNewSubmenu(name='About Vent', shortcut='v')
        self.s1.addItem(text='Background', onSelect=self.switch_tutorial,
                        arguments=['background'], shortcut='b')
        self.s1.addItem(text='Terminology', onSelect=self.switch_tutorial,
                        arguments=['terminology'], shortcut='t')
        self.s1.addItem(text='Getting Setup', onSelect=self.switch_tutorial,
                        arguments=['setup'], shortcut='s')
        self.s2 = self.m7.addNewSubmenu(name='Working with Tools',
                                        shortcut='c')
        self.s2.addItem(text='Starting Tools', onSelect=self.switch_tutorial,
                        arguments=['starting_tools'], shortcut='s')
        self.s3 = self.m7.addNewSubmenu(name='Working with Plugins',
                                        shortcut='p')
        self.s3.addItem(text='Adding Tools', onSelect=self.switch_tutorial,
                        arguments=['adding_tools'], shortcut='a')
        self.s4 = self.m7.addNewSubmenu(name='Files', shortcut='f')
        self.s4.addItem(text='Adding Files', onSelect=self.switch_tutorial,
                        arguments=['adding_files'], shortcut='a')
        self.s5 = self.m7.addNewSubmenu(name='Help', shortcut='s')
        self.s5.addItem(text='Basic Troubleshooting',
                        onSelect=self.switch_tutorial,
                        arguments=['basic_troubleshooting'], shortcut='t')
387483
private void initContextMenauAndToolBar() {
        toolbar = new JToolBar();
        toolbar.add(new Button(saveAction));
        toolbar.add(new Button(printAction));
        toolbar.addSeparator();
        toolbar.add(new Button(zoomInAction));
        toolbar.add(new Button(zoomOutAction));
        toolbar.add(new Button(resetAction));
        toolbar.addSeparator();
        toolbar.add(new Button(enlargePlotAreaAction));
        toolbar.add(new Button(shrinkPlotAreaAction));
        toolbar.add(new Button(increaseHeightAction));
        toolbar.add(new Button(decreaseHeightAction));
        toolbar.add(new Button(increaseWidthAction));
        toolbar.add(new Button(decreaseWidthAction));
        toolbar.addSeparator();
        toolbar.add(new Button(propertyAction));
    
        decreaseHeightAction.setEnabled(false);
        decreaseWidthAction.setEnabled(false);
        
        //Initialize popup menu.
        popup = new JPopupMenu();        
        popup.add(new JMenuItem(saveAction));
        popup.add(new JMenuItem(printAction));
        popup.addSeparator();
        popup.add(new JMenuItem(zoomInAction));
        popup.add(new JMenuItem(zoomOutAction));
        popup.add(new JMenuItem(resetAction));
        popup.addSeparator();
        popup.add(new JMenuItem(enlargePlotAreaAction));
        popup.add(new JMenuItem(shrinkPlotAreaAction));
        popup.add(new JMenuItem(increaseHeightAction));
        popup.add(new JMenuItem(decreaseHeightAction));
        popup.add(new JMenuItem(increaseWidthAction));
        popup.add(new JMenuItem(decreaseWidthAction));
        popup.addSeparator();
        popup.add(new JMenuItem(propertyAction));
        
        AncestorListener ancestorListener = new AncestorListener() {

            @Override
            public void ancestorAdded(AncestorEvent ae) {
                boolean inScrollPane = false;
                Container parent = getParent();
                while (parent != null) {
                    if (parent instanceof JScrollPane) {
                        inScrollPane = true;
                        scrollPane = (JScrollPane) parent;
                        break;
                    }
                    
                    parent = parent.getParent();
                }
                
                increaseHeightAction.setEnabled(inScrollPane);
                increaseWidthAction.setEnabled(inScrollPane);
            }

            @Override
            public void ancestorRemoved(AncestorEvent ae) {
            }

            @Override
            public void ancestorMoved(AncestorEvent ae) {
            }
        };
        
        addAncestorListener(ancestorListener);
    }
711843
def make_localised_form(model, form, exclude=None):
    
    
    newfields = {}  
    
    for localized_field in model.localized_fields:
        # get the descriptor, which contains the form field
        default_field_descriptor = getattr(model, localized_field)
        
        # See if we've got overridden fields in a custom form.
        if hasattr(form, 'declared_fields'):
            form_field = form.declared_fields.get(
                localized_field, default_field_descriptor.form_field)
        else:
            form_field = default_field_descriptor.form_field
         
        # wrap the widget to show the origin of the value;
        # either database, catalog or fallback.
        if type(form_field.widget) is not WidgetWrapper:
            form_field.widget = WidgetWrapper(form_field.widget)
         
        newfields[localized_field] = form_field
 
    if hasattr(form, 'Meta'):
         setattr(form.Meta, 'model', model)
    else:
         newfields['Meta'] = type('Meta', tuple(), {'model':model})
    
    newfields['localized_fields'] = model.localized_fields
    
    return ModelFormMetaclass(model.__name__, (LocalisedForm, form), newfields)
919991
function initContextMenuContainer(params) {
          // Destructuring
          var customClass = params.customClass;

          var $ul = $('<ul>');
          $ul.addClass('dropdown-menu');
          $ul.attr({ 'role': 'menu' });
          $ul.css({
            display: 'block',
            position: 'absolute',
            left: params.event.pageX + 'px',
            top: params.event.pageY + 'px',
            'z-index': 10000
          });

          if(customClass) { $ul.addClass(customClass); }

          return $ul;
        }
366602
def _append(self, menu):
        ''''''
        menu.AppendCheckItem(self.id(), self.name, self.description)
        menu.Check(self.id(), self.checked)
516958
public static MenuItem createFromExistingWithId(MenuItem selected, int newId) {
        return visitWithResult(selected, new AbstractMenuItemVisitor<MenuItem>() {
            @Override
            public void visit(AnalogMenuItem item) {
                setResult(AnalogMenuItemBuilder.anAnalogMenuItemBuilder()
                        .withExisting(item)
                        .withId(newId)
                        .menuItem()
                );
            }

            @Override
            public void visit(BooleanMenuItem item) {
                setResult(BooleanMenuItemBuilder.aBooleanMenuItemBuilder()
                        .withExisting(item)
                        .withId(newId)
                        .menuItem()
                );
            }

            @Override
            public void visit(EnumMenuItem item) {
                setResult(EnumMenuItemBuilder.anEnumMenuItemBuilder()
                        .withExisting(item)
                        .withId(newId)
                        .menuItem()
                );
            }

            @Override
            public void visit(SubMenuItem item) {
                setResult(SubMenuItemBuilder.aSubMenuItemBuilder()
                        .withExisting(item)
                        .withId(newId)
                        .menuItem()
                );
            }

            @Override
            public void visit(TextMenuItem item) {
                setResult(TextMenuItemBuilder.aTextMenuItemBuilder()
                        .withExisting(item)
                        .withId(newId)
                        .menuItem()
                );
            }

            @Override
            public void visit(RemoteMenuItem item) {
                setResult(RemoteMenuItemBuilder.aRemoteMenuItemBuilder()
                        .withExisting(item)
                        .withId(newId)
                        .menuItem()
                );
            }

            @Override
            public void visit(FloatMenuItem item) {
                setResult(FloatMenuItemBuilder.aFloatMenuItemBuilder()
                        .withExisting(item)
                        .withId(newId)
                        .menuItem()
                );
            }
            @Override
            public void visit(ActionMenuItem item) {
                setResult(ActionMenuItemBuilder.anActionMenuItemBuilder()
                        .withExisting(item)
                        .withId(newId)
                        .menuItem()
                );
            }
        }).orElse(null);
    }
238522
def create_modelform(self, base_form=forms.ModelForm,
                         field_types=settings.CUSTOM_FIELD_TYPES,
                         widget_types=settings.CUSTOM_WIDGET_TYPES):
        

        _builder = self

        class CustomFieldModelBaseForm(base_form):
            def __init__(self, *args, **kwargs):
                """
                Constructor
                """
                # additional form variables
                self.custom_classes = None
                self.is_custom_form = True
                self.instance = None

                # construct the form
                super(CustomFieldModelBaseForm, self).__init__(*args, **kwargs)

                # init custom fields from model in the form
                self.init_custom_fields()

            def clean(self):
                """
                Clean the form
                """
                cleaned_data = super(CustomFieldModelBaseForm, self).clean()
                return cleaned_data

            def save(self, commit=True):
                """
                Save the form
                """
                self.instance = super(CustomFieldModelBaseForm, self).save(commit=commit)
                if self.instance and commit:
                    self.instance.save()
                    self.save_custom_fields()
                return self.instance

            def init_custom_fields(self):
                """
                Populate the ``form.fields[]`` with the additional fields coming from
                the custom fields models.
                """
                content_type = self.get_content_type()
                fields = self.get_fields_for_content_type(content_type)
                for f in fields:
                    name = str(f.name)
                    initial = f.initial
                    self.fields[name] = self.get_formfield_for_field(f)
                    self.fields[name].is_custom = True
                    self.fields[name].label = f.label
                    self.fields[name].required = f.required
                    self.fields[name].widget = self.get_widget_for_field(f)
                    if self.instance and self.instance.pk:
                        value = self.search_value_for_field(f,
                                                            content_type,
                                                            self.instance.pk)
                        if len(value) > 0:
                            initial = value[0].value
                    self.fields[name].initial = self.initial[name] = initial

            def save_custom_fields(self):
                """ Perform save and validation over the custom fields """
                if not self.instance.pk:
                    raise Exception("The model instance has not been saved. Have you called instance.save() ?")

                content_type = self.get_content_type()
                fields = self.get_fields_for_content_type(content_type)
                for f in fields:
                    name = str(f.name)
                    fv = self.search_value_for_field(f,
                                                     content_type,
                                                     self.instance.pk)
                    if len(fv) > 0:
                        value = fv[0]
                        value.value = self.cleaned_data[name]
                    else:
                        value = self.create_value_for_field(f,
                                                            self.instance.pk,
                                                            self.cleaned_data[name])
                    value.save()

            def get_model(self):
                """
                Returns the actual model this ``ModelForm`` is referring to
                """
                return self._meta.model

            def get_content_type(self):
                """
                Returns the content type instance of the model this ``ModelForm`` is
                referring to
                """
                return ContentType.objects.get_for_model(self.get_model())

            def get_formfield_for_field(self, field):
                """
                Returns the defined formfield instance built from the type of the field

                :param field: custom field instance
                :return: the formfield instance
                """
                field_attrs = {
                    'label': field.label,
                    'help_text': field.help_text,
                    'required': field.required,
                }
                if field.data_type == CUSTOM_TYPE_TEXT:
                    #widget_attrs = {}
                    if field.min_length:
                        field_attrs['min_length'] = field.min_length
                    if field.max_length:
                        field_attrs['max_length'] = field.max_length
                    #    widget_attrs['maxlength'] = field.max_length
                    #field_attrs['widget'] = widgets.AdminTextInputWidget(attrs=widget_attrs)
                elif field.data_type == CUSTOM_TYPE_INTEGER:
                    if field.min_value: field_attrs['min_value'] = int(float(field.min_value))
                    if field.max_value: field_attrs['max_value'] = int(float(field.max_value))
                    #field_attrs['widget'] = spinner.IntegerSpinnerWidget(attrs=field_attrs)
                elif field.data_type == CUSTOM_TYPE_FLOAT:
                    if field.min_value: field_attrs['min_value'] = float(field.min_value)
                    if field.max_value: field_attrs['max_value'] = float(field.max_value)
                    #field_attrs['widget'] = spinner.SpinnerWidget(attrs=field_attrs)
                elif field.data_type == CUSTOM_TYPE_TIME:
                    #field_attrs['widget'] = date.TimePickerWidget()
                    pass
                elif field.data_type == CUSTOM_TYPE_DATE:
                    #field_attrs['widget'] = date.DatePickerWidget()
                    pass
                elif field.data_type == CUSTOM_TYPE_DATETIME:
                    #field_attrs['widget'] = date.DateTimePickerWidget()
                    pass
                elif field.data_type == CUSTOM_TYPE_BOOLEAN:
                    pass
                field_type = import_class(field_types[field.data_type])
                return field_type(**field_attrs)

            def get_widget_for_field(self, field, attrs={}):
                """
                Returns the defined widget type instance built from the type of the field

                :param field: custom field instance
                :param attrs: attributes of widgets
                :return: the widget instance
                """
                return import_class(widget_types[field.data_type])(**attrs)

            def get_fields_for_content_type(self, content_type):
                """
                Returns all fields for a given content type

                Example implementation:

                  return MyCustomField.objects.filter(content_type=content_type)

                :param content_type: content type to search
                :return: the custom field instances
                """

                return _builder.fields_model_class.objects.filter(content_type=content_type)

            def search_value_for_field(self, field, content_type, object_id):
                """
                This function will return the CustomFieldValue instance for a given
                field of an object that has the given content_type

                Example implementation:

                  return MyCustomFieldValue.objects.filter(custom_field=field,
                                                           content_type=content_type,
                                                           object_id=object_id)

                :param field: the custom field instance
                :param content_type: the content type instance
                :param object_id: the object id this value is referring to
                :return: CustomFieldValue queryset
                """
                return _builder.values_model_class.objects.filter(custom_field=field,
                                                                  content_type=content_type,
                                                                  object_id=object_id)

            def create_value_for_field(self, field, object_id, value):
                """
                Create a value for a given field of an object

                Example implementation:

                  return MyCustomFieldValue(custom_field=field,
                                            object_id=object_id,
                                            value=value)

                :param field: the custom field instance
                :param object_id: the object id this value is referring to
                :param value: the value to set
                :return: the value instance (not saved!)
                """
                return _builder.values_model_class(custom_field=field,
                                                   object_id=object_id,
                                                   value=value)

        return CustomFieldModelBaseForm
1214581
private void menuUndoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuUndoActionPerformed
    final TabTitle title = this.getFocusedTab();
    if (title != null) {
      this.menuUndo.setEnabled(title.getProvider().undo());
      this.menuRedo.setEnabled(title.getProvider().isRedo());
    }
  }
747456
def createMenu(self, parent):
        
        menu = QtGui.QMenu(parent)
        menu.setTitle('&View')

        act = menu.addAction('&Lock/Unlock Layout')
        act.setIcon(QtGui.QIcon(projexui.resources.find('img/view/lock.png')))
        act.triggered.connect(self.toggleLocked)
        
        menu.addSeparator()
        act = menu.addAction('&Export Layout as...')
        act.setIcon(QtGui.QIcon(projexui.resources.find('img/view/export.png')))
        act.triggered.connect(self.exportProfile)
        
        act = menu.addAction('&Import Layout from...')
        act.setIcon(QtGui.QIcon(projexui.resources.find('img/view/import.png')))
        act.triggered.connect(self.importProfile)

        menu.addSeparator()

        act = menu.addAction('&Clear Layout')
        act.setIcon(QtGui.QIcon(projexui.resources.find('img/view/remove.png')))
        act.triggered.connect(self.resetForced)

        return menu
650718
def contextMenuEvent(self, event):
        """"""
        self.update_menu()
        self.menu.popup(event.globalPos())
100283
private String buildAddForm() {

        StringBuffer result = new StringBuffer(256);

        // only display form if the current user has the "control" right
        if (getEditable()) {
            result.append(dialogSpacer());
            result.append(dialogBlockStart(key(Messages.GUI_PERMISSION_ADD_ACE_0)));

            // get all possible entry types
            ArrayList<String> options = new ArrayList<String>();
            ArrayList<String> optionValues = new ArrayList<String>();
            for (int i = 0; i < (getTypes(false).length - (1 * (isRoleEditable() ? 0 : 1))); i++) {
                options.add(getTypesLocalized()[i]);
                optionValues.add(Integer.toString(i));
            }

            // create the input form for adding an ace
            result.append("<form action=\"").append(getDialogUri()).append(
                "\" method=\"post\" name=\"add\" class=\"nomargin\">\n");
            // set parameters to show correct hidden input fields
            setParamAction(DIALOG_ADDACE);
            setParamType(null);
            setParamName(null);
            result.append(paramsAsHidden());
            result.append("<table border=\"0\" width=\"100%\">\n");
            result.append("<tr>\n");
            result.append("\t<td>").append(
                buildSelect("name=\"" + PARAM_TYPE + "\"", options, optionValues, -1)).append("</td>\n");
            result.append("\t<td class=\"maxwidth\"><input type=\"text\" class=\"maxwidth\" name=\"");
            result.append(PARAM_NAME);
            result.append("\" value=\"\"></td>\n");

            result.append("<td><span style='display: block; height: 1px; width: 10px;'/></td>");

            result.append(
                button(
                    new CmsPrincipalWidget().getButtonJs(PARAM_NAME, "add"),
                    null,
                    "principal",
                    org.opencms.workplace.Messages.GUI_DIALOG_BUTTON_SEARCH_0,
                    getSettings().getUserSettings().getEditorButtonStyle()));

            result.append(
                button(
                    "javascript:document.forms['add'].submit();",
                    null,
                    "new",
                    Messages.GUI_LABEL_ADD_0,
                    getSettings().getUserSettings().getEditorButtonStyle()));

            result.append("</tr>\n");
            result.append("</form>\n");
            result.append("</table>\n");

            result.append(dialogBlockEnd());
        }
        return result.toString();
    }
1128157
private void buildUI() {

		// Attribute select:
		attributeSelect = new SelectItem("attributeItem");
		attributeSelect.setWidth(140);
		attributeSelect.setShowTitle(false);
		attributeSelect.setValueMap(getSearchableAttributes(layer));
		attributeSelect.setHint(I18nProvider.getSearch().gridChooseAttribute());
		attributeSelect.setShowHintInField(true);

		attributeSelect.setValidateOnChange(true);
		attributeSelect.setShowErrorStyle(true);
		attributeSelect.setRequired(true);

		// Operator select:
		operatorSelect = new SelectItem("operatorItem");
		operatorSelect.setDisabled(true);
		operatorSelect.setWidth(140);
		operatorSelect.setShowTitle(false);

		operatorSelect.setValidateOnChange(true);
		operatorSelect.setShowErrorStyle(true);
		operatorSelect.setRequired(true);

		// Value form item:
		valueItem = new AttributeFormItem("valueItem");
		valueItem.setShowTitle(false);
		valueItem.setDisabled(true);
		valueItem.setWidth(150);

		// Mechanisms:
		attributeSelect.addChangedHandler(new ChangedHandler() {

			public void onChanged(ChangedEvent event) {
				selectedAttribute = getSelectedAttribute();
				if (selectedAttribute != null) {
					// Adjust operator value map and enabled:
					operatorSelect.setDisabled(false);
					String[] operators = getOperatorsForAttributeType(selectedAttribute);
					operatorSelect.setValueMap(operators);
					operatorSelect.setValue(operators[0]);

					// Adjust value form item and enable:
					valueItem.setAttributeInfo(selectedAttribute);
					valueItem.setDisabled(false);
					valueItem.setWidth(form.getWidth() - 290);
				}
			}
		});

		// Finalize:
		form = new DynamicForm();
		form.setNumCols(6);
		form.setHeight(26);
		form.setWidth100();
		form.setFields(attributeSelect, operatorSelect, valueItem);
		addChild(form);
	}
1306967
def new(self, event):
        """"""

        # Grid table handles interaction to code_array

        self.grid.actions.clear(event.shape)

        _grid_table = GridTable(self.grid, self.grid.code_array)
        self.grid.SetTable(_grid_table, True)

        # Update toolbars
        self.grid.update_entry_line()
        self.grid.update_attribute_toolbar()
337799
public function addInstanceForm()
    {
        if(!$this->isXmlHttpRequest()){
            throw new common_exception_BadRequest('wrong request mode');
        }

        $clazz = $this->getCurrentClass();
        $formContainer = new tao_actions_form_CreateInstance(array($clazz), array());
        $myForm = $formContainer->getForm();

        if ($myForm->isSubmited() && $myForm->isValid()) {
            $properties = $myForm->getValues();
            $instance = $this->createInstance(array($clazz), $properties);

            $this->setData('message', __('%s created', $instance->getLabel()));
            $this->setData('reload', true);
        }

        $this->setData('formTitle', __('Create instance of ').$clazz->getLabel());
        $this->setData('myForm', $myForm->render());

        $this->setView('form.tpl', 'tao');
    }
414425
function addForm(schema, form, cloneFormsDeprecated) {
      var isAdmin = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
      var indicators = arguments.length > 4 ? arguments[4] : undefined;
      var conditionsExprCompiler, contents, deploymentValues, jsonql, metadata, reverseJoins;
      contents = [];
      metadata = []; // Get deployments

      deploymentValues = _.map(form.deployments, function (dep) {
        return {
          id: dep._id,
          name: {
            en: dep.name
          }
        };
      });
      metadata.push({
        id: "deployment",
        type: "enum",
        name: {
          en: "Deployment"
        },
        enumValues: deploymentValues
      }); // Add user

      metadata.push({
        id: "user",
        name: {
          en: "Enumerator"
        },
        type: "join",
        join: {
          type: "n-1",
          toTable: "users",
          fromColumn: "user",
          toColumn: "_id"
        }
      }); // Add status

      metadata.push({
        id: "status",
        type: "enum",
        name: {
          en: "Status"
        },
        enumValues: [{
          id: "draft",
          name: {
            en: "Draft"
          }
        }, {
          id: "pending",
          name: {
            en: "Pending"
          }
        }, {
          id: "final",
          name: {
            en: "Final"
          }
        }, {
          id: "rejected",
          name: {
            en: "Rejected"
          }
        }]
      }); // Add code

      metadata.push({
        id: "code",
        type: "text",
        name: {
          en: "Response Code"
        }
      }); // Add startedOn

      metadata.push({
        id: "startedOn",
        type: "datetime",
        name: {
          en: "Drafted On"
        }
      }); // Add submitted on

      metadata.push({
        id: "submittedOn",
        type: "datetime",
        name: {
          en: "Submitted On"
        }
      }); // Add approvalLevel. Only has value if pending

      jsonql = {
        type: "case",
        cases: [{
          when: {
            type: "op",
            op: "=",
            exprs: [{
              type: "field",
              tableAlias: "{alias}",
              column: "status"
            }, {
              type: "literal",
              value: "pending"
            }]
          },
          then: {
            type: "op",
            op: "::text",
            exprs: [{
              type: "op",
              op: "jsonb_array_length",
              exprs: [{
                type: "field",
                tableAlias: "{alias}",
                column: "approvals"
              }]
            }]
          }
        }]
      };
      metadata.push({
        id: "approvalLevel",
        type: "enum",
        name: {
          en: "Approval Level"
        },
        jsonql: jsonql,
        enumValues: [{
          id: "0",
          name: {
            en: "Pending Level 1"
          }
        }, {
          id: "1",
          name: {
            en: "Pending Level 2"
          }
        }, {
          id: "2",
          name: {
            en: "Pending Level 3"
          }
        }, {
          id: "3",
          name: {
            en: "Pending Level 4"
          }
        }]
      }); // Add IpAddress

      metadata.push({
        id: "ipAddress",
        type: "text",
        name: {
          en: "IP Address"
        }
      });
      contents.push({
        id: "metadata",
        type: "section",
        name: {
          en: "Response Metadata"
        },
        desc: {
          en: "Information about the response such as status, date, and IP Address"
        },
        contents: metadata
      });
      conditionsExprCompiler = new ConditionsExprCompiler(form.design); // List of joins in format: { table: destination table, column: join column to add }

      reverseJoins = [];
      this.addFormItem(form.design, contents, "responses:".concat(form._id), conditionsExprCompiler, null, reverseJoins); // Add to schema

      schema = schema.addTable({
        id: "responses:".concat(form._id),
        name: form.design.name,
        primaryKey: "_id",
        contents: contents,
        ordering: "submittedOn",
        label: "code"
      }); // Add any roster tables

      schema = this.addRosterTables(schema, form.design, conditionsExprCompiler, reverseJoins, "responses:".concat(form._id)); // Add reverse joins from entity and site questions

      schema = this.addReverseJoins(schema, form, reverseJoins);

      if (isAdmin) {
        schema = this.addConfidentialData(schema, form, conditionsExprCompiler);
        schema = this.addConfidentialDataForRosters(schema, form, conditionsExprCompiler);
      }

      schema = this.addCalculations(schema, form);
      schema = this.addIndicatorCalculations(schema, form, indicators, false); // Create table

      return schema;
    }
418245
@Override public boolean onCreateOptionsMenu(Menu menu) {
    if (actionBarMenuAction != null) {
      menu.add(actionBarMenuAction.title)
          .setShowAsActionFlags(SHOW_AS_ACTION_ALWAYS)
          .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override public boolean onMenuItemClick(MenuItem menuItem) {
              actionBarMenuAction.action.call();
              return true;
            }
          });
    }
    menu.add("Log Scope Hierarchy")
        .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
          @Override public boolean onMenuItemClick(MenuItem item) {
            Log.d("DemoActivity", MortarScopeDevHelper.scopeHierarchyToString(activityScope));
            return true;
          }
        });
    return true;
  }
1154866
private void menuFileMenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_menuFileMenuSelected
    final TabTitle title = this.getFocusedTab();
    updateMenuItemsForProvider(title == null ? null : title.getProvider());
  }