Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 122211 Details for
Bug 260641
[OCL] ocl.examples.interpreter: add page up/down history
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for org.eclipse.emf.ocl.examples.interpreter.console.OCLConsolePage
OCLConsolePage.patch (text/plain), 4.98 KB, created by
Nicolas Rouquette
on 2009-01-11 15:32:34 EST
(
hide
)
Description:
Patch for org.eclipse.emf.ocl.examples.interpreter.console.OCLConsolePage
Filename:
MIME Type:
Creator:
Nicolas Rouquette
Created:
2009-01-11 15:32:34 EST
Size:
4.98 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P cvs.org.eclipse.emf.ocl.examples.interpreter >Index: src/org/eclipse/emf/ocl/examples/interpreter/console/OCLConsolePage.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/examples/org.eclipse.emf.ocl.examples.interpreter/src/org/eclipse/emf/ocl/examples/interpreter/console/OCLConsolePage.java,v >retrieving revision 1.21 >diff -u -r1.21 OCLConsolePage.java >--- src/org/eclipse/emf/ocl/examples/interpreter/console/OCLConsolePage.java 5 Oct 2008 14:35:44 -0000 1.21 >+++ src/org/eclipse/emf/ocl/examples/interpreter/console/OCLConsolePage.java 11 Jan 2009 20:28:24 -0000 >@@ -24,6 +24,7 @@ > import java.util.Iterator; > import java.util.List; > import java.util.Map; >+import java.util.Vector; > > import org.eclipse.core.runtime.FileLocator; > import org.eclipse.core.runtime.IAdaptable; >@@ -80,6 +81,7 @@ > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.SashForm; > import org.eclipse.swt.custom.StyleRange; >+import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.events.KeyEvent; > import org.eclipse.swt.events.KeyListener; > import org.eclipse.swt.graphics.Color; >@@ -111,6 +113,12 @@ > private static int BUNDLE_AVAILABLE = Bundle.RESOLVED | Bundle.ACTIVE | > Bundle.STARTING; > >+ /** >+ * The number of expressions to save in the history. >+ */ >+ public static int OCL_EXPRESSION_RING_BUFFER_SIZE = 10; >+ >+ private static String lineSeparator = System.getProperty("line.separator"); > private Composite page; > > private ITextViewer output; >@@ -119,7 +127,7 @@ > > private ColorManager colorManager; > >- private String lastOCLExpression; >+ private final Vector<String> oclExpressionHistory = new Vector<String>(OCL_EXPRESSION_RING_BUFFER_SIZE); > private EObject context; > > private ISelectionService selectionService; >@@ -197,8 +205,8 @@ > > input = new OCLSourceViewer(page, colorManager, SWT.BORDER | SWT.MULTI); > input.setDocument(document); >- input.getTextWidget().addKeyListener(new InputKeyListener()); >- >+ input.getTextWidget().addKeyListener(new InputKeyListener(input.getTextWidget())); >+ > selectionListener = new ISelectionListener() { > public void selectionChanged(IWorkbenchPart part, ISelection selection) { > OCLConsolePage.this.selectionChanged(selection); >@@ -432,7 +440,15 @@ > } > > // store the successfully parsed expression >- lastOCLExpression = expression; >+ if (oclExpressionHistory.size() == oclExpressionHistory.capacity()) { >+ oclExpressionHistory.remove(0); >+ } >+ >+ if (expression.endsWith(lineSeparator)) { >+ int offset = expression.length() - lineSeparator.length(); >+ expression = expression.substring(0, offset); >+ } >+ oclExpressionHistory.add(expression); > } catch (Exception e) { > result = false; > error((e.getLocalizedMessage() == null) ? e.getClass().getName() >@@ -590,6 +606,13 @@ > private class InputKeyListener implements KeyListener { > private boolean evaluationSuccess = false;; > >+ private final StyledText textWidget; >+ >+ public InputKeyListener(StyledText textWidget) { >+ super(); >+ this.textWidget = textWidget; >+ } >+ > public void keyPressed(KeyEvent e) { > switch (e.keyCode) { > case SWT.CR : >@@ -619,6 +642,25 @@ > if ((e.stateMask & SWT.CTRL) == SWT.CTRL) { > input.getContentAssistant().showPossibleCompletions(); > } >+ break; >+ >+ case SWT.PAGE_UP: >+ if (!oclExpressionHistory.isEmpty()) { >+ String lastExpression = oclExpressionHistory.remove(oclExpressionHistory.size()-1); >+ oclExpressionHistory.add(0, lastExpression); >+ document.set(oclExpressionHistory.lastElement()); >+ textWidget.setCaretOffset(document.getLength()); >+ } >+ break; >+ >+ case SWT.PAGE_DOWN: >+ if (!oclExpressionHistory.isEmpty()) { >+ String firstExpression = oclExpressionHistory.remove(0); >+ oclExpressionHistory.add(firstExpression); >+ document.set(oclExpressionHistory.lastElement()); >+ textWidget.setCaretOffset(document.getLength()); >+ } >+ break; > } > } > } >@@ -682,7 +724,7 @@ > public void run() { > Shell shell = getControl().getShell(); > >- if (lastOCLExpression != null) { >+ if (! oclExpressionHistory.isEmpty()) { > FileDialog dlg = new FileDialog(shell, SWT.SAVE); > dlg.setFilterExtensions(new String[] {"*.xmi"}); //$NON-NLS-1$ > dlg.setText(OCLInterpreterMessages.console_saveDlg_title); >@@ -690,7 +732,7 @@ > String file = dlg.open(); > if (file != null) { > try { >- OCLResource.save(file, document, lastOCLExpression); >+ OCLResource.save(file, document, oclExpressionHistory.lastElement()); > } catch (Exception e) { > MessageDialog.openError( > shell,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 260641
: 122211