org.eclipse.ui.texteditor.IDocumentProviderExtension Java Examples

The following examples show how to use org.eclipse.ui.texteditor.IDocumentProviderExtension. 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: TestEditor.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
private void initializeSourceViewer(final IEditorInput input) {

        final IDocumentProvider documentProvider = getDocumentProvider();
        final IAnnotationModel model = documentProvider.getAnnotationModel(input);
        final IDocument document = documentProvider.getDocument(input);

        if (document != null) {
            fSourceViewer.setDocument(document, model);
            fSourceViewer.setEditable(isEditable());
            fSourceViewer.showAnnotations(model != null);
        }

        if (fElementStateListener instanceof IElementStateListenerExtension) {
            boolean isStateValidated = false;
            if (documentProvider instanceof IDocumentProviderExtension)
                isStateValidated = ((IDocumentProviderExtension) documentProvider).isStateValidated(input);

            final IElementStateListenerExtension extension = (IElementStateListenerExtension) fElementStateListener;
            extension.elementStateValidationChanged(input, isStateValidated);
        }

    }
 
Example #2
Source File: TestEditor.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
protected void updateState(final IEditorInput input) {
    final IDocumentProvider provider = getDocumentProvider();
    if (provider instanceof IDocumentProviderExtension) {
        final IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;
        try {

            extension.updateStateCache(input);

            if (fSourceViewer != null)
                fSourceViewer.setEditable(isEditable());

        } catch (final CoreException e) {
            ERDiagramActivator.log(e);
        }
    }
}
 
Example #3
Source File: TestEditor.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private void initializeSourceViewer(IEditorInput input) {

		IDocumentProvider documentProvider = getDocumentProvider();
		IAnnotationModel model = documentProvider.getAnnotationModel(input);
		IDocument document = documentProvider.getDocument(input);

		if (document != null) {
			fSourceViewer.setDocument(document, model);
			fSourceViewer.setEditable(isEditable());
			fSourceViewer.showAnnotations(model != null);
		}

		if (fElementStateListener instanceof IElementStateListenerExtension) {
			boolean isStateValidated = false;
			if (documentProvider instanceof IDocumentProviderExtension)
				isStateValidated = ((IDocumentProviderExtension) documentProvider)
						.isStateValidated(input);

			IElementStateListenerExtension extension = (IElementStateListenerExtension) fElementStateListener;
			extension.elementStateValidationChanged(input, isStateValidated);
		}

	}
 
Example #4
Source File: TestEditor.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
protected void updateState(IEditorInput input) {
	IDocumentProvider provider = getDocumentProvider();
	if (provider instanceof IDocumentProviderExtension) {
		IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;
		try {

			extension.updateStateCache(input);

			if (fSourceViewer != null)
				fSourceViewer.setEditable(isEditable());

		} catch (CoreException e) {
			Activator.log(e);
		}
	}
}
 
Example #5
Source File: TestEditor.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
public boolean isEditable() {
    final IDocumentProvider provider = getDocumentProvider();
    if (provider instanceof IDocumentProviderExtension) {
        final IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;
        return extension.isModifiable(getEditorInput());
    }
    return false;
}
 
Example #6
Source File: TestEditor.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
protected void validateState(final IEditorInput input) {

        final IDocumentProvider provider = getDocumentProvider();
        if (!(provider instanceof IDocumentProviderExtension))
            return;

        final IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;

        try {

            extension.validateState(input, getSite().getShell());

        } catch (final CoreException x) {
            final IStatus status = x.getStatus();
            if (status == null || status.getSeverity() != IStatus.CANCEL) {
                final Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
                final ILog log = Platform.getLog(bundle);
                log.log(x.getStatus());

                final Shell shell = getSite().getShell();
                final String title = "EditorMessages.Editor_error_validateEdit_title";
                final String msg = "EditorMessages.Editor_error_validateEdit_message";
                ErrorDialog.openError(shell, title, msg, x.getStatus());
            }
            return;
        }

        if (fSourceViewer != null)
            fSourceViewer.setEditable(isEditable());

    }
 
Example #7
Source File: EditorRefreshActionDelegate.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run(IAction action) {
	if(editor != null){
		IDocumentProvider provider = editor.getDocumentProvider() ; 
		IDocumentProviderExtension extension= (IDocumentProviderExtension) provider;
		try {
			extension.synchronize(editor.getEditorInput());
		} catch (CoreException e) {
			BonitaStudioLog.error(e) ;
		}
	}
}
 
Example #8
Source File: TestEditor.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public boolean isEditable() {
	IDocumentProvider provider = getDocumentProvider();
	if (provider instanceof IDocumentProviderExtension) {
		IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;
		return extension.isModifiable(getEditorInput());
	}
	return false;
}
 
Example #9
Source File: TestEditor.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
protected void validateState(IEditorInput input) {

		IDocumentProvider provider = getDocumentProvider();
		if (!(provider instanceof IDocumentProviderExtension))
			return;

		IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;

		try {

			extension.validateState(input, getSite().getShell());

		} catch (CoreException x) {
			IStatus status = x.getStatus();
			if (status == null || status.getSeverity() != IStatus.CANCEL) {
				Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
				ILog log = Platform.getLog(bundle);
				log.log(x.getStatus());

				Shell shell = getSite().getShell();
				String title = "EditorMessages.Editor_error_validateEdit_title";
				String msg = "EditorMessages.Editor_error_validateEdit_message";
				ErrorDialog.openError(shell, title, msg, x.getStatus());
			}
			return;
		}

		if (fSourceViewer != null)
			fSourceViewer.setEditable(isEditable());

	}
 
Example #10
Source File: AbstractFoldingEditor.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * This code auto-refreshes files that are out of synch when we first open them. This is a bit of a hack that looks
 * to see if it seems we're out of sync and the file isn't open yet. If it is already open, we call super so it pops
 * a dialog asking if you want to update the file contents.
 */
@Override
protected void handleEditorInputChanged()
{
	final IDocumentProvider provider = getDocumentProvider();
	if (provider == null)
	{
		// fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=15066
		close(false);
		return;
	}

	final IEditorInput input = getEditorInput();
	boolean wasActivated = true;
	try
	{
		Field f = AbstractTextEditor.class.getDeclaredField("fHasBeenActivated"); //$NON-NLS-1$
		f.setAccessible(true);
		wasActivated = (Boolean) f.get(this);
	}
	catch (Exception e1)
	{
		// ignore
	}
	if (!wasActivated && !provider.isDeleted(input))
	{
		try
		{
			if (provider instanceof IDocumentProviderExtension)
			{
				IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;
				extension.synchronize(input);
			}
			else
			{
				doSetInput(input);
			}
			return;
		}
		catch (Exception e)
		{
			// ignore
		}
	}
	super.handleEditorInputChanged();
}