Commit 01e3ea7a authored by azara's avatar azara
Browse files

BS-13466 Guidance in Studio

allow to change section description according to the section context
change contract description 
parent 2ee4c0aa
......@@ -34,15 +34,21 @@ public abstract class AbstractBonitaDescriptionSection extends AbstractModelerPr
protected Form form;
private TabbedPropertySheetPage tabbedPropertySheetPage;
private TogglePropertyHelpContributionItem togglePropertyHelpContributionItem;
@Override
public void refresh() {
super.refresh();
if (form != null) {
form.setText(getSectionTitle());
updateSectionDescription();
}
}
protected void updateSectionDescription() {
togglePropertyHelpContributionItem.setHelpContent(getSectionDescription());
}
@Override
public void createControls(final Composite parent, final TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
......@@ -61,7 +67,7 @@ public abstract class AbstractBonitaDescriptionSection extends AbstractModelerPr
form.setToolBarVerticalAlignment(SWT.CENTER);
final TogglePropertyHelpContributionItem togglePropertyHelpContributionItem = new TogglePropertyHelpContributionItem(widgetFactory, form,
togglePropertyHelpContributionItem = new TogglePropertyHelpContributionItem(widgetFactory, form,
getSectionDescription());
updateToolbar(form.getToolBarManager());
form.getToolBarManager().add(togglePropertyHelpContributionItem);
......
......@@ -15,15 +15,13 @@
package org.bonitasoft.studio.common.properties;
import org.bonitasoft.studio.common.Messages;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IContributionManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
......@@ -35,9 +33,9 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
/**
* @author Romain Bioteau
*/
public class TogglePropertyHelpContributionItem implements IContributionItem {
public class TogglePropertyHelpContributionItem extends ContributionItem implements IContributionItem {
private final String helpContent;
private String helpContent;
private final Form form;
private final FormToolkit toolkit;
private Label decriptionLabel;
......@@ -49,70 +47,11 @@ public class TogglePropertyHelpContributionItem implements IContributionItem {
this.toolkit = toolkit;
}
@Override
public void update(final String arg0) {
}
@Override
public void update() {
}
@Override
public void setVisible(final boolean arg0) {
}
@Override
public void setParent(final IContributionManager arg0) {
}
@Override
public void saveWidgetState() {
}
@Override
public boolean isVisible() {
return helpContent != null && !helpContent.isEmpty();
}
@Override
public boolean isSeparator() {
return false;
}
@Override
public boolean isGroupMarker() {
return false;
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public boolean isDynamic() {
return false;
}
@Override
public boolean isDirty() {
return false;
}
@Override
public String getId() {
return null;
}
@Override
public void fill(final CoolBar arg0, final int arg1) {
}
protected void toggleHelp() {
if (decriptionLabel != null) {
decriptionLabel.dispose();
......@@ -164,13 +103,15 @@ public class TogglePropertyHelpContributionItem implements IContributionItem {
menuItem.setSelection(decriptionLabel != null);
}
@Override
public void fill(final Composite arg0) {
public void setHelpContent(final String helpContent) {
this.helpContent = helpContent;
if (decriptionLabel != null) {
decriptionLabel.setText(helpContent);
}
}
@Override
public void dispose() {
public String getHelpContent() {
return helpContent;
}
}
contractSectionDescription=Define a contract for this step or pool instantiation.
processContractSectionDescription=A contract defines the information that a process requires for instantiation.\nAfter you have defined the contract, you can generate the form by clicking the UI designer icon on the right of this panel. This generates a form with the relevant widgets and data bindings for the contract inputs. You must handle constraints with validation in the form.\nYou can use contract input values as the initial value of variables, documents and search keys or in connectors in (on enter).
stepContractSectionDescription=A contract defines the information that a task requires to execute. If inputs are missing or constraints are not fulfilled on form submission, the task is not executed and stays ready.\nAfter you have defined the contract, you can generate the form by clicking the UI designer icon on the right of this panel. This generates a form with the relevant widgets and data bindings for the contract inputs. You must handle constraints with validation in the form.\nYou can use a contract input value in operations and connectors out (on finish).
name=Name
type=Type
mandatory=Mandatory
......
......@@ -16,20 +16,26 @@ package org.bonitasoft.studio.contract.ui.property;
import static org.assertj.core.api.Assertions.assertThat;
import static org.bonitasoft.studio.model.process.builders.ContractBuilder.aContract;
import static org.bonitasoft.studio.model.process.builders.PoolBuilder.aPool;
import static org.bonitasoft.studio.model.process.builders.TaskBuilder.aTask;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import org.bonitasoft.studio.contract.i18n.Messages;
import org.bonitasoft.studio.designer.ui.contribution.CreateAndEditFormContributionItem;
import org.bonitasoft.studio.model.process.Contract;
import org.bonitasoft.studio.model.process.ContractInput;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.bonitasoft.studio.model.process.Pool;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.bonitasoft.studio.model.process.Task;
import org.bonitasoft.studio.swt.AbstractSWTTestCase;
import org.eclipse.core.databinding.observable.value.WritableValue;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
......@@ -37,6 +43,7 @@ import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.progress.IProgressService;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
......@@ -72,6 +79,9 @@ public class ContractPropertySectionTest extends AbstractSWTTestCase {
@Mock
private IProgressService progressService;
@Mock
private IWorkbenchPart part;
/**
* @throws java.lang.Exception
*/
......@@ -148,4 +158,18 @@ public class ContractPropertySectionTest extends AbstractSWTTestCase {
assertThat(button.isEnabled()).isTrue();
}
@Test
public void should_getSectionDescription_return_processMessage() {
final Pool pool = aPool().havingContract(aContract()).build();
section.init(new WritableValue(pool.getContract(), Contract.class));
assertThat(section.getSectionDescription()).isEqualTo(Messages.processContractSectionDescription);
}
@Test
public void should_getSectionDescription_return_stepMessage() {
final Task task = aTask().havingContract(aContract()).build();
section.init(new WritableValue(task.getContract(), Contract.class));
doReturn(aTask().build()).when(selectionProvider).getAdapter(EObject.class);
assertThat(section.getSectionDescription()).isEqualTo(Messages.stepContractSectionDescription);
}
}
......@@ -25,7 +25,8 @@ public class Messages extends NLS {
NLS.initializeMessages("messages", Messages.class);//$NON-NLS-1$
}
public static String contractSectionDescription;
public static String processContractSectionDescription;
public static String stepContractSectionDescription;
public static String name;
public static String type;
public static String mandatory;
......
......@@ -34,6 +34,7 @@ import org.bonitasoft.studio.model.process.ContractContainer;
import org.bonitasoft.studio.model.process.ContractInput;
import org.bonitasoft.studio.model.process.ContractInputType;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.model.process.Task;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.Realm;
......@@ -95,7 +96,11 @@ public class ContractPropertySection extends AbstractBonitaDescriptionSection {
@Override
public String getSectionDescription() {
return Messages.contractSectionDescription;
final Object selection = selectionProvider.getAdapter(EObject.class);
if (selection != null && selection instanceof Task) {
return Messages.stepContractSectionDescription;
}
return Messages.processContractSectionDescription;
}
@Override
......
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