Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.SubProgressMonitor


        try {

            ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();

            // first search the local catalog.
            List<IResolve> matches = catalog.find(url, new SubProgressMonitor(progressMonitor, 2));

            for (IResolve resolve : matches) {
                if (resolve instanceof ExpectedService) {
                    // found the resource now we have to search it for the
                    // resource we want
                    if (searchServiceForResource(new SubProgressMonitor(progressMonitor, 2), addPosition, map,
                            (IService) resolve))
                        return;
                } else if (resolve instanceof ExpectedGeoResource) {
                    // yay we found the resource this is too easy:)

                    ApplicationGIS.addLayersToMap(map, Collections.singletonList((IGeoResource) resolve), addPosition);
                    return;
                }
            }

            // usually only returns 1 service but it may be that multiple
            // Services know how to interpret the URL
            List<IService> services = CatalogPlugin.getDefault().getServiceFactory().createService(url);
            IService found = null;
            progressMonitor.worked(1);

            // find the service you want
            for (IService service : services) {
                // determine if the service is the type you are expecting;
                if (service instanceof ExpectedService) {
                    found = service;
                    break;
                }
            }

            catalog.add(found);
            searchServiceForResource(new SubProgressMonitor(progressMonitor, 2), addPosition, map, found);

        } finally {
            progressMonitor.done();
        }
View Full Code Here


           
            if( monitor == null ) monitor = new NullProgressMonitor();               
            try {
                monitor.beginTask("Get Feature", 100 );
               
                ILayer layer = layerProvider.get( new SubProgressMonitor(monitor, 25) );
                FeatureSource<SimpleFeatureType, SimpleFeature> source = layer
                        .getResource(FeatureSource.class, new SubProgressMonitor(monitor, 25));
               
                FeatureIterator<SimpleFeature> iter = source.getFeatures(fidFilter).features();
                monitor.worked(25);
                try {
                    if (iter.hasNext()) {
View Full Code Here

        try {
            epsgLogger.setLevel(Level.SEVERE);
   
            unpackEPSGDatabase();
           
            searchEPSGProperties(bundle, new SubProgressMonitor(monitor, 20));
   
            loadEPSG(bundle, new SubProgressMonitor(monitor, 60));
   
            monitor.subTask(Messages.OPERATIONS_DEFINITIONS);
            load(ReferencingFactoryFinder.getCoordinateOperationAuthorityFactories(null));
            monitor.worked(2);
   
View Full Code Here

        if (monitor == null) {
            monitor = new NullProgressMonitor();
        }

        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
        subMonitor.beginTask(LaunchingMessages.StandardVMDebugger_Launching_VM____1, 4);
        subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Finding_free_socket____2);

        int port= SocketUtil.findFreePort();
        if (port == -1) {
            abort(LaunchingMessages.StandardVMDebugger_Could_not_find_a_free_socket_for_the_debugger_1, null, IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE);
        }

        subMonitor.worked(1);

        // check for cancellation
        if (monitor.isCanceled()) {
            return;
        }

        subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Constructing_command_line____3);

        String program= constructProgramString(config);

        List arguments= new ArrayList(12);

        arguments.add(program);

        // VM args are the first thing after the java program so that users can specify
        // options like '-client' & '-server' which are required to be the first options
        String[] allVMArgs = combineVmArgs(config, fVMInstance);
        addArguments(allVMArgs, arguments);
        arguments.add("-D"+MVELDebugHandler.DEBUG_LAUNCH_KEY+"=true");
       
        addBootClassPathArguments(arguments, config);

        String[] cp= config.getClassPath();
        if (cp.length > 0) {
            arguments.add("-classpath"); //$NON-NLS-1$
            arguments.add(convertClassPath(cp));
        }
        double version = getJavaVersion();
        if (version < 1.5) {
            arguments.add("-Xdebug"); //$NON-NLS-1$
            arguments.add("-Xnoagent"); //$NON-NLS-1$
        }

        //check if java 1.4 or greater
        if (version < 1.4) {
            arguments.add("-Djava.compiler=NONE"); //$NON-NLS-1$
        }
        if (version < 1.5) {
            arguments.add("-Xrunjdwp:transport=dt_socket,suspend=y,address=localhost:" + port); //$NON-NLS-1$
        } else {
            arguments.add("-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:" + port); //$NON-NLS-1$
        }

        arguments.add(config.getClassToLaunch());
        addArguments(config.getProgramArguments(), arguments);
       
        String[] cmdLine= new String[arguments.size()];
        arguments.toArray(cmdLine);

        String[] envp= config.getEnvironment();

        // check for cancellation
        if (monitor.isCanceled()) {
            return;
        }

        subMonitor.worked(1);
        subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Starting_virtual_machine____4);

        ListeningConnector connector= getConnector();
        if (connector == null) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_find_an_appropriate_debug_connector_2, null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE);
        }
        Map map= connector.defaultArguments();

        specifyArguments(map, port);
        Process p= null;
        try {
            try {
                // check for cancellation
                if (monitor.isCanceled()) {
                    return;
                }

                connector.startListening(map);

                File workingDir = getWorkingDir(config);
                p = exec(cmdLine, workingDir, envp);
                if (p == null) {
                    return;
                }

                // check for cancellation
                if (monitor.isCanceled()) {
                    p.destroy();
                    return;
                }
                java.util.Date date= new java.util.Date();
                Timestamp ts = new Timestamp(date.getTime());
                String format= LaunchingMessages.StandardVMRunner__0____1___2;
            String label = NLS.bind(format, new String[] { cmdLine[0], ts.toString() });
                IProcess process= newProcess(launch, p, label, getDefaultProcessMap());
                process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLineInternal(cmdLine));
                subMonitor.worked(1);
                subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Establishing_debug_connection____5);
                boolean retry= false;
                do  {
                    try {

                        ConnectRunnable runnable = new ConnectRunnable(connector, map);
                        Thread connectThread = new Thread(runnable, "Listening Connector"); //$NON-NLS-1$
                        connectThread.setDaemon(true);
                        connectThread.start();
                        while (connectThread.isAlive()) {
                            if (monitor.isCanceled()) {
                                connector.stopListening(map);
                                p.destroy();
                                return;
                            }
                            try {
                                p.exitValue();
                                // process has terminated - stop waiting for a connection
                                try {
                                    connector.stopListening(map);
                                } catch (IOException e) {
                                    // expected
                                }
                                checkErrorMessage(process);
                            } catch (IllegalThreadStateException e) {
                                // expected while process is alive
                            }
                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException e) {
                            }
                        }

                        Exception ex = runnable.getException();
                        if (ex instanceof IllegalConnectorArgumentsException)                         {
                            throw (IllegalConnectorArgumentsException)ex;
                        }
                        if (ex instanceof InterruptedIOException) {
                            throw (InterruptedIOException)ex;
                        }
                        if (ex instanceof IOException) {
                            throw (IOException)ex;
                        }

                        VirtualMachine vm= runnable.getVirtualMachine();
                        if (vm != null) {
                            DroolsDebugModel.newDebugTarget(launch, vm, renderDebugTarget(config.getClassToLaunch(), port), process, true, false, config.isResumeOnStartup());
                            subMonitor.worked(1);
                            subMonitor.done();
                        }
                        return;
                    } catch (InterruptedIOException e) {
                        checkErrorMessage(process);
View Full Code Here

    private void createProject(IProjectDescription description,
            IProject projectHandle, IProgressMonitor monitor)
            throws CoreException, OperationCanceledException {
        try {
            monitor.beginTask("", 2000);
            projectHandle.create(description, new SubProgressMonitor(monitor,
                    1000));
            if (monitor.isCanceled()) {
                throw new OperationCanceledException();
            }
            projectHandle.open(IResource.BACKGROUND_REFRESH,
                new SubProgressMonitor(monitor, 1000));
        } finally {
            monitor.done();
        }
    }
View Full Code Here

    public void connect(Map<String, String> arguments, IProgressMonitor monitor, ILaunch launch) throws CoreException {
        if (monitor == null) {
            monitor = new NullProgressMonitor();
        }
       
        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
        subMonitor.beginTask(LaunchingMessages.SocketAttachConnector_Connecting____1, 2);
        subMonitor.subTask(LaunchingMessages.SocketAttachConnector_Configuring_connection____1);
       
        AttachingConnector connector= getAttachingConnector();
        String portNumberString = arguments.get("port"); //$NON-NLS-1$
        if (portNumberString == null) {
            abort(LaunchingMessages.SocketAttachConnector_Port_unspecified_for_remote_connection__2, null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_PORT);
        }
        String host = arguments.get("hostname"); //$NON-NLS-1$
        if (host == null) {
            abort(LaunchingMessages.SocketAttachConnector_Hostname_unspecified_for_remote_connection__4, null, IJavaLaunchConfigurationConstants.ERR_UNSPECIFIED_HOSTNAME);
        }
        Map<String, Connector.Argument> map= connector.defaultArguments();
       
        Connector.Argument param= map.get("hostname"); //$NON-NLS-1$
        param.setValue(host);
        param= map.get("port"); //$NON-NLS-1$
        param.setValue(portNumberString);
       
        String timeoutString = arguments.get("timeout"); //$NON-NLS-1$
        if (timeoutString != null) {
            param= map.get("timeout"); //$NON-NLS-1$
            param.setValue(timeoutString);
        }
       
        ILaunchConfiguration configuration = launch.getLaunchConfiguration();
        boolean allowTerminate = false;
        if (configuration != null) {
            allowTerminate = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, false);
        }
        subMonitor.worked(1);
        subMonitor.subTask(LaunchingMessages.SocketAttachConnector_Establishing_connection____2);
        try {
            VirtualMachine vm = connector.attach(map);
            String vmLabel = constructVMLabel(vm, host, portNumberString, configuration);
            IDebugTarget debugTarget= DroolsDebugModel.newDebugTarget(launch, vm, vmLabel, null, allowTerminate, true);
            launch.addDebugTarget(debugTarget);
            subMonitor.worked(1);
            subMonitor.done();
        } catch (TimeoutException e) {
            abort(LaunchingMessages.SocketAttachConnector_0, e, IJavaLaunchConfigurationConstants.ERR_REMOTE_VM_CONNECTION_FAILED);
        } catch (UnknownHostException e) {
            abort(NLS.bind(LaunchingMessages.SocketAttachConnector_Failed_to_connect_to_remote_VM_because_of_unknown_host____0___1, new String[]{host}), e, IJavaLaunchConfigurationConstants.ERR_REMOTE_VM_CONNECTION_FAILED);
        } catch (ConnectException e) {
View Full Code Here

        if (monitor == null) {
            monitor = new NullProgressMonitor();
        }

        IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
        subMonitor.beginTask(LaunchingMessages.StandardVMDebugger_Launching_VM____1, 4);
        subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Finding_free_socket____2);

        int port= SocketUtil.findFreePort();
        if (port == -1) {
            abort(LaunchingMessages.StandardVMDebugger_Could_not_find_a_free_socket_for_the_debugger_1, null, IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE);
        }

        subMonitor.worked(1);

        // check for cancellation
        if (monitor.isCanceled()) {
            return;
        }

        subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Constructing_command_line____3);

        String program= constructProgramString(config);

        List<String> arguments= new ArrayList<String>(12);

        arguments.add(program);

        // VM args are the first thing after the java program so that users can specify
        // options like '-client' & '-server' which are required to be the first options
        String[] allVMArgs = combineVmArgs(config, fVMInstance);
        addArguments(allVMArgs, arguments);
        arguments.add("-D"+MVELDebugHandler.DEBUG_LAUNCH_KEY+"=true");
       
        addBootClassPathArguments(arguments, config);

        String[] cp= config.getClassPath();
        if (cp.length > 0) {
            arguments.add("-classpath"); //$NON-NLS-1$
            arguments.add(convertClassPath(cp));
        }
        double version = getJavaVersion();
        if (version < 1.5) {
            arguments.add("-Xdebug"); //$NON-NLS-1$
            arguments.add("-Xnoagent"); //$NON-NLS-1$
        }

        //check if java 1.4 or greater
        if (version < 1.4) {
            arguments.add("-Djava.compiler=NONE"); //$NON-NLS-1$
        }
        if (version < 1.5) {
            arguments.add("-Xrunjdwp:transport=dt_socket,suspend=y,address=localhost:" + port); //$NON-NLS-1$
        } else {
            arguments.add("-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:" + port); //$NON-NLS-1$
        }

        arguments.add(config.getClassToLaunch());
        addArguments(config.getProgramArguments(), arguments);
       
        String[] cmdLine= new String[arguments.size()];
        arguments.toArray(cmdLine);

        String[] envp= config.getEnvironment();

        // check for cancellation
        if (monitor.isCanceled()) {
            return;
        }

        subMonitor.worked(1);
        subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Starting_virtual_machine____4);

        ListeningConnector connector= getConnector();
        if (connector == null) {
            abort(LaunchingMessages.StandardVMDebugger_Couldn__t_find_an_appropriate_debug_connector_2, null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE);
        }
        Map<String, Argument> map= connector.defaultArguments();

        specifyArguments(map, port);
        Process p= null;
        try {
            try {
                // check for cancellation
                if (monitor.isCanceled()) {
                    return;
                }

                connector.startListening(map);

                File workingDir = getWorkingDir(config);
                p = exec(cmdLine, workingDir, envp);
                if (p == null) {
                    return;
                }

                // check for cancellation
                if (monitor.isCanceled()) {
                    p.destroy();
                    return;
                }
                java.util.Date date= new java.util.Date();
                Timestamp ts = new Timestamp(date.getTime());
                String format= LaunchingMessages.StandardVMRunner__0____1___2;
            String label = NLS.bind(format, new String[] { cmdLine[0], ts.toString() });
                IProcess process= newProcess(launch, p, label, getDefaultProcessMap());
                process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLineInternal(cmdLine));
                subMonitor.worked(1);
                subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Establishing_debug_connection____5);
                boolean retry= false;
                do  {
                    try {

                        ConnectRunnable runnable = new ConnectRunnable(connector, map);
                        Thread connectThread = new Thread(runnable, "Listening Connector"); //$NON-NLS-1$
                        connectThread.setDaemon(true);
                        connectThread.start();
                        while (connectThread.isAlive()) {
                            if (monitor.isCanceled()) {
                                connector.stopListening(map);
                                p.destroy();
                                return;
                            }
                            try {
                                p.exitValue();
                                // process has terminated - stop waiting for a connection
                                try {
                                    connector.stopListening(map);
                                } catch (IOException e) {
                                    // expected
                                }
                                checkErrorMessage(process);
                            } catch (IllegalThreadStateException e) {
                                // expected while process is alive
                            }
                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException e) {
                            }
                        }

                        Exception ex = runnable.getException();
                        if (ex instanceof IllegalConnectorArgumentsException)                         {
                            throw (IllegalConnectorArgumentsException)ex;
                        }
                        if (ex instanceof InterruptedIOException) {
                            throw (InterruptedIOException)ex;
                        }
                        if (ex instanceof IOException) {
                            throw (IOException)ex;
                        }

                        VirtualMachine vm= runnable.getVirtualMachine();
                        if (vm != null) {
                            DroolsDebugModel.newDebugTarget(launch, vm, renderDebugTarget(config.getClassToLaunch(), port), process, true, false, config.isResumeOnStartup());
                            subMonitor.worked(1);
                            subMonitor.done();
                        }
                        return;
                    } catch (InterruptedIOException e) {
                        checkErrorMessage(process);
View Full Code Here

    private void createProject(IProjectDescription description,
            IProject projectHandle, IProgressMonitor monitor)
            throws CoreException, OperationCanceledException {
        try {
            monitor.beginTask("", 2000);
            projectHandle.create(description, new SubProgressMonitor(monitor,
                    1000));
            if (monitor.isCanceled()) {
                throw new OperationCanceledException();
            }
            projectHandle.open(IResource.BACKGROUND_REFRESH,
                new SubProgressMonitor(monitor, 1000));
        } finally {
            monitor.done();
        }
    }
View Full Code Here

      } else {

        lastCompletedFilter = null;
        lastCompletedResult = null;

        SubProgressMonitor subMonitor = null;
        if (monitor != null) {
          monitor
              .beginTask(
                  WorkbenchMessages.FilteredItemsSelectionDialog_searchJob_taskName,
                  100);
          subMonitor = new SubProgressMonitor(monitor, 95);

        }

        fillContentProvider(contentProvider, itemsFilter, subMonitor);
View Full Code Here

      }

      // the TableViewer's root (the input) is treated as parent

      lastFilteredItems = Arrays.asList(getFilteredItems(list.getInput(),
          monitor != null ? new SubProgressMonitor(monitor, 100)
              : null));

      if (reset || (monitor != null && monitor.isCanceled())) {
        if (monitor != null)
          monitor.done();
View Full Code Here

TOP

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

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.