List of usage examples for javax.swing JOptionPane NO_OPTION
int NO_OPTION
To view the source code for javax.swing JOptionPane NO_OPTION.
Click Source Link
From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java
/** * Shutdowns the GridNode//from w ww .j a v a 2 s . com */ protected void doShutdownNode() { int result = JOptionPane.showConfirmDialog(this, "Are You Sure to Shutdown Node ?", "Nebula Grid", JOptionPane.YES_NO_OPTION); // If user chose no, abort shutdown if (result == JOptionPane.NO_OPTION) return; new Thread(new Runnable() { @Override public void run() { try { // If connected to Cluster, unregister if (Grid.isNode()) { GridNode.getInstance().shutdown(); } removeIcon(); System.exit(0); } catch (Exception e) { log.fatal("[GridNode] Exception while Shutting Down", e); System.exit(1); } } }).start(); }
From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java
/** * Command: Delete selected <code>Collectable</code>s in the Result panel. */// w w w . j a v a 2 s. c o m private void cmdDeleteSelectedCollectables() { assert getCollectStateModel().getOuterState() == CollectState.OUTERSTATE_RESULT; assert CollectState.isResultModeSelected(getCollectStateModel().getResultMode()); if (multipleCollectablesSelected()) { final int iCount = getResultTable().getSelectedRowCount(); final String sMessage = getSpringLocaleDelegate().getMessage("GenericObjectCollectController.82", "Sollen die ausgew\u00e4hlten {0} Datens\u00e4tze wirklich gel\u00f6scht werden?", iCount); final int btn = JOptionPane.showConfirmDialog(getTab(), sMessage, getSpringLocaleDelegate() .getMessage("GenericObjectCollectController.21", "Datens\u00e4tze l\u00f6schen"), JOptionPane.YES_NO_OPTION); if (btn == JOptionPane.YES_OPTION) new DeleteSelectedCollectablesController<CollectableGenericObjectWithDependants>(this) .run(getMultiActionProgressPanel(iCount)); else if (btn == JOptionPane.NO_OPTION) getResultPanel().btnDelete.setSelected(false); } else { final String sMessage = getSpringLocaleDelegate().getMessage("GenericObjectCollectController.77", "Soll der ausgew\u00e4hlte Datensatz ({0}) wirklich gel\u00f6scht werden?", getSelectedCollectable().getIdentifierLabel()); final int btn = JOptionPane.showConfirmDialog(getTab(), sMessage, getSpringLocaleDelegate().getMessage( "GenericObjectCollectController.25", "Datensatz l\u00f6schen"), JOptionPane.YES_NO_OPTION); if (btn == JOptionPane.YES_OPTION) UIUtils.runCommand(getTab(), new Runnable() { @Override public void run() { try { checkedDeleteSelectedCollectable(); //refreshResult(); } catch (CommonPermissionException ex) { final String sErrorMsg = getSpringLocaleDelegate().getMessage( "GenericObjectCollectController.68", "Sie verf\u00fcgen nicht \u00fcber die ausreichenden Rechte, um diesen Datensatz zu l\u00f6schen."); getResultPanel().btnDelete.setSelected(false); Errors.getInstance().showExceptionDialog(getTab(), sErrorMsg, ex); } catch (CommonBusinessException ex) { getResultPanel().btnDelete.setSelected(false); //Errors.getInstance().showExceptionDialog(getFrame(), SpringLocaleDelegate.getMessage("GenericObjectCollectController.30","Der Datensatz konnte nicht gel\u00f6scht werden."), ex); Errors.getInstance().showExceptionDialog(getTab(), getSpringLocaleDelegate().getMessage("GenericObjectCollectController.30", "Der Datensatz konnte nicht gel\u00f6scht werden."), new CommonRemoveException()); } } }); else if (btn == JOptionPane.NO_OPTION) getResultPanel().btnDelete.setSelected(false); } }
From source file:org.nuclos.client.genericobject.GenericObjectCollectController.java
/** * @deprecated Move to ResultController hierarchy. *///from ww w .j a v a2 s . c o m private void cmdRestoreSelectedCollectables() { assert getCollectStateModel().getOuterState() == CollectState.OUTERSTATE_RESULT; assert CollectState.isResultModeSelected(getCollectStateModel().getResultMode()); if (multipleCollectablesSelected()) { final int iCount = getResultTable().getSelectedRowCount(); final String sMessage = getSpringLocaleDelegate().getMessage("GenericObjectCollectController.83", "Sollen die ausgew\u00e4hlten {0} Datens\u00e4tze wirklich wiederhergestellt werden?", iCount); final int btn = JOptionPane.showConfirmDialog(getTab(), sMessage, getSpringLocaleDelegate() .getMessage("GenericObjectCollectController.22", "Datens\u00e4tze wiederherstellen"), JOptionPane.YES_NO_OPTION); if (btn == JOptionPane.YES_OPTION) new RestoreSelectedCollectablesController(GenericObjectCollectController.this) .run(getMultiActionProgressPanel(iCount)); else if (btn == JOptionPane.NO_OPTION) getResultPanel().btnDelete.setSelected(true); } else { final String sMessage = getSpringLocaleDelegate().getMessage("GenericObjectCollectController.78", "Soll der ausgew\u00e4hlte Datensatz ({0}) wirklich wiederhergestellt werden?", getSelectedCollectable().getIdentifierLabel()); final int btn = JOptionPane.showConfirmDialog(getTab(), sMessage, getSpringLocaleDelegate().getMessage( "GenericObjectCollectController.27", "Datensatz wiederherstellen"), JOptionPane.YES_NO_OPTION); if (btn == JOptionPane.YES_OPTION) UIUtils.runCommand(getTab(), new Runnable() { @Override public void run() { try { checkedRestoreCollectable(getSelectedCollectable()); getResultController().getSearchResultStrategy().refreshResult(); } catch (CommonPermissionException ex) { final String sErrorMsg = getSpringLocaleDelegate().getMessage( "GenericObjectCollectController.66", "Sie verf\u00fcgen nicht \u00fcber die ausreichenden Rechte, um diesen Datensatz wiederherzustellen."); getResultPanel().btnDelete.setSelected(true); Errors.getInstance().showExceptionDialog(getTab(), sErrorMsg, ex); } catch (CommonBusinessException ex) { getResultPanel().btnDelete.setSelected(true); Errors.getInstance().showExceptionDialog(getTab(), getSpringLocaleDelegate().getMessage("GenericObjectCollectController.32", "Der Datensatz konnte nicht wiederhergestellt werden."), ex); } } }); else if (btn == JOptionPane.NO_OPTION) getResultPanel().btnDelete.setSelected(true); } }
From source file:org.nuclos.client.main.MainController.java
private void handleMessage(final Message msg) { try {/*from w ww.ja v a2s.co m*/ if ((msg.getJMSCorrelationID() == null || msg.getJMSCorrelationID().equals(MainController.this.getUserName())) && msg instanceof ObjectMessage) { final Object objMessage = ((ObjectMessage) msg).getObject(); if (objMessage.getClass().equals(ApiMessageImpl.class)) { final ApiMessageImpl apiMsg = (ApiMessageImpl) ((ObjectMessage) msg).getObject(); LOG.info("Handle " + apiMsg); Component parent = null; if (apiMsg.getReceiverId() != null) { MainFrameTab target = MainFrameTab.getMainFrameTab(apiMsg.getReceiverId()); parent = target; if (target != null) { if (apiMsg.getMessage().isOverlay()) { OverlayOptionPane.showMessageDialog(target, apiMsg.getMessage().getMessage(), apiMsg.getMessage().getTitle(), new OvOpAdapter() { }); return; } } else { LOG.warn(String.format("Receiver with id %s not found!", apiMsg.getReceiverId())); } } if (parent == null) { parent = Main.getInstance().getMainFrame(); } JOptionPane.showMessageDialog(parent, apiMsg.getMessage().getMessage(), apiMsg.getMessage().getTitle(), JOptionPane.INFORMATION_MESSAGE); } else if (objMessage.getClass().equals(RuleNotification.class)) { final RuleNotification notification = (RuleNotification) ((ObjectMessage) msg).getObject(); getNotificationDialog().addMessage(notification); switch (notification.getPriority()) { case LOW: // just add the message, nothing else. break; case NORMAL: getMainFrame().getMessagePanel().startFlashing(); break; case HIGH: getNotificationDialog().setVisible(true); break; default: LOG.warn("Undefined message priority: " + notification.getPriority()); } LOG.info("Handled RuleNotification " + notification.toDescription()); } else if (objMessage.getClass().equals(CommandMessage.class)) { final CommandMessage command = (CommandMessage) ((ObjectMessage) msg).getObject(); switch (command.getCommand()) { case CommandMessage.CMD_SHUTDOWN: getNotificationDialog().addMessage(new RuleNotification(Priority.HIGH, getSpringLocaleDelegate().getMessage("MainController.19", "Der Client wird auf Anweisung des Administrators in 10 Sekunden beendet."), "Administrator")); getNotificationDialog().setVisible(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { Thread.sleep(10000); } catch (InterruptedException e) { // do nothing } finally { MainController.this.cmdExit(); } } }); break; } LOG.info("Handled CommandMessage " + command); } else if (objMessage.getClass().equals(CommandInformationMessage.class)) { final CommandInformationMessage command = (CommandInformationMessage) ((ObjectMessage) msg) .getObject(); switch (command.getCommand()) { case CommandInformationMessage.CMD_INFO_SHUTDOWN: Object[] options = { "OK" }; int decision = JOptionPane.showOptionDialog(getMainFrame(), command.getInfo(), getSpringLocaleDelegate().getMessage("MainController.17", "Administrator - Passwort\u00e4nderung"), JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); if (decision == 0 || decision == JOptionPane.CLOSED_OPTION || decision == JOptionPane.NO_OPTION) { new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(10000); } catch (InterruptedException e) { // do nothing } finally { MainController.this.cmdExit(); } } }, "MainController.handleMessage.cmdExit").run(); } break; } LOG.info("Handled CommandInformationMessage " + command); } } else { LOG.warn(getSpringLocaleDelegate().getMessage("MainController.14", "Message of type {0} received, while an ObjectMessage was expected.", msg.getClass().getName())); } } catch (JMSException ex) { LOG.warn("Exception thrown in JMS message listener.", ex); } }
From source file:org.nuclos.client.ui.collect.CollectController.java
protected void openSelectedCollectableInNewTab() { String entity = getEntityName(); final MainFrameTabbedPane openInTabbed; if (MainFrame.isPredefinedEntityOpenLocationSet(entity)) openInTabbed = MainFrame.getPredefinedEntityOpenLocation(entity); else//from www . j av a2 s . c o m openInTabbed = MainFrame.getTabbedPane(CollectController.this.getTab()); final List<Clct> selectedList = getSelectedCollectables(); final List<Thread> loadingThreads = new ArrayList<Thread>(); final int openQuestionCount = 5; final int size = selectedList.size(); for (int i = 0; i < size; i++) { final int currentIndex = i; final Object id = selectedList.get(i).getId(); Thread t = new Thread(new Runnable() { @Override public void run() { UIUtils.invokeOnDispatchThread(new Runnable() { @Override public void run() { try { if (currentIndex == openQuestionCount && size >= openQuestionCount * 2) { int res = JOptionPane.showConfirmDialog(openInTabbed.getComponentPanel(), getSpringLocaleDelegate().getMessage("CollectController.openInNewTab.1", "Es wurden bereits {0} Tabs geffnet. Mchten Sie die weiteren {1} Tabs auch noch ffnen?", openQuestionCount, (size - openQuestionCount)), getSpringLocaleDelegate().getMessage("CollectController.openInNewTab.2", "Wirklich alle selektierten Datenstze in neuen Tabs ffnen?"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (res == JOptionPane.NO_OPTION) { getTab().unlockLayer(); loadingThreads.clear(); return; } } MainFrameTab tab = new MainFrameTab(); openInTabbed.add(tab); NuclosCollectController<?> clct = NuclosCollectControllerFactory.getInstance() .newCollectController(getEntityName(), tab, getCustomUsage()); getMainController().initMainFrameTab(clct, tab); tab.postAdd(); clct.runViewSingleCollectableWithId(id, false); loadingThreads.remove(0); if (loadingThreads.size() > 0) { loadingThreads.get(0).start(); } else { getTab().unlockLayer(); } } catch (Exception e) { throw new NuclosFatalException(e); } } }); } }, "CollectController.openSelectedCollectableInNewTab"); loadingThreads.add(t); } if (loadingThreads.size() > 0) { loadingThreads.get(0).start(); } else { this.getTab().unlockLayer(); } }
From source file:org.nuclos.client.wizard.steps.NuclosEntityNameStep.java
@Override protected void initComponents() { colMasterdata = MetaDataClientProvider.getInstance().getAllEntities(); double size[][] = { { TableLayout.PREFERRED, 200, TableLayout.FILL }, { 20, 20, 20, 20, 20, TableLayout.FILL } }; TableLayout layout = new TableLayout(size); layout.setVGap(3);/* w w w . j a v a 2 s.com*/ layout.setHGap(5); this.setLayout(layout); lbName = new JLabel(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.1", "Bitte geben Sie den Namen der neuen Entit\u00e4t ein") + ": "); tfName = new JTextField(); tfName.setToolTipText(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.tooltip.1", "Namen der neuen Entit\u00e4t")); tfName.addFocusListener(NuclosWizardUtils.createWizardFocusAdapter()); lbChoice = new JLabel(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.2", "oder w\u00e4hlen Sie eine Entit\u00e4t die Sie ver\u00e4ndern m\u00f6chten") + ": "); cmbEntity = new JComboBox(); cmbEntity.setToolTipText(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.tooltip.2", "Namen der Entit\u00e4t die Sie ver\u00e4ndern m\u00f6chten")); this.fillEntityCombobox(); cmbEntity.setEditable(true); AutoCompleteDecorator.decorate(cmbEntity); lbInfo = new JLabel(); lbInfo.setVisible(false); lbInfo.setForeground(Color.RED); btnRemove = new JButton(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.8", "Entit\u00e4t entfernen")); btnRemove.setVisible(false); this.add(lbName, "0,0"); this.add(tfName, "1,0"); this.add(lbChoice, "0,1"); this.add(cmbEntity, "1,1"); this.add(lbInfo, "0,2,1,2"); this.add(btnRemove, "0,3"); tfName.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { doSomeWork(e); } @Override public void insertUpdate(DocumentEvent e) { doSomeWork(e); } @Override public void changedUpdate(DocumentEvent e) { doSomeWork(e); } protected void doSomeWork(DocumentEvent e) { int size = e.getDocument().getLength(); try { for (EntityMetaDataVO metaVO : colMasterdata) { if (e.getDocument().getLength() == 0) { lbInfo.setVisible(false); break; } if (e.getDocument().getLength() > 250) { lbInfo.setText(SpringLocaleDelegate.getInstance().getMessage( "wizard.step.entityname.12", "Der Name ist zu lang. Bitte k\u00fcrzen!")); lbInfo.setVisible(true); NuclosEntityNameStep.this.setComplete(false); return; } if (e.getDocument().getText(0, size).equals(metaVO.getEntity()) || e.getDocument().getText(0, size).equals(SpringLocaleDelegate.getInstance() .getResource(metaVO.getLocaleResourceIdForLabel(), ""))) { NuclosEntityNameStep.this.setComplete(false); lbInfo.setText(SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.4", "Entit\u00e4t ist schon vorhanden")); lbInfo.setVisible(true); return; } else { lbInfo.setVisible(false); } if (e.getDocument().getLength() > 25) { lbInfo.setText( SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.13", "Der Tabellenname wird fr interne Zwecke gekrzt!")); lbInfo.setVisible(true); } else { lbInfo.setVisible(false); } } if (size > 0) { if (cmbEntity.getSelectedIndex() > 0) { NuclosEntityNameStep.this.model.resetModel(); } NuclosEntityNameStep.this.setComplete(true); cmbEntity.setSelectedIndex(0); cmbEntity.setEnabled(false); } else { //NuclosEntityNameStep.this.model.resetModel(); NuclosEntityNameStep.this.setComplete(false); model.setTableOrViewName(null); cmbEntity.setEnabled(true); } NuclosEntityNameStep.this.model .setEntityName(e.getDocument().getText(0, e.getDocument().getLength())); if (!NuclosEntityNameStep.this.model.isEditMode()) { NuclosEntityNameStep.this.model .setLabelSingular(e.getDocument().getText(0, e.getDocument().getLength())); } } catch (BadLocationException ex) { Errors.getInstance().showExceptionDialog(NuclosEntityNameStep.this, ex); } } }); cmbEntity.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { final Object obj = e.getItem(); if (obj instanceof EntityWrapper) { EntityMetaDataVO vo = ((EntityWrapper) obj).getWrappedEntity(); NuclosEntityNameStep.this.model.setEditMode(true); NuclosEntityNameStep.this.model.resetModel(); NuclosEntityNameStep.this.setComplete(true); btnRemove.setVisible(true); } else if (obj instanceof String) { NuclosEntityNameStep.this.model.setEditMode(false); NuclosEntityNameStep.this.model.resetModel(); tfName.setEnabled(true); btnRemove.setVisible(false); NuclosEntityNameStep.this.setComplete(false); } } } }); ListenerUtil.registerActionListener(btnRemove, this, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { StringBuffer sbMessage = new StringBuffer(); if (!dropEntityAllowed(((EntityWrapper) cmbEntity.getSelectedItem()).getWrappedEntity(), sbMessage)) { JOptionPane.showMessageDialog( NuclosEntityNameStep.this, sbMessage, SpringLocaleDelegate.getInstance() .getMessage("wizard.step.inputattribute.12", "Entfernen nicht mglich!"), JOptionPane.OK_OPTION); return; } boolean blnImportStructure = MetaDataDelegate.getInstance().hasEntityImportStructure( ((EntityWrapper) cmbEntity.getSelectedItem()).getWrappedEntity().getId()); if (blnImportStructure) { String sMessage = SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.14", "Diese Entitt besitzt Strukturdefinitionen fr Objektimporte. Diese wird gelscht! Sie knnen den Vorgang abbrechen!"); int abort = JOptionPane .showConfirmDialog( NuclosEntityNameStep.this, sMessage, SpringLocaleDelegate.getInstance() .getMessage("wizard.step.entityname.16", "Achtung!"), JOptionPane.OK_CANCEL_OPTION); if (abort != JOptionPane.OK_OPTION) return; } boolean blnWorkflow = MetaDataDelegate.getInstance().hasEntityWorkflow( ((EntityWrapper) cmbEntity.getSelectedItem()).getWrappedEntity().getId()); if (blnWorkflow) { String sMessage = SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.15", "Diese Entitt ist in einem Arbeitsschritt integriert! Dieser wird gelscht!"); int abort = JOptionPane .showConfirmDialog( NuclosEntityNameStep.this, sMessage, SpringLocaleDelegate.getInstance() .getMessage("wizard.step.entityname.16", "Achtung!"), JOptionPane.OK_CANCEL_OPTION); if (abort != JOptionPane.OK_OPTION) return; } final String sMessage = SpringLocaleDelegate.getInstance().getMessage( "wizard.step.entityname.9", "Sind Sie sicher, dass Sie die Entit\u00e4t l\u00f6schen m\u00f6chten?"); final String sTitle = SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.10", "L\u00f6schen"); int dropEntity = JOptionPane.showConfirmDialog(NuclosEntityNameStep.this, sMessage, sTitle, JOptionPane.YES_NO_OPTION); switch (dropEntity) { case JOptionPane.YES_OPTION: boolean bDropLayout = false; if (MetaDataDelegate.getInstance().hasEntityLayout( ((EntityWrapper) cmbEntity.getSelectedItem()).getWrappedEntity().getId())) { int dropLayout = JOptionPane.showConfirmDialog(NuclosEntityNameStep.this, SpringLocaleDelegate.getInstance().getMessage("wizard.step.entityname.11", "Soll das Layout der Entitt gelscht werden?"), sTitle, JOptionPane.YES_NO_OPTION); bDropLayout = (dropLayout == JOptionPane.YES_OPTION); } final boolean bDropLayoutfinal = bDropLayout; UIUtils.runCommandLater(getParent(), new Runnable() { @Override public void run() { try { MetaDataDelegate.getInstance().removeEntity( ((EntityWrapper) cmbEntity.getSelectedItem()).getWrappedEntity(), bDropLayoutfinal); NuclosWizardUtils.flushCaches(); NuclosConsole.getInstance().invalidateAllCaches(); NuclosEntityNameStep.this.model.cancelWizard(); } catch (Exception ex) { Errors.getInstance().showExceptionDialog(NuclosEntityNameStep.this, ex); return; } finally { MasterDataDelegate.getInstance().invalidateLayoutCache(); } } }); break; case JOptionPane.NO_OPTION: default: return; } } catch (Exception ex) { Errors.getInstance().showExceptionDialog(NuclosEntityNameStep.this, ex); return; } } }); }
From source file:org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent.java
public void addViews() { this.setLayout(new GridBagLayout()); final GridBagConstraints c = new DefaultGridBagConstraints(); this.checkPrevisionnelle = new JCheckBox(); this.checkComplement = new JCheckBox(); this.fieldTTC = new DeviseField(); final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration .getInstance());/*from w ww.j ava2 s . c om*/ this.textAvoirTTC = new DeviseField(); // Champ Module c.gridx = 0; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; final JPanel addP = ComptaSQLConfElement.createAdditionalPanel(); this.setAdditionalFieldsPanel(new FormLayouter(addP, 1)); this.add(addP, c); c.gridy++; c.gridwidth = 1; if (getTable().contains("ID_POLE_PRODUIT")) { JLabel labelPole = new JLabel(getLabelFor("ID_POLE_PRODUIT")); labelPole.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelPole, c); c.gridx++; ElementComboBox pole = new ElementComboBox(); this.add(pole, c); this.addSQLObject(pole, "ID_POLE_PRODUIT"); c.gridy++; c.gridwidth = 1; c.gridx = 0; } /******************************************************************************************* * * RENSEIGNEMENTS ******************************************************************************************/ // Ligne 1 : Numero de facture JLabel labelNum = new JLabel(getLabelFor("NUMERO")); labelNum.setHorizontalAlignment(SwingConstants.RIGHT); c.gridx = 0; c.gridy++; c.weightx = 0; this.add(labelNum, c); this.textNumeroUnique = new JUniqueTextField(16); c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.NONE; DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique); this.add(textNumeroUnique, c); // Date c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; final JDate dateSaisie = new JDate(true); // listener permettant la mise jour du numro de facture en fonction de la date // slectionne dateSaisie.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (!isFilling() && dateSaisie.getValue() != null) { final String nextNumero = NumerotationAutoSQLElement .getNextNumero(SaisieVenteFactureSQLElement.class, dateSaisie.getValue()); if (textNumeroUnique.getText().trim().length() > 0 && !nextNumero.equalsIgnoreCase(textNumeroUnique.getText())) { int answer = JOptionPane.showConfirmDialog(SaisieVenteFactureSQLComponent.this, "Voulez vous actualiser le numro de la facture?", "Changement du numro de facture", JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.NO_OPTION) { return; } } textNumeroUnique.setText(nextNumero); } } }); this.add(dateSaisie, c); // Ligne 2 : reference c.gridx = 0; c.gridwidth = 1; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; JLabel labelLibelle = new JLabel(getLabelFor("NOM")); labelLibelle.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelLibelle, c); SQLTextCombo textLibelle = new SQLTextCombo(); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.BOTH; this.add(textLibelle, c); this.addSQLObject(textLibelle, "NOM"); c.fill = GridBagConstraints.HORIZONTAL; this.comboCommercial = new ElementComboBox(false); // Commercial String field; field = "ID_COMMERCIAL"; c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; this.add(this.comboCommercial, c); this.addRequiredSQLObject(this.comboCommercial, field); // Client c.gridx = 0; c.gridy++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; this.comboClient = new ElementComboBox(); this.add(this.comboClient, c); if (getTable().contains("ID_ECHEANCIER_CCI")) { // Echeancier c.gridx++; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel(getLabelFor("ID_ECHEANCIER_CCI"), SwingConstants.RIGHT), c); c.gridx++; c.weightx = 1; c.fill = GridBagConstraints.NONE; final ElementComboBox echeancier = new ElementComboBox(); final SQLElement contactElement = Configuration.getInstance().getDirectory() .getElement("ECHEANCIER_CCI"); echeancier.init(contactElement, contactElement.getComboRequest(true)); DefaultGridBagConstraints.lockMinimumSize(echeancier); this.addView(echeancier, "ID_ECHEANCIER_CCI"); selAffaire.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent arg0) { // TODO Raccord de mthode auto-gnr if (selAffaire.getSelectedRow() != null) { echeancier.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_AFFAIRE"), "=", selAffaire.getSelectedRow().getID())); if (!isFilling()) { SQLRow rowPole = selAffaire.getSelectedRow().getForeignRow("ID_POLE_PRODUIT"); comboCommercial.setValue(rowPole); } } else { echeancier.getRequest().setWhere(null); } } }); this.add(echeancier, c); } this.comboClient.addValueListener(this.changeClientListener); this.comboAdresse = new ElementComboBox(); this.comboAdresse.setAddIconVisible(false); this.comboAdresse.setListIconVisible(false); JLabel labelAdresse = new JLabel(getLabelFor("ID_ADRESSE"), SwingConstants.RIGHT); c.gridy++; c.gridx = 0; c.gridwidth = 1; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; labelAdresse.setHorizontalAlignment(SwingConstants.RIGHT); this.add(labelAdresse, c); c.gridx++; c.fill = GridBagConstraints.NONE; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; this.add(this.comboAdresse, c); // Acompte this.checkAcompte = new JCheckBox(getLabelFor("ACOMPTE")); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; // this.add(this.checkAcompte, c); c.gridwidth = 1; this.addView(this.checkAcompte, "ACOMPTE"); // Compte Service this.checkCompteServiceAuto = new JCheckBox(getLabelFor("COMPTE_SERVICE_AUTO")); this.addSQLObject(this.checkCompteServiceAuto, "COMPTE_SERVICE_AUTO"); this.compteSelService = new ISQLCompteSelector(); this.labelCompteServ = new JLabel("Compte Service"); c.gridy++; c.gridx = 0; c.gridwidth = 1; c.weightx = 0; this.labelCompteServ.setHorizontalAlignment(SwingConstants.RIGHT); this.add(this.labelCompteServ, c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1; this.add(this.compteSelService, c); String valServ = DefaultNXProps.getInstance().getStringProperty("ArticleService"); Boolean bServ = Boolean.valueOf(valServ); this.checkCompteServiceAuto.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setCompteServiceVisible(!SaisieVenteFactureSQLComponent.this.checkCompteServiceAuto.isSelected()); } }); // FIXME A checker si utile pour Preventec ou KD setCompteServiceVisible(false); // setCompteServiceVisible(!(bServ != null && !bServ.booleanValue())); final JPanel pAcompte = new JPanel(); final DeviseField textAcompteHT = new DeviseField(); pAcompte.add(new JLabel("Acompte HT")); pAcompte.add(textAcompteHT); pAcompte.add(new JLabel("soit")); final JTextField textAcompte = new JTextField(5); pAcompte.add(textAcompte); pAcompte.add(new JLabel("%")); c.gridx = 0; c.gridy++; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; this.add(pAcompte, c); c.anchor = GridBagConstraints.WEST; this.addView(textAcompte, "POURCENT_ACOMPTE"); pAcompte.setVisible(false); /******************************************************************************************* * * DETAILS ******************************************************************************************/ this.tableFacture = new SaisieVenteFactureItemTable(); final ElementComboBox boxTarif = new ElementComboBox(); if (this.getTable().getFieldsName().contains("ID_TARIF")) { // TARIF c.gridy++; c.gridx = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; this.add(new JLabel("Tarif appliquer", SwingConstants.RIGHT), c); c.gridx++; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.NONE; c.weightx = 1; DefaultGridBagConstraints.lockMinimumSize(boxTarif); this.add(boxTarif, c); this.addView(boxTarif, "ID_TARIF"); boxTarif.addModelListener("wantedID", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID()); tableFacture.setTarif(selectedRow, false); } }); } c.gridy++; c.gridx = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; ITextArea infos = new ITextArea(4, 4); this.add(this.tableFacture, c); // FIXME this.addView(this.tableFacture.getRowValuesTable(), ""); /******************************************************************************************* * * MODE DE REGLEMENT ******************************************************************************************/ JPanel panelBottom = new JPanel(new GridBagLayout()); GridBagConstraints cBottom = new DefaultGridBagConstraints(); cBottom.weightx = 1; cBottom.anchor = GridBagConstraints.NORTHWEST; // Mode de rglement this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP); this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT"); panelBottom.add(this.eltModeRegl, cBottom); /******************************************************************************************* * * FRAIS DE PORT ET REMISE ******************************************************************************************/ JPanel panelFrais = new JPanel(); panelFrais.setLayout(new GridBagLayout()); final GridBagConstraints cFrais = new DefaultGridBagConstraints(); this.textPortHT = new DeviseField(5); DefaultGridBagConstraints.lockMinimumSize(textPortHT); addSQLObject(this.textPortHT, "PORT_HT"); this.textRemiseHT = new DeviseField(5); DefaultGridBagConstraints.lockMinimumSize(textRemiseHT); addSQLObject(this.textRemiseHT, "REMISE_HT"); // Frais de port cFrais.gridheight = 1; cFrais.gridx = 1; SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8); if (getTable().contains("ID_TAXE_PORT")) { JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT")); labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT); cFrais.gridy++; panelFrais.add(labelPortHT, cFrais); cFrais.gridx++; panelFrais.add(this.textPortHT, cFrais); JLabel labelTaxeHT = new JLabel(getLabelFor("ID_TAXE_PORT")); labelTaxeHT.setHorizontalAlignment(SwingConstants.RIGHT); cFrais.gridx = 1; cFrais.gridy++; panelFrais.add(labelTaxeHT, cFrais); cFrais.gridx++; panelFrais.add(boxTaxePort, cFrais); this.addView(boxTaxePort, "ID_TAXE_PORT", REQ); boxTaxePort.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { // TODO Raccord de mthode auto-gnr totalTTC.updateTotal(); } }); } // Remise JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT")); labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT); cFrais.gridy++; cFrais.gridx = 1; panelFrais.add(labelRemiseHT, cFrais); cFrais.gridx++; panelFrais.add(this.textRemiseHT, cFrais); cFrais.gridy++; cBottom.gridx++; cBottom.weightx = 1; cBottom.anchor = GridBagConstraints.NORTHEAST; cBottom.fill = GridBagConstraints.NONE; panelBottom.add(panelFrais, cBottom); /******************************************************************************************* * * CALCUL DES TOTAUX ******************************************************************************************/ DeviseField fieldHT = new DeviseField(); final DeviseField fieldTVA = new DeviseField(); DeviseField fieldService = new DeviseField(); DeviseField fieldTHA = new DeviseField(); DeviseField fieldDevise = null; if (getTable().getFieldsName().contains("T_DEVISE")) { fieldDevise = new DeviseField(); addSQLObject(fieldDevise, "T_DEVISE"); } // FIXME was required but not displayed for KD addSQLObject(fieldTHA, "T_HA"); addRequiredSQLObject(fieldHT, "T_HT"); addRequiredSQLObject(fieldTVA, "T_TVA"); addRequiredSQLObject(this.fieldTTC, "T_TTC"); addRequiredSQLObject(fieldService, "T_SERVICE"); JTextField poids = new JTextField(); addSQLObject(poids, "T_POIDS"); totalTTC = new TotalPanel(this.tableFacture, fieldHT, fieldTVA, this.fieldTTC, this.textPortHT, this.textRemiseHT, fieldService, fieldTHA, fieldDevise, poids, null, (getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null)); DefaultGridBagConstraints.lockMinimumSize(totalTTC); cBottom.gridx++; cBottom.weightx = 1; cBottom.anchor = GridBagConstraints.EAST; cBottom.fill = GridBagConstraints.HORIZONTAL; panelBottom.add(totalTTC, cBottom); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy++; c.weighty = 0; this.add(panelBottom, c); // Ligne : Avoir c.gridy++; c.gridx = 0; c.weightx = 1; c.weighty = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; this.add(createPanelAvoir(), c); // Infos c.gridy++; c.gridx = 0; c.gridwidth = 4; c.fill = GridBagConstraints.BOTH; this.add(new TitledSeparator(getLabelFor("INFOS")), c); c.gridy++; final JScrollPane comp = new JScrollPane(infos); infos.setBorder(null); DefaultGridBagConstraints.lockMinimumSize(comp); this.add(comp, c); this.panelOO = new PanelOOSQLComponent(this); c.gridy++; c.gridx = 0; c.weightx = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.NORTHEAST; this.add(this.panelOO, c); this.addSQLObject(this.textAvoirTTC, "T_AVOIR_TTC"); this.addRequiredSQLObject(dateSaisie, "DATE"); this.addRequiredSQLObject(this.comboClient, "ID_CLIENT"); this.addSQLObject(this.comboAdresse, "ID_ADRESSE"); this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO"); this.addSQLObject(infos, "INFOS"); this.addSQLObject(this.checkPrevisionnelle, "PREVISIONNELLE"); this.addSQLObject(this.checkComplement, "COMPLEMENT"); this.addSQLObject(this.selAvoir, "ID_AVOIR_CLIENT"); this.addSQLObject(this.compteSelService, "ID_COMPTE_PCE_SERVICE"); ModeDeReglementSQLComponent modeReglComp; modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild(); this.selAvoir.getRequest().setWhere(new Where(this.tableAvoir.getField("SOLDE"), "=", Boolean.FALSE)); this.selAvoir.fillCombo(); // Selection du compte de service int idCompteVenteService = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_SERVICE"); if (idCompteVenteService <= 1) { try { idCompteVenteService = ComptePCESQLElement.getIdComptePceDefault("VentesServices"); } catch (Exception e) { e.printStackTrace(); } } this.compteSelService.setValue(idCompteVenteService); // Lock DefaultGridBagConstraints.lockMinimumSize(this.comboClient); DefaultGridBagConstraints.lockMinimumSize(this.comboCommercial); DefaultGridBagConstraints.lockMinimumSize(this.comboAdresse); // Listeners this.comboClient.addValueListener(this.listenerModeReglDefaut); this.fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { refreshText(); } }); this.selAvoir.addValueListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { refreshText(); } }); this.checkAcompte.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { pAcompte.setVisible(SaisieVenteFactureSQLComponent.this.checkAcompte.isSelected()); } }); this.changeClientListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (SaisieVenteFactureSQLComponent.this.comboClient.getValue() != null) { final SQLRow row = SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow(); final int id = row == null ? SQLRow.NONEXISTANT_ID : row.getID(); SaisieVenteFactureSQLComponent.this.defaultContactRowValues.putForeignID("ID_CLIENT", row); if (row != null) { if (SaisieVenteFactureSQLComponent.this.contact != null) { Where w = new Where( SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"), "=", SQLRow.NONEXISTANT_ID); w = w.or(new Where( SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"), "=", id)); SaisieVenteFactureSQLComponent.this.contact.getRequest().setWhere(w); } if (SaisieVenteFactureSQLComponent.this.comboAdresse != null) { Where w = new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=", row.getInt("ID_ADRESSE")); w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=", row.getInt("ID_ADRESSE_L"))); w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=", row.getInt("ID_ADRESSE_F"))); SQLRow rowCli = row; w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getField("ID_CLIENT"), "=", rowCli.getID())); SaisieVenteFactureSQLComponent.this.comboAdresse.getRequest().setWhere(w); } } else { if (SaisieVenteFactureSQLComponent.this.comboAdresse != null) { SaisieVenteFactureSQLComponent.this.comboAdresse.getRequest().setWhere(null); } } SaisieVenteFactureSQLComponent.this.previousClient = id; } } }; this.changeCompteListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { SQLSelect sel = new SQLSelect(getTable().getBase()); sel.addSelect(SaisieVenteFactureSQLComponent.this.client.getTable().getKey()); Where where = new Where( SaisieVenteFactureSQLComponent.this.client.getTable().getField("ID_COMPTE_PCE"), "=", SaisieVenteFactureSQLComponent.this.compteSel.getValue()); sel.setWhere(where); String req = sel.asString(); List l = getTable().getBase().getDataSource().execute(req); if (l != null) { if (l.size() == 1) { Map<String, Object> m = (Map<String, Object>) l.get(0); Object o = m.get(SaisieVenteFactureSQLComponent.this.client.getTable().getKey().getName()); System.err.println("Only one value match :: " + o); if (o != null) { SaisieVenteFactureSQLComponent.this.comboClient .setValue(Integer.valueOf(((Number) o).intValue())); } } } } }; this.textPortHT.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { totalTTC.updateTotal(); } }); this.textRemiseHT.getDocument().addDocumentListener(new SimpleDocumentListener() { @Override public void update(DocumentEvent e) { totalTTC.updateTotal(); } }); this.comboClient.addValueListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (SaisieVenteFactureSQLComponent.this.isFilling()) return; final SQLRow row = ((SQLRequestComboBox) evt.getSource()).getSelectedRow(); if (row != null) { SaisieVenteFactureSQLComponent.this.defaultContactRowValues.putForeignID("ID_CLIENT", row); if (SaisieVenteFactureSQLComponent.this.client.getTable().contains("ID_TARIF")) { SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF"); if (foreignRow != null && !foreignRow.isUndefined() && (boxTarif.getSelectedRow() == null || boxTarif.getSelectedId() != foreignRow.getID()) && JOptionPane.showConfirmDialog(null, "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) { boxTarif.setValue(foreignRow.getID()); // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow, // true); } else { boxTarif.setValue(foreignRow); } } int idCpt = row.getInt("ID_COMPTE_PCE"); if (idCpt <= 1) { // Select Compte client par defaut idCpt = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT"); if (idCpt <= 1) { try { idCpt = ComptePCESQLElement.getIdComptePceDefault("Clients"); } catch (Exception e) { e.printStackTrace(); } } } if (SaisieVenteFactureSQLComponent.this.compteSel != null) { Integer i = SaisieVenteFactureSQLComponent.this.compteSel.getValue(); if (i == null || i.intValue() != idCpt) { SaisieVenteFactureSQLComponent.this.compteSel.setValue(idCpt); } } } } }); }
From source file:org.openscience.jchempaint.application.JChemPaint.java
private static void checkCoordinates(IChemModel chemModel) throws CDKException { for (IAtomContainer next : ChemModelManipulator.getAllAtomContainers(chemModel)) { if (GeometryTools.has2DCoordinatesNew(next) != 2) { String error = GT._("Not all atoms have 2D coordinates." + " JCP can only show full 2D specified structures." + " Shall we lay out the structure?"); int answer = JOptionPane.showConfirmDialog(null, error, "No 2D coordinates", JOptionPane.YES_NO_OPTION); if (answer == JOptionPane.NO_OPTION) { throw new CDKException(GT._("Cannot display without 2D coordinates")); } else { // CreateCoordinatesForFileDialog frame = // new CreateCoordinatesForFileDialog(chemModel); // frame.pack(); // frame.show(); WaitDialog.showDialog(); List<IAtomContainer> acs = ChemModelManipulator.getAllAtomContainers(chemModel); generate2dCoordinates(acs); WaitDialog.hideDialog(); return; }// w w w . j a va 2 s . c om } } /* * Add implicit hydrogens (in ControllerParameters, * autoUpdateImplicitHydrogens is true by default, so we need to do that * anyway) */ CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(chemModel.getBuilder()); for (IAtomContainer molecule : ChemModelManipulator.getAllAtomContainers(chemModel)) { if (molecule != null) { try { hAdder.addImplicitHydrogens(molecule); } catch (CDKException e) { // do nothing } } } }
From source file:org.openuat.apps.BedaApp.java
private void transferProtocol(boolean isInitiator, final RemoteConnection connection, OOBChannel channel, final byte[] oobMsg) { this.isInitiator = false; // reset, so we are ready for further pairing attempts. final String READY = "READY"; final String DONE = "DONE"; final InputStream in; final OutputStream out; try {/*from w ww . j a v a 2s.c o m*/ in = connection.getInputStream(); out = connection.getOutputStream(); } catch (IOException e) { logger.log(Level.SEVERE, "Failed to open stream from connection. Abort transfer protocol.", e); return; } if (isInitiator) { logger.finer("Running transfer as initiator"); try { String initString = UACAPProtocolConstants.TRANSFER_AUTH + ":" + channel.toString(); LineReaderWriter.println(out, initString); String lineIn = LineReaderWriter.readLine(in); if (!lineIn.equals(READY)) { logger.severe("Unexpected protocol string from remote device. Abort transfer protocol."); return; } channel.transmit(oobMsg); // wait for other device lineIn = LineReaderWriter.readLine(in); if (!lineIn.equals(DONE)) { logger.severe("Unexpected protocol string from remote device. Abort transfer protocol."); return; } statusLabel.setText(""); int ret = JOptionPane.showConfirmDialog(mainWindow, "Was the other device successful?", "Authentication", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret == JOptionPane.YES_OPTION) { informSuccess(); } else if (ret == JOptionPane.NO_OPTION) { alertError("Authentication failed!"); } } catch (IOException e) { logger.severe("Failed to read/write from io stream. Abort transfer protocol."); } } else { // responder logger.finer("Running transfer as responder"); try { String lineIn = LineReaderWriter.readLine(in); String protocolDesc = lineIn.substring(0, lineIn.indexOf(':')); String channelDesc = lineIn.substring(lineIn.indexOf(':') + 1); if (!protocolDesc.equals(UACAPProtocolConstants.TRANSFER_AUTH)) { logger.severe("Wrong protocol descriptor from remote device. Abort transfer protocol."); return; } // get appropriate channel OOBChannel captureChannel = buttonChannels.get(channelDesc); OOBMessageHandler messageHandler = new OOBMessageHandler() { @Override public void handleOOBMessage(int channelType, byte[] data) { try { LineReaderWriter.println(out, DONE); // check data if (logger.isLoggable(Level.INFO)) { logger.info("sent oobMsg: " + new String(Hex.encodeHex(oobMsg)) + " received oobMsg: " + new String(Hex.encodeHex(data))); } statusLabel.setText(""); if (Arrays.equals(data, oobMsg)) { JOptionPane.showMessageDialog(mainWindow, "Authentication successful! Please report to the other device", "Success", JOptionPane.INFORMATION_MESSAGE); showHomeScreen(); } else { alertError("Authentication failed! Please report to the other device"); } } catch (IOException e) { logger.severe("Failed to read/write to io stream. Abort transfer protocol."); } finally { connection.close(); } } }; captureChannel.setOOBMessageHandler(messageHandler); LineReaderWriter.println(out, READY); captureChannel.capture(); } catch (IOException e) { logger.log(Level.SEVERE, "Failed to read/write from io stream. Abort transfer protocol.", e); } } }
From source file:org.orbisgis.groovy.GroovyConsolePanel.java
/** * Open a dialog that let the user select a file and add or replace the * content of the sql editor.// ww w .java2 s .c o m */ public void onOpenFile() { final OpenFilePanel inFilePanel = new OpenFilePanel("groovyConsoleInFile", I18N.tr("Open script")); inFilePanel.addFilter("groovy", I18N.tr("Groovy Script (*.groovy)")); inFilePanel.loadState(); if (UIFactory.showDialog(inFilePanel)) { int answer = JOptionPane.NO_OPTION; if (scriptPanel.getDocument().getLength() > 0) { answer = JOptionPane.showConfirmDialog(this, I18N.tr("Do you want to clear all before loading the file ?"), I18N.tr("Open file"), JOptionPane.YES_NO_CANCEL_OPTION); } String text; try { text = FileUtils.readFileToString(inFilePanel.getSelectedFile()); } catch (IOException e1) { LOGGER.error(I18N.tr("Cannot write the script."), e1); return; } if (answer == JOptionPane.YES_OPTION) { scriptPanel.setText(text); } else if (answer == JOptionPane.NO_OPTION) { scriptPanel.append(text); } } }