Saros
Distributed Collaborative Editing and Distributed Party Programming
de.fu_berlin.inf.dpp.editor.internal.EditorAPI Class Reference
Inheritance diagram for de.fu_berlin.inf.dpp.editor.internal.EditorAPI:
de.fu_berlin.inf.dpp.editor.internal.IEditorAPI

List of all members.

Public Member Functions

IEditorPart openEditor (SPath path)
IEditorPart openEditor (SPath path, boolean activate)
boolean openEditor (IEditorPart part)
void closeEditor (IEditorPart part)
IEditorPart getActiveEditor ()
IResource getEditorResource (IEditorPart editorPart)
ITextSelection getSelection (IEditorPart editorPart)
void setEditable (final IEditorPart editorPart, final boolean newIsEditable)
ILineRange getViewport (IEditorPart editorPart)
SPath getActiveEditorPath ()
SPath getEditorPath (IEditorPart editorPart)
IDocumentProvider getDocumentProvider (final IEditorInput input)
IDocument getDocument (final IEditorPart editorPart)

Static Public Member Functions

static Set< IEditorPart > getOpenEditors ()
static ILineRange getViewport (ITextViewer viewer)
static ITextViewer getViewer (IEditorPart editorPart)
static boolean saveProject (final IProject projectToSave, final boolean confirm)

Protected Attributes

final VerifyKeyListener keyVerifier

Detailed Description

The central implementation of the IEditorAPI which basically encapsulates the interaction with the TextEditor.

Pretty much all methods in this class need to be called from SWT

Author:
rdjemili

Member Function Documentation

void de.fu_berlin.inf.dpp.editor.internal.EditorAPI.closeEditor ( IEditorPart  part)

Closes the given editorpart.

Needs to be called from an UI thread.

Implements de.fu_berlin.inf.dpp.editor.internal.IEditorAPI.

IEditorPart de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getActiveEditor ( )
Returns:
the editor that is currently activated.

Implements de.fu_berlin.inf.dpp.editor.internal.IEditorAPI.

SPath de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getActiveEditorPath ( )

Syntactic sugar for getting the path of the IEditorPart returned by getActiveEditor()

Implements de.fu_berlin.inf.dpp.editor.internal.IEditorAPI.

IDocument de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getDocument ( final IEditorPart  editorPart)
IDocumentProvider de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getDocumentProvider ( final IEditorInput  input)
SPath de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getEditorPath ( IEditorPart  editorPart)
Returns:
the path of the file the given editor is displaying or null if the given editor is not showing a file or the file is not referenced via a path in the project.

Implements de.fu_berlin.inf.dpp.editor.internal.IEditorAPI.

IResource de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getEditorResource ( IEditorPart  editorPart)

Returns the resource currently displayed in the given editorPart.

Returns:
Can be null, e.g. if the given editorPart is not operating on a resource, or has several resources.

Implements de.fu_berlin.inf.dpp.editor.internal.IEditorAPI.

static Set<IEditorPart> de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getOpenEditors ( ) [static]

This method will return all editors open in all IWorkbenchWindows.

This method will ask Eclipse to restore editors which have not been loaded yet (if Eclipse is started editors are loaded lazily), which is why it must run in the SWT thread. So calling this method might cause partOpen events to be sent.

Returns:
all editors that are currently opened
ITextSelection de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getSelection ( IEditorPart  editorPart)

Returns the current text selection for given editor.

Parameters:
editorPartthe editorPart for which to get the text selection.
Returns:
the current text selection. Returns TextSelection#emptySelection() if no text selection exists.

Implements de.fu_berlin.inf.dpp.editor.internal.IEditorAPI.

static ITextViewer de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getViewer ( IEditorPart  editorPart) [static]

Gets a ITextViewer instance for the given editor part.

Parameters:
editorPartfor which we want a TextViewer.
Returns:
ITextViewer or null if there is no TextViewer for the editorPart.
ILineRange de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getViewport ( IEditorPart  editorPart)
Returns:
Return the viewport for given editor or null, if this editorPart does not have ITextViewer associated.

Implements de.fu_berlin.inf.dpp.editor.internal.IEditorAPI.

static ILineRange de.fu_berlin.inf.dpp.editor.internal.EditorAPI.getViewport ( ITextViewer  viewer) [static]
IEditorPart de.fu_berlin.inf.dpp.editor.internal.EditorAPI.openEditor ( SPath  path)

Opens the editor with given path. Needs to be called from an UI thread.

Returns:
the opened editor or null if the editor couldn't be opened.

Implements de.fu_berlin.inf.dpp.editor.internal.IEditorAPI.

IEditorPart de.fu_berlin.inf.dpp.editor.internal.EditorAPI.openEditor ( SPath  path,
boolean  activate 
)

Opens the editor with given path. Needs to be called from an UI thread.

Parameters:
activatetrue, if editor should get focus, otherwise false
Returns:
the opened editor or null if the editor couldn't be opened.

Implements de.fu_berlin.inf.dpp.editor.internal.IEditorAPI.

boolean de.fu_berlin.inf.dpp.editor.internal.EditorAPI.openEditor ( IEditorPart  part)

Opens the given editor part.

Needs to be called from an UI thread.

Returns:
true if the editor part was successfully opened, false otherwise

Implements de.fu_berlin.inf.dpp.editor.internal.IEditorAPI.

static boolean de.fu_berlin.inf.dpp.editor.internal.EditorAPI.saveProject ( final IProject  projectToSave,
final boolean  confirm 
) [static]

Saves the given project and returns true if the operation was successful or false if the user canceled.

TODO Tell the user why we do want to save!

Parameters:
confirmtrue to ask the user before saving unsaved changes, and false to save unsaved changes without asking

TODO saveAllEditors does not save the Documents that we are modifying in the background

void de.fu_berlin.inf.dpp.editor.internal.EditorAPI.setEditable ( final IEditorPart  editorPart,
final boolean  newIsEditable 
)

Member Data Documentation

Initial value:
 new VerifyKeyListener() {
        @Override
        public void verifyKey(VerifyEvent event) {
            if (event.character > 0) {
                event.doit = false;

                Object adapter = getActiveEditor().getAdapter(
                    IEditorStatusLine.class);
                if (adapter != null) {
                    SarosView
                        .showNotification("Read-Only Notification",
                            "You have only read access and therefore can't perform modifications.");

                    Display display = SWTUtils.getDisplay();

                    if (!display.isDisposed())
                        display.beep();
                }
            }
        }
    }
 All Classes Namespaces Files Functions Variables Enumerations