Search in sources :

Example 1 with AddAction

use of com.haulmont.cuba.gui.components.actions.AddAction in project cuba by cuba-platform.

the class EntityInspectorEditor method initShortcuts.

protected void initShortcuts() {
    final String commitShortcut = configuration.getConfig(ClientConfig.class).getCommitShortcut();
    Action commitAction = new AbstractAction("commitAndClose", commitShortcut) {

        @Override
        public void actionPerform(Component component) {
            commitAndClose();
        }
    };
    addAction(commitAction);
}
Also used : ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) AddAction(com.haulmont.cuba.gui.components.actions.AddAction) ClientConfig(com.haulmont.cuba.client.ClientConfig)

Example 2 with AddAction

use of com.haulmont.cuba.gui.components.actions.AddAction in project cuba by cuba-platform.

the class EntityInspectorEditor method createButtonsPanel.

/**
 * Creates a buttons panel managing table's content.
 *
 * @param metaProperty property representing table's data
 * @param propertyDs   property's Datasource (CollectionPropertyDatasource usually)
 * @param table        table
 * @return buttons panel
 */
@SuppressWarnings("unchecked")
protected ButtonsPanel createButtonsPanel(final MetaProperty metaProperty, final CollectionDatasource propertyDs, Table table) {
    MetaClass propertyMetaClass = metaProperty.getRange().asClass();
    ButtonsPanel propertyButtonsPanel = componentsFactory.createComponent(ButtonsPanel.class);
    Button createButton = componentsFactory.createComponent(Button.class);
    CreateAction createAction = new CreateAction(metaProperty, propertyDs, propertyMetaClass);
    createButton.setAction(createAction);
    table.addAction(createAction);
    createButton.setCaption(messages.getMessage(EntityInspectorEditor.class, "create"));
    createButton.setIcon("icons/create.png");
    Button addButton = componentsFactory.createComponent(Button.class);
    AddAction addAction = createAddAction(metaProperty, propertyDs, table, propertyMetaClass);
    table.addAction(addAction);
    addButton.setAction(addAction);
    addButton.setCaption(messages.getMessage(EntityInspectorEditor.class, "add"));
    addButton.setIcon("icons/add.png");
    Button editButton = componentsFactory.createComponent(Button.class);
    EditAction editAction = new EditAction(metaProperty, table, propertyDs);
    editButton.setAction(editAction);
    editButton.setCaption(messages.getMessage(EntityInspectorEditor.class, "edit"));
    editButton.setIcon("icons/edit.png");
    table.addAction(editAction);
    table.setItemClickAction(editAction);
    table.setEnterPressAction(editAction);
    RemoveAction removeAction = createRemoveAction(metaProperty, table);
    Button removeButton = componentsFactory.createComponent(Button.class);
    removeButton.setAction(removeAction);
    table.addAction(removeAction);
    removeButton.setCaption(messages.getMessage(EntityInspectorEditor.class, "remove"));
    removeButton.setIcon("icons/remove.png");
    propertyButtonsPanel.add(createButton);
    propertyButtonsPanel.add(addButton);
    propertyButtonsPanel.add(editButton);
    propertyButtonsPanel.add(removeButton);
    return propertyButtonsPanel;
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) AddAction(com.haulmont.cuba.gui.components.actions.AddAction)

Example 3 with AddAction

use of com.haulmont.cuba.gui.components.actions.AddAction in project cuba by cuba-platform.

the class EntityInspectorEditor method createAddAction.

protected AddAction createAddAction(MetaProperty metaProperty, CollectionDatasource propertyDs, Table table, MetaClass propertyMetaClass) {
    Lookup.Handler addHandler = createAddHandler(metaProperty, propertyDs);
    AddAction addAction = new AddAction(table, addHandler, OPEN_TYPE);
    addAction.setWindowId(EntityInspectorBrowse.SCREEN_NAME);
    HashMap<String, Object> params = new HashMap<>();
    params.put("entity", propertyMetaClass.getName());
    MetaProperty inverseProperty = metaProperty.getInverse();
    if (inverseProperty != null)
        params.put("parentProperty", inverseProperty.getName());
    addAction.setWindowParams(params);
    addAction.setOpenType(OPEN_TYPE);
    addAction.setShortcut(configuration.getConfig(ClientConfig.class).getTableAddShortcut());
    return addAction;
}
Also used : MetaProperty(com.haulmont.chile.core.model.MetaProperty) AddAction(com.haulmont.cuba.gui.components.actions.AddAction)

Aggregations

AddAction (com.haulmont.cuba.gui.components.actions.AddAction)3 RemoveAction (com.haulmont.cuba.gui.components.actions.RemoveAction)2 MetaClass (com.haulmont.chile.core.model.MetaClass)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 ClientConfig (com.haulmont.cuba.client.ClientConfig)1 ItemTrackingAction (com.haulmont.cuba.gui.components.actions.ItemTrackingAction)1