Skip to content
Snippets Groups Projects
Commit d6079b9d authored by Gregory Viguier's avatar Gregory Viguier
Browse files

Release 6.0.13

parent 6ac5ba11
No related branches found
No related merge requests found
Showing
with 1780 additions and 1677 deletions
......@@ -15,6 +15,7 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
......
......@@ -10,7 +10,7 @@
</parent>
<groupId>fr.soleil.gui</groupId>
<artifactId>Diff4cBean</artifactId>
<version>6.0.9</version>
<version>6.0.13</version>
<name>DiffractometerBean</name>
<developers>
<developer>
......
......@@ -204,13 +204,16 @@ public class DiffractometerBean extends AbstractTangoBox {
this.setWidgetModel(virtCrystalLabel, this.stringBox, virtCrystalKey);
this.HKLToolBar.add(virtCrystalLabel);
}
// Crystal Selection
this.HKLToolBar.add(new JLabel("Crystal List"));
this.HKLToolBar.add(this.getCrystalComboEditor());
// Actions on CrystalManager
this.HKLToolBar.add(new JButton(
new UseCrystalAction(ContextModel.getRealDiffractometer(), ContextModel.getCrystalManager())));
JButton useInPilotButton = new JButton(new UseCrystalAction(ContextModel.getRealDiffractometer(),
ContextModel.getCrystalManager(), realCrystalLabel));
this.HKLToolBar.add(useInPilotButton);
this.HKLToolBar.add(new JButton(new NewCrystalAction(ContextModel.getCrystalManager())));
this.HKLToolBar.add(new JButton(new CopyCrystalAction(ContextModel.getCrystalManager())));
this.HKLToolBar.add(new JButton(new DeleteCrystalAction(ContextModel.getCrystalManager())));
......@@ -267,6 +270,7 @@ public class DiffractometerBean extends AbstractTangoBox {
}
}
if (!arg0.equals(realCrystalLabel.getText())) {
realCrystalLabel.setBackground(Color.RED);
} else {
......@@ -400,7 +404,9 @@ public class DiffractometerBean extends AbstractTangoBox {
final TangoKey waveLengthKey = this.generateAttributeKey("WaveLength");
final TangoKey waveLengthUnitKey = new TangoKey();
TangoKeyTool.registerAttributeProperty(waveLengthUnitKey, getModel(), "WaveLength", AttributePropertyType.UNIT);
TangoKeyTool.registerAttributeProperty(waveLengthUnitKey,
getModel(), "WaveLength", AttributePropertyType.UNIT);
this.setWidgetModel(this.simpleScalarViewerLambda, this.stringBox, waveLengthKey);
this.setWidgetModel(this.lambdaUnit, this.stringBox, waveLengthUnitKey);
this.stringBox.setColorEnabled(lambdaUnit, false);
......@@ -417,7 +423,9 @@ public class DiffractometerBean extends AbstractTangoBox {
this.pseudoAxesBean.start();
this.resumeBean.setModel(this.getModel());
this.resumeBean.start();
} catch (DevFailed e) {
} catch (
DevFailed e) {
e.printStackTrace();
}
}
......@@ -731,8 +739,9 @@ public class DiffractometerBean extends AbstractTangoBox {
private JSplitPane getRightSplitPane() {
if (this.rightSplitPane == null) {
this.rightSplitPane = new JSplitPane();
this.rightSplitPane.setRightComponent(new JScrollPane(this.getControlTabbedPane(),
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED));
this.rightSplitPane.setRightComponent(
new JScrollPane(this.getControlTabbedPane(), ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED));
// JScrollPane
this.rightSplitPane.setLeftComponent(getWestPanel());
......
......@@ -11,7 +11,11 @@ import java.util.prefs.Preferences;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import fr.soleil.bean.diffractometer.gui.util.AutoScrolledFormattedTextField;
import fr.soleil.bean.diffractometer.gui.util.FormattedLabel;
import fr.soleil.bean.diffractometer.model.AxesFormat;
import fr.soleil.bean.motor.UserMotorBean;
import fr.soleil.comete.box.AbstractTangoBox;
import fr.soleil.comete.definition.widget.util.CometeFont;
......@@ -29,7 +33,7 @@ public class ReachTargetBean extends AbstractTangoBox {
private static final long serialVersionUID = 1L;
public final static int REAL_AXES_TYPE = 1;
public final static int PSEUDO_AXES_TYPE = 2;
private Label pViewers = null;
private FormattedLabel pViewers = null;
private AutoScrolledTextField pViewersTextField = null;
private double pViewersLabelValues = 0;
private Label labels = null;
......@@ -103,10 +107,13 @@ public class ReachTargetBean extends AbstractTangoBox {
this.panel.add(this.labels, viewerPanelConstraints1);
if (this.type == REAL_AXES_TYPE) {
this.pViewers = this.generateLabel();
this.pViewers = new FormattedLabel();
this.pViewers.setFormat(AxesFormat.getInstance().getFormat(targetlabel));
this.pViewers.setPreferredSize(new Dimension(60, 60));
this.pViewers.setMinimumSize(new Dimension(60, 60));
this.pViewers.setHorizontalTextPosition(SwingConstants.CENTER);
this.pViewers.setToolTipText("Target Motor Position Value");
final TangoKey stringScalarKey = new TangoKey();
TangoKeyTool.registerAttribute(stringScalarKey,
this.attribute.substring(0, this.attribute.lastIndexOf("/")),
......@@ -189,10 +196,12 @@ public class ReachTargetBean extends AbstractTangoBox {
public AutoScrolledTextField getPViewersTextField() {
if (this.pViewersTextField == null) {
this.pViewersTextField = new AutoScrolledTextField();
this.pViewersTextField = new AutoScrolledFormattedTextField();
this.pViewersTextField.setCometeFont(new CometeFont("Dialog", Font.PLAIN, 16));
this.pViewersTextField.setPreferredSize(new Dimension(60, 60));
this.pViewersTextField.setMinimumSize(new Dimension(60, 60));
((AutoScrolledFormattedTextField) this.pViewersTextField)
.setFormat(AxesFormat.getInstance().getFormat(this.targetlabel));
this.pViewersTextField.setToolTipText("Target Motor Position Value");
this.pViewersTextField.setBackground(Color.GREEN);
}
......
......@@ -12,8 +12,6 @@ import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
......@@ -342,8 +340,7 @@ public class TargetAxesBeanPanel extends AbstractTangoBox {
public void setPseudoAxesValues(final double[] pseudoAxesValues) {
this.pseudoAxesValues = pseudoAxesValues;
for (int i = 0; i < pseudoAxesValues.length; i++) {
final BigDecimal bd = new BigDecimal(pseudoAxesValues[i]).setScale(4, RoundingMode.HALF_EVEN);
this.reachTargetBean[i].setPViewersLabelValues(bd.doubleValue());
this.reachTargetBean[i].setPViewersLabelValues(pseudoAxesValues[i]);
}
}
......
......@@ -4,6 +4,7 @@
*/
package fr.soleil.bean.diffractometer.gui.action;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
......@@ -16,22 +17,25 @@ import org.tango.utils.DevFailedUtils;
import fr.esrf.Tango.DevFailed;
import fr.esrf.TangoApi.DeviceAttribute;
import fr.esrf.TangoApi.DeviceProxy;
import fr.soleil.comete.swing.Label;
public class UseCrystalAction extends AbstractAction {
private static final long serialVersionUID = 1L;
private DeviceProxy realDiffractometerProxy = null;
private DeviceProxy crystalManagerProxy = null;
private Label realCrystalLabel;
/**
* @throws DevFailed
*
*/
public UseCrystalAction(String realModel, String crystalManagerModel) {
public UseCrystalAction(String realModel, String crystalManagerModel, Label realCrystalLabel) {
super();
try {
this.realDiffractometerProxy = new DeviceProxy(realModel);
this.crystalManagerProxy = new DeviceProxy(crystalManagerModel);
this.realCrystalLabel = realCrystalLabel;
// This is an instance initializer; it is executed just after the
// constructor of the superclass is invoked
......@@ -46,16 +50,6 @@ public class UseCrystalAction extends AbstractAction {
} catch (DevFailed e) {
JOptionPane.showMessageDialog(null, DevFailedUtils.toString(e), "Use Crystal", JOptionPane.WARNING_MESSAGE);
}
// Set an icon
// Icon icon = new ImageIcon("icon.gif");
// putValue(Action.SMALL_ICON, icon);
// Set a mnemonic character. In most look and feels, this causes the
// specified character to be underlined This indicates that if the
// component
// using this action has the focus and In some look and feels, this
// causes
}
@Override
......@@ -68,6 +62,7 @@ public class UseCrystalAction extends AbstractAction {
DeviceAttribute crystalForPilot = realDiffractometerProxy.read_attribute("Crystal");
crystalForPilot.insert(crystal);
realDiffractometerProxy.write_attribute(crystalForPilot);
realCrystalLabel.setBackground(Color.GREEN);
} catch (DevFailed e1) {
e1.printStackTrace();
JOptionPane.showMessageDialog((Component) e.getSource(), DevFailedUtils.toString(e1), "Use Crystal",
......
package fr.soleil.bean.diffractometer.gui.crystal;
import java.util.Locale;
import java.util.Set;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableCellRenderer;
import fr.esrf.Tango.DevFailed;
import fr.soleil.bean.diffractometer.model.AxesFormat;
/**
......@@ -16,6 +16,7 @@ import fr.soleil.bean.diffractometer.model.AxesFormat;
*/
public class ReflectionCellDoubleRenderer extends JTextField implements TableCellRenderer {
private static final long serialVersionUID = 1L;
private static final String AXIS_INDEX = "axisindex";
public ReflectionCellDoubleRenderer() {
super();
......@@ -35,15 +36,14 @@ public class ReflectionCellDoubleRenderer extends JTextField implements TableCel
Set<String> devicenames = null;
devicenames = AxesFormat.getInstance().getAxesSet();
String axesFormat = null;
// apply the format only on the columns of deviceAxesNames
if (devicenames.contains(name)) {
try {
axesFormat = AxesFormat.getInstance().getFormat(name);
} catch (DevFailed e) {
}
if (AXIS_INDEX.equals(name.toLowerCase())){
setText((int)mon_double + "");
} else
if (devicenames.contains(name.toLowerCase())) {
axesFormat = AxesFormat.getInstance().getFormat(name);
if (axesFormat != null) {
setText(String.format(axesFormat, mon_double));
setText(String.format(Locale.US, axesFormat, mon_double));
} else {
setText(mon_double + "");
}
......
......@@ -246,7 +246,7 @@ public class ReflectionsPanel extends AbstractTangoBox {
}
final List<TableColumn> l = this.reflectionsListTable.getColumns(true);
final List<TableColumn> ll = this.reflectionsListTable.getColumns(false);
final List<Integer> indexList = new ArrayList<Integer>();
final List<Integer> indexList = new ArrayList<>();
for (final TableColumn tc : ll) {
final int modelIndex = tc.getModelIndex();
indexList.add(modelIndex);
......@@ -508,7 +508,6 @@ public class ReflectionsPanel extends AbstractTangoBox {
try {
final DeviceProxy crystalManagerProxy = new DeviceProxy(ContextModel.getCrystalManager());
String reflectionFormat = crystalManagerProxy.get_attribute_info(REFLECTIONS).format;
String[] titlesFromDevice = crystalManagerProxy.read_attribute(ATTRIBUTE_REFLECTIONS_COLUMN_TITLES)
.extractStringArray();
String titles[] = new String[titlesFromDevice.length - 2];
......@@ -522,8 +521,7 @@ public class ReflectionsPanel extends AbstractTangoBox {
}
this.reflectionsModel = new ReflectionTableModel(ContextModel.getCrystalManager(), REFLECTIONS, titles);
getReflectionTable().setDefaultRenderer(Double.class,
new ReflectionCellDoubleRenderer());
getReflectionTable().setDefaultRenderer(Double.class, new ReflectionCellDoubleRenderer());
} catch (final DevFailed e) {
logger.error(DevFailedUtils.toString(e));
}
......
......@@ -64,7 +64,7 @@ public class SummaryBean extends AbstractTangoBox {
private final Logger logger = LoggerFactory.getLogger(SummaryBean.class);
private JTable resumeTable;
private final List<String> attributes = new LinkedList<String>();
private final List<String> attributes = new LinkedList<>();
private ScheduledExecutorService executor;
private ScheduledFuture<?> future;
private SummaryTableModel resumeTableModel;
......@@ -258,7 +258,7 @@ public class SummaryBean extends AbstractTangoBox {
@Override
public void run() {
// COLOR STUFF
List<String> pseudoAxisList = new ArrayList<String>(Arrays.asList(pseudoAxesProxies));
List<String> pseudoAxisList = new ArrayList<>(Arrays.asList(pseudoAxesProxies));
final Color[] colorsToUse = new Color[pseudoAxisList.size() + 1];
for (int i = 0; i < colorsToUse.length; i++) {
if (i % 2 == 1) {
......@@ -289,8 +289,10 @@ public class SummaryBean extends AbstractTangoBox {
DbDatum realPseudoAxisProperty = dev.get_property(ATTRIBUTE_REAL_PSEUDO_AXIS_PROXY);
String realPseudoAxis = realPseudoAxisProperty.extractString();
AttributeProxy paReal = new AttributeProxy(realPseudoAxis + "/" + pseudoAxisName);
String format = paReal.get_info_ex().format;
String format = AxesFormat.getInstance().getFormat(pseudoAxisName);
if (format == null) {
format = pa.get_info_ex().format;
}
DeviceProxy realPseudoAxisProxy = new DeviceProxy(realPseudoAxis);
DbDatum engineNameProperty = realPseudoAxisProxy.get_property("EngineName");
String mode = engineNameProperty.extractString();
......@@ -337,6 +339,7 @@ public class SummaryBean extends AbstractTangoBox {
double realValue = Double.NaN, readSim = Double.NaN, writeSim = Double.NaN;
String displayName = "";
String axisName = "";
final String[] split = realAxisProxy.split(":");
final DeviceAttribute axisAttribute = dp.read_attribute(realAxisProxy);
axisName = axisAttribute.getName();
......@@ -345,6 +348,7 @@ public class SummaryBean extends AbstractTangoBox {
AttrDataFormat.SCALAR);
DeviceAttribute realValueAttr = diffProxy.read_attribute(realAxisProxy);
String format = AxesFormat.getInstance().getFormat(realAxisProxy);
realValue = realValueAttr.extractDouble();
displayName = diffProxy.get_attribute_info(realAxisProxy).label;
final int index = SummaryBean.this.resumeTableModel.indexOf("", displayName);
......
package fr.soleil.bean.diffractometer.gui.util;
import fr.soleil.comete.swing.AutoScrolledTextField;
@SuppressWarnings("serial")
public class AutoScrolledFormattedTextField extends AutoScrolledTextField {
private String format;
public void setFormat(String format) {
this.format = format;
}
@Override
public void setText(String text) {
if (text != null && format != null) {
String formattedValue = text;
Double dValue = null;
try {
dValue = Double.valueOf(text);
formattedValue = String.format(format, dValue);
} catch (Exception e) {
}
super.setText(formattedValue);
} else {
super.setText(text);
}
}
}
......@@ -33,6 +33,7 @@ import fr.esrf.TangoApi.ApiUtil;
import fr.esrf.TangoApi.AttributeProxy;
import fr.esrf.TangoApi.DbDatum;
import fr.esrf.TangoApi.DeviceProxy;
import fr.soleil.bean.diffractometer.model.AxesFormat;
import fr.soleil.bean.diffractometer.model.ContextModel;
import fr.soleil.bean.diffractometer.model.DiffractometerModel;
import fr.soleil.comete.box.AbstractTangoBox;
......@@ -84,7 +85,7 @@ public class AxesBean extends AbstractTangoBox {
DevFailedUtils.logDevFailed(e, logger);
}
if (values != null) {
result = new HashMap<String, String>();
result = new HashMap<>();
for (int i = 0; i < values.length; i++) {
String value = values[i];
String[] val = value.split(":");
......@@ -284,13 +285,18 @@ public class AxesBean extends AbstractTangoBox {
viewerPanelConstraints1.weightx = 1;
this.panels[i].add(labels[i], viewerPanelConstraints1);
this.pViewers[i] = new AutoScrolledTextField();
this.pViewers[i] = new AutoScrolledFormattedTextField();
this.pViewers[i].setAutoscrolls(false);
this.pViewers[i].setFont(DEFAULT_FONT);
this.pViewers[i].setHorizontalAlignment(JTextField.CENTER);
final TangoKey vKey = this.generateAttributeKey(this.pseudoAxis[i][1]);
this.setWidgetModel(this.pViewers[i], this.stringBox, vKey);
stringBox.setFormatEnabled(this.pViewers[i], false);
((AutoScrolledFormattedTextField) this.pViewers[i])
.setFormat(AxesFormat.getInstance().getFormat(this.pseudoAxis[i][1]));
final GridBagConstraints viewerPanelConstraints2 = new GridBagConstraints();
viewerPanelConstraints2.fill = GridBagConstraints.BOTH;
viewerPanelConstraints2.gridx = 0;
......@@ -304,6 +310,9 @@ public class AxesBean extends AbstractTangoBox {
final TangoKey eKey = this.generateWriteAttributeKey(this.pseudoAxis[i][1]);
this.setWidgetModel(this.pEditors[i], this.numberBox, eKey);
numberBox.setFormatEnabled(this.pEditors[i], false);
this.pEditors[i].setFormat(AxesFormat.getInstance().getFormat(this.pseudoAxis[i][1]));
final GridBagConstraints viewerPanelConstraints3 = new GridBagConstraints();
viewerPanelConstraints3.fill = GridBagConstraints.NONE;
viewerPanelConstraints3.gridx = 0;
......
package fr.soleil.bean.diffractometer.gui.util;
import java.awt.Component;
import java.text.DecimalFormat;
import java.util.Locale;
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
......@@ -9,12 +9,15 @@ import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.table.TableCellEditor;
import org.apache.commons.lang3.StringUtils;
import fr.soleil.bean.diffractometer.gui.summary.SummaryTableModel;
public class CellDoubleEditor extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = -6710333214667600320L;
protected JTextField jTextField = null;
protected Double cellValue;
private final DecimalFormat decimalFormat = new DecimalFormat("#,##0.0###");
public CellDoubleEditor() {
this.jTextField = new JTextField();
......@@ -22,7 +25,13 @@ public class CellDoubleEditor extends AbstractCellEditor implements TableCellEdi
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
jTextField.setText(decimalFormat.format(value));
SummaryTableModel tableModel = (SummaryTableModel) table.getModel();
String format = tableModel.getFormatFor(row);
String strValue = "" + value;
if (format != null) {
strValue = StringUtils.trim(String.format(Locale.US, format, value));
}
jTextField.setText(strValue);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
......@@ -35,6 +44,12 @@ public class CellDoubleEditor extends AbstractCellEditor implements TableCellEdi
@Override
public Object getCellEditorValue() {
return cellValue = new Double(jTextField.getText());
Object result = new Double(0);
try {
result = new Double(jTextField.getText());
} catch (NumberFormatException nfe) {
//
}
return result;
}
}
package fr.soleil.bean.diffractometer.gui.util;
import fr.soleil.comete.swing.Label;
@SuppressWarnings("serial")
public class FormattedLabel extends Label {
private String format;
public void setFormat(String format) {
this.format = format;
}
@Override
public void setText(String text) {
if (text != null && format != null) {
String formattedValue = text;
Double dValue = null;
try {
dValue = Double.valueOf(text);
formattedValue = String.format(format, dValue);
} catch (Exception e) {
}
super.setText(formattedValue);
} else {
super.setText(text);
}
}
}
......@@ -29,16 +29,12 @@ public class SolutionTable extends NumberMatrixTable implements INumberTarget {
private void updateAttributeValue(short selectedIndex) {
DeviceAttribute attr;
try {
DeviceProxy device = new DeviceProxy(diffBean.firstPseudoAxis);
AttributeProxy attProxy = new AttributeProxy(
diffBean.firstPseudoAxis + "/" + DiffractometerBean.ATTRIBUTE_SOLUTIONS_IDX);
attr = new DeviceAttribute(DiffractometerBean.ATTRIBUTE_SOLUTIONS_IDX, selectedIndex);
attProxy.write(attr);
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
// TODO Remove Thread.sleep
}
device.command_inout("ApplySolutionAngle");
} catch (final DevFailed e) {
e.printStackTrace();
......
......@@ -4,6 +4,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import fr.esrf.Tango.DevFailed;
import fr.esrf.TangoApi.AttributeInfo;
import fr.esrf.TangoApi.DeviceAttribute;
......@@ -14,37 +16,43 @@ public class AxesFormat {
private String format;
private DeviceProxy diffractometer;
private final static String DIFFRACTO_PREPA = "PREPA/K6C/DIFFRACTOMETER";
private final static String AXES_NAMES = "axesNames";
private Map<String, String> loadedFormats;
private AxesFormat() {
loadedFormats = new HashMap<>();
try {
diffractometer = new DeviceProxy(ContextModel.getRealDiffractometer());
loadMapFormat();
} catch (DevFailed e) {
e.printStackTrace();
}
}
public static synchronized AxesFormat getInstance() {
public static AxesFormat getInstance() {
if (uniqueInstanceFormat == null) {
synchronized (AxesFormat.class) {
if (uniqueInstanceFormat == null) {
uniqueInstanceFormat = new AxesFormat();
}
}
}
return uniqueInstanceFormat;
}
private Map<String, String> loadMapFormat() throws DevFailed {
String[] list = getAxesNames();
for (int i = 0; i < list.length; i++) {
AttributeInfo attr = diffractometer.get_attribute_info(list[i]);
private void loadMapFormat() throws DevFailed {
String[] axes = getAxesNames();
for (int i = 0; i < axes.length; i++) {
AttributeInfo attr = diffractometer.get_attribute_info(axes[i]);
format = attr.format;
loadedFormats.put(list[i], format);
loadedFormats.put(axes[i].toLowerCase(), format);
loadedFormats.put(StringUtils.remove(axes[i], "Axis").toLowerCase(), format);
}
return loadedFormats;
}
// the name must begin with "Axis"
public String getFormat(String axes) throws DevFailed {
String format = loadMapFormat().get(axes);
return format;
public String getFormat(String axe) {
return loadedFormats.get(axe.toLowerCase().trim());
}
public Set<String> getAxesSet() {
......@@ -52,10 +60,13 @@ public class AxesFormat {
}
private String[] getAxesNames() throws DevFailed {
diffractometer = new DeviceProxy(DIFFRACTO_PREPA);
String[] result = null;
if (diffractometer != null) {
DeviceAttribute axesNames = diffractometer.read_attribute(AXES_NAMES);
String[] list = axesNames.extractStringArray();
return list;
result = axesNames.extractStringArray();
}
return result;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment