當前位置: 首頁>>代碼示例>>Java>>正文


Java Application類代碼示例

本文整理匯總了Java中com.intellij.openapi.application.Application的典型用法代碼示例。如果您正苦於以下問題:Java Application類的具體用法?Java Application怎麽用?Java Application使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Application類屬於com.intellij.openapi.application包,在下文中一共展示了Application類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: invokeDialog

import com.intellij.openapi.application.Application; //導入依賴的package包/類
@NotNull
@Override
protected void invokeDialog(AnActionEvent e,Project project, PsiDirectory dir) {
    BaseDialog dialog = new BaseDialog("請輸入基類前綴:",project);
    dialog.show();
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        String prefix = dialog.getClassNamePrefix();
        if(prefix != null && !prefix.isEmpty()){
            Application application = ApplicationManager.getApplication();
            application.runWriteAction(() -> {
                PsiElement createdElement = createProjectDir(dir,prefix);
                final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
                if(view != null&&createdElement != null){
                    view.selectElement(createdElement);
                }
            });
        }
    }
}
 
開發者ID:wangtotang,項目名稱:DaggerHelper,代碼行數:20,代碼來源:NewModuleDirAction.java

示例2: scheduleCourseListUpdate

import com.intellij.openapi.application.Application; //導入依賴的package包/類
public void scheduleCourseListUpdate(Application application) {
  if (!checkNeeded()) {
    return;
  }
  application.getMessageBus().connect(application).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
    @Override
    public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {

      long timeToNextCheck = StudySettings.getInstance().getLastTimeChecked() + CHECK_INTERVAL - System.currentTimeMillis();
      if (timeToNextCheck <= 0) {
        myCheckRunnable.run();
      }
      else {
        queueNextCheck(timeToNextCheck);
      }
    }
  });
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:19,代碼來源:EduStepicUpdater.java

示例3: invokeDialog

import com.intellij.openapi.application.Application; //導入依賴的package包/類
@NotNull
@Override
protected void invokeDialog(AnActionEvent e,Project project, PsiDirectory dir) {
    BaseDialog dialog = new BaseDialog("請輸入基類前綴:",project);
    dialog.show();
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        String prefix = dialog.getClassNamePrefix();
        if(prefix != null && !prefix.isEmpty()){
            Application application = ApplicationManager.getApplication();
            application.runWriteAction(() -> {
                PsiElement[] elements = createProjectDir(dir,prefix);
                final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
                if(view != null){
                    for (PsiElement element : elements) {
                        view.selectElement(element);
                    }
                }
            });
        }
    }
}
 
開發者ID:wangtotang,項目名稱:DaggerHelper,代碼行數:22,代碼來源:NewProjectDirAction.java

示例4: refreshIoFiles

import com.intellij.openapi.application.Application; //導入依賴的package包/類
@Override
public void refreshIoFiles(@NotNull Iterable<File> files, boolean async, boolean recursive, @Nullable Runnable onFinish) {
  final VirtualFileManagerEx manager = (VirtualFileManagerEx)VirtualFileManager.getInstance();

  Application app = ApplicationManager.getApplication();
  boolean fireCommonRefreshSession = app.isDispatchThread() || app.isWriteAccessAllowed();
  if (fireCommonRefreshSession) manager.fireBeforeRefreshStart(false);

  try {
    List<VirtualFile> filesToRefresh = new ArrayList<VirtualFile>();

    for (File file : files) {
      final VirtualFile virtualFile = refreshAndFindFileByIoFile(file);
      if (virtualFile != null) {
        filesToRefresh.add(virtualFile);
      }
    }

    RefreshQueue.getInstance().refresh(async, recursive, onFinish, filesToRefresh);
  }
  finally {
    if (fireCommonRefreshSession) manager.fireAfterRefreshFinish(false);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:LocalFileSystemBase.java

示例5: showError

import com.intellij.openapi.application.Application; //導入依賴的package包/類
public static void showError(final Project project, final String message, final boolean error) {
  final Application application = ApplicationManager.getApplication();
  if (application.isUnitTestMode()) {
    return;
  }
  final String title = VcsBundle.message("patch.apply.dialog.title");
  final Runnable messageShower = new Runnable() {
    @Override
    public void run() {
      if (error) {
        Messages.showErrorDialog(project, message, title);
      }
      else {
        Messages.showInfoMessage(project, message, title);
      }
    }
  };
  WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
      @Override
      public void run() {
        messageShower.run();
      }
    }, null, project);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:PatchApplier.java

示例6: actionPerformed

import com.intellij.openapi.application.Application; //導入依賴的package包/類
public final void actionPerformed(final AnActionEvent anActionEvent)
    {
        logger.debug("entered actionPerformed");
        // we're being called on the Swing event dispatch thread.  Spin off another thread to do the 
        // rearranging and let Swing's thread go.
//        Thread t = new Thread(new Runnable() {
//            public void run()
//            {
//                //To change body of implemented methods use Options | File Templates.
        final Application application = ApplicationManager.getApplication();
        application.runWriteAction(new RearrangeIt(anActionEvent.getDataContext()));
//            }
//        }, "RearrangerThread");
//        t.start();
//        new RearrangeIt(anActionEvent.getDataContext()).run();
    }
 
開發者ID:DaveKriewall,項目名稱:Rearranger,代碼行數:17,代碼來源:SpaceTest4.java

示例7: LocalFileSystemImpl

import com.intellij.openapi.application.Application; //導入依賴的package包/類
public LocalFileSystemImpl(@NotNull ManagingFS managingFS) {
  myManagingFS = managingFS;
  myWatcher = new FileWatcher(myManagingFS);
  if (myWatcher.isOperational()) {
    final int PERIOD = 1000;
    Runnable runnable = new Runnable() {
      public void run() {
        final Application application = ApplicationManager.getApplication();
        if (application == null || application.isDisposed()) return;
        storeRefreshStatusToFiles();
        JobScheduler.getScheduler().schedule(this, PERIOD, TimeUnit.MILLISECONDS);
      }
    };
    JobScheduler.getScheduler().schedule(runnable, PERIOD, TimeUnit.MILLISECONDS);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:LocalFileSystemImpl.java

示例8: create

import com.intellij.openapi.application.Application; //導入依賴的package包/類
@NotNull
@Override
protected PsiElement[] create(String componentName, PsiDirectory directory) {
    List<PsiElement> elements = new LinkedList<>();
    Application application = ApplicationManager.getApplication();
    application.runWriteAction(() -> {
        PsiDirectory componentDirectory = directory.createSubdirectory(componentName);
        elements.add(componentDirectory);
        String[] fileNames = getRequiredFileNames(componentName);
        for (String fileName : fileNames) {
            PsiFile file = componentDirectory.createFile(fileName);
            elements.add(file);
        }
    });
    return elements.toArray(new PsiElement[elements.size()]);
}
 
開發者ID:Cognifide,項目名稱:IntelliJ-Shortcuts-For-AEM,代碼行數:17,代碼來源:NewAemComponentAction.java

示例9: beforeApplicationLoaded

import com.intellij.openapi.application.Application; //導入依賴的package包/類
@Override
public void beforeApplicationLoaded(@NotNull Application application, @NotNull String configPath) {
  // Invoke later is necessary to make showWarning work.
  // setFrameIcon is called to change icon of welcome screen and it is unclear
  // if invoke later can be invoked to early (in the future) so setFrameIcon
  // is called again on ClassicIcon#projectOpened just in case.
  // Important here is only setDockIcon and this would work without invoke later also.
  application.invokeLater(new Runnable() {
    @Override
    public void run() {
      if (SystemInfo.isMac) {
        setDockIcon();
      } else {
        ClassicIcon.setFrameIcon(null);
      }
    }
  });
}
 
開發者ID:retomerz,項目名稱:classic-icon-idea,代碼行數:19,代碼來源:AppLoader.java

示例10: setUpFileWatcher

import com.intellij.openapi.application.Application; //導入依賴的package包/類
private void setUpFileWatcher() {
  final Application application = ApplicationManager.getApplication();
  if (application.isDisposeInProgress() || !myWatcher.isOperational()) return;
  application.assertReadAccessAllowed();

  synchronized (myLock) {
    final WatchRequestImpl[] watchRequests = normalizeRootsForRefresh();
    final List<String> myRecursiveRoots = new ArrayList<String>();
    final List<String> myFlatRoots = new ArrayList<String>();

    for (WatchRequestImpl watchRequest : watchRequests) {
      if (watchRequest.isToWatchRecursively()) {
        myRecursiveRoots.add(watchRequest.myFSRootPath);
      }
      else {
        myFlatRoots.add(watchRequest.myFSRootPath);
      }
    }

    myWatcher.setWatchRoots(myRecursiveRoots, myFlatRoots);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:LocalFileSystemImpl.java

示例11: getRootTagAttributeSafely

import com.intellij.openapi.application.Application; //導入依賴的package包/類
/**
 * Get the value of an attribute in the {@link com.intellij.psi.xml.XmlFile} safely (meaning it will acquire the read lock first).
 */
@Nullable
public static String getRootTagAttributeSafely(@NotNull final XmlFile file,
                                               @NotNull final String attribute,
                                               @Nullable final String namespace) {
  Application application = ApplicationManager.getApplication();
  if (!application.isReadAccessAllowed()) {
    return application.runReadAction(new Computable<String>() {
      @Nullable
      @Override
      public String compute() {
        return getRootTagAttributeSafely(file, attribute, namespace);
      }
    });
  } else {
    XmlTag tag = file.getRootTag();
    if (tag != null) {
      XmlAttribute attr = namespace != null ? tag.getAttribute(attribute, namespace) : tag.getAttribute(attribute);
      if (attr != null) {
        return attr.getValue();
      }
    }
    return null;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:AndroidPsiUtils.java

示例12: run

import com.intellij.openapi.application.Application; //導入依賴的package包/類
public static void run(final Project project, final Runnable action) {
  final ProjectLevelVcsManager plVcsManager = ProjectLevelVcsManager.getInstance(project);
  plVcsManager.startBackgroundVcsOperation();
  try {
    action.run();
  } finally {
    final Application application = ApplicationManager.getApplication();
    if (application.isDispatchThread()) {
      application.executeOnPooledThread(new Runnable() {
        public void run() {
          plVcsManager.stopBackgroundVcsOperation();
        }
      });
    } else {
      plVcsManager.stopBackgroundVcsOperation();
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:ExclusiveBackgroundVcsAction.java

示例13: doFix

import com.intellij.openapi.application.Application; //導入依賴的package包/類
@Override
public void doFix(@NotNull final Project project,
                  ProblemDescriptor descriptor) {

  final PsiElement constant = descriptor.getPsiElement();
  final Application application = ApplicationManager.getApplication();
  application.invokeLater(new Runnable() {

    @Override
    public void run() {
      if (!constant.isValid()) return;
      final JavaRefactoringActionHandlerFactory factory =
        JavaRefactoringActionHandlerFactory.getInstance();
      final RefactoringActionHandler introduceHandler =
        factory.createIntroduceConstantHandler();
      final DataManager dataManager = DataManager.getInstance();
      final DataContext dataContext = dataManager.getDataContext();
      introduceHandler.invoke(project, new PsiElement[]{constant},
                              dataContext);
    }
  }, project.getDisposed());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:IntroduceConstantFix.java

示例14: getGlobalInstance

import com.intellij.openapi.application.Application; //導入依賴的package包/類
@NotNull
public static IdeFocusManager getGlobalInstance() {
  IdeFocusManager fm = null;

  Application app = ApplicationManager.getApplication();
  if (app != null && app.hasComponent(IdeFocusManager.class)) {
    fm = app.getComponent(IdeFocusManager.class);
  }

  if (fm == null) {
    // happens when app is semi-initialized (e.g. when IDEA server dialog is shown)
    fm = PassThroughIdeFocusManager.getInstance();
  }

  return fm;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:IdeFocusManager.java

示例15: show

import com.intellij.openapi.application.Application; //導入依賴的package包/類
private static void show(final Project project, final String message, final MessageType type, final boolean showOverChangesView,
                         @Nullable final NamedRunnable[] notificationListener) {
  final Application application = ApplicationManager.getApplication();
  if (application.isHeadlessEnvironment()) return;
  final Runnable showErrorAction = new Runnable() {
    public void run() {
      new VcsBalloonProblemNotifier(project, message, type, showOverChangesView, notificationListener).run();
    }
  };
  if (application.isDispatchThread()) {
    showErrorAction.run();
  }
  else {
    application.invokeLater(showErrorAction);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:VcsBalloonProblemNotifier.java


注:本文中的com.intellij.openapi.application.Application類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。