Java Code Examples for org.eclipse.ui.editors.text.EditorsUI

The following examples show how to use org.eclipse.ui.editors.text.EditorsUI. These examples are extracted from open source projects. 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
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
	String tooltipAffordanceString = EditorsUI
			.getTooltipAffordanceString();
	if (BrowserInformationControl.isAvailable(parent)) {
		String font = "org.eclipse.jdt.ui.javadocfont";
		BrowserInformationControl iControl = new BrowserInformationControl(
				parent, font, false) {
			@Override
			public IInformationControlCreator getInformationPresenterControlCreator() {
				return fInformationPresenterControlCreator;
			}
		};
		addLinkListener(iControl);
		return iControl;
	} else {
		return new DefaultInformationControl(parent,
				tooltipAffordanceString);
	}
}
 
Example 2
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
	String tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
	if (BrowserInformationControl.isAvailable(parent)) {
		String font = "org.eclipse.jdt.ui.javadocfont"; // FIXME: PreferenceConstants.APPEARANCE_JAVADOC_FONT;
		IXtextBrowserInformationControl iControl = new XtextBrowserInformationControl(parent, font,
				tooltipAffordanceString) {
			/*
			 * @see org.eclipse.jface.text.IInformationControlExtension5#getInformationPresenterControlCreator()
			 */
			@Override
			public IInformationControlCreator getInformationPresenterControlCreator() {
				return fInformationPresenterControlCreator;
			}
		};
		addLinkListener(iControl);
		return iControl;
	} else {
		return new DefaultInformationControl(parent, tooltipAffordanceString);
	}
}
 
Example 3
Source Project: birt   Source File: DecoratedScriptEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Constructs a decorated script editor with the specified parent and the
 * specified script.
 * 
 * @param parent
 *            the parent editor.
 * @param script
 *            the script to edit
 */
public DecoratedScriptEditor( IEditorPart parent, String script )
{
	super( );
	this.parent = parent;
	this.sourceViewerConfiguration = new ScriptSourceViewerConfiguration( context );
	setSourceViewerConfiguration( this.sourceViewerConfiguration );
	setDocumentProvider( new ScriptDocumentProvider( parent ) );
	setScript( script );

	IPreferences preferences = PreferenceFactory.getInstance( )
			.getPreferences( ReportPlugin.getDefault( ) );
	if ( preferences instanceof PreferenceWrapper )
	{
		IPreferenceStore store = ( (PreferenceWrapper) preferences ).getPrefsStore( );
		if ( store != null )
		{
			IPreferenceStore baseEditorPrefs = EditorsUI.getPreferenceStore();
			setPreferenceStore( new ChainedPreferenceStore(new IPreferenceStore[]{store, baseEditorPrefs}) );
		}
	}
}
 
Example 4
Source Project: xtext-eclipse   Source File: XbaseHoverProvider.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
	String tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
	if (BrowserInformationControl.isAvailable(parent)) {
		String font = "org.eclipse.jdt.ui.javadocfont";
		IXtextBrowserInformationControl iControl = new XbaseInformationControl(parent, font,
				tooltipAffordanceString, xbaseHoverConfiguration) {
			@Override
			public IInformationControlCreator getInformationPresenterControlCreator() {
				return fInformationPresenterControlCreator;
			}
		};
		addLinkListener(iControl);
		return iControl;
	} else {
		return new DefaultInformationControl(parent, tooltipAffordanceString);
	}
}
 
Example 5
Source Project: xds-ide   Source File: SpellCheckEngine.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a new spell check manager.
 */
private SpellCheckEngine() {

	try {

		Locale locale= null;
		final Enumeration<URL> locations= getDictionaryLocations();

		while (locations != null && locations.hasMoreElements()) {
			URL location= locations.nextElement();

			for (final Iterator<Locale> iterator= getLocalesWithInstalledDictionaries(location).iterator(); iterator.hasNext();) {

				locale= iterator.next();
				fLocaleDictionaries.put(locale, new LocaleSensitiveSpellDictionary(locale, location));
			}
		}

	} catch (IOException exception) {
		// Do nothing
	}
	
	PreferenceKeys.PKEY_SPELLING_LOCALE.addChangeListener(this);
	EditorsUI.getPreferenceStore().addPropertyChangeListener(this);
}
 
Example 6
Source Project: xds-ide   Source File: SpellCheckEngine.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public synchronized final void shutdown() {

	    PreferenceKey.removeChangeListener(PreferenceKeys.PKEY_SPELLING_LOCALE.getQualifier(), this);
		EditorsUI.getPreferenceStore().removePropertyChangeListener(this);

		ISpellDictionary dictionary= null;
		for (final Iterator<ISpellDictionary> iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) {
			dictionary= iterator.next();
			dictionary.unload();
		}
		fGlobalDictionaries= null;

		for (final Iterator<ISpellDictionary> iterator= fLocaleDictionaries.values().iterator(); iterator.hasNext();) {
			dictionary= iterator.next();
			dictionary.unload();
		}
		fLocaleDictionaries= null;

		fUserDictionary= null;
		fChecker= null;
	}
 
Example 7
Source Project: goclipse   Source File: AbstractLangEditor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
protected IPreferenceStore createCombinedPreferenceStore(IEditorInput input) {
	List<IPreferenceStore> stores = new ArrayList<IPreferenceStore>(4);
	
	IProject project = EditorUtils.getAssociatedProject(input);
	if (project != null) {
		stores.add(new EclipsePreferencesAdapter(new ProjectScope(project), LangUIPlugin.PLUGIN_ID));
	}
	
	stores.add(LangUIPlugin.getInstance().getPreferenceStore());
	stores.add(LangUIPlugin.getInstance().getCorePreferenceStore());
	
	alterCombinedPreferenceStores_beforeEditorsUI(stores);
	stores.add(EditorsUI.getPreferenceStore());
	
	return new ChainedPreferenceStore(ArrayUtil.createFrom(stores, IPreferenceStore.class));
}
 
Example 8
Source Project: statecharts   Source File: HelpHoverProvider.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
	String tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
	if (BrowserInformationControl.isAvailable(parent)) {
		String font = "org.eclipse.jdt.ui.javadocfont";

		boolean areHoverDocsScrollable = true;

		// resizable flag of BrowserInformationControl causes the scrollbar to be always
		// enabled.
		BrowserInformationControl iControl = new BrowserInformationControl(parent, font,
				areHoverDocsScrollable) {
			@Override
			public IInformationControlCreator getInformationPresenterControlCreator() {
				return fInformationPresenterControlCreator;
			}
		};
		addLinkListener(iControl);
		return iControl;
	} else {
		return new DefaultInformationControl(parent, tooltipAffordanceString);
	}
}
 
Example 9
Source Project: gama   Source File: GamlHoverProvider.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public IInformationControl doCreateInformationControl(final Shell parent) {

	final String tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
	if (BrowserInformationControl.isAvailable(parent)) {
		final String font = "org.eclipse.jdt.ui.javadocfont"; // FIXME:
																// PreferenceConstants.APPEARANCE_JAVADOC_FONT;
		final IXtextBrowserInformationControl iControl =
				new GamlInformationControl(parent, font, tooltipAffordanceString) {

				};
		addLinkListener(iControl);
		return iControl;
	} else {
		return new DefaultInformationControl(parent, tooltipAffordanceString);
	}
}
 
Example 10
public IInformationControl doCreateInformationControl(Shell parent)
{
	if (CustomBrowserInformationControl.isAvailable(parent))
	{
		CustomBrowserInformationControl iControl = new CustomBrowserInformationControl(parent, null,
				EditorsUI.getTooltipAffordanceString())
		{
			public IInformationControlCreator getInformationPresenterControlCreator()
			{
				return informationPresenterControlCreator;
			}
		};
		iControl.setBackgroundColor(getBackgroundColor());
		iControl.setForegroundColor(getForegroundColor());
		return iControl;
	}
	else
	{
		// return new ThemedInformationControl(parent, null, EditorsUI.getTooltipAffordanceString());
		return new DefaultInformationControl(parent, true);
	}
}
 
Example 11
private String getEditorId(IFileStore file) {
	IWorkbench workbench = PlatformUI.getWorkbench();
	IEditorRegistry editorRegistry= workbench.getEditorRegistry();
	IEditorDescriptor descriptor= editorRegistry.getDefaultEditor(file.getName(), getContentType(file));

	// check the OS for in-place editor (OLE on Win32)
	if (descriptor == null && editorRegistry.isSystemInPlaceEditorAvailable(file.getName()))
		descriptor= editorRegistry.findEditor(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID);
	
	// check the OS for external editor
	if (descriptor == null && editorRegistry.isSystemExternalEditorAvailable(file.getName()))
		descriptor= editorRegistry.findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
	
	if (descriptor != null)
		return descriptor.getId();
	
	return EditorsUI.DEFAULT_TEXT_EDITOR_ID;
}
 
Example 12
@Override
protected void initializeEditor() {
	setDocumentProvider(JavaPlugin.getDefault().getPropertiesFileDocumentProvider());
	IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
	setPreferenceStore(store);
	JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools();
	setSourceViewerConfiguration(new PropertiesFileSourceViewerConfiguration(textTools.getColorManager(), store, this, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING));
	setEditorContextMenuId("#TextEditorContext"); //$NON-NLS-1$
	setRulerContextMenuId("#TextRulerContext"); //$NON-NLS-1$
	setHelpContextId(ITextEditorHelpContextIds.TEXT_EDITOR);
	configureInsertMode(SMART_INSERT, false);
	setInsertMode(INSERT);

	// Need to listen on Editors UI preference store because JDT disables this functionality in its preferences.
	fPropertyChangeListener= new IPropertyChangeListener() {
		public void propertyChange(PropertyChangeEvent event) {
			if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS.equals(event.getProperty()))
				handlePreferenceStoreChanged(event);
		}
	};
	EditorsUI.getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
}
 
Example 13
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
	if (!EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED))
		return null;

	IReconcilingStrategy strategy= new SpellingReconcileStrategy(sourceViewer, EditorsUI.getSpellingService()) {
		@Override
		protected IContentType getContentType() {
			return PROPERTIES_CONTENT_TYPE;
		}
	};

	MonoReconciler reconciler= new MonoReconciler(strategy, false);
	reconciler.setDelay(500);
	return reconciler;
}
 
Example 14
Source Project: Pydev   Source File: PyOpenResourceAction.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void openFiles(PythonpathZipChildTreeNode[] pythonPathFilesSelected) {
    for (PythonpathZipChildTreeNode n : pythonPathFilesSelected) {
        try {
            if (PythonPathHelper.isValidSourceFile(n.zipPath)) {
                new PyOpenAction().run(new ItemPointer(n.zipStructure.file, new Location(), new Location(), null,
                        n.zipPath));
            } else {
                IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry();
                IEditorDescriptor defaultEditor = editorReg.getDefaultEditor(n.zipPath);
                PydevZipFileStorage storage = new PydevZipFileStorage(n.zipStructure.file, n.zipPath);
                PydevZipFileEditorInput input = new PydevZipFileEditorInput(storage);

                if (defaultEditor != null) {
                    IDE.openEditor(page, input, defaultEditor.getId());
                } else {
                    IDE.openEditor(page, input, EditorsUI.DEFAULT_TEXT_EDITOR_ID);
                }
            }
        } catch (PartInitException e) {
            Log.log(e);
        }
    }
}
 
Example 15
public final void propertyChange(final PropertyChangeEvent event) {
	if (event.getProperty().equals(PreferenceConstants.SPELLING_LOCALE)) {
		resetSpellChecker();
		return;
	}

	if (event.getProperty().equals(PreferenceConstants.SPELLING_USER_DICTIONARY)) {
		resetUserDictionary();
		return;
	}

	if (event.getProperty().equals(PreferenceConstants.SPELLING_USER_DICTIONARY_ENCODING)) {
		resetUserDictionary();
		return;
	}

	if (event.getProperty().equals(SpellingService.PREFERENCE_SPELLING_ENABLED) && !EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
		if (this == fgEngine)
			SpellCheckEngine.shutdownInstance();
		else
			shutdown();
	}
}
 
Example 16
public synchronized final void shutdown() {

		JavaPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
		EditorsUI.getPreferenceStore().removePropertyChangeListener(this);

		ISpellDictionary dictionary= null;
		for (final Iterator<ISpellDictionary> iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) {
			dictionary= iterator.next();
			dictionary.unload();
		}
		fGlobalDictionaries= null;

		for (final Iterator<ISpellDictionary> iterator= fLocaleDictionaries.values().iterator(); iterator.hasNext();) {
			dictionary= iterator.next();
			dictionary.unload();
		}
		fLocaleDictionaries= null;

		fUserDictionary= null;
		fChecker= null;
	}
 
Example 17
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
	if (!EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED))
		return null;

	IReconcilingStrategy strategy = new SpellingReconcileStrategy(sourceViewer, EditorsUI.getSpellingService()) {
		@Override
		protected IContentType getContentType() {
			return EditorConfigTextTools.EDITORCONFIG_CONTENT_TYPE;
		}
	};

	MonoReconciler reconciler = new MonoReconciler(strategy, false);
	reconciler.setDelay(500);
	return reconciler;
}
 
Example 18
Source Project: saros   Source File: SarosAnnotation.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Loads the default colors from the plugin.xml and overwrites possible errors in the EditorsUI
 * preference store.
 */
public static void resetColors() {

  log.debug("resetting annotation colors");

  final IPreferenceStore preferenceStore = EditorsUI.getPreferenceStore();

  final AnnotationPreferenceLookup lookup = EditorsUI.getAnnotationPreferenceLookup();

  final String[] annotationTypesToReset = {
    SelectionAnnotation.TYPE, ViewportAnnotation.TYPE, ContributionAnnotation.TYPE
  };

  for (int i = 0; i <= SIZE; ++i) {

    for (String annotationType : annotationTypesToReset) {

      final String annotationTypeToLookup = getNumberedType(annotationType, i);

      final AnnotationPreference preference =
          lookup.getAnnotationPreference(annotationTypeToLookup);

      if (preference == null) {
        log.warn("could not reset color for annotation type: " + annotationTypeToLookup);
        continue;
      }

      preferenceStore.setToDefault(preference.getColorPreferenceKey());

      if (log.isTraceEnabled()) {
        log.trace(
            "reset "
                + annotationTypeToLookup
                + " to: "
                + preferenceStore.getString(preference.getColorPreferenceKey()));
      }
    }
  }
}
 
Example 19
@Override
public IInformationControl doCreateInformationControl(Shell parent) {
	return new AnnotationInformationControl(parent, EditorsUI.getTooltipAffordanceString()) {

		@Override
		public IInformationControlCreator getInformationPresenterControlCreator() {
			return fPresenterControlCreator;
		}
	};
}
 
Example 20
Source Project: saros   Source File: SarosAnnotation.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the color for the given annotation type and user color id.
 *
 *<p>E.g: <code>getColor("saros.annotations.viewport", 2)
 * <p><b>Important notice:</b> Every returned color instance allocates OS resources that need to
 * be disposed with {@link Color#dispose()}!
 *
 * @see Annotation#getType()
 * @param type annotation type as defined in the plugin.xml
 * @param colorId the color id
 * @return the corresponding color or a default one if no color is stored
 */
public static Color getColor(final String type, final int colorId) {

  final String typeToLookup = getNumberedType(type, colorId);

  final AnnotationPreference ap =
      EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(typeToLookup);

  if (ap == null)
    throw new IllegalArgumentException(
        "could not read color value of annotation '"
            + typeToLookup
            + "' because it does not exists");

  RGB rgb =
      PreferenceConverter.getColor(EditorsUI.getPreferenceStore(), ap.getColorPreferenceKey());

  if (rgb == PreferenceConverter.COLOR_DEFAULT_DEFAULT) { // NOPMD
    rgb = ap.getColorPreferenceValue();
  }

  if (rgb == null)
    throw new IllegalArgumentException(
        "annotation '" + typeToLookup + "' does not have a default color");

  return new Color(Display.getDefault(), rgb);
}
 
Example 21
Source Project: xtext-eclipse   Source File: AbstractHover.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public IInformationControlCreator getHoverControlCreator() {
	return new IInformationControlCreator() {
		@Override
		public IInformationControl createInformationControl(Shell parent) {
			return new DefaultInformationControl(parent, EditorsUI.getTooltipAffordanceString());
		}
	};
}
 
Example 22
@Override
public boolean canReuse(IInformationControl control) {
	if (!super.canReuse(control))
		return false;

	if (control instanceof IInformationControlExtension4) {
		String tooltipAffordanceString = EditorsUI.getTooltipAffordanceString();
		((IInformationControlExtension4) control).setStatusText(tooltipAffordanceString);
	}

	return true;
}
 
Example 23
@Override
public IPreferenceStore getPreferenceStore() {
	lazyInitialize();
	Activator activator = Activator.getDefault();
	if (activator != null)
		return new ChainedPreferenceStore(new IPreferenceStore[] {
				getWritablePreferenceStore(),
				activator.getPreferenceStore(), 
				EditorsUI.getPreferenceStore() });
	return new ChainedPreferenceStore(new IPreferenceStore[] {
			getWritablePreferenceStore(),
			EditorsUI.getPreferenceStore() });
}
 
Example 24
@Override
public IPreferenceStore getContextPreferenceStore(Object context) {
	lazyInitialize();
	// may be null on shutdown
	Activator activator = Activator.getDefault();
	if (activator != null)
		return new ChainedPreferenceStore(new IPreferenceStore[] { 
				getWritablePreferenceStore(context),
				activator.getPreferenceStore(),
				EditorsUI.getPreferenceStore()});
	return new ChainedPreferenceStore(new IPreferenceStore[] { 
			getWritablePreferenceStore(context),
			EditorsUI.getPreferenceStore()});
}
 
Example 25
/**
 * Creates a new source viewer configuration.
 * 
 * @param te The editor that this configuration is associated to
 */
public TexSourceViewerConfiguration(TexEditor editor) {        
    super(EditorsUI.getPreferenceStore());
    this.editor = editor;
    this.colorManager = new ColorManager();
    this.annotationHover = new TexAnnotationHover();

    // Adds a listener for changing content assistant properties if
    // these are changed in the preferences
    TexlipsePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new  
            IPropertyChangeListener() {
        
        public void propertyChange(PropertyChangeEvent event) {
            
            if (assistant == null)
                return;
            
            String property = event.getProperty();
            if (TexlipseProperties.TEX_COMPLETION.equals(property)) {
                assistant.enableAutoActivation(
                        TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(
                                TexlipseProperties.TEX_COMPLETION));
            } else if (TexlipseProperties.TEX_COMPLETION_DELAY.equals(property)) {
                assistant.setAutoActivationDelay(
                        TexlipsePlugin.getDefault().getPreferenceStore().getInt(
                                TexlipseProperties.TEX_COMPLETION_DELAY));
            }
        };
    });
    
}
 
Example 26
Source Project: xds-ide   Source File: ModulaSpellingHover.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IInformationControlCreator getHoverControlCreator() {
	return new IInformationControlCreator() {
		public IInformationControl createInformationControl(Shell parent) {
			return new HoverInformationControl(parent, EditorsUI.getTooltipAffordanceString());
		}
	};
}
 
Example 27
Source Project: xds-ide   Source File: SpellCheckEngine.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public final void propertyChange(final PropertyChangeEvent event) {
    if (event.getProperty().equals(SpellingService.PREFERENCE_SPELLING_ENABLED) && !EditorsUI.getPreferenceStore().getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
        if (this == fgEngine)
            SpellCheckEngine.shutdownInstance();
        else
            shutdown();
    }
}
 
Example 28
@Override
protected Control createContents(final Composite parent) {
    Composite composite= new Composite(parent, SWT.NONE);
    GridLayout layout= new GridLayout();
    layout.numColumns= 1;
    layout.marginHeight= 0;
    layout.marginWidth= 0;
    composite.setLayout(layout);

    Link link= new Link(composite, SWT.NONE);
    link.setText(Messages.MarkOccurrencesPreferencePage_LinkText);
    link.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            String data= null;
            AnnotationPreference preference= EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference("org.eclipse.jdt.ui.occurrences"); //$NON-NLS-1$
            if (preference != null)
                data= preference.getPreferenceLabel();
            PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, data);
        }
    });
    
    SWTFactory.createLabel(composite, "", 1); //$NON-NLS-1$
    
    cboxOnOff = SWTFactory.createCheckbox(composite, Messages.MarkOccurrencesPreferencePage_MarkOccurrencesOfElement, 1);
    
    initFromStore();
    return composite;
}
 
Example 29
Source Project: birt   Source File: ScriptDebugHover.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public IInformationControlCreator getHoverControlCreator( )
{
	return new IInformationControlCreator( ) {

		public IInformationControl createInformationControl( Shell parent )
		{
			return new DefaultInformationControl( parent,
					EditorsUI.getTooltipAffordanceString( ) );
		}
	};
}
 
Example 30
Source Project: xds-ide   Source File: ModulaReconciler.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void uninstall() {
    EditorsUI.getPreferenceStore().removePropertyChangeListener(propertyChangeListener);
    propertyChangeListener = null;

    super.uninstall();
}