From: <kev...@us...> - 2011-11-30 12:17:12
|
Revision: 19211 http://jmri.svn.sourceforge.net/jmri/?rev=19211&view=rev Author: kevin-dickerson Date: 2011-11-30 12:17:05 +0000 (Wed, 30 Nov 2011) Log Message: ----------- Fix jenkins find bugs errors Modified Paths: -------------- trunk/jmri/java/src/jmri/jmrit/signalling/AddEntryExitPairPanel.java trunk/jmri/java/src/jmri/jmrit/signalling/EntryExitPairs.java Modified: trunk/jmri/java/src/jmri/jmrit/signalling/AddEntryExitPairPanel.java =================================================================== --- trunk/jmri/java/src/jmri/jmrit/signalling/AddEntryExitPairPanel.java 2011-11-30 11:29:30 UTC (rev 19210) +++ trunk/jmri/java/src/jmri/jmrit/signalling/AddEntryExitPairPanel.java 2011-11-30 12:17:05 UTC (rev 19211) @@ -47,8 +47,6 @@ JComboBox selectPanel = new JComboBox(); JComboBox fromPoint = new JComboBox(); JComboBox toPoint = new JComboBox(); - ActionListener selectPanelListener; - ActionListener addButton; ArrayList<LayoutEditor> panels; protected static final ResourceBundle rb = ResourceBundle.getBundle("jmri.jmrit.signalling.EntryExitBundle"); @@ -60,31 +58,21 @@ JPanel top = new JPanel(); top.setLayout(new GridLayout(3,2)); - //JPanel p; - //p = new JPanel(); - //p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + top.add(new JLabel(rb.getString("SelectPanel"))); top.add(selectPanel); - selectPanel.removeActionListener(selectPanelListener); selectPanel.removeAllItems(); panels = jmri.jmrit.display.PanelMenu.instance().getLayoutEditorPanelList(); for (int i = 0; i<panels.size(); i++){ selectPanel.addItem(panels.get(i).getLayoutName()); - /*if(panels.get(i).getLayoutName().equals(panel.getLayoutName())) - selectPanel.setSelect*/ } if(panel!=null) selectPanel.setSelectedItem(panel.getLayoutName()); - selectPanel.addActionListener(selectPanelListener); - JButton ok; - //add(p); + - //p = new JPanel(); - //p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); top.add(new JLabel(rb.getString("FromLocation"))); top.add(fromPoint); - //add(p); - selectPanelListener = new ActionListener() { + ActionListener selectPanelListener = new ActionListener() { public void actionPerformed(ActionEvent e) { beanComboBox(fromPoint, null); beanComboBox(toPoint, null); @@ -94,15 +82,14 @@ beanComboBox(fromPoint, null); beanComboBox(toPoint, null); selectPanel.addActionListener(selectPanelListener); - //p = new JPanel(); - //p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); + top.add(new JLabel(rb.getString("ToLocation"))); top.add(toPoint); add(top); JPanel p=new JPanel(); - - p.add(ok = new JButton(rb.getString("Add"))); + JButton ok = new JButton(rb.getString("Add")); + p.add(ok); ok.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e){ @@ -165,16 +152,22 @@ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (retval == 0) { + final PropertyChangeListener propertyNXListener = new PropertyChangeListener(){ + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals("autoGenerateComplete")){ + if (entryExitFrame!=null) + entryExitFrame.setVisible(false); + EntryExitPairs.instance().removePropertyChangeListener(this); + JOptionPane.showMessageDialog(null, "Generation of Entry Exit Pairs Completed"); + } + } + }; try { - //InstanceManager.signalMastLogicManagerInstance().addPropertyChangeListener(this); EntryExitPairs entryexit = EntryExitPairs.instance(); entryexit.addPropertyChangeListener(propertyNXListener); entryexit.automaticallyDiscoverEntryExitPairs(panels.get(selectPanel.getSelectedIndex())); - //InstanceManager.signalMastLogicManagerInstance().automaticallyDiscoverEntryExitPairs(); - } catch (jmri.JmriException e){ EntryExitPairs.instance().removePropertyChangeListener(propertyNXListener); - //InstanceManager.signalMastLogicManagerInstance().removePropertyChangeListener(this); JOptionPane.showMessageDialog(null, e.toString()); entryExitFrame.setVisible(false); } @@ -213,17 +206,19 @@ String description = ""; NamedBean source = null; /* Initial release to deal with sensors only - if ((pp.get(i).getWestBoundSignalMast()!=null) && (!pp.get(i).getWestBoundSignalMast().equals(""))){ - description = pp.get(i).getWestBoundSignalMast(); - source = InstanceManager.signalMastManagerInstance().getSignalMast(pp.get(i).getWestBoundSignalMast()); - - } + else if((pp.get(i).getWestBoundSignal()!=null) && (!pp.get(i).getWestBoundSignal().equals(""))){ description = pp.get(i).getWestBoundSignal(); source = InstanceManager.signalHeadManagerInstance().getSignalHead(pp.get(i).getWestBoundSignal()); - } else*/ if ((pp.get(i).getWestBoundSensor()!=null) && (!pp.get(i).getWestBoundSensor().equals(""))){ - description = pp.get(i).getWestBoundSensor(); - source = InstanceManager.sensorManagerInstance().getSensor(pp.get(i).getWestBoundSensor()); + } else*/ + if ((pp.get(i).getWestBoundSensor()!=null) && (!pp.get(i).getWestBoundSensor().equals(""))){ + /*if ((pp.get(i).getWestBoundSignalMast()!=null) && (!pp.get(i).getWestBoundSignalMast().equals(""))){ + description = pp.get(i).getWestBoundSignalMast(); + source = InstanceManager.signalMastManagerInstance().getSignalMast(pp.get(i).getWestBoundSignalMast()); + } else {*/ + description = pp.get(i).getWestBoundSensor(); + source = InstanceManager.sensorManagerInstance().getSensor(pp.get(i).getWestBoundSensor()); + //} } if(source!=null){ @@ -244,9 +239,15 @@ description = pp.get(i).getEastBoundSignal(); source = InstanceManager.signalHeadManagerInstance().getSignalHead(pp.get(i).getEastBoundSignal()); - } else*/ if ((pp.get(i).getEastBoundSensor()!=null) && (!pp.get(i).getEastBoundSensor().equals(""))){ - description = pp.get(i).getEastBoundSensor(); - source = InstanceManager.sensorManagerInstance().getSensor(pp.get(i).getEastBoundSensor()); + } else*/ + if ((pp.get(i).getEastBoundSensor()!=null) && (!pp.get(i).getEastBoundSensor().equals(""))){ + /*if ((pp.get(i).getEastBoundSignalMast()!=null)&& (!pp.get(i).getEastBoundSignalMast().equals(""))){ + description = pp.get(i).getEastBoundSignalMast(); + source = InstanceManager.signalMastManagerInstance().getSignalMast(pp.get(i).getEastBoundSignalMast()); + } else {*/ + description = pp.get(i).getEastBoundSensor(); + source = InstanceManager.sensorManagerInstance().getSensor(pp.get(i).getEastBoundSensor()); + //} } if(source!=null){ //description = getPointAsString(pp.get(i),true); @@ -548,38 +549,10 @@ } public void propertyChange(java.beans.PropertyChangeEvent e) { - // updateNameList(); if (e.getPropertyName().equals("length")) { updateNameList(); - //log.debug("Table changed length to "+signalMastLogicList.size()); fireTableDataChanged(); - }/* else if (e.getSource() instanceof SignalMastLogic) { - SignalMastLogic logic = (SignalMastLogic)e.getSource(); - if (matchPropertyName(e)){ - for (int i = 0; i< signalMastLogicList.size(); i++) { - Hashtable<SignalMastLogic, SignalMast> b = signalMastLogicList.get(i); - Enumeration<SignalMastLogic> en = b.keys(); - while (en.hasMoreElements()) { - SignalMastLogic sm = en.nextElement(); - if (sm==logic){ - fireTableRowsUpdated(i, i); - } - } - } - } - } else if (e.getSource() instanceof jmri.SignalMast){ - jmri.SignalMast sigMast = (jmri.SignalMast)e.getSource(); - for (int i = 0; i<signalMastLogicList.size(); i++){ - Hashtable<SignalMastLogic, SignalMast> b = signalMastLogicList.get(i); - Enumeration<SignalMastLogic> en = b.keys(); - while (en.hasMoreElements()) { - SignalMastLogic sm = en.nextElement(); - //SignalMast dest = b.get(sm); - if(sm.getSourceMast()==sigMast) - fireTableRowsUpdated(i, i); - } - } - }*/ + } } } @@ -609,10 +582,9 @@ .setPreferredWidth((sample.getPreferredSize().width)+4); } - class ValidPoints{ + static class ValidPoints{ NamedBean bean; - boolean direction; String description; ValidPoints(NamedBean bean, String description){ @@ -629,38 +601,6 @@ } } - /*protected PropertyChangeListener propertyBlockManagerListener = new PropertyChangeListener(){ - public void propertyChange(PropertyChangeEvent e) { - if(e.getPropertyName().equals("topology")){ - //boolean newValue = new Boolean.parseBoolean(String.valueOf(e.getNewValue())); - boolean newValue = (Boolean) e.getNewValue(); - if(newValue){ - // for(int i = 0; i <signalMastLogic.size(); i++){ - // signalMastLogic.get(i).setupLayoutEditorDetails(); - // } - if(runWhenStablised){ - try { - EntryExitPairs.instance().automaticallyDiscoverEntryExitPairs(toUseWhenStable); - } catch (JmriException je){ - //Considered normal if routing not enabled - } - } - } - } - } - };*/ - - protected PropertyChangeListener propertyNXListener = new PropertyChangeListener(){ - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getPropertyName().equals("autoGenerateComplete")){ - if (entryExitFrame!=null) - entryExitFrame.setVisible(false); - EntryExitPairs.instance().removePropertyChangeListener(propertyNXListener); - JOptionPane.showMessageDialog(null, "Generation of Entry Exit Pairs Completed"); - } - } - }; - boolean runWhenStablised = false; LayoutEditor toUseWhenStable; Modified: trunk/jmri/java/src/jmri/jmrit/signalling/EntryExitPairs.java =================================================================== --- trunk/jmri/java/src/jmri/jmrit/signalling/EntryExitPairs.java 2011-11-30 11:29:30 UTC (rev 19210) +++ trunk/jmri/java/src/jmri/jmrit/signalling/EntryExitPairs.java 2011-11-30 12:17:05 UTC (rev 19211) @@ -404,8 +404,8 @@ LayoutBlock protecting; jmri.SignalMastLogic sml; String ref = "Empty"; - boolean reverseRoute = false; - boolean uniDirection = true; + //boolean reverseRoute = false; + //boolean uniDirection = true; //Using Object here rather than sourceSensor, working on the basis that it might //one day be possible to have a signal icon selectable on a panel and @@ -552,13 +552,13 @@ //We have a problem, the destination point is already setup with a route, therefore we would need to //check some how that a route hasn't been set to it. destination = activatedEndPoint.getFacing();/*= getFacingTrackSegment(activeEndPoint, point.getDirection());*/ - reverseRoute = false; + // reverseRoute = false; } else { destination = this.protecting; protect = activatedEndPoint.getProtecting(); start = activatedEndPoint.getFacing(); destination = this.start; - reverseRoute = true; + //reverseRoute = true; try{ if(!InstanceManager.layoutBlockManagerInstance().checkValidDest(start, protect, this.protecting, this.start)){ start = activatedEndPoint.getProtecting(); @@ -686,6 +686,7 @@ log.debug(ref + " all blocks have automatically been cleared down"); } else { log.debug(ref + " No blocks were cleared down " + routeDetails.size()); + //Might need to consider if this is a reversed route try{ log.debug(ref + " set first block as active so that we can manually clear this down " + routeDetails.get(0).getBlock().getSensor().getDisplayName()); routeDetails.get(0).getBlock().getSensor().setState(Sensor.ACTIVE); @@ -740,7 +741,7 @@ smlm.removeSignalMastLogic(sml); sml=null; destSignal=null; - reverseRoute = false; + //reverseRoute = false; } if ((state) && (entryExitType!=SETUPTURNOUTSONLY)){ @@ -828,7 +829,7 @@ for(Entry<DestinationPoints, Object> en : revDestObject.entrySet()){ PointDetails point = (en.getKey()).getPoint(); if(point.equals(dest)){ - if(revDestObject.get(dest) instanceof Sensor){ + if(revDestObject.get(en.getKey()) instanceof Sensor){ Sensor sen = (Sensor) revDestObject.get(dest); sen.removePropertyChangeListener(propertyDestinationListener); } @@ -838,7 +839,6 @@ destPoint2Remove = en.getKey(); destObject.remove(revDestObject.get(en.getKey())); } - } revDestObject.remove(destPoint2Remove); } @@ -870,8 +870,13 @@ return rtn; } - boolean isDestinationValid(PointDetails dest){ - return revDestObject.containsKey(dest); + boolean isDestinationValid(PointDetails destPoint){ + boolean exists = false; + for(Entry<DestinationPoints, Object> en : revDestObject.entrySet()){ + if((en.getKey()).getPoint().equals(destPoint)) + exists = true; + } + return exists; } boolean getUniDirection(Object dest, LayoutEditor panel){ @@ -900,7 +905,7 @@ } boolean isRouteActive(PointDetails endpoint){ - if((activeEntryExit) && (endpoint.equals(activeEndPoint))) + if((activeEntryExit) && (endpoint.equals(activeEndPoint.getPoint()))) return true; return false; } @@ -915,7 +920,7 @@ PointDetails point = null; Boolean uniDirection = true; - int repeatActivation = 0x00; + //int repeatActivation = 0x00; DestinationPoints(PointDetails point){ this.point=point; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |