示例#1
0
 public static void main(String[] args) {
   ErrorReporter errorReporter = new ErrorReporter();
   Verify verify = new Verify(errorReporter);
   verify.run();
   errorReporter.printReport();
   System.exit(errorReporter.hasErrors() ? 1 : 0);
 }
 // Switch to an existing project. Note that this does not switch screens.
 // TODO(sharon): it might be better to throw an exception if the
 // project doesn't exist.
 private boolean switchToProject(long projectId, String projectName) {
   if (projectMap.containsKey(projectId)) {
     DesignProject project = projectMap.get(projectId);
     if (project == currentProject) {
       OdeLog.wlog("DesignToolbar: ignoring call to switchToProject for current project");
       return true;
     }
     pushedScreens.clear(); // Effectively switching applications clear stack of screens
     clearDropDownMenu(WIDGET_NAME_SCREENS_DROPDOWN);
     OdeLog.log(
         "DesignToolbar: switching to existing project " + projectName + " with id " + projectId);
     currentProject = projectMap.get(projectId);
     // TODO(sharon): add screens to drop-down menu in the right order
     for (Screen screen : currentProject.screens.values()) {
       addDropDownButtonItem(
           WIDGET_NAME_SCREENS_DROPDOWN,
           new ToolbarItem(
               screen.screenName,
               screen.screenName,
               new SwitchScreenAction(projectId, screen.screenName)));
     }
     projectNameLabel.setText(projectName);
   } else {
     ErrorReporter.reportError(
         "Design toolbar doesn't know about project " + projectName + " with id " + projectId);
     OdeLog.wlog(
         "Design toolbar doesn't know about project " + projectName + " with id " + projectId);
     return false;
   }
   return true;
 }
 public void warning(String message, String sourceURI, int line, String lineText, int lineOffset) {
   if (chainedReporter != null) {
     chainedReporter.warning(message, sourceURI, line, lineText, lineOffset);
   } else {
     // Do nothing
   }
 }
 public static void reportException(ErrorReporter er, RhinoException ex) {
   if (er instanceof ToolErrorReporter) {
     ((ToolErrorReporter) er).reportException(ex);
   } else {
     String msg = getExceptionMessage(ex);
     er.error(msg, ex.sourceName(), ex.lineNumber(), ex.lineSource(), ex.columnNumber());
   }
 }
 private void warn(String message, boolean showDebugString) {
   if (verbose) {
     if (showDebugString) {
       message = message + "\r\n" + getDebugString(10);
     }
     logger.warning(message, null, -1, null, -1);
   }
 }
 public void deadLetter(Long msgId) {
   try {
     channel.basicReject(msgId, false);
   } catch (Exception e) {
     logger.error("could not fail with dead-lettering (when configured) for msgId: " + msgId, e);
     reporter.reportError(e);
   }
 }
 public EvaluatorException runtimeError(
     String message, String sourceURI, int line, String lineText, int lineOffset) {
   if (chainedReporter != null) {
     return chainedReporter.runtimeError(message, sourceURI, line, lineText, lineOffset);
   } else {
     return new EvaluatorException(message, sourceURI, line, lineText, lineOffset);
   }
 }
 public void failWithRedelivery(Long msgId) {
   try {
     channel.basicReject(msgId, true);
   } catch (Exception e) {
     logger.error("could not fail with redelivery for msgId: " + msgId, e);
     reporter.reportError(e);
   }
 }
 public void ack(Long msgId) {
   try {
     channel.basicAck(msgId, false);
   } catch (Exception e) {
     logger.error("could not ack for msgId: " + msgId, e);
     reporter.reportError(e);
   }
 }
示例#10
0
 @Override
 public void execute() {
   List<Project> selectedProjects =
       ProjectListBox.getProjectListBox().getProjectList().getSelectedProjects();
   if (selectedProjects.size() == 1) {
     exportProject(selectedProjects.get(0));
   } else {
     // The user needs to select only one project.
     ErrorReporter.reportInfo(MESSAGES.wrongNumberProjectsSelected());
   }
 }
示例#11
0
 public void resolve(TranslationUnit unit) {
   typeLookup.fillTypeMap();
   for (TypeRef ref : typeLookup.getTypeRefs()) {
     Type foundType = typeLookup.lookup(ref, unit.getPackage());
     if (foundType == null) {
       errorReporter.reportError("Cannot resolve type reference '" + ref + "'");
       continue;
     }
     ref.applySerializrType(foundType);
   }
 }
 private void doSwitchScreen(long projectId, String screenName, View view) {
   if (!projectMap.containsKey(projectId)) {
     OdeLog.wlog(
         "DesignToolbar: no project with id "
             + projectId
             + ". Ignoring SwitchScreenAction.execute().");
     return;
   }
   DesignProject project = projectMap.get(projectId);
   if (currentProject != project) {
     // need to switch projects first. this will not switch screens.
     if (!switchToProject(projectId, project.name)) {
       return;
     }
     // currentProject == project now
   }
   String newScreenName = screenName;
   if (!currentProject.screens.containsKey(newScreenName)) {
     // Can't find the requested screen in this project. This shouldn't happen, but if it does
     // for some reason, try switching to Screen1 instead.
     OdeLog.wlog(
         "Trying to switch to non-existent screen "
             + newScreenName
             + " in project "
             + currentProject.name
             + ". Trying Screen1 instead.");
     if (currentProject.screens.containsKey(YoungAndroidSourceNode.SCREEN1_FORM_NAME)) {
       newScreenName = YoungAndroidSourceNode.SCREEN1_FORM_NAME;
     } else {
       // something went seriously wrong!
       ErrorReporter.reportError(
           "Something is wrong. Can't find Screen1 for project " + currentProject.name);
       return;
     }
   }
   currentView = view;
   Screen screen = currentProject.screens.get(newScreenName);
   ProjectEditor projectEditor = screen.formEditor.getProjectEditor();
   currentProject.setCurrentScreen(newScreenName);
   setDropDownButtonCaption(WIDGET_NAME_SCREENS_DROPDOWN, newScreenName);
   OdeLog.log("Setting currentScreen to " + newScreenName);
   if (currentView == View.FORM) {
     projectEditor.selectFileEditor(screen.formEditor);
     toggleEditor(false);
   } else { // must be View.BLOCKS
     projectEditor.selectFileEditor(screen.blocksEditor);
     toggleEditor(true);
   }
   // Inform the Blockly Panel which project/screen (aka form) we are working on
   BlocklyPanel.setCurrentForm(projectId + "_" + newScreenName);
   updateButtons();
 }
示例#13
0
 public Message nextMessage() {
   reinitIfNecessary();
   if (consumerTag == null || consumer == null) return Message.NONE;
   try {
     return Message.forDelivery(consumer.nextDelivery(MS_WAIT_FOR_MESSAGE));
   } catch (ShutdownSignalException sse) {
     reset();
     logger.error("shutdown signal received while attempting to get next message", sse);
     reporter.reportError(sse);
     return Message.NONE;
   } catch (InterruptedException ie) {
     /* nothing to do. timed out waiting for message */
     logger.debug("interruepted while waiting for message", ie);
     return Message.NONE;
   } catch (ConsumerCancelledException cce) {
     /* if the queue on the broker was deleted or node in the cluster containing the queue failed */
     reset();
     logger.error("consumer got cancelled while attempting to get next message", cce);
     reporter.reportError(cce);
     return Message.NONE;
   }
 }
示例#14
0
    @Override
    public void execute() {
      List<Project> selectedProjects =
          ProjectListBox.getProjectListBox().getProjectList().getSelectedProjects();
      if (selectedProjects.size() > 0) {
        // Show one confirmation window for selected projects.
        if (deleteConfirmation(selectedProjects)) {
          for (Project project : selectedProjects) {
            deleteProject(project);
          }
        }

      } else {
        // The user can select a project to resolve the
        // error.
        ErrorReporter.reportInfo(MESSAGES.noProjectSelectedForDelete());
      }
    }
示例#15
0
  public void open() {
    try {
      connection = createConnection();
      channel = connection.createChannel();
      if (prefetchCount > 0) {
        logger.info("setting basic.qos / prefetch count to " + prefetchCount + " for " + queueName);
        channel.basicQos(prefetchCount);
      }
      // run any declaration prior to queue consumption
      declarator.execute(channel);

      consumer = new QueueingConsumer(channel);
      consumerTag = channel.basicConsume(queueName, isAutoAcking(), consumer);
    } catch (Exception e) {
      reset();
      logger.error("could not open listener on queue " + queueName);
      reporter.reportError(e);
    }
  }
示例#16
0
 public void error(String message, String sourceURI, int line, String lineText, int lineOffset) {
   if (forEval) {
     // Assume error message strings that start with "TypeError: "
     // should become TypeError exceptions. A bit of a hack, but we
     // don't want to change the ErrorReporter interface.
     String error = "SyntaxError";
     final String TYPE_ERROR_NAME = "TypeError";
     final String DELIMETER = ": ";
     final String prefix = TYPE_ERROR_NAME + DELIMETER;
     if (message.startsWith(prefix)) {
       error = TYPE_ERROR_NAME;
       message = message.substring(prefix.length());
     }
     throw ScriptRuntime.constructError(error, message, sourceURI, line, lineText, lineOffset);
   }
   if (chainedReporter != null) {
     chainedReporter.error(message, sourceURI, line, lineText, lineOffset);
   } else {
     throw runtimeError(message, sourceURI, line, lineText, lineOffset);
   }
 }
 public void initialize() {
   String storageMode = this.appSettings.getString("storageMode", "");
   if (storageMode.equals("internal") || storageMode.equals(""))
     this.appdb = this.appcontext.openOrCreateDatabase("MobileOrg", 0, null);
   else if (storageMode.equals("sdcard")) {
     File sdcard = Environment.getExternalStorageDirectory();
     File morgDir = new File(sdcard, "mobileorg");
     if (!morgDir.exists()) {
       morgDir.mkdir();
     }
     File morgFile = new File(morgDir, "mobileorg.db");
     this.appdb = SQLiteDatabase.openOrCreateDatabase(morgFile, null);
     Log.d(LT, "Setting database path to " + morgFile.getAbsolutePath());
   } else {
     ErrorReporter.displayError(this.appcontext, r.getString(R.string.error_opening_database));
     return;
   }
   this.appdb.execSQL(
       "CREATE TABLE IF NOT EXISTS files"
           + " (file VARCHAR, name VARCHAR,"
           + " checksum VARCHAR);");
   this.lastStorageMode = storageMode;
 }
示例#18
0
  /**
   * Runs the server. The server will wait for some match info (which specifies the teams and set of
   * maps to run) and then begin running matches.
   */
  public void run() {
    int aWins = 0, bWins = 0;

    while (!matches.isEmpty()) {
      Match match = matches.peek();
      if (!finished.isEmpty())
        match.setInitialTeamMemory(finished.getLast().getComputedTeamMemory());

      try {
        debug("running match " + match);
        match.initialize();
        runMatch(match, proxyWriter);
        finished.add(match);
        matches.remove(match);

        if (match.getWinner() == Team.A) aWins++;
        else if (match.getWinner() == Team.B) bWins++;

        match.finish();

        // Allow best of three scrimmages -- single game scrims should still work fine
        // TODO:This "win mode" should probably be something from the database
        if (mode == Mode.TOURNAMENT || mode == Mode.SCRIMMAGE) {
          if (aWins == 2 || bWins == 2) break;
        }

      } catch (Exception e) {
        ErrorReporter.report(e);
        error("couldn't run match: ");

        this.state = State.ERROR;
      }
    }

    proxyWriter.terminate();
  }