Examples of TurnoutGroup


Examples of ch.fork.AdHocRailway.domain.turnouts.TurnoutGroup

            }
            TurnoutConfig config = null;
            int selectedGroupPane = turnoutGroupsTabbedPane.getSelectedIndex();

            do {
                TurnoutGroup selectedTurnoutGroup = indexToTurnoutGroup
                        .get(selectedGroupPane);
                int nextNumber = 0;
                TurnoutPersistenceIface turnoutPersistence = AdHocRailway
                        .getInstance().getTurnoutPersistence();
                if (Preferences
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.TurnoutGroup

            if (previousSelectedGroup != null) {
                // turnoutPersistence.updateTurnoutGroup(previousSelectedGroup);
            }
            if (turnoutGroupList.getSelectedIndex() == -1)
                turnoutGroupList.setSelectedIndex(0);
            TurnoutGroup selectedGroup = (TurnoutGroup) turnoutGroupList
                    .getSelectedValue();
            if (selectedGroup == null)
                return;
            previousSelectedGroup = selectedGroup;
            List<Turnout> turnouts = new ArrayList<Turnout>(
                    selectedGroup.getTurnouts());
            turnoutGroupConfig.setTurnoutGroup(selectedGroup);
            turnoutModel.setList(turnouts);
            TableResizer.adjustColumnWidths(turnoutsTable, 5);
        }
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.TurnoutGroup

        public Component getListCellRendererComponent(JList list, Object value,
                int index, boolean isSelected, boolean cellHasFocus) {
            Component component = super.getListCellRendererComponent(list,
                    value, index, isSelected, cellHasFocus);

            TurnoutGroup group = (TurnoutGroup) value;
            setText(group == null ? "" : (" " + group.getName()));
            return component;
        }
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.TurnoutGroup

                    "Add Turnout-Group", JOptionPane.QUESTION_MESSAGE);
            if (newGroupName == null)
                return;
            TurnoutPersistenceIface turnoutPersistence = AdHocRailway
                    .getInstance().getTurnoutPersistence();
            TurnoutGroup newTurnoutGroup = new TurnoutGroup();
            newTurnoutGroup.setName(newGroupName);
            if (Preferences.getInstance().getBooleanValue(
                    PreferencesKeys.USE_FIXED_TURNOUT_AND_ROUTE_GROUP_SIZES)) {
                String newAmount = JOptionPane.showInputDialog(
                        TurnoutConfigurationDialog.this,
                        "How many Turnouts should be in this group?", "10");
                int newOffset = 1;
                for (TurnoutGroup group : turnoutPersistence
                        .getAllTurnoutGroups()) {
                    newOffset += group.getTurnoutNumberAmount();
                }
                newTurnoutGroup.setTurnoutNumberOffset(newOffset);
                newTurnoutGroup.setTurnoutNumberAmount(Integer
                        .parseInt(newAmount));
            }

            previousSelectedGroup = null;
            turnoutPersistence.addTurnoutGroup(newTurnoutGroup);
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.TurnoutGroup

        public RemoveTurnoutGroupAction() {
            super("Remove Group", ImageTools.createImageIcon("remove.png"));
        }

        public void actionPerformed(ActionEvent arg0) {
            TurnoutGroup groupToDelete = (TurnoutGroup) (turnoutGroupList
                    .getSelectedValue());
            if (groupToDelete == null) {
                JOptionPane.showMessageDialog(TurnoutConfigurationDialog.this,
                        "Please select a Turnout-Group", "Error",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            int response = JOptionPane.showConfirmDialog(
                    TurnoutConfigurationDialog.this,
                    "Really remove Turnout-Group '" + groupToDelete.getName()
                            + "' ?", "Remove Turnout-Group",
                    JOptionPane.YES_NO_OPTION);
            if (response == JOptionPane.YES_OPTION) {
                TurnoutPersistenceIface turnoutPersistence = AdHocRailway
                        .getInstance().getTurnoutPersistence();
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.TurnoutGroup

        public AddTurnoutAction() {
            super("Add", ImageTools.createImageIcon("add.png"));
        }

        public void actionPerformed(ActionEvent e) {
            TurnoutGroup selectedTurnoutGroup = (TurnoutGroup) (turnoutGroupList
                    .getSelectedValue());
            if (selectedTurnoutGroup == null) {
                JOptionPane.showMessageDialog(TurnoutConfigurationDialog.this,
                        "Please select a switch group", "Error",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            int nextNumber = 0;
            TurnoutPersistenceIface turnoutPersistence = AdHocRailway
                    .getInstance().getTurnoutPersistence();
            if (Preferences.getInstance().getBooleanValue(
                    PreferencesKeys.USE_FIXED_TURNOUT_AND_ROUTE_GROUP_SIZES)) {
                nextNumber = turnoutPersistence
                        .getNextFreeTurnoutNumberOfGroup(selectedTurnoutGroup);
                if (nextNumber == -1) {
                    JOptionPane.showMessageDialog(
                            TurnoutConfigurationDialog.this,
                            "No more free numbers in this group", "Error",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }
            } else {
                nextNumber = turnoutPersistence.getNextFreeTurnoutNumber();
            }
            Turnout newTurnout = new Turnout();
            newTurnout.setNumber(nextNumber);

            newTurnout.setBus1(Preferences.getInstance().getIntValue(
                    PreferencesKeys.DEFAULT_TURNOUT_BUS));
            newTurnout.setBus2(Preferences.getInstance().getIntValue(
                    PreferencesKeys.DEFAULT_TURNOUT_BUS));

            newTurnout.setTurnoutGroup(selectedTurnoutGroup);
            newTurnout.setDefaultStateEnum(SRCPTurnoutState.STRAIGHT);
            newTurnout.setOrientationEnum(TurnoutOrientation.EAST);
            newTurnout.setTurnoutType(turnoutPersistence
                    .getTurnoutType(SRCPTurnoutTypes.DEFAULT));

            TurnoutConfig switchConfig = new TurnoutConfig(
                    TurnoutConfigurationDialog.this, newTurnout);
            if (switchConfig.isOkPressed()) {
                List<Turnout> turnouts = new ArrayList<Turnout>(
                        selectedTurnoutGroup.getTurnouts());
                turnoutModel.setList(turnouts);
            }
        }
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.TurnoutGroup

        public void actionPerformed(ActionEvent e) {
            if (turnoutsTable.isEditing())
                turnoutsTable.getCellEditor().stopCellEditing();

            TurnoutGroup selectedTurnoutGroup = (TurnoutGroup) (turnoutGroupList
                    .getSelectedValue());
            int[] rows = turnoutsTable.getSelectedRows();
            int[] numbers = new int[rows.length];
            int i = 0;
            for (int row : rows) {
                numbers[i] = (Integer) turnoutsTable.getValueAt(row, 0);
                i++;
            }
            TurnoutPersistenceIface turnoutPersistence = AdHocRailway
                    .getInstance().getTurnoutPersistence();
            for (int number : numbers) {
                turnoutPersistence.deleteTurnout(turnoutPersistence
                        .getTurnoutByNumber(number));
            }
            List<Turnout> turnouts = new ArrayList<Turnout>(
                    selectedTurnoutGroup.getTurnouts());
            turnoutModel.setList(turnouts);
            turnoutsTable.clearSelection();
        }
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.TurnoutGroup

    // Event Handlers
    public void startElement(String uri, String localName, String qName,
            Attributes attributes) throws SAXException {
        qName = qName.toLowerCase();
        if (qName.equals("switchgroup")) {
            actualTurnoutGroup = new TurnoutGroup(0,
                    attributes.getValue("name"), 0, 0);

            turnoutPersistence.addTurnoutGroup(actualTurnoutGroup);
        } else if (qName.equals("switch")) {
            parseTurnout(qName, attributes);
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.TurnoutGroup

        int turnoutNumberOffset = Integer.parseInt(attributes
                .getValue("turnoutNumberOffset"));
        int turnoutAmount = Integer.parseInt(attributes
                .getValue("turnoutAmount"));

        actualTurnoutGroup = new TurnoutGroup(0, name, turnoutNumberOffset,
                turnoutAmount);

        turnoutPersistence.addTurnoutGroup(actualTurnoutGroup);
    }
View Full Code Here

Examples of ch.fork.AdHocRailway.domain.turnouts.TurnoutGroup

    // Event Handlers
    public void startElement(String uri, String localName, String qName,
            Attributes attributes) throws SAXException {
        qName = qName.toLowerCase();
        if (qName.equals("switchgroup")) {
            actualTurnoutGroup = new TurnoutGroup(0,
                    attributes.getValue("name"), 0, 0);

            turnoutPersistence.addTurnoutGroup(actualTurnoutGroup);

        } else if (qName.equals("switch")) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.