protected void addExpressionStyles(int lineOffset, int lineLenght, Vector<StyleRange> styles) { final String content = document.get(); for (Expression exp : expressions) { if (supportedTypes.keySet().contains(exp.getType())) { try { int i = lineOffset; IRegion index = null; index = finder.find(i, exp.getName(), true, true, true, false); while (index != null && index.getOffset() < lineOffset + lineLenght) { if (PatternLineStyleListener.isNotEscapeWord(content, index.getOffset())) { styles.add( new StyleRange( index.getOffset(), index.getLength(), Display.getDefault().getSystemColor(supportedTypes.get(exp.getType())), null, SWT.BOLD)); } i = index.getOffset() + index.getLength(); if (i < lineOffset + lineLenght) { index = finder.find(i, exp.getName(), true, true, true, false); } else { index = null; } } } catch (BadLocationException e) { // Ignore } } } }
public void buildTree() { for (int i = 0; i < oldExpressions.size(); i++) { final Expression oldExpression = oldExpressions.get(i); CompareScript left = new CompareScript(oldExpression.getName(), oldExpression); left.setElement(oldExpression); left.setImage(adapterFactoryLabelProvider.getImage(oldExpression)); final Expression newExpression = newExpressions.get(i); final CompareScript right = new CompareScript(newExpression.getName(), newExpression); right.setElement(newExpression); right.addContentChangeListener( new IContentChangeListener() { @Override public void contentChanged(IContentChangeNotifier compareScript) { if (compareScript instanceof CompareScript) { setDirty(true); if (getViewer() == null || getViewer().getControl().isDisposed()) return; getViewer().refresh(true); } } }); right.setImage(adapterFactoryLabelProvider.getImage(newExpression)); DiffNode leaf = new DiffNode(null, Differencer.CHANGE, null, left, right); final DiffNode poolNode = buildPathNodes(oldExpression.eContainer(), leaf); if (((CompareScript) poolNode.getAncestor()).getElement() instanceof Pool && root.getChildren().length == 0) { root.add(poolNode); } } }
/* * (non-Javadoc) * @see org.eclipse.core.databinding.validation.IValidator#validate(java.lang.Object) */ @Override public IStatus validate(final Object value) { final String content = inputExpression.getContent(); final WebPageRepositoryStore repositoryStore = repositoryAccessor.getRepositoryStore(WebPageRepositoryStore.class); return repositoryStore.getChild(content) == null ? ValidationStatus.error( Messages.bind( Messages.pageDoesntExists, String.format("%s (%s)", inputExpression.getName(), content))) : ValidationStatus.ok(); }
private DiffNode buildPathNodes(EObject container, DiffNode node) { DiffNode parentNode = new DiffNode(Differencer.NO_CHANGE); node.setParent(parentNode); parentNode.add(node); CompareScript ancestor = null; String name = adapterFactoryLabelProvider.getText(container); Expression expr = ExpressionHelper.createConstantExpression(name, String.class.getName()); expr.setName(name); ancestor = new CompareScript(expr.getName(), expr); ancestor.setElement(container); ancestor.setImage(adapterFactoryLabelProvider.getImage(container)); parentNode.setAncestor(ancestor); if (insertParentNode(parentNode)) { return parentNode; } if (container instanceof Pool) { return parentNode; } if (container instanceof ConnectorParameter) { return buildPathNodes(container.eContainer().eContainer(), parentNode); } return buildPathNodes(container.eContainer(), parentNode); }
@Override public void okPressed() { if (!editorInputExpression.getContent().equals(editorInputExpression.getName())) { editorInputExpression.setName(editorInputExpression.getContent()); } }