package Qt;
import org.kde.qt.QApplication;
import org.kde.qt.QFont;
import org.kde.qt.QLabel;
import org.kde.qt.QMainWindow;
import org.kde.qt.QMessageBox;
import org.kde.qt.QToolTip;
import org.kde.qt.QWidget;
import org.kde.qt.qtjava;
import core.RPC;
import core.XML_Parser;
public class MainWindow extends QMainWindow {
private QLabel msg;
private RPC rpc = new RPC("localhost", 31416);
public XML_Parser parser;
public MainWindow(QWidget parent, String name) {
super(parent, name);
MenuBar menuBar = new MenuBar(this, "MenuBar");
createStatusBar();
rpc.createConnection();
msg.setText("[ Welcome ]");
}
public MainWindow() {
this(null, null);
}
private void createStatusBar() {
msg = new QLabel(statusBar(), "message");
msg.setAlignment(AlignCenter);
QFont boldfont = new QFont();
boldfont.setWeight(QFont.Bold);
msg.setFont(boldfont);
statusBar().addWidget(msg, 4);
QToolTip.add(msg, "Message area");
}
public void attachToProject() {
// TODO
}
public void accountManager() {
// TODO
}
public void runAlways() {
msg.setText("Setting run mode...");
parser = new XML_Parser(rpc.set_run_mode(RPC.RUN_MODE_ALWAYS).toString());
if(parser.runMode()) {
msg.setText(msg.text()+" done");
} else {
msg.setText(msg.text()+" ERROR!!!");
}
}
public void runBasedOnPreferences() {
msg.setText("Setting run mode...");
parser = new XML_Parser(rpc.set_run_mode(RPC.RUN_MODE_AUTO).toString());
if(parser.runMode()) {
msg.setText(msg.text()+" done");
} else {
msg.setText(msg.text()+" ERROR!!!");
}
}
public void suspend() {
msg.setText("Setting run mode...");
parser = new XML_Parser(rpc.set_run_mode(RPC.RUN_MODE_NEVER).toString());
if(parser.runMode()) {
msg.setText(msg.text()+" done");
} else {
msg.setText(msg.text()+" ERROR!!!");
}
}
public void networkAlwaysAvailable() {
msg.setText("Setting network mode...");
parser = new XML_Parser(rpc.set_network_mode(RPC.NETWORK_MODE_ALWAYS).toString());
if(parser.networkMode()) {
msg.setText(msg.text()+" done");
} else {
msg.setText(msg.text()+" ERROR!!!");
}
}
public void networkAuto() {
msg.setText("Setting network mode...");
parser = new XML_Parser(rpc.set_network_mode(RPC.NETWORK_MODE_AUTO).toString());
if(parser.networkMode()) {
msg.setText(msg.text()+" done");
} else {
msg.setText(msg.text()+" ERROR!!!");
}
}
public void networkSuspend() {
msg.setText("Setting network mode...");
parser = new XML_Parser(rpc.set_network_mode(RPC.NETWORK_MODE_NEVER).toString());
if(parser.networkMode()) {
msg.setText(msg.text()+" done");
} else {
msg.setText(msg.text()+" ERROR!!!");
}
}
public void options() {
// TODO
}
public void selectComputer() {
// TODO
}
public void benchark() {
msg.setText("running Benchmarks...");
parser = new XML_Parser(rpc.run_benchmarks().toString());
if(parser.benchmark()) {
msg.setText(msg.text()+" done");
} else {
msg.setText(msg.text()+" ERROR!!!");
}
}
public void retryCommunication() {
// TODO
}
public void jboincManager() {
// TODO
}
public void jboincWebsite() {
// TODO
}
public void BOINCWebsite() {
// TODO
}
public void about() {
// TODO
}
public void aboutQt() {
// TODO
QMessageBox.aboutQt(this, "Qt Menu Example");
}
public static void main(String[] args) {
QApplication a = new QApplication(args);
MainWindow main = new MainWindow();
main.resize(600, 600);
main.setCaption("Qt MainWindow");
a.setMainWidget(main);
main.show();
a.exec();
return;
}
static {
qtjava.initialize();
}
}