public boolean checkStates() throws BadLocationException {
        dialog.addMessageToLogger("Checking states for assignment resources to the states", 1);
        boolean[] assignedStates = new boolean[pn.getStates().size()];
        for (State state : pn.getStates()) {
            int i = pn.getStates().indexOf(state);
            assignedStates[i] = false;
            int sumOfAssigned = 0;
            state.toString();

            for (Resource r : state.getPn().getListOfResources()) {
                for (int j = 0; j < r.getProcess().length; j++) {
                    sumOfAssigned += r.getProcess()[j];
                }
            }
            if (sumOfAssigned > 0) {
                assignedStates[i] = true;
            }
        }

        ArrayList<Integer> listOfUnassigned = new ArrayList<Integer>();
        for (int i = 0; i < assignedStates.length; i++) {
            if (!assignedStates[i]) {
                listOfUnassigned.add(i);
            }
        }
        //System.out.println("SUM OF ALL STATES:" + assignedStates.length);
        //System.out.println("SUM OF ASSIGNED STATES:" + (assignedStates.length - listOfUnassigned.size()));
        State newS = new State(pn.getState(), 0, null, pn);

        //System.out.println(newS.getKey().equals(pn.getStates().get(1).getKey()));
        //System.out.println(newS.getKey()==pn.getStates().get(1).getKey());
        if (listOfUnassigned.size() == 1 && newS.getKey().equals(pn.getStates().get(listOfUnassigned.get(0)).getKey())) {
            setAssignedResourcesToStates(true);
            dialog.addMessageToLogger("Valid assignment of resource to the states", 1);
            return true;
        } else {
            setAssignedResourcesToStates(false);
            dialog.addMessageToLogger("Invalid assignment of resource to the states", 3);
            return false;
        }
    }