public void initComponent() { final int port = mySettings.getPortNumber(); final boolean allowRequestsFromLocalhostOnly = mySettings.isAllowRequestsFromLocalhostOnly(); EditorEventMulticaster eventMulticaster = EditorFactory.getInstance().getEventMulticaster(); eventMulticaster.addDocumentListener(new DocumentChangeListener()); try { serverSocket = new ServerSocket(); serverSocket.bind(new InetSocketAddress(allowRequestsFromLocalhostOnly ? "localhost" : "0.0.0.0", port)); log.info("Listening " + port); } catch (IOException e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { Messages.showMessageDialog("Can't bind with " + port + " port. Appetizer plugin won't work", "Appetizer Plugin Error", Messages.getErrorIcon()); } }); return; } MessageNotifier messageNotifier = new SocketMessageNotifier(serverSocket); messageNotifier.addMessageHandler(new OpenFileMessageHandler(new FileNavigatorImpl())); listenerThread = new Thread(messageNotifier); listenerThread.start(); }
private void setupAutoStartDocumentListener(boolean enabled) { final EditorEventMulticaster editorEventMulticaster = EditorFactory.getInstance().getEventMulticaster(); if (autoStartDocumentListener != null) { editorEventMulticaster.removeDocumentListener(autoStartDocumentListener); autoStartDocumentListener = null; } if (enabled) { editorEventMulticaster.addDocumentListener(autoStartDocumentListener = new DocumentListener() { @Override public void documentChanged(DocumentEvent e) { if (running) return; //getSelectedTextEditor() must be run from event dispatch thread EventQueue.invokeLater(() -> { final Editor selectedTextEditor = FileEditorManager.getInstance(project).getSelectedTextEditor(); if (selectedTextEditor == null) return; if(e.getDocument().equals(selectedTextEditor.getDocument())) { setRunning(true); } }); } }); } }
public void startIfNeeded() { if (TRACKING.compareAndSet(false, true)) ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> { VirtualFileManager.getInstance().addVirtualFileListener(new StylintConfigFileVfsListener(), StylintConfigFileChangeTracker.this.project); EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster(); multicaster.addDocumentListener(new StylintConfigFileDocumentListener(), StylintConfigFileChangeTracker.this.project); })); }
private void startListener() { if (LISTENING.compareAndSet(false, true)) ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { VirtualFileManager.getInstance().addVirtualFileListener(new SassLintConfigFileVfsListener(), SassLintConfigFileListener.this.project); EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster(); multicaster.addDocumentListener(new SassLintConfigFileDocumentListener(), SassLintConfigFileListener.this.project); } }); } }); }
private void startListener() { if (LISTENING.compareAndSet(false, true)) ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { VirtualFileManager.getInstance().addVirtualFileListener(new CoffeeLintConfigFileVfsListener(), CoffeeLintConfigFileListener.this.project); EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster(); multicaster.addDocumentListener(new CoffeeLintConfigFileDocumentListener(), CoffeeLintConfigFileListener.this.project); } }); } }); }
private void startListener() { if (LISTENING.compareAndSet(false, true)) ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { VirtualFileManager.getInstance().addVirtualFileListener(new ESLintConfigFileVfsListener(), ESLintConfigFileListener.this.project); EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster(); multicaster.addDocumentListener(new ESLintConfigFileDocumentListener(), ESLintConfigFileListener.this.project); } }); } }); }
@Override @NotNull public EditorEventMulticaster getEventMulticaster() { return new MockEditorEventMulticaster(); }
@Override @NotNull public EditorEventMulticaster getEventMulticaster() { return myEditorEventMulticaster; }
@Override @Nonnull public EditorEventMulticaster getEventMulticaster() { return new MockEditorEventMulticaster(); }
@Override @Nonnull public EditorEventMulticaster getEventMulticaster() { return myEditorEventMulticaster; }
/** * Returns the service for attaching event listeners to all editor instances. * * @return the event multicaster instance. */ @NotNull public abstract EditorEventMulticaster getEventMulticaster();
/** * Returns the service for attaching event listeners to all editor instances. * * @return the event multicaster instance. */ @Nonnull public abstract EditorEventMulticaster getEventMulticaster();