Exemplo n.º 1
0
  /**
   * Creates the tool context denoting the range of samples that should be analysed by a tool.
   *
   * @return a tool context, never <code>null</code>.
   */
  private ToolContext createToolContext() {
    int startOfDecode = -1;
    int endOfDecode = -1;

    final int dataLength = this.dataContainer.getValues().length;
    if (this.dataContainer.isCursorsEnabled()) {
      if (this.dataContainer.isCursorPositionSet(0)) {
        final Long cursor1 = this.dataContainer.getCursorPosition(0);
        startOfDecode = this.dataContainer.getSampleIndex(cursor1.longValue()) - 1;
      }
      if (this.dataContainer.isCursorPositionSet(1)) {
        final Long cursor2 = this.dataContainer.getCursorPosition(1);
        endOfDecode = this.dataContainer.getSampleIndex(cursor2.longValue()) + 1;
      }
    } else {
      startOfDecode = 0;
      endOfDecode = dataLength;
    }

    startOfDecode = Math.max(0, startOfDecode);
    if ((endOfDecode < 0) || (endOfDecode >= dataLength)) {
      endOfDecode = dataLength - 1;
    }

    return new DefaultToolContext(startOfDecode, endOfDecode);
  }
Exemplo n.º 2
0
 /**
  * Goes to the current cursor position of the cursor with the given index.
  *
  * @param aCursorIdx the index of the cursor to go to, >= 0 && < 10.
  */
 public void gotoCursorPosition(final int aCursorIdx) {
   if ((this.mainFrame != null) && this.dataContainer.isCursorsEnabled()) {
     final Long cursorPosition = this.dataContainer.getCursorPosition(aCursorIdx);
     if (cursorPosition != null) {
       this.mainFrame.gotoPosition(cursorPosition.longValue());
     }
   }
 }
Exemplo n.º 3
0
 /** Goes to the current cursor position of the last available cursor. */
 public void gotoLastAvailableCursor() {
   if ((this.mainFrame != null) && this.dataContainer.isCursorsEnabled()) {
     for (int c = CapturedData.MAX_CURSORS - 1; c >= 0; c--) {
       if (this.dataContainer.isCursorPositionSet(c)) {
         final Long cursorPosition = this.dataContainer.getCursorPosition(c);
         if (cursorPosition != null) {
           this.mainFrame.gotoPosition(cursorPosition.longValue());
         }
         break;
       }
     }
   }
 }
 public NativeTestContainer(
     FrameworkFactory frameworkFactory,
     List<ProvisionOption> bundles,
     Map<String, String> properties) {
   m_bundles = bundles;
   m_properties = properties;
   m_frameworkFactory = frameworkFactory;
   String s = m_properties.get("pax-exam.framework.shutdown.timeout");
   m_timeout = s != null ? Long.valueOf(s) : TIMEOUT_IN_MILLIS;
 }
Exemplo n.º 5
0
  /**
   * Sets the cursor position of the cursor with the given index.
   *
   * @param aCursorIdx the index of the cursor to set, >= 0 && < 10;
   * @param aLocation the mouse location on screen where the cursor should become, cannot be <code>
   *     null</code>.
   */
  public void setCursorPosition(final int aCursorIdx, final Point aLocation) {
    // Implicitly enable cursor mode, the user already had made its
    // intensions clear that he want to have this by opening up the
    // context menu anyway...
    setCursorMode(true);

    if (this.mainFrame != null) {
      // Convert the mouse-position to a sample index...
      final long sampleIdx = this.mainFrame.convertMousePositionToSampleIndex(aLocation);

      this.dataContainer.setCursorPosition(aCursorIdx, Long.valueOf(sampleIdx));

      fireCursorChangedEvent(aCursorIdx, aLocation.x);
    }

    updateActions();
  }
  public EquinoxLogServices(EquinoxConfiguration environmentInfo, Location configuration) {
    String logFilePath = environmentInfo.getConfiguration(EclipseStarter.PROP_LOGFILE);
    if (logFilePath == null) {
      logFilePath = Long.toString(System.currentTimeMillis()) + EquinoxLogServices.LOG_EXT;
    }

    File logFile = new File(logFilePath);
    if (!logFile.isAbsolute()) {
      File configAreaDirectory = null;
      if (configuration != null)
        // TODO assumes the URL is a file: url
        configAreaDirectory = new File(configuration.getURL().getFile());

      if (configAreaDirectory != null) {
        logFile = new File(configAreaDirectory, logFilePath);
      } else {
        logFile = null;
      }
    }

    boolean enabled =
        "true"
            .equals(
                environmentInfo.getConfiguration(
                    PROP_LOG_ENABLED, "true")); // $NON-NLS-1$ //$NON-NLS-2$
    if (logFile != null) {
      environmentInfo.setConfiguration(EclipseStarter.PROP_LOGFILE, logFile.getAbsolutePath());
      logWriter = new EquinoxLogWriter(logFile, EQUINOX_LOGGER_NAME, enabled, environmentInfo);

      File perfLogFile = new File(logFile.getParentFile(), "performance.log"); // $NON-NLS-1$
      perfWriter = new EquinoxLogWriter(perfLogFile, PERF_LOGGER_NAME, true, environmentInfo);
    } else {
      logWriter =
          new EquinoxLogWriter((Writer) null, EQUINOX_LOGGER_NAME, enabled, environmentInfo);
      perfWriter = new EquinoxLogWriter((Writer) null, PERF_LOGGER_NAME, true, environmentInfo);
    }

    if ("true"
        .equals(environmentInfo.getConfiguration(EclipseStarter.PROP_CONSOLE_LOG))) // $NON-NLS-1$
    logWriter.setConsoleLog(true);
    logServiceManager = new LogServiceManager(logWriter, perfWriter);
    eclipseLogFactory = new EquinoxLogFactory(logWriter, logServiceManager);
    rootFrameworkLog = eclipseLogFactory.createFrameworkLog(null, logWriter);
  }
Exemplo n.º 7
0
 /* GuardedBy(lock) */
 private String generateName() {
   return "generated_" + Long.toString(nextID++); // $NON-NLS-1$;
 }
  public void execute(String s, PrintStream out, PrintStream err) {
    // Get start level service.
    ServiceReference ref =
        m_context.getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName());
    if (ref == null) {
      out.println("StartLevel service is unavailable.");
      return;
    }

    StartLevel sl = (StartLevel) m_context.getService(ref);
    if (sl == null) {
      out.println("StartLevel service is unavailable.");
      return;
    }

    // Parse command line.
    StringTokenizer st = new StringTokenizer(s, " ");

    // Ignore the command name.
    st.nextToken();

    // If there is only one token, then assume it is
    // a bundle ID for which we must retrieve the bundle
    // level.
    if (st.countTokens() == 1) {
      // Get the bundle and display start level.
      Bundle bundle = null;
      String token = null;
      try {
        token = st.nextToken();
        long id = Long.parseLong(token);
        bundle = m_context.getBundle(id);
        if (bundle != null) {
          out.println("Bundle " + token + " is level " + sl.getBundleStartLevel(bundle));
        } else {
          err.println("Bundle ID " + token + " is invalid.");
        }
      } catch (NumberFormatException ex) {
        err.println("Unable to parse integer '" + token + "'.");
      } catch (Exception ex) {
        err.println(ex.toString());
      }
    }
    // If there is more than one token, assume the first
    // token is the new start level and the remaining
    // tokens are the bundle IDs whose start levels should
    // be changed.
    else if (st.countTokens() > 1) {
      // Get the bundle.
      Bundle bundle = null;
      String token = null;
      int startLevel = -1;

      try {
        token = st.nextToken();
        startLevel = Integer.parseInt(token);
      } catch (NumberFormatException ex) {
        err.println("Unable to parse start level '" + token + "'.");
      }

      // Ignore invalid start levels.
      if (startLevel > 0) {
        // Set the start level for each specified bundle.
        while (st.hasMoreTokens()) {
          try {
            token = st.nextToken();
            long id = Long.parseLong(token);
            bundle = m_context.getBundle(id);
            if (bundle != null) {
              sl.setBundleStartLevel(bundle, startLevel);
            } else {
              err.println("Bundle ID '" + token + "' is invalid.");
            }
          } catch (NumberFormatException ex) {
            err.println("Unable to parse bundle ID '" + token + "'.");
          } catch (Exception ex) {
            err.println(ex.toString());
          }
        }
      } else {
        err.println("Invalid start level.");
      }
    } else {
      err.println("Incorrect number of arguments.");
    }
  }
    public int compareTo(Object other) {
      Long thisServiceId = ServiceRegistrationImpl.this.serviceId;
      Long otherServiceId = ((ServiceRegistrationImpl) other).serviceId;

      return otherServiceId.compareTo(thisServiceId);
    }