All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jive3.TaskSubDevicePropertyNode Maven / Gradle / Ivy

The newest version!
package jive3;

import fr.esrf.TangoApi.Database;
import fr.esrf.Tango.DevFailed;

import javax.swing.*;

import jive.JiveUtils;

import java.io.IOException;
import java.util.Vector;

// ---------------------------------------------------------------

class TaskSubDevicePropertyNode extends PropertyNode {

  private Database db;
  private String   devName;
  private String   subName;

  TaskSubDevicePropertyNode(TreePanel parent,Database db,String devName,String subName) {
    this.db = db;
    this.devName = devName;
    this.parentPanel = parent;
    this.subName = subName;
  }

  void populateNode() throws DevFailed {
  }

  ImageIcon getIcon() {
    return TangoNodeRenderer.leaficon;
  }

  public String toString() {
    return subName;
  }

  String getTitle() {
    return "Device properties";
  }

  String getName() {
    return devName+"/"+subName;
  }
  
  String getDevName() {
    return devName;  
  }
  
  String getSubName() {
    return subName;
  }

  public boolean isLeaf() {
    return true;
  }

  void execAction(int number,boolean multipleCall) {
    defaultPropertyAction(number);
  }

  private boolean acceptProperty(String name) {

    return !(JiveUtils.IsPollCfgItem(name) ||
             JiveUtils.IsLogCfgItem(name) ||
             JiveUtils.IsHdbCfgItem(name) ||
             JiveUtils.IsSystemItem(name));

  }

  public void viewHistory() {

    parentPanel.invoker.historyDlg.viewDevicePropertyHistory(devName,subName+"/*");
    parentPanel.invoker.showHistory();

  }

  void saveProperties() {

    try {
      DbFileWriter.SaveDeviceProperties(devName);
    } catch (DevFailed e) {
      JiveUtils.showTangoError(e);
    } catch (IOException e2) {
      JiveUtils.showJiveError(e2.getMessage());
    }

  }

  String[][] getProperties() {

    String[][] ret = new String[0][0];

    try {

      String plist[] = db.get_device_property_list(devName, subName + "/*");
      Vector pvec = new Vector();
      int cutIdx = subName.length() + 1;

      for (int i = 0; i < plist.length; i++) {
        // Remove config item
        if( acceptProperty(plist[i]) ) {
          pvec.add(plist[i].substring(cutIdx));
          String[] res = db.get_device_property(devName, plist[i]).extractStringArray();
          pvec.add(JiveUtils.stringArrayToString(res));
        }
      }

      ret = new String[pvec.size()/2][2];
      for(int i=0;i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy