Commit 33622273 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub

feat(contentAssit) Increase content assist size (#236)

* Display all variable names in content assist of expression viewer
* Fix some layout issue in operations

closes [BS-16064](https://bonitasoft.atlassian.net/browse/BS-16064)
parent 6dc29c59
......@@ -47,7 +47,6 @@ import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.preference.JFacePreferences;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.Util;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
......@@ -818,7 +817,7 @@ public class BonitaContentProposalAdapter implements SWTBotConstants {
protected void adjustBounds() {
// Get our control's location in display coordinates.
final Point location = control.getDisplay().map(control.getParent(), null, control.getLocation());
int initialX = location.x + POPUP_OFFSET;
int initialX = location.x - POPUP_OFFSET;
int initialY = location.y + control.getSize().y + POPUP_OFFSET;
// If we are inserting content, use the cursor position to
// position the control.
......@@ -831,20 +830,20 @@ public class BonitaContentProposalAdapter implements SWTBotConstants {
// If there is no specified size, force it by setting
// up a layout on the table.
if (popupSize == null) {
final GridData data = new GridData(GridData.FILL_BOTH);
data.heightHint = proposalTable.getItemHeight() * POPUP_CHAR_HEIGHT;
data.widthHint = Math.max(control.getSize().x + TB_OFFSET, POPUP_MINIMUM_WIDTH);
final GridData data = GridDataFactory.fillDefaults().create();
data.heightHint = this.proposalTable.getItemHeight() * POPUP_CHAR_HEIGHT;
data.widthHint = proposalTable.getParent().computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
proposalTable.setLayoutData(data);
getShell().pack();
popupSize = getShell().getSize();
}
// Constrain to the display
final Rectangle constrainedBounds = getConstrainedShellBounds(new Rectangle(initialX, initialY, popupSize.x,
popupSize.y));
final Rectangle constrainedBounds = getConstrainedShellBounds(new Rectangle(initialX, initialY, popupSize.x, popupSize.y));
// If there has been an adjustment causing the popup to overlap
// with the control, then put the popup above the control.
initialX = initialX - (popupSize.x - control.getParent().getSize().x);
if (constrainedBounds.y < initialY) {
getShell().setBounds(initialX, location.y - popupSize.y, popupSize.x, popupSize.y);
} else {
......@@ -1276,7 +1275,7 @@ public class BonitaContentProposalAdapter implements SWTBotConstants {
* The corresponding SWT bug is
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=90321
*/
private static final boolean USE_VIRTUAL = !Util.isMotif();
private static final boolean USE_VIRTUAL = false;// !Util.isMotif();
/*
* The delay before showing a secondary popup.
......
......@@ -169,8 +169,6 @@ public class OperationGroupViewer implements IBonitaVariableContext, ISelectionP
@Override
public void widgetSelected(final SelectionEvent e) {
createOperation();
// addLineUI(action);
// refresh();
}
private Operation createOperation() {
......@@ -235,6 +233,9 @@ public class OperationGroupViewer implements IBonitaVariableContext, ISelectionP
public void setEditingDomain(EditingDomain editingDomain) {
this.editingDomain = editingDomain;
for (final OperationViewer v : operationViewers) {
v.setEditingDomain(editingDomain);
}
}
public int getNbLines() {
......@@ -250,13 +251,6 @@ public class OperationGroupViewer implements IBonitaVariableContext, ISelectionP
}
}
private void removeLine(final int i) {
// removeLineUI(i);
getOperations().remove(i);
// updateOrderButtons();
// refresh();
}
protected int removeLineUI(final int i) {
final int lineNumber = i;
removes.get(lineNumber).dispose();
......@@ -353,26 +347,13 @@ public class OperationGroupViewer implements IBonitaVariableContext, ISelectionP
@Override
public void widgetSelected(final SelectionEvent e) {
removeLine(removes.indexOf(e.getSource()));
getOperations().remove(removes.indexOf(e.getSource()));
}
});
opViewer.layout(true, true);
return remove;
}
// /**
// * add lines from the form
// */
// public void fillTable() {
// final IObservableList observableList = CustomEMFEditObservables.observeList(Realm.getDefault(), getEObject(), getOperationContainmentFeature());
// observableList.removeListChangeListener(operationListlistener);
// observableList.addListChangeListener(operationListlistener);
// for (final Operation action : getOperations()) {
// addLineUI(action);
// }
// updateOrderButtons();
// }
private void updateOrderButtons() {
for (final ToolBar tb : moveToolbars) {
if (moveToolbars.indexOf(tb) == getOperations().size() - 1 && moveToolbars.indexOf(tb) == 0) {
......@@ -466,6 +447,7 @@ public class OperationGroupViewer implements IBonitaVariableContext, ISelectionP
*/
@Override
public void setIsOverviewContext(boolean isOverviewContext) {
//NOTHING TO DO
}
protected EReference getOperationContainmentFeature() {
......@@ -562,7 +544,6 @@ public class OperationGroupViewer implements IBonitaVariableContext, ISelectionP
}
}
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
......
......@@ -75,7 +75,6 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
public class OperationViewer extends Composite implements IBonitaVariableContext {
private final class RevalidateActionExpressionChangeListener implements IChangeListener {
......@@ -148,8 +147,8 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
public void createDatabinding(EMFDataBindingContext context) {
defaultReturnTypeResolver = new DefaultReturnTypeResolver(operationObervable);
bindStorageViewer(context,operationObervable);
bindActionExpression(context,operationObervable);
bindStorageViewer(context, operationObervable);
bindActionExpression(context, operationObervable);
updateVisibilityOfActionExpressionControl(operationObervable);
final IObservableValue rightOperandObservable = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), operationObervable,
......@@ -157,11 +156,11 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
final IObservableValue rightOperandReturnTypeObservable = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), rightOperandObservable,
ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE);
rightOperandReturnTypeObservable.addChangeListener(new RevalidateActionExpressionChangeListener());
bindOperator(context,operationObervable);
bindOperator(context, operationObervable);
}
private void bindOperator(EMFDataBindingContext context,IObservableValue operationObervable) {
private void bindOperator(EMFDataBindingContext context, IObservableValue operationObervable) {
final UpdateValueStrategy uvsOperator = new UpdateValueStrategy();
final IObservableValue operatorObservableValue = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), operationObervable,
ExpressionPackage.Literals.OPERATION__OPERATOR);
......@@ -185,7 +184,7 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
operatorExpressionObserveValue);
}
private void bindStorageViewer(EMFDataBindingContext context,final IObservableValue operationObservable) {
private void bindStorageViewer(EMFDataBindingContext context, final IObservableValue operationObservable) {
if (storageExpressionProvider != null) {
storageViewer.setExpressionNatureProvider(storageExpressionProvider);
}
......@@ -228,7 +227,7 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
});
}
private void bindActionExpression(EMFDataBindingContext context,final IObservableValue operationObservable) {
private void bindActionExpression(EMFDataBindingContext context, final IObservableValue operationObservable) {
if (actionExpressionProvider != null) {
getActionExpression().setExpressionNatureProvider(actionExpressionProvider);
}
......@@ -241,7 +240,8 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
ExpressionPackage.Literals.OPERATION__RIGHT_OPERAND);
final IObservableValue leftOperandObservableValue = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), operationObservable,
ExpressionPackage.Literals.OPERATION__LEFT_OPERAND);
final IObservableValue returnTypeExpressionObservableValue = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), actionExpressionObservableValue,
final IObservableValue returnTypeExpressionObservableValue = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
actionExpressionObservableValue,
ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE);
context.bindValue(
ViewerProperties.singleSelection().observe(getActionExpression()),
......@@ -268,8 +268,7 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
private void updateVisibilityOfActionExpressionControl(final IObservableValue operationObservableValue) {
operationObservableValue.addValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
final IObservableValue observableValue = event.getObservableValue();
......@@ -282,7 +281,7 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
}
}
});
}
protected void doCreateControls() {
......@@ -290,7 +289,7 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
setOperatorLink(createOperatorLink());
setActionExpression(createActionExpressionViewer());
}
protected Link createOperatorLink() {
final Link operatorLabel = new Link(this, SWT.NONE);
if (widgetFactory != null) {
......@@ -353,7 +352,7 @@ public class OperationViewer extends Composite implements IBonitaVariableContext
final ReadOnlyExpressionViewer storageViewer = new ReadOnlyExpressionViewer(this, SWT.BORDER, widgetFactory, getEditingDomain(),
ExpressionPackage.Literals.OPERATION__LEFT_OPERAND);
storageViewer.setIsPageFlowContext(isPageFlowContext);
storageViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().hint(230, SWT.DEFAULT).grab(false, false).create());
storageViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).grab(true, false).create());
if (storageExpressionFilter != null) {
storageViewer.addFilter(storageExpressionFilter);
}
......
......@@ -659,8 +659,7 @@ public class ExpressionViewer extends ContentViewer implements ExpressionConstan
&& filteredExpressionType.contains(ExpressionConstants.FORM_REFERENCE_TYPE)
&& filteredExpressions.isEmpty()) {
contentAssistText.setProposalEnabled(false);
}
else {
} else {
contentAssistText.setProposalEnabled(true);
}
}
......@@ -1017,18 +1016,11 @@ public class ExpressionViewer extends ContentViewer implements ExpressionConstan
final Entry<Integer, String> message = getMessageToDisplay();
if (message != null) {
messageDecoration.setDescriptionText(message.getValue());
if (message.getKey() == IStatus.INFO) {
// Issue with focus
messageDecoration.setShowOnlyOnFocus(false);
} else {
messageDecoration.setShowOnlyOnFocus(false);
}
messageDecoration.setShowOnlyOnFocus(false);
final Image icon = getImageForMessageKind(message.getKey());
if (icon != null) {
messageDecoration.setImage(icon);
}
messageDecoration.show();
} else {
......@@ -1292,7 +1284,6 @@ public class ExpressionViewer extends ContentViewer implements ExpressionConstan
@Override
public boolean isPageFlowContext() {
return isPageFlowContext;
}
......@@ -1344,9 +1335,7 @@ public class ExpressionViewer extends ContentViewer implements ExpressionConstan
try {
service.busyCursorWhile(removeOperation);
isExecuted = true;
} catch (final InvocationTargetException e) {
BonitaStudioLog.error(e);
} catch (final InterruptedException e) {
} catch (final InvocationTargetException | InterruptedException e) {
BonitaStudioLog.error(e);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment