org.eclipse.jface.text.source.projection.ProjectionViewer Java Examples
The following examples show how to use
org.eclipse.jface.text.source.projection.ProjectionViewer.
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: JavaScriptLightWeightEditor.java From typescript.java with MIT License | 6 votes |
/** * Install everything necessary to get document folding working and enable * document folding * * @param sourceViewer */ private void installProjectionSupport() { ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer(); fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors()); fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$ fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$ fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { return new DefaultInformationControl(parent); } }); fProjectionSupport.install(); if (isFoldingEnabled()) { projectionViewer.doOperation(ProjectionViewer.TOGGLE); } }
Example #2
Source File: PyEditProjection.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override public void createPartControl(Composite parent) { super.createPartControl(parent); try { ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer(); fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors()); fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() { @Override public IInformationControl createInformationControl(Shell shell) { return new DefaultInformationControl(shell); } }); fProjectionSupport.install(); if (isFoldingEnabled()) { projectionViewer.doOperation(ProjectionViewer.TOGGLE); } } catch (Exception e) { Log.log(e); } }
Example #3
Source File: RepositionHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * A semi-hack... This uses stuff that may change at any time in Eclipse. * In the java editor, the projection annotation model contains the collapsible regions which correspond to methods (and other areas * such as import groups). * * This may work in other editor types as well... TBD */ protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection, ExecutionEvent event) throws BadLocationException { ITextViewerExtension viewer = MarkUtils.getITextViewer(editor); if (viewer instanceof ProjectionViewer) { ProjectionAnnotationModel projection = ((ProjectionViewer)viewer).getProjectionAnnotationModel(); Iterator<Annotation> pit = projection.getAnnotationIterator(); while (pit.hasNext()) { Position p = projection.getPosition(pit.next()); if (p.includes(currentSelection.getOffset())) { if (isUniversalPresent()) { // Do this here to prevent subsequent scrolling once range is revealed MarkUtils.setSelection(editor, new TextSelection(document, p.offset, 0)); } // the viewer is pretty much guaranteed to be a TextViewer if (viewer instanceof TextViewer) { ((TextViewer)viewer).revealRange(p.offset, p.length); } break; } } } return NO_OFFSET; }
Example #4
Source File: DecoratedScriptEditor.java From birt with Eclipse Public License 1.0 | 6 votes |
protected ISourceViewer createSourceViewer( Composite parent, IVerticalRuler ruler, int styles ) { fAnnotationAccess = getAnnotationAccess( ); fOverviewRuler = createOverviewRuler( getSharedColors( ) ); ProjectionViewer viewer = new ProjectionViewer( parent, ruler, getOverviewRuler( ), isOverviewRulerVisible( ), styles ); ProjectionSupport fProjectionSupport = new ProjectionSupport( viewer, getAnnotationAccess( ), getSharedColors( ) ); fProjectionSupport.addSummarizableAnnotationType( "org.eclipse.ui.workbench.texteditor.error" ); //$NON-NLS-1$ fProjectionSupport.addSummarizableAnnotationType( "org.eclipse.ui.workbench.texteditor.warning" ); //$NON-NLS-1$ fProjectionSupport.install( ); // Ensures source viewer decoration support has been created and // configured. getSourceViewerDecorationSupport( viewer ); return viewer; }
Example #5
Source File: DecoratedScriptEditor.java From birt with Eclipse Public License 1.0 | 6 votes |
public void createPartControl( Composite parent ) { if ( input != null ) { setInput( input ); } super.createPartControl( parent ); ISourceViewer viewer = getViewer( ); if ( viewer instanceof ProjectionViewer ) { // Turn projection mode on. ( (ProjectionViewer) viewer ).doOperation( ProjectionViewer.TOGGLE ); } // bidi_hcg: Force LTR orientation of the StyledText widget getSourceViewer( ).getTextWidget( ).setOrientation( SWT.LEFT_TO_RIGHT ); }
Example #6
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected void performRevert() { ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer(); projectionViewer.setRedraw(false); try { boolean projectionMode= projectionViewer.isProjectionMode(); if (projectionMode) { projectionViewer.disableProjection(); if (fProjectionModelUpdater != null) fProjectionModelUpdater.uninstall(); } super.performRevert(); if (projectionMode) { if (fProjectionModelUpdater != null) fProjectionModelUpdater.install(this, projectionViewer); projectionViewer.enableProjection(); } } finally { projectionViewer.setRedraw(true); } }
Example #7
Source File: XbaseEditor.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override protected void handlePreferenceStoreChanged(PropertyChangeEvent event) { super.handlePreferenceStoreChanged(event); String property = event.getProperty(); if (property.equals(org.eclipse.jdt.ui.PreferenceConstants.EDITOR_FOLDING_ENABLED)) { ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer(); if (event.getNewValue() != null && Boolean.valueOf(event.getNewValue().toString())) { if (!projectionViewer.isProjectionMode()) { installFoldingSupport(projectionViewer); } } else { if (projectionViewer.isProjectionMode()) { uninstallFoldingSupport(); projectionViewer.disableProjection(); } } } }
Example #8
Source File: BibEditor.java From texlipse with Eclipse Public License 1.0 | 6 votes |
public void createPartControl(Composite parent) { super.createPartControl(parent); ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer(); fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors()); fProjectionSupport .addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); fProjectionSupport .addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); fProjectionSupport.install(); if (TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.BIB_CODE_FOLDING)) { projectionViewer.doOperation(ProjectionViewer.TOGGLE); } this.documentModel.update(); }
Example #9
Source File: FoldingActionsGroup.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Constructs a new FoldingActionsGroup with a given text editor. * * @param textEditor */ public FoldingActionsGroup(ITextEditor textEditor) { // Initialize the actions. collapseAction = new TextOperationAction(Messages.getResourceBundle(), "Folding.Collapse.", textEditor, ProjectionViewer.COLLAPSE, true); //$NON-NLS-1$ collapseAction.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE); textEditor.setAction(IFoldingCommandIds.FOLDING_COLLAPSE, collapseAction); expandAction = new TextOperationAction(Messages.getResourceBundle(), "Folding.Expand.", textEditor, ProjectionViewer.EXPAND, true); //$NON-NLS-1$ expandAction.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND); textEditor.setAction(IFoldingCommandIds.FOLDING_EXPAND, expandAction); collapseAllAction = new TextOperationAction(Messages.getResourceBundle(), "Folding.CollapseAll.", textEditor, ProjectionViewer.COLLAPSE_ALL, true); //$NON-NLS-1$ collapseAllAction.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE_ALL); textEditor.setAction(IFoldingCommandIds.FOLDING_COLLAPSE_ALL, collapseAllAction); expandAllAction = new TextOperationAction(Messages.getResourceBundle(), "Folding.ExpandAll.", textEditor, ProjectionViewer.EXPAND_ALL, true); //$NON-NLS-1$ expandAllAction.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND_ALL); textEditor.setAction(IFoldingCommandIds.FOLDING_EXPAND_ALL, expandAllAction); }
Example #10
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Does the actual toggling of projection. */ private void toggleFolding() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer instanceof ProjectionViewer) { ProjectionViewer pv= (ProjectionViewer) sourceViewer; if (pv.isProjectionMode() != isFoldingEnabled()) { if (pv.canDoOperation(ProjectionViewer.TOGGLE)) pv.doOperation(ProjectionViewer.TOGGLE); } } }
Example #11
Source File: TypeScriptDocumentRegionProcessor.java From typescript.java with MIT License | 5 votes |
protected IReconcilingStrategy getTypeScriptFoldingStrategy() { if ("org.eclipse.wst.jsdt.core.jsSource".equals(contentType)) { return super.getFoldingStrategy(); } if (foldingStrategy == null) { ITextViewer viewer = getTextViewer(); if (viewer instanceof ProjectionViewer) { foldingStrategy = new TypeScriptFoldingStrategy(); foldingStrategy.setViewer((ProjectionViewer) viewer); foldingStrategy.setDocument(getDocument()); } } return foldingStrategy; }
Example #12
Source File: XtextSourceViewerEx.java From statecharts with Eclipse Public License 1.0 | 5 votes |
/** * Set the private fHandleProjectionChanges field value. * * @param value * the new value. */ protected void setPrivateHandleProjectionChangesField(boolean value) { try { Field declaredField = ProjectionViewer.class .getDeclaredField("fHandleProjectionChanges"); declaredField.setAccessible(true); declaredField.set(this, value); } catch (Exception e) { e.printStackTrace(); } }
Example #13
Source File: JsonEditor.java From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 | 5 votes |
@Override public void createPartControl(Composite parent) { super.createPartControl(parent); ProjectionViewer viewer = getProjectionViewer(); projectionSupport = new ProjectionSupport(viewer, getAnnotationAccess(), getSharedColors()); projectionSupport.install(); // turn projection mode on viewer.doOperation(ProjectionViewer.TOGGLE); annotationModel = viewer.getProjectionAnnotationModel(); getPreferenceStore().addPropertyChangeListener(preferenceChangeListener); }
Example #14
Source File: GamlEditor.java From gama with GNU General Public License v3.0 | 5 votes |
@Override protected void installFoldingSupport(final ProjectionViewer projectionViewer) { super.installFoldingSupport(projectionViewer); if (!isRangeIndicatorEnabled()) { projectionViewer.doOperation(ProjectionViewer.TOGGLE); } }
Example #15
Source File: GamaFoldingActionGroup.java From gama with GNU General Public License v3.0 | 5 votes |
GamaFoldingActionGroup(final ITextEditor editor, final ITextViewer viewer) { super(editor, viewer); if (!(viewer instanceof ProjectionViewer)) { return; } this.pViewer = (ProjectionViewer) viewer; collapseStrings = new FoldingAction() { // $NON-NLS-1$ // private final EClass type = GamlPackage. @Override public void run() { final ProjectionAnnotationModel model = pViewer.getProjectionAnnotationModel(); final Iterator<?> iterator = model.getAnnotationIterator(); final List<Annotation> toCollapse = new ArrayList<>(); while (iterator.hasNext()) { final Object next = iterator.next(); if (next instanceof ProjectionAnnotation) { final ProjectionAnnotation pa = (ProjectionAnnotation) next; final Position position = model.getPosition(pa); if (position instanceof TypedFoldedPosition) { if (((TypedFoldedPosition) position).getType().equals("__comment")) { pa.markCollapsed(); toCollapse.add(pa); } } } } model.modifyAnnotations(null, null, toCollapse.toArray(new Annotation[0])); } }; collapseStrings.setActionDefinitionId("org.xtext.example.folding.ui.folding.collapseStrings"); editor.setAction("FoldingCollapseStrings", collapseStrings); //$NON-NLS-1$ }
Example #16
Source File: AbstractFoldingEditor.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void createPartControl(Composite parent) { super.createPartControl(parent); ProjectionViewer viewer = (ProjectionViewer) getSourceViewer(); ProjectionSupport projectionSupport = new ProjectionSupport(viewer, getAnnotationAccess(), getSharedColors()); projectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$ projectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$ projectionSupport.install(); viewer.doOperation(ProjectionViewer.TOGGLE); }
Example #17
Source File: AbstractFoldingEditor.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected ProjectionAnnotationModel getAnnotationModel() { ISourceViewer viewer = getSourceViewer(); if (viewer instanceof ProjectionViewer) { return ((ProjectionViewer) viewer).getProjectionAnnotationModel(); } return null; }
Example #18
Source File: DefaultJavaFoldingStructureProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} * <p> * Subclasses may extend. * </p> * * @param editor {@inheritDoc} * @param viewer {@inheritDoc} */ public void install(ITextEditor editor, ProjectionViewer viewer) { Assert.isLegal(editor != null); Assert.isLegal(viewer != null); internalUninstall(); if (editor instanceof JavaEditor) { fProjectionListener= new ProjectionListener(viewer); fEditor= (JavaEditor)editor; } }
Example #19
Source File: AbstractSourceColoringConfigurationBlock.java From goclipse with Eclipse Public License 1.0 | 5 votes |
protected ProjectionViewer createPreviewViewer(Composite parent, boolean showAnnotationsOverview, int styles, IPreferenceStore store) { LangSourceViewer sourceViewer = new LangSourceViewer(parent, null, null, showAnnotationsOverview, styles); ColorManager2 colorManager = new ColorManager2(); sourceViewer.addOwned(colorManager); SimpleSourceViewerConfiguration configuration = createSimpleSourceViewerConfig(store, colorManager); sourceViewer.configure(configuration); return sourceViewer; }
Example #20
Source File: DecoratedScriptEditor.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Set the specified action enabled. * * @param action * the specified action to set enable. */ private void enableAction( IAction action ) { if ( action instanceof IUpdate ) { ( (IUpdate) action ).update( ); } else { ISourceViewer viewer = getViewer( ); action.setEnabled( viewer instanceof ProjectionViewer ? ( (ProjectionViewer) viewer ).isProjectionMode( ) : true ); } }
Example #21
Source File: DecoratedScriptEditor.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Collapses all item with the specified style. * * @param style * the style to collapse */ private void collapseStyle( int style ) { ISourceViewer viewer = getViewer( ); if ( !( viewer instanceof ProjectionViewer ) ) { return; } ProjectionAnnotationModel model = ( (ProjectionViewer) viewer ).getProjectionAnnotationModel( ); if ( model == null ) { return; } List modified = new ArrayList( ); Iterator iter = model.getAnnotationIterator( ); while ( iter.hasNext( ) ) { Object annotation = iter.next( ); if ( annotation instanceof ScriptProjectionAnnotation ) { ScriptProjectionAnnotation scriptAnnotation = (ScriptProjectionAnnotation) annotation; if ( !scriptAnnotation.isCollapsed( ) && scriptAnnotation.isStyle( style ) ) { scriptAnnotation.markCollapsed( ); modified.add( scriptAnnotation ); } } } model.modifyAnnotations( null, null, (Annotation[]) modified.toArray( new Annotation[modified.size( )] ) ); }
Example #22
Source File: AbstractSourceColoringConfigurationBlock.java From goclipse with Eclipse Public License 1.0 | 5 votes |
protected Control createPreviewViewer(Composite topControl) { IPreferenceStore store = LangUIPlugin.getInstance().getCombinedPreferenceStore(); ProjectionViewer fPreviewViewer = this.createPreviewViewer(topControl, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store); fPreviewViewer.setEditable(false); IDocument document = new Document(getPreviewContent()); LangDocumentPartitionerSetup.getInstance().setup(document); fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); }
Example #23
Source File: XtextEditor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void createPartControl(Composite parent) { super.createPartControl(parent); ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer(); projectionSupport = installProjectionSupport(projectionViewer); installFoldingSupport(projectionViewer); installHighlightingHelper(); installSelectionChangedListener(); initializeDirtyStateSupport(); callback.afterCreatePartControl(this); }
Example #24
Source File: TLAEditor.java From tlaplus with MIT License | 5 votes |
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { ProjectionViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles); // ensure decoration support has been created and configured. // @see org.eclipse.ui.texteditor.ExtendedTextEditor#createSourceViewer getSourceViewerDecorationSupport(viewer); return viewer; }
Example #25
Source File: AbstractEditorTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private XtextEditor getXtextEditor(IEditorPart openEditor) throws NoSuchFieldException, IllegalAccessException { XtextEditor xtextEditor = EditorUtils.getXtextEditor(openEditor); if (xtextEditor != null) { ISourceViewer sourceViewer = xtextEditor.getInternalSourceViewer(); ((ProjectionViewer) sourceViewer).doOperation(ProjectionViewer.EXPAND_ALL); return xtextEditor; } else if (openEditor instanceof ErrorEditorPart) { Field field = openEditor.getClass().getDeclaredField("error"); field.setAccessible(true); throw new IllegalStateException("Couldn't open the editor.", ((Status) field.get(openEditor)).getException()); } else { fail("Opened Editor with id:" + getEditorId() + ", is not an XtextEditor"); } return null; }
Example #26
Source File: BibEditor.java From texlipse with Eclipse Public License 1.0 | 5 votes |
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { fOverviewRuler = createOverviewRuler(getSharedColors()); ISourceViewer viewer = new ProjectionViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles); // ensure decoration support has been created and configured. getSourceViewerDecorationSupport(viewer); return viewer; }
Example #27
Source File: TexEditor.java From texlipse with Eclipse Public License 1.0 | 5 votes |
/** * Create the part control. * * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ public void createPartControl(Composite parent) { super.createPartControl(parent); // enable projection support (for code folder) ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer(); fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors()); fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); fProjectionSupport.install(); if (TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.CODE_FOLDING)) { projectionViewer.doOperation(ProjectionViewer.TOGGLE); } fAnnotationUpdater = new TexlipseAnnotationUpdater(this); ((IPostSelectionProvider) getSelectionProvider()).addPostSelectionChangedListener( new ISelectionChangedListener(){ public void selectionChanged(SelectionChangedEvent event) { //Delete all StatuslineErrors after selection changes documentModel.removeStatusLineErrorMessage(); } }); // register documentModel as documentListener // in initializeEditor this would cause NPE this.getDocumentProvider().getDocument(getEditorInput()).addDocumentListener(this.documentModel); this.documentModel.initializeModel(); this.documentModel.updateNow(); ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer instanceof ITextViewerExtension) { if (fBracketInserter == null) fBracketInserter = new BracketInserter(getSourceViewer(), this); ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter); } }
Example #28
Source File: XbaseFoldingActionContributor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void contributeActions(XtextEditor xtextEditor) { foldingActionGroup = new FoldingActionGroup(xtextEditor, xtextEditor.getInternalSourceViewer()) { @Override protected TextEditorAction createToggleFoldingAction(ITextEditor editor) { TextEditorAction toggle = new ResourceActionExtension(FoldingMessages.getResourceBundle(), "Projection.Toggle.", editor, ProjectionViewer.TOGGLE); toggle.setChecked(true); toggle.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE); return toggle; } }; }
Example #29
Source File: DefaultFoldingStructureProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void install(XtextEditor editor, ProjectionViewer viewer) { Assert.isNotNull(editor); Assert.isNotNull(viewer); uninstall(); this.editor = editor; this.viewer = viewer; projectionListener = new ProjectionChangeListener(viewer); }
Example #30
Source File: TLAEditor.java From tlaplus with MIT License | 5 votes |
@Override public void createPartControl(final Composite parent) { super.createPartControl(parent); /* * Add projection support (i.e. for folding) */ final ProjectionViewer viewer = (ProjectionViewer) getSourceViewer(); projectionSupport = new ProjectionSupport(viewer, getAnnotationAccess(), getSharedColors()); projectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$ projectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$ projectionSupport.install(); if (viewer.canDoOperation(ProjectionViewer.TOGGLE)) { viewer.doOperation(ProjectionViewer.TOGGLE); } // model for adding projections (folds) annotationModel = viewer.getProjectionAnnotationModel(); // this must be instantiated after annotationModel so that it does // not call methods that use annotation model when the model is still null proofStructureProvider = new TLAProofFoldingStructureProvider(this); // refresh the editor in case it should be // read only refresh(); // tlapmColoring = new TLAPMColoringOutputListener(this); service = this.getSite().getService(IEventBroker.class); }