com.intellij.ide.SaveAndSyncHandler Java Examples
The following examples show how to use
com.intellij.ide.SaveAndSyncHandler.
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: PantsUtil.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
public static void synchronizeFiles() { /** * Run in SYNC in unit test mode, and {@link com.twitter.intellij.pants.testFramework.PantsIntegrationTestCase.doImport} * is required to be wrapped in WriteAction. Otherwise it will run in async mode. */ if (ApplicationManager.getApplication().isUnitTestMode() && ApplicationManager.getApplication().isWriteAccessAllowed()) { ApplicationManager.getApplication().runWriteAction(() -> { FileDocumentManager.getInstance().saveAllDocuments(); SaveAndSyncHandler.getInstance().refreshOpenFiles(); VirtualFileManager.getInstance().refreshWithoutFileWatcher(false); /** synchronous */ }); } else { ApplicationManager.getApplication().invokeLater(() -> { FileDocumentManager.getInstance().saveAllDocuments(); SaveAndSyncHandler.getInstance().refreshOpenFiles(); VirtualFileManager.getInstance().refreshWithoutFileWatcher(true); /** asynchronous */ }); } }
Example #2
Source File: ExecutionManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void processTerminated(ProcessEvent event) { if (myProject.isDisposed()) return; if (!myTerminateNotified.compareAndSet(false, true)) return; ApplicationManager.getApplication().invokeLater(() -> { RunnerLayoutUi ui = myDescriptor.getRunnerLayoutUi(); if (ui != null && !ui.isDisposed()) { ui.updateActionsNow(); } }, ModalityState.any()); myProject.getMessageBus().syncPublisher(EXECUTION_TOPIC).processTerminated(myExecutorId, myEnvironment, myProcessHandler, event.getExitCode()); SaveAndSyncHandler saveAndSyncHandler = SaveAndSyncHandler.getInstance(); if (saveAndSyncHandler != null) { saveAndSyncHandler.scheduleRefresh(); } }
Example #3
Source File: BlazeProjectCreator.java From intellij with Apache License 2.0 | 4 votes |
private void doCreate() throws IOException { String projectFilePath = wizardContext.getProjectFileDirectory(); File projectDir = new File(projectFilePath).getParentFile(); logger.assertTrue( projectDir != null, "Cannot create project in '" + projectFilePath + "': no parent file exists"); FileUtil.ensureExists(projectDir); if (wizardContext.getProjectStorageFormat() == StorageScheme.DIRECTORY_BASED) { final File ideaDir = new File(projectFilePath, Project.DIRECTORY_STORE_FOLDER); FileUtil.ensureExists(ideaDir); } String name = wizardContext.getProjectName(); Project newProject = projectBuilder.createProject(name, projectFilePath); if (newProject == null) { return; } if (!ApplicationManager.getApplication().isUnitTestMode()) { newProject.save(); } if (!projectBuilder.validate(null, newProject)) { return; } projectBuilder.commit(newProject, null, ModulesProvider.EMPTY_MODULES_PROVIDER); StartupManager.getInstance(newProject) .registerPostStartupActivity( () -> { // ensure the dialog is shown after all startup activities are done //noinspection SSBasedInspection SwingUtilities.invokeLater( () -> { if (newProject.isDisposed() || ApplicationManager.getApplication().isUnitTestMode()) { return; } ApplicationManager.getApplication() .invokeLater( () -> { if (newProject.isDisposed()) { return; } final ToolWindow toolWindow = ToolWindowManager.getInstance(newProject) .getToolWindow(ToolWindowId.PROJECT_VIEW); if (toolWindow != null) { toolWindow.activate(null); } }, ModalityState.NON_MODAL); }); }); ProjectUtil.updateLastProjectLocation(projectFilePath); if (WindowManager.getInstance().isFullScreenSupportedInCurrentOS()) { IdeFocusManager instance = IdeFocusManager.findInstance(); IdeFrame lastFocusedFrame = instance.getLastFocusedFrame(); if (lastFocusedFrame instanceof IdeFrameEx) { boolean fullScreen = ((IdeFrameEx) lastFocusedFrame).isInFullScreen(); if (fullScreen) { newProject.putUserData(IdeFrameImpl.SHOULD_OPEN_IN_FULL_SCREEN, Boolean.TRUE); } } } BaseSdkCompat.openProject(newProject, Paths.get(projectFilePath)); if (!ApplicationManager.getApplication().isUnitTestMode()) { SaveAndSyncHandler.getInstance().scheduleProjectSave(newProject); } }
Example #4
Source File: SynchronizeAction.java From consulo with Apache License 2.0 | 4 votes |
@Override public void actionPerformed(AnActionEvent e) { FileDocumentManager.getInstance().saveAllDocuments(); SaveAndSyncHandler.getInstance().refreshOpenFiles(); VirtualFileManager.getInstance().refreshWithoutFileWatcher(true); }
Example #5
Source File: FileChooserDialogImpl.java From consulo with Apache License 2.0 | 4 votes |
protected JComponent createCenterPanel() { JPanel panel = new MyPanel(); myUiUpdater = new MergingUpdateQueue("FileChooserUpdater", 200, false, panel); Disposer.register(myDisposable, myUiUpdater); new UiNotifyConnector(panel, myUiUpdater); panel.setBorder(JBUI.Borders.empty()); createTree(); final DefaultActionGroup group = createActionGroup(); ActionToolbar toolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true); toolBar.setTargetComponent(panel); final JPanel toolbarPanel = new JPanel(new BorderLayout()); toolbarPanel.add(toolBar.getComponent(), BorderLayout.CENTER); myTextFieldAction = new TextFieldAction() { public void linkSelected(final LinkLabel aSource, final Object aLinkData) { toggleShowTextField(); } }; toolbarPanel.add(myTextFieldAction, BorderLayout.EAST); JPanel extraToolbarPanel = createExtraToolbarPanel(); if (extraToolbarPanel != null) { toolbarPanel.add(extraToolbarPanel, BorderLayout.SOUTH); } myPathTextFieldWrapper = new JPanel(new BorderLayout()); myPathTextFieldWrapper.setBorder(JBUI.Borders.emptyBottom(2)); myPathTextField = new FileTextFieldImpl.Vfs(FileChooserFactoryImpl.getMacroMap(), getDisposable(), new LocalFsFinder.FileChooserFilter(myChooserDescriptor, myFileSystemTree)) { @Override protected void onTextChanged(final String newValue) { myUiUpdater.cancelAllUpdates(); updateTreeFromPath(newValue); } }; consulo.disposer.Disposer.register(myDisposable, myPathTextField); myPathTextFieldWrapper.add(myPathTextField.getField(), BorderLayout.CENTER); if (getRecentFiles().length > 0) { myPathTextFieldWrapper.add(createHistoryButton(), BorderLayout.EAST); } myNorthPanel = new JPanel(new BorderLayout()); myNorthPanel.add(toolbarPanel, BorderLayout.NORTH); updateTextFieldShowing(); panel.add(myNorthPanel, BorderLayout.NORTH); registerMouseListener(group); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myFileSystemTree.getTree()); //scrollPane.setBorder(BorderFactory.createLineBorder(new Color(148, 154, 156))); panel.add(scrollPane, BorderLayout.CENTER); panel.setPreferredSize(JBUI.size(400)); JLabel hintLabel = new JLabel(DRAG_N_DROP_HINT, SwingConstants.CENTER); hintLabel.setForeground(JBColor.gray); hintLabel.setFont(JBUI.Fonts.smallFont()); panel.add(hintLabel, BorderLayout.SOUTH); ApplicationManager.getApplication().getMessageBus().connect(getDisposable()).subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener() { @Override public void applicationActivated(IdeFrame ideFrame) { ((DesktopSaveAndSyncHandlerImpl)SaveAndSyncHandler.getInstance()).maybeRefresh(ModalityState.current()); } }); return panel; }