/** * Returns the editor's vertical ruler, if it is a {@link CompositeRuler}, <code>null</code> * otherwise. * * @return the editor's {@link CompositeRuler} or <code>null</code> */ private CompositeRuler getRuler() { Object ruler= fEditor.getAdapter(IVerticalRulerInfo.class); if (ruler instanceof CompositeRuler) return (CompositeRuler) ruler; return null; }
/** * Returns the editor's vertical ruler, if it is a {@link CompositeRuler}, <code>null</code> * otherwise. * * @return the editor's {@link CompositeRuler} or <code>null</code> */ private CompositeRuler getRuler() { Object ruler= fEditor.getAdapter(IVerticalRulerInfo.class); if (ruler instanceof CompositeRuler) return (CompositeRuler) ruler; return null; }
/** * Returns the editor's vertical ruler, if it is a {@link CompositeRuler}, <code>null</code> * otherwise. * * @return the editor's {@link CompositeRuler} or <code>null</code> */ private CompositeRuler getRuler() { Object ruler= fEditor.getAdapter(IVerticalRulerInfo.class); if (ruler instanceof CompositeRuler) return (CompositeRuler) ruler; return null; }
/** * Sets the given message as error message to this editor's status line. * * @param message message to be set * @since 3.2 */ protected void setStatusLineErrorMessage(String message) { IEditorStatusLine statusLine= (IEditorStatusLine)getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(true, message, null); }
/** * Displays information in the status line why a line move is not possible */ private void showStatus() { IEditorStatusLine status= (IEditorStatusLine) fEditor.getAdapter(IEditorStatusLine.class); if (status == null) return; status.setMessage(false, EditorMessages.Editor_MoveLines_IllegalMove_status, null); }
/** * Sets the given message as message to this editor's status line. * * @param message message to be set * @since 3.2 */ protected void setStatusLineMessage(String message) { IEditorStatusLine statusLine= (IEditorStatusLine)getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(false, message, null); }
/** * Sets the given message as error message to this editor's status line. * * @param message message to be set * @since 3.2 */ protected void setStatusLineErrorMessage(String message) { IEditorStatusLine statusLine= getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(true, message, null); }
/** * Sets the given message as message to this editor's status line. * * @param message message to be set * @since 3.2 */ protected void setStatusLineMessage(String message) { IEditorStatusLine statusLine= getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(false, message, null); }
/** * Ends the compound change. */ private void endCompoundEdit() { if (!fEditInProgress || fEditor == null) return; IRewriteTarget target= (IRewriteTarget)fEditor.getAdapter(IRewriteTarget.class); if (target != null) { target.endCompoundChange(); } fEditInProgress= false; }
/** * Sets the given message as message to this editor's status line. * * @param message message to be set * @since 3.2 */ protected void setStatusLineMessage(String message) { IEditorStatusLine statusLine= getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(false, message, null); }
/** * Sets the given message as error message to this editor's status line. * * @param message message to be set * @since 3.2 */ protected void setStatusLineErrorMessage(String message) { IEditorStatusLine statusLine= getAdapter(IEditorStatusLine.class); if (statusLine != null) statusLine.setMessage(true, message, null); }
/** * Ends the compound change. */ private void beginCompoundEdit() { if (fEditInProgress || fEditor == null) return; fEditInProgress= true; fStrategy.arm(fEditor.getSourceViewer()); IRewriteTarget target= (IRewriteTarget)fEditor.getAdapter(IRewriteTarget.class); if (target != null) { target.beginCompoundChange(); } }
/** * Adds enabled ruler contributions to the vertical ruler. * <p> * Clients may extend or replace.</p> * * @param ruler the composite ruler to add contributions to * @since 3.3 */ protected void updateContributedRulerColumns(CompositeRuler ruler) { IColumnSupport support= getAdapter(IColumnSupport.class); if (support == null) return; RulerColumnPreferenceAdapter adapter= null; if (fPreferenceStore != null) adapter= new RulerColumnPreferenceAdapter(getPreferenceStore(), PREFERENCE_RULER_CONTRIBUTIONS); RulerColumnRegistry registry= RulerColumnRegistry.getDefault(); List<RulerColumnDescriptor> descriptors= registry.getColumnDescriptors(); for (Iterator<RulerColumnDescriptor> it= descriptors.iterator(); it.hasNext();) { final RulerColumnDescriptor descriptor= it.next(); support.setColumnVisible(descriptor, adapter == null || adapter.isEnabled(descriptor)); } }
/** * Adds enabled ruler contributions to the vertical ruler. * <p> * Clients may extend or replace.</p> * * @param ruler the composite ruler to add contributions to * @since 3.3 */ protected void updateContributedRulerColumns(CompositeRuler ruler) { IColumnSupport support= getAdapter(IColumnSupport.class); if (support == null) return; RulerColumnPreferenceAdapter adapter= null; if (fPreferenceStore != null) adapter= new RulerColumnPreferenceAdapter(getPreferenceStore(), PREFERENCE_RULER_CONTRIBUTIONS); RulerColumnRegistry registry= RulerColumnRegistry.getDefault(); List<RulerColumnDescriptor> descriptors= registry.getColumnDescriptors(); for (Iterator<RulerColumnDescriptor> it= descriptors.iterator(); it.hasNext();) { final RulerColumnDescriptor descriptor= it.next(); support.setColumnVisible(descriptor, adapter == null || adapter.isEnabled(descriptor)); } }
/** * Adds enabled ruler contributions to the vertical ruler. * <p> * Clients may extend or replace.</p> * * @param ruler the composite ruler to add contributions to * @since 3.3 */ protected void updateContributedRulerColumns(CompositeRuler ruler) { IColumnSupport support= (IColumnSupport)getAdapter(IColumnSupport.class); if (support == null) return; RulerColumnPreferenceAdapter adapter= null; if (fPreferenceStore != null) adapter= new RulerColumnPreferenceAdapter(getPreferenceStore(), PREFERENCE_RULER_CONTRIBUTIONS); RulerColumnRegistry registry= RulerColumnRegistry.getDefault(); List descriptors= registry.getColumnDescriptors(); for (Iterator it= descriptors.iterator(); it.hasNext();) { final RulerColumnDescriptor descriptor= (RulerColumnDescriptor) it.next(); support.setColumnVisible(descriptor, adapter == null || adapter.isEnabled(descriptor)); } }
@Override public void dragFinished(DragSourceEvent event) { try { if (event.detail == DND.DROP_MOVE && validateEditorInputState()) { Point newSelection= st.getSelection(); int length= fSelection.y - fSelection.x; int delta= 0; if (newSelection.x < fSelection.x) delta= length; st.replaceTextRange(fSelection.x + delta, length, ""); //$NON-NLS-1$ if (fTextDragAndDropToken == null) { // Move in same editor - end compound change IRewriteTarget target= getAdapter(IRewriteTarget.class); if (target != null) target.endCompoundChange(); } } } finally { fTextDragAndDropToken= null; } } });
@Override public void dragFinished(DragSourceEvent event) { try { if (event.detail == DND.DROP_MOVE && validateEditorInputState()) { Point newSelection= st.getSelection(); int length= fSelection.y - fSelection.x; int delta= 0; if (newSelection.x < fSelection.x) delta= length; st.replaceTextRange(fSelection.x + delta, length, ""); //$NON-NLS-1$ if (fTextDragAndDropToken == null) { // Move in same editor - end compound change IRewriteTarget target= getAdapter(IRewriteTarget.class); if (target != null) target.endCompoundChange(); } } } finally { fTextDragAndDropToken= null; } } });
/** * Initializes the drag and drop support for the given viewer based on * provided editor adapter for drop target listeners. * * @param viewer the viewer * @since 3.0 */ protected void initializeDragAndDrop(ISourceViewer viewer) { IDragAndDropService dndService= (IDragAndDropService)getSite().getService(IDragAndDropService.class); if (dndService == null) return; ITextEditorDropTargetListener listener= (ITextEditorDropTargetListener) getAdapter(ITextEditorDropTargetListener.class); if (listener == null) { Object object= Platform.getAdapterManager().loadAdapter(this, "org.eclipse.ui.texteditor.ITextEditorDropTargetListener"); //$NON-NLS-1$ if (object instanceof ITextEditorDropTargetListener) listener= (ITextEditorDropTargetListener)object; } if (listener != null) dndService.addMergedDropTarget(viewer.getTextWidget(), DND.DROP_MOVE | DND.DROP_COPY, listener.getTransfers(), listener); IPreferenceStore store= getPreferenceStore(); if (store != null && store.getBoolean(PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED)) installTextDragAndDrop(viewer); }
/** * Initializes the drag and drop support for the given viewer based on * provided editor adapter for drop target listeners. * * @param viewer the viewer * @since 3.0 */ protected void initializeDragAndDrop(ISourceViewer viewer) { IDragAndDropService dndService= getSite().getService(IDragAndDropService.class); if (dndService == null) return; ITextEditorDropTargetListener listener= getAdapter(ITextEditorDropTargetListener.class); if (listener == null) { Object object= Platform.getAdapterManager().loadAdapter(this, "org.eclipse.ui.texteditor.ITextEditorDropTargetListener"); //$NON-NLS-1$ if (object instanceof ITextEditorDropTargetListener) listener= (ITextEditorDropTargetListener)object; } if (listener != null) dndService.addMergedDropTarget(viewer.getTextWidget(), DND.DROP_MOVE | DND.DROP_COPY, listener.getTransfers(), listener); IPreferenceStore store= getPreferenceStore(); if (store != null && store.getBoolean(PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED)) installTextDragAndDrop(viewer); }
/** * Initializes the drag and drop support for the given viewer based on * provided editor adapter for drop target listeners. * * @param viewer the viewer * @since 3.0 */ protected void initializeDragAndDrop(ISourceViewer viewer) { IDragAndDropService dndService= getSite().getService(IDragAndDropService.class); if (dndService == null) return; ITextEditorDropTargetListener listener= getAdapter(ITextEditorDropTargetListener.class); if (listener == null) { Object object= Platform.getAdapterManager().loadAdapter(this, "org.eclipse.ui.texteditor.ITextEditorDropTargetListener"); //$NON-NLS-1$ if (object instanceof ITextEditorDropTargetListener) listener= (ITextEditorDropTargetListener)object; } if (listener != null) dndService.addMergedDropTarget(viewer.getTextWidget(), DND.DROP_MOVE | DND.DROP_COPY, listener.getTransfers(), listener); IPreferenceStore store= getPreferenceStore(); if (store != null && store.getBoolean(PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED)) installTextDragAndDrop(viewer); }