From 3a1dcbf5a28fe4a5aac4c1dd805cd9dae55f5d95 Mon Sep 17 00:00:00 2001 From: Alexander Fedorov Date: Sat, 7 Aug 2021 21:19:08 +0300 Subject: [PATCH] Bug 575165 - [Passage][Operator] License Agreement management: gui Add org.eclipse.passage.loc.agreements.emfforms Signed-off-by: Alexander Fedorov --- .../OSGI-INF/l10n/bundle.properties | 2 +- .../build.properties | 2 +- .../plugin.xml | 2 +- .../plugin.properties | 7 +- .../AgreementsGroupItemProvider.java | 2 +- .../model/agreements.genmodel | 2 +- .../.classpath | 7 + .../.project | 39 ++++++ .../.settings/org.eclipse.jdt.core.prefs | 101 +++++++++++++++ .../.settings/org.eclipse.jdt.ui.prefs | 122 ++++++++++++++++++ .../org.eclipse.pde.ds.annotations.prefs | 8 ++ .../.settings/org.eclipse.pde.prefs | 34 +++++ .../META-INF/MANIFEST.MF | 37 ++++++ .../OSGI-INF/l10n/bundle.properties | 23 ++++ ...greementGroupIdentifierRendererService.xml | 9 ++ ...rs.AgreementsIdentifierRendererService.xml | 9 ++ .../about.html | 36 ++++++ .../build.properties | 21 +++ .../fragment.e4xmi | 6 + .../plugin.xml | 24 ++++ .../AgreementsCreateElementCallback.java | 34 +++++ .../emfforms/parts/AgreementsDetailsPart.java | 46 +++++++ ...reementGroupIdentifierRendererService.java | 55 ++++++++ .../AgreementIdentifierRenderer.java | 90 +++++++++++++ .../AgreementsIdentifierRendererService.java | 55 ++++++++ .../loc/agreements/ui/AgreementsUi.java | 21 ++- .../META-INF/MANIFEST.MF | 3 +- .../pom.xml | 3 +- 28 files changed, 784 insertions(+), 16 deletions(-) create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/.classpath create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/.project create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/.settings/org.eclipse.jdt.core.prefs create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/.settings/org.eclipse.jdt.ui.prefs create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/.settings/org.eclipse.pde.ds.annotations.prefs create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/.settings/org.eclipse.pde.prefs create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/META-INF/MANIFEST.MF create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/OSGI-INF/l10n/bundle.properties create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/OSGI-INF/org.eclipse.passage.loc.agreements.emfforms.renderers.AgreementGroupIdentifierRendererService.xml create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/OSGI-INF/org.eclipse.passage.loc.agreements.emfforms.renderers.AgreementsIdentifierRendererService.xml create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/about.html create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/build.properties create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/fragment.e4xmi create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/plugin.xml create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/parts/AgreementsCreateElementCallback.java create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/parts/AgreementsDetailsPart.java create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementGroupIdentifierRendererService.java create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementIdentifierRenderer.java create mode 100644 bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementsIdentifierRendererService.java diff --git a/bundles/org.eclipse.passage.lic.agreements.e4.ui/OSGI-INF/l10n/bundle.properties b/bundles/org.eclipse.passage.lic.agreements.e4.ui/OSGI-INF/l10n/bundle.properties index 67275e5d0..8adcd564b 100644 --- a/bundles/org.eclipse.passage.lic.agreements.e4.ui/OSGI-INF/l10n/bundle.properties +++ b/bundles/org.eclipse.passage.lic.agreements.e4.ui/OSGI-INF/l10n/bundle.properties @@ -14,7 +14,7 @@ Bundle-Name = Passage LIC Agreements E4 UI Bundle-Vendor = Eclipse Passage -Bundle-Copyright = Copyright (c) 2021 ArSysOp and others.\n\ +Bundle-Copyright = Copyright (c) 2021 ArSysOp.\n\ \n\ This program and the accompanying materials are made\n\ available under the terms of the Eclipse Public License 2.0\n\ diff --git a/bundles/org.eclipse.passage.lic.agreements.e4.ui/build.properties b/bundles/org.eclipse.passage.lic.agreements.e4.ui/build.properties index f0e3e9789..c364a0e34 100644 --- a/bundles/org.eclipse.passage.lic.agreements.e4.ui/build.properties +++ b/bundles/org.eclipse.passage.lic.agreements.e4.ui/build.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2021 ArSysOp and others +# Copyright (c) 2021 ArSysOp # # This program and the accompanying materials are made available under the # terms of the Eclipse Public License 2.0 which is available at diff --git a/bundles/org.eclipse.passage.lic.agreements.e4.ui/plugin.xml b/bundles/org.eclipse.passage.lic.agreements.e4.ui/plugin.xml index 01954ced6..3cc759922 100644 --- a/bundles/org.eclipse.passage.lic.agreements.e4.ui/plugin.xml +++ b/bundles/org.eclipse.passage.lic.agreements.e4.ui/plugin.xml @@ -1,7 +1,7 @@ + + + + + + + + diff --git a/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/parts/AgreementsCreateElementCallback.java b/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/parts/AgreementsCreateElementCallback.java new file mode 100644 index 000000000..9a17b0d41 --- /dev/null +++ b/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/parts/AgreementsCreateElementCallback.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2021 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.loc.agreements.emfforms.parts; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emfforms.spi.swt.treemasterdetail.util.CreateElementCallback; + +public class AgreementsCreateElementCallback implements CreateElementCallback { + + @Override + public void initElement(EObject parent, EReference reference, EObject newObject) { + } + + @Override + public boolean beforeCreateElement(Object newElement) { + return true; + } + + @Override + public void afterCreateElement(Object newElement) { + } + +} diff --git a/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/parts/AgreementsDetailsPart.java b/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/parts/AgreementsDetailsPart.java new file mode 100644 index 000000000..83940b7a0 --- /dev/null +++ b/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/parts/AgreementsDetailsPart.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (c) 2021 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.loc.agreements.emfforms.parts; + +import javax.inject.Inject; + +import org.eclipse.e4.core.contexts.IEclipseContext; +import org.eclipse.e4.core.di.annotations.Optional; +import org.eclipse.e4.ui.di.UIEventTopic; +import org.eclipse.e4.ui.model.application.ui.basic.MPart; +import org.eclipse.e4.ui.workbench.modeling.ESelectionService; +import org.eclipse.emfforms.spi.swt.treemasterdetail.util.CreateElementCallback; +import org.eclipse.passage.lic.agreements.model.api.AgreementsGroup; +import org.eclipse.passage.loc.internal.agreements.AgreementRegistryEvents; +import org.eclipse.passage.loc.workbench.emfforms.parts.DetailsView; + +public class AgreementsDetailsPart extends DetailsView { + + @Inject + public AgreementsDetailsPart(MPart part, ESelectionService selectionService) { + super(part, selectionService); + } + + @Inject + @Optional + public void showFeatureSet(@UIEventTopic(AgreementRegistryEvents.AGREEMENTS_GROUP_CREATE) AgreementsGroup input, + IEclipseContext context) { + show(input, context); + } + + @Override + protected CreateElementCallback getCreateElementCallback() { + return new AgreementsCreateElementCallback(); + } + +} diff --git a/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementGroupIdentifierRendererService.java b/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementGroupIdentifierRendererService.java new file mode 100644 index 000000000..4d1d51535 --- /dev/null +++ b/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementGroupIdentifierRendererService.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2021 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.loc.agreements.emfforms.renderers; + +import org.eclipse.emf.ecp.view.spi.model.VControl; +import org.eclipse.emfforms.spi.common.report.ReportService; +import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding; +import org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService; +import org.eclipse.passage.lic.agreements.model.meta.AgreementsPackage; +import org.eclipse.passage.loc.workbench.emfforms.renderers.StructuredFeatureRendererService; +import org.eclipse.passage.loc.workbench.emfforms.renderers.ValidatedTextRenderer; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; + +@Component +public class AgreementGroupIdentifierRendererService extends StructuredFeatureRendererService + implements EMFFormsDIRendererService { + + public AgreementGroupIdentifierRendererService() { + super(ValidatedTextRenderer.class, AgreementsPackage.eINSTANCE.getAgreementsGroup_Identifier()); + } + + @Reference + @Override + public void bindEMFFormsDatabinding(EMFFormsDatabinding databindingService) { + super.bindEMFFormsDatabinding(databindingService); + } + + @Override + public void unbindEMFFormsDatabinding(EMFFormsDatabinding databindingService) { + super.unbindEMFFormsDatabinding(databindingService); + } + + @Reference + @Override + public void bindReportService(ReportService reportService) { + super.bindReportService(reportService); + } + + @Override + public void unbindReportService(ReportService reportService) { + super.unbindReportService(reportService); + } + +} diff --git a/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementIdentifierRenderer.java b/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementIdentifierRenderer.java new file mode 100644 index 000000000..e32f672a6 --- /dev/null +++ b/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementIdentifierRenderer.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 2021 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.loc.agreements.emfforms.renderers; + +import javax.inject.Inject; + +import org.eclipse.emf.ecp.view.spi.context.ViewModelContext; +import org.eclipse.emf.ecp.view.spi.model.VControl; +import org.eclipse.emf.ecp.view.template.model.VTViewTemplateProvider; +import org.eclipse.emfforms.spi.common.report.ReportService; +import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException; +import org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedReport; +import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding; +import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider; +import org.eclipse.passage.lic.agreements.AgreementDescriptor; +import org.eclipse.passage.loc.agreements.ui.AgreementsUi; +import org.eclipse.passage.loc.internal.agreements.AgreementRegistry; +import org.eclipse.passage.loc.workbench.emfforms.renderers.TextWithButtonRenderer; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class AgreementIdentifierRenderer extends TextWithButtonRenderer { + + private static final String IDENTIFIER_EMPTY = ""; //$NON-NLS-1$ + + private final AgreementRegistry registry; + + @Inject + public AgreementIdentifierRenderer(VControl vElement, ViewModelContext viewContext, ReportService reportService, + EMFFormsDatabinding emfFormsDatabinding, EMFFormsLabelProvider emfFormsLabelProvider, + VTViewTemplateProvider vtViewTemplateProvider) { + super(vElement, viewContext, reportService, emfFormsDatabinding, emfFormsLabelProvider, vtViewTemplateProvider); + registry = viewContext.getService(AgreementRegistry.class); + } + + @Override + protected Control createSWTControl(Composite parent) { + Control control = super.createSWTControl(parent); + text.setEditable(true); + button.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + selectIdentifier(); + } + }); + + return control; + } + + @Override + protected String getUnsetText() { + return IDENTIFIER_EMPTY; + } + + protected void selectIdentifier() { + Shell shell = Display.getDefault().getActiveShell(); + AgreementDescriptor initial = null; + try { + Object value = getModelValue().getValue(); + if (value instanceof String) { + String id = (String) value; + initial = registry.agreement(id); + } + } catch (DatabindingFailedException e) { + getReportService().report(new DatabindingFailedReport(e)); + } + AgreementDescriptor descriptor = AgreementsUi.selectAgreementDescriptor(shell, registry, initial); + if (descriptor != null) { + String identifier = descriptor.getIdentifier(); + if (identifier != null) { + text.setText(identifier); + } + } + } + +} diff --git a/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementsIdentifierRendererService.java b/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementsIdentifierRendererService.java new file mode 100644 index 000000000..2006b0663 --- /dev/null +++ b/bundles/org.eclipse.passage.loc.agreements.emfforms/src/org/eclipse/passage/loc/agreements/emfforms/renderers/AgreementsIdentifierRendererService.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2021 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.loc.agreements.emfforms.renderers; + +import org.eclipse.emf.ecp.view.spi.model.VControl; +import org.eclipse.emfforms.spi.common.report.ReportService; +import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding; +import org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService; +import org.eclipse.passage.lic.agreements.model.meta.AgreementsPackage; +import org.eclipse.passage.loc.workbench.emfforms.renderers.StructuredFeatureRendererService; +import org.eclipse.passage.loc.workbench.emfforms.renderers.ValidatedTextRenderer; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; + +@Component +public class AgreementsIdentifierRendererService extends StructuredFeatureRendererService + implements EMFFormsDIRendererService { + + public AgreementsIdentifierRendererService() { + super(ValidatedTextRenderer.class, AgreementsPackage.eINSTANCE.getAgreement_Identifier()); + } + + @Reference + @Override + public void bindEMFFormsDatabinding(EMFFormsDatabinding databindingService) { + super.bindEMFFormsDatabinding(databindingService); + } + + @Override + public void unbindEMFFormsDatabinding(EMFFormsDatabinding databindingService) { + super.unbindEMFFormsDatabinding(databindingService); + } + + @Reference + @Override + public void bindReportService(ReportService reportService) { + super.bindReportService(reportService); + } + + @Override + public void unbindReportService(ReportService reportService) { + super.unbindReportService(reportService); + } + +} diff --git a/bundles/org.eclipse.passage.loc.agreements.ui/src/org/eclipse/passage/loc/agreements/ui/AgreementsUi.java b/bundles/org.eclipse.passage.loc.agreements.ui/src/org/eclipse/passage/loc/agreements/ui/AgreementsUi.java index 68df6b721..fe33bd6e2 100644 --- a/bundles/org.eclipse.passage.loc.agreements.ui/src/org/eclipse/passage/loc/agreements/ui/AgreementsUi.java +++ b/bundles/org.eclipse.passage.loc.agreements.ui/src/org/eclipse/passage/loc/agreements/ui/AgreementsUi.java @@ -12,10 +12,25 @@ *******************************************************************************/ package org.eclipse.passage.loc.agreements.ui; -public interface AgreementsUi { +import org.eclipse.passage.lic.agreements.AgreementDescriptor; +import org.eclipse.passage.lic.agreements.model.meta.AgreementsPackage; +import org.eclipse.passage.loc.internal.agreements.AgreementRegistry; +import org.eclipse.passage.loc.internal.agreements.ui.i18n.AgreementsUiMessages; +import org.eclipse.passage.loc.workbench.LocWokbench; +import org.eclipse.swt.widgets.Shell; - String BUNDLE_SYMBOLIC_NAME = "org.eclipse.passage.loc.agreements.ui"; //$NON-NLS-1$ +public final class AgreementsUi { - String PERSPECTIVE_MAIN = BUNDLE_SYMBOLIC_NAME + '.' + "perspective.main"; //$NON-NLS-1$ + public static final String BUNDLE_SYMBOLIC_NAME = "org.eclipse.passage.loc.agreements.ui"; //$NON-NLS-1$ + public static final String PERSPECTIVE_MAIN = BUNDLE_SYMBOLIC_NAME + '.' + "perspective.main"; //$NON-NLS-1$ + + public static AgreementDescriptor selectAgreementDescriptor(Shell shell, AgreementRegistry registry, + AgreementDescriptor initial) { + String classifier = AgreementsPackage.eINSTANCE.getAgreement().getName(); + String title = AgreementsUiMessages.AgreementsUi_select_agreement; + Iterable input = registry.agreements(); + Class clazz = AgreementDescriptor.class; + return LocWokbench.selectClassifier(shell, classifier, title, input, initial, clazz); + } } diff --git a/bundles/org.eclipse.passage.loc.workbench.emfforms/META-INF/MANIFEST.MF b/bundles/org.eclipse.passage.loc.workbench.emfforms/META-INF/MANIFEST.MF index 71d518ae2..e4d81d999 100644 --- a/bundles/org.eclipse.passage.loc.workbench.emfforms/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.passage.loc.workbench.emfforms/META-INF/MANIFEST.MF @@ -51,6 +51,7 @@ Export-Package: org.eclipse.passage.loc.internal.workbench.emfforms;x-internal:= org.eclipse.passage.loc.licenses.emfforms, org.eclipse.passage.loc.products.emfforms, org.eclipse.passage.loc.users.emfforms, - org.eclipse.passage.loc.features.emfforms" + org.eclipse.passage.loc.features.emfforms, + org.eclipse.passage.loc.agreements.emfforms" Bundle-ActivationPolicy: lazy Service-Component: OSGI-INF/*.xml diff --git a/releng/org.eclipse.passage.loc.aggregator/pom.xml b/releng/org.eclipse.passage.loc.aggregator/pom.xml index 2cb40a119..bd748e337 100644 --- a/releng/org.eclipse.passage.loc.aggregator/pom.xml +++ b/releng/org.eclipse.passage.loc.aggregator/pom.xml @@ -68,7 +68,8 @@ ../../bundles/org.eclipse.passage.loc.agreements.core ../../bundles/org.eclipse.passage.loc.agreements.ui - ../../bundles/org.eclipse.passage.loc.workspace