public void apply() throws ConfigurationException { myPanel.saveSettings(); if (myPanel.getProjectSettings().isCheckIncomingOutgoing()) { myProject.getMessageBus().syncPublisher(HgVcs.INCOMING_OUTGOING_CHECK_TOPIC).show(); } else { myProject.getMessageBus().syncPublisher(HgVcs.INCOMING_OUTGOING_CHECK_TOPIC).hide(); } }
protected boolean showConflicts( @NotNull MultiMap<PsiElement, String> conflicts, @Nullable final UsageInfo[] usages) { if (!conflicts.isEmpty() && ApplicationManager.getApplication().isUnitTestMode()) { if (!ConflictsInTestsException.isTestIgnore()) throw new ConflictsInTestsException(conflicts.values()); return true; } if (myPrepareSuccessfulSwingThreadCallback != null && !conflicts.isEmpty()) { final String refactoringId = getRefactoringId(); if (refactoringId != null) { RefactoringEventData conflictUsages = new RefactoringEventData(); conflictUsages.putUserData(RefactoringEventData.CONFLICTS_KEY, conflicts.values()); myProject .getMessageBus() .syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC) .conflictsDetected(refactoringId, conflictUsages); } final ConflictsDialog conflictsDialog = prepareConflictsDialog(conflicts, usages); if (!conflictsDialog.showAndGet()) { if (conflictsDialog.isShowConflicts()) prepareSuccessful(); return false; } } prepareSuccessful(); return true; }
Tool( Project project, String command, ToolKey key, TextFieldWithBrowseButton pathField, RawCommandLineEditor flagsField, JButton autoFindButton, JTextField versionField, String versionParam, @Nullable Topic<SettingsChangeNotifier> topic) { this.project = project; this.command = command; this.key = key; this.pathField = pathField; this.flagsField = flagsField; this.versionField = versionField; this.versionParam = versionParam; this.autoFindButton = autoFindButton; this.topic = topic; this.publisher = topic == null ? null : project.getMessageBus().syncPublisher(topic); this.propertyFields = Arrays.asList( new PropertyField(key.pathKey, pathField), new PropertyField(key.flagsKey, flagsField)); GuiUtil.addFolderListener(pathField, command); GuiUtil.addApplyPathAction(autoFindButton, pathField, command); updateVersion(); }
public ExternalAnnotationsManagerImpl( @NotNull final Project project, final PsiManager psiManager) { super(psiManager); myBus = project.getMessageBus(); final MessageBusConnection connection = myBus.connect(project); connection.subscribe( ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { dropCache(); } }); final MyVirtualFileListener fileListener = new MyVirtualFileListener(); VirtualFileManager.getInstance().addVirtualFileListener(fileListener); Disposer.register( myPsiManager.getProject(), new Disposable() { @Override public void dispose() { VirtualFileManager.getInstance().removeVirtualFileListener(fileListener); } }); }
private void startListening( @NotNull final List<Trinity<PsiModifierListOwner, String, Boolean>> expectedSequence) { myBusConnection = myProject.getMessageBus().connect(); myBusConnection.subscribe( ExternalAnnotationsManager.TOPIC, new DefaultAnnotationsListener() { private int index = 0; @Override public void afterExternalAnnotationChanging( @NotNull PsiModifierListOwner owner, @NotNull String annotationFQName, boolean successful) { if (index < expectedSequence.size() && expectedSequence.get(index).first == owner && expectedSequence.get(index).second.equals(annotationFQName) && expectedSequence.get(index).third == successful) { index++; myExpectedEventWasProduced = true; } else { super.afterExternalAnnotationChanging(owner, annotationFQName, successful); } } }); }
public GradleResourceCompilerConfigurationGenerator(@NotNull final Project project) { myProject = project; myModulesConfigurationHash = ContainerUtil.newConcurrentMap(); myExternalProjectDataService = (ExternalProjectDataService) ServiceManager.getService(ProjectDataManager.class) .getDataService(ExternalProjectDataService.KEY); assert myExternalProjectDataService != null; project .getMessageBus() .connect(project) .subscribe( ProjectTopics.MODULES, new ModuleAdapter() { public void moduleRemoved(@NotNull Project project, @NotNull Module module) { myModulesConfigurationHash.remove(module.getName()); } @Override public void modulesRenamed( @NotNull Project project, @NotNull List<Module> modules, @NotNull Function<Module, String> oldNameProvider) { for (Module module : modules) { moduleRemoved(project, module); } } }); }
public void addRunContentListener(final RunContentListener listener, final Executor executor) { final Disposable disposable = Disposer.newDisposable(); myProject .getMessageBus() .connect(disposable) .subscribe( RUN_CONTENT_TOPIC, new RunContentWithExecutorListener() { @Override public void contentSelected( RunContentDescriptor descriptor, @NotNull Executor executor2) { if (executor2.equals(executor)) { listener.contentSelected(descriptor); } } @Override public void contentRemoved( RunContentDescriptor descriptor, @NotNull Executor executor2) { if (executor2.equals(executor)) { listener.contentRemoved(descriptor); } } }); myListeners.put(listener, disposable); }
public void activate() { myProject .getMessageBus() .connect() .subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this); directoryMappingChanged(); }
public SvnCommittedChangesProvider(final Project project) { myProject = project; myVcs = SvnVcs.getInstance(myProject); myZipper = new MyZipper(); myConnection = myProject.getMessageBus().connect(); myConnection.subscribe( VcsConfigurationChangeListener.BRANCHES_CHANGED_RESPONSE, new VcsConfigurationChangeListener.DetailedNotification() { public void execute( final Project project, final VirtualFile vcsRoot, final List<CommittedChangeList> cachedList) { ApplicationManager.getApplication() .invokeLater( new Runnable() { public void run() { if (project.isDisposed()) { return; } for (CommittedChangeList committedChangeList : cachedList) { if ((committedChangeList instanceof SvnChangeList) && ((vcsRoot == null) || (vcsRoot.equals( ((SvnChangeList) committedChangeList).getVcsRoot())))) { ((SvnChangeList) committedChangeList).forceReloadCachedInfo(true); } } } }); } }); }
static void subscribeTo(NavBarPanel panel) { if (panel.getClientProperty(LISTENER) != null) { unsubscribeFrom(panel); } final NavBarListener listener = new NavBarListener(panel); final Project project = panel.getProject(); panel.putClientProperty(LISTENER, listener); KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(listener); FileStatusManager.getInstance(project).addFileStatusListener(listener); PsiManager.getInstance(project).addPsiTreeChangeListener(listener); WolfTheProblemSolver.getInstance(project).addProblemListener(listener); ActionManager.getInstance().addAnActionListener(listener); final MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe(ProjectTopics.PROJECT_ROOTS, listener); connection.subscribe(NavBarModelListener.NAV_BAR, listener); connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener); panel.putClientProperty(BUS, connection); panel.addKeyListener(listener); if (panel.isInFloatingMode()) { final Window window = SwingUtilities.windowForComponent(panel); if (window != null) { window.addWindowFocusListener(listener); } } }
@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(); } }
public void setProject() { if (!(_project instanceof DefaultProject)) { _failureReason = PluginFailureReason.NONE; _permanentProjectConnection = _project.getMessageBus().connect(); _permanentProjectConnection.subscribe(ProjectTopics.PROJECT_ROOTS, _moduleClasspathListener); } }
@Override public void undo() { myProject .getMessageBus() .syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC) .undoRefactoring(myRefactoringId); }
public ModulePointerManagerImpl(Project project) { myProject = project; project .getMessageBus() .connect() .subscribe( ProjectTopics.MODULES, new ModuleAdapter() { @Override public void beforeModuleRemoved(Project project, Module module) { unregisterPointer(module); } @Override public void moduleAdded(Project project, Module module) { moduleAppears(module); } @Override public void modulesRenamed(Project project, List<Module> modules) { for (Module module : modules) { moduleAppears(module); } } }); }
public boolean canCloseProject(final Project project) { assert project != null; if (!project.equals(myProject)) { return true; } if (shouldAskUser()) { int result = Messages.showOkCancelDialog( myProject, CompilerBundle.message("warning.compiler.running.on.project.close"), CompilerBundle.message("compiler.running.dialog.title"), Messages.getQuestionIcon()); if (result != 0) { return false; // veto closing } myUserAcceptedCancel = true; final MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe( CompilerTopics.COMPILATION_STATUS, new CompilationStatusAdapter() { public void compilationFinished( boolean aborted, int errors, int warnings, final CompileContext compileContext) { connection.disconnect(); ProjectUtil.closeAndDispose(project); } }); cancel(); return false; // cancel compiler and let it finish, after compilation close the project, but // currently - veto closing } return !myIndicator.isRunning(); }
TextEditorComponent( @NotNull final Project project, @NotNull final VirtualFile file, @NotNull final TextEditorImpl textEditor) { super(new BorderLayout(), textEditor); myProject = project; myFile = file; myTextEditor = textEditor; myDocument = FileDocumentManager.getInstance().getDocument(myFile); LOG.assertTrue(myDocument != null); myDocumentListener = new MyDocumentListener(); myDocument.addDocumentListener(myDocumentListener); myEditorMouseListener = new MyEditorMouseListener(); myEditorPropertyChangeListener = new MyEditorPropertyChangeListener(); myConnection = project.getMessageBus().connect(); myConnection.subscribe(FileTypeManager.TOPIC, new MyFileTypeListener()); myVirtualFileListener = new MyVirtualFileListener(); myFile.getFileSystem().addVirtualFileListener(myVirtualFileListener); myEditor = createEditor(); add(myEditor.getComponent(), BorderLayout.CENTER); myModified = isModifiedImpl(); myValid = isEditorValidImpl(); LOG.assertTrue(myValid); }
private void updateActiveTarget( @Nullable RunnerAndConfigurationSettings settings, @Nullable ExecutionTarget toSelect) { List<ExecutionTarget> suitable = settings == null ? Collections.singletonList(DefaultExecutionTarget.INSTANCE) : getTargetsFor(settings); ExecutionTarget toNotify; synchronized (myActiveTargetLock) { if (toSelect == null) toSelect = myActiveTarget; int index = -1; if (toSelect != null) { index = suitable.indexOf(toSelect); } else if (mySavedActiveTargetId != null) { for (int i = 0, size = suitable.size(); i < size; i++) { if (suitable.get(i).getId().equals(mySavedActiveTargetId)) { index = i; break; } } } toNotify = doSetActiveTarget( index >= 0 ? suitable.get(index) : ContainerUtil.getFirstItem(suitable, DefaultExecutionTarget.INSTANCE)); } if (toNotify != null) { myProject.getMessageBus().syncPublisher(TOPIC).activeTargetChanged(toNotify); } }
@Override public void projectOpened() { project .getMessageBus() .connect(project) .subscribe( FileEditorManagerListener.FILE_EDITOR_MANAGER, new MyFileEditorManagerListener()); }
public synchronized void start() { final MessageBusConnection myBusConnection = project.getMessageBus().connect(myQueue); myBusConnection.subscribe( VirtualFileManager.VFS_CHANGES, new BulkFileListener() { public void before(List<? extends VFileEvent> vFileEvents) {} public void after(List<? extends VFileEvent> vFileEvents) { for (VFileEvent vFileEvent : vFileEvents) { // if (vFileEvent instanceof VFileMoveEvent) { // if (isRelevant(vFileEvent.getPath())) { // LeiningenProject leiningenProject = // manager.byPath(vFileEvent.getPath()); // if (leiningenProject != null) { // manager.removeLeiningenProject(leiningenProject); // } // // VirtualFile newProjectFile = // ((VFileMoveEvent)vFileEvent).getNewParent().findFileByRelativePath(((VFileMoveEvent) vFileEvent).getFile().getName()); // if ( newProjectFile != null ) { // LeiningenProject newProject = new // LeiningenProject(newProjectFile, theProject); // } // } // } // if (vFileEvent instanceof VFileDeleteEvent) { // if (isRelevant(vFileEvent.getPath())) { // LeiningenProject leiningenProject = // manager.byPath(vFileEvent.getPath()); // if (leiningenProject != null) { // manager.removeLeiningenProject(leiningenProject); // } // } // } if (vFileEvent instanceof VFileCreateEvent) { if (isRelevant(vFileEvent.getPath())) { manager.importLeiningenProject( vFileEvent.getFileSystem().findFileByPath(vFileEvent.getPath()), project); } } } } private boolean isRelevant(String path) { return path != null && path.endsWith(LeiningenConstants.PROJECT_CLJ); } }); myBusConnection.subscribe( ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { public void beforeRootsChange(ModuleRootEvent moduleRootEvent) {} public void rootsChanged(ModuleRootEvent moduleRootEvent) {} }); myQueue.activate(); }
public InspectionProjectProfileManagerImpl( @NotNull Project project, @NotNull InspectionProfileManager inspectionProfileManager, @NotNull DependencyValidationManager holder, @NotNull NamedScopeManager localScopesHolder) { super(project, inspectionProfileManager, holder); myLocalScopesHolder = localScopesHolder; mySeverityRegistrar = new SeverityRegistrar(project.getMessageBus()); }
public InjectedLanguageManagerImpl(Project project, DumbService dumbService) { myProject = project; myDumbService = dumbService; final ExtensionPoint<MultiHostInjector> multiPoint = Extensions.getArea(project).getExtensionPoint(MultiHostInjector.MULTIHOST_INJECTOR_EP_NAME); ((ExtensionPointImpl<MultiHostInjector>) multiPoint) .addExtensionPointListener( new ExtensionPointListener<MultiHostInjector>() { @Override public void extensionAdded( @NotNull MultiHostInjector injector, @Nullable PluginDescriptor pluginDescriptor) { clearInjectorCache(); } @Override public void extensionRemoved( @NotNull MultiHostInjector injector, @Nullable PluginDescriptor pluginDescriptor) { clearInjectorCache(); } }, false, this); final ExtensionPointListener<LanguageInjector> myListener = new ExtensionPointListener<LanguageInjector>() { @Override public void extensionAdded( @NotNull LanguageInjector extension, @Nullable PluginDescriptor pluginDescriptor) { clearInjectorCache(); } @Override public void extensionRemoved( @NotNull LanguageInjector extension, @Nullable PluginDescriptor pluginDescriptor) { clearInjectorCache(); } }; final ExtensionPoint<LanguageInjector> psiManagerPoint = Extensions.getRootArea().getExtensionPoint(LanguageInjector.EXTENSION_POINT_NAME); ((ExtensionPointImpl<LanguageInjector>) psiManagerPoint) .addExtensionPointListener(myListener, false, this); myProgress = new DaemonProgressIndicator(); project .getMessageBus() .connect(this) .subscribe( DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListenerAdapter() { @Override public void daemonCancelEventOccurred(@NotNull String reason) { if (!myProgress.isCanceled()) myProgress.cancel(); } }); }
public ProjectRootManagerComponent(Project project, StartupManager startupManager) { super(project); myConnection = project.getMessageBus().connect(project); myConnection.subscribe( FileTypeManager.TOPIC, new FileTypeListener() { @Override public void beforeFileTypesChanged(@NotNull FileTypeEvent event) { beforeRootsChange(true); } @Override public void fileTypesChanged(@NotNull FileTypeEvent event) { rootsChanged(true); } }); VirtualFileManager.getInstance() .addVirtualFileManagerListener( new VirtualFileManagerAdapter() { @Override public void afterRefreshFinish(boolean asynchronous) { doUpdateOnRefresh(); } }, project); startupManager.registerStartupActivity( new Runnable() { @Override public void run() { myStartupActivityPerformed = true; } }); myHandler = new BatchUpdateListener() { @Override public void onBatchUpdateStarted() { myRootsChanged.levelUp(); myFileTypesChanged.levelUp(); } @Override public void onBatchUpdateFinished() { myRootsChanged.levelDown(); myFileTypesChanged.levelDown(); } }; myConnection.subscribe(VirtualFilePointerListener.TOPIC, new MyVirtualFilePointerListener()); myDoLogCachesUpdate = ApplicationManager.getApplication().isInternal() && !ApplicationManager.getApplication().isUnitTestMode(); }
public UnindexedFilesUpdater(final Project project, boolean onStartup) { myProject = project; myOnStartup = onStartup; project.getMessageBus().connect(this).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { DumbService.getInstance(project).cancelTask(UnindexedFilesUpdater.this); } }); }
public void setIgnoreSpacesInAnnotate(final boolean value) { final boolean changed = IGNORE_SPACES_IN_ANNOTATE != value; IGNORE_SPACES_IN_ANNOTATE = value; if (changed) { myProject .getMessageBus() .syncPublisher(VcsAnnotationRefresher.LOCAL_CHANGES_CHANGED) .configurationChanged(SvnVcs.getKey()); } }
@Override public void processWillTerminate(ProcessEvent event, boolean shouldNotBeUsed) { if (myProject.isDisposed()) return; if (!myWillTerminateNotified.compareAndSet(false, true)) return; myProject .getMessageBus() .syncPublisher(EXECUTION_TOPIC) .processTerminating(myExecutorId, myEnvironment, myProcessHandler); }
private void doCommit(ArtifactModelImpl artifactModel) { boolean hasChanges; LOG.assertTrue(!myInsideCommit, "Recursive commit"); myInsideCommit = true; try { final List<ArtifactImpl> allArtifacts = artifactModel.getOriginalArtifacts(); final Set<ArtifactImpl> removed = new THashSet<ArtifactImpl>(myModel.myArtifactsList); final List<ArtifactImpl> added = new ArrayList<ArtifactImpl>(); final List<Pair<ArtifactImpl, String>> changed = new ArrayList<Pair<ArtifactImpl, String>>(); for (ArtifactImpl artifact : allArtifacts) { final boolean isAdded = !removed.remove(artifact); final ArtifactImpl modifiableCopy = artifactModel.getModifiableCopy(artifact); if (isAdded) { added.add(artifact); } else if (modifiableCopy != null && !modifiableCopy.equals(artifact)) { final String oldName = artifact.getName(); artifact.copyFrom(modifiableCopy); changed.add(Pair.create(artifact, oldName)); } } myModel.setArtifactsList(allArtifacts); myModificationTracker.incModificationCount(); final ArtifactListener publisher = myProject.getMessageBus().syncPublisher(TOPIC); hasChanges = !removed.isEmpty() || !added.isEmpty() || !changed.isEmpty(); ProjectRootManagerEx.getInstanceEx(myProject) .mergeRootsChangesDuring( new Runnable() { @Override public void run() { for (ArtifactImpl artifact : removed) { publisher.artifactRemoved(artifact); } // it's important to send 'removed' events before 'added'. Otherwise when // artifacts are reloaded from xml artifact pointers will be damaged for (ArtifactImpl artifact : added) { publisher.artifactAdded(artifact); } for (Pair<ArtifactImpl, String> pair : changed) { publisher.artifactChanged(pair.getFirst(), pair.getSecond()); } } }); } finally { myInsideCommit = false; } updateWatchedRoots(); if (hasChanges) { BuildManager.getInstance().clearState(myProject); } }
private void activate() { synchronized (LOCK) { for (final Module mod : myModuleManager.getModules()) { // currently only modules with MPS facet, later should either take dependencies into account // or just take all modules if (!hasMPSFacet(mod)) continue; trackModule(mod, false); } // add listeners workerConnection = myProject.getMessageBus().connect(); // setup add/remove module listeners (change in dependencies) workerConnection.subscribe(ProjectTopics.MODULES, new ModuleWatcher(myProject)); // setup project roots listeners workerConnection.subscribe( ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void beforeRootsChange(ModuleRootEvent moduleRootEvent) { // To change body of implemented methods use File | Settings | File Templates. } @Override public void rootsChanged(ModuleRootEvent moduleRootEvent) { System.out.println("ROOTS DEBUG: event"); } }); // setup create/delete files listeners VirtualFileManager.getInstance() .addVirtualFileListener( new VirtualFileAdapter() { @Override public void fileCreated(VirtualFileEvent event) { System.out.println("VIRT FILE DEBUG: " + event.getFile().getName()); // check that it's java and under one of our content roots // ... } @Override public void fileDeleted(VirtualFileEvent event) { synchronized (LOCK) { } } }); myIsActivated = true; } }
public BlockSupportImpl(Project project) { project .getMessageBus() .connect() .subscribe( DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() { @Override public void updateStarted(@NotNull final Document doc) { doc.putUserData(DO_NOT_REPARSE_INCREMENTALLY, Boolean.TRUE); } }); }
@Override protected void subscribeToRepoChangeEvents(@NotNull Project project) { project .getMessageBus() .connect() .subscribe( HgVcs.STATUS_TOPIC, new HgUpdater() { @Override public void update(Project project, @Nullable VirtualFile root) { updateLater(); } }); }
/* Invoked by reflection */ TodoView(Project project, ProjectLevelVcsManager manager) { myProject = project; myVCSManager = manager; myCurrentPanelSettings = new TodoPanelSettings(); myAllPanelSettings = new TodoPanelSettings(); myChangeListTodosPanelSettings = new TodoPanelSettings(); myVCSManager.addVcsListener(myVcsListener); final MyPropertyChangeListener myPropertyChangeListener = new MyPropertyChangeListener(); TodoConfiguration.getInstance().addPropertyChangeListener(myPropertyChangeListener, this); MessageBusConnection connection = myProject.getMessageBus().connect(this); connection.subscribe(AppTopics.FILE_TYPES, new MyFileTypeListener()); }