本文整理匯總了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);
}
});
}
}
}
示例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);
}
}
});
}
示例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);
}
}
});
}
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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()]);
}
示例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);
}
}
});
}
示例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);
}
}
示例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;
}
}
示例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();
}
}
}
示例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());
}
示例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;
}
示例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);
}
}