public static void main(String[] args) { SwingUtilities.invokeLater( () -> { MainGUI gui = new MainGUI(); MainController controller = new MainController(gui); controller.showGUI(); }); }
@Override public void start(Stage primaryStage) throws Exception { primaryStage.initStyle(StageStyle.UNDECORATED); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getClassLoader().getResource(MAIN_VIEW_LOCATION)); Parent root = (Parent) fxmlLoader.load(); root.getStylesheets().add(STYLESHEET); Scene scene = new Scene(root, WIDTH, HEIGHT); primaryStage.setScene(scene); primaryStage.show(); // layout containers wont be initialized until primary stage is shown MainController controller = (MainController) fxmlLoader.getController(); controller.init(); }
@FXML private void goToOverview(ActionEvent event) { RegName.clear(); RegPass.clear(); InvalidLabel.setText(""); main.setScreen(App.HotelOverviewID); }
private void createBindings() { refreshConnectionList(); connectionsTable = (XulTree) document.getElementById("connections-table"); // Bind the connection table to a list of connections bf.setBindingType(Binding.Type.ONE_WAY); // CHECKSTYLE:LineLength:OFF try { bf.createBinding(dbConnectionList, "children", connectionsTable, "elements") .fireSourceChanged(); (bindButtonNew = bf.createBinding(this, "repReadOnly", "connections-new", "disabled")) .fireSourceChanged(); (bindButtonEdit = bf.createBinding(this, "repReadOnly", "connections-edit", "disabled")) .fireSourceChanged(); (bindButtonRemove = bf.createBinding(this, "repReadOnly", "connections-remove", "disabled")) .fireSourceChanged(); if (repository != null) { bf.createBinding(connectionsTable, "selectedItems", this, "selectedConnections"); } } catch (Exception ex) { if (mainController == null || !mainController.handleLostRepository(ex)) { // convert to runtime exception so it bubbles up through the UI throw new RuntimeException(ex); } } }
/** setup the maintenance panel and display it. */ public void displayMaintenancePanel() { SimulatorControlPanel scp = mCtrl.getSimulatorControlPanel(); if (mpanel == null) mpanel = new MaintenancePanel((Frame) scp, this); mpanel.display(); mpanel.setActive(MaintenancePanel.DIALOG, true); // setActive of password, invalid and valid display. }
@Override protected boolean doLazyInit() { try { mainController = (MainController) this.getXulDomContainer().getEventHandler("mainController"); } catch (XulException e) { return false; } try { setRepReadOnly(this.repository.getRepositoryMeta().getRepositoryCapabilities().isReadOnly()); // Load the SWT Shell from the explorer dialog shell = ((SwtDialog) document.getElementById("repository-explorer-dialog")).getShell(); bf = new DefaultBindingFactory(); bf.setDocument(this.getXulDomContainer().getDocumentRoot()); if (bf != null) { createBindings(); } enableButtons(true, false, false); return true; } catch (Exception e) { if (mainController == null || !mainController.handleLostRepository(e)) { return false; } } return false; }
private void initFileMenu() { openMenuItem.setAccelerator(KeyCombination.keyCombination(KeyCombination.META_DOWN + "+o")); openMenuItem.setOnAction( (ae) -> { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open Binary"); fileChooser.setInitialDirectory(new File(System.getProperty("user.home"))); InputStream resourceAsStream = null; try { resourceAsStream = new FileInputStream( fileChooser.showOpenDialog( MainController.getSharedMainController().getPrimaryStage())); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Unable to open file: " + e); } openStream(resourceAsStream); }); openTestMenuItem.setAccelerator( KeyCombination.keyCombination( KeyCombination.META_DOWN + "+" + KeyCombination.SHIFT_ANY + "+o")); openTestMenuItem.setOnAction( (ae) -> { final InputStream resourceAsStream = MenuBarController.class.getResourceAsStream("mach_bin.out"); openStream(resourceAsStream); }); }
// TransferCashButtonListener // get all the cash from store and set store cash 0; public void transferAll() { StoreController sctrl = mCtrl.getStoreController(); MachineryController machctrl = mCtrl.getMachineryController(); int cc; // coin quantity; try { cc = sctrl.transferAll(); mpanel.displayCoins(cc); machctrl.displayCoinStock(); // the cash qty current is displayed in the Maintenance panel needs to be update to be 0; // not required. mpanel.updateCurrentQtyDisplay(Store.CASH, 0); } catch (VMCSException e) { System.out.println("MaintenanceController.transferAll:" + e); } }
// invoked in CoinDisplayListener public void displayCoin(int idx) { StoreController sctrl = mCtrl.getStoreController(); CashStoreItem item; try { item = (CashStoreItem) sctrl.getStoreItem(Store.CASH, idx); mpanel.getCoinDisplay().displayQty(idx, item.getQuantity()); } catch (VMCSException e) { System.out.println("MaintenanceController.displayCoin:" + e); } }
public void loginMaintainer(boolean st) { mpanel.displayPasswordState(st); mpanel.clearPassword(); if (st == true) { // login successful mpanel.setActive(MaintenancePanel.WORKING, true); mpanel.setActive(MaintenancePanel.PSWD, false); MachineryController machctrl = mCtrl.getMachineryController(); machctrl.setDoorState(false); } }
// StoreViewerListener public void changeStoreQty(char type, int idx, int qty) { StoreController sctrl = mCtrl.getStoreController(); try { mpanel.updateQtyDisplay(type, idx, qty); mpanel.initCollectCash(); mpanel.initTotalCash(); } catch (VMCSException e) { System.out.println("MaintenanceController.changeStoreQty:" + e); } }
// invoked in DrinkDisplayListener; public void displayDrinks(int idx) { StoreController sctrl = mCtrl.getStoreController(); DrinksStoreItem item; try { item = (DrinksStoreItem) sctrl.getStoreItem(Store.DRINK, idx); DrinksBrand db = (DrinksBrand) item.getContent(); mpanel.getDrinksDisplay().displayQty(idx, item.getQuantity()); mpanel.displayPrice(db.getPrice()); } catch (VMCSException e) { System.out.println("MaintenanceController.displayDrink:" + e); } }
@Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { // TODO Auto-generated method stub if (isChecked) { Intent hsintent = new Intent(context, HelloService.class); context.startService(hsintent); } else { Intent intent = new Intent(context, HelloService.class); ((MainController) context).stopService(intent); } }
// exit button listener; public void logoutMaintainer() { MachineryController machctrl = mCtrl.getMachineryController(); boolean ds = machctrl.isDoorClosed(); if (ds == false) { MessageDialog msg = new MessageDialog(mpanel, "Please Lock the Door before You Leave"); msg.setLocation(500, 500); return; } mpanel.setActive(MaintenancePanel.DIALOG, true); }
public void removeConnection() { try { Collection<UIDatabaseConnection> connections = connectionsTable.getSelectedItems(); if (connections != null && !connections.isEmpty()) { for (Object obj : connections) { if (obj != null && obj instanceof UIDatabaseConnection) { UIDatabaseConnection connection = (UIDatabaseConnection) obj; DatabaseMeta databaseMeta = connection.getDatabaseMeta(); // Make sure this connection already exists and store its id for updating ObjectId idDatabase = repository.getDatabaseID(databaseMeta.getName()); if (idDatabase == null) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Delete.DoesNotExists.Message", databaseMeta.getName())); mb.setText( BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.Title")); mb.open(); } else { repository.deleteDatabaseMeta(databaseMeta.getName()); } } } } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Message")); mb.setText(BaseMessages.getString(PKG, "RepositoryExplorerDialog.Connection.Delete.Title")); mb.open(); } } catch (KettleException e) { if (mainController == null || !mainController.handleLostRepository(e)) { new ErrorDialog( shell, BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"), BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Remove.UnexpectedError.Message"), e); } } finally { refreshConnectionList(); } }
protected void mergeProcesses() { String message; if ("".compareTo(this.processNameT.getValue()) != 0 && "".compareTo(this.versionNameT.getValue()) != 0) { try { Integer folderId = 0; if (UserSessionManager.getCurrentFolder() != null) { folderId = UserSessionManager.getCurrentFolder().getId(); } ProcessSummaryType result = getService() .mergeProcesses( selectedProcessVersions, this.processNameT.getValue(), this.versionNameT.getValue(), this.domainCB.getValue(), UserSessionManager.getCurrentUser().getUsername(), folderId, this.makePublic.isChecked(), this.algosLB.getSelectedItem().getLabel(), this.removeEnt.isChecked(), ((Doublebox) this.mergethreshold.getFirstChild().getNextSibling()).getValue(), ((Doublebox) this.labelthreshold.getFirstChild().getNextSibling()).getValue(), ((Doublebox) this.contextthreshold.getFirstChild().getNextSibling()).getValue(), ((Doublebox) this.skipnweight.getFirstChild().getNextSibling()).getValue(), ((Doublebox) this.subnweight.getFirstChild().getNextSibling()).getValue(), ((Doublebox) this.skipeweight.getFirstChild().getNextSibling()).getValue()); message = "Merge built one process."; mainC.displayNewProcess(result); } catch (Exception e) { message = "Merge failed (" + e.getMessage() + ")"; } mainC.displayMessage(message); this.processMergeW.detach(); } }
public void createConnection() { try { DatabaseMeta databaseMeta = new DatabaseMeta(); databaseMeta.initializeVariablesFrom(null); getDatabaseDialog().setDatabaseMeta(databaseMeta); String dbName = getDatabaseDialog().open(); if (dbName != null) { dbName = dbName.trim(); if (!dbName.isEmpty()) { // See if this user connection exists... ObjectId idDatabase = repository.getDatabaseID(dbName); if (idDatabase == null) { repository.insertLogEntry( BaseMessages.getString( PKG, "ConnectionsController.Message.CreatingDatabase", getDatabaseDialog().getDatabaseMeta().getName())); repository.save( getDatabaseDialog().getDatabaseMeta(), Const.VERSION_COMMENT_INITIAL_VERSION, null); } else { showAlreadyExistsMessage(); } } } // We should be able to tell the difference between a cancel and an empty database name // // else { // MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); // mb.setMessage(BaseMessages.getString(PKG, // "RepositoryExplorerDialog.Connection.Edit.MissingName.Message")); // mb.setText(BaseMessages.getString(PKG, // "RepositoryExplorerDialog.Connection.Edit.MissingName.Title")); // mb.open(); // } } catch (KettleException e) { if (mainController == null || !mainController.handleLostRepository(e)) { new ErrorDialog( shell, BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"), BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Message"), e); } } finally { refreshConnectionList(); } }
@FXML private void handleRegistrationAction(ActionEvent event) throws IOException { if (RegName.getText().equals("") || RegPass.getText().equals("")) { RegName.clear(); RegPass.clear(); InvalidLabel.setText("Username or Password field cannot be empty"); } else { String Username = RegName.getText(); String Password = RegPass.getText(); SQLiteJDBC.InsertUser(Username, Password); RegName.clear(); RegPass.clear(); InvalidLabel.setText(""); main.setScreen(App.HotelOverviewID); } }
public void setEncodingPopup(NSPopUpButton encodingPopup) { this.encodingPopup = encodingPopup; this.encodingPopup.setEnabled(true); this.encodingPopup.removeAllItems(); this.encodingPopup.addItemWithTitle(DEFAULT); this.encodingPopup.menu().addItem(NSMenuItem.separatorItem()); this.encodingPopup.addItemsWithTitles( NSArray.arrayWithObjects(MainController.availableCharsets())); if (null == host.getEncoding()) { this.encodingPopup.selectItemWithTitle(DEFAULT); } else { this.encodingPopup.selectItemWithTitle(host.getEncoding()); } this.encodingPopup.setTarget(this.id()); final Selector action = Foundation.selector("encodingSelectionChanged:"); this.encodingPopup.setAction(action); }
public void setRepReadOnly(boolean isRepReadOnly) { try { if (this.isRepReadOnly != isRepReadOnly) { this.isRepReadOnly = isRepReadOnly; if (initialized) { bindButtonNew.fireSourceChanged(); bindButtonEdit.fireSourceChanged(); bindButtonRemove.fireSourceChanged(); } } } catch (Exception e) { if (mainController == null || !mainController.handleLostRepository(e)) { // convert to runtime exception so it bubbles up through the UI throw new RuntimeException(e); } } }
private void openStream(final InputStream stream) { if (stream == null) { LOGGER.log(Level.SEVERE, "Unable to open file!"); return; } AbstractABI read = null; try { read = Reader.Read(stream); } catch (Exception e) { e.printStackTrace(); } if (read == null) { LOGGER.log(Level.SEVERE, "Unable to parse ABI!"); return; } MainController.getSharedMainController().setABI(read); }
private void doLogin() { if (usernameField.getText().isEmpty()) { showConsoleText("username missing"); return; } if (passwordField.getText().isEmpty()) { showConsoleText("password missing"); return; } if (!userService.authenticate(usernameField.getText(), passwordField.getText())) { showConsoleText("authentication failed"); return; } showConsoleText("login accepted"); Navigation.getInstance().loadScreen(MainController.getName()); }
private void initializeMainController() { mainController = MainController.getInstance(); }
public void editConnection() { try { Collection<UIDatabaseConnection> connections = connectionsTable.getSelectedItems(); if (connections != null && !connections.isEmpty()) { // Grab the first item in the list & send it to the database dialog DatabaseMeta databaseMeta = ((UIDatabaseConnection) connections.toArray()[0]).getDatabaseMeta(); // Make sure this connection already exists and store its id for updating ObjectId idDatabase = repository.getDatabaseID(databaseMeta.getName()); if (idDatabase == null) { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Message")); mb.setText( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.DoesNotExists.Title")); mb.open(); } else { getDatabaseDialog().setDatabaseMeta(databaseMeta); String dbName = getDatabaseDialog().open(); if (dbName != null) { dbName = dbName.trim(); if (!dbName.isEmpty()) { ObjectId idRenamed = repository.getDatabaseID(dbName); if (idRenamed == null || idRenamed.equals(idDatabase)) { // renaming to non-existing name or updating the current repository.insertLogEntry( BaseMessages.getString( PKG, "ConnectionsController.Message.UpdatingDatabase", databaseMeta.getName())); repository.save(databaseMeta, Const.VERSION_COMMENT_EDIT_VERSION, null); } else { // trying to rename to an existing name - show error dialog showAlreadyExistsMessage(); } } } // We should be able to tell the difference between a cancel and an empty database name // // else { // MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); // mb.setMessage(BaseMessages.getString(PKG, // "RepositoryExplorerDialog.Connection.Edit.MissingName.Message")); // mb.setText(BaseMessages.getString(PKG, // "RepositoryExplorerDialog.Connection.Edit.MissingName.Title")); // mb.open(); // } } } else { MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); mb.setMessage( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Message")); mb.setText( BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.NoItemSelected.Title")); mb.open(); } } catch (KettleException e) { if (mainController == null || !mainController.handleLostRepository(e)) { new ErrorDialog( shell, BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Create.UnexpectedError.Title"), BaseMessages.getString( PKG, "RepositoryExplorerDialog.Connection.Edit.UnexpectedError.Message"), e); } } finally { refreshConnectionList(); } }
// TotalCashButtonListener public void getTotalCash() { StoreController sctrl = mCtrl.getStoreController(); int tc = sctrl.getTotalCash(); mpanel.displayTotalCash(tc); }
@Override public void actionPerformed(ActionEvent pAE) { DocumentMaster docM = mOwner.getSelectedDocM(); WorkflowModel wfModel = mOwner.getSelectedWorkflowModel(); FolderTreeNode folderTreeNode = mOwner.getSelectedFolder(); DocumentMasterTemplate template = mOwner.getSelectedDocMTemplate(); MainController controller = MainController.getInstance(); try { if (docM == null && wfModel == null && template == null && folderTreeNode != null) { if (folderTreeNode instanceof TagTreeNode) { String questionMsg = MessageFormat.format( I18N.BUNDLE.getString("DeleteElement_question_tag"), folderTreeNode.getName()); if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog( mOwner, questionMsg, I18N.BUNDLE.getString("DeleteElement_question_title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) { controller.delTag(folderTreeNode.getName()); } } else { String questionMsg = MessageFormat.format( I18N.BUNDLE.getString("DeleteElement_question_folder"), folderTreeNode.getCompletePath()); if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog( mOwner, questionMsg, I18N.BUNDLE.getString("DeleteElement_question_title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) { DocumentMasterKey[] pks = controller.delFolder(folderTreeNode.getCompletePath()); for (DocumentMasterKey pk : pks) { FileIO.rmDir(Config.getCheckOutFolder(pk)); FileIO.rmDir(Config.getCacheFolder(pk)); Prefs.removeDocNode(pk); } } } } else if (docM != null) { String questionMsg = MessageFormat.format(I18N.BUNDLE.getString("DeleteElement_question_document"), docM); if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog( mOwner, questionMsg, I18N.BUNDLE.getString("DeleteElement_question_title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) { controller.delDocM(docM); FileIO.rmDir(Config.getCheckOutFolder(docM)); FileIO.rmDir(Config.getCacheFolder(docM)); Prefs.removeDocNode(docM); } } else if (wfModel != null) { String questionMsg = MessageFormat.format(I18N.BUNDLE.getString("DeleteElement_question_workflow"), wfModel); if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog( mOwner, questionMsg, I18N.BUNDLE.getString("DeleteElement_question_title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) { controller.delWorkflowModel(wfModel); } } else if (template != null) { String questionMsg = MessageFormat.format( I18N.BUNDLE.getString("DeleteElement_question_template"), template); if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog( mOwner, questionMsg, I18N.BUNDLE.getString("DeleteElement_question_title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)) { controller.delDocMTemplate(template); FileIO.rmDir(Config.getCacheFolder(template)); } } } catch (Exception pEx) { String message = pEx.getMessage() == null ? I18N.BUNDLE.getString("Error_unknown") : pEx.getMessage(); JOptionPane.showMessageDialog( null, message, I18N.BUNDLE.getString("Error_title"), JOptionPane.ERROR_MESSAGE); } ExplorerFrame.unselectElementInAllFrame(); }
public void onModuleLoad() { MainController main = new MainController(new HandlerManager(null)); RootLayoutPanel.get().add(main.asWidget()); main.go(); }
public void showInfoMessage(String message) { JOptionPane.showMessageDialog( mainController.getMainGui(), message, "Info", JOptionPane.INFORMATION_MESSAGE); logger.error("Info: " + message); }
private void jButton1ActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed Icon grumpySays = new ImageIcon(getClass().getResource(mainController.getGrumpySaysPath())); jLabel1.setIcon(grumpySays); } // GEN-LAST:event_jButton1ActionPerformed
public void showErrorMessage(String message) { JOptionPane.showMessageDialog( mainController.getMainGui(), message, "Error", JOptionPane.ERROR_MESSAGE); logger.error("Error: " + message); }