Skip to content
Snippets Groups Projects
Commit 86ea3147 authored by Alexander Marinc's avatar Alexander Marinc
Browse files

Updated to uAAl 0.3.1 and implement first version of plug-in functionality

parent 11d50349
No related branches found
No related tags found
No related merge requests found
Showing
with 101 additions and 41 deletions
......@@ -16,12 +16,11 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.universAAL.middleware</groupId>
<artifactId>mw.data.representation</artifactId>
<version>0.3.0-SNAPSHOT</version>
<version>0.3.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
......
package org.universAAL.ucc.api.plugin;
import org.universAAL.ucc.api.view.IAbstractMenu;
public interface IPlugin {
public void registerViews();
//public IAbstractMenu getMenu();
}
package org.universAAL.ucc.api.plugin;
import org.universAAL.ucc.api.view.IMainWindow;
public interface IPluginBase {
public void registerPlugin(final IPlugin plugin);
public void unregisterPlugin(final IPlugin plugin);
public void addMenu(final PluginMenu menu);
public IMainWindow getMainView();
}
......@@ -7,17 +7,11 @@ package org.universAAL.ucc.api.view;
*/
public interface IMainWindow {
/**
*
* @param subWindow
*/
public void addSubWindow(ISubWindow subWindow);
/**
*
* @param subWindow
*/
public void closeSubWindow(ISubWindow subWindow);
public void removeSubWindow(ISubWindow subWindow);
public void showSubWindow(ISubWindow subWindow);
public void hideSubWindow(ISubWindow subWindow);
public boolean initialize();
......
......@@ -16,22 +16,21 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.universAAL.middleware</groupId>
<artifactId>mw.data.representation</artifactId>
<version>0.3.0-SNAPSHOT</version>
<version>0.3.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.universAAL.middleware</groupId>
<artifactId>mw.bus.model</artifactId>
<version>0.3.0-SNAPSHOT</version>
<version>0.3.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.universAAL.middleware</groupId>
<artifactId>mw.bus.io</artifactId>
<version>0.3.0-SNAPSHOT</version>
<version>0.3.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.universAAL.ucc</groupId>
......
......@@ -16,12 +16,11 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.universAAL.middleware</groupId>
<artifactId>mw.data.representation</artifactId>
<version>0.3.0-SNAPSHOT</version>
<version>0.3.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.universAAL.ucc</groupId>
......
......@@ -20,7 +20,7 @@
<dependency>
<groupId>org.universAAL.middleware</groupId>
<artifactId>mw.data.representation</artifactId>
<version>0.3.0-SNAPSHOT</version>
<version>0.3.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.universAAL.ucc</groupId>
......
......@@ -31,7 +31,7 @@ public class Activator implements BundleActivator {
private static IConfigurator configurator = null;
private static PluginBase pluginBase = null;
MainWindow mainWindow = null;
public MainWindow mainWindow = null;
static final String libraryNames[] = { "qtjambi.dll",
"com_trolltech_qt_core.dll", "com_trolltech_qt_gui.dll", "com_trolltech_qt_network.dll",
......
......@@ -60,11 +60,30 @@ public class MainWindow extends QMainWindow implements IMainWindow {
}
}
public void closeSubWindow(ISubWindow subWindow) {
public void removeSubWindow(ISubWindow subWindow) {
QMdiSubWindow mdiChild = subWindows.remove(subWindow);
if (mdiChild != null)
mdiChild.close();
}
public void showSubWindow(ISubWindow subWindow) {
QMdiSubWindow child = this.subWindows.get(subWindow);
if (child == null) {
System.err.println("Can not find SubWindow --> can not show it!");
return;
}
child.show();
}
public void hideSubWindow(ISubWindow subWindow) {
QMdiSubWindow child = this.subWindows.get(subWindow);
if (child == null) {
System.err.println("Can not find SubWindow --> can not hide it!");
return;
}
child.hide();
}
public boolean initialize() {
// TODO Auto-generated method stub
......
package org.universAAL.ucc.viewjambi.impl;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import org.universAAL.ucc.api.plugin.IPlugin;
import org.universAAL.ucc.api.plugin.IPluginBase;
import org.universAAL.ucc.api.plugin.PluginMenu;
import org.universAAL.ucc.api.plugin.PluginMenuEntry;
import org.universAAL.ucc.api.plugin.PluginMenuSimpleEntry;
import org.universAAL.ucc.api.view.IMainWindow;
import com.trolltech.qt.QSignalEmitter;
import com.trolltech.qt.core.QObject;
import com.trolltech.qt.gui.QAction;
import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QMenu;
public class PluginBase extends QSignalEmitter implements IPluginBase {
public class PluginBase extends QObject implements IPluginBase {
ArrayList<IPlugin> plugins = new ArrayList<IPlugin>();
private ArrayList<IPlugin> plugins = new ArrayList<IPlugin>();
private Hashtable<QAction, Runnable> pluginMenuActions = new Hashtable<QAction, Runnable>();
public PluginBase() {
......@@ -22,8 +29,6 @@ public class PluginBase extends QSignalEmitter implements IPluginBase {
QApplication.invokeLater(new Runnable() {
public void run() {
plugin.registerViews();
//QMenu menu = new QMenu("Test");
//menu.addAction(new QAction("Click Me", menu));
}});
this.plugins.add(plugin);
}
......@@ -31,4 +36,46 @@ public class PluginBase extends QSignalEmitter implements IPluginBase {
public void unregisterPlugin(final IPlugin plugin) {
this.plugins.remove(plugin);
}
public void addMenu(final PluginMenu menu) {
final PluginBase base = this;
QApplication.invokeLater(new Runnable() {
public void run() {
MainWindow mainWindow = MainWindow.getInstance();
QMenu newMenu = new QMenu(menu.getCaption());
for (Iterator<PluginMenuEntry> i = menu.getEntries(); i.hasNext(); ) {
PluginMenuEntry entry = i.next();
switch (entry.getType()) {
case SEPERATOR : newMenu.addSeparator();
case SIMPLE_TEXT : {
PluginMenuSimpleEntry sEntry = (PluginMenuSimpleEntry)entry;
QAction action = new QAction(sEntry.getCaption(), newMenu);
pluginMenuActions.put(action, sEntry.getToBeDoneAtClick());
action.triggered.connect(base, "pluginActionClicked(Boolean)");
newMenu.addAction(action);
}
}
}
mainWindow.menuBar().addMenu(newMenu);
}}
);
}
public IMainWindow getMainView() {
return MainWindow.getInstance();
}
protected void pluginActionClicked(Boolean value) {
Object object = QObject.signalSender();
if (object == null || !(object instanceof QAction)) {
System.err.println("Object have to be of type QAction!");
return;
}
Runnable toExec = this.pluginMenuActions.get(object);
if (toExec == null) {
System.err.println("Action not registered!");
return;
}
toExec.run();
}
}
......@@ -35,7 +35,7 @@ public class InformationView extends SubWindow {
}
protected void closeMe() {
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().hideSubWindow(this);
}
protected String statusToString(int status) {
......
......@@ -113,13 +113,13 @@ public class ConfigView extends SubWindow {
QMessageBox.information(this, "Installation", "Installation successfully completed!");
}else
QMessageBox.critical(this, "Error", completed);
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
}
protected void cancel() {
Activator.getInstaller().revertInstallation(new File(appDir));
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
}
/** For convenience and test purposes the xml parsing is done here.
......
......@@ -49,12 +49,12 @@ public class DeinstallView extends SubWindow {
}else{
QMessageBox.critical(this, "Deinstall Application", "Could not deinstall the application!");
}
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
}
}
protected void cancel() {
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
}
}
......@@ -41,18 +41,18 @@ public class InstallView extends SubWindow {
p=p.replace("/", "\\");
try {
String appDir = Activator.getInstaller().installApplication(p);
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
MainWindow.getInstance().showLicense(appDir);
} catch (NullPointerException e){
QMessageBox.critical(this, "Error", "Installation failed! The Application probably already is installed!");
} catch (Exception e) {
QMessageBox.critical(this, "Error", e.getMessage());
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
}
}
protected void cancel() {
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
}
}
......@@ -30,7 +30,7 @@ public class LicenseView extends SubWindow {
protected void accept() {
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
MainWindow.getInstance().configureApp(appDir);
}
......@@ -59,7 +59,7 @@ public class LicenseView extends SubWindow {
protected void cancel() {
Activator.getInstaller().revertInstallation(new File(appDir));
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
}
}
......@@ -71,7 +71,7 @@ public class OverviewView extends SubWindow {
protected void cancel() {
System.out.println("Setting active to false..");
active = false;
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
}
}
......@@ -50,7 +50,7 @@ public class Overview_ConfigView extends SubWindow {
protected void cancel() {
MainWindow.getInstance().closeSubWindow(this);
MainWindow.getInstance().removeSubWindow(this);
}
protected void save(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment