@Override protected void process(final List<Task> chunks) { for (final Task task : chunks) { try { task.execute(); } catch (final Exception e) { WidgetUtils.showErrorMessage("Error processing transfer chunk: " + task, e); } } }
public AnalysisResult getResult() { if (_result == null && _worker != null) { try { _result = _worker.get(); } catch (final Exception e) { WidgetUtils.showErrorMessage("Unable to fetch result", e); } } return _result; }
protected void done() { try { get(); } catch (final ExecutionException e) { logger.error("ExecutionException occurred while getting the result of the HTML rendering", e); final Throwable cause = e.getCause(); WidgetUtils.showErrorMessage("Error writing result to HTML page", cause); } catch (final InterruptedException e) { logger.warn("Unexpected interrupt in done() method!"); } }
public static Integer showMaxRowsDialog(final int defaultValue) { final String maxRowsString = JOptionPane.showInputDialog("How many records do you want to process?", defaultValue); if (Strings.isNullOrEmpty(maxRowsString)) { return null; } final Number maxRows = ConvertToNumberTransformer.transformValue(maxRowsString); if (maxRows == null || maxRows.intValue() < 1) { WidgetUtils.showErrorMessage("Not a valid number", "Please enter a valid number of records."); return null; } return maxRows.intValue(); }
public static void showErrorMessage(final String shortMessage, final Throwable exception) { final StringBuilder sb = new StringBuilder(); Throwable ex = exception; while (ex != null) { if (sb.length() != 0) { sb.append("\n\n"); } String message = ex.getMessage(); if (StringUtils.isNullOrEmpty(message)) { message = "(" + ex.getClass().getName() + ")"; } sb.append(message); ex = ex.getCause(); } showErrorMessage(shortMessage, sb.toString(), exception); }
@Override public final ActionListener createActionListener(final AnalysisJobBuilder analysisJobBuilder, final Action<AnalysisJobBuilder> executeAction, final AnalysisJobBuilderWindow analysisJobBuilderWindow) { return event -> { try { run(analysisJobBuilder, executeAction, analysisJobBuilderWindow); } catch (final Exception e) { WidgetUtils.showErrorMessage("Unexpected error", "An error occurred while executing job in mode '" + getText() + "'", e); } }; }
private JComboBox<String> createDatastoreCombobox() { final String[] comboBoxModel = CollectionUtils.array(new String[1], _datastoreCatalog.getDatastoreNames()); final JComboBox<String> comboBox = new JComboBox<>(comboBoxModel); comboBox.setEditable(false); final JDialog parent = this; comboBox.addActionListener(e -> { try { final ComboBoxUpdater comboBoxUpdater = new ComboBoxUpdater(parent); comboBoxUpdater.execute(); } catch (final Exception exception) { final String exceptionMessage = "An unexpected error occurred while updating combo boxes:\n" + exception.getMessage(); logger.error(exceptionMessage); WidgetUtils.showErrorMessage("Unexpected error", exceptionMessage); } }); return comboBox; }
@Override public void uncaughtException(final Thread t, final Throwable e) { if (isIgnoreIssue(e)) { logger.debug("Ignoring uncaught exception", e); return; } if (e instanceof RestrictedFunctionalityException) { logger.debug("Handling restricted functionality exception", e); final StringBuilder sb = new StringBuilder(e.getMessage()); final RestrictedFunctionalityCallToAction[] callToActions = ((RestrictedFunctionalityException) e).getCallToActions(); for (final RestrictedFunctionalityCallToAction callToAction : callToActions) { sb.append('\n'); sb.append(" - " + callToAction.getName() + " - " + callToAction.getHref()); } final String detailedMessage = sb.toString(); WidgetUtils .invokeSwingAction(() -> WidgetUtils.showErrorMessage("Restricted functionality", detailedMessage)); return; } logger.error("Thread " + t.getName() + " threw uncaught exception", e); WidgetUtils.invokeSwingAction(() -> WidgetUtils.showErrorMessage("Unexpected error!", e)); }
@Override protected void done() { super.done(); if (!_cancelled) { try { final FileObject[] files = get(); if (_listener != null) { _listener.onFilesDownloaded(files); } } catch (final Throwable e) { if (_listener == null) { // when there is no listener, the error will be catched and // handled by the blocking getFiles() call. return; } WidgetUtils.showErrorMessage("Error transfering file(s)!", e); } } }
protected void done() { try { final TableModel tableModel = get(); _table.setModel(tableModel); final int columnCount = _table.getColumnCount(); if (columnCount > 10) { _table.setHorizontalScrollEnabled(true); } updatePagingButtons(); _loadingIcon.setVisible(false); _table.setVisible(true); } catch (Throwable e) { e = ErrorUtils.unwrapForPresentation(e); logger.error("Unexpected error occurred while building DataSetWindow contents", e); DataSetWindow.this.dispose(); final String exceptionMessage = e.getMessage(); if (Strings.isNullOrEmpty(exceptionMessage)) { WidgetUtils.showErrorMessage("Unexpected error", "An unexpected error occurred while building data set.\n\nSee logs for details."); } else { WidgetUtils.showErrorMessage("Unexpected error", "An unexpected error occurred while building data set:\n" + exceptionMessage + "\n\nSee logs for details."); } } }
private ActionListener createDownloadActionListener(final DatabaseDriverDescriptor dd) { final FileDownloadListener downloadListener = files -> { final String driverClassName = dd.getDriverClassName(); logger.info("Registering and loading driver '{}' in files '{}'", driverClassName, files); final UserDatabaseDriver userDatabaseDriver = new UserDatabaseDriver(files, driverClassName); _userPreferences.getDatabaseDrivers().add(userDatabaseDriver); try { userDatabaseDriver.loadDriver(); } catch (final IllegalStateException e) { WidgetUtils.showErrorMessage("Error while loading driver", "Error message: " + e.getMessage(), e); } updateDriverList(); }; final WebServiceHttpClient httpClient = new SimpleWebServiceHttpClient(_httpClient); return new DownloadFilesActionListener(dd.getDownloadUrls(), downloadListener, _windowContext, httpClient, _userPreferences); } }
private DCPanel createButtonPanel() { final JButton saveButton = WidgetFactory.createPrimaryButton("Save table definitions", IconUtils.ACTION_SAVE_BRIGHT); saveButton.addActionListener(event -> { final SimpleTableDef[] tableDefs = _tableDefsPanel.getTableDefs(); try { _saveAction.run(tableDefs); } catch (final Exception e) { WidgetUtils.showErrorMessage("Could not save table definitions", e); } TableDefinitionDialog.this.dispose(); }); final JButton cancelButton = WidgetFactory.createDefaultButton("Cancel", IconUtils.ACTION_CANCEL); cancelButton.addActionListener(e -> TableDefinitionDialog.this.dispose()); final DCPanel buttonPanel = DCPanel.flow(Alignment.CENTER, saveButton, cancelButton); buttonPanel.setBorder(WidgetUtils.BORDER_EMPTY); return buttonPanel; } }
@Override public void actionPerformed(final ActionEvent event) { final AnalysisJobBuilder ajb = new AnalysisJobBuilder(_configuration); ajb.setDatastore(_datastore); ajb.addSourceColumns(getColumns()); final QuickAnalysisStrategy quickAnalysisStrategy = QuickAnalysisStrategy.loadFromUserPreferences(_userPreferences); quickAnalysisStrategy.configureAnalysisJobBuilder(ajb); try { if (!ajb.isConfigured(true)) { throw new IllegalStateException("Unknown job configuration issue!"); } final Injector injector = Guice.createInjector(new DCModuleImpl(_dcModule, ajb)); final RunAnalysisActionListener actionListener = injector.getInstance(RunAnalysisActionListener.class); actionListener.actionPerformed(event); } catch (final Exception e) { WidgetUtils.showErrorMessage("Error", "Could not perform quick analysis on table " + _table.getName(), e); } }
final InputColumn<?>[] currentValue = _callback.getColumns(); if (currentValue == null || currentValue.length == 0) { WidgetUtils.showErrorMessage("No columns selected", "Cannot reorder columns, when none is selected."); return; WidgetUtils.showErrorMessage("Nothing to reorder", "You need to have at least two selected colummns to be able to reorder them."); return;
@Override public void actionPerformed(final ActionEvent event) { final String queryString = _queryTextArea.getText(); logger.debug("Query being parsed: {}", queryString); try (DatastoreConnection con = _datastore.openConnection()) { final DataContext dataContext = con.getDataContext(); final Query q = dataContext.parseQuery(queryString); logger.info("Parsed query: {}", q); final String limitString = _limitTextField.getText(); if (!StringUtils.isNullOrEmpty(limitString)) { final int limit = Integer.parseInt(limitString); q.setMaxRows(limit); } final DataSet dataSet = dataContext.executeQuery(q); _centerPanel.setVisible(true); _table.setModel(new DataSetTableModel(dataSet)); } catch (final MetaModelException e) { WidgetUtils.showErrorMessage("Failed to execute query", e.getMessage(), e); } } });
dispose(); } catch (final IllegalStateException e) { WidgetUtils.showErrorMessage("Error while loading driver", "Error message: " + e.getMessage(), e);
dropTableButton.addActionListener(e -> { if (!confirmTextField.getText().trim().equalsIgnoreCase(_table.getName().trim())) { WidgetUtils.showErrorMessage("Enter the table's name to confirm", "The names do not match. Please enter '" + _table.getName() + "' if you wish to drop the table.");
final String tableName = tableNameTextField.getText().trim(); if (tableName.isEmpty()) { WidgetUtils.showErrorMessage("Invalid table name", "Please enter a valid table name."); return; WidgetUtils.showErrorMessage("No columns defined", "Please add at least one column to the table."); return;
public static void showErrorMessage(final String shortMessage, final String detailedMessage, final Throwable exception) { final Throwable presentedException = ErrorUtils.unwrapForPresentation(exception); if (exception == null) { showErrorMessage(shortMessage, detailedMessage); return; } final String finalDetailedMessage = detailedMessage == null ? "" : detailedMessage; final String finalShortMessage = shortMessage == null ? "" : shortMessage; final ErrorInfo info = new ErrorInfo(finalShortMessage, finalDetailedMessage, null, "error", presentedException, ErrorLevel.SEVERE, null); final JXErrorPane errorPane = new JXErrorPane(); errorPane.setErrorInfo(info); final JDialog dialog = JXErrorPane.createDialog(null, errorPane); centerOnScreen(dialog); JXErrorPane.setDefaultLocale(Locale.ENGLISH); dialog.setLocale(Locale.ENGLISH); dialog.setModal(true); dialog.setTitle(finalShortMessage); dialog.setVisible(true); dialog.toFront(); }
_serverInformationCatalog.addServerInformation(newServer); } catch (final Exception exception) { WidgetUtils.showErrorMessage("Error", exception); invalidateForm(exception); return;