Skip to content
Snippets Groups Projects
Commit 401616f2 authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

code updated according to changes in databrowser

parent 7e4ccd6b
Branches
No related tags found
No related merge requests found
...@@ -55,11 +55,7 @@ import fr.soleil.comete.bean.tangodeviceexplorer.view.DeviceStatePanel; ...@@ -55,11 +55,7 @@ import fr.soleil.comete.bean.tangodeviceexplorer.view.DeviceStatePanel;
import fr.soleil.comete.bean.tangodeviceexplorer.view.ExecutionCommandDialog; import fr.soleil.comete.bean.tangodeviceexplorer.view.ExecutionCommandDialog;
import fr.soleil.comete.bean.tangodeviceexplorer.view.TangoDeviceExplorer; import fr.soleil.comete.bean.tangodeviceexplorer.view.TangoDeviceExplorer;
import fr.soleil.comete.definition.widget.properties.ChartProperties; import fr.soleil.comete.definition.widget.properties.ChartProperties;
import fr.soleil.comete.definition.widget.properties.ImageProperties;
import fr.soleil.comete.definition.widget.properties.PlotProperties;
import fr.soleil.comete.definition.widget.properties.xml.ChartPropertiesXmlManager; import fr.soleil.comete.definition.widget.properties.xml.ChartPropertiesXmlManager;
import fr.soleil.comete.definition.widget.properties.xml.ImagePropertiesXmlManager;
import fr.soleil.comete.definition.widget.properties.xml.PlotPropertiesXmlManager;
import fr.soleil.comete.swing.util.CometeUtils; import fr.soleil.comete.swing.util.CometeUtils;
import fr.soleil.comete.swing.util.EDTManager; import fr.soleil.comete.swing.util.EDTManager;
import fr.soleil.comete.tango.data.service.TangoKey; import fr.soleil.comete.tango.data.service.TangoKey;
...@@ -88,7 +84,7 @@ public class TangoDeviceExplorerController extends DataBrowserController { ...@@ -88,7 +84,7 @@ public class TangoDeviceExplorerController extends DataBrowserController {
private final TangoDataSourceBrowser dataSourceBrowser; private final TangoDataSourceBrowser dataSourceBrowser;
private String deviceName; private String deviceName;
private IKey sourceKey; private IKey knownSourceKey;
private Map<String, Item> openedAttribute; private Map<String, Item> openedAttribute;
private List<Item> openedSpectrumImageAttribute; private List<Item> openedSpectrumImageAttribute;
private List<Item> openedSpectrum; private List<Item> openedSpectrum;
...@@ -137,8 +133,8 @@ public class TangoDeviceExplorerController extends DataBrowserController { ...@@ -137,8 +133,8 @@ public class TangoDeviceExplorerController extends DataBrowserController {
public void setDeviceName(String deviceName) { public void setDeviceName(String deviceName) {
this.deviceName = deviceName; this.deviceName = deviceName;
sourceKey = new TangoKey(); knownSourceKey = new TangoKey();
TangoKeyTool.registerDeviceName(sourceKey, deviceName); TangoKeyTool.registerDeviceName(knownSourceKey, deviceName);
} }
public DataItemViewer getDataItemViewer() { public DataItemViewer getDataItemViewer() {
...@@ -225,89 +221,90 @@ public class TangoDeviceExplorerController extends DataBrowserController { ...@@ -225,89 +221,90 @@ public class TangoDeviceExplorerController extends DataBrowserController {
LOGGER.debug("Stack trace", e); LOGGER.debug("Stack trace", e);
} }
// image scales // XXX no more global scale item
Item xScaleItem = dataItemViewer.getImageXScaleItem(); // // image scales
Item yScaleItem = dataItemViewer.getImageYScaleItem(); // Item xScaleItem = dataItemViewer.getImageXScaleItem();
IKey xScaleItemKey = (xScaleItem == null ? null : xScaleItem.getKey()); // Item yScaleItem = dataItemViewer.getImageYScaleItem();
IKey yScaleItemKey = (yScaleItem == null ? null : yScaleItem.getKey()); // IKey xScaleItemKey = (xScaleItem == null ? null : xScaleItem.getKey());
// IKey yScaleItemKey = (yScaleItem == null ? null : yScaleItem.getKey());
if (!openedAttribute.isEmpty()) { //
Collection<Item> values = openedAttribute.values(); // if (!openedAttribute.isEmpty()) {
Element elemItems = new Element("items"); // Collection<Item> values = openedAttribute.values();
racine.addContent(elemItems); // Element elemItems = new Element("items");
IKey itemKey = null; // racine.addContent(elemItems);
for (Item attributeItem : values) { // IKey itemKey = null;
itemKey = attributeItem.getKey(); // for (Item attributeItem : values) {
Element elemItem = new Element("item"); // itemKey = attributeItem.getKey();
elemItems.addContent(elemItem); // Element elemItem = new Element("item");
// elemItems.addContent(elemItem);
Item theItem = items.get(itemKey); //
elemItem.setAttribute("axis", theItem.getAxis().name()); // Item theItem = items.get(itemKey);
// elemItem.setAttribute("axis", theItem.getAxis().name());
if (itemKey == xScaleItemKey) { //
elemItem.setAttribute("imageXScale", "true"); // if (itemKey == xScaleItemKey) {
} // elemItem.setAttribute("imageXScale", "true");
if (itemKey == yScaleItemKey) { // }
elemItem.setAttribute("imageYScale", "true"); // if (itemKey == yScaleItemKey) {
} // elemItem.setAttribute("imageYScale", "true");
// }
try { //
// set item key // try {
String itemKeyXML = itemKey.toXML(); // // set item key
org.w3c.dom.Element itemKeyNode = (org.w3c.dom.Element) XMLUtils // String itemKeyXML = itemKey.toXML();
.getRootNodeFromFileContent(itemKeyXML); // org.w3c.dom.Element itemKeyNode = (org.w3c.dom.Element) XMLUtils
Element elemItemKey = builder.build(itemKeyNode); // .getRootNodeFromFileContent(itemKeyXML);
elemItemKey.detach(); // Element elemItemKey = builder.build(itemKeyNode);
elemItem.addContent(elemItemKey); // elemItemKey.detach();
// elemItem.addContent(elemItemKey);
// set item properties (plot or image) //
switch (theItem.getAxis()) { // // set item properties (plot or image)
case Y1: // switch (theItem.getAxis()) {
case Y2: // case Y1:
case Y1_COLUMN: // case Y2:
case Y1_ROW: // case Y1_COLUMN:
case Y2_COLUMN: // case Y1_ROW:
case Y2_ROW: { // case Y2_COLUMN:
String id = itemKey.getInformationKey(); // case Y2_ROW: {
PlotProperties plotProperties = dataItemViewer.getChartDataViewPlotProperties(id); // String id = itemKey.getInformationKey();
if (plotProperties != null) { // PlotProperties plotProperties = dataItemViewer.getChartDataViewPlotProperties(id);
String plotPropXML = PlotPropertiesXmlManager.toXmlString(plotProperties); // if (plotProperties != null) {
org.w3c.dom.Element plotPropNode = (org.w3c.dom.Element) XMLUtils // String plotPropXML = PlotPropertiesXmlManager.toXmlString(plotProperties);
.getRootNodeFromFileContent(plotPropXML); // org.w3c.dom.Element plotPropNode = (org.w3c.dom.Element) XMLUtils
Element elemPlotProp = builder.build(plotPropNode); // .getRootNodeFromFileContent(plotPropXML);
elemPlotProp.detach(); // Element elemPlotProp = builder.build(plotPropNode);
elemItem.addContent(elemPlotProp); // elemPlotProp.detach();
} // elemItem.addContent(elemPlotProp);
} // }
break; // }
// break;
case IMAGE: { //
ImageProperties imageProperties = dataItemViewer.getImageProperties(itemKey); // case IMAGE: {
if (imageProperties != null) { // ImageProperties imageProperties = dataItemViewer.getImageProperties(itemKey);
String imagePropXML = ImagePropertiesXmlManager.toXmlString(imageProperties); // if (imageProperties != null) {
// String imagePropXML = ImagePropertiesXmlManager.toXmlString(imageProperties);
org.w3c.dom.Element imagePropNode; //
// org.w3c.dom.Element imagePropNode;
imagePropNode = (org.w3c.dom.Element) XMLUtils //
.getRootNodeFromFileContent(imagePropXML); // imagePropNode = (org.w3c.dom.Element) XMLUtils
Element elemImageProp = builder.build(imagePropNode); // .getRootNodeFromFileContent(imagePropXML);
elemImageProp.detach(); // Element elemImageProp = builder.build(imagePropNode);
elemItem.addContent(elemImageProp); // elemImageProp.detach();
} // elemItem.addContent(elemImageProp);
} // }
break; // }
// break;
default: //
break; // default:
} // break;
} // }
// }
catch (XMLWarning e) { //
e.printStackTrace(); // catch (XMLWarning e) {
} // e.printStackTrace();
// }
} //
} // }
// }
// Put deviceName in XML // Put deviceName in XML
Element elemDevice = new Element("device"); Element elemDevice = new Element("device");
...@@ -560,6 +557,25 @@ public class TangoDeviceExplorerController extends DataBrowserController { ...@@ -560,6 +557,25 @@ public class TangoDeviceExplorerController extends DataBrowserController {
return (cancelable != null) && cancelable.isCanceled(); return (cancelable != null) && cancelable.isCanceled();
} }
public static IKey getSourceKey(IKey key, IKey knownSourceKey) {
IKey sourceKey;
String xDevice = TangoKeyTool.getDeviceName(key);
String device = TangoKeyTool.getDeviceName(knownSourceKey);
if (xDevice == null) {
if (device == null) {
sourceKey = knownSourceKey;
} else {
sourceKey = null;
}
} else if ((device != null) && device.equalsIgnoreCase(xDevice)) {
sourceKey = knownSourceKey;
} else {
sourceKey = new TangoKey();
TangoKeyTool.registerDeviceName(knownSourceKey, xDevice);
}
return sourceKey;
}
public void openItem(final IDataSourceBrowser browser, final IKey sourceKey, final IKey itemKey, public void openItem(final IDataSourceBrowser browser, final IKey sourceKey, final IKey itemKey,
DataType forcedType, AxisType forcedAxis, ICancelable cancelable, boolean cursorManagement) { DataType forcedType, AxisType forcedAxis, ICancelable cancelable, boolean cursorManagement) {
// Display the waiting cursor // Display the waiting cursor
...@@ -568,7 +584,7 @@ public class TangoDeviceExplorerController extends DataBrowserController { ...@@ -568,7 +584,7 @@ public class TangoDeviceExplorerController extends DataBrowserController {
IKey sliderScale = browser.getSliderScale(itemKey); IKey sliderScale = browser.getSliderScale(itemKey);
DataFormat format = browser.getFormat(itemKey); DataFormat format = browser.getFormat(itemKey);
Item item = new Item(itemKey, browser, forcedType, format); Item item = new Item(itemKey, sourceKey, browser, forcedType, format);
// if itemOpened is true you can't open the attribute because the attribute is already added // if itemOpened is true you can't open the attribute because the attribute is already added
String attributeName = TangoKeyTool.getAttributeName(itemKey); String attributeName = TangoKeyTool.getAttributeName(itemKey);
...@@ -603,7 +619,9 @@ public class TangoDeviceExplorerController extends DataBrowserController { ...@@ -603,7 +619,9 @@ public class TangoDeviceExplorerController extends DataBrowserController {
} }
sources.add(sourceKey); sources.add(sourceKey);
item.setXKey(xScale); IKey xSourceKey = getSourceKey(xScale, sourceKey);
item.setXKey(xScale, xSourceKey);
if (forcedAxis != null) { if (forcedAxis != null) {
DataType currentType = browser.getType(itemKey); DataType currentType = browser.getType(itemKey);
if ((forcedAxis == AxisType.IMAGE) && (currentType != DataType.IMAGE)) { if ((forcedAxis == AxisType.IMAGE) && (currentType != DataType.IMAGE)) {
...@@ -654,7 +672,7 @@ public class TangoDeviceExplorerController extends DataBrowserController { ...@@ -654,7 +672,7 @@ public class TangoDeviceExplorerController extends DataBrowserController {
if (dataType == null) { if (dataType == null) {
itemType = dataSourceBrowser.getKeyType(key); itemType = dataSourceBrowser.getKeyType(key);
} }
openItem(dataSourceBrowser, sourceKey, key, itemType, axisType); openItem(dataSourceBrowser, knownSourceKey, key, itemType, axisType);
} }
} }
...@@ -937,7 +955,7 @@ public class TangoDeviceExplorerController extends DataBrowserController { ...@@ -937,7 +955,7 @@ public class TangoDeviceExplorerController extends DataBrowserController {
if (isCanceled()) { if (isCanceled()) {
break; break;
} else { } else {
openItem(dataSourceBrowser, sourceKey, key, itemType, axisType, this, false); openItem(dataSourceBrowser, knownSourceKey, key, itemType, axisType, this, false);
} }
} // end for (IKey key : keysForAttributes) } // end for (IKey key : keysForAttributes)
publish(device); publish(device);
......
...@@ -346,12 +346,14 @@ public class DeviceTreePanel extends AbstractDeviceExplorerPanel implements Mous ...@@ -346,12 +346,14 @@ public class DeviceTreePanel extends AbstractDeviceExplorerPanel implements Mous
int[] selectedRows = table.getSelectedRows(); int[] selectedRows = table.getSelectedRows();
Item item = null; Item item = null;
IKey sourceKey = null;
for (int index : selectedRows) { for (int index : selectedRows) {
item = (Item) table.getValueAt(index, 0); item = (Item) table.getValueAt(index, 0);
sourceKey = TangoDeviceExplorerController.getSourceKey(xKey, item.getSourceKey());
if (putKeyOnX) { if (putKeyOnX) {
item.setXKey(xKey, browser, dataType, format); item.setXKey(xKey, sourceKey, browser, dataType, format);
} else { } else {
item.setXKey(xKey, browser, dataType, format); item.setXKey(xKey, sourceKey, browser, dataType, format);
} }
controller.openItem(xAttribut, dataType, AxisType.X); controller.openItem(xAttribut, dataType, AxisType.X);
controller.setItemScale(item); controller.setItemScale(item);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment