Search in sources :

Example 71 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project sling by apache.

the class InstallEditorSection method init.

public void init(IEditorSite site, IEditorInput input) {
    super.init(site, input);
    serverListener = new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (ISlingLaunchpadServer.PROP_INSTALL_LOCALLY.equals(evt.getPropertyName())) {
                quickLocalInstallButton.setSelection((Boolean) evt.getNewValue());
                bundleLocalInstallButton.setSelection(!(Boolean) evt.getNewValue());
            }
        }
    };
    server.addPropertyChangeListener(serverListener);
    launchpadServer = (ISlingLaunchpadServer) server.getAdapter(ISlingLaunchpadServer.class);
    if (launchpadServer == null) {
        // TODO progress monitor
        launchpadServer = (ISlingLaunchpadServer) server.loadAdapter(ISlingLaunchpadServer.class, new NullProgressMonitor());
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Example 72 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project JMRI by JMRI.

the class RosterFrame method createTop.

JComponent createTop() {
    Object selectedRosterGroup = prefsMgr.getProperty(getWindowFrameRef(), SELECTED_ROSTER_GROUP);
    groups = new RosterGroupsPanel((selectedRosterGroup != null) ? selectedRosterGroup.toString() : null);
    groups.setNewWindowMenuAction(this.getNewWindowAction());
    setTitle(groups.getSelectedRosterGroup());
    final JPanel rosters = new JPanel();
    rosters.setLayout(new BorderLayout());
    // set up roster table
    rtable = new RosterTable(true, ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    rtable.setRosterGroup(this.getSelectedRosterGroup());
    rtable.setRosterGroupSource(groups);
    rosters.add(rtable, BorderLayout.CENTER);
    // add selection listener
    rtable.getTable().getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> {
        JTable table = rtable.getTable();
        if (!e.getValueIsAdjusting()) {
            if (rtable.getSelectedRosterEntries().length == 1 && table.getSelectedRow() >= 0) {
                log.debug("Selected row ", table.getSelectedRow());
                locoSelected(rtable.getModel().getValueAt(table.getRowSorter().convertRowIndexToModel(table.getSelectedRow()), RosterTableModel.IDCOL).toString());
            } else if (rtable.getSelectedRosterEntries().length > 1 || table.getSelectedRow() < 0) {
                locoSelected(null);
            }
        // leave last selected item visible if no selection
        }
    });
    //Set all the sort and width details of the table first.
    String rostertableref = getWindowFrameRef() + ":roster";
    rtable.getTable().setName(rostertableref);
    // Allow only one column to be sorted at a time - 
    // Java allows multiple column sorting, but to effectly persist that, we
    // need to be intelligent about which columns can be meaningfully sorted
    // with other columns; this bypasses the problem by only allowing the
    // last column sorted to affect sorting
    RowSorterUtil.addSingleSortableColumnListener(rtable.getTable().getRowSorter());
    // Reset and then persist the table's ui state
    JTablePersistenceManager tpm = InstanceManager.getNullableDefault(JTablePersistenceManager.class);
    if (tpm != null) {
        tpm.resetState(rtable.getTable());
        tpm.persist(rtable.getTable());
    }
    rtable.getTable().setDragEnabled(true);
    rtable.getTable().setTransferHandler(new TransferHandler() {

        @Override
        public int getSourceActions(JComponent c) {
            return TransferHandler.COPY;
        }

        @Override
        public Transferable createTransferable(JComponent c) {
            JTable table = rtable.getTable();
            ArrayList<String> Ids = new ArrayList<>(table.getSelectedRowCount());
            for (int i = 0; i < table.getSelectedRowCount(); i++) {
                Ids.add(rtable.getModel().getValueAt(table.getRowSorter().convertRowIndexToModel(table.getSelectedRows()[i]), RosterTableModel.IDCOL).toString());
            }
            return new RosterEntrySelection(Ids);
        }

        @Override
        public void exportDone(JComponent c, Transferable t, int action) {
        // nothing to do
        }
    });
    MouseListener rosterMouseListener = new rosterPopupListener();
    rtable.getTable().addMouseListener(rosterMouseListener);
    try {
        clickDelay = ((Integer) Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval"));
    } catch (RuntimeException e) {
        clickDelay = 500;
        log.debug("Unable to get the double click speed, Using JMRI default of half a second" + e.toString());
    }
    // assemble roster/groups splitpane
    rosterGroupSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, groups, rosters);
    rosterGroupSplitPane.setOneTouchExpandable(true);
    // emphasis rosters
    rosterGroupSplitPane.setResizeWeight(0);
    Object w = prefsMgr.getProperty(getWindowFrameRef(), "rosterGroupPaneDividerLocation");
    if (w != null) {
        groupSplitPaneLocation = (Integer) w;
        rosterGroupSplitPane.setDividerLocation(groupSplitPaneLocation);
    }
    if (!Roster.getDefault().getRosterGroupList().isEmpty()) {
        if (prefsMgr.getSimplePreferenceState(this.getClass().getName() + ".hideGroups")) {
            hideGroupsPane(true);
        }
    } else {
        enableRosterGroupMenuItems(false);
    }
    PropertyChangeListener propertyChangeListener = (PropertyChangeEvent changeEvent) -> {
        JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource();
        String propertyName = changeEvent.getPropertyName();
        if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
            int current = sourceSplitPane.getDividerLocation();
            hideGroups = current <= 1;
            Integer last = (Integer) changeEvent.getNewValue();
            if (current >= 2) {
                groupSplitPaneLocation = current;
            } else if (last >= 2) {
                groupSplitPaneLocation = last;
            }
        }
    };
    groups.addPropertyChangeListener(SELECTED_ROSTER_GROUP, new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            prefsMgr.setProperty(this.getClass().getName(), SELECTED_ROSTER_GROUP, pce.getNewValue());
            setTitle((String) pce.getNewValue());
        }
    });
    rosterGroupSplitPane.addPropertyChangeListener(propertyChangeListener);
    Roster.getDefault().addPropertyChangeListener((PropertyChangeEvent e) -> {
        if (e.getPropertyName().equals("RosterGroupAdded") && Roster.getDefault().getRosterGroupList().size() == 1) {
            // if the pane is hidden, show it when 1st group is created
            hideGroupsPane(false);
            enableRosterGroupMenuItems(true);
        } else if (!rtable.isVisible() && (e.getPropertyName().equals("saved"))) {
            if (firstHelpLabel != null) {
                firstHelpLabel.setVisible(false);
            }
            rtable.setVisible(true);
            rtable.resetColumnWidths();
        }
    });
    if (Roster.getDefault().numEntries() == 0) {
        try {
            BufferedImage myPicture = ImageIO.read(FileUtil.findURL(("resources/" + Bundle.getMessage("ThrottleFirstUseImage")), FileUtil.Location.INSTALLED));
            //rosters.add(new JLabel(new ImageIcon( myPicture )), BorderLayout.CENTER);
            firstHelpLabel = new JLabel(new ImageIcon(myPicture));
            rtable.setVisible(false);
            rosters.add(firstHelpLabel, BorderLayout.NORTH);
            //tableArea.add(firstHelpLabel);
            rtable.setVisible(false);
        } catch (IOException ex) {
        // handle exception...
        }
    }
    return rosterGroupSplitPane;
}
Also used : RosterEntrySelection(jmri.util.datatransfer.RosterEntrySelection) JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) PropertyChangeListener(java.beans.PropertyChangeListener) ListSelectionEvent(javax.swing.event.ListSelectionEvent) ArrayList(java.util.ArrayList) BufferedImage(java.awt.image.BufferedImage) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) PropertyChangeEvent(java.beans.PropertyChangeEvent) JComponent(javax.swing.JComponent) Transferable(java.awt.datatransfer.Transferable) JLabel(javax.swing.JLabel) IOException(java.io.IOException) JTablePersistenceManager(jmri.swing.JTablePersistenceManager) JTable(javax.swing.JTable) TransferHandler(javax.swing.TransferHandler) JSplitPane(javax.swing.JSplitPane)

Example 73 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project JMRI by JMRI.

the class RosterFrame method buildWindow.

protected final void buildWindow() {
    //Additions to the toolbar need to be added first otherwise when trying to hide bits up during the initialisation they remain on screen
    additionsToToolBar();
    frameInstances.add(this);
    prefsMgr = InstanceManager.getDefault(UserPreferencesManager.class);
    getTop().add(createTop());
    getBottom().setMinimumSize(summaryPaneDim);
    getBottom().add(createBottom());
    statusBar();
    systemsMenu();
    helpMenu(getMenu(), this);
    if ((!prefsMgr.getSimplePreferenceState(this.getClass().getName() + ".hideGroups")) && !Roster.getDefault().getRosterGroupList().isEmpty()) {
        hideGroupsPane(false);
    } else {
        hideGroupsPane(true);
    }
    if (prefsMgr.getSimplePreferenceState(this.getClass().getName() + ".hideSummary")) {
        //We have to set it to display first, then we can hide it.
        hideBottomPane(false);
        hideBottomPane(true);
    }
    PropertyChangeListener propertyChangeListener = (PropertyChangeEvent changeEvent) -> {
        JSplitPane sourceSplitPane = (JSplitPane) changeEvent.getSource();
        String propertyName = changeEvent.getPropertyName();
        if (propertyName.equals(JSplitPane.LAST_DIVIDER_LOCATION_PROPERTY)) {
            int current = sourceSplitPane.getDividerLocation() + sourceSplitPane.getDividerSize();
            int panesize = (int) (sourceSplitPane.getSize().getHeight());
            hideBottomPane = panesize - current <= 1;
        //p.setSimplePreferenceState(DecoderPro3Window.class.getName()+".hideSummary",hideSummary);
        }
    };
    updateProgrammerStatus();
    ConnectionStatus.instance().addPropertyChangeListener((PropertyChangeEvent e) -> {
        if ((e.getPropertyName().equals("change")) || (e.getPropertyName().equals("add"))) {
            log.debug("Received property {} with value {} ", e.getPropertyName(), e.getNewValue());
            updateProgrammerStatus();
        }
    });
    InstanceManager.addPropertyChangeListener((PropertyChangeEvent e) -> {
        if (e.getPropertyName().equals(InstanceManager.getDefaultsPropertyName(ProgrammerManager.class))) {
            log.debug("Received property {} with value {} ", e.getPropertyName(), e.getNewValue());
            updateProgrammerStatus();
        }
    });
    getSplitPane().addPropertyChangeListener(propertyChangeListener);
    if (this.getProgrammerConfigManager().getDefaultFile() != null) {
        programmer1 = this.getProgrammerConfigManager().getDefaultFile();
    }
    this.getProgrammerConfigManager().addPropertyChangeListener(ProgrammerConfigManager.DEFAULT_FILE, (PropertyChangeEvent evt) -> {
        if (this.getProgrammerConfigManager().getDefaultFile() != null) {
            programmer1 = this.getProgrammerConfigManager().getDefaultFile();
        }
    });
    String lastProg = (String) prefsMgr.getProperty(getWindowFrameRef(), "selectedProgrammer");
    if (lastProg != null) {
        if (lastProg.equals("service") && service.isEnabled()) {
            service.setSelected(true);
            updateProgMode();
        } else if (lastProg.equals("ops") && ops.isEnabled()) {
            ops.setSelected(true);
            updateProgMode();
        } else if (lastProg.equals("edit") && edit.isEnabled()) {
            edit.setSelected(true);
            updateProgMode();
        }
    }
    if (frameInstances.size() > 1) {
        firePropertyChange("closewindow", "setEnabled", true);
        allowQuit(frameInstances.get(0).isAllowQuit());
    } else {
        firePropertyChange("closewindow", "setEnabled", false);
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) ProgrammerManager(jmri.ProgrammerManager) GlobalProgrammerManager(jmri.GlobalProgrammerManager) AddressedProgrammerManager(jmri.AddressedProgrammerManager) JSplitPane(javax.swing.JSplitPane) UserPreferencesManager(jmri.UserPreferencesManager)

Example 74 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project JMRI by JMRI.

the class DestinationPoints method setRoute.

//For a clear down we need to add a message, if it is a cancel, manual clear down or I didn't mean it.
void setRoute(boolean state) {
    if (log.isDebugEnabled()) {
        log.debug("Set route " + src.getPoint().getDisplayName());
    }
    if (disposed) {
        log.error("Set route called even though interlock has been disposed of");
        return;
    }
    if (routeDetails == null) {
        log.error("No route to set or clear down");
        setActiveEntryExit(false);
        setRouteTo(false);
        setRouteFrom(false);
        if ((getSignal() instanceof SignalMast) && (getEntryExitType() != EntryExitPairs.FULLINTERLOCK)) {
            SignalMast mast = (SignalMast) getSignal();
            mast.setHeld(false);
        }
        synchronized (this) {
            destination = null;
        }
        return;
    }
    if (!state) {
        switch(manager.getClearDownOption()) {
            case EntryExitPairs.PROMPTUSER:
                cancelClearOptionBox();
                break;
            case EntryExitPairs.AUTOCANCEL:
                cancelClearInterlock(EntryExitPairs.CANCELROUTE);
                break;
            case EntryExitPairs.AUTOCLEAR:
                cancelClearInterlock(EntryExitPairs.CLEARROUTE);
                break;
            default:
                cancelClearOptionBox();
                break;
        }
        if (log.isDebugEnabled()) {
            log.debug("Exit " + src.getPoint().getDisplayName());
        }
        return;
    }
    if (manager.isRouteStacked(this, false)) {
        manager.cancelStackedRoute(this, false);
    }
    /* We put the setting of the route into a seperate thread and put a glass pane in front of the layout editor.
         The swing thread for flashing the icons will carry on without interuption. */
    final ArrayList<Color> realColorStd = new ArrayList<Color>();
    final ArrayList<Color> realColorXtra = new ArrayList<Color>();
    final ArrayList<LayoutBlock> routeBlocks = new ArrayList<LayoutBlock>();
    if (manager.useDifferentColorWhenSetting()) {
        for (LayoutBlock lbk : routeDetails) {
            routeBlocks.add(lbk);
            realColorXtra.add(lbk.getBlockExtraColor());
            realColorStd.add(lbk.getBlockTrackColor());
            lbk.setBlockExtraColor(manager.getSettingRouteColor());
            lbk.setBlockTrackColor(manager.getSettingRouteColor());
        }
        //Force a redraw, to reflect color change
        src.getPoint().getPanel().redrawPanel();
    }
    ActiveTrain tmpat = null;
    if (manager.getDispatcherIntegration() && jmri.InstanceManager.getNullableDefault(jmri.jmrit.dispatcher.DispatcherFrame.class) != null) {
        jmri.jmrit.dispatcher.DispatcherFrame df = jmri.InstanceManager.getDefault(jmri.jmrit.dispatcher.DispatcherFrame.class);
        for (ActiveTrain atl : df.getActiveTrainsList()) {
            if (atl.getEndBlock() == src.getStart().getBlock()) {
                if (atl.getLastAllocatedSection() == atl.getEndBlockSection()) {
                    if (!atl.getReverseAtEnd() && !atl.getResetWhenDone()) {
                        tmpat = atl;
                        break;
                    }
                    log.warn("Interlock will not be added to existing Active Train as it is set for back and forth operation");
                }
            }
        }
    }
    final ActiveTrain at = tmpat;
    Runnable setRouteRun = new Runnable() {

        @Override
        public void run() {
            src.getPoint().getPanel().getGlassPane().setVisible(true);
            try {
                Hashtable<Turnout, Integer> turnoutSettings = new Hashtable<Turnout, Integer>();
                ConnectivityUtil connection = new ConnectivityUtil(point.getPanel());
                // Last block in the route is the one that we are protecting at the last sensor/signalmast
                for (int i = 0; i < routeDetails.size(); i++) {
                    //if we are not using the dispatcher and the signal logic is dynamic, then set the turnouts
                    if (at == null && isSignalLogicDynamic()) {
                        if (i > 0) {
                            ArrayList<LayoutTurnout> turnoutlist;
                            int nxtBlk = i + 1;
                            int preBlk = i - 1;
                            if (i < routeDetails.size() - 1) {
                                turnoutlist = connection.getTurnoutList(routeDetails.get(i).getBlock(), routeDetails.get(preBlk).getBlock(), routeDetails.get(nxtBlk).getBlock());
                                ArrayList<Integer> throwlist = connection.getTurnoutSettingList();
                                for (int x = 0; x < turnoutlist.size(); x++) {
                                    if (turnoutlist.get(x) instanceof LayoutSlip) {
                                        int slipState = throwlist.get(x);
                                        LayoutSlip ls = (LayoutSlip) turnoutlist.get(x);
                                        int taState = ls.getTurnoutState(slipState);
                                        turnoutSettings.put(ls.getTurnout(), taState);
                                        int tbState = ls.getTurnoutBState(slipState);
                                        ls.getTurnoutB().setCommandedState(tbState);
                                        turnoutSettings.put(ls.getTurnoutB(), tbState);
                                    } else {
                                        String t = turnoutlist.get(x).getTurnoutName();
                                        Turnout turnout = InstanceManager.turnoutManagerInstance().getTurnout(t);
                                        turnoutSettings.put(turnout, throwlist.get(x));
                                        if (turnoutlist.get(x).getSecondTurnout() != null) {
                                            turnoutSettings.put(turnoutlist.get(x).getSecondTurnout(), throwlist.get(x));
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ((getEntryExitType() == EntryExitPairs.FULLINTERLOCK)) {
                        // was set against occupancy sensor
                        routeDetails.get(i).getBlock().addPropertyChangeListener(propertyBlockListener);
                        if (i > 0) {
                            routeDetails.get(i).setUseExtraColor(true);
                        }
                    } else {
                        // was set against occupancy sensor
                        routeDetails.get(i).getBlock().removePropertyChangeListener(propertyBlockListener);
                    }
                }
                if (at == null) {
                    if (!isSignalLogicDynamic()) {
                        jmri.SignalMastLogic tmSml = InstanceManager.getDefault(jmri.SignalMastLogicManager.class).getSignalMastLogic((SignalMast) src.sourceSignal);
                        for (Turnout t : tmSml.getAutoTurnouts((SignalMast) getSignal())) {
                            turnoutSettings.put(t, tmSml.getAutoTurnoutState(t, (SignalMast) getSignal()));
                        }
                    }
                    for (Map.Entry<Turnout, Integer> entry : turnoutSettings.entrySet()) {
                        entry.getKey().setCommandedState(entry.getValue());
                        Runnable r = new Runnable() {

                            @Override
                            public void run() {
                                try {
                                    Thread.sleep(250 + manager.turnoutSetDelay);
                                } catch (InterruptedException ex) {
                                    Thread.currentThread().interrupt();
                                }
                            }
                        };
                        Thread thr = new Thread(r, "Entry Exit Route, turnout setting");
                        thr.start();
                        try {
                            thr.join();
                        } catch (InterruptedException ex) {
                        //            log.info("interrupted at join " + ex);
                        }
                    }
                }
                src.getPoint().getPanel().redrawPanel();
                if (getEntryExitType() != EntryExitPairs.SETUPTURNOUTSONLY) {
                    if (getEntryExitType() == EntryExitPairs.FULLINTERLOCK) {
                        //If our start block is already active we will set it as our lastSeenActiveBlock.
                        if (src.getStart().getState() == Block.OCCUPIED) {
                            src.getStart().removePropertyChangeListener(propertyBlockListener);
                            lastSeenActiveBlockObject = src.getStart().getBlock().getValue();
                            log.debug("Last seen value " + lastSeenActiveBlockObject);
                        }
                    }
                    if ((src.sourceSignal instanceof SignalMast) && (getSignal() instanceof SignalMast)) {
                        SignalMast smSource = (SignalMast) src.sourceSignal;
                        SignalMast smDest = (SignalMast) getSignal();
                        synchronized (this) {
                            sml = InstanceManager.getDefault(jmri.SignalMastLogicManager.class).newSignalMastLogic(smSource);
                            if (!sml.isDestinationValid(smDest)) {
                                //if no signalmastlogic existed then created it, but set it not to be stored.
                                sml.setDestinationMast(smDest);
                                sml.setStore(jmri.SignalMastLogic.STORENONE, smDest);
                            }
                        }
                        //Remove the first block as it is our start block
                        routeDetails.remove(0);
                        synchronized (this) {
                            smSource.setHeld(false);
                            //Only change the block and turnout details if this a temp signalmast logic
                            if (sml.getStoreState(smDest) == jmri.SignalMastLogic.STORENONE) {
                                LinkedHashMap<Block, Integer> blks = new LinkedHashMap<Block, Integer>();
                                for (int i = 0; i < routeDetails.size(); i++) {
                                    if (routeDetails.get(i).getBlock().getState() == Block.UNKNOWN) {
                                        routeDetails.get(i).getBlock().setState(Block.UNOCCUPIED);
                                    }
                                    blks.put(routeDetails.get(i).getBlock(), Block.UNOCCUPIED);
                                }
                                sml.setAutoBlocks(blks, smDest);
                                sml.setAutoTurnouts(turnoutSettings, smDest);
                                sml.initialise(smDest);
                            }
                        }
                        smSource.addPropertyChangeListener(new PropertyChangeListener() {

                            @Override
                            public void propertyChange(PropertyChangeEvent e) {
                                SignalMast source = (SignalMast) e.getSource();
                                source.removePropertyChangeListener(this);
                                setRouteFrom(true);
                                setRouteTo(true);
                            }
                        });
                        src.pd.extendedtime = true;
                        point.extendedtime = true;
                    } else {
                        if (src.sourceSignal instanceof SignalMast) {
                            SignalMast mast = (SignalMast) src.sourceSignal;
                            mast.setHeld(false);
                        } else if (src.sourceSignal instanceof SignalHead) {
                            SignalHead head = (SignalHead) src.sourceSignal;
                            head.setHeld(false);
                        }
                        setRouteFrom(true);
                        setRouteTo(true);
                    }
                }
                if (manager.useDifferentColorWhenSetting()) {
                    //final ArrayList<Color> realColorXtra = realColorXtra;
                    javax.swing.Timer resetColorBack = new javax.swing.Timer(manager.getSettingTimer(), new java.awt.event.ActionListener() {

                        @Override
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                            for (int i = 0; i < routeBlocks.size(); i++) {
                                LayoutBlock lbk = routeBlocks.get(i);
                                lbk.setBlockExtraColor(realColorXtra.get(i));
                                lbk.setBlockTrackColor(realColorStd.get(i));
                            }
                            src.getPoint().getPanel().redrawPanel();
                        }
                    });
                    resetColorBack.setRepeats(false);
                    resetColorBack.start();
                }
                if (at != null) {
                    jmri.Section sec = null;
                    if (sml != null && sml.getAssociatedSection((SignalMast) getSignal()) != null) {
                        sec = sml.getAssociatedSection((SignalMast) getSignal());
                    } else {
                        sec = InstanceManager.getDefault(jmri.SectionManager.class).createNewSection(src.getPoint().getDisplayName() + ":" + point.getDisplayName());
                        if (sec == null) {
                            //A Section already exists, lets grab it and check that it is one used with the Interlocking, if so carry on using that.
                            sec = InstanceManager.getDefault(jmri.SectionManager.class).getSection(src.getPoint().getDisplayName() + ":" + point.getDisplayName());
                        } else {
                            sec.setSectionType(jmri.Section.DYNAMICADHOC);
                        }
                        if (sec.getSectionType() == jmri.Section.DYNAMICADHOC) {
                            sec.removeAllBlocksFromSection();
                            for (LayoutBlock key : routeDetails) {
                                if (key != src.getStart()) {
                                    sec.addBlock(key.getBlock());
                                }
                            }
                            String dir = jmri.Path.decodeDirection(src.getStart().getNeighbourDirection(routeDetails.get(0).getBlock()));
                            jmri.EntryPoint ep = new jmri.EntryPoint(routeDetails.get(0).getBlock(), src.getStart().getBlock(), dir);
                            ep.setTypeForward();
                            sec.addToForwardList(ep);
                            LayoutBlock proDestLBlock = point.getProtecting().get(0);
                            if (proDestLBlock != null) {
                                dir = jmri.Path.decodeDirection(proDestLBlock.getNeighbourDirection(point.getFacing()));
                                ep = new jmri.EntryPoint(point.getFacing().getBlock(), proDestLBlock.getBlock(), dir);
                                ep.setTypeReverse();
                                sec.addToReverseList(ep);
                            }
                        }
                    }
                    jmri.InstanceManager.getDefault(jmri.jmrit.dispatcher.DispatcherFrame.class).extendActiveTrainsPath(sec, at, src.getPoint().getPanel());
                }
                src.pd.setNXButtonState(EntryExitPairs.NXBUTTONINACTIVE);
                point.setNXButtonState(EntryExitPairs.NXBUTTONINACTIVE);
            } catch (RuntimeException ex) {
                log.error("An error occured while setting the route");
                ex.printStackTrace();
                src.pd.setNXButtonState(EntryExitPairs.NXBUTTONINACTIVE);
                point.setNXButtonState(EntryExitPairs.NXBUTTONINACTIVE);
                if (manager.useDifferentColorWhenSetting()) {
                    for (int i = 0; i < routeBlocks.size(); i++) {
                        LayoutBlock lbk = routeBlocks.get(i);
                        lbk.setBlockExtraColor(realColorXtra.get(i));
                        lbk.setBlockTrackColor(realColorStd.get(i));
                    }
                }
                src.getPoint().getPanel().redrawPanel();
            }
            src.getPoint().getPanel().getGlassPane().setVisible(false);
        //src.setMenuEnabled(true);
        }
    };
    Thread thrMain = new Thread(setRouteRun, "Entry Exit Set Route");
    thrMain.start();
    try {
        thrMain.join();
    } catch (InterruptedException e) {
        log.error("Interuption exception " + e.toString());
    }
    if (log.isDebugEnabled()) {
        log.debug("finish route " + src.getPoint().getDisplayName());
    }
}
Also used : LayoutSlip(jmri.jmrit.display.layoutEditor.LayoutSlip) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ActiveTrain(jmri.jmrit.dispatcher.ActiveTrain) PropertyChangeEvent(java.beans.PropertyChangeEvent) LayoutTurnout(jmri.jmrit.display.layoutEditor.LayoutTurnout) Color(java.awt.Color) Block(jmri.Block) LayoutBlock(jmri.jmrit.display.layoutEditor.LayoutBlock) LayoutTurnout(jmri.jmrit.display.layoutEditor.LayoutTurnout) Turnout(jmri.Turnout) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConnectivityUtil(jmri.jmrit.display.layoutEditor.ConnectivityUtil) ActionListener(java.awt.event.ActionListener) PropertyChangeListener(java.beans.PropertyChangeListener) SignalHead(jmri.SignalHead) LayoutBlock(jmri.jmrit.display.layoutEditor.LayoutBlock) SignalMast(jmri.SignalMast) Hashtable(java.util.Hashtable) ActionEvent(java.awt.event.ActionEvent)

Example 75 with PropertyChangeEvent

use of java.beans.PropertyChangeEvent in project JMRI by JMRI.

the class ThrottlesPreferences method set.

public void set(ThrottlesPreferences tp) {
    setWindowDimension(tp.getWindowDimension());
    setUseExThrottle(tp.isUsingExThrottle());
    setUsingToolBar(tp.isUsingToolBar());
    setUsingFunctionIcon(tp.isUsingFunctionIcon());
    setResizeWindow(tp.isResizingWindow());
    setSaveThrottleOnLayoutSave(tp.isSavingThrottleOnLayoutSave());
    setUseRosterImage(tp.isUsingRosterImage());
    setEnableRosterSearch(tp.isEnablingRosterSearch());
    setAutoLoad(tp.isAutoLoading());
    setHideUndefinedFuncButt(tp.isHidingUndefinedFuncButt());
    setIgnoreThrottlePosition(tp.isIgnoringThrottlePosition());
    if (listeners != null) {
        for (int i = 0; i < listeners.size(); i++) {
            PropertyChangeListener l = listeners.get(i);
            PropertyChangeEvent e = new PropertyChangeEvent(this, "ThrottlePreferences", null, this);
            l.propertyChange(e);
        }
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener)

Aggregations

PropertyChangeEvent (java.beans.PropertyChangeEvent)589 PropertyChangeListener (java.beans.PropertyChangeListener)375 ActionEvent (java.awt.event.ActionEvent)42 ActionListener (java.awt.event.ActionListener)35 JPanel (javax.swing.JPanel)35 Test (org.junit.Test)33 ArrayList (java.util.ArrayList)30 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)27 IFigure (org.eclipse.draw2d.IFigure)25 File (java.io.File)24 JLabel (javax.swing.JLabel)24 BorderLayout (java.awt.BorderLayout)22 List (java.util.List)21 IOException (java.io.IOException)19 Dimension (java.awt.Dimension)16 ChangeEvent (javax.swing.event.ChangeEvent)15 PropertyVetoException (java.beans.PropertyVetoException)14 PropertyChangeSupport (java.beans.PropertyChangeSupport)13 ChangeListener (javax.swing.event.ChangeListener)13 UnprocessedChangeEvents (org.jvnet.hk2.config.UnprocessedChangeEvents)13