Package org.eclipse.jface.text.source

Examples of org.eclipse.jface.text.source.SourceViewer


    @SuppressWarnings("unchecked")
    @Override
    protected void configureTextViewer(TextViewer textViewer) {
        if (!(textViewer instanceof SourceViewer))
            return;
        final SourceViewer sourceViewer = (SourceViewer) textViewer;

        final IIndentPrefs indentPrefs = new DefaultIndentPrefs();

        //Hack to provide the source viewer configuration that'll only be created later (there's a cycle there).
        final WeakReference<PyEditConfigurationWithoutEditor>[] sourceViewerConfigurationObj = new WeakReference[1];

        IPreferenceStore chainedPrefStore = PydevPrefs.getChainedPrefStore();
        final ColorAndStyleCache c = new ColorAndStyleCache(chainedPrefStore);
        this.getColorCache().add(c); //add for it to be disposed later.

        IPySyntaxHighlightingAndCodeCompletionEditor editor = new IPySyntaxHighlightingAndCodeCompletionEditor() {

            public void resetForceTabs() {

            }

            public void resetIndentPrefixes() {
                SourceViewerConfiguration configuration = getEditConfiguration();
                String[] types = configuration.getConfiguredContentTypes(sourceViewer);
                for (int i = 0; i < types.length; i++) {
                    String[] prefixes = configuration.getIndentPrefixes(sourceViewer, types[i]);
                    if (prefixes != null && prefixes.length > 0)
                        sourceViewer.setIndentPrefixes(prefixes, types[i]);
                }
            }

            public IIndentPrefs getIndentPrefs() {
                return indentPrefs;
            }

            public ISourceViewer getEditorSourceViewer() {
                return sourceViewer;
            }

            public PyEditConfigurationWithoutEditor getEditConfiguration() {
                return sourceViewerConfigurationObj[0].get();
            }

            public ColorAndStyleCache getColorCache() {
                return c;
            }

            public PySelection createPySelection() {
                ISelection selection = sourceViewer.getSelection();
                if (selection instanceof ITextSelection) {
                    return new PySelection(sourceViewer.getDocument(), (ITextSelection) selection);
                } else {
                    return null;
                }
            }

            public File getEditorFile() {
                IResource file = PyMergeViewer.this.getResource(PyMergeViewer.this.getInput());
                if (file != null && file instanceof IFile) {
                    IPath path = file.getLocation().makeAbsolute();
                    return path.toFile();
                }
                return null;
            }

            public IPythonNature getPythonNature() throws MisconfigurationException {
                return PyMergeViewer.this.getPythonNature(PyMergeViewer.this.getInput());
            }

            public Object getAdapter(Class adapter) {
                if (adapter == IResource.class) {
                    return PyMergeViewer.this.getResource(PyMergeViewer.this.getInput());
                }
                if (adapter == IFile.class) {
                    IResource resource = PyMergeViewer.this.getResource(PyMergeViewer.this.getInput());
                    if (resource instanceof IFile) {
                        return resource;
                    }
                }
                return null;
            }
        };

        final PyEditConfiguration sourceViewerConfiguration = new PyEditConfiguration(c, editor, chainedPrefStore);
        sourceViewerConfigurationObj[0] = new WeakReference<PyEditConfigurationWithoutEditor>(sourceViewerConfiguration);
        sourceViewer.configure(sourceViewerConfiguration);

        IPropertyChangeListener prefChangeListener = PyEdit.createPrefChangeListener(editor);
        getPrefChangeListeners().add(prefChangeListener);
        chainedPrefStore.addPropertyChangeListener(prefChangeListener);
    }
View Full Code Here


      int styles) {
    super(parent, styles);
    setLayout(new FillLayout());

    AnnotationModel annotationModel = new AnnotationModel();
    sourceViewer = new SourceViewer(this, null, null, true, SWT.MULTI
        | SWT.V_SCROLL | SWT.WRAP);
    getTextWidget().setAlwaysShowScrollBars(false);
    getTextWidget().setFont(UIUtils
        .getFont(UIPreferences.THEME_CommitMessageEditorFont));
View Full Code Here

    ((GridLayout) sampleArea.getLayout()).marginLeft = 5;
    ((GridLayout) sampleArea.getLayout()).marginTop = 5;
    createLabel(sampleArea, SSEUIMessages.Sample_text__UI_); // =
                                  // "&Sample text:"
    SourceViewer viewer = new SourceViewer(sampleArea, null, SWT.BORDER
        | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL
        | SWT.READ_ONLY);
    fText = viewer.getTextWidget();
    GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData3.widthHint = convertWidthInCharsToPixels(20);
    gridData3.heightHint = convertHeightInCharsToPixels(5);
    gridData3.horizontalSpan = 2;
    fText.setLayoutData(gridData3);
    fText.setEditable(false);
    fText.setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$
    fText.addKeyListener(getTextKeyListener());
    fText.addSelectionListener(getTextSelectionListener());
    fText.addMouseListener(getTextMouseListener());
    fText.addTraverseListener(getTraverseListener());

    final IPreferenceStore editorStore = EditorsPlugin.getDefault()
        .getPreferenceStore();
    fText.setBackground(editorStore
        .getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null
        : new Color(fText.getDisplay(), PreferenceConverter.getColor(
            editorStore,
            AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)));
    setAccessible(fText, SSEUIMessages.Sample_text__UI_);
    fDocument = StructuredModelManager.getModelManager()
        .createStructuredDocumentFor(
            ContentTypeIdForPHP.ContentTypeID_PHP);
    fDocument.set(getExampleText());
    viewer.setDocument(fDocument);

    top.setWeights(new int[] { 2, 1 });
    editor.setWeights(new int[] { 1, 1 });
    PlatformUI
        .getWorkbench()
View Full Code Here

  private SourceViewer createEditor(Composite parent) {
    String prefix = getPrefix();
    IDocument document = new Document(prefix + fTemplate.getPattern());

    SourceViewer viewer = createViewer(parent);

    viewer.setEditable(true);
    viewer.setDocument(document, prefix.length(), document.getLength()
        - prefix.length());

    // Font font=
    // JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    // viewer.getTextWidget().setFont(font);
    // new PHPSourcePreviewerUpdater(viewer, configuration, store);

    int nLines = document.getNumberOfLines();
    if (nLines < 5) {
      nLines = 5;
    } else if (nLines > 12) {
      nLines = 12;
    }

    Control control = viewer.getControl();
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = convertWidthInCharsToPixels(80);
    data.heightHint = convertHeightInCharsToPixels(nLines);
    control.setLayoutData(data);

    viewer.addTextListener(new ITextListener() {
      public void textChanged(TextEvent event) {
        if (event.getDocumentEvent() != null)
          doSourceChanged(event.getDocumentEvent().getDocument());
      }
    });

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
      public void selectionChanged(SelectionChangedEvent event) {
        updateSelectionDependentActions();
      }
    });
View Full Code Here

   * @param parent
   *            the parent composite of the viewer
   * @return a configured <code>SourceViewer</code>
   */
  protected SourceViewer createViewer(Composite parent) {
    SourceViewer viewer = new SourceViewer(parent, null, null, false,
        SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    SourceViewerConfiguration configuration = new SourceViewerConfiguration() {
      public IContentAssistant getContentAssistant(
          ISourceViewer sourceViewer) {

        ContentAssistant assistant = new ContentAssistant();
        assistant.enableAutoActivation(true);
        assistant.enableAutoInsert(true);
        assistant.setContentAssistProcessor(fTemplateProcessor,
            IDocument.DEFAULT_CONTENT_TYPE);
        return assistant;
      }
    };
    viewer.configure(configuration);
    return viewer;
  }
View Full Code Here

      super(parent, template, edit, isNameModifiable, registry);
    }

    @Override
    protected SourceViewer createViewer(Composite parent) {
      SourceViewer viewer = new SourceViewer(parent, null, null, false,
          SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
      SourceViewerConfiguration configuration = new SourceViewerConfiguration() {
        public IContentAssistant getContentAssistant(
            ISourceViewer sourceViewer) {

          ContentAssistant assistant = new ContentAssistant();
          assistant.enableAutoActivation(true);
          assistant.enableAutoInsert(true);
          assistant.setContentAssistProcessor(getTemplateProcessor(),
              IDocument.DEFAULT_CONTENT_TYPE);
          assistant.setProposalSelectorBackground(Display
              .getCurrent().getSystemColor(
                  SWT.COLOR_INFO_BACKGROUND));
          return assistant;
        }
      };
      viewer.configure(configuration);
      return viewer;
    }
View Full Code Here

      composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
      composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    }

    // Source viewer
    fViewer= new SourceViewer(composite, null, textStyle);
    fViewer.configure(new SourceViewerConfiguration());
    fViewer.setEditable(false);

    fText= fViewer.getTextWidget();
    gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
View Full Code Here

    protected Point getInitialSize() {
        return new Point(600, 450);
    }

    private Control createTextualEditor(Composite parent) {
        globalsViewer = new SourceViewer(parent, null, SWT.BORDER);
        globalsViewer.configure(new DRLSourceViewerConfig(null) {
            public IReconciler getReconciler(ISourceViewer sourceViewer) {
                return null;
            }
            public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
View Full Code Here

    protected Point getInitialSize() {
        return new Point(600, 450);
    }

    private Control createTextualEditor(Composite parent) {
        constraintViewer = new SourceViewer(parent, null, SWT.BORDER);
        constraintViewer.configure(new DRLSourceViewerConfig(null) {
            public IReconciler getReconciler(ISourceViewer sourceViewer) {
                return null;
            }
            public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
View Full Code Here

    protected Point getInitialSize() {
        return new Point(600, 450);
    }

    private Control createTextualEditor(Composite parent) {
        importsViewer = new SourceViewer(parent, null, SWT.BORDER);
        importsViewer.configure(new DRLSourceViewerConfig(null) {
            public IReconciler getReconciler(ISourceViewer sourceViewer) {
                return null;
            }
            public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.source.SourceViewer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.