Commit 78858adf authored by Romain Bioteau's avatar Romain Bioteau
Browse files

Update ui from feedbacks

parent cd2f8b32
......@@ -188,7 +188,7 @@
<propertyTabs
contributorId="org.bonitasoft.studio.diagram">
<propertyTab
afterTab="tab.lane"
afterTab="tab.data"
category="domain"
id="tab.actors"
label="%actor_tab_label">
......
......@@ -54,5 +54,7 @@ public interface SWTBotConstants {
public static final String SQLBUILDER_CRITERIA_TREE_ID = "sqlBuilderCriteriaTreeId";
public static final String APPLICATION_SECTION_FORMS_SELECTION_TREE = "org.bonitasoft.studio.application.formTree";;
public static final String APPLICATION_SECTION_FORMS_SELECTION_TREE = "org.bonitasoft.studio.application.formTree";
public static final String SWTBOT_ID_INPUT_NAME_TEXTEDITOR = "SWTBOT_ID_INPUT_NAME_TEXTEDITOR";
}
......@@ -43,15 +43,12 @@ public abstract class AbstractBonitaDescriptionSection extends AbstractModelerPr
public void refresh(){
super.refresh();
if(tabbedPropertySheetPage != null){
final ITabDescriptor tab = tabbedPropertySheetPage.getSelectedTab();
if (tab != null && form != null) {
form.setText(tab.getLabel()/* + " " + Messages.descriptionTitle */);
if (form != null) {
form.setText(getSectionTitle());
}
}
}
@Override
public void createControls(final Composite parent, final TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
......@@ -59,8 +56,6 @@ public abstract class AbstractBonitaDescriptionSection extends AbstractModelerPr
tabbedPropertySheetPage=aTabbedPropertySheetPage;
final TabbedPropertySheetWidgetFactory widgetFactory = tabbedPropertySheetPage.getWidgetFactory();
form = widgetFactory.createForm(parent);
// widgetFactory.decorateFormHeading(form);
form.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).create());
form.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
form.getBody().setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).create());
......@@ -69,11 +64,7 @@ public abstract class AbstractBonitaDescriptionSection extends AbstractModelerPr
form.getToolBarManager().add(new TogglePropertyHelpContributionItem(widgetFactory, form, getSectionDescription()));
form.getToolBarManager().update(true);
final ITabDescriptor tab = tabbedPropertySheetPage.getSelectedTab();
if(tab != null){
form.setText(tab.getLabel()/* + " " + Messages.descriptionTitle */);
}
form.setText(getSectionTitle());
createContent(form.getBody());
form.update();
......@@ -98,6 +89,14 @@ public abstract class AbstractBonitaDescriptionSection extends AbstractModelerPr
return tabbedPropertySheetPage;
}
public String getSectionTitle() {
final ITabDescriptor tab = tabbedPropertySheetPage.getSelectedTab();
if (tab != null) {
return tab.getLabel();
}
return "";
}
public abstract String getSectionDescription();
......
......@@ -17,9 +17,11 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.9.0",
org.bonitasoft.studio.common.repository;bundle-version="6.4.0",
org.bonitasoft.studio.data,
org.eclipse.jdt.ui,
org.bonitasoft.studio.model.edit
org.bonitasoft.studio.model.edit,
org.bonitasoft.studio.pics;bundle-version="6.4.0"
Bundle-Activator: org.bonitasoft.studio.contract.ContractPlugin
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.contract.core
Export-Package: org.bonitasoft.studio.contract.core,
org.bonitasoft.studio.contract.i18n;x-friends:="org.bonitasoft.studio.swtbot.framework"
Import-Package: org.bonitasoft.engine.bpm.contract,
org.bonitasoft.engine.bpm.process.impl
......@@ -6,10 +6,10 @@
<propertyTabs
contributorId="org.bonitasoft.studio.diagram">
<propertyTab
afterTab="tab.actors"
afterTab="tab.lane"
category="domain"
id="tab.contract"
label="%tab.contract.label">
id="tab.inputs"
label="%tab.inputs.label">
</propertyTab>
</propertyTabs>
</extension>
......@@ -21,8 +21,8 @@
class="org.bonitasoft.studio.contract.ui.property.ContractPropertySection"
enablesFor="1"
filter="org.bonitasoft.studio.contract.ui.property.TaskFilter"
id="ContractSection"
tab="tab.contract"
id="InputsSection"
tab="tab.inputs"
viewID="org.bonitasoft.studio.views.properties.process.general">
</propertySection>
</propertySections>
......
......@@ -33,6 +33,8 @@ import org.bonitasoft.studio.model.process.ContractInputType;
import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.value.IObservableValue;
......@@ -42,7 +44,9 @@ import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.databinding.swt.SWTObservables;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
import org.eclipse.jface.databinding.viewers.ViewersObservables;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
......@@ -112,7 +116,7 @@ public class ContractPropertySection extends EObjectSelectionProviderSection {
private void createContractInputTable(final Composite parent) {
final Composite buttonsComposite = getWidgetFactory().createComposite(parent);
buttonsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).align(SWT.FILL, SWT.TOP).create());
buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).spacing(0, 3).create());
buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).spacing(0, 3).extendedMargins(0, 0, 25, 0).create());
final Button addButton = getWidgetFactory().createButton(buttonsComposite, Messages.add, SWT.PUSH);
addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
......@@ -122,7 +126,7 @@ public class ContractPropertySection extends EObjectSelectionProviderSection {
removeButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
final TableViewer inputsTableViewer = new TableViewer(getWidgetFactory().createTable(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE));
final TableViewer inputsTableViewer = new TableViewer(getWidgetFactory().createTable(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI));
inputsTableViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(500, 180).create());
inputsTableViewer.getTable().setHeaderVisible(true);
final ObservableListContentProvider observableListContentProvider = new ObservableListContentProvider();
......@@ -176,6 +180,18 @@ public class ContractPropertySection extends EObjectSelectionProviderSection {
validate((Contract) event.diff.getNewValue());
}
});
final UpdateValueStrategy modelStrategy = new UpdateValueStrategy();
modelStrategy.setConverter(new Converter(Object.class,Boolean.class) {
@Override
public Object convert(final Object from) {
return from != null;
}
});
context.bindValue(SWTObservables.observeEnabled(removeButton), ViewersObservables.observeSingleSelection(inputsTableViewer),new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),modelStrategy);
inputsTableViewer.getTable().setFocus();
}
......@@ -203,10 +219,11 @@ public class ContractPropertySection extends EObjectSelectionProviderSection {
public Image getImage(final Object object) {
return null;
}
});
nameColumnViewer
.setEditingSupport(new InputNamePropertyEditingSupport(propertySourceProvider, viewer, adapterFactoryLabelProvider,
new ContractDefinitionValidator(getMessageManager())));
.setEditingSupport(new InputNamePropertyEditingSupport(propertySourceProvider, viewer, adapterFactoryLabelProvider,
new ContractDefinitionValidator(getMessageManager())));
}
protected void createInputDescriptionColumn(final TableViewer viewer) {
......
......@@ -19,6 +19,7 @@ package org.bonitasoft.studio.contract.ui.property.edit;
import java.util.Date;
import org.bonitasoft.studio.common.DataUtil;
import org.bonitasoft.studio.common.jface.SWTBotConstants;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.contract.core.ContractDefinitionValidator;
import org.bonitasoft.studio.contract.i18n.Messages;
......@@ -29,8 +30,9 @@ import org.bonitasoft.studio.model.process.ContractInput;
import org.bonitasoft.studio.model.process.ContractInputMapping;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.pics.PicsConstants;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
......@@ -41,9 +43,15 @@ import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalListener;
import org.eclipse.jface.fieldassist.TextContentAdapter;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellEditorListener;
import org.eclipse.jface.viewers.ICellEditorValidator;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.jface.window.DefaultToolTip;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyEditingSupport;
......@@ -52,12 +60,15 @@ import org.eclipse.ui.views.properties.PropertyEditingSupport;
* @author Romain Bioteau
*
*/
public class InputNamePropertyEditingSupport extends PropertyEditingSupport implements ICellEditorValidator {
public class InputNamePropertyEditingSupport extends PropertyEditingSupport implements ICellEditorValidator, ICellEditorListener {
private Object currentElement;
private final AdapterFactoryLabelProvider adapterFactoryLabelProvider;
private final ContractDefinitionValidator contractDefinitionValidator;
private DefaultToolTip toolTip;
private boolean validate = false;
private Object cuurentValue;
public InputNamePropertyEditingSupport(final AdapterFactoryContentProvider propertySourceProvider, final TableViewer viewer,
final AdapterFactoryLabelProvider adapterFactoryLabelProvider, final ContractDefinitionValidator contractDefinitionValidator) {
......@@ -75,18 +86,42 @@ public class InputNamePropertyEditingSupport extends PropertyEditingSupport impl
@Override
protected CellEditor getCellEditor(final Object element) {
if (element instanceof ContractInput) {
validate = false;
final TextCellEditor cellEditor = (TextCellEditor) super.getCellEditor(element);
currentElement = element;
attachContentAssist(element, cellEditor);
createTooltip(cellEditor);
cellEditor.setValidator(this);
cellEditor.addListener(this);
cellEditor.getControl().addControlListener(new ControlListener() {
@Override
public void controlResized(final ControlEvent arg0) {
}
@Override
public void controlMoved(final ControlEvent event) {
toolTip.show(new Point(0, 20));
}
});
return cellEditor;
}
return null;
}
private void createTooltip(final TextCellEditor cellEditor) {
toolTip = new DefaultToolTip(cellEditor.getControl(), SWT.ICON_INFORMATION, true);
toolTip.setText(Messages.automaticMappingTooltip);
toolTip.setImage(Pics.getImage(PicsConstants.hint));
toolTip.setHideDelay(10000);
toolTip.setHideOnMouseDown(false);
}
protected void attachContentAssist(final Object element, final TextCellEditor cellEditor) {
final Text textControl = (Text) cellEditor.getControl();
textControl.setToolTipText(Messages.automaticMappingTooltip);
textControl.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_INPUT_NAME_TEXTEDITOR);
KeyStroke keyStroke = null;
try {
keyStroke = KeyStroke.getInstance("Ctrl+Space");
......@@ -154,12 +189,28 @@ public class InputNamePropertyEditingSupport extends PropertyEditingSupport impl
@Override
public String isValid(final Object value) {
final IStatus status = contractDefinitionValidator.validateInputName((ContractInput) currentElement, (String) value);
if (!status.isOK()) {
return status.getMessage();
if (validate || getValue(currentElement) != null) {
contractDefinitionValidator.validateInputName((ContractInput) currentElement, (String) value);
}
cuurentValue = value;
return null;
}
@Override
public void applyEditorValue() {
toolTip.hide();
validate = true;
isValid(cuurentValue);
}
@Override
public void cancelEditor() {
toolTip.hide();
}
@Override
public void editorValueChanged(final boolean oldValidState, final boolean newValidState) {
validate = oldValidState || newValidState;
}
}
......@@ -121,7 +121,6 @@ public class InputMappingProposalProvider implements IContentProposalProvider {
return compatibleTypes.contains(inputType);
}
@SuppressWarnings("restriction")
protected String toJavaType(final IMethod method) {
String qualifiedType = Object.class.getName();
try {
......
......@@ -27,7 +27,7 @@
<propertyTabs
contributorId="org.bonitasoft.studio.diagram">
<propertyTab
afterTab="tab.lane"
afterTab="tab.inputs"
category="domain"
id="tab.data"
label="%tab.data.label">
......
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