Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.SubMonitor


                "Synchronizing invitation",
                subMonitor.newChild(25, SubMonitor.SUPPRESS_ALL_LABELS));
        }

        try {
            SubMonitor archiveMonitor = subMonitor.newChild(50,
                SubMonitor.SUPPRESS_ALL_LABELS);

            List<File> archivesToSend = new LinkedList<File>();

            for (Map.Entry<String, List<IPath>> entry : projectFilesToSend
View Full Code Here


  }

  private void buildProject(IProject p, IProgressMonitor monitor, String mode) throws CoreException{
    int work = 100;

    SubMonitor subM = SubMonitor.convert(monitor, 100);
    subM.setTaskName("Building project " + p.getName());

    IProjectDescription description = p.getDescription();

    IProject[] referencedProjects = description.getReferencedProjects();
    int len = referencedProjects.length;
    if(len > 0){
      int sub_work = (work / 2) / len;
      for (int i = 0; i < referencedProjects.length; i++){
        buildProject(referencedProjects[i], new SubProgressMonitor(subM, sub_work), mode);
        subM.worked(sub_work);
      }
      work /= 2;
    }

    ICommand xvrBuilder = XVRUtils.getXVRBuilderCommand(p);
    Map<String, String> args = XVRUtils.getBuilderArgs(p);
    args.put(XVRConstants.BUILD_MODE, mode);
    xvrBuilder.setArguments(args);

    p.build(IncrementalProjectBuilder.FULL_BUILD, xvrBuilder.getBuilderName(), xvrBuilder.getArguments(), subM.newChild(work));
    subM.worked(work);
  }
View Full Code Here

  @Override
  public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
    int work = 100;

    SubMonitor subM = SubMonitor.convert(monitor, work);
    subM.setTaskName("Validating precondition");

    subM.subTask("Checking active project");
    updateActiveProject();
    if(this.active_prj == null || !this.active_prj.exists()) {
      XVRUtils.displayError("No project selected to be launched.");
      if(mode.equals(ILaunchManager.DEBUG_MODE))
        XVRUtils.setDebugSession(false);
      subM.worked(work);
      return false;
    }
    subM.worked(work/2);

    return this.checkProject(this.active_prj, subM.newChild(work/2));
  }
View Full Code Here

  }

  private boolean checkProject(IProject p, IProgressMonitor monitor) throws CoreException{
    int work = 100;

    SubMonitor subM = SubMonitor.convert(monitor, work);
    subM.setTaskName("Checking project " + p.getName());

    IProjectDescription description = p.getDescription();
    IProject[] referencedProjects = description.getReferencedProjects();
    int len = referencedProjects.length;
    if(len > 0){
      int sub_work = (work / 2) / len;
      for (int i = 0; i < referencedProjects.length; i++){
        if(!checkProject(referencedProjects[i], new SubProgressMonitor(subM, sub_work))){
          subM.worked(work);
          return false;
        }
        subM.worked(sub_work);
      }
      work /= 2;
    }
    subM.worked(work);
    String main = XVRUtils.getBuilderPreferece(XVRProjectSupport.ARG_MAIN_KEY, p);
    //String main = (String) p.getSessionProperty(XVRBuilder.KEY_MAIN_FILE);
    if(main == null){
      XVRUtils.displayError("Main program not specified in project : " + p.getName());
      return false;
View Full Code Here

     *
     * @sarosThread must be called by the extensionDownloadThreadPool
     */
    protected void processTransferObjectToPacket(
        TransferDescription description, IncomingTransferObject transferObject) {
        SubMonitor monitor = SubMonitor.convert(new NullProgressMonitor());

        String name = description.type;
        String namespace = description.namespace;
        // IQ provider?

View Full Code Here

                try {
                    dialog.run(true, true, new IRunnableWithProgress() {
                        public void run(IProgressMonitor monitor)
                            throws InterruptedException {

                            SubMonitor progress = SubMonitor.convert(monitor);
                            progress
                                .beginTask(
                                    Messages.ConsistencyAction_progress_perform_recovery,
                                    100);
                            watchdogClient.runRecovery(progress.newChild(100));
                            monitor.done();
                        }
                    });
                } catch (InvocationTargetException e) {
                    log.error("Exception not expected here.", e); //$NON-NLS-1$
View Full Code Here

            this.fileToSend = fileToSend;
        }

        @Override
        protected IStatus run(IProgressMonitor ipmonitor) {
            SubMonitor monitor = SubMonitor.convert(ipmonitor);
            monitor.beginTask(Messages.SendFileAction_monitor_set_up_session_text, 101);

            setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);

            log.info("Asking " + user + " to accept our transfer."); //$NON-NLS-1$ //$NON-NLS-2$
            monitor.subTask(MessageFormat.format(Messages.SendFileAction_monitor_notifying_text,
                user.getHumanReadableName()));
            try {
                setStreamSession(streamServiceManager.createSession(
                    sendFileService, user,
                    FileDescription.fromFile(fileToSend), null));
                monitor.worked(1);
            } catch (RemoteCancellationException e) {
                errorPopup(getName(), Messages.SendFileAction_error_file_transfer_rejected_text, e,
                    monitor);
                return Status.CANCEL_STATUS;
            } catch (ConnectionException e) {
                errorPopup(getName(), Messages.SendFileAction_error_no_connection_establish_text, e,
                    monitor);
                return Status.CANCEL_STATUS;
            } catch (TimeoutException e) {
                errorPopup(getName(), Messages.SendFileAction_error_timed_out_text,
                    e, monitor);
                return Status.CANCEL_STATUS;
            } catch (ExecutionException e) {
                monitor.subTask(MessageFormat.format(Messages.SendFileAction_unexpected_error,
                    e.getMessage()));
                log.error("Unexpected error: ", e); //$NON-NLS-1$
                return new Status(IStatus.ERROR, Saros.SAROS,
                    Messages.SendFileAction_status_could_not_create_session_text, e);
            } catch (InterruptedException e) {
                return Status.CANCEL_STATUS;
            }

            monitor.setTaskName(Messages.SendFileAction_monitor_sending_text);

            try {
                send(getStreamSession(), fileToSend,
                    monitor.newChild(100, SubMonitor.SUPPRESS_SETTASKNAME));

            } catch (InterruptedIOException e) {
                monitor.subTask(Messages.SendFileAction_monitor_canceled_text);
                return Status.CANCEL_STATUS;
            } catch (IOException e) {
                if (streamException == null) {
                    // plain IOE
                    log.error("Error while sending file: ", e); //$NON-NLS-1$
                    return new Status(IStatus.ERROR, Saros.SAROS,
                        "Error while sending file", e); //$NON-NLS-1$
                } else {
                    // IOE because stream is down
                    if (streamException instanceof ReceiverGoneException) {
                        monitor.subTask(Messages.SendFileAction_monitor_receiver_left_during_transfer_text);
                        return Status.CANCEL_STATUS;
                    }
                    if (streamException instanceof ConnectionException) {
                        monitor.subTask(Messages.SendFileAction_monitor_lost_connection_text);
                        return Status.CANCEL_STATUS;
                    }
                    log.error("Unexpected error: ", streamException); //$NON-NLS-1$
                    return new Status(IStatus.ERROR, Saros.SAROS,
                        Messages.SendFileAction_status_unexpected_error, streamException);
                }
            } catch (RemoteCancellationException e) {
                monitor.subTask(Messages.SendFileAction_monitor_canceled_text);
                return Status.CANCEL_STATUS;
            } catch (SarosCancellationException e) {
                monitor.subTask(Messages.SendFileAction_monitor_canceled_text);
                return Status.CANCEL_STATUS;
            } finally {
                readyToStop.countDown();
                monitor.done();
            }

            monitor.setTaskName(sendSuccessfully ? Messages.SendFileAction_monitor_successful_sent_text
                : Messages.SendFileAction_monitor_not_sent_whole_file_text);
            return sendSuccessfully ? Status.OK_STATUS : Status.CANCEL_STATUS;
        }
View Full Code Here

            setStreamSession(session);
        }

        @Override
        protected IStatus run(IProgressMonitor ipmonitor) {
            SubMonitor monitor = SubMonitor.convert(ipmonitor);
            setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);

            try {
                if (getStreamSession().getInitiationDescription() instanceof FileDescription) {
                    fileDescription = (FileDescription) getStreamSession()
                        .getInitiationDescription();
                } else {
                    log.error("Got no filedescription!"); //$NON-NLS-1$
                    return new Status(IStatus.ERROR, Saros.SAROS,
                        Messages.SendFileAction_status_cannot_receive_file_text);
                }
                setName(MessageFormat.format(Messages.SendFileAction_status_receiving_text,
                    fileDescription.name, getStreamSession().getRemoteJID()));
                monitor.beginTask(
                    Messages.SendFileAction_monitor_choose_location_text, 102);

                File file;
                try {
                    file = saveFile(fileDescription.name,
                        monitor.newChild(1, SubMonitor.SUPPRESS_SETTASKNAME));
                } catch (SarosCancellationException e) {
                    monitor.subTask(Messages.SendFileAction_monitor_canceled_text);
                    return Status.CANCEL_STATUS;
                }

                monitor.setTaskName(Messages.SendFileAction_monitor_receiving_text);

                FileOutputStream fileOutputStream;
                try {
                    monitor.subTask(Messages.SendFileAction_monitor_opening_text);
                    fileOutputStream = new FileOutputStream(file);
                    monitor.worked(1);
                } catch (FileNotFoundException e) {
                    errorPopup(Messages.SendFileAction_error_cannot_open_file_title,
                        Messages.SendFileAction_error_cannot_open_file_message,
                        e, monitor);
                    return new Status(IStatus.ERROR, Saros.SAROS,
                        Messages.SendFileAction_status_cannot_open_file, e);
                }

                try {
                    receive(getStreamSession(), fileOutputStream,
                        monitor.newChild(100, SubMonitor.SUPPRESS_SETTASKNAME));
                } catch (RemoteCancellationException e) {
                    monitor.subTask(Messages.SendFileAction_monitor_canceled_text);
                    return Status.CANCEL_STATUS;
                } catch (IOException e) {
                    if (stopped) {
                        // interrupted IO
                        monitor.subTask(Messages.SendFileAction_monitor_canceled_text);
                        return Status.CANCEL_STATUS;
                    }
                    if (streamException == null) {
                        // plain IOE
                        log.error("Error while receiving file: ", e); //$NON-NLS-1$
                        return new Status(IStatus.ERROR, Saros.SAROS,
                            Messages.SendFileAction_error_receiving_file_text, e);
                    } else {
                        // IOE because stream is down
                        if (streamException instanceof ReceiverGoneException) {
                            monitor.subTask(Messages.SendFileAction_monitor_receiver_left_during_transfer_text);
                            return Status.CANCEL_STATUS;
                        }
                        if (streamException instanceof ConnectionException) {
                            monitor.subTask(Messages.SendFileAction_monitor_lost_connection_text);
                            return Status.CANCEL_STATUS;
                        }
                        log.error("Unexpected error: ", streamException); //$NON-NLS-1$
                        return new Status(IStatus.ERROR, Saros.SAROS,
                            Messages.SendFileAction_status_unexpected_error_text, streamException);
                    }
                } catch (SarosCancellationException e) {
                    monitor.subTask(Messages.SendFileAction_monitor_canceled_text);
                    return Status.CANCEL_STATUS;
                }

            } finally {
                if (!stopped && streamException == null)
                    getStreamSession().stopSession();
                readyToStop.countDown();
                monitor.done();
            }

            monitor
                .setTaskName(receivedSuccessfully ? Messages.SendFileAction_monitor_successful_received_file_text
                    : Messages.SendFileAction_monitor_could_not_receive_whole_file_text);
            return receivedSuccessfully ? Status.OK_STATUS
                : Status.CANCEL_STATUS;
        }
View Full Code Here

  private boolean compile(String mode, IProgressMonitor monitor) throws CoreException{
    if(!this.initialized)
      throw new CoreException(new Status(Status.ERROR, XVRPlugin.PLUGIN_ID, "The builder has not been properly initialized"));

    final IProject prj = getProject();
    SubMonitor buildMonitor = SubMonitor.convert(monitor, "Building project " + prj.getName(), 50);
   
    //Save all changes
    buildMonitor.subTask("Saving editors");
    Display.getDefault().syncExec(new Runnable() { // save all editors needs to be called by the ui thread!
      @Override
      public void run() {
        IDE.saveAllEditors(new IResource[]{prj}, !XVRUtils.getBooleanPreference(PreferenceConstants.GEN_AUTO_SAVE_ON_BUILD));
      }
    });
   
    buildMonitor.worked(30);
    buildMonitor.subTask("compiling");

    List<String> compilerArgs = new ArrayList<String>();

    compilerArgs.add(this.compiler_path);

    //Add main source file
    compilerArgs.add(this.main_file.replace("\\", "/"));
   
    if(mode != null && mode.equals(ILaunchManager.DEBUG_MODE))
      compilerArgs.add("-G");
   
    //adds first the include directories specified by the user
    if(this.include_dirs != null && !this.include_dirs.isEmpty()){
      compilerArgs.add("-I");
      compilerArgs.add(this.include_dirs);
    }
   
    //then the default one.
    compilerArgs.add("-I");
    compilerArgs.add(this.include_path);

    compilerArgs.add("-A");
   
    //aggiunto parametro -p nel compilatore per definire dove volgiamo che sia salvato il risultato della compilazione
    //adesso devo dare la possibilita di definire una directory in cui mettere i file compilati e poi fare in modo che i template generino sia src che bin(che eventualmente nascondo oppure mostro anche bin, asm e dbg)
    /*compilerArgs.add("-p");
    compilerArgs.add("bin/prova.bin");*/

    String[] commandLine = (String[]) compilerArgs.toArray(new String[compilerArgs.size()]);
    ProcessBuilder builder = new ProcessBuilder(commandLine);
    builder.directory( new File(prj.getLocation().toString()));
    builder.redirectErrorStream(true);
    final Process compilerProcess;
    //ILaunch l = XVRUtils.getXVRLaunh();
   
    buildMonitor.worked(10);
    try {
      compilerProcess = builder.start();
    } catch (IOException e1) {
      e1.printStackTrace();
      buildMonitor.done();
      throw new CoreException(new ResourceStatus(ResourceStatus.BUILD_FAILED, "Compilation of " + prj.getName() + " failed due to the following exception: " + e1.getMessage()));
    }
    CompilerConsoleHandler.dumpBuildMessages(compilerProcess.getInputStream());
   
    try {
      compilerProcess.waitFor();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    finally{
      buildMonitor.worked(60);
      buildMonitor.done();
    }
   
    if(compilerProcess.exitValue() != 0)
      //throw new CoreException(new Status(Status.ERROR, XVRPlugin.PLUGIN_ID, "Compilation of " + prj.getName() + "failed and returns with code : " + compilerProcess.exitValue()));
      throw new CoreException(new ResourceStatus(ResourceStatus.BUILD_FAILED, "Compilation of " + prj.getName() + " failed and returns with code : " + compilerProcess.exitValue()));
View Full Code Here

      fAnalyzer.performFullAnalysis(theJavaProject, subMonitor.newChild(1));
    }
  }

  private void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) throws CoreException {
    SubMonitor subMonitor = SubMonitor.convert(monitor);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.core.runtime.SubMonitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.