org.eclipse.ocl.examples.xtext.console
Class OCLConsolePage

java.lang.Object
  extended by org.eclipse.ui.part.Page
      extended by org.eclipse.ocl.examples.xtext.console.OCLConsolePage
All Implemented Interfaces:
org.eclipse.ui.part.IPage, org.eclipse.ui.part.IPageBookViewPage

public class OCLConsolePage
extends org.eclipse.ui.part.Page

The page implementing the Interactive OCL console.


Nested Class Summary
protected static class OCLConsolePage.CancelableEvaluationVisitor
           
protected static class OCLConsolePage.CancelableTypeManager
           
protected static class OCLConsolePage.ExceptionValue
           
 
Method Summary
 void createControl(org.eclipse.swt.widgets.Composite parent)
           
 void dispose()
          Extends the inherited method to dispose of additional colour resources.
protected  org.eclipse.jface.viewers.ISelection getActiveSelection()
           
 org.eclipse.swt.widgets.Control getControl()
           
 org.eclipse.xtext.ui.editor.model.IXtextDocument getDocument(org.eclipse.emf.common.util.URI trimFragment)
           
 BaseDocument getEditorDocument()
           
 java.lang.String getLastOCLExpression()
          Gets the editor image for the specified element.
protected  void refreshSelection(java.lang.Object selected)
          Prints the specified object to the output viewer.
 void setFocus()
           
 
Methods inherited from class org.eclipse.ui.part.Page
getSite, init, makeContributions, setActionBars
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createControl

public void createControl(org.eclipse.swt.widgets.Composite parent)
Specified by:
createControl in interface org.eclipse.ui.part.IPage
Specified by:
createControl in class org.eclipse.ui.part.Page

dispose

public void dispose()
Extends the inherited method to dispose of additional colour resources.

Specified by:
dispose in interface org.eclipse.ui.part.IPage
Overrides:
dispose in class org.eclipse.ui.part.Page

getActiveSelection

protected org.eclipse.jface.viewers.ISelection getActiveSelection()

getControl

public org.eclipse.swt.widgets.Control getControl()
Specified by:
getControl in interface org.eclipse.ui.part.IPage
Specified by:
getControl in class org.eclipse.ui.part.Page

getDocument

public org.eclipse.xtext.ui.editor.model.IXtextDocument getDocument(org.eclipse.emf.common.util.URI trimFragment)

getEditorDocument

public BaseDocument getEditorDocument()

getLastOCLExpression

public java.lang.String getLastOCLExpression()
Gets the editor image for the specified element.

Parameters:
element - a model element
Returns:
the corresponding image private ImageDescriptor getImage(EObject element) { ImageDescriptor result = null; IItemLabelProvider provider = (IItemLabelProvider) new ComposedAdapterFactory( ComposedAdapterFactory.Descriptor.Registry.INSTANCE).adapt( element, IItemLabelProvider.class); if (provider != null) { Object image = provider.getImage(element); if (image != null) { result = ExtendedImageRegistry.INSTANCE.getImageDescriptor(image); } } return result; }

refreshSelection

protected void refreshSelection(java.lang.Object selected)
Prints the specified object to the output viewer. The object is converted to a string using the best matching EMF label provider adapter if it is an EObject; otherwise, just use String.valueOf(java.lang.Object) on it. If the object is a collection or an array, then we print each element on a separate line.

Parameters:
object - the object or collection to print
color - the color to print the object with
bold - whether to display it in bold text private void print(Value value, Color color, boolean bold) { CollectionValue collectionValue = value.isCollectionValue(); if (collectionValue != null) { for (Value elementValue : collectionValue) { append(String.valueOf(elementValue), color, bold); } } else { append(String.valueOf(value), color, bold); } /* Collection toPrint; if (object == null) { toPrint = Collections.EMPTY_SET; } else if (object instanceof Collection) { toPrint = (Collection) object; } else if (object.getClass().isArray()) { toPrint = Arrays.asList((Object[]) object); } else { toPrint = Collections.singleton(object); } for (Iterator iter = toPrint.iterator(); iter.hasNext();) { append(toString(iter.next()), color, bold); } * / // append(String.valueOf(object), color, bold); scrollText(); }

setFocus

public void setFocus()
Specified by:
setFocus in interface org.eclipse.ui.part.IPage
Specified by:
setFocus in class org.eclipse.ui.part.Page