@Override protected boolean canPaste(Object targetObject, Object[] sourceObjects) { HashMap<?, ?> currentPackageFragments = null; // Only export package objects that represent existing package // fragments within the Java project that this plugin.xml is stored // can be pasted for (Object sourceObject : sourceObjects) { // Only export package objects are allowed if ((sourceObject instanceof ExportPackageObject) == false) { return false; } // Get the package fragments that are allowed and store them to // assist in searching if (currentPackageFragments == null) { currentPackageFragments = createCurrentExportPackageMap(); } // Only export packages that are in the list of allowed package // fragments are allowed ExportPackageObject exportPackageObject = (ExportPackageObject) sourceObject; if (currentPackageFragments.containsKey(exportPackageObject.getName()) == false) { return false; } } return true; }
public void setModel(IPluginModelBase[] plugins) { if (plugins != null && plugins.length > 0) { versions.clear(); } for (int i = 0; i < plugins.length; ++i) { String name = plugins[i].getBundleDescription().getSymbolicName(); Version version = plugins[i].getBundleDescription().getVersion(); Version oldVersion = versions.get(name); if (oldVersion == null || oldVersion.compareTo(version) < 0) { versions.put(name, version); } } }
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { IPluginModelBase plugin = (IPluginModelBase) element; Version hVersion = versions.get(plugin.getBundleDescription().getSymbolicName()); if (hVersion == null) return true; return hVersion.equals(plugin.getBundleDescription().getVersion()); }