Package com.intellij.openapi.progress

Examples of com.intellij.openapi.progress.ProgressIndicator


     * @return available plugins
     * @throws IOException if an error occurs
     */
    private PluginGoalContainer[] loadPlugins(final VirtualFile pPluginsCacheFile)
            throws IOException {
        final ProgressIndicator prg = IDEUtils.getProgressIndicator();
        if (prg != null) {
            prg.setIndeterminate(true);
            prg.setText("Discovering available plugins...");
            prg.start();
        }

        int counter = 0;
        try {
            if (pPluginsCacheFile == null || !pPluginsCacheFile.isValid() || !FileUtils.exists(
                    pPluginsCacheFile) || pPluginsCacheFile.isDirectory()) {
                if (prg != null) {
                    prg.setText("No available plugins found.");
                    prg.setFraction(1);
                }
                return new PluginGoalContainer[0];
            }

            final VirtualFile pluginsDir = pPluginsCacheFile.getParent();
            if (pluginsDir == null || !pluginsDir.isValid() || !FileUtils.exists(pluginsDir) || !pluginsDir.isDirectory()) {
                if (prg != null) {
                    prg.setText("No available plugins found.");
                    prg.setFraction(1);
                }
                return new PluginGoalContainer[0];
            }

            final Properties props = new Properties();
            final byte[] data = pPluginsCacheFile.contentsToByteArray();
            final ByteArrayInputStream stream = new ByteArrayInputStream(data);
            props.load(stream);

            if (prg != null) {
                prg.setText("Found " + props.size() + " plugins.");
                prg.setIndeterminate(false);
                prg.setFraction(0);
            }

            final Set<PluginGoalContainer> plugins = new HashSet<PluginGoalContainer>(30);
            final Set<Map.Entry<Object, Object>> entries = props.entrySet();

            final int pluginCount = entries.size();

            for (Map.Entry<Object, Object> entry : entries) {
                final String pluginName = entry.getValue().toString();
                final String artifactId = entry.getKey().toString();

                if (prg != null) {
                    prg.setText("Loading plugin '" + pluginName + "'");
                    prg.setFraction((double) counter / (double) pluginCount);
                    counter++;
                }

                final VirtualFile pluginDir = pluginsDir.findChild(artifactId);
                if (pluginDir == null || !pluginDir.isValid() || !FileUtils.exists(pluginDir) || !pluginDir.isDirectory()) {
                    if (prg != null)
                        prg.setText("Could not load plugin '" + pluginName + "'");
                    continue;
                }

                final PluginGoalContainer plugin = parsePlugin(pluginDir);
                if (plugin != null)
                    plugins.add(plugin);
            }

            return plugins.toArray(new PluginGoalContainer[plugins.size()]);
        }
        finally {
            if (prg != null) {
                prg.setText("Done - loaded " + counter + " plugin(s).");
                prg.setFraction(1);
            }
        }
    }
View Full Code Here


            download(pPomUrl, pRemoteRepo, pArtifact.getRelativePath(true));
        else {
            final ChildrenFetchService service = ChildrenFetchService.getInstance();
            final RepoPathElement elt = pArtifact.toRepoPathElement(pRemoteRepo);

            final ProgressIndicator prg = IDEUtils.getProgressIndicator();
            if (prg != null) {
                if (prg.isCanceled())
                    return;
                prg.setText2("Searching for children of '" + elt.getRelativeURIPath() + "'...");
            }
            final Future<RepoPathElement[]> result = service.fetch(elt);

            try {
                final RepoPathElement[] elements = result.get(30, TimeUnit.SECONDS);
                if (prg != null)
                    prg.setText2("Found " + elements.length + " artifacts under '" + elt.getRelativeURIPath() + "', downloading...");
                for (int i = 0; i < elements.length; i++) {
                    RepoPathElement element = elements[i];
                    if (prg != null) {
                        if (prg.isCanceled())
                            return;
                        prg.setText2("Download artifact " + (i + 1) + " out of " + elements.length + " for " + elt.getRelativeURIPath());
                    }

                    final Artifact artifact = Artifact.fromRepoPathElement(element);
                    download(pPomUrl, pRemoteRepo, artifact);
                }
View Full Code Here

                                 final File pDstFile,
                                 final String pProxyHost,
                                 final Integer pProxyPort,
                                 final String pProxyUser,
                                 final String pProxyPassword) throws IOException {
        final ProgressIndicator indicator = IDEUtils.getProgressIndicator();
        if (indicator != null && indicator.isCanceled())
            return;

        //
        //make sure the directory for the file exists
        //
        pDstFile.getParentFile().mkdirs();

        //
        //setup the progress indicator, if available
        //
        if (indicator != null) {
            indicator.setText("Downloading from " + pUrl);
            indicator.startNonCancelableSection();
        }

        //
        //download the file
        //
        try {
            final String port = pProxyPort == null ? null : pProxyPort.toString();
            HttpUtils.getFile(pUrl,                                 //url to download
                              pDstFile,                             //destination file
                              false,                                //ignore errors?
                              true,                                 //use timestamp
                              pProxyHost,                           //proxy host
                              port,                                 //proxy port
                              pProxyUser,                           //proxy username
                              pProxyPassword,                       //proxy password
                              null, null,                           //login settings
                              new ProgressIndicatorDownloadMeter()  //download meter
            );
        }
        catch (IOException e) {
            if (indicator != null) {
                indicator.finishNonCancelableSection();
                indicator.setText(e.getMessage());
                indicator.setText2("");
            }
            throw e;
        }

        if (indicator != null) {
            indicator.finishNonCancelableSection();
            indicator.setText("Finished downloading file.");
        }
    }
View Full Code Here

*/
public class ProgressIndicatorDownloadMeter implements DownloadMeter {
    private AtomicBoolean started = new AtomicBoolean(false);

    public void finish(final int pTotal) {
        final ProgressIndicator indicator = IDEUtils.getProgressIndicator();
        if (indicator != null)
            indicator.setFraction(1);
    }
View Full Code Here

        if (indicator != null)
            indicator.setFraction(1);
    }

    public void update(final int pComplete, final int pTotal) {
        final ProgressIndicator indicator = IDEUtils.getProgressIndicator();
        if (indicator != null) {
            if (started.compareAndSet(false, true))
                indicator.setIndeterminate(false);

            final double fraction = (double) pComplete / (double) pTotal;
            indicator.setFraction(fraction);
        }
    }
View Full Code Here

          return true;
        }
      }
    };

    final ProgressIndicator indicator =
        FindUsagesManager.startProcessUsages(handler, handler.getPrimaryElements(),
            handler.getSecondaryElements(), collect, options, new Runnable() {
              @Override
              public void run() {
                ApplicationManager.getApplication().invokeLater(new Runnable() {
                  @Override
                  public void run() {
                    Disposer.dispose(processIcon);
                    Container parent = processIcon.getParent();
                    parent.remove(processIcon);
                    parent.repaint();
                    pingEDT.ping(); // repaint title
                    synchronized (usages) {
                      if (visibleNodes.isEmpty()) {
                        if (usages.isEmpty()) {
                          String text = UsageViewBundle.message("no.usages.found.in",
                              searchScopePresentableName(options, project));
                          showHint(text, editor, popupPosition, handler, maxUsages, options);
                          popup.cancel();
                        } else {
                          // all usages filtered out
                        }
                      } else if (visibleNodes.size() == 1) {
                        if (usages.size() == 1) {
                          //the only usage
                          Usage usage = visibleNodes.iterator().next().getUsage();
                          usage.navigate(true);
                          //String message = UsageViewBundle.message("show.usages.only.usage", searchScopePresentableName(options, project));
                          //navigateAndHint(usage, message, handler, popupPosition, maxUsages, options);
                          popup.cancel();
                        } else {
                          assert usages.size() > 1 : usages;
                          // usage view can filter usages down to one
                          Usage visibleUsage = visibleNodes.iterator().next().getUsage();
                          if (areAllUsagesInOneLine(visibleUsage, usages)) {
                            String hint = UsageViewBundle.message("all.usages.are.in.this.line",
                                usages.size(), searchScopePresentableName(options, project));
                            navigateAndHint(visibleUsage, hint, handler, popupPosition, maxUsages,
                                options);
                            popup.cancel();
                          }
                        }
                      } else {
                        String title = presentation.getTabText();
                        boolean shouldShowMoreSeparator =
                            visibleNodes.contains(MORE_USAGES_SEPARATOR_NODE);
                        String fullTitle = getFullTitle(usages, title, shouldShowMoreSeparator,
                            visibleNodes.size() - (shouldShowMoreSeparator ? 1 : 0), false);
                        ((AbstractPopup) popup).setCaption(fullTitle);
                      }
                    }
                  }
                }, project.getDisposed());
              }
            }
        );
    Disposer.register(popup, new Disposable() {
      @Override
      public void dispose() {
        indicator.cancel();
      }
    });
  }
View Full Code Here

import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;

public class ProgressMonitor {
    public static String getTaskDescription() {
        ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        if (progressIndicator != null) {
            return progressIndicator.getText();
        }
        return null;
    }
View Full Code Here

        }
        return null;
    }

    public static void setTaskDescription(String description) {
        ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        if (progressIndicator != null) {
            progressIndicator.setText(description);
        }
    }
View Full Code Here

            progressIndicator.setText(description);
        }
    }

    public static void setSubtaskDescription(String subtaskDescription) {
        ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        if (progressIndicator != null) {
            progressIndicator.setText2(subtaskDescription);
        }
    }
View Full Code Here

            progressIndicator.setText2(subtaskDescription);
        }
    }

    public static boolean isCancelled() {
        ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
        return progressIndicator != null && progressIndicator.isCanceled();
    }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.progress.ProgressIndicator

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.