Esempio n. 1
0
  /**
   * Set Environment key to value
   *
   * @param key variable name ('#' will be converted to '_')
   * @param stringValue try to convert to Object
   */
  public void setEnvironment(String key, String stringValue) {
    if (key == null || key.length() == 0) return;
    //	log.fine( "Scriptlet.setEnvironment " + key, stringValue);
    if (stringValue == null) {
      m_ctx.remove(key);
      return;
    }

    //  Boolean
    if (stringValue.equals("Y")) {
      m_ctx.put(convertKey(key), Boolean.valueOf(true));
      return;
    }
    if (stringValue.equals("N")) {
      m_ctx.put(convertKey(key), Boolean.valueOf(false));
      return;
    }

    //  Timestamp
    Timestamp timeValue = null;
    try {
      timeValue = Timestamp.valueOf(stringValue);
      m_ctx.put(convertKey(key), timeValue);
      return;
    } catch (Exception e) {
    }

    //  Numeric
    Integer intValue = null;
    try {
      intValue = Integer.valueOf(stringValue);
    } catch (NumberFormatException e) {
    }
    Double doubleValue = null;
    try {
      doubleValue = Double.valueOf(stringValue);
    } catch (NumberFormatException e) {
    }
    if (doubleValue != null) {
      if (intValue != null) {
        double di = Double.parseDouble(intValue.toString());
        //  the numbers are the same -> integer
        if (Double.compare(di, doubleValue.doubleValue()) == 0) {
          m_ctx.put(convertKey(key), intValue);
          return;
        }
      }
      m_ctx.put(convertKey(key), doubleValue);
      return;
    }
    if (intValue != null) {
      m_ctx.put(convertKey(key), intValue);
      return;
    }
    m_ctx.put(convertKey(key), stringValue);
  } //  SetEnvironment
Esempio n. 2
0
  /** Synchronizes the state of the actions to the current state of this host. */
  private void updateActions() {
    final DeviceController currentDeviceController = getDeviceController();

    final boolean deviceControllerSet = currentDeviceController != null;
    final boolean deviceCapturing = deviceControllerSet && currentDeviceController.isCapturing();
    final boolean deviceSetup =
        deviceControllerSet && !deviceCapturing && currentDeviceController.isSetup();

    getAction(CaptureAction.ID).setEnabled(deviceControllerSet);
    getAction(CancelCaptureAction.ID).setEnabled(deviceCapturing);
    getAction(RepeatCaptureAction.ID).setEnabled(deviceSetup);

    final boolean projectChanged = this.projectManager.getCurrentProject().isChanged();
    final boolean projectSavedBefore =
        this.projectManager.getCurrentProject().getFilename() != null;
    final boolean dataAvailable = this.dataContainer.hasCapturedData();

    getAction(SaveProjectAction.ID).setEnabled(projectChanged);
    getAction(SaveProjectAsAction.ID).setEnabled(projectSavedBefore && projectChanged);
    getAction(SaveDataFileAction.ID).setEnabled(dataAvailable);

    getAction(ZoomInAction.ID).setEnabled(dataAvailable);
    getAction(ZoomOutAction.ID).setEnabled(dataAvailable);
    getAction(ZoomDefaultAction.ID).setEnabled(dataAvailable);
    getAction(ZoomFitAction.ID).setEnabled(dataAvailable);

    final boolean triggerEnable = dataAvailable && this.dataContainer.hasTriggerData();
    getAction(GotoTriggerAction.ID).setEnabled(triggerEnable);

    // Update the cursor actions accordingly...
    final boolean enableCursors = dataAvailable && this.dataContainer.isCursorsEnabled();

    for (int c = 0; c < CapturedData.MAX_CURSORS; c++) {
      final boolean enabled = enableCursors && this.dataContainer.isCursorPositionSet(c);
      getAction(GotoNthCursorAction.getID(c)).setEnabled(enabled);
    }

    getAction(GotoFirstCursorAction.ID).setEnabled(enableCursors);
    getAction(GotoLastCursorAction.ID).setEnabled(enableCursors);

    getAction(SetCursorModeAction.ID).setEnabled(dataAvailable);
    getAction(SetCursorModeAction.ID)
        .putValue(Action.SELECTED_KEY, Boolean.valueOf(this.dataContainer.isCursorsEnabled()));

    boolean anyCursorSet = false;
    for (int c = 0; c < CapturedData.MAX_CURSORS; c++) {
      final boolean cursorPositionSet = this.dataContainer.isCursorPositionSet(c);
      anyCursorSet |= cursorPositionSet;

      final Action action = getAction(SetCursorAction.getCursorId(c));
      action.setEnabled(dataAvailable);
      action.putValue(Action.SELECTED_KEY, Boolean.valueOf(cursorPositionSet));
    }

    getAction(ClearCursors.ID).setEnabled(enableCursors && anyCursorSet);
  }
Esempio n. 3
0
 public void propertyChange(PropertyChangeEvent e) {
   String propertyName = e.getPropertyName();
   if (e.getPropertyName().equals(Action.NAME)) {
     String text = (String) e.getNewValue();
     menuItem.setText(text);
   } else if (propertyName.equals("enabled")) {
     Boolean enabledState = (Boolean) e.getNewValue();
     menuItem.setEnabled(enabledState.booleanValue());
   }
 }
Esempio n. 4
0
 /**
  * Generates handles response. This is were we would pass stuff to cli or gui, etc
  *
  * @param n the processed policy object
  * @return the policyObjected as accepted by user (potentially modified
  */
 public PolicyObject userResponse(PolicyObject n) {
   if ((parseAct(genProps.getProperty("userResponse", null)) == null)
       && !Boolean.parseBoolean(genProps.getProperty("blanketAccept", "false"))) {
     return userInterface.userResponse(n);
   } else {
     if (Boolean.parseBoolean(genProps.getProperty("blanketAccept", "false"))) {
       return n.setAction(n.getAction().setOverride(true));
     } else {
       return n.setAction(parseAct(genProps.getProperty("userResponse", null)));
     }
   }
 }
Esempio n. 5
0
  public static void invokeSetMethod(Object obj, String prop, String value)
      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    Class cl = obj.getClass();
    // change first letter to uppercase
    String setMeth = "set" + prop.substring(0, 1).toUpperCase() + prop.substring(1);

    // try string method
    try {
      Class[] cldef = {String.class};
      Method meth = cl.getMethod(setMeth, cldef);
      Object[] params = {value};
      meth.invoke(obj, params);
      return;
    } catch (NoSuchMethodException ex) {
      try {
        // try int method
        Class[] cldef = {Integer.TYPE};
        Method meth = cl.getMethod(setMeth, cldef);
        Object[] params = {Integer.valueOf(value)};
        meth.invoke(obj, params);
        return;
      } catch (NoSuchMethodException nsmex) {
        // try boolean method
        Class[] cldef = {Boolean.TYPE};
        Method meth = cl.getMethod(setMeth, cldef);
        Object[] params = {Boolean.valueOf(value)};
        meth.invoke(obj, params);
        return;
      }
    }
  }
Esempio n. 6
0
  /**
   * A constructor permitting a user interface class to launch everything and be in control.
   *
   * @param args any commandline arguements
   * @param ui the known UserIO object
   * @throws Exception Mostly from loadWeights, but should also happen for loadFromConfig
   */
  public Gio(String[] args, UserIO ui) throws Exception {

    userInterface = ui;
    genProps = loadFromConfig("./PrivacyAdviser.cfg");
    loadCLO(args);
    // TODO add method to check validity of genProps (after each file load, clo load, and ui load).

    if ((genProps.getProperty("genConfig") != null)
        && (genProps.getProperty("genConfig") != "./PrivacyAdvisor.cfg")) {
      System.err.println("clo config call");
      genProps = loadFromConfig(genProps.getProperty("genConfig")); // TODO merge, not override
      loadCLO(args);
    }

    // start the logger
    logger =
        startLogger(
            genProps.getProperty("loglocation", "./LOG.txt"),
            genProps.getProperty("loglevel", "INFO"));
    if (userInterface == null) {
      selectUI(genProps.getProperty("userIO"));
    }
    selectPDB(genProps.getProperty("policyDB"));

    // load the weights configuration file
    origWeights = new Properties();
    origWeights = loadWeights();
    if (Boolean.parseBoolean(genProps.getProperty("useNet", "false"))) {
      startNetwork();
    } else {
      nr = null;
    }
  }
 public static void fetchDeviceNames() {
   String nametable = System.getProperty("hm2mqtt.hm.jsonNameTable");
   if (nametable != null) {
     fetchDeviceNamesFromNameTable(nametable);
     return;
   }
   if (Boolean.getBoolean("hm2mqtt.hm.disableReGa")) return;
   fetchDeviceNamesFromReGa();
 }
Esempio n. 8
0
 /**
  * Loads the case history into cache. This is where the background database chosen.
  *
  * @param dLoc the location of the database
  */
 public void loadDB() {
   try {
     // TODO what about if we want to create a new db?
     if (!Boolean.parseBoolean(genProps.getProperty("newDB"))) {
       pdb.loadDB();
     }
   } catch (Exception e) {
     System.err.println("Something wrong with loading DB");
   }
   try {
     loadCLPolicies();
   } catch (Exception e) {
     System.err.println("Error. Probably wrong path to P3P folder");
   }
 }
Esempio n. 9
0
  private void doReincarnation() throws RDCException {
    try {
      // TODO JavaClassRunner is very simple and primitive.
      // Feel free to beef it up...

      String[] props = normalProps;

      if (Boolean.parseBoolean(System.getenv("AS_SUPER_DEBUG")))
        props = debuggerProps; // very very difficult to debug this stuff otherwise!

      new JavaClassRunner(classpath, props, classname, args);
    } catch (Exception e) {
      logger.severe(strings.get("restart.server.jvmError", e));
      throw new RDCException();
    }
  }
Esempio n. 10
0
  @SuppressWarnings("OverridableMethodCallInConstructor")
  Notepad() {
    super(true);

    // Trying to set Nimbus look and feel
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception ignored) {
    }

    setBorder(BorderFactory.createEtchedBorder());
    setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor = createEditor();
    // Add this as a listener for undoable edits.
    editor.getDocument().addUndoableEditListener(undoHandler);

    // install the command table
    commands = new HashMap<Object, Action>();
    Action[] actions = getActions();
    for (Action a : actions) {
      commands.put(a.getValue(Action.NAME), a);
    }

    JScrollPane scroller = new JScrollPane();
    JViewport port = scroller.getViewport();
    port.add(editor);

    String vpFlag = getProperty("ViewportBackingStore");
    if (vpFlag != null) {
      Boolean bs = Boolean.valueOf(vpFlag);
      port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE);
    }

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add("North", createToolbar());
    panel.add("Center", scroller);
    add("Center", panel);
    add("South", createStatusbar());
  }
Esempio n. 11
0
  public static void invokeSetMethodCaseInsensitive(Object obj, String prop, String value)
      throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    String alternateMethodName = null;
    Class cl = obj.getClass();

    String setMeth = "set" + prop;

    Method[] methodsList = cl.getMethods();
    boolean methodFound = false;
    int i = 0;
    for (i = 0; i < methodsList.length; ++i) {
      if (methodsList[i].getName().equalsIgnoreCase(setMeth) == true) {
        Class[] parameterTypes = methodsList[i].getParameterTypes();
        if (parameterTypes.length == 1) {
          if (parameterTypes[0].getName().equals("java.lang.String")) {
            methodFound = true;
            break;
          } else alternateMethodName = methodsList[i].getName();
        }
      }
    }
    if (methodFound == true) {
      Object[] params = {value};
      methodsList[i].invoke(obj, params);
      return;
    }
    if (alternateMethodName != null) {
      try {
        // try int method
        Class[] cldef = {Integer.TYPE};
        Method meth = cl.getMethod(alternateMethodName, cldef);
        Object[] params = {Integer.valueOf(value)};
        meth.invoke(obj, params);
        return;
      } catch (NoSuchMethodException nsmex) {
        // try boolean method
        Class[] cldef = {Boolean.TYPE};
        Method meth = cl.getMethod(alternateMethodName, cldef);
        Object[] params = {Boolean.valueOf(value)};
        meth.invoke(obj, params);
        return;
      }

    } else throw new NoSuchMethodException(setMeth);
  }
Esempio n. 12
0
 /**
  * Returns whether or not the capture size is bound to the number of channels.
  *
  * @return <code>true</code> if the capture size is bound to the number of channels, <code>false
  *     </code> otherwise.
  */
 public boolean isCaptureSizeBoundToEnabledChannels() {
   final String value = this.properties.get(DEVICE_CAPTURESIZE_BOUND);
   return Boolean.parseBoolean(value);
 }
Esempio n. 13
0
 private void initConsoleLog() {
   String consoleLogStr = getProperty(consoleLogKey, "false");
   consoleLog = Boolean.parseBoolean(consoleLogStr);
 }
Esempio n. 14
0
 /**
  * Returns whether or not the device supports triggers.
  *
  * @return <code>true</code> if the device supports triggers, <code>false</code> otherwise.
  */
 public boolean isTriggerSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_TRIGGERS);
   return Boolean.parseBoolean(value);
 }
Esempio n. 15
0
 /**
  * Returns whether or not the device supports a testing mode.
  *
  * @return <code>true</code> if testing mode is supported by the device, <code>false</code>
  *     otherwise.
  */
 public boolean isTestModeSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_TEST_MODE);
   return Boolean.parseBoolean(value);
 }
Esempio n. 16
0
 /**
  * Returns whether the device send its samples in "reverse" order.
  *
  * @return <code>true</code> if samples are send in reverse order (= last sample first), <code>
  *     false</code> otherwise.
  */
 public boolean isSamplesInReverseOrder() {
   final String rawValue = this.properties.get(DEVICE_SAMPLE_REVERSE_ORDER);
   return Boolean.parseBoolean(rawValue);
 }
Esempio n. 17
0
 /**
  * Returns whether or not the device supports RLE (Run-Length Encoding).
  *
  * @return <code>true</code> if a RLE encoder is present in the device, <code>false</code>
  *     otherwise.
  */
 public boolean isRleSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_RLE);
   return Boolean.parseBoolean(value);
 }
Esempio n. 18
0
 /**
  * Returns whether upon opening the DTR line needs to be high (= <code>true</code>) or low (=
  * <code>false</code>).
  *
  * <p>This method has no meaning if the used interface is <em>not</em> {@link
  * DeviceInterface#SERIAL}.
  *
  * @return <code>true</code> if the DTR line needs to be set upon opening the serial port, <code>
  *     false</code> if the DTR line needs to be reset upon opening the serial port.
  */
 public boolean isOpenPortDtr() {
   final String value = this.properties.get(DEVICE_OPEN_PORT_DTR);
   return Boolean.parseBoolean(value);
 }
Esempio n. 19
0
 /**
  * Returns whether or not the device supports a noise filter.
  *
  * @return <code>true</code> if a noise filter is present in the device, <code>false</code>
  *     otherwise.
  */
 public boolean isNoiseFilterSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_NOISEFILTER);
   return Boolean.parseBoolean(value);
 }
Esempio n. 20
0
 private void initDebug() {
   debug = Boolean.valueOf(System.getProperty(debugKey, Boolean.toString(debug)));
 }
Esempio n. 21
0
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 /////////               ALL PRIVATE BELOW               ////////////////////
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 private void init(AdminCommandContext context) throws IOException {
   logger = context.getLogger();
   props = Globals.get(StartupContext.class).getArguments();
   verbose = Boolean.parseBoolean(props.getProperty("-verbose", "false"));
   logger.info(strings.get("restart.server.init"));
 }
Esempio n. 22
0
 /**
  * call the user interface's general configuration method if the userInit option is true, and a
  * user interface exists
  */
 public void configUI() {
   if (Boolean.parseBoolean(genProps.getProperty("userInit", "false"))
       && !(userInterface == null)) {
     userInterface.user_init(genProps);
   }
 }
Esempio n. 23
0
/**
 * A central location for holding all runtime configurable properties as well as logging
 * configuration.
 *
 * <p>Ideally we will find all properties used by <code>Aparapi</code> here. Please consider
 * updating this class if you wish to add new properties which control <code>Aparapi</code>s
 * behavior.
 *
 * @author gfrost
 */
public class Config extends ConfigJNI {

  // Logging setup
  private static final String logPropName = propPkgName + ".logLevel";

  private static final Logger logger = Logger.getLogger(Config.getLoggerName());

  /**
   * Allows the user to request to use a jvmti agent to access JNI code rather than loading
   * explicitly.
   *
   * <p>Usage -agentpath=/full/path/to/agent.dll -Dcom.amd.aparapi.useAgent=true
   */
  public static final boolean useAgent = Boolean.getBoolean(propPkgName + ".useAgent");

  /** Disable Unsafe */
  public static final boolean disableUnsafe = Boolean.getBoolean(propPkgName + ".disableUnsafe");

  /**
   * Allows the user to request a specific Kernel.EXECUTION_MODE enum value for all Kernels.
   *
   * <p>Usage -Dcom.amd.aparapi.executionMode={SEQ|JTP|CPU|GPU|ACC}
   *
   * @see com.amd.aparapi.Kernel.EXECUTION_MODE
   */
  public static final String executionMode = System.getProperty(propPkgName + ".executionMode");

  /**
   * Allows the user to request that the execution mode of each kernel invocation be reported to
   * stdout.
   *
   * <p>Usage -Dcom.amd.aparapi.enableExecutionModeReporting={true|false}
   */
  public static final boolean enableExecutionModeReporting =
      Boolean.getBoolean(propPkgName + ".enableExecutionModeReporting");

  /**
   * Allows the user to request that generated OpenCL code is dumped to standard out.
   *
   * <p>Usage -Dcom.amd.aparapi.enableShowGeneratedOpenCL={true|false}
   */
  public static final boolean enableShowGeneratedOpenCL =
      Boolean.getBoolean(propPkgName + ".enableShowGeneratedOpenCL");

  /**
   * Upon exiting the JVM, dumps kernel profiling info to standard out.
   *
   * <p>Usage -Dcom.amd.aparapi.dumpProfilesOnExit={true|false}
   */
  public static final boolean dumpProfilesOnExit =
      Boolean.getBoolean(propPkgName + ".dumpProfilesOnExit");

  /**
   * Dumps profiling info (for a single execution) after every Kernel execution.
   *
   * <p>Usage -Dcom.amd.aparapi.dumpProfileOnExecution={true|false}
   */
  public static final boolean dumpProfileOnExecution =
      Boolean.getBoolean(propPkgName + ".dumpProfileOnExecution");

  // Pragma/OpenCL codegen related flags
  public static final boolean enableAtomic32 = Boolean.getBoolean(propPkgName + ".enableAtomic32");

  public static final boolean enableAtomic64 = Boolean.getBoolean(propPkgName + ".enableAtomic64");

  public static final boolean enableByteWrites =
      Boolean.getBoolean(propPkgName + ".enableByteWrites");

  public static final boolean enableDoubles = Boolean.getBoolean(propPkgName + ".enableDoubles");

  // Debugging related flags
  public static final boolean verboseComparitor =
      Boolean.getBoolean(propPkgName + ".verboseComparitor");

  public static final boolean dumpFlags = Boolean.getBoolean(propPkgName + ".dumpFlags");

  // Individual bytecode support related flags
  public static final boolean enablePUTFIELD = Boolean.getBoolean(propPkgName + ".enable.PUTFIELD");

  public static final boolean enableARETURN = !Boolean.getBoolean(propPkgName + ".disable.ARETURN");

  public static final boolean enablePUTSTATIC =
      Boolean.getBoolean(propPkgName + ".enable.PUTSTATIC");

  // Allow static array accesses
  public static final boolean enableGETSTATIC =
      true; // Boolean.getBoolean(propPkgName + ".enable.GETSTATIC");

  public static final boolean enableINVOKEINTERFACE =
      Boolean.getBoolean(propPkgName + ".enable.INVOKEINTERFACE");

  public static final boolean enableMONITOR = Boolean.getBoolean(propPkgName + ".enable.MONITOR");

  public static final boolean enableNEW = Boolean.getBoolean(propPkgName + ".enable.NEW");

  public static final boolean enableATHROW = Boolean.getBoolean(propPkgName + ".enable.ATHROW");

  public static final boolean enableMETHODARRAYPASSING =
      !Boolean.getBoolean(propPkgName + ".disable.METHODARRAYPASSING");

  public static final boolean enableARRAYLENGTH =
      Boolean.getBoolean(propPkgName + ".enable.ARRAYLENGTH");

  public static final boolean enableSWITCH = Boolean.getBoolean(propPkgName + ".enable.SWITCH");

  public static boolean enableShowFakeLocalVariableTable =
      Boolean.getBoolean(propPkgName + ".enableShowFakeLocalVariableTable");

  public static final boolean enableInstructionDecodeViewer =
      Boolean.getBoolean(propPkgName + ".enableInstructionDecodeViewer");

  public static String instructionListenerClassName =
      System.getProperty(propPkgName + ".instructionListenerClass");

  public static InstructionListener instructionListener = null;

  public interface InstructionListener {
    void showAndTell(String message, Instruction _start, Instruction _instruction);
  }

  static {
    try {
      final Level level = Level.parse(System.getProperty(getLoggerName(), "WARNING"));

      final Handler[] handlers = Logger.getLogger("").getHandlers();
      for (final Handler handler : handlers) {
        handler.setLevel(level);
      }

      logger.setLevel(level);
    } catch (final Exception e) {
      System.out.println("Exception " + e + " in Aparapi logging setup");
      e.printStackTrace();
    }
  };

  static {
    if (enableInstructionDecodeViewer
        && ((instructionListenerClassName == null) || instructionListenerClassName.equals(""))) {
      instructionListenerClassName = InstructionViewer.class.getName();
    }

    if ((instructionListenerClassName != null) && !instructionListenerClassName.equals("")) {
      try {
        final Class<?> instructionListenerClass = Class.forName(instructionListenerClassName);
        instructionListener = (InstructionListener) instructionListenerClass.newInstance();
      } catch (final ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (final InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (final IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (dumpFlags) {
      System.out.println(propPkgName + ".executionMode{GPU|ACC|CPU|JTP|SEQ}=" + executionMode);
      System.out.println(
          propPkgName + ".logLevel{OFF|FINEST|FINER|FINE|WARNING|SEVERE|ALL}=" + logger.getLevel());
      System.out.println(propPkgName + ".enableProfiling{true|false}=" + enableProfiling);
      System.out.println(propPkgName + ".enableProfilingCSV{true|false}=" + enableProfilingCSV);
      System.out.println(propPkgName + ".enableVerboseJNI{true|false}=" + enableVerboseJNI);
      System.out.println(
          propPkgName
              + ".enableVerboseJNIOpenCLResourceTracking{true|false}="
              + enableVerboseJNIOpenCLResourceTracking);
      System.out.println(
          propPkgName + ".enableShowGeneratedOpenCL{true|false}=" + enableShowGeneratedOpenCL);
      System.out.println(
          propPkgName
              + ".enableExecutionModeReporting{true|false}="
              + enableExecutionModeReporting);
      System.out.println(
          propPkgName
              + ".enableInstructionDecodeViewer{true|false}="
              + enableInstructionDecodeViewer);
      System.out.println(
          propPkgName
              + ".instructionListenerClassName{<class name which extends com.amd.aparapi.Config.InstructionListener>}="
              + instructionListenerClassName);
    }
  }

  public static String getLoggerName() {
    return logPropName;
  }
}
Esempio n. 24
0
  /**
   * Creates window with parameters specified by <code>params</code>
   *
   * @see #init
   */
  private final void create(XCreateWindowParams params) {
    XToolkit.awtLock();
    try {
      XSetWindowAttributes xattr = new XSetWindowAttributes();
      try {
        checkParams(params);

        long value_mask = ((Long) params.get(VALUE_MASK)).longValue();

        Long eventMask = (Long) params.get(EVENT_MASK);
        xattr.set_event_mask(eventMask.longValue());
        value_mask |= XlibWrapper.CWEventMask;

        Long border_pixel = (Long) params.get(BORDER_PIXEL);
        if (border_pixel != null) {
          xattr.set_border_pixel(border_pixel.longValue());
          value_mask |= XlibWrapper.CWBorderPixel;
        }

        Long colormap = (Long) params.get(COLORMAP);
        if (colormap != null) {
          xattr.set_colormap(colormap.longValue());
          value_mask |= XlibWrapper.CWColormap;
        }
        Long background_pixmap = (Long) params.get(BACKGROUND_PIXMAP);
        if (background_pixmap != null) {
          xattr.set_background_pixmap(background_pixmap.longValue());
          value_mask |= XlibWrapper.CWBackPixmap;
        }

        Long parentWindow = (Long) params.get(PARENT_WINDOW);
        Rectangle bounds = (Rectangle) params.get(BOUNDS);
        Integer depth = (Integer) params.get(DEPTH);
        Integer visual_class = (Integer) params.get(VISUAL_CLASS);
        Long visual = (Long) params.get(VISUAL);
        Boolean overrideRedirect = (Boolean) params.get(OVERRIDE_REDIRECT);
        if (overrideRedirect != null) {
          xattr.set_override_redirect(overrideRedirect.booleanValue());
          value_mask |= XlibWrapper.CWOverrideRedirect;
        }

        Boolean saveUnder = (Boolean) params.get(SAVE_UNDER);
        if (saveUnder != null) {
          xattr.set_save_under(saveUnder.booleanValue());
          value_mask |= XlibWrapper.CWSaveUnder;
        }

        Integer backingStore = (Integer) params.get(BACKING_STORE);
        if (backingStore != null) {
          xattr.set_backing_store(backingStore.intValue());
          value_mask |= XlibWrapper.CWBackingStore;
        }

        Integer bitGravity = (Integer) params.get(BIT_GRAVITY);
        if (bitGravity != null) {
          xattr.set_bit_gravity(bitGravity.intValue());
          value_mask |= XlibWrapper.CWBitGravity;
        }

        if (log.isLoggable(Level.FINE)) {
          log.fine("Creating window for " + this + " with the following attributes: \n" + params);
        }
        window =
            XlibWrapper.XCreateWindow(
                XToolkit.getDisplay(),
                parentWindow.longValue(),
                bounds.x,
                bounds.y, // location
                bounds.width,
                bounds.height, // size
                0, // border
                depth.intValue(), // depth
                visual_class.intValue(), // class
                visual.longValue(), // visual
                value_mask, // value mask
                xattr.pData); // attributes

        if (window == 0) {
          throw new IllegalStateException(
              "Couldn't create window because of wrong parameters. Run with NOISY_AWT to see details");
        }
        XToolkit.addToWinMap(window, this);
      } finally {
        xattr.dispose();
      }
    } finally {
      XToolkit.awtUnlock();
    }
  }
Esempio n. 25
0
  /**
   * exports the data to a CSV file
   *
   * @param aFile File object
   */
  private void storeToCsvFile(final File aFile, final UARTDataSet aDataSet) {
    try {
      final CsvExporter exporter = ExportUtils.createCsvExporter(aFile);

      exporter.setHeaders(
          "index",
          "start-time",
          "end-time",
          "event?",
          "event-type",
          "RxD event",
          "TxD event",
          "RxD data",
          "TxD data");

      final List<UARTData> decodedData = aDataSet.getData();
      for (int i = 0; i < decodedData.size(); i++) {
        final UARTData ds = decodedData.get(i);

        final String startTime = Unit.Time.format(aDataSet.getTime(ds.getStartSampleIndex()));
        final String endTime = Unit.Time.format(aDataSet.getTime(ds.getEndSampleIndex()));

        String eventType = null;
        String rxdEvent = null;
        String txdEvent = null;
        String rxdData = null;
        String txdData = null;

        switch (ds.getType()) {
          case UARTData.UART_TYPE_EVENT:
            eventType = ds.getEventName();
            break;

          case UARTData.UART_TYPE_RXEVENT:
            rxdEvent = ds.getEventName();
            break;

          case UARTData.UART_TYPE_TXEVENT:
            txdEvent = ds.getEventName();
            break;

          case UARTData.UART_TYPE_RXDATA:
            rxdData = Integer.toString(ds.getData());
            break;

          case UARTData.UART_TYPE_TXDATA:
            txdData = Integer.toString(ds.getData());
            break;

          default:
            break;
        }

        exporter.addRow(
            Integer.valueOf(i),
            startTime,
            endTime,
            Boolean.valueOf(ds.isEvent()),
            eventType,
            rxdEvent,
            txdEvent,
            rxdData,
            txdData);
      }

      exporter.close();
    } catch (final IOException exception) {
      // Make sure to handle IO-interrupted exceptions properly!
      if (!HostUtils.handleInterruptedException(exception)) {
        LOG.log(Level.WARNING, "CSV export failed!", exception);
      }
    }
  }
Esempio n. 26
0
 /**
  * Returns whether or not the device supports "complex" triggers.
  *
  * @return <code>true</code> if complex triggers are supported by the device, <code>false</code>
  *     otherwise.
  */
 public boolean isComplexTriggersSupported() {
   final String value = this.properties.get(DEVICE_TRIGGER_COMPLEX);
   return Boolean.parseBoolean(value);
 }
Esempio n. 27
0
 /**
  * Returns whether or not the device supports "double-data rate" sampling, also known as
  * "demux"-sampling.
  *
  * @return <code>true</code> if DDR is supported by the device, <code>false</code> otherwise.
  */
 public boolean isDoubleDataRateSupported() {
   final String value = this.properties.get(DEVICE_SUPPORTS_DDR);
   return Boolean.parseBoolean(value);
 }
Esempio n. 28
0
  /**
   * Gets the value of a specific property as a <tt>boolean</tt>. If the specified property name is
   * associated with a value, the string representation of the value is parsed into a
   * <tt>boolean</tt> according to the rules of {@link Boolean#parseBoolean(String)} . Otherwise,
   * <tt>defaultValue</tt> is returned.
   *
   * @param propertyName the name of the property to get the value of as a <tt>boolean</tt>
   * @param defaultValue the value to be returned if the specified property name is not associated
   *     with a value
   * @return the value of the property with the specified name as a <tt>boolean</tt>;
   *     <tt>defaultValue</tt> if the property with the specified name is not associated with a
   *     value
   */
  public static boolean getBoolean(String propertyName, boolean defaultValue) {
    String str = getString(propertyName);

    return (str == null) ? defaultValue : Boolean.parseBoolean(str);
  }