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;
}
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);
}
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();
}
}
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();
}
}
Aggregations