Search in sources :

Example 21 with PolicyUnit

use of org.ovirt.engine.core.common.scheduling.PolicyUnit in project ovirt-engine by oVirt.

the class PolicyUnitListPanel method doDrag.

private boolean doDrag(DragDropEventBase<?> event, boolean isDrop) {
    String dragDropEventData = PolicyUnitPanel.getDragDropEventData(event, isDrop);
    // $NON-NLS-1$
    String[] split = dragDropEventData.split(" ");
    if (split != null && split.length == EVENT_DATA_COUNT) {
        if (!type.equals(split[0])) {
            return false;
        } else if (Boolean.valueOf(split[2]).equals(used)) {
            return false;
        }
    }
    PolicyUnit policyUnit = model.getPolicyUnitsMap().get(Guid.createGuidFromString(split[1]));
    if (PolicyUnitPanel.FILTER.equals(split[0])) {
        if (used) {
            model.addFilter(policyUnit, false, 0);
        } else {
            model.removeFilter(policyUnit);
        }
    } else if (FunctionPolicyUnitPanel.FUNCTION.equals(split[0])) {
        if (used) {
            model.addFunction(policyUnit);
        } else {
            model.removeFunction(policyUnit);
        }
    }
    return true;
}
Also used : PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit)

Example 22 with PolicyUnit

use of org.ovirt.engine.core.common.scheduling.PolicyUnit in project ovirt-engine by oVirt.

the class EvenDistributionWeightPolicyUnitTest method mockPolicyUnit.

protected <T extends EvenDistributionWeightPolicyUnit> T mockPolicyUnit(Class<T> unitType) throws Exception {
    final T policyUnit = unitType.getConstructor(PolicyUnit.class, PendingResourceManager.class).newInstance(null, new PendingResourceManager());
    policyUnit.setSlaValidator(slaValidator);
    return spy(policyUnit);
}
Also used : PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit) PendingResourceManager(org.ovirt.engine.core.bll.scheduling.pending.PendingResourceManager)

Example 23 with PolicyUnit

use of org.ovirt.engine.core.common.scheduling.PolicyUnit in project ovirt-engine by oVirt.

the class ClusterPolicyPopupView method updateFunctions.

private void updateFunctions(NewClusterPolicyModel model) {
    FunctionPolicyUnitPanel functionPolicyUnitPanel;
    usedFunctionPanel.clear();
    for (Pair<PolicyUnit, Integer> pair : model.getUsedFunctions()) {
        functionPolicyUnitPanel = new FunctionPolicyUnitPanel(pair.getFirst(), model, true, model.getClusterPolicy().isLocked(), style, pair.getSecond());
        usedFunctionPanel.add(functionPolicyUnitPanel);
        functionPolicyUnitPanel.initWidget();
    }
    unusedFunctionPanel.clear();
    for (PolicyUnit policyUnit : model.getUnusedFunctions()) {
        functionPolicyUnitPanel = new FunctionPolicyUnitPanel(policyUnit, model, false, model.getClusterPolicy().isLocked(), style, null);
        unusedFunctionPanel.add(functionPolicyUnitPanel);
        functionPolicyUnitPanel.initWidget();
    }
}
Also used : FunctionPolicyUnitPanel(org.ovirt.engine.ui.webadmin.section.main.view.popup.scheduling.panels.FunctionPolicyUnitPanel) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit)

Example 24 with PolicyUnit

use of org.ovirt.engine.core.common.scheduling.PolicyUnit in project ovirt-engine by oVirt.

the class ClusterPolicyPopupView method updateFilters.

private void updateFilters(NewClusterPolicyModel model) {
    usedFilterPanel.clear();
    PolicyUnitPanel first = null;
    PolicyUnitPanel last = null;
    List<PolicyUnitPanel> list = new ArrayList<>();
    PolicyUnitPanel tempPolicyUnitPanel;
    for (PolicyUnit policyUnit : model.getUsedFilters()) {
        tempPolicyUnitPanel = new PolicyUnitPanel(policyUnit, model, true, model.getClusterPolicy().isLocked(), style);
        Integer position = model.getFilterPositionMap().get(policyUnit.getId());
        if (position == null || position == 0) {
            list.add(tempPolicyUnitPanel);
        } else {
            if (position < 0) {
                first = tempPolicyUnitPanel;
            } else if (position > 0) {
                last = tempPolicyUnitPanel;
            }
            tempPolicyUnitPanel.setPosition(position);
        }
        tempPolicyUnitPanel.initWidget();
    }
    if (first != null) {
        usedFilterPanel.add(first);
    }
    for (PolicyUnitPanel policyUnitPanel : list) {
        usedFilterPanel.add(policyUnitPanel);
    }
    if (last != null) {
        usedFilterPanel.add(last);
    }
    unusedFilterPanel.clear();
    for (PolicyUnit policyUnit : model.getUnusedFilters()) {
        PolicyUnitPanel policyUnitPanel = new PolicyUnitPanel(policyUnit, model, false, model.getClusterPolicy().isLocked(), style);
        unusedFilterPanel.add(policyUnitPanel);
        policyUnitPanel.initWidget();
    }
}
Also used : PolicyUnitPanel(org.ovirt.engine.ui.webadmin.section.main.view.popup.scheduling.panels.PolicyUnitPanel) FunctionPolicyUnitPanel(org.ovirt.engine.ui.webadmin.section.main.view.popup.scheduling.panels.FunctionPolicyUnitPanel) ArrayList(java.util.ArrayList) PolicyUnit(org.ovirt.engine.core.common.scheduling.PolicyUnit)

Aggregations

PolicyUnit (org.ovirt.engine.core.common.scheduling.PolicyUnit)24 Guid (org.ovirt.engine.core.compat.Guid)7 ArrayList (java.util.ArrayList)6 LinkedHashMap (java.util.LinkedHashMap)5 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ClusterPolicy (org.ovirt.engine.core.common.scheduling.ClusterPolicy)4 HashSet (java.util.HashSet)2 RankSelectorPolicyUnit (org.ovirt.engine.core.bll.scheduling.policyunits.RankSelectorPolicyUnit)2 Pair (org.ovirt.engine.core.common.utils.Pair)2 FunctionPolicyUnitPanel (org.ovirt.engine.ui.webadmin.section.main.view.popup.scheduling.panels.FunctionPolicyUnitPanel)2 ImageResource (com.google.gwt.resources.client.ImageResource)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 Column (com.google.gwt.user.cellview.client.Column)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1