summaryrefslogtreecommitdiffstats
path: root/rba.tool.core/src/rba/tool/core/sort/SortValueManager.java
blob: 17fbb37b7faf00ad2fe33af9059730fb87c5d4b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package rba.tool.core.sort;

import org.eclipse.core.resources.IProject;

import rba.tool.core.console.ConsoleManager;
import rba.tool.core.z3.Z3CodeManager;

public class SortValueManager {

    public static SortValueManager INSTANCE = new SortValueManager();

    private static final String CONSOLE_TITLE = "#### Execution of Constraint ####";

    private SortValue areaZorderSortValue = new SortValue();

    private SortValue visibilitySortValue = new SortValue();;

    private SortValue csPrioritySortValue = new SortValue();;

    private static final String NOTIFIER_ID = "rba.tool.core.CalculateSortValue";

    public boolean updateSortValue(IProject project) {

        try {
            ISortValueCalculation calc = Z3CodeManager.INSTNACE.getSortCaluculator(project);
            calc.setUp();
            areaZorderSortValue.setSortValue(calc.calculateArea_zorder());
            visibilitySortValue.setSortValue(calc.calculateAllocatable_visibility());
            csPrioritySortValue.setSortValue(calc.calculateContentState_priority());
            calc.close();

        } catch (RuntimeException e) {
            ConsoleManager.INSTANCE.output(CONSOLE_TITLE, NOTIFIER_ID);
            ConsoleManager.INSTANCE.output(e.getMessage(), NOTIFIER_ID);
            ConsoleManager.INSTANCE.output("##################", NOTIFIER_ID);

            areaZorderSortValue.clear();
            visibilitySortValue.clear();
            csPrioritySortValue.clear();
            return false;
        }
        return true;
    }

    public SortValue getAreaZorderSortValue() {
        return areaZorderSortValue;
    }

    public SortValue getAllocatableVisibilitySortValue() {
        return visibilitySortValue;
    }

    public SortValue getCsPrioritySortValue() {
        return csPrioritySortValue;
    }
}