Skip to content
Permalink
Browse files

fix: Recover from merging in master

  • Loading branch information...
rhwood committed Jun 16, 2019
1 parent 2c484c8 commit 175b95a3fd1f31ad901ae4f68309a401c3ff5105
@@ -43,18 +43,18 @@ protected void createModel() {
// build the list, with default at start and internal at end (if present)
jmri.managers.AbstractProxyManager<E> proxy = (jmri.managers.AbstractProxyManager<E>) getManager();

tabbedTableArray.add(new TabbedTableItem<E>(Bundle.getMessage("All"), true, getManager(), getNewTableAction("All"))); // NOI18N
tabbedTableArray.add(new TabbedTableItem<>(Bundle.getMessage("All"), true, getManager(), getNewTableAction("All"))); // NOI18N

List<jmri.Manager<E>> managerList = proxy.getDisplayOrderManagerList();
for (Manager<E> manager : managerList) {
String manuName = ConnectionNameFromSystemName.getConnectionName(manager.getSystemPrefix());
TabbedTableItem<E> itemModel = new TabbedTableItem<E>(manuName, true, manager, getNewTableAction(manuName)); // connection name to display in Tab
TabbedTableItem<E> itemModel = new TabbedTableItem<>(manuName, true, manager, getNewTableAction(manuName)); // connection name to display in Tab
tabbedTableArray.add(itemModel);
}

} else {
String manuName = ConnectionNameFromSystemName.getConnectionName(getManager().getSystemPrefix());
tabbedTableArray.add(new TabbedTableItem<E>(manuName, true, getManager(), getNewTableAction(manuName)));
tabbedTableArray.add(new TabbedTableItem<>(manuName, true, getManager(), getNewTableAction(manuName)));
}
for (int x = 0; x < tabbedTableArray.size(); x++) {
AbstractTableAction<E> table = tabbedTableArray.get(x).getAAClass();
@@ -83,7 +83,7 @@ public JPanel getPanel() {
return dataPanel;
}

protected ArrayList<TabbedTableItem<E>> tabbedTableArray = new ArrayList<TabbedTableItem<E>>();
protected ArrayList<TabbedTableItem<E>> tabbedTableArray = new ArrayList<>();

@Override
protected void setTitle() {
@@ -101,7 +101,10 @@ protected void addPressed(ActionEvent e) {
@Override
public void addToFrame(BeanTableFrame<E> f) {
try {
tabbedTableArray.get(dataTabs.getSelectedIndex()).getAAClass().addToFrame(f);
TabbedTableItem<E> table = tabbedTableArray.get(dataTabs.getSelectedIndex());
if (table != null) {
table.getAAClass().addToFrame(f);
}
} catch (ArrayIndexOutOfBoundsException ex) {
log.error(ex.toString() + " in add to Frame " + dataTabs.getSelectedIndex() + " " + dataTabs.getSelectedComponent());
}
@@ -117,11 +120,12 @@ public void setMenuBar(BeanTableFrame<E> f) {
}

public void addToBottomBox(JComponent c, String str) {
for (int x = 0; x < tabbedTableArray.size(); x++) {
if (tabbedTableArray.get(x).getItemString().equals(str)) {
tabbedTableArray.get(x).addToBottomBox(c);
tabbedTableArray.forEach((table) -> {
String item = table.getItemString();
if (item != null && item.equals(str)) {
table.addToBottomBox(c);
}
}
});
}

@Override
@@ -56,6 +56,7 @@
import jmri.swing.NamedBeanComboBox;
import jmri.util.ConnectionNameFromSystemName;
import jmri.util.JmriJFrame;
import jmri.util.swing.ComboBoxToolTipRenderer;
import jmri.util.table.ButtonEditor;
import jmri.util.table.ButtonRenderer;

@@ -7,6 +7,7 @@
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import javax.annotation.Nonnull;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
@@ -9,6 +9,7 @@
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Nonnull;
@@ -1,6 +1,5 @@
package jmri.jmrit.simplelightctrl;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeListener;
@@ -9,7 +8,7 @@
import javax.swing.JPanel;
import jmri.InstanceManager;
import jmri.Light;
import jmri.util.swing.JmriBeanComboBox;
import jmri.swing.NamedBeanComboBox;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -32,7 +31,6 @@
String newState = "";

// GUI member declarations

javax.swing.JButton onButton = new javax.swing.JButton();
javax.swing.JButton offButton = new javax.swing.JButton();

@@ -63,15 +61,16 @@
javax.swing.JTextField transitionTimeTextField = new javax.swing.JTextField(4);

javax.swing.JButton applyButton = new javax.swing.JButton();
private JmriBeanComboBox to1;
private final NamedBeanComboBox<Light> to1;
private PropertyChangeListener _parentLightListener = null;

public SimpleLightCtrlFrame() {
super();

to1 = new JmriBeanComboBox(InstanceManager.lightManagerInstance() );
to1.setFirstItemBlank(true);
to1.addActionListener (new ActionListener () {

to1 = new NamedBeanComboBox<>(InstanceManager.lightManagerInstance());
to1.setAllowNull(true);
to1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
log.info("actionevent");
resetLightToCombo();
@@ -171,7 +170,7 @@ public void actionPerformed(ActionEvent e) {
applyButtonActionPerformed(e);
}
});

// set buttons inactive as no Light yet selected
setControlFrameActive(false);

@@ -189,20 +188,20 @@ public void actionPerformed(ActionEvent e) {
pane2.add(textStateLabel);
pane2.add(nowStateTextField);
getContentPane().add(pane2);

// on off buttons
pane2 = new JPanel();
pane2.add(onButton);
pane2.add(offButton);
getContentPane().add(pane2);
getContentPane().add(new javax.swing.JSeparator(javax.swing.SwingConstants.HORIZONTAL));

// Controllers enabled checkbox
pane2 = new JPanel();
pane2.add(textIsEnabledLabel);
pane2.add(statusIsEnabledCheckBox);
getContentPane().add(pane2);

// Controllers text
pane2 = new JPanel();
pane2.add(nowControllersTextField);
@@ -243,46 +242,38 @@ public void actionPerformed(ActionEvent e) {
pack();

}
private void setControlFrameActive(boolean showLight){
log.info("selected light is {}",selectedLight() );

private void setControlFrameActive(boolean showLight) {
log.info("selected light is {}", to1.getSelectedItem());
onButton.setEnabled(showLight);
offButton.setEnabled(showLight);
statusIsEnabledCheckBox.setEnabled(showLight);

if (showLight && light.isIntensityVariable()) {
intensityButton.setEnabled(true);
intensityMinTextField.setEnabled(true);
intensityMaxTextField.setEnabled(true);
intensityTextField.setEnabled(true);
applyButton.setEnabled(true);
}
else {
} else {
intensityButton.setEnabled(false);
intensityMinTextField.setEnabled(false);
intensityMaxTextField.setEnabled(false);
intensityTextField.setEnabled(false);
intensityButton.setEnabled(false);
applyButton.setEnabled(false);
}

if (showLight && light.isTransitionAvailable()) {
transitionTimeTextField.setEnabled(true);
}
else {
} else {
transitionTimeTextField.setEnabled(false);
}

}

// returns the Light selected in the Combobox
// null if no Light selected
private Light selectedLight(){
return (Light) to1.getSelectedBean();

}

public void offButtonActionPerformed(ActionEvent e) {
if (selectedLight() == null) {
if (to1.getSelectedItem() == null) {
nowStateTextField.setText(Bundle.getMessage("ErrorTitle"));
return;
}
@@ -296,7 +287,7 @@ public void offButtonActionPerformed(ActionEvent e) {
}

public void onButtonActionPerformed(ActionEvent e) {
if (selectedLight() == null) {
if (to1.getSelectedItem() == null) {
nowStateTextField.setText(Bundle.getMessage("ErrorTitle"));
return;
}
@@ -310,15 +301,15 @@ public void onButtonActionPerformed(ActionEvent e) {
}

public void intensityButtonActionPerformed(ActionEvent e) {
if (selectedLight() == null) {
if (to1.getSelectedItem() == null) {
nowStateTextField.setText(Bundle.getMessage("ErrorTitle"));
return;
}
try {
log.debug("about to command DIM"); // NOI18N
// and set commanded state to DIM
light.setTargetIntensity(Double.parseDouble(intensityTextField.getText().trim()) / 100);
} catch (Exception ex) {
} catch (NumberFormatException ex) {
log.error(Bundle.getMessage("LightErrorIntensityButtonException") + ex.toString());
nowStateTextField.setText(Bundle.getMessage("ErrorTitle"));
}
@@ -336,7 +327,7 @@ private void enabledCheckboxActionPerformed(ActionEvent e) {
* Handle changes for intensity, rate, etc.
*/
public void applyButtonActionPerformed(ActionEvent e) {
if (selectedLight() == null) {
if (to1.getSelectedItem() == null) {
nowStateTextField.setText(Bundle.getMessage("ErrorTitle"));
resetLightToCombo();
return;
@@ -346,60 +337,60 @@ public void applyButtonActionPerformed(ActionEvent e) {
double min = Double.parseDouble(intensityMinTextField.getText()) / 100.;
double max = Double.parseDouble(intensityMaxTextField.getText()) / 100.;
double time = Double.parseDouble(transitionTimeTextField.getText());
log.debug("setting min: {} max: {} transition: {}",min,max,time); // NOI18N
log.debug("setting min: {} max: {} transition: {}", min, max, time); // NOI18N
if (!light.isTransitionAvailable()) {
time = 0.0d;
}

light.setMinIntensity(min);
light.setMaxIntensity(max);
light.setTransitionTime(time);
updateLightStatusFields(false);

} catch (Exception ex) {
} catch (NumberFormatException ex) {
log.error(Bundle.getMessage("ErrorTitle") + ex.toString());
nowStateTextField.setText(Bundle.getMessage("ErrorTitle"));
}
}

private void resetLightToCombo() {
if (light !=null && light == selectedLight() ) {
if (light != null && light == to1.getSelectedItem()) {
return;
}
log.debug("Light changed in combobox to {}",selectedLight());
log.debug("Light changed in combobox to {}", to1.getSelectedItem());
// remove changelistener from previous Light
if (light != null ) {
if (light != null) {
light.removePropertyChangeListener(_parentLightListener);
}
light = selectedLight();
if (light!=null ) {
light = to1.getSelectedItem();
if (light != null) {
light.addPropertyChangeListener(
_parentLightListener = new PropertyChangeListener() {
_parentLightListener = new PropertyChangeListener() {
@Override
public void propertyChange(java.beans.PropertyChangeEvent e) {
log.debug("recv propChange: {} {} -> {}",e.getPropertyName(),e.getOldValue(),e.getNewValue());
log.debug("recv propChange: {} {} -> {}", e.getPropertyName(), e.getOldValue(), e.getNewValue());
updateLightStatusFields(false);
}
} );
});
setControlFrameActive(true);
updateLightStatusFields(true);

StringBuilder name = new StringBuilder("<html>");
light.getLightControlList().forEach((otherLc) -> {
name.append(jmri.jmrit.beantable.LightTableAction.getDescriptionText(otherLc,otherLc.getControlType() ));
name.append(jmri.jmrit.beantable.LightTableAction.getDescriptionText(otherLc, otherLc.getControlType()));
name.append("<br>");
});
if ( light.getLightControlList().size()==0 ) {

if (light.getLightControlList().isEmpty()) {
name.append("None");
}
name.append("</html>");
nowControllersTextField.setText(name.toString());

repaint();
revalidate();
pack();

} else {
setControlFrameActive(false);
nowStateTextField.setText(Bundle.getMessage("BeanStateUnknown"));

0 comments on commit 175b95a

Please sign in to comment.
You can’t perform that action at this time.