/** Collects elements in lib that may have type changes */ public static void collectPotentialTypeChanged(MethodLibrary lib, HashMap map) { for (Iterator it = lib.eAllContents(); it.hasNext(); ) { Object obj = it.next(); if (obj instanceof Guidance || obj instanceof Activity) { MethodElement elem = (MethodElement) obj; map.put(elem.getGuid(), elem); } } }
/** * Gets the display name for a method element. * * @param element a method element * @param plural if <code>true</code>, return the plural form of the display name */ public static String getUIText(MethodElement element, boolean plural) { if (plural) { String label = (String) ELEMENT_TEXT_PLURAL.get(element.getClass()); return (label == null) ? element.getName() : label; } else { String label = (String) ELEMENT_TEXT.get(element.getClass()); return (label == null) ? element.getName() : label; } }
/** * Gets the display name for a method element in lower case. * * <p>Note: This method does not applies to the German language since it has no distinction * between a upper case and lower case noun. * * @param element a method element * @param plural if <code>true</code>, return the plural form of the display name */ public static String getUITextLower(MethodElement element, boolean plural) { String label; if (plural) { label = (String) ELEMENT_TEXT_PLURAL.get(element.getClass()); label = (label == null) ? element.getName() : label; } else { label = (String) ELEMENT_TEXT.get(element.getClass()); label = (label == null) ? element.getName() : label; } return StrUtil.toLower(label); }
private static int comparePresentationName(MethodElement e1, MethodElement e2) { Collator collator = Collator.getInstance(); String name1 = e1 instanceof BreakdownElement ? ProcessUtil.getPresentationName((BreakdownElement) e1) : e1.getPresentationName(); if (name1.length() < 1) name1 = e1.getName(); String name2 = e2 instanceof BreakdownElement ? ProcessUtil.getPresentationName((BreakdownElement) e2) : e2.getPresentationName(); if (name2.length() < 1) name2 = e2.getName(); return collator.compare(name1, name2); }
/** * Handles MethodElement type changes. Note: for MethodElement objects in importMap only eClass * type is used in this method. */ public static void handleTypeChanges(HashMap baseMap, HashMap importMap) { ArrayList toChangeList = new ArrayList(); for (Iterator it = importMap.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); Object guid = entry.getKey(); MethodElement baseElem = (MethodElement) baseMap.get(guid); if (baseElem != null) { MethodElement elem = (MethodElement) entry.getValue(); if (!elem.eClass().equals(baseElem.eClass())) { MethodElement elemPair[] = new MethodElement[] {baseElem, elem}; toChangeList.add(elemPair); } } } for (int i = 0; i < toChangeList.size(); i++) { MethodElement elemPair[] = (MethodElement[]) toChangeList.get(i); final MethodElement baseElem = elemPair[0]; final MethodElement importElem = elemPair[1]; if (baseElem instanceof Guidance) { Display.getDefault() .syncExec( new Runnable() { public void run() { ConvertGuidanceType.convertGuidance( (Guidance) baseElem, MsgBox.getDefaultShell(), null, importElem.eClass()); } }); } else if (baseElem instanceof Activity) { TypeConverter.convertActivity((Activity) baseElem, importElem.eClass()); } } }
/** * Builds the dependency for a method element. * * @param element A method element. */ private void buildDependency(MethodElement element) { if (element == null) { return; } try { PackageDependency dependency = buildDependencyFor(element); boolean isProcess = element instanceof ProcessComponent; EList elements = element.eContents(); if (elements != null) { for (Iterator it = elements.iterator(); it.hasNext(); ) { Object obj = it.next(); if (!(obj instanceof MethodElement)) { continue; } MethodElement methodElement = (MethodElement) obj; if (methodElement != null && !LibraryUtil.selectable(methodElement)) { buildDependencyFor(methodElement); } else if (isProcess && methodElement instanceof ProcessPackage) { for (Iterator itt = methodElement.eAllContents(); itt.hasNext(); ) { Object objj = itt.next(); if (objj instanceof MethodElement) { MethodElement m = (MethodElement) objj; if (!LibraryUtil.selectable(m)) { buildDependencyFor(m); } } } } } } dependency.setLoaded(true); } catch (Exception e) { if (debug) { e.printStackTrace(); } } }
/** Fixes the imported library's system package guids with those base's. */ public static void fixImportLibrarySystemPackageGUIDs( MethodLibrary baseLibrary, MethodLibrary importLibraty) { HashMap pluginsMap = new HashMap(); List plugins = baseLibrary.getMethodPlugins(); for (int i = 0; i < plugins.size(); i++) { MethodPlugin plugin = (MethodPlugin) plugins.get(i); pluginsMap.put(plugin.getGuid(), plugin); } if (pluginsMap.isEmpty()) { return; } List importPluginsToFix = new ArrayList(); List importPlugins = importLibraty.getMethodPlugins(); for (int i = 0; i < importPlugins.size(); i++) { MethodPlugin plugin = (MethodPlugin) importPlugins.get(i); if (pluginsMap.containsKey(plugin.getGuid())) { importPluginsToFix.add(plugin); } } for (int i = 0; i < importPluginsToFix.size(); i++) { MethodPlugin importPlugin = (MethodPlugin) importPluginsToFix.get(i); MethodPlugin basePlugin = (MethodPlugin) pluginsMap.get(importPlugin.getGuid()); if (basePlugin == null) { continue; } List importPackages = TngUtil.getAllSystemPackages(importPlugin); HashMap importPackageMap = new HashMap(); for (int j = 0; j < importPackages.size(); j++) { MethodElement importPackage = (MethodElement) importPackages.get(j); importPackageMap.put(importPackage.getName(), importPackage); } List basePackages = TngUtil.getAllSystemPackages(basePlugin); for (int j = 0; j < basePackages.size(); j++) { MethodElement basePackage = (MethodElement) basePackages.get(j); MethodElement importPackage = (MethodElement) importPackageMap.get(basePackage.getName()); if (importPackage == null) { continue; } String guid = basePackage.getGuid(); if (!importPackage.getGuid().equals(guid)) { importPackage.setGuid(guid); } } } }
/** * Gets the relative URI of a method element in the managed method library. * * @param element a method element * @return a relative URI */ public URI getElementRelativeURI(MethodElement element) { if (debug) { DebugTrace.print( this, "getElementRelativeURI", "element=" + element); // $NON-NLS-1$ //$NON-NLS-2$ } if (element != null) { Resource resource = library.eResource(); if (resource != null) { URI libraryURI = resource.getURI(); URI elementURI = element.eResource().getURI(); return elementURI.deresolve(libraryURI); } } return null; }
/** * Generates the HTML for a Method element. * * @param element A Method element. * @return A url of the generated content HTML file. */ public String generateHtml(MethodElement element) { String url = null; if (debug) { long startTime = System.currentTimeMillis(); IElementLayout layout = getLayoutManager().getLayout(element, true); url = generateHtml(layout); long endTime = System.currentTimeMillis(); System.out.println( "Time taken to render HTML page for " + element.getName() + //$NON-NLS-1$ ": " + (endTime - startTime) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ } else { IElementLayout layout = getLayoutManager().getLayout(element, true); url = generateHtml(layout); } return url; }
public int compare(Object o1, Object o2) { if (o1 == o2) return 0; o1 = getMethodElement(o1); if (o1 == null) { return 0; } o2 = getMethodElement(o2); if (o2 == null) { return 0; } MethodElement e1 = (MethodElement) o1; MethodElement e2 = (MethodElement) o2; Collator collator = Collator.getInstance(); ; return collator.compare(e1.getName() + e1.getGuid(), e2.getName() + e2.getGuid()); }