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


Java ModalityState.current方法代碼示例

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


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

示例1: choose

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
@Override
public void choose(@Nullable final VirtualFile toSelect, @NotNull final Consumer<List<VirtualFile>> callback) {
  ExtensionsInitializer.initialize();

  myCallback = callback;
  myModalityState = ModalityState.current();

  final VirtualFile lastOpenedFile = FileChooserUtil.getLastOpenedFile(myProject);
  final VirtualFile selectFile = FileChooserUtil.getFileToSelect(myChooserDescriptor, myProject, toSelect, lastOpenedFile);
  final String selectPath = selectFile != null ? FileUtil.toSystemDependentName(selectFile.getPath()) : null;

  //noinspection SSBasedInspection
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      showNativeChooserAsSheet(MacFileChooserDialogImpl.this, selectPath);
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:MacFileChooserDialogImpl.java

示例2: SwingWorker

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
/**
 * Start a thread that will call the <code>construct</code> method
 * and then exit.
 */

public SwingWorker() {
  myModalityState = ModalityState.current();

  final Runnable doFinished = new Runnable() {
    public void run() {
      finished();
    }
  };

  Runnable doConstruct = new Runnable() {
    public void run() {
      try{
        setValue(construct());
        if (LOG.isDebugEnabled()) {
          LOG.debug("construct() terminated");
        }
      }
      catch (Throwable e) {
        LOG.error(e);
        onThrowable();
        throw new RuntimeException(e);
      }
      finally{
        myThreadVar.clear();
      }
      if (LOG.isDebugEnabled()) {
        LOG.debug("invoking 'finished' action");
      }
      ApplicationManager.getApplication().invokeLater(doFinished, myModalityState);
    }
  };

  final Thread workerThread = new Thread(doConstruct, "SwingWorker work thread");
  workerThread.setPriority(Thread.NORM_PRIORITY);
  myThreadVar = new ThreadVar(workerThread);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:42,代碼來源:SwingWorker.java

示例3: showDumbModeWarningLaterIfNobodyConsumesEvent

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
private static void showDumbModeWarningLaterIfNobodyConsumesEvent(final InputEvent e, final AnActionEvent... actionEvents) {
  if (ModalityState.current() == ModalityState.NON_MODAL) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (e.isConsumed()) return;

          ActionUtil.showDumbModeWarning(actionEvents);
        }
      });
    }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:IdeKeyEventDispatcher.java

示例4: loadItems

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
private static void loadItems(@NotNull final JComboBox jComboBox,
                              final List<Object> items,
                              final String groupId,
                              final URL... localUrls) {
  final ModalityState state = ModalityState.current();
  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      final List<Object> newItems = new ArrayList<Object>();
      newItems.addAll(Arrays.asList(LibrariesDownloadAssistant.getVersions(groupId, localUrls)));

      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          items.clear();
          if (!newItems.isEmpty()) {
            items.addAll(newItems);
            final CollectionComboBoxModel model = (CollectionComboBoxModel)jComboBox.getModel();
            model.update();
            jComboBox.setSelectedIndex(0);
          }
          jComboBox.setEnabled(true);
        }
      }, state);
    }
  }

  );
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:30,代碼來源:LibrariesDownloadUiUtil.java

示例5: getCurrent

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
private static ModalityState getCurrent() {
  if (ApplicationManager.getApplication().isDispatchThread()) {
    return ModalityState.current();
  }
  final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
  if (pi == null) {
    return ModalityState.defaultModalityState();
  }
  return pi.getModalityState();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:SvnAuthenticationManager.java

示例6: startLoadTask

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
private void startLoadTask(@NotNull final Pair<RepositoryTreeNode, Expander> data) {
  final ModalityState state = ModalityState.current();
  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      ProgressManager.getInstance().runProcess(new LoadTask(data), new EmptyProgressIndicator() {
        @NotNull
        @Override
        public ModalityState getModalityState() {
          return state;
        }
      });
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:RepositoryLoader.java

示例7: edit

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
protected void edit() {
  final ModalityState current = ModalityState.current();
  myDescription.fetchVersions(new DownloadableFileSetVersions.FileSetVersionsCallback<FrameworkLibraryVersion>() {
    @Override
    public void onSuccess(@NotNull final List<? extends FrameworkLibraryVersion> versions) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          String pathForDownloaded = "";
          final VirtualFile existingRootDirectory = myEditorComponent.getExistingRootDirectory();
          if (existingRootDirectory != null) {
            pathForDownloaded = existingRootDirectory.getPath();
          }
          else {
            final VirtualFile baseDir = myEditorComponent.getBaseDirectory();
            if (baseDir != null) {
              pathForDownloaded = baseDir.getPath() + "/lib";
            }
          }
          final LibraryDownloadSettings initialSettings = new LibraryDownloadSettings(getCurrentVersion(versions), myLibraryType,
                                                                                      LibrariesContainer.LibraryLevel.PROJECT,
                                                                                      pathForDownloaded);
          final LibraryDownloadSettings settings = DownloadingOptionsDialog.showDialog(getMainPanel(), initialSettings, versions, false);
          if (settings != null) {
            final NewLibraryEditor editor = settings.download(getMainPanel(), null);
            if (editor != null) {
              final LibraryEditorBase target = (LibraryEditorBase)myEditorComponent.getLibraryEditor();
              target.removeAllRoots();
              myEditorComponent.renameLibrary(editor.getName());
              target.setType(myLibraryType);
              editor.applyTo(target);
              myEditorComponent.updateRootsTree();
              myCurrentVersionString = settings.getVersion().getVersionString();
              setModified();
            }
          }
        }
      }, current);
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:42,代碼來源:DownloadableLibraryPropertiesEditor.java

示例8: reloadModel

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
public void reloadModel(final boolean userForcedRefresh) {
  myUpdating.set(true);
  myTable.getEmptyText().setText(StatusText.DEFAULT_EMPTY_TEXT);
  final JBLoadingPanel loadingPanel = getLoadingPanel();
  loadingPanel.startLoading();

  final ModalityState modalityState = ModalityState.current();

  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    public void run() {
      EmptyProgressIndicator indicator = new EmptyProgressIndicator() {
        @NotNull
        @Override
        public ModalityState getModalityState() {
          return modalityState;
        }
      };
      ProgressManager.getInstance().executeProcessUnderProgress(new Runnable() {
        @Override
        public void run() {
          try {
            if (myDisposed) return;
            myUpdater = new Updater(loadingPanel, 100);
            myUpdater.start();
            text.set("Loading...");
            myTree = new DTree(null, "", true);
            mySrc.refresh(userForcedRefresh);
            myTrg.refresh(userForcedRefresh);
            scan(mySrc, myTree, true);
            scan(myTrg, myTree, false);
          }
          catch (final IOException e) {
            LOG.warn(e);
            reportException(VcsBundle.message("refresh.failed.message", StringUtil.decapitalize(e.getLocalizedMessage())));
          }
          finally {
            if (myTree != null) {
              myTree.setSource(mySrc);
              myTree.setTarget(myTrg);
              myTree.update(mySettings);
              applySettings();
            }
          }
        }
      }, indicator);
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:49,代碼來源:DirDiffTableModel.java

示例9: executeOnPooledThread

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
@CalledInAwt
@NotNull
public static ProgressIndicator executeOnPooledThread(@NotNull final Consumer<ProgressIndicator> task, @NotNull Disposable parent) {
  final ModalityState modalityState = ModalityState.current();
  final ProgressIndicator indicator = new EmptyProgressIndicator() {
    @NotNull
    @Override
    public ModalityState getModalityState() {
      return modalityState;
    }
  };
  indicator.start();

  final Disposable disposable = new Disposable() {
    @Override
    public void dispose() {
      if (indicator.isRunning()) indicator.cancel();
    }
  };
  Disposer.register(parent, disposable);

  ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      ProgressManager.getInstance().executeProcessUnderProgress(new Runnable() {
        @Override
        public void run() {
          try {
            task.consume(indicator);
          }
          finally {
            indicator.stop();
            Disposer.dispose(disposable);
          }
        }
      }, indicator);
    }
  });

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

示例10: getModalityState

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
protected ModalityState getModalityState() {
  return ModalityState.current();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:4,代碼來源:AutoScrollFromSourceHandler.java

示例11: getCurrentState

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
@NotNull
protected ModalityState getCurrentState() {
  return ModalityState.current();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:UiActivityMonitorImpl.java

示例12: initDialog

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
private void initDialog(final Project project, final CommittedChangesTableModel changes, final Mode mode) {
  myProject = project;
  myChanges = changes;
  myMode = mode;
  setTitle(VcsBundle.message("dialog.title.changes.browser"));
  setCancelButtonText(CommonBundle.getCloseButtonText());
  final ModalityState currentState = ModalityState.current();
  if ((mode != Mode.Choose) && (ModalityState.NON_MODAL.equals(currentState))) {
    setModal(false);
  }
  myAppender = new AsynchConsumer<List<CommittedChangeList>>() {

    public void finished() {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (ChangesBrowserDialog.this.isShowing()) {
            myCommittedChangesBrowser.stopLoading();
          }
        }
      });
    }

    public void consume(final List<CommittedChangeList> committedChangeLists) {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (ChangesBrowserDialog.this.isShowing()) {
            final boolean selectFirst = (myChanges.getRowCount() == 0) && (!committedChangeLists.isEmpty());
            myChanges.addRows(committedChangeLists);
            if (selectFirst) {
              myCommittedChangesBrowser.selectFirstIfAny();
            }
          }
        }
      });
    }
  };

  init();

  if (myInitRunnable != null) {
    new AdjustComponentWhenShown() {
      @Override
      protected boolean init() {
        myInitRunnable.consume(ChangesBrowserDialog.this);
        return true;
      }
    }.install(myCommittedChangesBrowser);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:52,代碼來源:ChangesBrowserDialog.java

示例13: RemoteFetchTask

import com.intellij.openapi.application.ModalityState; //導入方法依賴的package包/類
/**
 * Should be called only from EDT, so current modality state can be captured.
 */
protected RemoteFetchTask(@Nullable Project project, @NotNull String title) {
  this(project, title, ModalityState.current());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:7,代碼來源:TaskUiUtil.java


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