Java Code Examples for org.netbeans.editor.Utilities#runInEventDispatchThread()
The following examples show how to use
org.netbeans.editor.Utilities#runInEventDispatchThread() .
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: NbEditorToolBar.java From netbeans with Apache License 2.0 | 6 votes |
/** See issue #57773 for details. Toolbar should be updated with possible changes after module install/uninstall */ private void installModulesInstallationListener(){ moduleRegListener = new FileChangeAdapter() { public @Override void fileChanged(FileEvent fe) { //some module installed/uninstalled. Refresh toolbar content Runnable r = new Runnable() { public void run() { if (isToolbarVisible()) { checkPresentersRemoved(); checkPresentersAdded(); } } }; Utilities.runInEventDispatchThread(r); } }; FileObject moduleRegistry = FileUtil.getConfigFile("Modules"); //NOI18N if (moduleRegistry !=null){ moduleRegistry.addFileChangeListener( FileUtil.weakFileChangeListener(moduleRegListener, moduleRegistry)); } }
Example 2
Source File: ToolTipSupport.java From netbeans with Apache License 2.0 | 5 votes |
/** Set the tooltip text to make the tooltip * to be shown on the screen. * @param text tooltip text to be displayed. */ public void setToolTipText(String text) { final String displayableText = makeDisplayable(text, UIManager.getFont(UI_PREFIX + ".font")); //NOI18N Utilities.runInEventDispatchThread(new Runnable() { public @Override void run() { String oldText = toolTipText; toolTipText = displayableText; firePropertyChange(PROP_TOOL_TIP_TEXT, oldText, toolTipText); if (toolTipText != null) { if (toolTipText.startsWith(HTML_PREFIX_LOWERCASE) || toolTipText.startsWith(HTML_PREFIX_UPPERCASE)) { JEditorPane jep = createHtmlTextToolTip(); jep.setText(toolTipText); jep.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); setToolTip(jep); } else { // With the improved algorithm for placing popups we can have all text tooltips to wrap lines. // Should this cause a problem please revert to the previouse state and have only singleline // tooltips to wrap lines. // boolean multiLineText = toolTipText.contains("\n"); //NOI18N // JTextArea ta = createTextToolTip(!multiLineText); JTextArea ta = createTextToolTip(true); ta.setText(toolTipText); setToolTip(ta); } } else { // null text if (status == STATUS_TEXT_VISIBLE) { setToolTipVisible(false); } } } }); }
Example 3
Source File: CompletionImpl.java From netbeans with Apache License 2.0 | 5 votes |
public void resultChanged(LookupEvent ev) { Utilities.runInEventDispatchThread(new Runnable(){ public void run(){ installKeybindings(); } }); }
Example 4
Source File: NbToolTip.java From netbeans with Apache License 2.0 | 5 votes |
public void run() { if (tts == null) return; if (tts == null || tts.getStatus() == ToolTipSupport.STATUS_HIDDEN) { return; // do nothing } if (!isRequestValid()) { return; } if (tts != null) tts.addPropertyChangeListener(this); final CharSequence tooltipText = resolveTooltipText(); if (tooltipText != null && tooltipText.length() > 0 && isRequestValid()) { Utilities.runInEventDispatchThread(new Runnable() { public void run() { final ToolTipSupport ftts = tts; if (ftts != null) { ftts.setToolTipText(tooltipText.toString()); if (tooltipText instanceof HyperlinkOperation.TooltipInfo) { JComponent tt = ftts.getToolTip(); if (tt instanceof JEditorPane) { ((JEditorPane)tt).addHyperlinkListener(((HyperlinkOperation.TooltipInfo)tooltipText).getListener()); ((JEditorPane)tt).setEditable(false); } } } } }); } else { // Attempt to get tooltip from view under mouse } }
Example 5
Source File: MainMenuAction.java From netbeans with Apache License 2.0 | 5 votes |
protected final void postSetMenu() { Utilities.runInEventDispatchThread(new Runnable() { @Override public void run() { setMenu(); } }); }
Example 6
Source File: NbEditorToolBar.java From netbeans with Apache License 2.0 | 4 votes |
private void refreshToolbarButtons() { final JTextComponent c = getComponent(); final boolean visible = isToolbarVisible(); Runnable r = new Runnable() { public void run() { if (visible) { checkPresentersAdded(); if (c != null) { //#62487 installNoOpActionMappings(); Map<String, MultiKeyBinding> keybsMap = getKeyBindingMap(); Component comps[] = getComponents(); for (int i = 0; i < comps.length; i++) { Component comp = comps[i]; if (comp instanceof JButton) { JButton button = (JButton) comp; Action action = button.getAction(); if (action == null) { continue; } String actionName = (String) action.getValue(Action.NAME); if (actionName == null) { continue; } String tooltipText = button.getToolTipText(); if (tooltipText != null) { int index = tooltipText.indexOf("("); //NOI18N if (index > 0) { tooltipText = tooltipText.substring(0, index - 1); } } MultiKeyBinding mkb = keybsMap.get(actionName); if (mkb != null) { button.setToolTipText(tooltipText + " (" + // NOI18N EditorActionUtilities.getKeyMnemonic(mkb) + ")"); // NOI18N } else { button.setToolTipText(tooltipText); } } } } } else { checkPresentersRemoved(); } setVisible(visible); } }; Utilities.runInEventDispatchThread(r); }