use of org.apache.felix.mosgi.console.ifc.CommonPlugin in project felix by apache.
the class Activator method start.
// /////////////////////////////////////
// BundleActivator //
// /////////////////////////////////////
public void start(BundleContext context) {
m_context = context;
// Listen for factory service events.
ServiceListener sl = new ServiceListener() {
public void serviceChanged(ServiceEvent event) {
ServiceReference ref = event.getServiceReference();
Object svcObj = m_context.getService(ref);
if (event.getType() == ServiceEvent.REGISTERED) {
synchronized (Activator.this) {
// !!!!!!!!!! ORDER MATTERS (Inheritance pb)
if (!m_pluginList.contains(svcObj)) {
if (svcObj instanceof CommonPlugin) {
m_commonpluginList.add(svcObj);
firePropertyChangedEvent(CommonPlugin.COMMON_PLUGIN_ADDED, null, svcObj);
} else if (svcObj instanceof Plugin) {
m_pluginList.add(svcObj);
firePropertyChangedEvent(Plugin.PLUGIN_ADDED, null, svcObj);
}
}
}
} else if (event.getType() == ServiceEvent.UNREGISTERING) {
synchronized (Activator.this) {
removePropertyChangeListener((PropertyChangeListener) svcObj);
if (svcObj instanceof CommonPlugin) {
m_commonpluginList.remove(svcObj);
firePropertyChangedEvent(CommonPlugin.COMMON_PLUGIN_REMOVED, null, svcObj);
} else if (svcObj instanceof Plugin) {
m_pluginList.remove(svcObj);
firePropertyChangedEvent(Plugin.PLUGIN_REMOVED, null, svcObj);
}
}
} else {
m_context.ungetService(ref);
}
}
};
try {
m_context.addServiceListener(sl, "(|(objectClass=" + Plugin.class.getName() + ")(objectClass=" + CommonPlugin.class.getName() + "))");
} catch (InvalidSyntaxException ex) {
System.err.println("ShellGuiActivator: Cannot add service listener.");
System.err.println("ShellGuiActivator: " + ex);
}
// Create and display the frame.
if (m_frame == null) {
m_frame = new JFrame("OSGi GUI Remote Manager");
m_frame.setUndecorated(true);
m_frame.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
m_frame.setIconImage(Toolkit.getDefaultToolkit().getImage(m_context.getBundle().getResource("images/logo.gif")));
// m_frame.setResizable(false);
// m_frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// TODO : add a windowListener and use a Preferences service to save screen size
m_frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
JFrame jf = (JFrame) we.getWindow();
System.out.println(" Console.gui : window closing (" + jf.getSize().height + "*" + jf.getSize().width + ")");
}
public void windowClosed(WindowEvent we) {
JFrame jf = (JFrame) we.getWindow();
System.out.println(" Console.gui : window closed (" + jf.getSize().height + "*" + jf.getSize().width + ")");
}
});
Dimension maxdim = m_frame.getToolkit().getScreenSize();
int m_width = maxdim.width - 100;
int m_height = maxdim.height - 100;
m_frame.setBounds((int) ((maxdim.width - m_width) / 2), 20, m_width, m_height);
// Right panel
JSplitPane rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new NodePanel(this, context), new CommonPanel(this));
rightSplitPane.setOneTouchExpandable(true);
rightSplitPane.setDividerLocation((int) (m_height * 2 / 3));
// General Panel
this.nodesTree = new NodesTree(this, context);
JSplitPane gSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, this.nodesTree, rightSplitPane);
gSplitPane.setOneTouchExpandable(true);
gSplitPane.setDividerLocation((int) (m_width / 4));
m_frame.getContentPane().add(gSplitPane);
}
// Now try to manually initialize the plugin list
// since some might already be available.
// initializePlugins();
m_frame.setVisible(true);
this.nodesTree.runDiscovery();
}
use of org.apache.felix.mosgi.console.ifc.CommonPlugin in project felix by apache.
the class CommonPanel method propertyChange.
public void propertyChange(PropertyChangeEvent event) {
if (event.getPropertyName().equals(CommonPlugin.COMMON_PLUGIN_ADDED)) {
CommonPlugin cp = (CommonPlugin) event.getNewValue();
this.add(cp.getName(), cp.getGUI());
this.beanEventBroadcaster.addPropertyChangeListener(cp);
}
if (event.getPropertyName().equals(CommonPlugin.COMMON_PLUGIN_REMOVED)) {
CommonPlugin cp = (CommonPlugin) event.getNewValue();
this.remove(cp.getGUI());
this.beanEventBroadcaster.removePropertyChangeListener(cp);
}
}
Aggregations