Java Code Examples for org.eclipse.swt.widgets.Control#setRedraw()
The following examples show how to use
org.eclipse.swt.widgets.Control#setRedraw() .
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: BibOutlinePage.java From texlipse with Eclipse Public License 1.0 | 6 votes |
/** * Updates the outline with new content. * * @param content The new content of the outline */ //public void update(Hashtable<String, BibStringTriMap<ReferenceEntry>> sortIndex) { public void update(BibOutlineContainer content) { this.content = content; TreeViewer viewer = getTreeViewer(); //this.sortIndex = sortIndex; if (viewer != null) { Control control = viewer.getControl(); if (control != null && !control.isDisposed()) { control.setRedraw(false); viewer.setInput(this.content); //viewer.setInput(sortIndex); control.setRedraw(true); } } }
Example 2
Source File: ModulaOutlinePage.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
/** * The editor is saved, so we should refresh representation * * @param tableNamePositions */ public void update() { //set the input so that the outlines parse can be called //update the tree viewer state TreeViewer viewer = getTreeViewer(); if (viewer != null) { Control control = viewer.getControl(); if (control != null && !control.isDisposed()) { try{ control.setRedraw(false); viewer.setInput(input); } finally{ control.setRedraw(true); } } } }
Example 3
Source File: MarkUtils.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Wrap selection provider setSelection within a block disabling highlight * range to protect against the JavaEditor from changing the narrow focus in * - org.eclipse.jdt.internal.ui.javaeditor.TogglePresentationAction - * * @param editor * @param selection * in model coords */ public static ITextSelection setSelection(ITextEditor editor, ITextSelection selection) { boolean isNarrow = editor.showsHighlightRangeOnly(); // Use the text widget, as the IRewriteTarget has unpleasant scrolling side effects Control text = getTextWidget(editor); try { text.setRedraw(false); if (isNarrow) { editor.showHighlightRangeOnly(false); } editor.getSelectionProvider().setSelection(selection); } finally { if (isNarrow) { editor.showHighlightRangeOnly(isNarrow); } text.setRedraw(true); } return selection; }
Example 4
Source File: BlockHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * @see com.mulgasoft.emacsplus.commands.EmacsPlusCmdHandler#transform(ITextEditor, IDocument, ITextSelection, ExecutionEvent) */ @Override protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection, ExecutionEvent event) throws BadLocationException { Control text = getTextWidget(editor); String cmd = ((getDirection() == FORWARD) ? IEmacsPlusCommandDefinitionIds.NEXT_LINE : IEmacsPlusCommandDefinitionIds.PREVIOUS_LINE); try { // use widget to avoid unpleasant scrolling side effects of IRewriteTarget text.setRedraw(false); for (int i=0; i < blockMovementSize; i++) { try { EmacsPlusUtils.executeCommand(cmd, null, editor); } catch (Exception e) {} } } finally { text.setRedraw(true); } return NO_OFFSET; }
Example 5
Source File: RectangleExecHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
@Override protected boolean doExecuteResult(ITextEditor editor, Object minibufferResult) { // use widget to avoid unpleasant scrolling side effects of IRewriteTarget Control widget = getTextWidget(editor); // wrap in compound change and no redraw IRewriteTarget rt = (IRewriteTarget) editor.getAdapter(IRewriteTarget.class); try { if (rt != null) { rt.beginCompoundChange(); } widget.setRedraw(false); int offset = rs.updateRectangle(editor, document, selection, (String)minibufferResult, isReplace(),false); if (offset > 0) { selectAndReveal(editor, offset, offset); } } finally { if (rt != null) { rt.endCompoundChange(); } widget.setRedraw(true); } return true; }
Example 6
Source File: TexOutlinePage.java From texlipse with Eclipse Public License 1.0 | 5 votes |
/** * Updates the outline with new content. Called by TexDocumentModel * through the editor. Saves the visible state of the outline, * sets the new content and restores the state. * * @param input the new outline input */ public void update(TexOutlineInput input) { this.input = input; TreeViewer viewer= getTreeViewer(); if (viewer != null) { Control control= viewer.getControl(); if (control != null && !control.isDisposed()) { control.setRedraw(false); //First try smart update boolean succUpdate = ((TexContentProvider) viewer.getContentProvider()).updateElements(viewer, input.getRootNodes()); if (!succUpdate) { viewer.getTree().deselectAll(); // save viewer state Object[] expandedElements = viewer.getExpandedElements(); // set new input viewer.setInput(input.getRootNodes()); /*viewer.getContentProvider().inputChanged(viewer, null, input.getRootNodes()); viewer.refresh(true);*/ // restore viewer state viewer.setExpandedElements(expandedElements); } control.setRedraw(true); // disable the refresh button, enable context stuff outlineActions.get(ACTION_UPDATE).setEnabled(false); outlineActions.get(ACTION_COPY).setEnabled(true); outlineActions.get(ACTION_CUT).setEnabled(true); outlineActions.get(ACTION_PASTE).setEnabled(true); outlineActions.get(ACTION_DELETE).setEnabled(true); } } }
Example 7
Source File: RegisterRectangleHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @see com.mulgasoft.emacsplus.minibuffer.IMinibufferExecutable#executeResult(org.eclipse.ui.texteditor.ITextEditor, java.lang.Object) */ public boolean doExecuteResult(ITextEditor editor, Object minibufferResult) { if (minibufferResult != null && ((String)minibufferResult).length() > 0) { String key = (String)minibufferResult; ITextSelection selection = getImpliedSelection(editor, getCurrentSelection(editor)); IDocument document = getThisDocument(editor); // if called with ^U, then delete text as well boolean delete = isEditable() && getCallCount() > 1; String[] rect; // use widget to avoid unpleasant scrolling side effects of IRewriteTarget Control widget = getTextWidget(editor); IRewriteTarget rt = (IRewriteTarget) editor.getAdapter(IRewriteTarget.class); try { if (delete) { // wrap in compound change and no redraw widget.setRedraw(false); if (rt != null) { rt.beginCompoundChange(); } } rect = new RectangleSupport(document,editor).copyRectangle(editor, document, selection, delete); if (rect != null && rect.length > 0) { TecoRegister.getInstance().put(key,rect); showResultMessage(editor, String.format(COPIED, key), false); } } catch (BadLocationException e) { showResultMessage(editor, BAD_INSERT_LOCATION, true); } finally { if (rt != null) { rt.endCompoundChange(); } widget.setRedraw(true); } } else { showResultMessage(editor, NO_REGISTER, true); } return true; }
Example 8
Source File: BrowseKillRingHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Insert text from kill ring entry into the most recently activated text editor * * @param text - the text from the kill ring entry */ // @SuppressWarnings("restriction") // for cast to internal org.eclipse.ui.internal.WorkbenchWindow private void insertFromBrowseRing(String text) { // insert into most recently active editor IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); RecentEditor recent = getRecentEditor(); // use widget to avoid unpleasant scrolling side effects of IRewriteTarget Control widget = MarkUtils.getTextWidget(recent.editor); if (recent.editor != null) { try { // cache for ancillary computations setThisEditor(recent.editor); // reduce the amount of unnecessary work if (window instanceof WorkbenchWindow) { ((WorkbenchWindow) window).largeUpdateStart(); } widget.setRedraw(false); recent.page.activate(recent.epart); insertText(recent.editor.getDocumentProvider().getDocument(recent.editor.getEditorInput()), (ITextSelection)recent.editor.getSelectionProvider().getSelection(), text); } catch (Exception e) { } finally { widget.setRedraw(true); setThisEditor(null); if (window instanceof WorkbenchWindow) { ((WorkbenchWindow) window).largeUpdateEnd(); } } } else { beep(); } }
Example 9
Source File: AbstractSearchIndexResultPage.java From Pydev with Eclipse Public License 1.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void setInput(ISearchResult newSearch, Object viewState) { String filter = ""; if (viewState instanceof Tuple) { Tuple<Object, Object> tuple = (Tuple<Object, Object>) viewState; filter = (String) tuple.o2; viewState = tuple.o1; } StructuredViewer viewer = getViewer(); Control control = viewer.getControl(); control.setRedraw(false); try { viewer.setFilters(new ViewerFilter[0]); //Reset the filter before setting the new selection try { super.setInput(newSearch, viewState); } catch (Exception e) { Log.log(e); super.setInput(newSearch, null); } filterText.setText(filter); textChanged(); } finally { control.setRedraw(true); } }
Example 10
Source File: FilteredElementTreeSelectionDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected WorkbenchJob doCreateRefreshJob() { return new WorkbenchJob("Refresh Filter") {//$NON-NLS-1$ @Override public IStatus runInUIThread(IProgressMonitor monitor) { if (treeViewer.getControl().isDisposed()) { return Status.CANCEL_STATUS; } String text= getFilterString(); if (text == null) { return Status.OK_STATUS; } boolean initial= initialText != null && initialText.equals(text); if (initial) { getPatternFilter().setPattern(null); } else { getPatternFilter().setPattern(text); } Control redrawFalseControl= treeComposite != null ? treeComposite : treeViewer.getControl(); try { // don't want the user to see updates that will be made to // the tree // we are setting redraw(false) on the composite to avoid // dancing scrollbar redrawFalseControl.setRedraw(false); if (!narrowingDown) { // collapse all TreeItem[] is= treeViewer.getTree().getItems(); for (int i= 0; i < is.length; i++) { TreeItem item= is[i]; if (item.getExpanded()) { treeViewer.setExpandedState(item.getData(), false); } } } treeViewer.refresh(true); updateToolbar(text.length() > 0 && !initial); } finally { // done updating the tree - set redraw back to true TreeItem[] items= getViewer().getTree().getItems(); if (items.length > 0 && getViewer().getTree().getSelectionCount() == 0) { treeViewer.getTree().setTopItem(items[0]); } redrawFalseControl.setRedraw(true); } return Status.OK_STATUS; } }; }
Example 11
Source File: EmacsPlusCmdHandler.java From e4macs with Eclipse Public License 1.0 | 4 votes |
protected void setRedraw(Control c, boolean redraw) { if (c != null) { c.setRedraw(redraw); } }