Search in sources :

Example 6 with ItemTrackingAction

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

the class CategoryAttrsFrame method initMoveButtons.

protected void initMoveButtons() {
    Action moveUpAction = new ItemTrackingAction("moveUp").withCaption("").withHandler(event -> {
        Set<CategoryAttribute> selected = categoryAttrsTable.getSelected();
        if (selected.isEmpty())
            return;
        CategoryAttribute currentAttr = selected.iterator().next();
        UUID prevId = categoryAttrsDs.prevItemId(currentAttr.getId());
        if (prevId == null)
            return;
        Integer tmp = currentAttr.getOrderNo();
        CategoryAttribute prevAttr = categoryAttrsDs.getItemNN(prevId);
        currentAttr.setOrderNo(prevAttr.getOrderNo());
        prevAttr.setOrderNo(tmp);
        sortTableByOrderNo();
    });
    ((Button) getComponentNN("moveUp")).setAction(moveUpAction);
    Action moveDownAction = new ItemTrackingAction("moveDown").withCaption("").withHandler(event -> {
        Set<CategoryAttribute> selected = categoryAttrsTable.getSelected();
        if (selected.isEmpty())
            return;
        CategoryAttribute currentAttr = selected.iterator().next();
        UUID nextId = categoryAttrsDs.nextItemId(currentAttr.getId());
        if (nextId == null)
            return;
        Integer tmp = currentAttr.getOrderNo();
        CategoryAttribute nextAttr = categoryAttrsDs.getItemNN(nextId);
        currentAttr.setOrderNo(nextAttr.getOrderNo());
        nextAttr.setOrderNo(tmp);
        sortTableByOrderNo();
    });
    ((Button) getComponentNN("moveDown")).setAction(moveDownAction);
    categoryAttrsTable.addAction(moveUpAction);
    categoryAttrsTable.addAction(moveDownAction);
}
Also used : RefreshAction(com.haulmont.cuba.gui.components.actions.RefreshAction) RemoveAction(com.haulmont.cuba.gui.components.actions.RemoveAction) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) CategoryAttribute(com.haulmont.cuba.core.entity.CategoryAttribute) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) UUID(java.util.UUID)

Example 7 with ItemTrackingAction

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

the class MbeansDisplayWindow method init.

@Override
public void init(Map<String, Object> params) {
    super.init(params);
    objectNameField.addValueChangeListener(new ObjectNameFieldListener());
    mbeansTable.addAction(new RefreshAction(mbeansTable));
    Action inspectAction = new ItemTrackingAction("inspect").withCaption(getMessage("action.inspect")).withHandler(event -> {
        Set<ManagedBeanInfo> selected = mbeansTable.getSelected();
        if (!selected.isEmpty()) {
            ManagedBeanInfo mbi = selected.iterator().next();
            if (mbi.getObjectName() != null) {
                // otherwise it's a fake root node
                Window editor = openEditor("jmxConsoleInspectMbean", mbi, OpenType.THIS_TAB);
                editor.addCloseListener(actionId -> {
                    mbeansTable.requestFocus();
                });
            } else {
                // expand / collapse fake root node
                UUID itemId = mbi.getId();
                if (mbeansTable.isExpanded(itemId)) {
                    mbeansTable.collapse(itemId);
                } else {
                    mbeansTable.expand(itemId);
                }
            }
        }
    });
    mbeansTable.addAction(inspectAction);
    mbeansTable.setItemClickAction(inspectAction);
    localJmxInstance = jmxControlAPI.getLocalInstance();
    jmxInstancesDs.refresh();
    jmxConnectionField.setValue(localJmxInstance);
    jmxConnectionField.setRequired(true);
    jmxConnectionField.addValueChangeListener(e -> {
        JmxInstance jmxInstance = (JmxInstance) e.getValue();
        try {
            mbeanDs.setJmxInstance(jmxInstance);
            mbeanDs.refresh();
        } catch (JmxControlException ex) {
            showNotification(getMessage("unableToConnectToInterface"), NotificationType.WARNING);
            if (jmxInstance != localJmxInstance) {
                jmxConnectionField.setValue(localJmxInstance);
            }
        }
    });
    jmxConnectionField.removeAllActions();
    jmxConnectionField.addAction(new PickerField.LookupAction(jmxConnectionField) {

        @Override
        public void afterCloseLookup(String actionId) {
            jmxInstancesDs.refresh();
        }
    });
    jmxConnectionField.addAction(new BaseAction("actions.Add").withIcon("icons/plus-btn.png").withHandler(event -> {
        JmxInstanceEditor instanceEditor = (JmxInstanceEditor) openEditor(metadata.create(JmxInstance.class), OpenType.DIALOG);
        instanceEditor.addCloseListener(actionId -> {
            if (COMMIT_ACTION_ID.equals(actionId)) {
                jmxInstancesDs.refresh();
                jmxConnectionField.setValue(instanceEditor.getItem());
            }
        });
    }));
    mbeanDs.setJmxInstance(localJmxInstance);
    mbeanDs.refresh();
    localJmxField.setValue(jmxControlAPI.getLocalNodeName());
    localJmxField.setEditable(false);
    mbeansTable.setStyleProvider((entity, property) -> {
        if (entity != null && entity.getObjectName() == null) {
            return "c-jmx-tree-table-domain";
        }
        return null;
    });
}
Also used : JmxControlException(com.haulmont.cuba.web.jmx.JmxControlException) StringUtils(org.apache.commons.lang.StringUtils) RefreshAction(com.haulmont.cuba.gui.components.actions.RefreshAction) ManagedBeanInfoDatasource(com.haulmont.cuba.web.app.ui.jmxcontrol.ds.ManagedBeanInfoDatasource) Resource(javax.annotation.Resource) ParamsMap(com.haulmont.bali.util.ParamsMap) Set(java.util.Set) UUID(java.util.UUID) ManagedBeanInfo(com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo) JmxInstance(com.haulmont.cuba.core.entity.JmxInstance) Metadata(com.haulmont.cuba.core.global.Metadata) Inject(javax.inject.Inject) JmxControlAPI(com.haulmont.cuba.web.jmx.JmxControlAPI) JmxInstanceEditor(com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor) Map(java.util.Map) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) com.haulmont.cuba.gui.components(com.haulmont.cuba.gui.components) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) OpenType(com.haulmont.cuba.gui.WindowManager.OpenType) RefreshAction(com.haulmont.cuba.gui.components.actions.RefreshAction) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) ItemTrackingAction(com.haulmont.cuba.gui.components.actions.ItemTrackingAction) JmxInstanceEditor(com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor) BaseAction(com.haulmont.cuba.gui.components.actions.BaseAction) ManagedBeanInfo(com.haulmont.cuba.web.jmx.entity.ManagedBeanInfo) JmxInstance(com.haulmont.cuba.core.entity.JmxInstance) RefreshAction(com.haulmont.cuba.gui.components.actions.RefreshAction) JmxControlException(com.haulmont.cuba.web.jmx.JmxControlException) UUID(java.util.UUID)

Aggregations

ItemTrackingAction (com.haulmont.cuba.gui.components.actions.ItemTrackingAction)7 Inject (javax.inject.Inject)4 MetaClass (com.haulmont.chile.core.model.MetaClass)3 OpenType (com.haulmont.cuba.gui.WindowManager.OpenType)3 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)3 RemoveAction (com.haulmont.cuba.gui.components.actions.RemoveAction)3 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)3 UUID (java.util.UUID)3 StringUtils (org.apache.commons.lang.StringUtils)3 ParamsMap (com.haulmont.bali.util.ParamsMap)2 Entity (com.haulmont.cuba.core.entity.Entity)2 UserRemoveAction (com.haulmont.cuba.gui.app.security.user.browse.UserRemoveAction)2 Type (com.haulmont.cuba.gui.components.DialogAction.Type)2 BaseAction (com.haulmont.cuba.gui.components.actions.BaseAction)2 CreateAction (com.haulmont.cuba.gui.components.actions.CreateAction)2 EditAction (com.haulmont.cuba.gui.components.actions.EditAction)2 RefreshAction (com.haulmont.cuba.gui.components.actions.RefreshAction)2 ComponentsFactory (com.haulmont.cuba.gui.xml.layout.ComponentsFactory)2 java.util (java.util)2 Map (java.util.Map)2