Package org.netbeans.api.progress

Examples of org.netbeans.api.progress.ProgressHandle


    public void cleanAllCache(final Project project) {
        requestProcessor.post(new Runnable() {

            @Override
            public void run() {
                ProgressHandle progressHandle = ProgressHandleFactory.createHandle(NbBundle.getMessage(IvyFacade.class, "CleanResolution"));
                progressHandle.start();
                try {
                    Ivy ivy = getIvy(project);
                    cleanAllRepositoryCache(ivy, progressHandle);
                    cleanResolutionCache(ivy, progressHandle);
                } catch (IvyException ex) {
                    Exceptions.printStackTrace(ex);
                }
                progressHandle.finish();
            }
        });
    }
View Full Code Here


        private MapperRunnable(DatabaseConnection dbconn) {
            this.dbconn =  dbconn;
        }
        @Override
        public void run() {
            ProgressHandle p = ProgressHandleFactory.createHandle("Processing...");
            p.start();
            Connection connection = dbconn.getJDBCConnection();
            ColorMapper.setConnection(connection);
            MapColorsEvent e = new MapColorsEvent(this, ColorQueryPanel.getQueries());
            ColorQueryPanel.fireMapColors(e);
            p.finish();
        }
View Full Code Here

        }

        public void compile() throws Exception {
            LifecycleManager.getDefault().saveAll();
            for (CoffeeScriptDataObject coffeeFile : data) {
                ProgressHandle handle = ProgressHandleFactory.createHandle("Compiling " + coffeeFile.getPrimaryFile().getNameExt(), this);
                try {
                    handle.start();
                    CoffeeScriptCompiler.CompilerResult result = CoffeeScriptSettings.getCompiler().compile(coffeeFile.getPrimaryFile().asText(), bare);
                    if (result == null) {
                        return; // Canceled
                    }
                    if (result.getJs() != null) {
                        CoffeeScriptUtils.writeJSForCoffeeScriptFile(result.getJs(), coffeeFile.getPrimaryFile());
                    }
                    handleResult(result);
                } finally {
                    handle.finish();
                }
            }
        }
View Full Code Here

            try {
                final XMLReader reader = XMLUtil.createXMLReader();
                final FileInputStream inputStream = new FileInputStream(file);
                final InputSource is = new InputSource(inputStream);

                final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName());
                final int basis = 1000;
                handle.start(basis);
                final int start = inputStream.available();

                final XMLParser.ParseMonitor parseMonitor = new XMLParser.ParseMonitor() {

                    public void setProgress(double d) {
                        try {
                            int curAvailable = inputStream.available();
                            int prog = (int) (basis * (double) (start - curAvailable) / (double) start);
                            handle.progress(prog);
                        } catch (IOException ex) {
                        }
                    }

                    public void setState(String state) {
                        setProgress(0.0);
                        handle.progress(state);
                    }
                };
                final Parser parser = new Parser();
                final OutlineTopComponent component = OutlineTopComponent.findInstance();

                component.requestActive();

                RequestProcessor.getDefault().post(new Runnable() {

                    public void run() {
                        GraphDocument document = null;
                        try {
                            document = parser.parse(reader, is, parseMonitor);
                            parseMonitor.setState("Finishing");
                            component.getDocument().addGraphDocument(document);
                        } catch (SAXException ex) {
                            String s = "Exception during parsing the XML file, could not load document!";
                            if (ex instanceof XMLParser.MissingAttributeException) {
                                XMLParser.MissingAttributeException e = (XMLParser.MissingAttributeException) ex;
                                s += "\nMissing attribute \"" + e.getAttributeName() + "\"";
                            }
                            ex.printStackTrace();
                            NotifyDescriptor d = new NotifyDescriptor.Message(s, NotifyDescriptor.ERROR_MESSAGE);
                            DialogDisplayer.getDefault().notify(d);
                        }
                        handle.finish();
                    }
                });

            } catch (SAXException ex) {
                ex.printStackTrace();
View Full Code Here

        if (DialogDisplayer.getDefault().notify( dd ).equals( DialogDescriptor.OK_OPTION )) {
            final Set<String> libraries = new HashSet<>( pn.getLibraries() );
            if (libraries.size() > 0) {
                final String npmPath = Npm.getDefault().exe( );
                final AtomicInteger jobs = new AtomicInteger();
                final ProgressHandle h = ProgressHandleFactory.createHandle( NbBundle.getMessage( AddLibraryAction.class,
                        "MSG_RUNNING_NPM", libraries.size(), project.getDisplayName() ) ); //NOI18N
                RequestProcessor.getDefault().post( new Runnable() {
                    @Override
                    public void run () {
                        final int totalLibs = libraries.size();
                        try {
                            h.start( totalLibs * 2 );
                            for (String lib : libraries) {
                                int job = jobs.incrementAndGet();
                                ExternalProcessBuilder epb = new ExternalProcessBuilder( npmPath ) //NOI18N
                                        .addArgument( "install" ) //NOI18N
                                        .addArgument( lib )
                                        .workingDirectory( FileUtil.toFile( project.getProjectDirectory() ) );
                                final String libraryName = lib;
                                ExecutionDescriptor des = new ExecutionDescriptor().controllable( true ).showProgress( true ).showSuspended( true ).frontWindow( false ).controllable( true ).optionsPath( "Advanced/Node" ).postExecution( new Runnable() {
                                    @Override
                                    public void run () {
                                        try {
                                            int ct = jobs.decrementAndGet();
                                            if (ct == 0) {
                                                try {
                                                    project.getProjectDirectory().refresh();
                                                    FileObject fo = project.getProjectDirectory().getFileObject( NodeJSProjectFactory.NODE_MODULES_FOLDER );
                                                    if (fo != null && fo.isValid()) {
                                                        fo.refresh();
                                                    }
                                                    root.updateChildren();
                                                } finally {
                                                    h.finish();
                                                }
                                            } else {
                                                h.progress( NbBundle.getMessage( ProjectNodeKey.class,
                                                        "PROGRESS_LIBS_REMAINING", totalLibs - ct ), totalLibs - ct ); //NOI18N
                                                h.setDisplayName( libraryName );
                                            }
                                        } finally {
                                            List<LibraryAndVersion> l = libraries( project );
                                            updateDependencies( project, l);
                                        }
                                    }
                                } ).charset( Charset.forName( "UTF-8" ) ).frontWindowOnError( true ); //NOI18N
                                ExecutionService service = ExecutionService.newService( epb, des, lib );
                                service.run();
                            }
                        } finally {
                            h.finish();
                        }
                    }
                } );
            }
        }
View Full Code Here

            return result == null ? false : result;
        }

        @Override
        public synchronized void run () {
            ProgressHandle handle = ProgressHandleFactory.createHandle(
                    NbBundle.getMessage( NodeJSProject.class, "RUNNING_NPM_INSTALL", getName() ) ); //NOI18N
            handle.start();
            try {
                String result = Npm.getDefault().run( FileUtil.toFile( getProjectDirectory() ), "install" ); //NOI18N
                InputOutput io = IOProvider.getDefault().getIO( getName() + " - npm install", true ); //NOI18N
                io.select();
                io.getOut().print( result );
                io.getOut().close();
                checkTask.schedule( 3000 );
            } finally {
                handle.finish();
            }
        }
View Full Code Here

            @Override
            public void run () {
                if (!EventQueue.isDispatchThread()) {
                    downloading = true;
                    ProgressHandle h = ProgressHandleFactory.createHandle( NbBundle.getMessage( NodePanel.class, "DOWNLOADING_SOURCES" ) );
                    h.start( 4 );
                    h.progress( "which git" );
                    System.out.println( "run which git" );
                    ProcessBuilder b = new ProcessBuilder( "which", "git" );
                    try {
                        Process p = b.start();
                        InputStream in = p.getInputStream();
                        int ix = p.waitFor();
                        if (ix != 0) {
                            return;
                        }
                        h.progress( 1 );
                        ByteArrayOutputStream out = new ByteArrayOutputStream();
                        FileUtil.copy( in, out );
                        String s = new String( out.toByteArray() ).trim();
                        System.out.println( "Git is " + s );
                        dest = new File( targetDir, name );
                        if (!dest.exists()) {
                            dest.mkdirs();
                        }
                        System.out.println( "Dest is " + dest );
                        ProcessBuilder b2 = new ProcessBuilder( s, "clone", "https://github.com/joyent/node.git", name );
                        b2.directory( dest.getParentFile() );
                        System.out.println( "starting git clone in " + dest.getAbsolutePath() );
                        Process p2 = b2.start();
                        h.progress( "git clone ", 2 );
                        Thread.sleep( 1000 );
                        h.progress( 3 );
                        EventQueue.invokeLater( this );
                        int code = p2.waitFor();
                        System.out.println( "git exit code was " + code );
                    } catch ( InterruptedException ex ) {
                        Exceptions.printStackTrace( ex );
                    } catch ( IOException ex ) {
                        Exceptions.printStackTrace( ex );
                    } finally {
                        h.finish();
                        downloading = false;
                        EventQueue.invokeLater( this );
                    }
                } else {
                    switch ( eqCount++ ) {
View Full Code Here

            this.handleRef = new AtomicReference<>(null);
            this.cancelController = cancelController;
        }

        public void start(String displayName) {
            ProgressHandle newHandle = ProgressHandleFactory.createHandle(displayName, new Cancellable() {
                @Override
                public boolean cancel() {
                    cancelController.cancel();
                    return true;
                }
            });

            newHandle.start();
            newHandle.suspend("");

            ProgressHandle prevHandle = handleRef.getAndSet(newHandle);
            if (prevHandle != null) {
                prevHandle.finish();
            }
        }
View Full Code Here

        public ProgressHandle getCurrentHandle() {
            return handleRef.get();
        }

        public void finish() {
            ProgressHandle prevRef = handleRef.getAndSet(null);
            if (prevRef != null) {
                prevRef.finish();
            }
        }
View Full Code Here

        if (JOptionPane.showOptionDialog(null, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, answers, answers[1]) != 0) {
            return;
        }

        CancellationSource cancel = Cancellation.createCancellationSource();
        final ProgressHandle progress = createProgress(cancel.getController());

        progress.start();
        PROJECT_PROCESSOR.execute(cancel.getToken(), new CancelableTask() {
            @Override
            public void execute(CancellationToken cancelToken) {
                doRemoveProject(cancelToken);
            }
        }, new CleanupTask() {
            @Override
            public void cleanup(boolean canceled, Throwable error) throws Exception {
                NbTaskExecutors.defaultCleanup(canceled, error);
                progress.finish();
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.netbeans.api.progress.ProgressHandle

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.