This plugin is an implementation of lines/families.
diff --git a/org.eclipse.opencert.lines/plugin.xml b/org.eclipse.opencert.lines/plugin.xml
index 9bc319e..1f32429 100644
--- a/org.eclipse.opencert.lines/plugin.xml
+++ b/org.eclipse.opencert.lines/plugin.xml
@@ -6,7 +6,7 @@
point="org.eclipse.ui.commands">
<category
name="Sample Category"
- id="org.eclipse.amass.lines.commands.category">
+ id="org.eclipse.opencert.lines.commands.category">
</category>
<command
name="Seamless Integration between EPF Composer and BVR Tool"
@@ -17,14 +17,14 @@
<extension
point="org.eclipse.ui.handlers">
<handler
- commandId="org.eclipse.amass.lines.commands.processCommand"
- class="org.eclipse.amass.lines.handlers.LinesHandler">
+ commandId="org.eclipse.opencert.lines.commands.processCommand"
+ class="org.eclipse.opencert.lines.handlers.LinesHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
- commandId="org.eclipse.amass.lines.commands.processCommand"
+ commandId="org.eclipse.opencert.lines.commands.processCommand"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+Q">
@@ -37,12 +37,12 @@
<menu
label="Process Lines"
mnemonic="M"
- id="org.eclipse.amass.lines.menus.sampleMenu">
+ id="org.eclipse.opencert.lines.menus.sampleMenu">
<command
- commandId="org.eclipse.amass.lines.commands.processCommand"
+ commandId="org.eclipse.opencert.lines.commands.processCommand"
mnemonic="S"
icon="icons/Process.gif"
- id="org.eclipse.amass.lines.menus.processCommand">
+ id="org.eclipse.opencert.lines.menus.processCommand">
</command>
</menu>
</menuContribution>
diff --git a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/Activator.java b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/Activator.java
index c2146f5..0d01804 100644
--- a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/Activator.java
+++ b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/Activator.java
@@ -1,3 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2018, MDH
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Muhammad Atif Javed
+ * Initial API and implementation and/or initial documentation
+ *******************************************************************************/
+/**
+ */
package org.eclipse.opencert.lines;
import org.eclipse.jface.resource.ImageDescriptor;
diff --git a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/Resources.properties b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/Resources.properties
index 1ff17af..1b51296 100644
--- a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/Resources.properties
+++ b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/Resources.properties
@@ -19,4 +19,11 @@
openLibraryError_msg=IUPL0301E: Unable to create the method library.
openLibraryInternlError_reason=An internal error has occurred.
openLibraryError_reason4=The specified method library folder is a plug-in or configuration specification export folder.
-openLibraryError_advice=Select OK to specify another method library path.
\ No newline at end of file
+openLibraryError_advice=Select OK to specify another method library path.
+
+# Version Mismatch Dialog
+versionMismatchDialog_text=IUPL305E: The selected library cannot be opened. You must upgrade {0} to version {1} or higher in order to open this library.
+versionMismatchDialog_text_unknown=IUPL306E: The selected library cannot be opened. You must upgrade {0} to a higher version in order to open this library.
+
+# Upgrade Method Library Dialog
+upgradeLibraryDialog_text=The library you have selected needs to be upgraded to the new library structure.\n\nDo you want to proceed with the upgrade?
diff --git a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/actions/OpenLibraryAction.java b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/actions/OpenLibraryAction.java
index 7790a8b..e247e43 100644
--- a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/actions/OpenLibraryAction.java
+++ b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/actions/OpenLibraryAction.java
@@ -3,18 +3,14 @@
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.opencert.lines.wizards.OpenWizard;
+import org.eclipse.opencert.lines.wizards.OpenLibraryWizard;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;
/**
- * Invokes the Publish Method Configuration wizard.
- *
- * @author Kelvin Low
- * @author Jinhua Xi
- * @since 1.0
+ * Invokes the Process Line wizard.
*/
public class OpenLibraryAction implements IWorkbenchWindowActionDelegate {
@@ -29,7 +25,7 @@
*/
public void run(IAction action) {
try {
- OpenWizard wizard = new OpenWizard();
+ OpenLibraryWizard wizard = new OpenLibraryWizard();
wizard.init(PlatformUI.getWorkbench(), null);
// Instantiate the wizard container with the wizard and open it.
diff --git a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/handlers/LinesHandler.java b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/handlers/LinesHandler.java
index be9405e..54e1dcd 100644
--- a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/handlers/LinesHandler.java
+++ b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/handlers/LinesHandler.java
@@ -1,3 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2018, MDH
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Muhammad Atif Javed
+ * Initial API and implementation and/or initial documentation
+ *******************************************************************************/
+/**
+ */
package org.eclipse.opencert.lines.handlers;
import java.io.File;
@@ -14,7 +30,7 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.opencert.lines.resolving.DoResolve;
-import org.eclipse.opencert.lines.wizards.OpenWizard;
+import org.eclipse.opencert.lines.wizards.OpenLibraryWizard;
import org.eclipse.swt.widgets.Display;
/**
@@ -27,7 +43,7 @@
@Override
public Object execute(ExecutionEvent event) {
- OpenWizard wizard = new OpenWizard();
+ OpenLibraryWizard wizard = new OpenLibraryWizard();
wizard.init(PlatformUI.getWorkbench(), null);
// Instantiate the wizard container with the wizard and open it.
diff --git a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/resolving/DoResolve.java b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/resolving/DoResolve.java
index cda7880..16e9ad2 100644
--- a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/resolving/DoResolve.java
+++ b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/resolving/DoResolve.java
@@ -1,3 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2018, MDH
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Muhammad Atif Javed
+ * Initial API and implementation and/or initial documentation
+ *******************************************************************************/
+/**
+ */
package org.eclipse.opencert.lines.resolving;
import java.io.File;
@@ -34,6 +50,9 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.TransformerException;
+/**
+ * Resolve problems with the XMI files.
+ */
public class DoResolve {
public static final String libraryFile = "library.xmi";
diff --git a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/resolving/LibraryDocument.java b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/resolving/LibraryDocument.java
index c83b8e2..ba5d229 100644
--- a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/resolving/LibraryDocument.java
+++ b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/resolving/LibraryDocument.java
@@ -10,10 +10,6 @@
/**
* Encapsulates a method library using a DOM document.
- *
- * @author Jinhua Xi
- * @author Weiping Lu
- * @since 1.0
*/
public class LibraryDocument {
diff --git a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/wizards/MainPage.java b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/wizards/MainPage.java
index e17ed49..4420766 100644
--- a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/wizards/MainPage.java
+++ b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/wizards/MainPage.java
@@ -21,8 +21,7 @@
import org.eclipse.swt.widgets.Shell;
/**
- * A wizard page that prompts the user to select a path to open a method
- * library.
+ * A wizard page that prompts the user to select a path to open a method library.
*/
public class MainPage extends BaseWizardPage {
diff --git a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/wizards/OpenLibraryWizard.java b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/wizards/OpenLibraryWizard.java
new file mode 100644
index 0000000..506cdf4
--- /dev/null
+++ b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/wizards/OpenLibraryWizard.java
@@ -0,0 +1,290 @@
+package org.eclipse.opencert.lines.wizards;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.epf.common.service.utils.CommandLineRunUtil;
+import org.eclipse.epf.common.service.versioning.VersionUtil;
+import org.eclipse.epf.common.ui.util.MsgDialog;
+import org.eclipse.epf.common.utils.FileUtil;
+import org.eclipse.epf.library.LibraryService;
+import org.eclipse.epf.library.edit.util.LibraryEditUtil;
+import org.eclipse.epf.library.ui.LibraryUIManager;
+import org.eclipse.epf.library.ui.LibraryUIPlugin;
+import org.eclipse.epf.library.ui.preferences.LibraryUIPreferences;
+import org.eclipse.epf.library.xmi.XMILibraryManager;
+import org.eclipse.epf.library.xmi.XMILibraryUtil;
+import org.eclipse.epf.persistence.migration.UpgradeCallerInfo;
+import org.eclipse.epf.ui.wizards.BaseWizard;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.opencert.lines.UIResources;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * A wizard that guides the user to open a method library.
+ */
+public class OpenLibraryWizard extends BaseWizard implements INewWizard {
+
+ /**
+ * The wizard ID.
+ */
+ public static final String WIZARD_ID = OpenLibraryWizard.class.getName();
+
+ /**
+ * The Open Library wizard extension point ID.
+ */
+ public static final String WIZARD_EXTENSION_POINT_ID = "org.eclipse.epf.library.ui.openLibraryWizard"; //$NON-NLS-1$
+
+ // The main wizard page.
+ protected MainPage mainPage;
+
+ /**
+ * Creates a new instance.
+ */
+ public OpenLibraryWizard() {
+ super();
+ }
+
+ /**
+ * @see org.eclipse.epf.ui.wizards.BaseWizard#init(IWorkbench,
+ * IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ super.init(workbench, selection);
+ setWindowTitle(UIResources.openLibraryWizard_title);
+ }
+
+ /**
+ * @see org.eclipse.epf.ui.wizards.BaseWizard#getWizardExtenderExtensionPointId()
+ */
+ public String getWizardExtenderExtensionPointId() {
+ return WIZARD_EXTENSION_POINT_ID;
+ }
+
+ /**
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages() {
+ if (wizardExtender == null) {
+ mainPage = createMainPage();
+ super.addPage(mainPage);
+ } else {
+ List<IWizardPage> wizardPages = new ArrayList<IWizardPage>();
+
+ IWizardPage page = wizardExtender
+ .getReplaceWizardPage(MainPage.PAGE_NAME);
+ if (page != null) {
+ wizardPages.add(page);
+ } else {
+ mainPage = createMainPage();
+ wizardPages.add(mainPage);
+ }
+
+ super.getNewWizardPages(wizardPages);
+
+ for (Iterator it = wizardPages.iterator(); it.hasNext();) {
+ IWizardPage wizardPage = (IWizardPage) it.next();
+ super.addPage(wizardPage);
+ }
+
+ wizardExtender.initWizardPages(wizardPages);
+ }
+ }
+
+ /**
+ * Creates the main wizard page.
+ *
+ * @return the main wizard page
+ */
+ protected MainPage createMainPage() {
+ return new MainPage();
+ }
+
+ /**
+ * @see org.eclipse.jface.wizard.Wizard#createPageControls(Composite)
+ */
+ public void createPageControls(Composite pageContainer) {
+ super.createPageControls(pageContainer);
+ pageContainer.getShell().setImage(
+ LibraryUIPlugin.getDefault().getSharedImage(
+ "full/obj16/MethodLibrary.gif")); //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ public boolean performFinish() {
+ boolean b = performFinish_();
+ if (b) {
+ FileUtil.getValidateEdit().sychnConneciton();
+ }
+ return b;
+ }
+ private boolean performFinish_() {
+ if (LibraryService.getInstance().getCurrentMethodConfiguration() != null) {
+ LibraryService.getInstance().setCurrentMethodConfiguration(null);
+ }
+ if (wizardExtender != null) {
+ return wizardExtender.doFinish();
+ } else {
+ return openMethodLibrary(mainPage.getLibraryPath(), "xmi"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Opens the method library at the user specified path.
+ *
+ * @param path
+ * the method library path
+ * @param type
+ * the method library type
+ */
+ public boolean openMethodLibrary(String path, String type) {
+ return openMethodLibrary(path, type, true);
+ }
+ public boolean openMethodLibrary(String path, String type, boolean addOpenLibraryPath) {
+ try {
+ Map<String, String> options = new HashMap<String, String>();
+ File libraryPath = new File(path);
+ options.put(XMILibraryManager.ARG_LIBRARY_PATH, libraryPath
+ .getAbsolutePath());
+
+ if (XMILibraryUtil.isValidLibrary(path, true) == Status.OK_STATUS) {
+ if (!handleToolVersion(path, null)) {
+ return false;
+ }
+ if (LibraryUIManager.getInstance().openLibrary(path)) {
+ if (addOpenLibraryPath) {
+ LibraryUIPreferences.addOpenLibraryPath(libraryPath
+ .getAbsolutePath());
+ }
+ return true;
+ }
+ } else if (XMILibraryUtil
+ .containsPluginOrConfigSpecExportFile(path)) {
+ throw new Exception(UIResources.openLibraryError_reason4);
+ } else {
+ MsgDialog msgDialog = LibraryUIPlugin.getDefault()
+ .getMsgDialog();
+ boolean rc = msgDialog
+ .displayConfirmation(
+ UIResources.openLibraryWizard_title,
+ NLS
+ .bind(
+ UIResources.openLibraryDialog_newLibrary_text,
+ new Object[] { path }));
+ if (!rc)
+ return false;
+ if (LibraryUIManager.getInstance().createLibrary(path)) {
+ LibraryUIPreferences.addOpenLibraryPath(libraryPath
+ .getAbsolutePath());
+ return true;
+ }
+ }
+
+ return true;
+ } catch (Exception e) {
+ String reason = e.getMessage();
+ if (reason == null) {
+ reason = UIResources.openLibraryInternlError_reason;
+ }
+ reason += "\n\n" + UIResources.openLibraryError_advice; //$NON-NLS-1$
+ if (e.getMessage() != null) {
+ LibraryUIPlugin.getDefault().getMsgDialog().displayError(
+ UIResources.openLibraryWizard_title,
+ UIResources.openLibraryError_msg, reason);
+ } else {
+ LibraryUIPlugin.getDefault().getMsgDialog().displayError(
+ UIResources.openLibraryWizard_title,
+ UIResources.openLibraryError_msg, reason, e);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Check and handle tool version differences
+ */
+ public static boolean handleToolVersion(String path,
+ UpgradeCallerInfo callerInfo) {
+ if (callerInfo == null) {
+ callerInfo = new UpgradeCallerInfo(UpgradeCallerInfo.upgradeLibrary, null);
+ }
+
+ String libXmi = XMILibraryManager.LIBRARY_XMI;
+ if (callerInfo != null && callerInfo.getIsExportedPluginLib()) {
+ libXmi = XMILibraryManager.exportFile;
+ }
+ VersionUtil.VersionCheckInfo info = VersionUtil
+ .checkLibraryVersion(new File(path, libXmi));
+ if (info != null && info.result > 0) {
+ String message = ""; //$NON-NLS-1$
+ if (info.toolID.equals(VersionUtil.getPrimaryToolID())) {
+ message = NLS.bind(
+ UIResources.versionMismatchDialog_text,
+ new Object[] { Platform.getProduct().getName(),
+ info.toolVersion });
+ } else {
+ message = NLS.bind(
+ UIResources.versionMismatchDialog_text_unknown,
+ new Object[] { Platform.getProduct().getName() });
+ }
+ if (!isUpgradeLibrary(callerInfo)) {
+ callerInfo.setErrorMsg(message);
+ return false;
+ }
+ LibraryUIPlugin.getDefault().getMsgDialog().displayError(
+ UIResources.openLibraryWizard_title, message);
+ return false;
+ }
+ if (XMILibraryUtil.isMethodLibraryUpgradeRequired(path, libXmi, info)) {
+ int confirmationIx = 0;
+ if (!CommandLineRunUtil.getInstance().isNeedToRun()
+ && isUpgradeLibrary(callerInfo)) {
+ confirmationIx = LibraryUIPlugin.getDefault().getMsgDialog()
+ .displayConfirmationWithCheckBox(
+ UIResources.openLibraryWizard_title,
+ UIResources.upgradeLibraryDialog_text,
+ UIResources.convertToSynProcessLib_msg);
+ if (confirmationIx == 0) {
+ return false;
+ }
+ }
+
+ if (! LibraryEditUtil.getInstance().isJunitTest()) {
+ callerInfo.setConverToSynFree(confirmationIx == 1);
+ }
+
+ if (!isUpgradeLibrary(callerInfo)) {
+ callerInfo.copyLibrary();
+ if (callerInfo.getCopiedLibFile() != null) {
+ path = callerInfo.getCopiedLibFile().getParentFile()
+ .getAbsolutePath();
+ }
+ }
+ if (!LibraryUIManager.upgradeLibrary(path, callerInfo)) {
+ if (callerInfo != null) {
+ }
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private static boolean isUpgradeLibrary(UpgradeCallerInfo callerInfo) {
+ return UpgradeCallerInfo.isUpgradeLibrary(callerInfo);
+ }
+
+
+}
diff --git a/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/wizards/WizardPage.java b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/wizards/WizardPage.java
new file mode 100644
index 0000000..9c21f57
--- /dev/null
+++ b/org.eclipse.opencert.lines/src/org/eclipse/opencert/lines/wizards/WizardPage.java
@@ -0,0 +1,24 @@
+package org.eclipse.opencert.lines.wizards;
+
+import java.util.Map;
+
+import org.eclipse.epf.ui.wizards.BaseWizardPage;
+
+/**
+ * The abstract class for a Open Method Library wizard page.
+ */
+public abstract class WizardPage extends BaseWizardPage {
+
+ /**
+ * Creates a new instance.
+ */
+ public WizardPage(String name) {
+ super(name);
+ }
+
+ /**
+ * Returns the library specific user selections.
+ */
+ public abstract Map getSelections();
+
+}