Commit a2b8b4be authored by Romain Bioteau's avatar Romain Bioteau
Browse files

Move code

parent e3bac67a
......@@ -44,7 +44,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.9.0",
org.eclipse.gmf.runtime.diagram.ui.properties;bundle-version="1.7.0",
org.eclipse.e4.core.di,
org.bonitasoft.studio.pagedesigner;bundle-version="7.0.0",
org.bonitasoft.studio.preferences;bundle-version="7.0.0"
org.bonitasoft.studio.preferences;bundle-version="7.0.0",
org.eclipse.e4.core.di.extensions
Bundle-Activator: org.bonitasoft.studio.contract.ContractPlugin
Bundle-ActivationPolicy: lazy
Export-Package: org.bonitasoft.studio.contract.core,
......
......@@ -36,4 +36,3 @@ addContentToConstraint=Add content to constraint {0}
editContentToConstraint=Edit content to constraint {0}
emptyExpressionContent=Empty expression content
noContractInputReferencedInExpression=No contract input is referenced in the expression
newFormTooltip=Create a new Form that will be mapped to this step
\ No newline at end of file
......@@ -63,6 +63,5 @@ public class Messages extends NLS {
public static String editContentToConstraint;
public static String emptyExpressionContent;
public static String noContractInputReferencedInExpression;
public static String newFormTooltip;
}
......@@ -18,6 +18,7 @@ import javax.inject.Inject;
import org.bonitasoft.studio.common.jface.databinding.CustomEMFEditObservables;
import org.bonitasoft.studio.common.properties.AbstractBonitaDescriptionSection;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.contract.core.validation.ContractDefinitionValidator;
import org.bonitasoft.studio.contract.i18n.Messages;
import org.bonitasoft.studio.contract.ui.property.constraint.ContractConstraintController;
......@@ -29,6 +30,7 @@ import org.bonitasoft.studio.model.process.ContractConstraint;
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.pagedesigner.ui.contribution.NewFormContributionItem;
import org.eclipse.core.databinding.UpdateValueStrategy;
import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.core.databinding.observable.Realm;
......@@ -38,6 +40,8 @@ import org.eclipse.core.databinding.observable.list.ListChangeEvent;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.e4.core.di.extensions.Preference;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.databinding.EMFObservables;
......@@ -57,6 +61,7 @@ import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.progress.IProgressService;
/**
* @author Romain Bioteau
......@@ -71,9 +76,19 @@ public class ContractPropertySection extends AbstractBonitaDescriptionSection {
private ContractConstraintController constraintController;
@Inject
@Preference
private IEclipsePreferences preferenceStore;
@Inject
private TaskAdaptableSelectionProvider selectionProvider;
@Inject
private RepositoryAccessor repositoryAccessor;
@Inject
private IProgressService progressService;
@Override
public String getSectionDescription() {
return Messages.contractSectionDescription;
......@@ -94,7 +109,8 @@ public class ContractPropertySection extends AbstractBonitaDescriptionSection {
@Override
protected void updateToolbar(final IToolBarManager toolbarManager) {
toolbarManager.add(new NewFormContributionItem(ViewersObservables.observeSingleSelection(selectionProvider)));
toolbarManager.add(new NewFormContributionItem(preferenceStore, progressService, ViewersObservables.observeSingleSelection(selectionProvider),
repositoryAccessor));
}
@Override
......
......@@ -11,7 +11,8 @@ Export-Package: org.bonitasoft.studio.pagedesigner,
org.bonitasoft.studio.pagedesigner.core,
org.bonitasoft.studio.pagedesigner.core.expression,
org.bonitasoft.studio.pagedesigner.core.repository,
org.bonitasoft.studio.pagedesigner.core.resources
org.bonitasoft.studio.pagedesigner.core.resources,
org.bonitasoft.studio.pagedesigner.ui.contribution
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.bonitasoft.studio.browser;bundle-version="6.5.0",
......@@ -41,7 +42,9 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.jface,
org.eclipse.e4.core.di.extensions;bundle-version="0.12.0",
org.eclipse.core.databinding.beans;bundle-version="1.2.200",
org.eclipse.core.databinding.property;bundle-version="1.4.200"
org.eclipse.core.databinding.property;bundle-version="1.4.200",
org.bonitasoft.studio.model.edit,
org.bonitasoft.studio.pics
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
Import-Package: org.bonitasoft.engine.bpm.bar,
......
......@@ -6,5 +6,6 @@ bin.includes = META-INF/,\
plugin.properties,\
lib/,\
messages.properties,\
webapp/
webapp/,\
icons/
source.. = src/
......@@ -10,4 +10,5 @@ url=URL
pageDoesntExists=Page \'{0}\' doesn't exists.
caseStartFormMappingDescription=Select the form that the user will see to start a case.
entryFormMappingDescription=Select the form that the user will see for this Task.
caseOverviewFormMappingDescription=Select the form that the user will see when consulting a finished case.
\ No newline at end of file
caseOverviewFormMappingDescription=Select the form that the user will see when consulting a finished case.
newFormTooltip=Create a new form that will be automatically mapped to this Task.
\ No newline at end of file
......@@ -34,6 +34,7 @@ public class Messages extends NLS {
public static String caseStartFormMappingDescription;
public static String entryFormMappingDescription;
public static String caseOverviewFormMappingDescription;
public static String newFormTooltip;
static {
NLS.initializeMessages("messages", Messages.class);
......
......@@ -12,14 +12,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.contract.ui.property;
package org.bonitasoft.studio.pagedesigner.ui.contribution;
import static org.assertj.core.util.Strings.isNullOrEmpty;
import static com.google.common.base.Strings.isNullOrEmpty;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.repository.RepositoryAccessor;
import org.bonitasoft.studio.contract.ContractPlugin;
import org.bonitasoft.studio.contract.i18n.Messages;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.ExpressionPackage;
import org.bonitasoft.studio.model.expression.provider.ExpressionItemProvider;
......@@ -29,39 +27,37 @@ import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.model.process.Task;
import org.bonitasoft.studio.model.process.provider.FormMappingItemProvider;
import org.bonitasoft.studio.model.process.provider.ProcessItemProviderAdapterFactory;
import org.bonitasoft.studio.pagedesigner.PageDesignerPlugin;
import org.bonitasoft.studio.pagedesigner.core.expression.CreateNewFormProposalListener;
import org.bonitasoft.studio.pagedesigner.core.repository.WebPageFileStore;
import org.bonitasoft.studio.pagedesigner.core.repository.WebPageRepositoryStore;
import org.bonitasoft.studio.pagedesigner.i18n.Messages;
import org.bonitasoft.studio.pics.Pics;
import org.bonitasoft.studio.preferences.BonitaStudioPreferencesPlugin;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IContributionManager;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.action.ContributionItem;
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.Menu;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
/**
* @author Romain Bioteau
*/
public class NewFormContributionItem implements IContributionItem {
public class NewFormContributionItem extends ContributionItem {
private final IObservableValue selectionObservableValue;
private ToolItem toolItem;
private final CreateNewFormProposalListener createNewFormListener;
private final RepositoryAccessor repositoryAccessor;
public NewFormContributionItem(final IObservableValue selectionObservableValue) {
public NewFormContributionItem(final IEclipsePreferences preferenceStore, final IProgressService progressService,
final IObservableValue selectionObservableValue, final RepositoryAccessor repositoryAccessor) {
this.selectionObservableValue = selectionObservableValue;
}
@Override
public void update(final String arg0) {
createNewFormListener = new CreateNewFormProposalListener(preferenceStore, progressService);
this.repositoryAccessor = repositoryAccessor;
}
@Override
......@@ -71,36 +67,6 @@ public class NewFormContributionItem implements IContributionItem {
}
}
@Override
public void setVisible(final boolean arg0) {
}
@Override
public void setParent(final IContributionManager arg0) {
}
@Override
public void saveWidgetState() {
}
@Override
public boolean isVisible() {
return true;
}
@Override
public boolean isSeparator() {
return false;
}
@Override
public boolean isGroupMarker() {
return false;
}
@Override
public boolean isEnabled() {
final Task task = (Task) selectionObservableValue.getValue();
......@@ -111,85 +77,44 @@ public class NewFormContributionItem implements IContributionItem {
return false;
}
@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) {
}
@Override
public void fill(final ToolBar toolbar, final int arg1) {
toolItem = new ToolItem(toolbar, SWT.LEFT | SWT.PUSH | SWT.NO_FOCUS);
toolItem.setEnabled(false);
toolItem.setToolTipText(Messages.newFormTooltip);
toolItem.setImage(Pics.getImage("new_form.png", ContractPlugin.getDefault()));
final CreateNewFormProposalListener createNewFormProposalListener = new CreateNewFormProposalListener(
InstanceScope.INSTANCE.getNode(BonitaStudioPreferencesPlugin.PLUGIN_ID), PlatformUI.getWorkbench().getProgressService());
toolItem.setImage(Pics.getImage("new_form.png", PageDesignerPlugin.getDefault()));
toolItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final Task task = (Task) selectionObservableValue.getValue();
final String newPageId = createNewFormProposalListener.handleEvent(task.getFormMapping(), null);
final ExpressionItemProvider expressionItemProvider = new ExpressionItemProvider(new ExpressionItemProviderAdapterFactory());
final RepositoryAccessor repositoryAccessor = getRepositoryAccessor();
final WebPageRepositoryStore repositoryStore = repositoryAccessor.getRepositoryStore(WebPageRepositoryStore.class);
repositoryStore.refresh();
final WebPageFileStore webPageFileStore = repositoryStore.getChild(newPageId + ".json");
if (webPageFileStore != null) {
final Expression targetForm = task.getFormMapping().getTargetForm();
expressionItemProvider.setPropertyValue(targetForm,
ExpressionPackage.Literals.EXPRESSION__NAME.getName(), webPageFileStore.getDisplayName());
expressionItemProvider.setPropertyValue(targetForm,
ExpressionPackage.Literals.EXPRESSION__CONTENT.getName(), newPageId);
expressionItemProvider.setPropertyValue(targetForm,
ExpressionPackage.Literals.EXPRESSION__TYPE.getName(), ExpressionConstants.FORM_REFERENCE_TYPE);
expressionItemProvider.setPropertyValue(targetForm,
ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE.getName(), String.class.getName());
expressionItemProvider.setPropertyValue(targetForm,
ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE_FIXED.getName(), true);
final FormMappingItemProvider formMappingItemProvider = new FormMappingItemProvider(new ProcessItemProviderAdapterFactory());
formMappingItemProvider.setPropertyValue(task.getFormMapping(), ProcessPackage.Literals.FORM_MAPPING__EXTERNAL.getName(), false);
toolItem.setEnabled(false);
}
createNewForm();
}
});
}
protected RepositoryAccessor getRepositoryAccessor() {
final RepositoryAccessor repositoryAccessor = new RepositoryAccessor();
repositoryAccessor.init();
return repositoryAccessor;
}
@Override
public void fill(final Menu parent, final int index) {
}
@Override
public void fill(final Composite arg0) {
protected void createNewForm() {
final Task task = (Task) selectionObservableValue.getValue();
final String newPageId = createNewFormListener.handleEvent(task.getFormMapping(), null);
final ExpressionItemProvider expressionItemProvider = new ExpressionItemProvider(new ExpressionItemProviderAdapterFactory());
final WebPageRepositoryStore repositoryStore = repositoryAccessor.getRepositoryStore(WebPageRepositoryStore.class);
repositoryStore.refresh();
final WebPageFileStore webPageFileStore = repositoryStore.getChild(newPageId + ".json");
if (webPageFileStore != null) {
final Expression targetForm = task.getFormMapping().getTargetForm();
expressionItemProvider.setPropertyValue(targetForm,
ExpressionPackage.Literals.EXPRESSION__NAME.getName(), webPageFileStore.getDisplayName());
expressionItemProvider.setPropertyValue(targetForm,
ExpressionPackage.Literals.EXPRESSION__CONTENT.getName(), newPageId);
expressionItemProvider.setPropertyValue(targetForm,
ExpressionPackage.Literals.EXPRESSION__TYPE.getName(), ExpressionConstants.FORM_REFERENCE_TYPE);
expressionItemProvider.setPropertyValue(targetForm,
ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE.getName(), String.class.getName());
expressionItemProvider.setPropertyValue(targetForm,
ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE_FIXED.getName(), true);
final FormMappingItemProvider formMappingItemProvider = new FormMappingItemProvider(new ProcessItemProviderAdapterFactory());
formMappingItemProvider.setPropertyValue(task.getFormMapping(), ProcessPackage.Literals.FORM_MAPPING__EXTERNAL.getName(), false);
toolItem.setEnabled(false);
}
}
@Override
public void dispose() {
}
}
Supports Markdown
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