/** * Handles registration of a new configuration form. * * @param event the <tt>ServiceEvent</tt> that notified us */ public void serviceChanged(ServiceEvent event) { Object sService = AdvancedConfigActivator.bundleContext.getService(event.getServiceReference()); // we don't care if the source service is not a configuration form if (!(sService instanceof ConfigurationForm)) return; ConfigurationForm configForm = (ConfigurationForm) sService; /* * This AdvancedConfigurationPanel is an advanced ConfigurationForm so * don't try to add it to itself. */ if ((configForm == this) || !configForm.isAdvanced()) return; switch (event.getType()) { case ServiceEvent.REGISTERED: if (logger.isInfoEnabled()) logger.info("Handling registration of a new Configuration Form."); this.addConfigForm(configForm); break; case ServiceEvent.UNREGISTERING: this.removeConfigForm(configForm); break; } }
/** Logs the interaction, Type can be S - Server Sent C - Client Sent */ public void logComand(String command, char type) { logger.info("For[" + type + "] " + command); }
public QSAdminGUI(QSAdminMain qsadminMain, JFrame parentFrame) { this.parentFrame = parentFrame; Container cp = this; qsadminMain.setGUI(this); cp.setLayout(new BorderLayout(5, 5)); headerPanel = new HeaderPanel(qsadminMain, parentFrame); mainCommandPanel = new MainCommandPanel(qsadminMain); cmdConsole = new CmdConsole(qsadminMain); propertiePanel = new PropertiePanel(qsadminMain); if (headerPanel == null || mainCommandPanel == null || cmdConsole == null || propertiePanel == null) { throw new RuntimeException("Loading of one of gui component failed."); } headerPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); cp.add(headerPanel, BorderLayout.NORTH); JScrollPane propertieScrollPane = new JScrollPane(propertiePanel); // JScrollPane commandScrollPane = new JScrollPane(mainCommandPanel); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, mainCommandPanel, cmdConsole); splitPane.setOneTouchExpandable(false); splitPane.setDividerLocation(250); // splitPane.setDividerLocation(0.70); tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.addTab("Main", ball, splitPane, "Main Commands"); tabbedPane.addTab("Get/Set", ball, propertieScrollPane, "Properties Panel"); QSAdminPluginConfig qsAdminPluginConfig = null; PluginPanel pluginPanel = null; // -- start of loadPlugins try { File xmlFile = null; ClassLoader classLoader = null; Class mainClass = null; File file = new File(pluginDir); File dirs[] = null; if (file.canRead()) dirs = file.listFiles(new DirFileList()); for (int i = 0; dirs != null && i < dirs.length; i++) { xmlFile = new File(dirs[i].getAbsolutePath() + File.separator + "plugin.xml"); if (xmlFile.canRead()) { qsAdminPluginConfig = PluginConfigReader.read(xmlFile); if (qsAdminPluginConfig.getActive().equals("yes") && qsAdminPluginConfig.getType().equals("javax.swing.JPanel")) { classLoader = ClassUtil.getClassLoaderFromJars(dirs[i].getAbsolutePath()); mainClass = classLoader.loadClass(qsAdminPluginConfig.getMainClass()); logger.fine("Got PluginMainClass " + mainClass); pluginPanel = (PluginPanel) mainClass.newInstance(); if (JPanel.class.isInstance(pluginPanel) == true) { logger.info("Loading plugin : " + qsAdminPluginConfig.getName()); pluginPanelMap.put("" + (2 + i), pluginPanel); plugins.add(pluginPanel); tabbedPane.addTab( qsAdminPluginConfig.getName(), ball, (JPanel) pluginPanel, qsAdminPluginConfig.getDesc()); pluginPanel.setQSAdminMain(qsadminMain); pluginPanel.init(); } } else { logger.info( "Plugin " + dirs[i] + " is disabled so skipping " + qsAdminPluginConfig.getActive() + ":" + qsAdminPluginConfig.getType()); } } else { logger.info("No plugin configuration found in " + xmlFile + " so skipping"); } } } catch (Exception e) { logger.warning("Error loading plugin : " + e); logger.fine("StackTrace:\n" + MyString.getStackTrace(e)); } // -- end of loadPlugins tabbedPane.addChangeListener( new ChangeListener() { int selected = -1; int oldSelected = -1; public void stateChanged(ChangeEvent e) { // if plugin selected = tabbedPane.getSelectedIndex(); if (selected >= 2) { ((PluginPanel) pluginPanelMap.get("" + selected)).activated(); } if (oldSelected >= 2) { ((PluginPanel) pluginPanelMap.get("" + oldSelected)).deactivated(); } oldSelected = selected; } }); // tabbedPane.setBorder(BorderFactory.createEmptyBorder(0,5,5,5)); cp.add(tabbedPane, BorderLayout.CENTER); buildMenu(); }