Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.IProgressMonitor


    @Test
    public void testFilterNONE() throws Exception {
        SelectFeaturesInFilterCommand command = new SelectFeaturesInFilterCommand(handler.getEditBlackboard(), handler.getEditLayer(), Filter.INCLUDE);
       
        command.setMap(handler.getContext().getMap());
        IProgressMonitor nullProgressMonitor=new NullProgressMonitor();
        command.run(nullProgressMonitor);
       
        assertEquals(6, handler.getEditBlackboard().getGeoms().size());
        boolean found = false;
        for( EditGeom geom : handler.getEditBlackboard().getGeoms() ) {
View Full Code Here


    }

    /** Will cancel any outstanding search */
    synchronized void stopSearch(){       
        if( searchMonitor != null ){
            IProgressMonitor cancelMonitor = searchMonitor;
           
            searchMonitor = null;
            cancelMonitor.setCanceled( true );           
        }       
    }
View Full Code Here

    @Override
    public Map<String, Serializable> createConnectionParameters( Object context) {
        Map<String, Serializable> params=null;
       
        IProgressMonitor monitor=new NullProgressMonitor();
        try {
            MemoryServiceExtensionImpl ext = new MemoryServiceExtensionImpl();
            URL id = new URL("http://localhost/scratch"); //$NON-NLS-1$
            params = ext.createParams(id);
            IService service = ext.createService(id, params);
            DataStore ds = service.resolve(DataStore.class, monitor);
            int i=0;
            String typename="New_Type_"; //$NON-NLS-1$
            List<String> typenames = Arrays.asList(ds.getTypeNames());
            while( typenames.contains(typename+i)){
                i++;
            }
            SimpleFeatureTypeBuilder build = new SimpleFeatureTypeBuilder();
            build.setName(typename+i);
            build.setNamespaceURI( "http://udig.refractions.net");
            build.setAbstract(false);
            build.add(Messages.NewServiceConnectionFactory_defaultGeom,com.vividsolutions.jts.geom.Geometry.class);
           
            SimpleFeatureType schema = build.buildFeatureType();
           
            ds.createSchema( schema ); //$NON-NLS-1$
        } catch (Exception e) {
            CatalogUIPlugin.log("Error creating MemoryDatastore or feature type", e); //$NON-NLS-1$
            return null;
        }finally{
            monitor.done();
        }
        return params;
    }
View Full Code Here

     * @throws InterruptedException
     */
    public static void runBlockingOperation( final IRunnableWithProgress runnable,
            final IProgressMonitor monitor2 ) throws InvocationTargetException, InterruptedException {

        final IProgressMonitor monitor=monitor2==null?new NullProgressMonitor():monitor2;
        final InterruptedException[] interruptedException = new InterruptedException[1];
        final InvocationTargetException[] invocationTargetException = new InvocationTargetException[1];
        Display d = Display.getCurrent();
        if (d == null)
            d = Display.getDefault();
        final Display display = d;
        final AtomicBoolean done = new AtomicBoolean();
        final Object mutex=new Object();
        done.set(false);

        Future<Object> future = executor.submit(new Callable<Object>(){
            @SuppressWarnings("unused")
            Exception e = new Exception("For debugging"); //$NON-NLS-1$
            public Object call() throws Exception {
                try {
                    runnable.run(new OffThreadProgressMonitor(monitor != null
                            ? monitor
                            : ProgressManager.instance().get(), display));
                } catch (InvocationTargetException ite) {
                    invocationTargetException[0] = ite;
                } catch (InterruptedException ie) {
                    interruptedException[0] = ie;
                } finally {
                    done.set(true);
                    synchronized (mutex) {
                        mutex.notify();
                    }
                }
                return null;
            }

        });
        while( !monitor.isCanceled() && !done.get() && !Thread.interrupted() ) {
            Thread.yield();
            if (Display.getCurrent() == null) {
                wait(mutex, 200);
            } else {
                try {
                    if (!d.readAndDispatch()) {
                        wait(mutex, 200);
                    }
                } catch (Exception e) {
                    UiPlugin.log("Error occurred while waiting for an operation to complete", e); //$NON-NLS-1$
                }
            }
        }
        if (monitor.isCanceled()) {
            future.cancel(true);
        }

        if (interruptedException[0] != null)
            throw interruptedException[0];
View Full Code Here

                    }

                    monitor.beginTask(Messages.ShutdownTaskList_shutDown, totalsteps);

                    for( PostTask task : postShutdownTasks ) {
                        IProgressMonitor subMonitor = new ProgressMonitorTaskNamer(monitor,
                                task.steps);
                        try {
                            task.task.postShutdown(subMonitor, workbench);
                        } catch (Throwable t) {
                            task.task.handlePostShutdownException(t);
                        } finally {
                            subMonitor.done();
                        }
                    }
                }
               
            });
View Full Code Here

            dialog.run(true, forced, new IRunnableWithProgress(){

                public void run( IProgressMonitor monitor2 ) throws InvocationTargetException,
                        InterruptedException {
                   
                    IProgressMonitor monitor=new OffThreadProgressMonitor(monitor2, display);
                   
                    int totalsteps = 0;
                    for( PreTask task : preShutdownTasks ) {
                        try {
                            task.steps = task.task.getProgressMonitorSteps();
                            totalsteps += task.steps;
                        } catch (Throwable e) {
                            UiPlugin.log("error calling getProgressMonitorSteps() on " + task.task, e); //$NON-NLS-1$
                        }
                    }
                    monitor.beginTask(Messages.ShutdownTaskList_shutDown,
                            totalsteps);

                    for( PreTask task : preShutdownTasks ) {
                        IProgressMonitor subMonitor = new ProgressMonitorTaskNamer(monitor, task.steps);
                        boolean result;
                        try {
                            result = task.task.preShutdown(subMonitor, workbench, forced);
                        } catch (Throwable t) {
                            result = task.task.handlePreShutdownException(t, forced);
                        }finally{
                            subMonitor.done();
                        }
                        if (!forced) {
                            if (monitor.isCanceled() || !result)
                                allowShutdown[0] = false;
                            if (monitor.isCanceled())
View Full Code Here

        return null;
    }

    public <T extends IResolve> T getById( Class<T> type, final ID id, IProgressMonitor monitor ) {

        IProgressMonitor monitor2 = monitor;;
        if (monitor2 == null)
            monitor2 = new NullProgressMonitor();
        if (id == null)
            return null;

        if (IService.class.isAssignableFrom(type)) {
            monitor2.beginTask(Messages.CatalogImpl_monitorTask, 1);
            IService service = getServiceById(id);
            monitor2.done();
            return type.cast(service);
        }

        URL url = id.toURL();
        if (IResolve.class.isAssignableFrom(type)) {
View Full Code Here

     * @param roughMatch an ID consists of a URL and other info like a typeQualifier if roughMatch
     *        is true then the extra information is ignored during search
     */
    public IResolve getChildById( IResolve handle, final ID id, boolean roughMatch,
            IProgressMonitor monitor ) {
        IProgressMonitor monitor2 = monitor;
        if (monitor2 == null)
            monitor2 = new NullProgressMonitor();

        if (roughMatch) {
            URL url1 = id.toURL();
            URL url2 = handle.getIdentifier();
            if (new ID(url1).equals(new ID(url2))) {
                return handle;
            }
        } else {
            if (id.equals(handle.getID())) {
                return handle;
            }
        }
        try {
            List< ? extends IResolve> children = handle.members(monitor2);
            if (children == null || children.isEmpty())
                return null;

            monitor2.beginTask(Messages.CatalogImpl_monitorTask2, children.size());
            for( IResolve child : children ) {
                IResolve found = getChildById(child, id, roughMatch, null);
                if (found != null)
                    return found;
            }
View Full Code Here

            if( Display.getCurrent() != null ){
                throw new IllegalStateException("search called from display thread");
            }
        }
       
        IProgressMonitor monitor = monitor2;
        if (monitor == null)
            monitor = new NullProgressMonitor();
        if ((pattern == null || "".equals(pattern.trim())) //$NON-NLS-1$
                && (bbox == null || bbox.isNull())) {
            return new LinkedList<IResolve>();
        }
        List<IResolve> result = new LinkedList<IResolve>();
        AST ast = ASTFactory.parse(pattern);
        if (ast == null) {
            return result;
        }
        HashSet<IService> searchScope = new HashSet<IService>();
        searchScope.addAll(this.services);
        try {
            monitor.beginTask(Messages.CatalogImpl_finding, searchScope.size() * 10);
            SERVICE: for( IService service : searchScope ) {
                ID serviceID = service.getID();
                if (check(service, ast)) {
                    result.add(service);
                }
                //Iterator< ? extends IGeoResource> resources;
                SubProgressMonitor submonitor = new SubProgressMonitor(monitor, 10);
                try {
                    List< ? extends IGeoResource> members = service.resources(submonitor);
                    if (members == null) {
                        continue SERVICE;
                    }
                    for( IGeoResource resource : members ) {
                        ID resoruceID = resource.getID();
                        try {
                            if (check(resource, ast, bbox)) {
                                result.add(resource);
                            }
                        } catch (Throwable t) {
                            CatalogPlugin.log("Could not search in resource:" + resoruceID, t);
                        }
                    }
                } catch (IOException e) {
                    CatalogPlugin.log("Could not search in service:" + serviceID, e);
                } finally {
                    submonitor.done();
                }
                Thread.yield(); // allow other threads to have a go... makes search view more responsive
            }
            return result;
        } finally {
            monitor.done();
        }
    }
View Full Code Here

     * @see org.locationtech.udig.catalog.ICatalog#resolve(java.lang.Class,
     *      org.eclipse.core.runtime.IProgressMonitor)
     * @SuppressWarnings(value={"unchecked" )
     */
    public <T> T resolve( Class<T> adaptee, IProgressMonitor monitor2 ) {
        IProgressMonitor monitor;
        if (monitor2 == null)
            monitor = new NullProgressMonitor();
        else
            monitor = monitor2;
        try {
            if (adaptee == null)
                return null;
            monitor.beginTask(Messages.CatalogImpl_resolving + adaptee.getSimpleName(), 2);
            monitor.worked(1);
            if (adaptee.isAssignableFrom(CatalogImpl.class))
                return adaptee.cast(this);
            if (adaptee.isAssignableFrom(CatalogInfoImpl.class))
                return adaptee.cast(metadata);
            if (adaptee.isAssignableFrom(services.getClass()))
                return adaptee.cast(services);
            if (adaptee.isAssignableFrom(List.class))
                return adaptee.cast(new LinkedList<IService>(services));
            if (adaptee.isAssignableFrom(catalogListeners.getClass()))
                return adaptee.cast(getListenersCopy());
        } finally {
            monitor.worked(1);
            monitor.done();
        }
        return null;
    }
View Full Code Here

TOP

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

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.