예제 #1
2
  protected void runScript(String[] cmd, JTextArea txaMsg) {
    String strg = "";

    if (cmd == null) return;

    Process prcs = null;
    try {
      Messages.postDebug("Running script: " + cmd[2]);
      Runtime rt = Runtime.getRuntime();

      prcs = rt.exec(cmd);

      if (prcs == null) return;

      InputStream istrm = prcs.getInputStream();
      if (istrm == null) return;

      BufferedReader bfr = new BufferedReader(new InputStreamReader(istrm));

      while ((strg = bfr.readLine()) != null) {
        // System.out.println(strg);
        strg = strg.trim();
        // Messages.postDebug(strg);
        strg = strg.toLowerCase();
        if (txaMsg != null) {
          txaMsg.append(strg);
          txaMsg.append("\n");
        }
      }
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.writeStackTrace(e);
      Messages.postDebug(e.toString());
    } finally {
      // It is my understanding that these streams are left
      // open sometimes depending on the garbage collector.
      // So, close them.
      try {
        if (prcs != null) {
          OutputStream os = prcs.getOutputStream();
          if (os != null) os.close();
          InputStream is = prcs.getInputStream();
          if (is != null) is.close();
          is = prcs.getErrorStream();
          if (is != null) is.close();
        }
      } catch (Exception ex) {
        Messages.writeStackTrace(ex);
      }
    }
  }
예제 #2
0
    /** Displays the labels and the values for the panel. */
    protected void displayPnlFields(HashMap hmPnl) {
      if (hmPnl == null || hmPnl.isEmpty()) return;

      Iterator keySetItr = hmPnl.keySet().iterator();
      String strLabel = "";
      String strValue = "";

      // if the file is empty, then create an empty set of textfields.
      if (hmPnl == null || hmPnl.isEmpty()) {
        displayNewTxf("", "");
        return;
      }

      Container container = getParent();
      if (container != null) container.setVisible(false);
      try {
        // Get each set of label and value, and display them.
        while (keySetItr.hasNext()) {
          strLabel = (String) keySetItr.next();
          strValue = (String) hmPnl.get(strLabel);

          displayNewTxf(strLabel, strValue);
        }

        if (container != null) container.setVisible(true);
        revalidate();
        repaint();
      } catch (Exception e) {
        Messages.writeStackTrace(e);
        // e.printStackTrace();
        Messages.postDebug(e.toString());
      }
    }
예제 #3
0
파일: Db4o.java 프로젝트: superyfwy/db4o
  protected static final ObjectContainer openMemoryFile1(MemoryFile memoryFile) {
    synchronized (Db4o.lock) {
      if (memoryFile == null) {
        memoryFile = new MemoryFile();
      }
      ObjectContainer oc = null;
      if (Deploy.debug) {
        System.out.println("db4o Debug is ON");
        oc = new YapMemoryFile(memoryFile);

        // intentionally no exception handling,
        // in order to follow uncaught errors
      } else {
        try {
          oc = new YapMemoryFile(memoryFile);
        } catch (Throwable t) {
          Messages.logErr(i_config, 4, "Memory File", t);
          return null;
        }
      }
      if (oc != null) {
        Platform4.postOpen(oc);
        Messages.logMsg(i_config, 5, "Memory File");
      }
      return oc;
    }
  }
예제 #4
0
  /** Write file with position and size of the login box */
  public static void writePersistence() {

    Messages.postDebug("LoginBox", "LoginBox.writePersistence");
    // If the panel has not been created, don't try to write a file
    if (position == null) return;

    String filepath = FileUtil.savePath("USER/PERSISTENCE/LoginPanel");

    FileWriter fw;
    PrintWriter os;
    try {
      File file = new File(filepath);
      fw = new FileWriter(file);
      os = new PrintWriter(fw);
      os.println("Login Panel");

      os.println(height);
      os.println(width);
      double xd = position.getX();
      int xi = (int) xd;
      os.println(xi);
      double yd = position.getY();
      int yi = (int) yd;
      os.println(yi);

      os.close();
    } catch (Exception er) {
      Messages.postError("Problem creating  " + filepath);
      Messages.writeStackTrace(er);
    }
  }
예제 #5
0
    protected void buildPanel(String strPath) {
      BufferedReader reader = WFileUtil.openReadFile(strPath);
      String strLine;

      if (reader == null) return;

      try {
        while ((strLine = reader.readLine()) != null) {
          if (strLine.startsWith("#") || strLine.startsWith("%") || strLine.startsWith("@"))
            continue;

          StringTokenizer sTokLine = new StringTokenizer(strLine, ":");

          // first token is the label e.g. Password Length
          if (sTokLine.hasMoreTokens()) {
            createLabel(sTokLine.nextToken(), this);
          }

          // second token is the value
          String strValue = sTokLine.hasMoreTokens() ? sTokLine.nextToken() : "";
          if (strValue.equalsIgnoreCase("yes") || strValue.equalsIgnoreCase("no"))
            createChkBox(strValue, this);
          else createTxf(strValue, this);
        }
      } catch (Exception e) {
        Messages.writeStackTrace(e);
        // e.printStackTrace();
        Messages.postDebug(e.toString());
      }
    }
예제 #6
0
파일: Support.java 프로젝트: floatin/Weave
  /**
   * Substitute actual data for the parameter markers to simulate parameter substitution in a
   * PreparedStatement.
   *
   * @param sql The SQL containing parameter markers to substitute.
   * @param list The parameter descriptors.
   * @param connection The current connection.
   * @return The modified SQL statement.
   */
  static String substituteParameters(String sql, ParamInfo[] list, ConnectionJDBC2 connection)
      throws SQLException {
    int len = sql.length();

    for (int i = 0; i < list.length; i++) {
      if (!list[i].isRetVal && !list[i].isSet && !list[i].isOutput) {
        throw new SQLException(
            Messages.get("error.prepare.paramnotset", Integer.toString(i + 1)), "07000");
      }

      Object value = list[i].value;

      if (value instanceof java.io.InputStream || value instanceof java.io.Reader) {
        try {
          if (list[i].jdbcType == java.sql.Types.LONGVARCHAR
              || list[i].jdbcType == java.sql.Types.CLOB
              || list[i].jdbcType == java.sql.Types.VARCHAR) {
            // TODO: Should improve the character set handling here
            value = list[i].getString("US-ASCII");
          } else {
            value = list[i].getBytes("US-ASCII");
          }
          // Replace the stream/reader with the String/byte[]
          list[i].value = value;
        } catch (java.io.IOException e) {
          throw new SQLException(Messages.get("error.generic.ioerror", e.getMessage()), "HY000");
        }
      }

      if (value instanceof String) {
        len += ((String) value).length() + 5;
      } else if (value instanceof byte[]) {
        len += ((byte[]) value).length * 2 + 4;
      } else {
        len += 32; // Default size
      }
    }

    StringBuffer buf = new StringBuffer(len + 16);
    int start = 0;

    for (int i = 0; i < list.length; i++) {
      int pos = list[i].markerPos;

      if (pos > 0) {
        buf.append(sql.substring(start, list[i].markerPos));
        start = pos + 1;
        final boolean isUnicode = connection.getTdsVersion() >= Driver.TDS70 && list[i].isUnicode;
        Support.embedData(buf, list[i].value, isUnicode, connection);
      }
    }

    if (start < sql.length()) {
      buf.append(sql.substring(start));
    }

    return buf.toString();
  }
예제 #7
0
 public void scale(double d1, double d2) {
   m_localGraphicsState.setXScale(d1);
   m_localGraphicsState.setYScale(d2);
   if (DEBUG)
     System.err.println(
         Messages.getInstance().getString("PostscriptGraphics_Scale_Error_Text_First")
             + d1
             + Messages.getInstance().getString("PostscriptGraphics_Scale_Error_Text_Second")
             + d2);
 }
예제 #8
0
 /**
  * Translates the origin of the graphics context to the point (x, y) in the current coordinate
  * system. Modifies this graphics context so that its new origin corresponds to the point (x, y)
  * in this graphics context's original coordinate system. All coordinates used in subsequent
  * rendering operations on this graphics context will be relative to this new origin.
  *
  * @param x the x coordinate.
  * @param y the y coordinate.
  */
 public void translate(int x, int y) {
   if (DEBUG)
     System.out.println(
         Messages.getInstance().getString("PostscriptGraphics_Translate_Text_First")
             + x
             + Messages.getInstance().getString("PostscriptGraphics_Translate_Text_Second")
             + y);
   m_localGraphicsState.setXOffset(m_localGraphicsState.getXOffset() + xScale(x));
   m_localGraphicsState.setYOffset(m_localGraphicsState.getYOffset() + yScale(y));
   m_psGraphicsState.setXOffset(m_psGraphicsState.getXOffset() + xScale(x));
   m_psGraphicsState.setYOffset(m_psGraphicsState.getYOffset() + yScale(y));
 }
예제 #9
0
  private void processMessage(Message message) throws IOException {
    if (message.getType().equals("SimpleMessage")) {
      MessageType messageType = (MessageType) message.getValue();
      String receiver = messageType.getToUser();
      history.get(receiver).add(messageType);
    }

    if (message.getType().equals("ConnectUserMessage")) {
      String user = (String) message.getValue();
      Messages messages = history.get(user);
      Operations.sendHistory(messages.getLastFiveWith(user), out);
    }
  }
예제 #10
0
  protected String getSampleName(String strDir, String strTray) {
    String strSampleName = "";
    String strSample;
    int nTray = 0;
    try {
      nTray = Integer.parseInt(strTray);
    } catch (Exception e) {
    }

    if (nTray <= 0) return strSampleName;

    String cmd =
        "SELECT loc_,studystatus from study WHERE (autodir=\'"
            + strDir
            + "\') AND (hostname=\'"
            + getHost()
            + "\')";
    // NB: bArrSample[0] is not used; array implicitly initialized false
    boolean[] bArrSample = new boolean[nTray + 1];
    m_dbResult = null;

    try {
      m_dbResult = getdbmanager().executeQuery(cmd);
    } catch (Exception e) {
      return strSampleName;
    }
    if (m_dbResult == null) return strSampleName;

    try {
      while (m_dbResult.next()) {
        strSample = m_dbResult.getString(1);
        int nSample = 0;
        nSample = Integer.parseInt(strSample);
        try {
          bArrSample[nSample] = true;
        } catch (IndexOutOfBoundsException ioobe) {
          Messages.postDebug("getSampleName: index out of bounds: " + nSample);
        }
      }
      for (int i = 1; i < bArrSample.length; i++) {
        if (!bArrSample[i]) {
          strSampleName = String.valueOf(i);
          break;
        }
      }
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.writeStackTrace(e);
    }
    return strSampleName;
  }
예제 #11
0
    protected void writeAuditTrail(String strPath, String strUser, StringBuffer sbValues) {
      BufferedReader reader = WFileUtil.openReadFile(strPath);
      String strLine;
      ArrayList aListData = WUtil.strToAList(sbValues.toString(), false, "\n");
      StringBuffer sbData = sbValues;
      String strPnl = (this instanceof DisplayTemplate) ? "Data Template " : "Data Dir ";
      if (reader == null) {
        Messages.postDebug("Error opening file " + strPath);
        return;
      }

      try {
        while ((strLine = reader.readLine()) != null) {
          // if the line in the file is not in the arraylist,
          // then that line has been deleted
          if (!aListData.contains(strLine))
            WUserUtil.writeAuditTrail(new Date(), strUser, "Deleted " + strPnl + strLine);

          // remove the lines that are also in the file or those which
          // have been deleted.
          aListData.remove(strLine);
        }

        // Traverse through the remaining new lines in the arraylist,
        // and write it to the audit trail
        for (int i = 0; i < aListData.size(); i++) {
          strLine = (String) aListData.get(i);
          WUserUtil.writeAuditTrail(new Date(), strUser, "Added " + strPnl + strLine);
        }
        reader.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
예제 #12
0
 private void createResults_() {
   results = new LinkedList();
   String dateTime = dateFormatter2_.format(date);
   // Messages.debug(3, "Rag::createResults_ dateTime=%1", dateTime);
   String regExp = "HREF=\\/(rapp[\\/a-zA-Z0-9]*" + dateTime + "[a-zA-Z0-9_\\.]*)>";
   Messages.debug(3, "Rag::createResults_ regExp=%1", regExp);
   Regexp reg = Regexp.compile(regExp);
   // Messages.debug(3, "Rag::createResults_ compiled regexp");
   Result result;
   int pos = 0;
   while ((result = reg.searchForward(buffer_, pos, charsread_ - pos)) != null) {
     pos = result.getMatchEnd() + 1;
     Messages.debug(3, "Rag:: gotResult:" + result.getMatch(1));
     results.add(RESULT_ADDRESS_ + result.getMatch(1));
   }
 }
예제 #13
0
  protected String gettitle(String strFreq) {
    StringBuffer sbufTitle = new StringBuffer().append("VnmrJ  ");
    String strPath = FileUtil.openPath(FileUtil.SYS_VNMR + "/vnmrrev");
    BufferedReader reader = WFileUtil.openReadFile(strPath);
    String strLine;
    String strtype = "";
    if (reader == null) return sbufTitle.toString();

    try {
      while ((strLine = reader.readLine()) != null) {
        strtype = strLine;
      }
      strtype = strtype.trim();
      if (strtype.equals("merc")) strtype = "Mercury";
      else if (strtype.equals("mercvx")) strtype = "Mercury-Vx";
      else if (strtype.equals("mercplus")) strtype = "MERCURY plus";
      else if (strtype.equals("inova")) strtype = "INOVA";
      String strHostName = m_strHostname;
      if (strHostName == null) strHostName = "";
      sbufTitle.append("    ").append(strHostName);
      sbufTitle.append("    ").append(strtype);
      sbufTitle.append(" - ").append(strFreq);
      reader.close();
    } catch (Exception e) {
      // e.printStackTrace();
      Messages.logError(e.toString());
    }

    return sbufTitle.toString();
  }
예제 #14
0
 public void removeThread(WorkerThread thread) {
   threads.remove(thread);
   Logger.log(Level.DEBUG, Messages.getString("connection_closed", Settings.getLocale()));
   if (FancyFileServer.getGUI() != null) {
     FancyFileServer.getGUI().updateConnectionsCounter();
   }
 }
예제 #15
0
 public void addEotDatum(int nSteps) {
   m_eotCount += nSteps;
   Messages.postDebug("AllTuneAlgorithm", "Motor " + m_gmi + " EOT count=" + m_eotCount);
   if (Math.abs(m_eotCount) > 5) {
     setEot(m_eotCount);
   }
 }
예제 #16
0
 /**
  * Set flag indicating if this motor is at the end of it's travel. Typically called after making a
  * motion of "step" motor steps. A positive value of "step" indicates are at the positive EOT. A
  * negative value of "step" indicates are at the negative EOT. A zero value for "step" indicates
  * are not at EOT.
  *
  * @param step Flag that we are at EOT for steps in this direction.
  */
 public void setEot(int step) {
   m_eotStatus = step;
   if (step == 0) {
     m_eotCount = 0;
   } else if (DebugOutput.isSetFor("TuneAlgorithm")) {
     Messages.postDebug("Setting EOT=" + step + " on motor " + m_gmi);
   }
 }
예제 #17
0
 private boolean readPersistence(boolean sysFlag) {
   String path = getPersistenceFilePath(sysFlag);
   boolean ok = readPersistence(path);
   if (!ok && sysFlag) {
     Messages.postError("Cannot read persistence file: " + path);
   }
   return ok;
 }
예제 #18
0
 private void setCaretValue(String s) {
   try {
     int i = Integer.parseInt(s);
     setCaretValue(i);
   } catch (NumberFormatException e) {
     Messages.writeStackTrace(e);
     // System.out.println("invalid caret position "+caretValue);
   }
 }
예제 #19
0
 public void setVisible(boolean bShow, String title) {
   if (bShow) {
     String strDir = "";
     String strFreq = "";
     String strTraynum = "";
     m_strHelpFile = getHelpFile(title);
     String strSampleName = getSampleName(title);
     String frameBounds = getFrameBounds(title);
     StringTokenizer tok = new QuotedStringTokenizer(title);
     if (tok.hasMoreTokens()) strDir = tok.nextToken();
     if (tok.hasMoreTokens()) strFreq = tok.nextToken();
     if (tok.hasMoreTokens()) strTraynum = tok.nextToken();
     else {
       try {
         Integer.parseInt(strDir);
         // if strdir is number, then strdir is empty, and the
         // strfreq is the number
         strTraynum = strFreq;
         strFreq = strDir;
         strDir = "";
       } catch (Exception e) {
       }
     }
     try {
       setTitle(gettitle(strFreq));
       m_lblSampleName.setText("3");
       boolean bVast = isVast(strTraynum);
       CardLayout layout = (CardLayout) m_pnlSampleName.getLayout();
       if (!bVast) {
         if (strSampleName == null) {
           strSampleName = getSampleName(strDir, strTraynum);
         }
         m_lblSampleName.setText(strSampleName);
         layout.show(m_pnlSampleName, OTHER);
       } else {
         m_strDir = strDir;
         setTrays();
         layout.show(m_pnlSampleName, VAST);
         m_trayTimer.start();
       }
       boolean bSample = bVast || !strSampleName.trim().equals("");
       m_pnlSampleName.setVisible(bSample);
       m_lblLogin.setForeground(getBackground());
       m_lblLogin.setVisible(false);
       m_passwordField.setText("");
       m_passwordField.setCaretPosition(0);
     } catch (Exception e) {
       Messages.writeStackTrace(e);
     }
     setBounds(frameBounds);
     ExpPanel exp = Util.getActiveView();
     if (exp != null) exp.waitLogin(true);
   }
   writePersistence();
   setVisible(bShow);
 }
예제 #20
0
 /** Add an additional binary type */
 public void accept(
     IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction) {
   if (this.options.verbose) {
     this.out.println(
         Messages.bind(Messages.compilation_loadBinary, new String(binaryType.getName())));
     //			new Exception("TRACE BINARY").printStackTrace(System.out);
     //		    System.out.println();
   }
   this.lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding, accessRestriction);
 }
예제 #21
0
  /** replaces the font (PS name) if necessary and returns the new name */
  private static String replacePSFont(String font) {
    String result;

    result = font;

    // do we have to replace it? -> same style, size
    if (m_PSFontReplacement.containsKey(font)) {
      result = m_PSFontReplacement.get(font).toString();
      if (DEBUG)
        System.out.println(
            Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_First")
                + font
                + Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_Second")
                + result
                + Messages.getInstance().getString("PostscriptGraphics_ReplacePSFont_Text_Third"));
    }

    return result;
  }
예제 #22
0
  /**
   * Add the initial set of compilation units into the loop -> build compilation unit declarations,
   * their bindings and record their results.
   */
  protected void internalBeginToCompile(ICompilationUnit[] sourceUnits, int maxUnits) {
    if (!this.useSingleThread && maxUnits >= ReadManager.THRESHOLD)
      this.parser.readManager = new ReadManager(sourceUnits, maxUnits);

    // Switch the current policy and compilation result for this unit to the requested one.
    for (int i = 0; i < maxUnits; i++) {
      CompilationResult unitResult = null;
      try {
        if (this.options.verbose) {
          this.out.println(
              Messages.bind(
                  Messages.compilation_request,
                  new String[] {
                    String.valueOf(i + 1),
                    String.valueOf(maxUnits),
                    new String(sourceUnits[i].getFileName())
                  }));
        }
        // diet parsing for large collection of units
        CompilationUnitDeclaration parsedUnit;
        unitResult =
            new CompilationResult(sourceUnits[i], i, maxUnits, this.options.maxProblemsPerUnit);
        long parseStart = System.currentTimeMillis();
        if (this.totalUnits < this.parseThreshold) {
          parsedUnit = this.parser.parse(sourceUnits[i], unitResult);
        } else {
          parsedUnit = this.parser.dietParse(sourceUnits[i], unitResult);
        }
        long resolveStart = System.currentTimeMillis();
        this.stats.parseTime += resolveStart - parseStart;
        // initial type binding creation
        this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
        this.stats.resolveTime += System.currentTimeMillis() - resolveStart;
        addCompilationUnit(sourceUnits[i], parsedUnit);
        ImportReference currentPackage = parsedUnit.currentPackage;
        if (currentPackage != null) {
          unitResult.recordPackageName(currentPackage.tokens);
        }
        // } catch (AbortCompilationUnit e) {
        //	requestor.acceptResult(unitResult.tagAsAccepted());
      } catch (AbortCompilation a) {
        // best effort to find a way for reporting this problem:
        if (a.compilationResult == null) a.compilationResult = unitResult;
        throw a;
      } finally {
        sourceUnits[i] = null; // no longer hold onto the unit
      }
    }
    if (this.parser.readManager != null) {
      this.parser.readManager.shutdown();
      this.parser.readManager = null;
    }
    // binding resolution
    this.lookupEnvironment.completeTypeBindings();
  }
예제 #23
0
 /** Add additional source types */
 public void accept(
     ISourceType[] sourceTypes,
     PackageBinding packageBinding,
     AccessRestriction accessRestriction) {
   this.problemReporter.abortDueToInternalError(
       Messages.bind(
           Messages.abort_againstSourceModel,
           new String[] {
             String.valueOf(sourceTypes[0].getName()), String.valueOf(sourceTypes[0].getFileName())
           }));
 }
예제 #24
0
파일: Job.java 프로젝트: neo2buha/jenkins
  private HealthReport getBuildStabilityHealthReport() {
    // we can give a simple view of build health from the last five builds
    int failCount = 0;
    int totalCount = 0;
    RunT i = getLastBuild();
    while (totalCount < 5 && i != null) {
      switch (i.getIconColor()) {
        case BLUE:
        case YELLOW:
          // failCount stays the same
          totalCount++;
          break;
        case RED:
          failCount++;
          totalCount++;
          break;

        default:
          // do nothing as these are inconclusive statuses
          break;
      }
      i = i.getPreviousBuild();
    }
    if (totalCount > 0) {
      int score = (int) ((100.0 * (totalCount - failCount)) / totalCount);

      Localizable description;
      if (failCount == 0) {
        description = Messages._Job_NoRecentBuildFailed();
      } else if (totalCount == failCount) {
        // this should catch the case where totalCount == 1
        // as failCount must be between 0 and totalCount
        // and we can't get here if failCount == 0
        description = Messages._Job_AllRecentBuildFailed();
      } else {
        description = Messages._Job_NOfMFailed(failCount, totalCount);
      }
      return new HealthReport(score, Messages._Job_BuildStability(description));
    }
    return null;
  }
예제 #25
0
 public Object next() {
   if (resultIterator_ != null) {
     String tmp = null;
     try {
       // parse date and further information from result
       tmp = (String) resultIterator_.next();
       Messages.debug(-1, "Rag::next before parse");
       Date d = dateFormatter3_.parse(tmp.substring(59, 73));
       Messages.debug(-1, "Rag::next after parse");
       h_.put("URL", tmp);
       tmp = RandomDate.format(d);
       h_.put("U_DATETIME", EtcUtil.makeURLish(tmp));
       h_.put("DATETIME", tmp);
     } catch (Exception e) {
       Messages.debug(
           -1, "Rag::exception during parsing of s=%1 (%2)", tmp.substring(59, 73), e);
       // e.printStackTrace();
     }
   }
   return h_;
 }
예제 #26
0
  public void runImpl() throws Exception {
    // create the URL corresponding to the date

    URL u = new URL(ADDRESS_ + dateFormatter1_.format(date));
    Messages.debug(3, "Rag::runImpl - reading data from URL=%1", u);
    // fetch the page into the buffer
    buffer_ = new char[BUF_SIZE_];
    Reader r = new InputStreamReader(u.openStream());
    int size = 1;
    charsread_ = 0;
    while (charsread_ < BUF_SIZE_ && size > 0) {
      size = r.read(buffer_, 0, BUF_SIZE_ - charsread_);
      if (size != -1) charsread_ += size;
      Messages.debug(3, "Rag::runImpl - read %1 chars", String.valueOf(size));
      if (!r.ready()) break;
    }
    r.close();
    Messages.debug(3, "Rag::runImpl - buffer=\"%1\"XXXXXXX", new String(buffer_, 0, charsread_));
    // create the results
    createResults_();
  }
예제 #27
0
  /*
   * Compiler crash recovery in case of unexpected runtime exceptions
   */
  protected void handleInternalException(
      Throwable internalException, CompilationUnitDeclaration unit, CompilationResult result) {

    if (result == null && unit != null) {
      result = unit.compilationResult; // current unit being processed ?
    }
    // Lookup environment may be in middle of connecting types
    if (result == null && this.lookupEnvironment.unitBeingCompleted != null) {
      result = this.lookupEnvironment.unitBeingCompleted.compilationResult;
    }
    if (result == null) {
      synchronized (this) {
        if (this.unitsToProcess != null && this.totalUnits > 0)
          result = this.unitsToProcess[this.totalUnits - 1].compilationResult;
      }
    }
    // last unit in beginToCompile ?

    boolean needToPrint = true;
    if (result != null) {
      /* create and record a compilation problem */
      // only keep leading portion of the trace
      String[] pbArguments =
          new String[] {
            Messages.bind(
                Messages.compilation_internalError, Util.getExceptionSummary(internalException)),
          };

      result.record(
          this.problemReporter.createProblem(
              result.getFileName(),
              IProblem.Unclassified,
              pbArguments,
              pbArguments,
              Error, // severity
              0, // source start
              0, // source end
              0, // line number
              0), // column number
          unit);

      /* hand back the compilation result */
      if (!result.hasBeenAccepted) {
        this.requestor.acceptResult(result.tagAsAccepted());
        needToPrint = false;
      }
    }
    if (needToPrint) {
      /* dump a stack trace to the console */
      internalException.printStackTrace();
    }
  }
예제 #28
0
 public void save() {
   getPreferenceStore();
   if (preferenceStore.needsSaving() || needsSaving) {
     try {
       if (defaultSet != -1) preferenceStore.setValue(KEY_DEFAULT, defaultSet > 0);
       preferenceStore.save();
       needsSaving = false;
     } catch (IOException e) {
       String message = Messages.bind(Messages.ScopeSet_errorSaving, name);
       HelpUIPlugin.logError(message, e);
     }
   }
 }
예제 #29
0
 public FormValidation doCheckIncludes(
     @AncestorInPath AbstractProject project, @QueryParameter String value)
     throws IOException, InterruptedException {
   if (project.getSomeWorkspace() != null) {
     String msg = project.getSomeWorkspace().validateAntFileMask(value);
     if (msg != null) {
       return FormValidation.error(msg);
     }
     return FormValidation.ok();
   } else {
     return FormValidation.warning(Messages.noworkspace());
   }
 }
예제 #30
0
 /**
  * Update the motor position, based on increment from last position. Also updates the backlash
  * tracking.
  *
  * @param n The number of steps from the previous position.
  */
 public void incrementPosition(int n) {
   Messages.postDebug("BacklashTracking", "incrementPosition(" + n + ") called");
   if (n != 0) {
     m_position += n;
     if (!isSameDirection(n)) {
       m_distanceThisDirection = 0; // Reversed direction
     }
     m_distanceThisDirection += Math.abs(n);
     if (n != 0) {
       m_lastStep = n;
     }
   }
 }