Example usage for org.apache.commons.lang BooleanUtils isTrue

List of usage examples for org.apache.commons.lang BooleanUtils isTrue

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils isTrue.

Prototype

public static boolean isTrue(Boolean bool) 

Source Link

Document

Checks if a Boolean value is true, handling null by returning false.

 BooleanUtils.isTrue(Boolean.TRUE)  = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null)          = false 

Usage

From source file:com.evolveum.midpoint.model.common.expression.Expression.java

public PrismValueDeltaSetTriple<V> evaluate(ExpressionEvaluationContext context)
        throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException {

    ExpressionVariables processedVariables = null;

    try {//from  w  w w  .  j  av a2  s.c  o  m

        processedVariables = processInnerVariables(context.getVariables(), context.getContextDescription(),
                context.getTask(), context.getResult());

        ExpressionEvaluationContext processedParameters = context.shallowClone();
        processedParameters.setVariables(processedVariables);

        for (ExpressionEvaluator<?, ?> evaluator : evaluators) {
            PrismValueDeltaSetTriple<V> outputTriple = (PrismValueDeltaSetTriple<V>) evaluator
                    .evaluate(processedParameters);
            if (outputTriple != null) {
                boolean allowEmptyRealValues = false;
                if (expressionType != null) {
                    allowEmptyRealValues = BooleanUtils.isTrue(expressionType.isAllowEmptyValues());
                }
                outputTriple.removeEmptyValues(allowEmptyRealValues);
                if (InternalsConfig.consistencyChecks) {
                    outputTriple.checkConsistence();
                }
                traceSuccess(context, processedVariables, outputTriple);
                return outputTriple;
            }
        }
        traceSuccess(context, processedVariables, null);
        return null;
    } catch (SchemaException ex) {
        traceFailure(context, processedVariables, ex);
        throw ex;
    } catch (ExpressionEvaluationException ex) {
        traceFailure(context, processedVariables, ex);
        throw ex;
    } catch (ObjectNotFoundException ex) {
        traceFailure(context, processedVariables, ex);
        throw ex;
    } catch (RuntimeException ex) {
        traceFailure(context, processedVariables, ex);
        throw ex;
    }
}

From source file:com.haulmont.cuba.web.gui.components.presentations.PresentationEditor.java

protected void commit() {
    Presentations presentations = component.getPresentations();

    Document doc = DocumentHelper.createDocument();
    doc.setRootElement(doc.addElement("presentation"));

    component.saveSettings(doc.getRootElement());

    String xml = Dom4j.writeDocument(doc, false);
    presentation.setXml(xml);//from w  w  w .  j  av a 2  s  . c om

    presentation.setName(nameField.getValue());
    presentation.setAutoSave(autoSaveField.getValue());
    presentation.setDefault(defaultField.getValue());

    User user = sessionSource.getUserSession().getCurrentOrSubstitutedUser();

    boolean userOnly = !allowGlobalPresentations || !BooleanUtils.isTrue(globalField.getValue());
    presentation.setUser(userOnly ? user : null);

    if (log.isTraceEnabled()) {
        log.trace(String.format("XML: %s", Dom4j.writeDocument(doc, true)));
    }

    if (isNew) {
        presentations.add(presentation);
    } else {
        presentations.modify(presentation);
    }
    presentations.commit();

    addCloseListener(e -> {
        if (isNew) {
            component.applyPresentation(presentation.getId());
        }
    });
}

From source file:jp.primecloud.auto.process.lb.LoadBalancerProcess.java

public void stop(Long loadBalancerNo) {
    LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo);
    if (loadBalancer == null) {
        // ?????/*ww w .  j av  a2  s. c  o  m*/
        throw new AutoException("EPROCESS-000010", loadBalancerNo);
    }

    if (BooleanUtils.isTrue(loadBalancer.getEnabled())) {
        // ?????
        return;
    }

    LoadBalancerStatus status = LoadBalancerStatus.fromStatus(loadBalancer.getStatus());
    if (status != LoadBalancerStatus.STOPPED && status != LoadBalancerStatus.RUNNING
            && status != LoadBalancerStatus.WARNING) {
        // ??????????
        if (log.isDebugEnabled()) {
            log.debug(MessageUtils.format("LoadBalancer {1} status is {2}.(loadBalancerNo={0})", loadBalancerNo,
                    loadBalancer.getLoadBalancerName(), status));
        }
        return;
    }

    if (log.isInfoEnabled()) {
        log.info(
                MessageUtils.getMessage("IPROCESS-200003", loadBalancerNo, loadBalancer.getLoadBalancerName()));
    }

    // ?
    loadBalancer.setStatus(LoadBalancerStatus.STOPPING.toString());
    loadBalancerDao.update(loadBalancer);

    // 
    processLogger.writeLogSupport(ProcessLogger.LOG_INFO, null, null, "LoadBalancerStop",
            new Object[] { loadBalancer.getLoadBalancerName() });

    try {
        // ??
        stopLoadBalancer(loadBalancer);

    } catch (RuntimeException e) {
        log.warn(e.getMessage());
    }

    // 
    processLogger.writeLogSupport(ProcessLogger.LOG_INFO, null, null, "LoadBalancerStopFinish",
            new Object[] { loadBalancer.getLoadBalancerName() });

    // ?
    loadBalancer = loadBalancerDao.read(loadBalancerNo);
    loadBalancer.setStatus(LoadBalancerStatus.STOPPED.toString());
    loadBalancerDao.update(loadBalancer);

    // ??
    List<LoadBalancerListener> listeners = loadBalancerListenerDao.readByLoadBalancerNo(loadBalancerNo);
    for (LoadBalancerListener listener : listeners) {
        LoadBalancerListenerStatus status2 = LoadBalancerListenerStatus.fromStatus(listener.getStatus());
        if (status2 != LoadBalancerListenerStatus.STOPPED) {
            listener.setStatus(LoadBalancerListenerStatus.STOPPED.toString());
            loadBalancerListenerDao.update(listener);
        }
    }

    List<LoadBalancerInstance> lbInstances = loadBalancerInstanceDao.readByLoadBalancerNo(loadBalancerNo);
    for (LoadBalancerInstance lbInstance : lbInstances) {
        LoadBalancerInstanceStatus status2 = LoadBalancerInstanceStatus.fromStatus(lbInstance.getStatus());
        if (status2 != LoadBalancerInstanceStatus.STOPPED) {
            lbInstance.setStatus(LoadBalancerInstanceStatus.STOPPED.toString());
            loadBalancerInstanceDao.update(lbInstance);
        }
    }

    if (log.isInfoEnabled()) {
        log.info(
                MessageUtils.getMessage("IPROCESS-200004", loadBalancerNo, loadBalancer.getLoadBalancerName()));
    }
}

From source file:com.haulmont.cuba.web.app.ui.jmxcontrol.util.AttributeEditor.java

public Object getAttributeValue(boolean allowNull) {
    if (checkBox != null) {
        Boolean value = checkBox.getValue();
        return BooleanUtils.isTrue(value);
    } else if (dateField != null) {
        Date date = dateField.getValue();
        return date;
    } else if (textField != null) {
        String strValue = textField.getValue();
        if (allowNull && StringUtils.isBlank(strValue)) {
            return null;
        } else {/* w  w w  .ja  v  a  2  s  .  c o  m*/
            if (strValue == null)
                strValue = "";
            return AttributeHelper.convert(type, strValue);
        }
    } else if (layout != null) {
        if (AttributeHelper.isList(type)) {
            return getValuesFromArrayLayout(layout);
        } else if (AttributeHelper.isArray(type)) {
            Class clazz = AttributeHelper.getArrayType(type);
            if (clazz != null) {
                List<String> strValues = getValuesFromArrayLayout(layout);
                Object array = Array.newInstance(clazz, strValues.size());
                for (int i = 0; i < strValues.size(); i++) {
                    Array.set(array, i, AttributeHelper.convert(clazz.getName(), strValues.get(i)));
                }
                return array;
            }
        }
    }
    return null;
}

From source file:ext.tmt.utils.EPMUtil.java

/**
* get the latest iterated epmdocument by the softtype
* the method will be run at server side//  www.ja va  2  s . com
* @param softType
* @param ibaConditionMap
* @param isLatest
*/
public static Vector getEPMDocumentsByTypeAndIBA(String softType, Map ibaConditionMap, boolean isLatest) {
    if (!RemoteMethodServer.ServerFlag) {
        try {
            return (Vector) RemoteMethodServer.getDefault().invoke("getEPMDocumentsByTypeAndIBA",
                    EPMUtil.class.getName(), null, new Class[] { String.class, Map.class, Boolean.class },
                    new Object[] { softType, ibaConditionMap, isLatest });
        } catch (Exception e) {
            log.error(ExceptionUtils.getStackTrace(e));
        }
    }
    try {
        Vector vec = new Vector();
        QuerySpec querySpec = new QuerySpec(EPMDocument.class);
        TypeDefinitionReference softTypeDefRef = TypedUtilityServiceHelper.service
                .getTypeDefinitionReference(softType);
        SearchCondition typeCondition = new SearchCondition(EPMDocument.class,
                EPMDocument.TYPE_DEFINITION_REFERENCE + ".key.branchId", SearchCondition.EQUAL,
                softTypeDefRef.getKey().getBranchId());
        querySpec.appendWhere(typeCondition);
        if (BooleanUtils.isTrue(isLatest)) {
            querySpec = new LatestConfigSpec().appendSearchCriteria(querySpec);
        }
        if (!MapUtils.isEmpty(ibaConditionMap)) {
            for (Iterator iter = ibaConditionMap.entrySet().iterator(); iter.hasNext();) {
                Entry entry = (Entry) iter.next();
                //             appendStringIBACondition(querySpec, entry.getKey().toString(),SearchCondition.EQUAL, entry.getValue().toString());
                appendStringIBACondition(querySpec, entry.getKey().toString(), SearchCondition.EQUAL,
                        entry.getValue().toString().toUpperCase());
            }
        }
        querySpec.appendOrderBy(EPMDocument.class, EPMDocument.MODIFY_TIMESTAMP, true);
        log.debug("querySpec=" + querySpec);
        QueryResult queryResult = PersistenceHelper.manager.find(querySpec);
        while (queryResult.hasMoreElements()) {
            Object obj = queryResult.nextElement();
            if (obj instanceof Persistable)
                vec.add(obj);
            else if (obj instanceof Persistable[])
                vec.add(((Persistable[]) obj)[0]);
        }
        return vec;
    } catch (Exception e) {
        log.error(ExceptionUtils.getStackTrace(e));
    }
    return null;
}

From source file:com.haulmont.cuba.core.app.scheduling.RunnerBean.java

protected void registerExecutionFinish(ScheduledTask task, ScheduledExecution execution, Object result) {
    if ((!BooleanUtils.isTrue(task.getLogFinish()) && !BooleanUtils.isTrue(task.getSingleton())
            && task.getSchedulingType() != SchedulingType.FIXED_DELAY) || execution == null)
        return;//from   w ww. ja  v a2  s  .  c  om

    log.trace("{}: registering execution finish", task);
    Transaction tx = persistence.createTransaction();
    try {
        EntityManager em = persistence.getEntityManager();
        execution = em.merge(execution);
        execution.setFinishTime(timeSource.currentTimestamp());
        if (result != null)
            execution.setResult(result.toString());

        tx.commit();
    } finally {
        tx.end();
    }
}

From source file:com.haulmont.cuba.gui.dynamicattributes.DynamicAttributesGuiTools.java

public void initDefaultAttributeValues(BaseGenericIdEntity item, MetaClass metaClass) {
    Preconditions.checkNotNullArgument(metaClass, "metaClass is null");
    Collection<CategoryAttribute> attributes = dynamicAttributes.getAttributesForMetaClass(metaClass);
    if (item.getDynamicAttributes() == null) {
        item.setDynamicAttributes(new HashMap<>());
    }//from  w  w  w  . ja va 2  s.co  m
    Date currentTimestamp = AppBeans.get(TimeSource.NAME, TimeSource.class).currentTimestamp();
    boolean entityIsCategorized = item instanceof Categorized && ((Categorized) item).getCategory() != null;

    for (CategoryAttribute categoryAttribute : attributes) {
        String code = DynamicAttributesUtils.encodeAttributeCode(categoryAttribute.getCode());
        if (entityIsCategorized
                && !categoryAttribute.getCategory().equals(((Categorized) item).getCategory())) {
            item.setValue(code, null);//cleanup attributes from not dedicated category
            continue;
        }

        if (item.getValue(code) != null) {
            continue;//skip not null attributes
        }

        if (categoryAttribute.getDefaultValue() != null) {
            if (BooleanUtils.isTrue(categoryAttribute.getIsEntity())) {
                MetaClass entityMetaClass = metadata.getClassNN(categoryAttribute.getJavaClassForEntity());
                LoadContext<Entity> lc = new LoadContext<>(entityMetaClass).setView(View.MINIMAL);
                String pkName = referenceToEntitySupport.getPrimaryKeyForLoadingEntity(entityMetaClass);
                lc.setQueryString(
                        format("select e from %s e where e.%s = :entityId", entityMetaClass.getName(), pkName))
                        .setParameter("entityId", categoryAttribute.getDefaultValue());
                Entity defaultEntity = dataManager.load(lc);
                item.setValue(code, defaultEntity);
            } else {
                item.setValue(code, categoryAttribute.getDefaultValue());
            }
        } else if (Boolean.TRUE.equals(categoryAttribute.getDefaultDateIsCurrent())) {
            item.setValue(code, currentTimestamp);
        }
    }
}

From source file:com.haulmont.cuba.gui.app.core.categories.CategoryAttrsFrame.java

protected void initDefaultValueColumn() {
    categoryAttrsTable.addGeneratedColumn("defaultValue", new Table.ColumnGenerator<CategoryAttribute>() {
        @Override//from   www .  j a v  a2 s  . co m
        public Component generateCell(CategoryAttribute attribute) {
            String defaultValue = "";

            if (BooleanUtils.isNotTrue(attribute.getIsEntity())) {
                PropertyType dataType = attribute.getDataType();
                switch (dataType) {
                case DATE:
                    Date date = attribute.getDefaultDate();
                    if (date != null) {
                        String dateTimeFormat = Datatypes.getFormatStringsNN(userSessionSource.getLocale())
                                .getDateTimeFormat();
                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateTimeFormat);
                        defaultValue = simpleDateFormat.format(date);
                    } else if (BooleanUtils.isTrue(attribute.getDefaultDateIsCurrent())) {
                        defaultValue = getMessage("currentDate");
                    }
                    break;
                case BOOLEAN:
                    Boolean b = attribute.getDefaultBoolean();
                    if (b != null)
                        defaultValue = BooleanUtils.isTrue(b) ? getMessage("msgTrue") : getMessage("msgFalse");
                    break;
                default:
                    if (attribute.getDefaultValue() != null)
                        defaultValue = attribute.getDefaultValue().toString();
                }
            } else {
                Class entityClass = attribute.getJavaClassForEntity();
                if (entityClass != null) {
                    defaultValue = "";
                    if (attribute.getObjectDefaultEntityId() != null) {
                        MetaClass metaClass = metadata.getClassNN(entityClass);
                        LoadContext<Entity> lc = new LoadContext<>(entityClass).setView(View.MINIMAL);
                        String pkName = referenceToEntitySupport.getPrimaryKeyForLoadingEntity(metaClass);
                        lc.setQueryString(format("select e from %s e where e.%s = :entityId",
                                metaClass.getName(), pkName))
                                .setParameter("entityId", attribute.getObjectDefaultEntityId());
                        Entity entity = dataManager.load(lc);
                        if (entity != null) {
                            defaultValue = InstanceUtils.getInstanceName(entity);
                        }
                    }
                } else {
                    defaultValue = getMessage("entityNotFound");
                }
            }

            Label defaultValueLabel = factory.createComponent(Label.class);
            defaultValueLabel.setValue(defaultValue);
            return defaultValueLabel;
        }
    });
}

From source file:com.haulmont.cuba.web.app.folders.FolderEditWindow.java

public FolderEditWindow(boolean adding, Folder folder, Presentations presentations, Runnable commitHandler) {
    this.folder = folder;
    this.commitHandler = commitHandler;

    messages = AppBeans.get(Messages.NAME);
    messagesPack = AppConfig.getMessagesPack();
    userSessionSource = AppBeans.get(UserSessionSource.NAME);
    Configuration configuration = AppBeans.get(Configuration.NAME);
    clientConfig = configuration.getConfig(ClientConfig.class);

    setCaption(adding ? getMessage("folders.folderEditWindow.adding") : getMessage("folders.folderEditWindow"));

    ThemeConstants theme = App.getInstance().getThemeConstants();
    setWidthUndefined();//from w w  w. j  a v  a2 s  .c  o m
    setResizable(false);

    int[] modifiers = { ShortcutAction.ModifierKey.CTRL };
    addAction(new ShortcutListener("commit", com.vaadin.event.ShortcutAction.KeyCode.ENTER, modifiers) {
        @Override
        public void handleAction(Object sender, Object target) {
            commit();
        }
    });

    layout = new VerticalLayout();
    layout.setWidthUndefined();
    layout.setSpacing(true);

    setContent(layout);
    setModal(true);
    center();

    String fieldWidth = theme.get("cuba.web.FolderEditWindow.field.width");

    nameField = new TextField();
    nameField.setRequired(true);
    nameField.setCaption(getMessage("folders.folderEditWindow.nameField"));
    nameField.setWidth(fieldWidth);
    nameField.setValue(folder.getName());
    nameField.focus();
    layout.addComponent(nameField);

    tabNameField = new TextField();
    tabNameField.setCaption(getMessage("folders.folderEditWindow.tabNameField"));
    tabNameField.setWidth(fieldWidth);
    tabNameField.setValue(StringUtils.trimToEmpty(folder.getTabName()));
    layout.addComponent(tabNameField);

    parentSelect = new ComboBox();
    parentSelect.setCaption(getMessage("folders.folderEditWindow.parentSelect"));
    parentSelect.setWidth(fieldWidth);
    parentSelect.setNullSelectionAllowed(true);
    fillParentSelect();
    parentSelect.setValue(folder.getParent());
    layout.addComponent(parentSelect);

    if (folder instanceof SearchFolder) {
        if (presentations != null) {
            presentation = new ComboBox();
            presentation.setCaption(getMessage("folders.folderEditWindow.presentation"));
            presentation.setWidth(fieldWidth);
            presentation.setNullSelectionAllowed(true);
            fillPresentations(presentations);
            presentation.setValue(((SearchFolder) folder).getPresentation());
            layout.addComponent(presentation);
        } else if (((SearchFolder) folder).getPresentation() != null) {
            selectedPresentationField = new TextField();
            selectedPresentationField.setWidth(fieldWidth);
            selectedPresentationField.setCaption(getMessage("folders.folderEditWindow.presentation"));
            selectedPresentationField.setValue(((SearchFolder) folder).getPresentation().getName());
            selectedPresentationField.setEnabled(false);
            layout.addComponent(selectedPresentationField);
        }
    }

    sortOrderField = new TextField();
    sortOrderField.setCaption(getMessage("folders.folderEditWindow.sortOrder"));
    sortOrderField.setWidth(fieldWidth);
    sortOrderField.setValue(folder.getSortOrder() == null ? "" : folder.getSortOrder().toString());
    layout.addComponent(sortOrderField);

    if (userSessionSource.getUserSession().isSpecificPermitted("cuba.gui.searchFolder.global")
            && folder instanceof SearchFolder && BooleanUtils.isNotTrue(((SearchFolder) folder).getIsSet())) {
        globalCb = new CubaCheckBox(getMessage("folders.folderEditWindow.global"));
        globalCb.setValue(((SearchFolder) folder).getUser() == null);
        layout.addComponent(globalCb);
    }

    applyDefaultCb = new CubaCheckBox(getMessage("folders.folderEditWindow.applyDefault"));
    applyDefaultCb.setValue(BooleanUtils.isTrue(((AbstractSearchFolder) folder).getApplyDefault()));
    applyDefaultCb.setVisible(clientConfig.getGenericFilterManualApplyRequired()
            && folder instanceof SearchFolder && BooleanUtils.isNotTrue(((SearchFolder) folder).getIsSet()));
    layout.addComponent(applyDefaultCb);

    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.setMargin(new MarginInfo(true, false, false, false));
    buttonsLayout.setSpacing(true);
    layout.addComponent(buttonsLayout);

    okBtn = new CubaButton(getMessage("actions.Ok"));
    okBtn.setIcon(WebComponentsHelper.getIcon("icons/ok.png"));
    okBtn.addStyleName(WebButton.ICON_STYLE);

    initButtonOkListener();
    buttonsLayout.addComponent(okBtn);

    cancelBtn = new CubaButton(getMessage("actions.Cancel"));
    cancelBtn.setIcon(WebComponentsHelper.getIcon("icons/cancel.png"));
    cancelBtn.addStyleName(WebButton.ICON_STYLE);
    cancelBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    buttonsLayout.addComponent(cancelBtn);

    if (AppUI.getCurrent().isTestMode()) {
        setCubaId("folderEditWindow");

        nameField.setCubaId("nameField");
        tabNameField.setCubaId("tabNameField");
        parentSelect.setCubaId("parentSelect");
        if (presentation != null) {
            presentation.setCubaId("presentationSelect");
        }
        sortOrderField.setCubaId("sortOrderField");
        if (selectedPresentationField != null) {
            selectedPresentationField.setCubaId("selectedPresentationField");
        }
        if (globalCb != null) {
            globalCb.setCubaId("globalCb");
        }
        applyDefaultCb.setCubaId("applyDefaultCb");
        okBtn.setCubaId("okBtn");
        cancelBtn.setCubaId("cancelBtn");
    }
}

From source file:com.haulmont.ext.web.ui.Call.CallBrowser.java

@Override
public void init(Map<String, Object> params) {
    super.init(params);
    //? ?  ? :// w  w  w  .jav  a2  s .c  om
    callTable.setMultiSelect(true);
    isTemplate = false;
    TableActionsHelper helper = new TableActionsHelper(this, callTable);
    helper.createRefreshAction();
    final Action removeAction = callTable.getAction("remove");
    final TaskmanService taskmanService = ServiceLocator.lookup(TaskmanService.NAME);
    callDs.addListener(new CollectionDsListenerAdapter() {
        @Override
        public void itemChanged(Datasource ds, Entity prevItem, Entity item) {
            super.itemChanged(ds, prevItem, item);

            if (editAction != null && editAction.getOwner() != null)
                ((Button) editAction.getOwner()).setEnabled(item != null);

            if (item == null)
                return;

            // ADMINISTRATOR_ROLE can remove any task, the CREATOR,
            // NOT INITIATOR only not sent on process
            Card card = (Card) ds.getItem();
            User subCreator = card.getSubstitutedCreator();
            User currentUser = UserSessionClient.getUserSession().getCurrentOrSubstitutedUser();
            Set<Card> selected = callTable.getSelected();
            boolean allowRemove = true;
            if (selected.size() > 1) {
                for (Card c : selected) {
                    if (taskmanService.isCurrentUserAdministrator()) {
                        break;
                    } else if (!(currentUser.equals(c.getSubstitutedCreator())
                            && (StringUtils.isBlank(c.getState()) || WfUtils.isCardInState(c, "New")))) {
                        allowRemove = false;
                        break;
                    }
                }
                removeAction.setEnabled(allowRemove);
                if (removeAction.getOwner() != null)
                    ((Button) removeAction.getOwner()).setEnabled(allowRemove);
            } else {
                allowRemove = taskmanService.isCurrentUserAdministrator() || (currentUser.equals(subCreator)
                        && (StringUtils.isBlank(((Card) ds.getItem()).getState())
                                || WfUtils.isCardInState((Card) ds.getItem(), "New")));
                removeAction.setEnabled(allowRemove);
                if (removeAction.getOwner() != null)
                    ((Button) removeAction.getOwner()).setEnabled(allowRemove);
            }

            if ((showResolutions != null) && BooleanUtils.isTrue((Boolean) showResolutions.getValue())
                    && (item == null || callTable.getSelected().size() < 2)) {
                String currentTab = tabsheet.getTab().getName();
                if (currentTab.equals("resolutionsTab") && resolutionsFrame != null)
                    resolutionsFrame.setCard((Card) item);
                if (currentTab.equals("hierarchyTab") && cardTreeFrame != null)
                    cardTreeFrame.setCard((Card) item);
            }
        }

        @Override
        public void stateChanged(Datasource ds, Datasource.State prevState, Datasource.State state) {
            if (removeAction != null && removeAction.getOwner() != null)
                ((Button) removeAction.getOwner())
                        .setEnabled(Datasource.State.VALID.equals(state) && ds.getItem() != null);
            if (editAction != null && editAction.getOwner() != null)
                ((Button) editAction.getOwner())
                        .setEnabled(Datasource.State.VALID.equals(state) && ds.getItem() != null);
        }

        @Override
        public void collectionChanged(CollectionDatasource ds, Operation operation) {
            refresh();
        }
    });
    callTable.getDatasource().addListener(new CollectionDsListenerAdapter() {
        public void collectionChanged(CollectionDatasource ds,
                CollectionDatasourceListener.Operation operation) {
            loadCardInfoList();
        }
    });

    callTable.addAction(new AbstractAction("createDoc") {
        public void actionPerform(Component component) {
            Doc docPattern = (Doc) getDsContext().get("docsDs").getItem();
            if (docPattern != null) {
                LoadContext loadContext = new LoadContext(docPattern.getClass());
                loadContext.setId(docPattern.getId());
                loadContext.setView("copy");
                docPattern = ServiceLocator.getDataService().load(loadContext);
                Doc doc;
                try {
                    doc = docPattern.getClass().newInstance();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                doc.copyFrom(docPattern);
                NumerationService ns = ServiceLocator.lookup(NumerationService.NAME);
                if (StringUtils.isBlank(docPattern.getNumber()) && doc.getDocKind() != null
                        && NumeratorType.ON_CREATE.equals(doc.getDocKind().getNumeratorType())) {
                    String num = ns.getNextNumber(doc);
                    if (num != null)
                        doc.setNumber(num);
                }
                doc.setCreateDate(TimeProvider.currentTimestamp());
                doc.setTemplate(false);
                doc.setCreator(UserSessionClient.getUserSession().getUser());
                doc.setSubstitutedCreator(UserSessionClient.getUserSession().getCurrentOrSubstitutedUser());
                Map<String, Object> params = new HashMap<String, Object>();
                params.put("justCreated", true);
                params.put("initialTemplate", docPattern);
                Window editor = openEditor(entityName + ".edit", doc, WindowManager.OpenType.THIS_TAB, params);
                editor.addListener(new CloseListener() {
                    public void windowClosed(String actionId) {
                        // refresh browser regardless of actionId as the new document
                        // could be saved by DocCreator
                        refresh();
                    }
                });
            } else {
                showNotification(getMessage("selectDocPattern.msg"), IFrame.NotificationType.HUMANIZED);
            }
        }

        @Override
        public String getCaption() {
            return getMessage("actions.createDoc");
        }

        @Override
        public boolean isVisible() {
            return super.isVisible() && isTemplate;
        }
    });

    if (createButton != null) {
        //   ?  ?  
        //  .  ??   ? ?
        //? ? 
        createButton.setEnabled(UserSessionProvider.getUserSession().isEntityOpPermitted(callDs.getMetaClass(),
                EntityOp.CREATE));
        // ?? "  "
        createButton.addAction(new CreateAction(callTable) {
            //  ?      ?
            @Override
            public String getCaption() {
                final String messagesPackage = getMessagesPack();
                return MessageProvider.getMessage(messagesPackage, "actions.CreateNew");
            }
        });
        // ?? " ?? "
        createButton.addAction(new CopyAction());
    }

    //  ?,    ?   ?? ?  ? ?? ?  
    //  ?   ,   ??    ??.
    callTable.addAction(new RemoveCardNullChildAction("remove", this, callTable));

    callTable.addAction(new EditAction());

    callTable.addAction(new RefreshAction(callTable));
    callTable.addAction(new ThesisExcelAction(callTable, new WebExportDisplay(), genericFilter));
    //  ?   ? 
    callTable.addAction(new DeleteNotification());

    cards = docflow_CardService.getCardsForCurrentUserActor();

    // ?  ?   ?? ?
    //?  ?
    initTableColoring();
    callDs.addListener(new DsListenerAdapter() {
        @Override
        public void stateChanged(Datasource ds, Datasource.State prevState, Datasource.State state) {
            super.stateChanged(ds, prevState, state);
            if (Datasource.State.VALID.equals(state)) {
                loadCardInfoList();
            }
            refresh();
        }
    });

    final Card exclItem = (Card) params.get("exclItem");
    if (exclItem != null) {
        this.setLookupValidator(new Window.Lookup.Validator() {
            public boolean validate() {
                Card selectedCard = callTable.getSingleSelected();
                CardService cardService = ServiceLocator.lookup(CardService.NAME);
                if (selectedCard != null && cardService.isDescendant(exclItem, selectedCard,
                        MetadataProvider.getViewRepository().getView(Card.class, "_minimal"), "parentCard")) {
                    showNotification(MessageProvider.getMessage(CallBrowser.class, "cardIsChild"),
                            IFrame.NotificationType.WARNING);
                    return false;
                }
                return true;
            }
        });
    }

    addCommentColumn();
    addHasAttachmentColumn();
    refresh();
}