Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.IProgressMonitor


  public void run(IProgressMonitor monitor) throws Exception {

    if (monitor == null) {
      monitor = new NullProgressMonitor();
    }
    IProgressMonitor prepMonitor = SubMonitor.convert(monitor, 80);
    prepMonitor.beginTask("Splitting features", 1); //$NON-NLS-1$

    LineString splitter = getSplittingLineInMapCRS(handler);
    assert splitter.getUserData() instanceof CoordinateReferenceSystem;

    FeatureCollection<SimpleFeatureType, SimpleFeature> featuresToSplit = getFeaturesToSplit(splitter);
    prepMonitor.worked(2);

    final List<UndoableMapCommand> undoableCommands = new ArrayList<UndoableMapCommand>();

    List<UndoableMapCommand> commands = buildCommandList(featuresToSplit, splitter);
    undoableCommands.addAll(commands);
    prepMonitor.worked(3);

    prepMonitor.done();

    if (undoableCommands.size() == 0) {
            ProjectPlugin.log("The split did not apply to any feature"); //$NON-NLS-1$
       
      throw new IllegalArgumentException(Messages.SplitFeaturesCommand_did_not_apply_to_any_feature);
    }
    IProgressMonitor splitMonitor = SubMonitor.convert(monitor, 20);
    composite = new UndoableComposite(undoableCommands);

    // cascade setMap on the aggregate commands
    composite.setMap(getMap());
    composite.run(splitMonitor);
View Full Code Here


  @Override
  public final void createPartControl(Composite parent) {
    editDomain = new MapEditDomain(null);
    try {
      IProgressMonitor monitor = getViewSite().getActionBars().getStatusLineManager().getProgressMonitor();
      viewer = new MapViewer(parent, SWT.DOUBLE_BUFFERED);
      List<IGeoResource> resources = new ArrayList<IGeoResource>();
      createResources(resources, monitor);
      IProject activeProject = ApplicationGIS.getActiveProject();
View Full Code Here

            final List<IGeoResource> resourceList = new ArrayList<IGeoResource>();

            final ICatalog connections = CatalogPlugin.getDefault().getLocalCatalog();

            try {
                IProgressMonitor monitor = new NullProgressMonitor();

                IRunnableWithProgress object = new IRunnableWithProgress() {
                    public void run(IProgressMonitor monitor) throws InvocationTargetException {
                        try {
                            List<IResolve> resources = connections.find(id.toURL(), monitor);
View Full Code Here

                    ProjectPackage.LAYER__GEO_RESOURCE, oldPreferredGeoResource, geoResource));
    }

    public <E> E getResource(Class<E> resourceType, IProgressMonitor monitor) throws IOException {

        IProgressMonitor monitor2 = monitor;
        if (monitor2 == null)
            monitor2 = ProgressManager.instance().get();
        try {
            for (IGeoResource georesource : getGeoResources()) {
                if (georesource.canResolve(resourceType)) {
                    return georesource.resolve(resourceType, monitor2);
                }
            }
            return null;
        } finally {
            monitor2.done();
        }
    }
View Full Code Here

     * @param obj2
     * @return true if same, otherwise false
     */
    private boolean isSameSelectionObj(Object obj1, Object obj2) {
       
        final IProgressMonitor monitor = new NullProgressMonitor();
       
        final IGeoResource resource1 = toGeoResource(obj1, monitor);
        final IGeoResource resource2 = toGeoResource(obj2, monitor);
        if ((resource1 != null && resource2 != null)
                && (resource1.getID().equals(resource2.getID()))) {
View Full Code Here

            CSV csv = resource.resolve(CSV.class, new SubProgressMonitor(monitor, 10) );
            reader = csv.reader();
           
            int nameIndex = csv.getHeader("name");

            IProgressMonitor drawMonitor = new SubProgressMonitor(monitor, 90);
            Coordinate worldLocation = new Coordinate();
           
            drawMonitor.beginTask("draw "+csv.toString(), csv.getSize());           
            String [] row;
            while ((row = reader.readNext()) != null) {
                Point point = csv.getPoint(row);
                Coordinate dataLocation = point.getCoordinate();
                try {
                    JTS.transform(dataLocation, worldLocation, dataToWorld);
                } catch (TransformException e) {
                    continue;
                }               
                if (bounds != null && !bounds.contains(worldLocation)) {
                    continue; // optimize!
                }               
                java.awt.Point p = getContext().worldToPixel(worldLocation);
                g.fillOval(p.x, p.y, 10, 10);
                String name = row[nameIndex];
                g.drawString(name, p.x + 15, p.y + 15);
                drawMonitor.worked(1);

                if (drawMonitor.isCanceled())
                    break;
            }
            drawMonitor.done();           
        } catch (IOException e) {
            throw new RenderException(e); // rethrow any exceptions encountered
        } catch (FactoryException e) {
            throw new RenderException(e); // rethrow any exceptions encountered
        } finally {
View Full Code Here

     *            
     * @return the map that was rendered.  It will not be saved or and is not part of any project.
     */
    public static IMap drawMap(final DrawMapParameter drawMapParams) throws RenderException {
        final DrawMapParameter params = new DrawMapParameter( drawMapParams );
        IProgressMonitor monitor = params.monitor;
       
        final Map map = (Map) EcoreUtil.copy((EObject) params.toDraw);
       
        map.getBlackboard().addAll(drawMapParams.toDraw.getBlackboard());
       
        for (int i = 0; i < map.getMapLayers().size(); i++) {
            ILayer source = params.toDraw.getMapLayers().get(i);
            Layer dest = map.getLayersInternal().get(i);
            dest.setFilter(source.getFilter());
            dest.getBlackboard().addAll(source.getBlackboard());
        }
       
        IRunnableWithProgress runnable = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                // Load IGeoResources using original map. The new map can't do this because it doesn't have a
                // Resource(file) and therefore can't resolve relative URIs
                List<ILayer> layers = drawMapParams.toDraw.getMapLayers();
                for (ILayer layer : layers) {
                    layer.getGeoResources();
                }
               
                Color background = (Color) map.getBlackboard().get(ProjectBlackboardConstants.MAP__BACKGROUND_COLOR);
                params.graphics.setBackground(background);
                if (!drawMapParams.transparent) {
                    params.graphics.clearRect(0, 0, params.destinationSize.width, params.destinationSize.height);
                }
                List<Layer> layersToRender = params.selectionStyle.handleSelection(map.getLayersInternal());
               
                ProjectUIPlugin
                        .trace(
                                ApplicationGIS.class,
                                "ApplicationGIS.drawMap() beginning rendering of map '" + map.getName() + "'", null); //$NON-NLS-1$ //$NON-NLS-2$

                ReferencedEnvelope bounds = (ReferencedEnvelope) params.toDraw.getViewportModel().getBounds();
                ReferencedEnvelope boundsCopy = new ReferencedEnvelope(bounds);
                RenderContext tools = configureMapForRendering(map, params.destinationSize, params.dpi, params.boundsStrategy, boundsCopy);
               
                RendererCreator decisive = new RendererCreatorImpl();
                decisive.setContext(tools);

                decisive.getLayers().addAll(layersToRender);

                SortedSet<RenderContext> sortedContexts = new TreeSet<RenderContext>(
                        decisive.getConfiguration());

                render(params, monitor, decisive, sortedContexts);

            }

            private void render(final DrawMapParameter params,
                    IProgressMonitor monitor, RendererCreator decisive,
                    SortedSet<RenderContext> sortedContexts)
                    throws InvocationTargetException {
               
                monitor.beginTask("Rendering map", sortedContexts.size());
                RenderContext mainContext = decisive.getContext();

                ILabelPainter labelPainter = mainContext.getLabelPainter();
                labelPainter.clear();
                labelPainter.start();
View Full Code Here

                for (ISearch search : catalogs) {
                    try {
                        monitor.subTask("Search "+search.getTitle() +" for "+searchText );
                        List<IResolve> searchResults = search.search(searchText, bounds, null);
                        monitor.worked(10);
                        IProgressMonitor searchMonitor = new SubProgressMonitor( monitor,10, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK );
                       
                        for (IResolve member : searchResults) {
                            if (member.canResolve(FeatureSource.class)) {
                                resolves.add(member);
                            }
View Full Code Here

        });
       
    }
   
    private void setPageInputAndEnablements() {
        final IProgressMonitor monitor = new NullProgressMonitor();
        final IGeoResource resource = (IGeoResource) getElement().getAdapter(IGeoResource.class);
        setShpPropertyParser(resource);
        setResourcePropsEnablements(resource, monitor);
        setFeaturePropsEnablements(resource, monitor);
        setHotlinkDescriptorParser(resource);
View Full Code Here

     * @param data
     * @throws IOException
     */
    @SuppressWarnings("unchecked")
    private void addToCatalog( File file, Data data ) throws IOException {
        IProgressMonitor monitor = ProgressManager.instance().get();

        // add the service to the catalog
        IServiceFactory sFactory = CatalogPlugin.getDefault().getServiceFactory();
        ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
        URL url = URLUtils.fileToURL(file);
        List<IService> services = sFactory.createService(url);
        monitor.beginTask("add to catalog", services.size() * 10);
        for( IService service : services ) {
            IService registeredService = catalog.add(service);
            SubProgressMonitor monitor2 = new SubProgressMonitor(monitor, 10);
            List<IGeoResource> contents = (List<IGeoResource>) registeredService.resources(monitor2);
            data.addNewResources( contents );
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.