com.intellij.openapi.util.EmptyRunnable Java Examples
The following examples show how to use
com.intellij.openapi.util.EmptyRunnable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PluginUtils.java From intellij with Apache License 2.0 | 6 votes |
/** Install and/or enable the given plugins. Does nothing for plugins already enabled. */ public static void installOrEnablePlugins(Set<String> pluginIds) { Set<String> toInstall = new HashSet<>(); for (String id : pluginIds) { if (isPluginEnabled(id)) { continue; } if (isPluginInstalled(id)) { if (!PluginManager.enablePlugin(id)) { notifyPluginEnableFailed(id); } } else { toInstall.add(id); } } if (!toInstall.isEmpty()) { PluginsAdvertiser.installAndEnablePlugins(toInstall, EmptyRunnable.INSTANCE); } }
Example #2
Source File: CoreCommandProcessor.java From consulo with Apache License 2.0 | 6 votes |
@Override @Nullable public CommandToken startCommand(@Nullable final Project project, @Nls final String name, @Nullable final Object groupId, @Nonnull final UndoConfirmationPolicy undoConfirmationPolicy) { ApplicationManager.getApplication().assertIsDispatchThread(); if (project != null && project.isDisposed()) return null; if (CommandLog.LOG.isDebugEnabled()) { CommandLog.LOG.debug("startCommand: name = " + name + ", groupId = " + groupId); } if (myCurrentCommand != null) { return null; } Document document = groupId instanceof Document ? (Document)groupId : (groupId instanceof Ref && ((Ref)groupId).get() instanceof Document ? (Document)((Ref)groupId).get() : null); myCurrentCommand = new CommandDescriptor(EmptyRunnable.INSTANCE, project, name, groupId, undoConfirmationPolicy, true, document); fireCommandStarted(); return myCurrentCommand; }
Example #3
Source File: ProgressWindow.java From consulo with Apache License 2.0 | 6 votes |
@Override public synchronized void stop() { LOG.assertTrue(!myStoppedAlready); super.stop(); UIUtil.invokeLaterIfNeeded(() -> { if (myDialog != null) { myDialog.hide(); } synchronized (this) { myStoppedAlready = true; } Disposer.dispose(this); }); //noinspection SSBasedInspection SwingUtilities.invokeLater(EmptyRunnable.INSTANCE); // Just to give blocking dispatching a chance to go out. }
Example #4
Source File: ToolWindowManagerBase.java From consulo with Apache License 2.0 | 6 votes |
protected void registerToolWindowsFromBeans(List<FinalizableCommand> list) { final List<ToolWindowEP> beans = ToolWindowEP.EP_NAME.getExtensionList(); for (final ToolWindowEP bean : beans) { if (checkCondition(myProject, bean)) { list.add(new FinalizableCommand(EmptyRunnable.INSTANCE) { @Override public void run() { try { initToolWindow(bean); } catch (ProcessCanceledException e) { throw e; } catch (Throwable t) { LOG.error("failed to init toolwindow " + bean.factoryClass, t); } } }); } } }
Example #5
Source File: PushedFilePropertiesUpdaterImpl.java From consulo with Apache License 2.0 | 6 votes |
private void doPushAll(@Nonnull List<? extends FilePropertyPusher<?>> pushers) { Module[] modules = ReadAction.compute(() -> ModuleManager.getInstance(myProject).getModules()); List<Runnable> tasks = new ArrayList<>(); for (final Module module : modules) { Runnable iteration = ReadAction.<Runnable, RuntimeException>compute(() -> { if (module.isDisposed()) return EmptyRunnable.INSTANCE; ProgressManager.checkCanceled(); final Object[] moduleValues = new Object[pushers.size()]; for (int i = 0; i < moduleValues.length; i++) { moduleValues[i] = pushers.get(i).getImmediateValue(module); } final ModuleFileIndex fileIndex = ModuleRootManager.getInstance(module).getFileIndex(); return () -> fileIndex.iterateContent(fileOrDir -> { applyPushersToFile(fileOrDir, pushers, moduleValues); return true; }); }); tasks.add(iteration); } invokeConcurrentlyIfPossible(tasks); }
Example #6
Source File: EnforcedPlainTextFileTypeManager.java From consulo with Apache License 2.0 | 6 votes |
private static void fireRootsChanged(final Collection<VirtualFile> files, final boolean isAdded) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { for (Project project : ProjectManager.getInstance().getOpenProjects()) { ProjectRootManagerEx.getInstanceEx(project).makeRootsChange(EmptyRunnable.getInstance(), false, true); ProjectPlainTextFileTypeManager projectPlainTextFileTypeManager = ProjectPlainTextFileTypeManager.getInstance(project); for (VirtualFile file : files) { if (projectPlainTextFileTypeManager.hasProjectContaining(file)) { if (isAdded) { projectPlainTextFileTypeManager.addFile(file); } else { projectPlainTextFileTypeManager.removeFile(file); } } } } } }); }
Example #7
Source File: HaxeImportOptimizer.java From intellij-haxe with Apache License 2.0 | 5 votes |
@NotNull @Override public Runnable processFile(final PsiFile file) { VirtualFile vFile = file.getVirtualFile(); if (vFile instanceof VirtualFileWindow) vFile = ((VirtualFileWindow)vFile).getDelegate(); if (vFile == null || !ProjectRootManager.getInstance(file.getProject()).getFileIndex().isInSourceContent(vFile)) { return EmptyRunnable.INSTANCE; } return () -> optimizeImports(file); }
Example #8
Source File: OptimizeImportsProcessor.java From consulo with Apache License 2.0 | 5 votes |
private void retrieveAndStoreNotificationInfo(@Nonnull Runnable runnable) { if (runnable instanceof ImportOptimizer.CollectingInfoRunnable) { String optimizerMessage = ((ImportOptimizer.CollectingInfoRunnable)runnable).getUserNotificationInfo(); myOptimizerNotifications.add(optimizerMessage != null ? new NotificationInfo(optimizerMessage) : NOTHING_CHANGED_NOTIFICATION); } else if (runnable == EmptyRunnable.getInstance()) { myOptimizerNotifications.add(NOTHING_CHANGED_NOTIFICATION); } else { myOptimizerNotifications.add(SOMETHING_CHANGED_WITHOUT_MESSAGE_NOTIFICATION); } }
Example #9
Source File: ProjectRootManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void rootSetChanged(final RootProvider wrapper) { if (myInsideRootsChange) return; myInsideRootsChange = true; try { makeRootsChange(EmptyRunnable.INSTANCE, false, true); } finally { myInsideRootsChange = false; } }
Example #10
Source File: ServersTreeStructure.java From consulo with Apache License 2.0 | 5 votes |
@Override public void startServer(@Nonnull Executor executor) { ServerConnection<?> connection = getConnection(); if (connection != null) { connection.computeDeployments(EmptyRunnable.INSTANCE); } }
Example #11
Source File: OptimizeImportsProcessor.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull protected FutureTask<Boolean> prepareTask(@Nonnull PsiFile file, boolean processChangedTextOnly) { if (DumbService.isDumb(file.getProject())) { return new FutureTask<>(EmptyRunnable.INSTANCE, true); } final Set<ImportOptimizer> optimizers = LanguageImportStatements.INSTANCE.forFile(file); final List<Runnable> runnables = new ArrayList<>(); List<PsiFile> files = file.getViewProvider().getAllFiles(); for (ImportOptimizer optimizer : optimizers) { for (PsiFile psiFile : files) { if (optimizer.supports(psiFile)) { runnables.add(optimizer.processFile(psiFile)); } } } Runnable runnable = !runnables.isEmpty() ? () -> { CodeStyleManagerImpl.setSequentialProcessingAllowed(false); try { for (Runnable runnable1 : runnables) { runnable1.run(); retrieveAndStoreNotificationInfo(runnable1); } putNotificationInfoIntoCollector(); } finally { CodeStyleManagerImpl.setSequentialProcessingAllowed(true); } } : EmptyRunnable.getInstance(); return new FutureTask<>(runnable, true); }
Example #12
Source File: CallbackData.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static CallbackData createSilent(@Nonnull Project project, @Nonnull InvokeAfterUpdateMode mode, @Nonnull Runnable afterUpdate) { Consumer<Runnable> callbackCaller = mode.isCallbackOnAwt() ? ApplicationManager.getApplication()::invokeLater : ApplicationManager.getApplication()::executeOnPooledThread; Runnable callback = () -> { logUpdateFinished(project, mode); if (!project.isDisposed()) afterUpdate.run(); }; return new CallbackData(() -> callbackCaller.accept(callback), EmptyRunnable.INSTANCE); }
Example #13
Source File: GraphTableModel.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public final Object getValueAt(int rowIndex, int columnIndex) { if (rowIndex >= getRowCount() - 1 && canRequestMore()) { requestToLoadMore(EmptyRunnable.INSTANCE); } VcsShortCommitDetails data = getShortDetails(rowIndex); switch (columnIndex) { case ROOT_COLUMN: return getRoot(rowIndex); case COMMIT_COLUMN: return new GraphCommitCell(data.getSubject(), getRefsAtRow(rowIndex), myDataPack.getVisibleGraph().getRowInfo(rowIndex).getPrintElements()); case AUTHOR_COLUMN: String authorString = VcsUserUtil.getShortPresentation(data.getAuthor()); return authorString + (VcsUserUtil.isSamePerson(data.getAuthor(), data.getCommitter()) ? "" : "*"); case DATE_COLUMN: if (data.getAuthorTime() < 0) { return ""; } else { return DateFormatUtil.formatDateTime(data.getAuthorTime()); } default: throw new IllegalArgumentException("columnIndex is " + columnIndex + " > " + (COLUMN_COUNT - 1)); } }
Example #14
Source File: NewMappings.java From consulo with Apache License 2.0 | 5 votes |
public void activateActiveVcses() { synchronized (myLock) { if (myActivated) return; myActivated = true; } keepActiveVcs(EmptyRunnable.getInstance()); mappingsChanged(); }
Example #15
Source File: ProjectConfigurable.java From consulo with Apache License 2.0 | 4 votes |
private void init() { myPanel = new JPanel(new VerticalFlowLayout(true, false)); final JPanel namePanel = new JPanel(new BorderLayout()); final JLabel label = new JLabel("<html><body><b>Project name:</b></body></html>", SwingConstants.LEFT); namePanel.add(label, BorderLayout.NORTH); myProjectName = new JTextField(); myProjectName.setColumns(40); final JPanel nameFieldPanel = new JPanel(); nameFieldPanel.setLayout(new BoxLayout(nameFieldPanel, BoxLayout.X_AXIS)); nameFieldPanel.add(Box.createHorizontalStrut(4)); nameFieldPanel.add(myProjectName); namePanel.add(nameFieldPanel, BorderLayout.CENTER); final JPanel wrapper = new JPanel(new FlowLayout(FlowLayout.LEFT)); wrapper.add(namePanel); wrapper.setAlignmentX(0); myPanel.add(wrapper); myPanel.add(new JLabel(ProjectBundle.message("project.compiler.output"))); final JTextField textField = new JTextField(); final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); InsertPathAction.addTo(textField, outputPathsChooserDescriptor); outputPathsChooserDescriptor.setHideIgnored(false); BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor); myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance()); FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null); myProjectCompilerOutput.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { if (myFreeze) return; myModulesConfigurator.processModuleCompilerOutputChanged(getCompilerOutputUrl()); } }); myPanel.add(myProjectCompilerOutput); myPanel.add(ScrollPaneFactory.createScrollPane(myErrorsComponent, true)); }
Example #16
Source File: UpdateCopyrightProcessor.java From consulo with Apache License 2.0 | 4 votes |
@Override protected Runnable preprocessFile(final PsiFile file) throws IncorrectOperationException { VirtualFile vfile = file.getVirtualFile(); if (vfile == null) { return EmptyRunnable.getInstance(); } final ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); if (progressIndicator != null) { progressIndicator.setText2(vfile.getPresentableUrl()); } Module mod = module; if (module == null) { mod = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vfile); } if (mod == null) { return EmptyRunnable.getInstance(); } UpdateCopyrightsProvider updateCopyrightsProvider = CopyrightUpdaters.INSTANCE.forFileType(file.getFileType()); if(updateCopyrightsProvider == null) { return EmptyRunnable.getInstance(); } CopyrightProfile copyrightProfile = CopyrightManager.getInstance(project).getCopyrightOptions(file); if (copyrightProfile != null && CopyrightUpdaters.hasExtension(file)) { logger.debug("process " + file); final UpdatePsiFileCopyright<?> updateCopyright = updateCopyrightsProvider.createInstance(file, copyrightProfile); return new Runnable() { @Override public void run() { try { updateCopyright.process(); } catch (Exception e) { logger.error(e); } } }; } else { return EmptyRunnable.getInstance(); } }
Example #17
Source File: SafeDeleteRefactoringImpl.java From consulo with Apache License 2.0 | 4 votes |
SafeDeleteRefactoringImpl(Project project, PsiElement[] elements) { super(SafeDeleteProcessor.createInstance(project, EmptyRunnable.INSTANCE, elements, true, true)); }
Example #18
Source File: PopupFactoryImpl.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public ListPopup createConfirmation(String title, final String yesText, String noText, final Runnable onYes, int defaultOptionIndex) { return createConfirmation(title, yesText, noText, onYes, EmptyRunnable.getInstance(), defaultOptionIndex); }
Example #19
Source File: ProgressWindow.java From consulo with Apache License 2.0 | 4 votes |
@Override public void startBlocking() { startBlocking(EmptyRunnable.getInstance()); }
Example #20
Source File: CommandProcessor.java From consulo with Apache License 2.0 | 4 votes |
@Nullable @Deprecated @DeprecationInfo("Use #hasCurrentCommand()") public final Runnable getCurrentCommand() { return hasCurrentCommand() ? EmptyRunnable.getInstance() : null; }
Example #21
Source File: PlatformTestCase.java From consulo with Apache License 2.0 | 4 votes |
private static void waitForAllLaters() throws InterruptedException, InvocationTargetException { for (int i = 0; i < 3; i++) { SwingUtilities.invokeAndWait(EmptyRunnable.getInstance()); } }
Example #22
Source File: ServersToolWindowContent.java From consulo with Apache License 2.0 | 4 votes |
public ServersToolWindowContent(@Nonnull Project project) { super(new BorderLayout()); myProject = project; myTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode()); myTree = new Tree(myTreeModel); myTree.setRootVisible(false); myTree.setShowsRootHandles(true); myTree.setCellRenderer(new NodeRenderer()); myTree.setLineStyleAngled(); getMainPanel().add(createToolbar(), BorderLayout.WEST); Splitter splitter = new OnePixelSplitter(false, 0.3f); splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myTree, SideBorder.LEFT)); myPropertiesPanelLayout = new CardLayout(); myPropertiesPanel = new JPanel(myPropertiesPanelLayout); myMessageLabel = new JLabel(EMPTY_SELECTION_MESSAGE, SwingConstants.CENTER); myPropertiesPanel.add(MESSAGE_CARD, new Wrapper(myMessageLabel)); splitter.setSecondComponent(myPropertiesPanel); getMainPanel().add(splitter, BorderLayout.CENTER); setupBuilder(project); for (RemoteServersViewContributor contributor : RemoteServersViewContributor.EP_NAME.getExtensionList()) { contributor.setupTree(myProject, myTree, myBuilder); } myTree.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { onSelectionChanged(); } }); new DoubleClickListener() { @Override protected boolean onDoubleClick(MouseEvent event) { Set<ServersTreeStructure.RemoteServerNode> nodes = getSelectedRemoteServerNodes(); if (nodes.size() == 1) { RemoteServer<?> server = nodes.iterator().next().getValue(); ServerConnectionManager.getInstance().getOrCreateConnection(server).computeDeployments(EmptyRunnable.INSTANCE); return true; } return false; } }.installOn(myTree); }
Example #23
Source File: ThreesideBinaryDiffViewer.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull protected Runnable performRediff(@Nonnull final ProgressIndicator indicator) { return EmptyRunnable.INSTANCE; }
Example #24
Source File: HeavyPlatformTestCaseExtension.java From GitToolBox with Apache License 2.0 | 4 votes |
private static void waitForAllLaters() throws InterruptedException, InvocationTargetException { for (int i = 0; i < 3; i++) { SwingUtilities.invokeAndWait(EmptyRunnable.getInstance()); } }
Example #25
Source File: LightPlatformTestCaseExtension.java From GitToolBox with Apache License 2.0 | 4 votes |
private static void waitForAllLaters() throws InterruptedException, InvocationTargetException { for (int i = 0; i < 3; i++) { SwingUtilities.invokeAndWait(EmptyRunnable.getInstance()); } }
Example #26
Source File: BlazeJavaAbstractTestCaseConfigurationProducerTest.java From intellij with Apache License 2.0 | 4 votes |
@Test public void testConfigurationCreatedFromMethodInAbstractClass() { PsiFile abstractClassFile = createAndIndexFile( new WorkspacePath("java/com/google/test/AbstractTestCase.java"), "package com.google.test;", "public abstract class AbstractTestCase {", " @org.junit.Test", " public void testMethod() {}", "}"); createAndIndexFile( new WorkspacePath("java/com/google/test/TestClass.java"), "package com.google.test;", "import com.google.test.AbstractTestCase;", "import org.junit.runner.RunWith;", "import org.junit.runners.JUnit4;", "@org.junit.runner.RunWith(org.junit.runners.JUnit4.class)", "public class TestClass extends AbstractTestCase {}"); PsiClass javaClass = ((PsiClassOwner) abstractClassFile).getClasses()[0]; PsiMethod method = PsiUtils.findFirstChildOfClassRecursive(javaClass, PsiMethod.class); assertThat(method).isNotNull(); ConfigurationContext context = createContextFromPsi(method); List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext(); assertThat(configurations).hasSize(1); ConfigurationFromContext fromContext = configurations.get(0); assertThat(fromContext.isProducedBy(BlazeJavaAbstractTestCaseConfigurationProducer.class)) .isTrue(); assertThat(fromContext.getSourceElement()).isEqualTo(method); RunConfiguration config = fromContext.getConfiguration(); assertThat(config).isInstanceOf(BlazeCommandRunConfiguration.class); BlazeCommandRunConfiguration blazeConfig = (BlazeCommandRunConfiguration) config; assertThat(blazeConfig.getTargets()).isEmpty(); assertThat(blazeConfig.getName()).isEqualTo("Choose subclass for AbstractTestCase.testMethod"); MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() .addTarget( TargetIdeInfo.builder() .setKind("java_test") .setLabel("//java/com/google/test:TestClass") .addSource(sourceRoot("java/com/google/test/TestClass.java")) .build()) .build()); registerProjectService( BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build())); BlazeJavaAbstractTestCaseConfigurationProducer.chooseSubclass( fromContext, context, EmptyRunnable.INSTANCE); assertThat(blazeConfig.getTargets()) .containsExactly(TargetExpression.fromStringSafe("//java/com/google/test:TestClass")); assertThat(getTestFilterContents(blazeConfig)) .isEqualTo(BlazeFlags.TEST_FILTER + "=com.google.test.TestClass#testMethod$"); }
Example #27
Source File: BlazeJavaAbstractTestCaseConfigurationProducerTest.java From intellij with Apache License 2.0 | 4 votes |
@Test public void testConfigurationCreatedFromAbstractClass() { workspace.createPsiDirectory(new WorkspacePath("java/com/google/test")); PsiFile abstractClassFile = createAndIndexFile( new WorkspacePath("java/com/google/test/AbstractTestCase.java"), "package com.google.test;", "public abstract class AbstractTestCase {}"); createAndIndexFile( new WorkspacePath("java/com/google/test/TestClass.java"), "package com.google.test;", "import com.google.test.AbstractTestCase;", "@org.junit.runner.RunWith(org.junit.runners.JUnit4.class)", "public class TestClass extends AbstractTestCase {", " @org.junit.Test", " public void testMethod1() {}", " @org.junit.Test", " public void testMethod2() {}", "}"); PsiClass javaClass = ((PsiClassOwner) abstractClassFile).getClasses()[0]; assertThat(javaClass).isNotNull(); ConfigurationContext context = createContextFromPsi(abstractClassFile); List<ConfigurationFromContext> configurations = context.getConfigurationsFromContext(); assertThat(configurations).hasSize(1); ConfigurationFromContext fromContext = configurations.get(0); assertThat(fromContext.isProducedBy(BlazeJavaAbstractTestCaseConfigurationProducer.class)) .isTrue(); assertThat(fromContext.getSourceElement()).isEqualTo(javaClass); RunConfiguration config = fromContext.getConfiguration(); assertThat(config).isInstanceOf(BlazeCommandRunConfiguration.class); BlazeCommandRunConfiguration blazeConfig = (BlazeCommandRunConfiguration) config; assertThat(blazeConfig.getTargets()).isEmpty(); assertThat(blazeConfig.getName()).isEqualTo("Choose subclass for AbstractTestCase"); MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() .addTarget( TargetIdeInfo.builder() .setKind("java_test") .setLabel("//java/com/google/test:TestClass") .addSource(sourceRoot("java/com/google/test/TestClass.java")) .build()) .build()); registerProjectService( BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build())); BlazeJavaAbstractTestCaseConfigurationProducer.chooseSubclass( fromContext, context, EmptyRunnable.INSTANCE); assertThat(blazeConfig.getTargets()) .containsExactly(TargetExpression.fromStringSafe("//java/com/google/test:TestClass")); assertThat(getTestFilterContents(blazeConfig)) .isEqualTo(BlazeFlags.TEST_FILTER + "=com.google.test.TestClass#"); }