public void select(String path) { Node nodeToSelect = getTemplateNode(path); if (nodeToSelect != null) { try { manager.setSelectedNodes (new Node[]{ nodeToSelect }); view.expandNode(nodeToSelect); } catch (PropertyVetoException ex) { Logger.getLogger(TemplatesPanel.class.getName()).log(Level.FINE, ex.getLocalizedMessage (), ex); } } SwingUtilities.invokeLater (new Runnable () { @Override public void run() { view.requestFocus (); } }); }
@Override public void run() { Node[] nodes = templatesRootNode.getChildren ().getNodes(true); Node nodeToSelect = null; if (pathToSelect != null) { nodeToSelect = getTemplateNode(pathToSelect); } if (nodes.length > 0) { Node firstNode; if (nodeToSelect != null) { firstNode = nodeToSelect; } else { firstNode = nodes[0]; } try { manager.setSelectedNodes (new Node[]{firstNode}); if (nodeToSelect != null) { view.expandNode(nodeToSelect); } } catch (PropertyVetoException ex) { Logger.getLogger(TemplatesPanel.class.getName()).log(Level.FINE, ex.getLocalizedMessage (), ex); } } SwingUtilities.invokeLater (new Runnable () { @Override public void run() { view.requestFocus (); } }); } });
LOGGER.error(ex.getLocalizedMessage()); invalidateUserInput();
@Override public void actionPerformed(ActionEvent evt) { try { dialog.setErrorText(null); dialog.setStatus(APPROVED); dialog.closeDialog(); } catch (PropertyVetoException e) { dialog.setErrorText(e.getLocalizedMessage()); } }
public void save() { if (entity != null) { try { fireVetoableChange(SAVE, null, entity); engine.update(entity); } catch (PropertyVetoException ex) { JOptionPane.showMessageDialog(workBench.getFrame(), ex.getLocalizedMessage(), I18n.get("REFUSED"), JOptionPane.ERROR_MESSAGE); } } else { saveAs(); } } public void saveAs()
/** * A setter that should be used by the property editor * to change the state of the environment. * Even the state property is bound, changes made from the editor itself * are allowed without restrictions. */ public void setState(Object newState) { if (getState().equals(newState)) { // no change, no fire vetoable and property change return; } try { getSupport().fireVetoableChange(PROP_STATE, getState(), newState); state = newState; // always notify state change getChange().firePropertyChange(PROP_STATE, null, newState); } catch (PropertyVetoException pve) { // and notify the user that the change cannot happen String msg = Exceptions.findLocalizedMessage(pve); if (msg == null) { msg = pve.getLocalizedMessage(); } if (msg != null) { DialogDisplayer.getDefault().notify( new NotifyDescriptor.Message(msg, NotifyDescriptor.WARNING_MESSAGE)); } else { // no message for the user, log the exception the standard way PropertyDialogManager.notify(pve); } } }
private void remove() { if (entity != null) { int confirm = JOptionPane.showConfirmDialog( workBench.getFrame(), entity.getKey().getName(), I18n.get("CONFIRM REMOVE?"), JOptionPane.OK_CANCEL_OPTION ); if (JOptionPane.YES_OPTION == confirm) { try { fireVetoableChange(SAVE, null, null); engine.delete(entity); entity = null; } catch (PropertyVetoException ex) { JOptionPane.showMessageDialog(workBench.getFrame(), ex.getLocalizedMessage(), I18n.get("REFUSED"), JOptionPane.ERROR_MESSAGE); } } } } private void clear()
public void open(boolean embed) { dialog = new StatementDialog( workBench.getFrame(), storedStatementsKind, engine, executeAction, autoActions ); dialog.setEmbed(embed); Entity ne = dialog.inputEntity(); if (ne != null) { try { entity = ne; fireVetoableChange(OPEN, null, entity); } catch (PropertyVetoException ex) { JOptionPane.showMessageDialog(workBench.getFrame(), ex.getLocalizedMessage(), I18n.get("REFUSED"), JOptionPane.ERROR_MESSAGE); } } }
public void saveAs() { if (confirmInstall()) { String name = JOptionPane.showInputDialog(workBench.getFrame(), I18n.get("ENTER NAME FOR STATEMENT"), ""); if (name != null) { try { Key key = engine.createKey(storedStatementsKind, name); Entity ne = new Entity(key); if (entity != null) { ne.setPropertiesFrom(entity); } entity = ne; fireVetoableChange(SAVE, null, entity); engine.update(entity); } catch (PropertyVetoException ex) { JOptionPane.showMessageDialog(workBench.getFrame(), ex.getLocalizedMessage(), I18n.get("REFUSED"), JOptionPane.ERROR_MESSAGE); } } } } private void remove()
public void open(final URL[] urls) { try { if (urls.length >= 1) { final URL url = urls[0]; final GCDocument gcDocument = new GCDocument(this, url.toString()); gcDocument.add(url); gcDocument.addInternalFrameListener(gcDocumentListener); desktopPane.add(gcDocument); gcDocument.setSelected(true); gcDocument.setSize(450, 300); gcDocument.setMaximum(true); //addAction.setSelectedFile(url); gcDocument.setVisible(true); } if (urls.length>1) { final URL[] addURLs = new URL[urls.length-1]; System.arraycopy(urls, 1, addURLs, 0, addURLs.length); add(addURLs); } recentURLsMenu.getRecentURLsModel().add(urls); repaint(); } catch (DataReaderException e) { e.printStackTrace(); } catch (PropertyVetoException e) { e.printStackTrace(); JOptionPane.showMessageDialog(GCViewerGui.this, e.toString() + " " + e.getLocalizedMessage(), localStrings.getString("fileopen_dialog_read_file_failed"), JOptionPane.ERROR_MESSAGE); } }