当前位置: 首页>>代码示例>>Java>>正文


Java Task.Modal方法代码示例

本文整理汇总了Java中com.intellij.openapi.progress.Task.Modal方法的典型用法代码示例。如果您正苦于以下问题:Java Task.Modal方法的具体用法?Java Task.Modal怎么用?Java Task.Modal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.progress.Task的用法示例。


在下文中一共展示了Task.Modal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: analyze

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
public void analyze() {
  final List<DependenciesBuilder> builders = new ArrayList<DependenciesBuilder>();

  final Task task;
  if (canStartInBackground()) {
    task = new Task.Backgroundable(myProject, getProgressTitle(), true, new PerformAnalysisInBackgroundOption(myProject)) {
      @Override
      public void run(@NotNull final ProgressIndicator indicator) {
        perform(builders);
      }

      @Override
      public void onSuccess() {
        DependenciesHandlerBase.this.onSuccess(builders);
      }
    };
  } else {
    task = new Task.Modal(myProject, getProgressTitle(), true) {
      @Override
      public void run(@NotNull ProgressIndicator indicator) {
        perform(builders);
      }

      @Override
      public void onSuccess() {
        DependenciesHandlerBase.this.onSuccess(builders);
      }
    };
  }
  ProgressManager.getInstance().run(task);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:DependenciesHandlerBase.java

示例2: performAction

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
public void performAction() {
  final ScreenRecorderOptionsDialog dialog = new ScreenRecorderOptionsDialog(myProject);
  if (!dialog.showAndGet()) {
    return;
  }

  final ScreenRecorderOptions options = dialog.getOptions();

  final CountDownLatch latch = new CountDownLatch(1);
  final CollectingOutputReceiver receiver = new CollectingOutputReceiver(latch);

  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      try {
        myDevice.startScreenRecorder(REMOTE_PATH, options, receiver);
      }
      catch (Exception e) {
        showError(myProject, "Unexpected error while launching screen recorder", e);
        latch.countDown();
      }
    }
  });

  Task.Modal screenRecorderShellTask = new ScreenRecorderTask(myProject, myDevice, latch, receiver);
  screenRecorderShellTask.setCancelText("Stop Recording");
  screenRecorderShellTask.queue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ScreenRecorderAction.java

示例3: parseTraceFileInBackground

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
private void parseTraceFileInBackground(@NotNull final Project project, @NotNull final VirtualFile file) {
  final Task.Modal parseTask = new Task.Modal(project, "Parsing trace file", false) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      indicator.setIndeterminate(true);

      File traceFile = VfsUtilCore.virtualToIoFile(file);
      VmTraceParser parser = new VmTraceParser(traceFile);
      try {
        parser.parse();
      }
      catch (final Throwable throwable) {
        ApplicationManager.getApplication().invokeAndWait(new Runnable() {
          @Override
          public void run() {
            //noinspection ThrowableResultOfMethodCallIgnored
            Messages.showErrorDialog(project, "Unexpected error while parsing trace file: " +
                                              Throwables.getRootCause(throwable).getMessage(), getName());
          }
        }, ModalityState.defaultModalityState());
        return;
      }

      final VmTraceData vmTraceData = parser.getTraceData();
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          myTraceViewPanel.setTrace(vmTraceData);
        }
      });
    }
  };
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      parseTask.queue();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:VmTraceEditor.java

示例4: perform

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
private T perform(boolean modal, final Disposable disposable) {
  final Semaphore semaphore = new Semaphore();
  semaphore.down();

  final AtomicReference<T> result = new AtomicReference<T>();

  final Progressive progressive = new Progressive() {

    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      indicator.setIndeterminate(true);
      while (!indicator.isCanceled()) {
        if (semaphore.waitFor(500)) {
          if (mySuccess.get()) {
            UIUtil.invokeLaterIfNeeded(new Runnable() {

              @Override
              public void run() {
                if (disposable == null || !Disposer.isDisposed(disposable)) {
                  postPerform(result.get());
                }
              }
            });
          }
          break;
        }
      }
    }
  };

  Task task;
  boolean cancellable = isCancellable(modal);
  if (modal) {
    task = new Task.Modal(myProject, myTitle, cancellable) {

      @Override
      public void run(@NotNull ProgressIndicator indicator) {
        progressive.run(indicator);
      }
    };
  }
  else {
    task = new Task.Backgroundable(myProject, myTitle, cancellable) {

      @Override
      public void run(@NotNull ProgressIndicator indicator) {
        progressive.run(indicator);
      }

      @Override
      public boolean shouldStartInBackground() {
        return CloudRuntimeTask.this.shouldStartInBackground();
      }
    };
  }

  mySuccess.set(false);
  myErrorMessage.set(null);

  run(semaphore, result);

  task.queue();

  return result.get();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:66,代码来源:CloudRuntimeTask.java

示例5: createVirtualEnv

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
public void createVirtualEnv(final VirtualEnvCallback callback) {
  final ProgressManager progman = ProgressManager.getInstance();
  final Sdk basicSdk = getSdk();
  final Task.Modal createTask = new Task.Modal(myProject, PyBundle.message("sdk.create.venv.dialog.creating.venv"), false) {
    String myPath;

    public void run(@NotNull final ProgressIndicator indicator) {

      try {
        indicator.setText(PyBundle.message("sdk.create.venv.dialog.creating.venv"));
        myPath = createEnvironment(basicSdk);
      }
      catch (final ExecutionException e) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
          @Override
          public void run() {
            final PackageManagementService.ErrorDescription description =
              PyPackageManagementService.toErrorDescription(Collections.singletonList(e), basicSdk);
            if (description != null) {
              PackagesNotificationPanel.showError(PyBundle.message("sdk.create.venv.dialog.error.failed.to.create.venv"), description);
            }
          }
        }, ModalityState.any());
      }
    }


    @Override
    public void onSuccess() {
      if (myPath != null) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
          @Override
          public void run() {
            DumbService.allowStartingDumbModeInside(DumbModePermission.MAY_START_BACKGROUND, new Runnable() {
              @Override
              public void run() {
                setupVirtualEnvSdk(myPath, associateWithProject(), callback);
              }
            });
          }
        });
      }
    }
  };
  progman.run(createTask);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:47,代码来源:AbstractCreateVirtualEnvDialog.java

示例6: parseAllocationsFileInBackground

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
private void parseAllocationsFileInBackground(final Project project, final VirtualFile file) {
  final Task.Modal parseTask = new Task.Modal(project, "Parsing allocations file", false) {
    private AllocationInfo[] myAllocations;
    private String myErrorMessage;

    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      indicator.setIndeterminate(true);

      final File allocationsFile = VfsUtilCore.virtualToIoFile(file);
      ByteBuffer data;
      try {
        data = ByteBufferUtil.mapFile(allocationsFile, 0, ByteOrder.BIG_ENDIAN);
      } catch (IOException ex) {
        myErrorMessage = "Error reading from allocations file " + allocationsFile.getAbsolutePath();
        throw new ProcessCanceledException();
      }

      try {
        myAllocations = AllocationsParser.parse(data);
      }
      catch (final Throwable throwable) {
        //noinspection ThrowableResultOfMethodCallIgnored
        myErrorMessage = "Unexpected error while parsing allocations file: " + Throwables.getRootCause(throwable).getMessage();
        throw new ProcessCanceledException();
      }
    }

    @Override
    public void onSuccess() {
      AllocationsView view = new AllocationsView(project, myAllocations);
      myPanel.add(view.getComponent(), BorderLayout.CENTER);
    }

    @Override
    public void onCancel() {
      Messages.showErrorDialog(project, myErrorMessage, getName());
    }
  };
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      parseTask.queue();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:47,代码来源:AllocationsEditor.java

示例7: collectOwnerOccurrences

import com.intellij.openapi.progress.Task; //导入方法依赖的package包/类
private static boolean collectOwnerOccurrences(final Project project,
                                               final GrParametersOwner owner,
                                               final Collection<PsiElement> occurrences) {
  final PsiElement namedElem = getReferencedElement(owner);
  if (namedElem == null) return true;
  final Ref<Boolean> result = new Ref<Boolean>(true);
  final Task task = new Task.Modal(project, GroovyIntentionsBundle
    .message("find.method.ro.closure.usages.0", owner instanceof GrClosableBlock ? CLOSURE_CAPTION : METHOD_CAPTION), true) {
    @Override
    public void run(@NotNull final ProgressIndicator indicator) {
      final Collection<PsiReference> references = Collections.synchronizedSet(new HashSet<PsiReference>());
      final Processor<PsiReference> consumer = new Processor<PsiReference>() {
        @Override
        public boolean process(PsiReference psiReference) {
          references.add(psiReference);
          return true;
        }
      };
      ReferencesSearch.search(namedElem).forEach(consumer);
      boolean isProperty = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
        @Override
        public Boolean compute() {
          return namedElem instanceof GrField && ((GrField)namedElem).isProperty();
        }
      });
      if (isProperty) {
        final GrAccessorMethod[] getters = ApplicationManager.getApplication().runReadAction(new Computable<GrAccessorMethod[]>() {
          @Override
          public GrAccessorMethod[] compute() {
            return ((GrField)namedElem).getGetters();
          }
        });
        for (GrAccessorMethod getter : getters) {
          MethodReferencesSearch.search(getter).forEach(consumer);
        }
      }
      for (final PsiReference reference : references) {
        ApplicationManager.getApplication().runReadAction(new Runnable() {
          @Override
          public void run() {
            final PsiElement element = reference.getElement();
            if (element != null) {
              occurrences.add(element);
            }
          }
        });
      }
    }

    @Override
    public void onCancel() {
      result.set(false);
    }

    @Override
    public void onSuccess() {
      result.set(true);
    }
  };
  ProgressManager.getInstance().run(task);
  return result.get().booleanValue();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:63,代码来源:ConvertParameterToMapEntryIntention.java


注:本文中的com.intellij.openapi.progress.Task.Modal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。