Java Code Examples for consulo.disposer.Disposer#dispose()
The following examples show how to use
consulo.disposer.Disposer#dispose() .
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: RootModelImpl.java From consulo with Apache License 2.0 | 6 votes |
@RequiredReadAction private void loadState(Element element, @Nullable ProgressIndicator progressIndicator) { String currentLayer = element.getAttributeValue("current-layer"); if (currentLayer != null) { setCurrentLayerSafe(currentLayer); for (Element moduleLayerElement : element.getChildren("module-layer")) { String name = moduleLayerElement.getAttributeValue("name"); ModuleRootLayerImpl moduleRootLayer = new ModuleRootLayerImpl(null, this); moduleRootLayer.loadState(moduleLayerElement, progressIndicator); ModuleRootLayerImpl layer = myLayers.put(name, moduleRootLayer); if (layer != null) { // dispose old layout Disposer.dispose(layer); } } } // old format - create default profile and load it if (myLayers.isEmpty()) { initDefaultLayer(element); } }
Example 2
Source File: PluginManagerConfigurable.java From consulo with Apache License 2.0 | 6 votes |
@Override public void disposeUIResources() { if (myPluginManagerMain != null) { getSplitterProportions().saveSplitterProportions(myPluginManagerMain.getMainPanel()); if (myAvailable) { final RowSorter<? extends TableModel> rowSorter = myPluginManagerMain.myPluginTable.getRowSorter(); if (rowSorter != null) { final List<? extends RowSorter.SortKey> sortKeys = rowSorter.getSortKeys(); if (sortKeys.size() > 0) { final RowSorter.SortKey sortKey = sortKeys.get(0); myUISettings.AVAILABLE_SORT_MODE = sortKey.getColumn(); myUISettings.AVAILABLE_SORT_COLUMN_ORDER = sortKey.getSortOrder().ordinal(); } } myUISettings.AVAILABLE_SORT_BY_STATUS = myPluginManagerMain.myPluginsModel.isSortByStatus(); } else { myUISettings.INSTALLED_SORT_BY_STATUS = myPluginManagerMain.myPluginsModel.isSortByStatus(); } Disposer.dispose(myPluginManagerMain); myPluginManagerMain = null; } }
Example 3
Source File: WebContainerStartup.java From consulo with Apache License 2.0 | 5 votes |
@Override public void destroy() { Application application = ApplicationManager.getApplication(); if (application != null) { Disposer.dispose(application); } }
Example 4
Source File: FileEditorManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
void disposeComposite(@Nonnull EditorWithProviderComposite editor) { if (getAllEditors().length == 0) { setCurrentWindow(null); } if (editor.equals(getLastSelected())) { editor.getSelectedEditor().deselectNotify(); getSplitters().setCurrentWindow(null, false); } final FileEditor[] editors = editor.getEditors(); final FileEditorProvider[] providers = editor.getProviders(); final FileEditor selectedEditor = editor.getSelectedEditor(); for (int i = editors.length - 1; i >= 0; i--) { final FileEditor editor1 = editors[i]; final FileEditorProvider provider = providers[i]; if (!editor.equals(selectedEditor)) { // we already notified the myEditor (when fire event) if (selectedEditor.equals(editor1)) { editor1.deselectNotify(); } } editor1.removePropertyChangeListener(myEditorPropertyChangeListener); provider.disposeEditor(editor1); } Disposer.dispose(editor); }
Example 5
Source File: AllFileTemplatesConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void disposeUIResources() { if (myCurrentTab != null) { final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(); propertiesComponent.setValue(CURRENT_TAB, myCurrentTab.getTitle(), TEMPLATES_TITLE); final FileTemplate template = myCurrentTab.getSelectedTemplate(); if (template != null) { propertiesComponent.setValue(SELECTED_TEMPLATE, template.getName()); } } if (myEditor != null) { myEditor.disposeUIResources(); myEditor = null; myEditorComponent = null; } myMainPanel = null; if (myUIDisposable != null) { Disposer.dispose(myUIDisposable); myUIDisposable = null; } myTabbedPane = null; myToolBar = null; myTabs = null; myCurrentTab = null; myTemplatesList = null; myCodeTemplatesList = null; myIncludesList = null; myOtherTemplatesList = null; }
Example 6
Source File: UsefulTestCase.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void tearDown() throws Exception { try { Disposer.dispose(myTestRootDisposable); cleanupSwingDataStructures(); } finally { if (shouldContainTempFiles()) { FileUtil.resetCanonicalTempPathCache(ORIGINAL_TEMP_DIR); if (ourPathToKeep != null && FileUtil.isAncestor(myTempDir, ourPathToKeep, false)) { File[] files = new File(myTempDir).listFiles(); if (files != null) { for (File file : files) { if (!FileUtil.pathsEqual(file.getPath(), ourPathToKeep)) { FileUtil.delete(file); } } } } else { FileUtil.delete(new File(myTempDir)); } } } UIUtil.removeLeakingAppleListeners(); super.tearDown(); }
Example 7
Source File: InspectionToolsConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void disposeUIResources() { for (SingleInspectionProfilePanel panel : myPanels.values()) { panel.disposeUI(); } myPanels.clear(); if (mySelectionAlarm != null) { Disposer.dispose(mySelectionAlarm); mySelectionAlarm = null; } }
Example 8
Source File: DesktopToolWindowContentUi.java From consulo with Apache License 2.0 | 5 votes |
private static AnAction createMergeTabsAction(final ContentManager manager, final String tabPrefix) { return new DumbAwareAction("Merge tabs to '" + tabPrefix + "' group") { @RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { final Content selectedContent = manager.getSelectedContent(); final List<Pair<String, JComponent>> tabs = new ArrayList<Pair<String, JComponent>>(); int selectedTab = -1; for (Content content : manager.getContents()) { if (tabPrefix.equals(content.getUserData(Content.TAB_GROUP_NAME_KEY))) { final String label = content.getTabName().substring(tabPrefix.length() + 2); final JComponent component = content.getComponent(); if (content == selectedContent) { selectedTab = tabs.size(); } tabs.add(Pair.create(label, component)); manager.removeContent(content, false); content.setComponent(null); Disposer.dispose(content); } } PropertiesComponent.getInstance().unsetValue(TabbedContent.SPLIT_PROPERTY_PREFIX + tabPrefix); for (int i = 0; i < tabs.size(); i++) { final Pair<String, JComponent> tab = tabs.get(i); ContentUtilEx.addTabbedContent(manager, tab.second, tabPrefix, tab.first, i == selectedTab); } } }; }
Example 9
Source File: ActionTracer.java From consulo with Apache License 2.0 | 5 votes |
@Override public void disposeUiResources() { Disposer.dispose(myListenerDisposable); myComponent = null; myText = null; }
Example 10
Source File: FlatWelcomeFrame.java From consulo with Apache License 2.0 | 5 votes |
@Override public void setVisible(boolean value) { if (myDisposed) { throw new IllegalArgumentException("Already disposed"); } super.setVisible(value); if (!value) { Disposer.dispose(this); } }
Example 11
Source File: TemplateExpressionLookupElement.java From consulo with Apache License 2.0 | 5 votes |
void handleTemplateInsert(List<? extends LookupElement> elements, final char completionChar) { final InsertionContext context = createInsertionContext(this, myState.getPsiFile(), elements, myState.getEditor(), completionChar); new WriteCommandAction(context.getProject()) { @Override protected void run(@Nonnull Result result) throws Throwable { doHandleInsert(context); } }.execute(); Disposer.dispose(context.getOffsetMap()); if (handleCompletionChar(context) && !myState.isFinished()) { myState.calcResults(true); myState.considerNextTabOnLookupItemSelected(getDelegate()); } }
Example 12
Source File: TemplateState.java From consulo with Apache License 2.0 | 5 votes |
private void cleanupTemplateState(boolean brokenOff) { final Editor editor = myEditor; fireBeforeTemplateFinished(brokenOff); if (!isDisposed()) { int oldVar = myCurrentVariableNumber; setCurrentVariableNumber(-1); currentVariableChanged(oldVar); TemplateManagerImpl.clearTemplateState(editor); fireTemplateFinished(brokenOff); } myListeners.clear(); Disposer.dispose(this); }
Example 13
Source File: DesktopEditorComposite.java From consulo with Apache License 2.0 | 5 votes |
@Override public void dispose() { for (FileEditor editor : myEditors) { if (!Disposer.isDisposed(editor)) { Disposer.dispose(editor); } } myFocusWatcher.deinstall(myFocusWatcher.getTopComponent()); }
Example 14
Source File: LibraryConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@Override public void disposeUIResources() { if (myLibraryEditorComponent != null) { Disposer.dispose(myLibraryEditorComponent); myLibraryEditorComponent = null; } }
Example 15
Source File: SMTestProxy.java From consulo with Apache License 2.0 | 5 votes |
@Override public void dispose() { if (myState instanceof TestFailedState) { Disposer.dispose((TestFailedState)myState); } super.dispose(); }
Example 16
Source File: DiffPanelImpl.java From consulo with Apache License 2.0 | 4 votes |
public void setDiffRequest(DiffRequest data) { myDiffRequest = data; if (data.getHints().contains(DiffTool.HINT_DO_NOT_IGNORE_WHITESPACES)) { setComparisonPolicy(ComparisonPolicy.DEFAULT, false); } myDataProvider.putData(myDiffRequest.getGenericData()); DiffContent content1 = data.getContents()[0]; DiffContent content2 = data.getContents()[1]; setContents(content1, content2); setTitles(data); setWindowTitle(myOwnerWindow, data.getWindowTitle()); myPanel.setToolbarActions(createToolbar()); data.customizeToolbar(myPanel.resetToolbar()); myPanel.registerToolbarActions(); initEditorSettings(getEditor1()); initEditorSettings(getEditor2()); final JComponent oldBottomComponent = myPanel.getBottomComponent(); if (oldBottomComponent instanceof Disposable) { Disposer.dispose((Disposable)oldBottomComponent); } final JComponent newBottomComponent = data.getBottomComponent(); myPanel.setBottomComponent(newBottomComponent); if (myIsRequestFocus) { IdeFocusManager fm = IdeFocusManager.getInstance(myProject); boolean isEditor1Focused = getEditor1() != null && fm.getFocusedDescendantFor(getEditor1().getComponent()) != null; boolean isEditor2Focused = myData.getContent2() != null && getEditor2() != null && fm.getFocusedDescendantFor(getEditor2().getComponent()) != null; if (isEditor1Focused || isEditor2Focused) { Editor e = isEditor2Focused ? getEditor2() : getEditor1(); if (e != null) { fm.requestFocus(e.getContentComponent(), true); } } myPanel.requestScrollEditors(); } }
Example 17
Source File: ExcludedEntriesConfigurable.java From consulo with Apache License 2.0 | 4 votes |
private void disposeMyDescriptions() { for (ExcludeEntryDescription description : myExcludeEntryDescriptions) { Disposer.dispose(description); } myExcludeEntryDescriptions.clear(); }
Example 18
Source File: QuickDocUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void updateQuickDocAsync(@Nonnull PsiElement element, @Nonnull CharSequence prefix, @Nonnull Consumer<Consumer<Object>> provider) { Project project = element.getProject(); StringBuilder sb = new StringBuilder(prefix); ConcurrentLinkedQueue<Object> queue = new ConcurrentLinkedQueue<>(); Disposable alarmDisposable = Disposable.newDisposable(); Disposer.register(project, alarmDisposable); AtomicBoolean stop = new AtomicBoolean(false); Ref<Object> cutAt = Ref.create(null); SingleAlarm alarm = new SingleAlarm(() -> { DocumentationComponent component = getActiveDocComponent(project); if (component == null) { stop.set(true); Disposer.dispose(alarmDisposable); return; } Object s = queue.poll(); while (s != null) { if (s == CUT_AT_CMD || cutAt.get() == CUT_AT_CMD) { cutAt.set(s); s = ""; } else if (!cutAt.isNull()) { int idx = StringUtil.indexOf(sb, cutAt.get().toString()); if (idx >= 0) sb.setLength(idx); cutAt.set(null); } sb.append(s); s = queue.poll(); } if (stop.get()) { Disposer.dispose(alarmDisposable); } String newText = sb.toString() + "<br><br><br>"; String prevText = component.getText(); if (!Comparing.equal(newText, prevText)) { component.replaceText(newText, element); } }, 100, alarmDisposable); ApplicationManager.getApplication().executeOnPooledThread(() -> { try { provider.consume(str -> { ProgressManager.checkCanceled(); if (stop.get()) throw new ProcessCanceledException(); queue.add(str); alarm.cancelAndRequest(); }); } finally { if (stop.compareAndSet(false, true)) { alarm.cancelAndRequest(); } } }); }
Example 19
Source File: CompositeSettingsEditor.java From consulo with Apache License 2.0 | 4 votes |
@Override public void disposeEditor() { Disposer.dispose(this); myIsDisposed = true; }
Example 20
Source File: CoreProgressManager.java From consulo with Apache License 2.0 | 4 votes |
@Override public void dispose() { // do nothing if already disposed Disposer.dispose((Disposable)myIndicator, false); }