use of org.osmorc.frameworkintegration.FrameworkIntegrator in project intellij-plugins by JetBrains.
the class BundleSelector method createModel.
private static TreeModel createModel(Project project, FrameworkInstanceDefinition instance, Collection<SelectedBundle> selectedList) {
Set<SelectedBundle> selected = ContainerUtil.newHashSet(selectedList);
DefaultMutableTreeNode root = new DefaultMutableTreeNode();
// all the modules
DefaultMutableTreeNode moduleNode = new DefaultMutableTreeNode(OsmorcBundle.message("bundle.selector.group.modules"));
Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
if (OsmorcFacet.hasOsmorcFacet(module)) {
SelectedBundle bundle = new SelectedBundle(SelectedBundle.BundleType.Module, module.getName(), null);
if (!selected.contains(bundle)) {
moduleNode.add(new DefaultMutableTreeNode(bundle));
}
}
}
if (moduleNode.getChildCount() > 0)
root.add(moduleNode);
// all the framework bundles (if there are any)
if (instance != null) {
FrameworkIntegrator integrator = FrameworkIntegratorRegistry.getInstance().findIntegratorByInstanceDefinition(instance);
if (integrator != null) {
DefaultMutableTreeNode frameworkNode = new DefaultMutableTreeNode(OsmorcBundle.message("bundle.selector.group.framework"));
for (SelectedBundle bundle : integrator.getFrameworkInstanceManager().getFrameworkBundles(instance, FrameworkBundleType.OTHER)) {
if (!selected.contains(bundle)) {
frameworkNode.add(new DefaultMutableTreeNode(bundle));
}
}
if (frameworkNode.getChildCount() > 0)
root.add(frameworkNode);
}
}
// all the libraries that are bundles already (doesn't make much sense to start bundlified libs as they have no activator).
DefaultMutableTreeNode libraryNode = new DefaultMutableTreeNode(OsmorcBundle.message("bundle.selector.group.libraries"));
List<String> paths = OrderEnumerator.orderEntries(project).librariesOnly().productionOnly().runtimeOnly().classes().getPathsList().getPathList();
for (String path : paths) {
String displayName = CachingBundleInfoProvider.getBundleSymbolicName(path);
if (displayName != null) {
SelectedBundle bundle = new SelectedBundle(SelectedBundle.BundleType.StartLibrary, displayName, path);
if (!selected.contains(bundle)) {
libraryNode.add(new DefaultMutableTreeNode(bundle));
}
}
}
if (libraryNode.getChildCount() > 0)
root.add(libraryNode);
return new DefaultTreeModel(root);
}
use of org.osmorc.frameworkintegration.FrameworkIntegrator in project intellij-plugins by JetBrains.
the class OsgiRunConfigurationEditor method onFrameworkChange.
/**
* Called when the framework is changed. This will create a new editor for framework properties and will also remove
* any framework bundles from the list, as they are no longer in classpath.
*/
private void onFrameworkChange() {
if (myFrameworkInstances.getSelectedItem() != null) {
FrameworkInstanceDefinition instance = (FrameworkInstanceDefinition) myFrameworkInstances.getSelectedItem();
FrameworkIntegrator integrator = FrameworkIntegratorRegistry.getInstance().findIntegratorByInstanceDefinition(instance);
assert integrator != null : instance;
// clear the panel
myAdditionalPropertiesPanel.removeAll();
// create and install a new editor (if present)
myCurrentRunPropertiesEditor = integrator.createRunPropertiesEditor();
if (myCurrentRunPropertiesEditor != null) {
myAdditionalPropertiesPanel.removeAll();
myAdditionalPropertiesPanel.add(myCurrentRunPropertiesEditor.getUI(), BorderLayout.CENTER);
if (myRunConfiguration != null) {
myCurrentRunPropertiesEditor.resetEditorFrom(myRunConfiguration);
OsgiRunConfigurationChecker checker = null;
if (integrator instanceof OsgiRunConfigurationCheckerProvider) {
checker = ((OsgiRunConfigurationCheckerProvider) integrator).getOsgiRunConfigurationChecker();
}
myRunConfiguration.setAdditionalChecker(checker);
}
}
// remove all framework bundles from the list
RunConfigurationTableModel model = getTableModel();
model.removeAllOfType(SelectedBundle.BundleType.FrameworkBundle);
}
}
Aggregations