예제 #1
0
  /** Initializes the wizard page controls with data. */
  protected void initControls() {
    String configId = config != null ? config.getGuid() : ""; // $NON-NLS-1$

    if ((config != null)
        && ConfigFreeProcessPublishUtil.getInstance().isSameMethodConfiguration(config)) {
      // For config free process publish
      processViewer.setContentProvider(new ProcessViewerOfConfigFreeContentProvider());
      publishConfigRadioButton.setEnabled(false);
      publishConfigRadioButton.setSelection(false);
      publishProcessesRadioButton.setSelection(true);
      processViewer.getControl().setEnabled(true);

      List<String> processIds = PublishingUIPreferences.getProcesses(configId);
      List<Process> processes = new ArrayList<Process>();
      if (processIds != null) {
        for (String guid : processIds) {
          MethodElement e =
              LibraryService.getInstance().getCurrentLibraryManager().getMethodElement(guid);
          if (e instanceof Process) {
            processes.add((Process) e);
          }
        }
      }
      processViewer.setCheckedElements(processes.toArray());

      boolean includeBaseProcess = PublishingUIPreferences.getIncludeBaseProcesses(configId);
      includeBaseProcessesCheckbox.setSelection(includeBaseProcess);

      updateCheckedStates();
    } else {
      processViewer.setContentProvider(new ProcessViewerContentProvider());
      boolean publishConfig = PublishingUIPreferences.getPublishEntireConfig(configId);
      publishConfigRadioButton.setEnabled(true);
      publishConfigRadioButton.setSelection(publishConfig);
      publishProcessesRadioButton.setSelection(!publishConfig);
      processViewer.getControl().setEnabled(!publishConfig);

      if (!publishConfig) {
        List<String> processIds = PublishingUIPreferences.getProcesses(configId);
        List<Process> processes = new ArrayList<Process>();
        if (processIds != null) {
          for (String guid : processIds) {
            MethodElement e =
                LibraryService.getInstance().getCurrentLibraryManager().getMethodElement(guid);
            if (e instanceof Process) {
              processes.add((Process) e);
            }
          }
        }
        processViewer.setCheckedElements(processes.toArray());
      }

      boolean includeBaseProcess = PublishingUIPreferences.getIncludeBaseProcesses(configId);
      includeBaseProcessesCheckbox.setSelection(includeBaseProcess);

      updateCheckedStates();
    }
  }
예제 #2
0
 /** @see org.eclipse.epf.ui.wizards.BaseWizardPage#onEnterPage(Object) */
 public void onEnterPage(Object obj) {
   if (obj != null && obj instanceof String) {
     String configName = (String) obj;
     config =
         LibraryServiceUtil.getMethodConfiguration(
             LibraryService.getInstance().getCurrentMethodLibrary(), configName);
     if (config != null) {
       processViewer.setInput(config);
       initControls();
       processViewer.expandAll();
     } else {
       // For config free process publishing
       config =
           ConfigFreeProcessPublishUtil.getInstance().getMethodConfigurationForConfigFreeProcess();
       processViewer.setInput(LibraryService.getInstance().getCurrentMethodLibrary());
       initControls();
       processViewer.expandAll();
     }
   }
 }
  /** Performs the import. */
  public void performImport(final IProgressMonitor monitor) {

    // need to disable the workspace refreshing
    boolean refresh = RefreshJob.getInstance().isEnabled();
    if (refresh) {
      // disable resource refreshing during import
      //
      RefreshJob.getInstance().setEnabled(false);
    }

    try {
      if (monitor != null) {
        monitor.setTaskName(ImportResources.ConfigurationImportService_MSG3);
      }

      if (isSpecsOnly()) {
        specsMgr.doImport(data.specs);
      } else {
        LibraryImportManager importingMgr = new LibraryImportManager(diffMgr, data.importList);
        importingMgr.doMerge(data.replaceExisting, monitor);
      }

      // refresh library files in workspace
      //
      MethodLibrary lib = LibraryService.getInstance().getCurrentMethodLibrary();
      ResourceUtil.refreshResources(lib, monitor);

    } catch (Exception e) {
      ImportPlugin.getDefault().getLogger().logError(e);
    } finally {
      if (refresh) {
        // re-enable resource refreshing
        //
        RefreshJob.getInstance().setEnabled(true);
      }
      if (upGradeInfo != null) {
        upGradeInfo.removeCopiedLibrary();
        upGradeInfo = null;
      }
    }

    try {
      postImportOperation(monitor);
    } catch (Exception e) {
      ImportPlugin.getDefault().getLogger().logError(e);
    }
  }
예제 #4
0
 /** Updates the check states of process tree viewer. */
 private void updateCheckedStates() {
   ITreeContentProvider cp = (ITreeContentProvider) processViewer.getContentProvider();
   if (config != null) {
     Object[] plugins = null;
     if (ConfigFreeProcessPublishUtil.getInstance().isSameMethodConfiguration(config)) {
       // For config free process publish
       plugins = cp.getChildren(LibraryService.getInstance().getCurrentMethodLibrary());
     } else {
       plugins = cp.getChildren(config);
     }
     for (int i = 0; i < plugins.length; i++) {
       Object[] uiFolders = cp.getChildren(plugins[i]);
       int totalUIFolders = uiFolders.length;
       int checkedUIFolders = 0;
       for (int j = 0; j < uiFolders.length; j++) {
         Object[] processes = cp.getChildren(uiFolders[j]);
         int totalProcesses = processes.length;
         int checkedProcesses = 0;
         for (int k = 0; k < processes.length; k++) {
           if (processViewer.getChecked(processes[k])) {
             checkedProcesses++;
           }
         }
         if (checkedProcesses == 0) {
           processViewer.setGrayChecked(uiFolders[j], false);
         } else if (checkedProcesses == totalProcesses) {
           processViewer.setGrayed(uiFolders[j], false);
           processViewer.setChecked(uiFolders[j], true);
         } else {
           processViewer.setGrayChecked(uiFolders[j], true);
         }
         if (processViewer.getChecked(uiFolders[j])) {
           checkedUIFolders++;
         }
       }
       if (checkedUIFolders == totalUIFolders) {
         processViewer.setGrayed(plugins[i], false);
         processViewer.setChecked(plugins[i], true);
       } else if (checkedUIFolders == 0) {
         processViewer.setGrayChecked(plugins[i], false);
       } else {
         processViewer.setGrayChecked(plugins[i], true);
       }
     }
   }
 }
  /** Analyzes the imported library with respect to the base library. */
  public void analyze(IProgressMonitor monitor) {
    try {
      if (monitor != null) {
        monitor.setTaskName(ImportResources.ConfigurationImportService_MSG0);
      }

      data.getErrorInfo().clear();

      // Prepare the library files.
      String path = data.llData.getParentFolder();
      if (path.indexOf(File.separator + LibraryDocument.libraryFile) < 0) {
        path += File.separator + LibraryDocument.libraryFile;
      }
      File importingLibPath = new File(path);

      boolean isLibraryFile = true;
      if (!importingLibPath.exists()) {
        importingLibPath = new File(importingLibPath.getParentFile(), LibraryDocument.exportFile);
        isLibraryFile = false;
      }

      if (!importingLibPath.exists()) {
        data.getErrorInfo()
            .addError(
                NLS.bind(
                    ImportResources.ConfigurationImportService_MSG1, importingLibPath.getParent()));
        return;
      }

      boolean handleVersion = isLibraryFile;
      if (handleVersion) {
        upGradeInfo =
            new ConfigurationImportService.UpgradeInfo(
                UpgradeCallerInfo.upgradeImportConfig, importingLibPath);
        if (!handleToolVersion(importingLibPath, upGradeInfo)) {
          String errMsg = upGradeInfo.getErrorMsg();
          if (errMsg == null || errMsg.length() == 0) {
            errMsg = ImportResources.ImportConfigurationWizard_ERR_Import_configuration;
          }
          data.getErrorInfo().addError(NLS.bind(errMsg, importingLibPath.getParent()));
          return;
        }
        if (upGradeInfo.getCopiedLibFile() != null) {
          importingLibPath = upGradeInfo.getCopiedLibFile();
        }
      }

      importingLibDoc = new LibraryDocument(importingLibPath);

      boolean isConfigSpecs = importingLibDoc.isConfigSpecsOnly();

      if (isConfigSpecs) {

        specsMgr = new ConfigSpecsImportManager();

        // Scan the library file for configuration information.
        data.specs = specsMgr.getConfigSpecs(importingLibDoc);

      } else {
        if (!isLibraryFile) {
          data.getErrorInfo()
              .addError(
                  NLS.bind(
                      ImportResources.ConfigurationImportService_MSG1,
                      importingLibPath.getParent()));
          return;
        }
        data.specs = null;

        // Open the library and compare the difference.

        // need to open and close the library to have the project resources initialized properly
        String libDir = importingLibPath.getParentFile().getAbsolutePath();

        String projectName =
            "Configuration Import Project (" //$NON-NLS-1$
                + Integer.toHexString(libDir.hashCode())
                + ")"; //$NON-NLS-1$

        MethodLibraryProject.openProject(libDir, projectName, monitor);
        try {
          MethodLibrary importLibraty = LibraryUtil.loadLibrary(importingLibPath.getAbsolutePath());
          MethodLibrary baseLibrary = LibraryService.getInstance().getCurrentMethodLibrary();

          handleTypeChanges(baseLibrary, importLibraty);

          String baseLibDir = null;
          try { // Not neccessary, but prevent introducing any potential regression due to this
                // change
            File bFile = new File(baseLibrary.eResource().getURI().toFileString()).getParentFile();
            ;
            baseLibDir = bFile.getAbsolutePath();
          } catch (Throwable e) {
          }
          if (libDir.equalsIgnoreCase(baseLibDir)) {
            data.getErrorInfo()
                .addError(
                    NLS.bind(
                        ImportResources.ConfigurationImportService_MSG2,
                        importingLibPath.getParent()));
            return;
          }

          fixImportLibrarySystemPackageGUIDs(baseLibrary, importLibraty);

          diffMgr = new LibraryDiffManager(baseLibrary, importLibraty);
          diffMgr.buildDiffTree();

          if (localDebug) {
            diffMgr.rootDiffTree.debugDump();
          }

        } catch (RuntimeException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        MethodLibraryProject.closeProject(libDir, monitor);
        MethodLibraryProject.deleteProject(libDir, monitor);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
 protected void postImportOperation(IProgressMonitor monitor) throws Exception {
   // Reopen the library.
   LibraryService.getInstance().reopenCurrentMethodLibrary();
 }
예제 #7
0
 /** Creates a new instance. */
 public DependencyManager(MethodLibrary library, MethodConfiguration config) {
   this.library = library;
   this.libraryManager = LibraryService.getInstance().getLibraryManager(library);
   this.config = config;
   init();
 }
예제 #8
0
  /**
   * Builds the dependency for a method element.
   *
   * <p>This creates an <code>ElementReference</code> for the given element that points to all the
   * referenced elements, and adds the given element as a dependent element to all the referenced
   * elements. This should only be called once for each method element.
   *
   * @param element A method element.
   * @return A <code>PackageDependency</code>.
   */
  private PackageDependency buildDependencyFor(MethodElement element) {
    if (element == null) {
      return null;
    }

    IConfigurationManager configMgr = LibraryService.getInstance().getConfigurationManager(config);
    if (configMgr != null) {
      SupportingElementData seData = configMgr.getSupportingElementData();
      if (seData != null && seData.isEnabled()) {
        seData.processVariabilityChildren(element, null);
      }
    }

    // Build the dependency on the selectable element/parent only
    MethodElement selectableElement = (MethodElement) LibraryUtil.getSelectable(element);
    if (selectableElement == null) {
      return null;
    }

    PackageDependency dependency = getDependency(selectableElement, true);

    // Remove any existing element reference for this element.
    dependency.removeReference(element);
    /*
    		// Get the VariabilityElement.
    		ContentElement baseElement = null;
    		if (element instanceof ContentElement) {
    			baseElement = (ContentElement) ((ContentElement) element)
    					.getVariabilityBasedOnElement();
    			if (baseElement != null) {
    				// Establish the package reference.
    				EObject selectableBase = LibraryUtil.getSelectable(baseElement);
    				if (selectableBase != null) {
    					PackageReference pkgRef = dependency.getReference(
    							selectableBase, true);

    					if (!pkgRef.hasReference(element, baseElement)) {
    						// Add the detail element reference to the package
    						// reference.
    						VariabilityElementReference ref = new VariabilityElementReference(
    								element, baseElement);
    						pkgRef.addReference(ref);
    					}

    					// Set the dependent of the referenced package.
    					getDependency(selectableBase, true).addDependent(
    							selectableElement);
    				}
    			}
    		}

    		List references = element.eCrossReferences();

    		// Update the dependents of those elements in the list.
    		if (references != null && references.size() > 0) {
    			// Get the selectable references
    			for (Iterator it = references.iterator(); it.hasNext();) {
    				EObject refElement = (EObject) it.next();
    				EObject selectableRef = LibraryUtil.getSelectable(refElement);
    				if (selectableRef != null) {
    					PackageReference pkgRef = dependency.getReference(
    							selectableRef, true);

    					if (element == selectableElement
    							&& refElement == selectableRef) {
    						// No need to add this.
    						continue;
    					}

    					if (!pkgRef.hasReference(element, refElement)) {
    						GeneralReference ref = new GeneralReference(element,
    								refElement);
    						pkgRef.addReference(ref);
    					}

    					getDependency(selectableRef, true).addDependent(
    							selectableElement);
    				}
    			}
    		}
    */
    List properties = LibraryUtil.getStructuralFeatures(element, true);
    for (int i = 0; i < properties.size(); i++) {
      EStructuralFeature f = (EStructuralFeature) properties.get(i);
      if (!(f instanceof EReference)) {
        continue;
      }

      EReference feature = (EReference) f;
      if (feature.isContainer() || feature.isContainment()) {
        continue;
      }

      if (element instanceof Task) {
        if (feature == UmaPackage.eINSTANCE.getTask_Steps()) {
          continue;
        }
      }

      if (element instanceof TaskDescriptor) {
        if (feature == UmaPackage.eINSTANCE.getTaskDescriptor_SelectedSteps()) {
          continue;
        }
      }

      Object value = TypeDefUtil.getInstance().eGet(element, feature);
      if (value == null) {
        continue;
      }

      MethodElement refElement = null;
      List values = null;
      int count = 0;

      if (feature.isMany()) {
        values = (List) value;
        if (values.size() > 0) {
          refElement = (MethodElement) values.get(count);
        }
      } else if (value instanceof MethodElement) {
        refElement = (MethodElement) value;

        if (replacerSet != null) {
          if (feature == UmaPackage.eINSTANCE.getVariabilityElement_VariabilityBasedOnElement()) {
            VariabilityElement ve =
                element instanceof VariabilityElement ? (VariabilityElement) element : null;
            VariabilityType type = ve == null ? null : ve.getVariabilityType();
            if (type == VariabilityType.EXTENDS_REPLACES || type == VariabilityType.REPLACES) {
              replacerSet.add(ve);
            }
          }
        }
      }

      while (refElement != null) {

        boolean skip = false;
        if (feature == UmaPackage.eINSTANCE.getRole_Modifies()) {
          skip = true;
        }

        MethodElement selectableRef =
            skip ? null : (MethodElement) LibraryUtil.getSelectable(refElement);
        if (selectableRef != null) {
          PackageReference pkgRef = dependency.getReference(selectableRef, true);

          if (element == selectableElement && refElement == selectableRef) {
            // No need to add this.
            break;
          }

          ElementReference ref = pkgRef.getReference(element, refElement);
          if (ref == null) {
            ref = new ElementReference(element, refElement);
            pkgRef.addReference(ref);
          }

          ref.addFeature(feature);

          getDependency(selectableRef, true).addDependent(selectableElement);
        }

        refElement = null;
        if (values != null) {
          count++;
          if (count < values.size()) {
            refElement = (MethodElement) values.get(count);
          }
        }
      }
    }

    return dependency;
  }