private IWorkbenchSite site;\r
private Button deleteExpression, newExpression;\r
private WidgetSupportImpl support;\r
- private WidgetSupportImpl expressionSupport = new WidgetSupportImpl();\r
+ private final WidgetSupportImpl expressionSupport = new WidgetSupportImpl();\r
\r
@Override\r
public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport _support) {\r
@Override\r
public Resource perform(ReadGraph graph)\r
throws DatabaseException {\r
- return (Resource)var.getRepresents(graph);\r
+ return var.getRepresents(graph);\r
}\r
});\r
input = new StructuredSelection(r);\r
Collection<Resource> variables = graph.getObjects(model, l0.ConsistsOf);\r
for(Resource v : variables) {\r
Object unit = graph.getPossibleRelatedValue(v, sr.HasUnit);\r
- if (unit != null && !map.keySet().contains((String) unit)) {\r
+ if (unit != null && !map.keySet().contains(unit)) {\r
map.put((String)unit, (String)unit);\r
\r
}\r
expressionWidget.validateFieldsTimed();\r
}\r
});\r
-\r
+ \r
// Pressing return without shift key triggers saving the expression\r
expressionWidget.addVerifyKeyListener(new VerifyKeyListener() {\r
\r
@Override\r
public void verifyKey(VerifyEvent event) {\r
- \r
- // Check if some of the expression fields has active completion assistant\r
+ // Check if some of the expression fields has active completion assistant\r
boolean isAnyAssistSessionActive = false;\r
for (int i = 0; i < expressionWidget.getExpression().getExpressionFields().size(); ++i) {\r
if (expressionWidget.getExpression().getExpressionFields().get(i).isAssistSessionActive()) {\r
break;\r
}\r
}\r
- if (!isAnyAssistSessionActive) {\r
- if(event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {\r
- if((event.stateMask & SWT.SHIFT) == 0) {\r
- event.doit = false;\r
+ if(event.keyCode == SWT.CR || event.keyCode == SWT.KEYPAD_CR) {\r
+ if (!isAnyAssistSessionActive) {\r
+ if((event.stateMask & SWT.SHIFT) == 0) {\r
+ event.doit = false;\r
((StyledText)event.widget).getParent().forceFocus();\r
expressionWidget.save();\r
}\r
+ } else {\r
+ // When a proposed expression is selected with enter, fields are validated.\r
+ expressionWidget.validateFieldsTimed();\r
}\r
}\r
}\r
if(focusLostListener == null) {\r
focusLostListener = new org.eclipse.ui.IPartListener2()\r
{\r
- public void partInputChanged(IWorkbenchPartReference partRef) {}\r
- public void partVisible(IWorkbenchPartReference partRef) {}\r
- public void partHidden(IWorkbenchPartReference partRef) {}\r
- public void partOpened(IWorkbenchPartReference partRef) {}\r
- public void partDeactivated(IWorkbenchPartReference partRef)\r
+ @Override\r
+ public void partInputChanged(IWorkbenchPartReference partRef) {}\r
+ @Override\r
+ public void partVisible(IWorkbenchPartReference partRef) {}\r
+ @Override\r
+ public void partHidden(IWorkbenchPartReference partRef) {}\r
+ @Override\r
+ public void partOpened(IWorkbenchPartReference partRef) {}\r
+ @Override\r
+ public void partDeactivated(IWorkbenchPartReference partRef)\r
{\r
if(partRef.getPart(false) instanceof PropertyPageView) {\r
PropertyPageView ppv = (PropertyPageView)partRef.getPart(false);\r
}\r
}\r
}\r
- public void partClosed(IWorkbenchPartReference partRef) {}\r
- public void partBroughtToTop(IWorkbenchPartReference partRef) {}\r
- public void partActivated(IWorkbenchPartReference partRef) {}\r
+ @Override\r
+ public void partClosed(IWorkbenchPartReference partRef) {}\r
+ @Override\r
+ public void partBroughtToTop(IWorkbenchPartReference partRef) {}\r
+ @Override\r
+ public void partActivated(IWorkbenchPartReference partRef) {}\r
};\r
site.getPage().addPartListener(focusLostListener);\r
}\r
private ArrayList<String> functions;\r
private ArrayList<String> variables = null;\r
\r
- private char[] allowedCharacters = {\r
+ private final char[] allowedCharacters = {\r
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','å','ä','ö',\r
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','Å','Ä','Ö',\r
'1','2','3','4','5','6','7','8','9','0','.','_','(',')'};\r
\r
- private String allowedConnectedCharactersRegExp = "[\\Q({[:;,<=>+-*/^\\E]";\r
+ private final String allowedConnectedCharactersRegExp = "[\\Q({[:;,<=>+-*/^\\E]";\r
\r
public CompletionProcessor(Table allowedVariables, boolean allowFunctions){\r
this.allowedVariables = allowedVariables;\r
}\r
String token = tokens[tokens.length - 1];\r
\r
- // Split the last token on '+', '-', etc. characters \r
- String tokensOfLastToken[] = token.split(allowedConnectedCharactersRegExp);\r
+ // If a '+', '-', etc. character is in the end, return all. \r
+ if (allowedConnectedCharactersRegExp.indexOf(token.charAt(token.length() - 1)) != -1) {\r
+ return collectProposals("", offset);\r
+ }\r
+ \r
+ // Split the last token on '+', '-', etc. characters\r
+ String tokensOfLastToken[] = token.split(allowedConnectedCharactersRegExp);\r
if (tokensOfLastToken.length == 0) {\r
return collectProposals("", offset);\r
}\r
token = tokensOfLastToken[tokensOfLastToken.length - 1];\r
-// System.out.println(token + "\noffset = " + offset);\r
+ //System.out.println(token + "\noffset = " + offset);\r
\r
return collectProposals(token, offset);\r
}\r
return assistSessionActive;\r
}\r
\r
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {\r
+ @Override\r
+ public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {\r
return new String[] {\r
IDocument.DEFAULT_CONTENT_TYPE\r
};\r
}\r
\r
- public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {\r
+ @Override\r
+ public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {\r
PresentationReconciler reconciler = new PresentationReconciler();\r
\r
DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getSclTokenScanner());\r
public void assistSessionEnded(ContentAssistEvent event) {\r
if (event.processor.equals(completionProcessor)) {\r
Thread waitBeforeStateChange = new Thread() {\r
- public void run() {\r
+ @Override\r
+ public void run() {\r
try {\r
sleep(WAIT_BEFORE_STATUS_CHANGE);\r
assistSessionActive = false;\r