final public AbstractAction getCloseAction() { return new AbstractAction(this.actionButtonTextFactory.execute(DialogMessages.CLOSE)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(final ActionEvent e) { AbstractDialog.this.dialogResultModel.set(DialogResult.NONE); close(); } }; }
final public Action getNoAction() { return new AbstractAction(this.actionButtonTextFactory.execute(DialogMessages.NO)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(final ActionEvent e) { AbstractDialog.this.dialogResultModel.set(DialogResult.NO); close(); } }; }
@Override public IExecutable<T> getExecutable(final IState<T> state) { return this.factory.execute(state); }
final public Action getCancelAction() { if (this.cancelAction == null) { this.cancelAction = new AbstractAction(this.actionButtonTextFactory.execute(DialogMessages.CANCEL)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(final ActionEvent event) { try { if (cancel()) { AbstractDialog.this.dialogResultModel.set(DialogResult.CANCEL); close(); } } catch (final Exception exception) { logger.log(ILevel.ERROR, "", exception); //$NON-NLS-1$ } } }; } return this.cancelAction; }
final public Action getApplyAction() { if (this.applyAction == null) { this.applyAction = new AbstractAction(this.actionButtonTextFactory.execute(DialogMessages.APPLY)) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(final ActionEvent event) { try { apply(); } catch (final Exception exception) { logger.log(ILevel.ERROR, "", exception); //$NON-NLS-1$ } } }; this.applyAction.setEnabled(false); } return this.applyAction; }
public O accept(final K key, final I value) throws E { if (this.functions.containsKey(key)) { return this.functions.get(key).execute(value); } if (this.defaultFunction != null) { return this.defaultFunction.execute(value); } throw new IllegalStateException(); // return Optional // .<IFunction<I, O, E>, E> create(this.defaultFunction) // .ifNullThrow() // .convert(f -> f.execute(value)) // .get(); } }
default IAggregator<I, V, O, E> then(final IFunction<? super O, ? extends O, E> after) { Objects.requireNonNull(after); return (final I o, final V t) -> after.execute(aggregate(o, t)); } }
public static <I, O, E extends Exception> IOptional<O, E> bind( final IOptional<I, E> optional, final IFunction<I, O, E> function) { return optional.convert(i -> function.execute(i)); }
final protected Action getOkAction() { return getOkAction(this.actionButtonTextFactory.execute(DialogMessages.OK)); }
public static <R, E extends Exception> R process( final InputStream inputStream, final IFunction<StartElement, R, E> function) throws E, IOException { try { inputStream.mark(Integer.MAX_VALUE); final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false); final XMLEventReader eventReader = inputFactory.createXMLEventReader(inputStream); while (eventReader.hasNext()) { final XMLEvent event = eventReader.nextEvent(); if (event.isStartElement()) { return function.execute(event.asStartElement()); } } return null; } catch (final XMLStreamException cause) { throw new IOException(cause); } finally { inputStream.reset(); } }
private void createTabbedView(final IFunction<Void, Iterable<IDialogTab>, RuntimeException> tabsFactory) { this.tabbedPanel.setMinimumSize(new Dimension(100, 100)); final JPanel contentPanel = (JPanel) getContentPane(); contentPanel.setLayout(new BorderLayout()); contentPanel.add(BorderLayout.CENTER, this.tabbedPanel); contentPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); for (final IDialogTab tab : tabsFactory.execute(null)) { addTab(tab); } this.tabbedPanel.addChangeListener(new ChangeListener() { @Override public void stateChanged(final ChangeEvent e) { final int selectedIndex = TabbedDialog.this.tabbedPanel.getSelectedIndex(); if (selectedIndex < 0) { setIcon(GuiIcons.EMPTY_ICON.getLargeIcon()); setMessage(IMessageConstants.EMPTY_MESSAGE); return; } final IDialogTab currentTab = TabbedDialog.this.tabs.get(selectedIndex); currentTab.updateView(); currentTab.checkFieldValues(); setIcon(currentTab.getIcon()); setMessage(currentTab.getMessage()); checkButton(currentTab); } }); }
@SuppressWarnings("resource") private Templates create(final String inputXsltScript, final SAXTransformerFactory transformerFactory) throws TransformerConfigurationException, IOException { if (inputXsltScript == null) { return null; } try (final InputStream stream = this.connector.execute(inputXsltScript)) { if (logger.isLoggable(ILevel.DEBUG)) { logger.log(ILevel.DEBUG, inputXsltScript); } return transformerFactory.newTemplates(new StreamSource(new NoneClosingInputStream(stream))); } } }
@Override public IObjectTableBuilder<T> addSortableStringColumn( final String title, final IFunction<T, String, RuntimeException> provider, final int size) { this.builder.addColumnConfiguration(new ObjectListColumnConfiguration<>(title, object -> { if (object == null) { return null; } return provider.execute(object); }, new ObjectTableCellRenderer(), size, String.class, true, null)); return this; }
@Override public IObjectTableBuilder<T> addStringColumn( final String title, final IFunction<T, String, RuntimeException> provider, final int size) { this.builder.addColumnConfiguration(new ObjectListColumnConfiguration<>(title, object -> { if (object == null) { return null; } return provider.execute(object); }, new ObjectTableCellRenderer(), size, String.class, false, null)); return this; }
@Override public IObjectTableBuilder<T> addSortableBooleanColumn( final String title, final IFunction<T, Boolean, RuntimeException> provider, final int size) { this.builder.addColumnConfiguration(new ObjectListColumnConfiguration<>(title, object -> { if (object == null) { return null; } return provider.execute(object); }, new BooleanRenderer(), size, Boolean.class, true, null)); return this; }
@SuppressWarnings("resource") private Templates create(final String inputXsltScript, final SAXTransformerFactory transformerFactory) throws TransformerConfigurationException, IOException { if (inputXsltScript == null) { return null; } try (final InputStream stream = this.connector.execute(inputXsltScript)) { if (logger.isLoggable(ILevel.DEBUG)) { logger.log(ILevel.DEBUG, inputXsltScript); } return transformerFactory.newTemplates(new StreamSource(new NoneClosingInputStream(stream))); } } }
@Override public IObjectTableBuilder<T> addEditableStringColumn( final String title, final IFunction<T, String, RuntimeException> provider, final IAggregator<T, String, T, RuntimeException> adaptor, final int size) { final DefaultCellEditor cellEditor = new DefaultCellEditor(new JTextField()); cellEditor.setClickCountToStart(2); this.builder.addColumnConfiguration(new ObjectListColumnConfiguration<>(title, (IColumnValueProvider<T>) object -> { if (object == null) { return null; } return provider.execute(object); }, // new ObjectTableCellRenderer(), (object, value) -> adaptor.aggregate(object, (String) value), cellEditor, size, false, null)); return this; }
@Override public IObjectTableBuilder<T> addIntegerColumn( final String title, final IFunction<T, Integer, RuntimeException> provider, final int size) { this.builder.addColumnConfiguration(new ObjectListColumnConfiguration<>(title, object -> { if (object == null) { return null; } return provider.execute(object); }, new NumberTableCellRenderer("0"), size, Integer.class, false, new NumberComparator())); //$NON-NLS-1$ return this; }
@Override public IObjectTableBuilder<T> addSortableDoubleColumn( final String title, final IFunction<T, Double, RuntimeException> provider, final int size) { this.builder.addColumnConfiguration(new ObjectListColumnConfiguration<>(title, object -> { if (object == null) { return null; } return provider.execute(object); }, new NumberTableCellRenderer("0.0000"), size, Double.class, true, new NumberComparator())); //$NON-NLS-1$ return this; }