List of usage examples for org.eclipse.jface.dialogs MessageDialog openError
public static void openError(Shell parent, String title, String message)
From source file:com.android.ddmuilib.handler.BaseFileHandler.java
License:Apache License
/** * Display an error message./*from w w w.j av a2s . c o m*/ * This must be called from the UI Thread. * @param format the string to display * @param args the string arguments */ protected void displayErrorFromUiThread(final String format, final Object... args) { MessageDialog.openError(mParentShell, getDialogTitle(), String.format(format, args)); }
From source file:com.android.ddmuilib.heap.NativeHeapPanel.java
License:Apache License
/** {@inheritDoc} */ @Override//from ww w . j a va2 s . com public void clientChanged(final Client client, int changeMask) { if (client != getCurrentClient()) { return; } if ((changeMask & Client.CHANGE_NATIVE_HEAP_DATA) != Client.CHANGE_NATIVE_HEAP_DATA) { return; } List<NativeAllocationInfo> allocations = client.getClientData().getNativeAllocationList(); if (allocations.size() == 0) { return; } // We need to clone this list since getClientData().getNativeAllocationList() clobbers // the list on future updates final List<NativeAllocationInfo> nativeAllocations = shallowCloneList(allocations); addNativeHeapSnapshot(new NativeHeapSnapshot(nativeAllocations)); updateDisplay(); // Attempt to resolve symbols in a separate thread. // The UI should be refreshed once the symbols have been resolved. if (USE_OLD_RESOLVER) { Thread t = new Thread( new SymbolResolverTask(nativeAllocations, client.getClientData().getMappedNativeLibraries())); t.setName("Address to Symbol Resolver"); t.start(); } else { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { resolveSymbols(); mDetailsTreeViewer.refresh(); mStackTraceTreeViewer.refresh(); } public void resolveSymbols() { Shell shell = Display.getDefault().getActiveShell(); ProgressMonitorDialog d = new ProgressMonitorDialog(shell); NativeSymbolResolverTask resolver = new NativeSymbolResolverTask(nativeAllocations, client.getClientData().getMappedNativeLibraries(), mSymbolSearchPathText.getText(), client.getClientData().getAbi()); try { d.run(true, true, resolver); } catch (InvocationTargetException e) { MessageDialog.openError(shell, "Error Resolving Symbols", e.getCause().getMessage()); return; } catch (InterruptedException e) { return; } MessageDialog.openInformation(shell, "Symbol Resolution Status", getResolutionStatusMessage(resolver)); } }); } }
From source file:com.android.ddmuilib.heap.NativeHeapPanel.java
License:Apache License
private void loadHeapDataFromFile() { // pop up a file dialog and get the file to load final String path = getHeapDumpToImport(); if (path == null) { return;/*from www. jav a2 s. co m*/ } Reader reader = null; try { reader = new FileReader(path); } catch (FileNotFoundException e) { // cannot occur since user input was via a FileDialog } Shell shell = Display.getDefault().getActiveShell(); ProgressMonitorDialog d = new ProgressMonitorDialog(shell); NativeHeapDataImporter importer = new NativeHeapDataImporter(reader); try { d.run(true, true, importer); } catch (InvocationTargetException e) { // exception while parsing, display error to user and then return MessageDialog.openError(shell, "Error Importing Heap Data", e.getCause().getMessage()); return; } catch (InterruptedException e) { // operation cancelled by user, simply return return; } NativeHeapSnapshot snapshot = importer.getImportedSnapshot(); addToImportedSnapshots(snapshot); // save imported snapshot for future use addNativeHeapSnapshot(snapshot); // add to currently displayed snapshots as well updateDisplay(); }
From source file:com.android.ddmuilib.heap.NativeHeapPanel.java
License:Apache License
/** Export currently displayed snapshot to a file */ private void exportSnapshot() { int idx = mSnapshotIndexCombo.getSelectionIndex(); String snapshotName = mSnapshotIndexCombo.getItem(idx); FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SAVE); fileDialog.setText("Save " + snapshotName); fileDialog.setFileName("allocations.txt"); final String fileName = fileDialog.open(); if (fileName == null) { return;/*w w w . j a va2 s.c o m*/ } final NativeHeapSnapshot snapshot = mNativeHeapSnapshots.get(idx); Thread t = new Thread(new Runnable() { @Override public void run() { PrintWriter out; try { out = new PrintWriter(new BufferedWriter(new FileWriter(fileName))); } catch (IOException e) { displayErrorMessage(e.getMessage()); return; } for (NativeAllocationInfo alloc : snapshot.getAllocations()) { out.println(alloc.toString()); } out.close(); } private void displayErrorMessage(final String message) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { MessageDialog.openError(Display.getDefault().getActiveShell(), "Failed to export heap data", message); } }); } }); t.setName("Saving Heap Data to File..."); t.start(); }
From source file:com.android.ddmuilib.logcat.LogCatPanel.java
License:Apache License
/** * Save logcat messages selected in the table to a file. */// w w w . ja va 2 s . com private void saveLogToFile() { /* show dialog box and get target file name */ final String fName = getLogFileTargetLocation(); if (fName == null) { return; } /* obtain list of selected messages */ final List<LogCatMessage> selectedMessages = getSelectedLogCatMessages(); /* save messages to file in a different (non UI) thread */ Thread t = new Thread(new Runnable() { @Override public void run() { BufferedWriter w = null; try { w = new BufferedWriter(new FileWriter(fName)); for (LogCatMessage m : selectedMessages) { w.append(m.toString()); w.newLine(); } } catch (final IOException e) { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { MessageDialog.openError(Display.getCurrent().getActiveShell(), "Unable to export selection to file.", "Unexpected error while saving selected messages to file: " + e.getMessage()); } }); } finally { if (w != null) { try { w.close(); } catch (IOException e) { // ignore } } } } }); t.setName("Saving selected items to logfile.."); t.start(); }
From source file:com.android.ddmuilib.screenrecord.ScreenRecorderAction.java
License:Apache License
private void showError(@NonNull final String message, @Nullable final Throwable e) { mParentShell.getDisplay().asyncExec(new Runnable() { @Override/* w w w .jav a 2s .c o m*/ public void run() { String msg = message; if (e != null) { msg += e.getLocalizedMessage() != null ? ": " + e.getLocalizedMessage() : ""; } MessageDialog.openError(mParentShell, TITLE, msg); } }); }
From source file:com.android.ddmuilib.SysinfoPanel.java
License:Apache License
/** * Fetches a new bugreport from the device and updates the display. * Fetching is asynchronous. See also addOutput, flush, and isCancelled. *///from www. j a v a 2 s.c o m private void loadFromDevice() { clearDataSet(); if (mMode == MODE_GFXINFO) { boolean en = isGfxProfilingEnabled(); if (!en) { if (enableGfxProfiling()) { MessageDialog.openInformation(Display.getCurrent().getActiveShell(), "DDMS", "Graphics profiling was enabled on the device.\n" + "It may be necessary to relaunch your application to see profile information."); } else { MessageDialog.openError(Display.getCurrent().getActiveShell(), "DDMS", "Unexpected error enabling graphics profiling on device.\n"); return; } } } final String command = getDumpsysCommand(mMode); if (command == null) { return; } Thread t = new Thread(new Runnable() { @Override public void run() { try { String header = null; if (mMode == MODE_MEMINFO) { // Hack to add bugreport-style section header for meminfo header = "------ MEMORY INFO ------\n"; } IShellOutputReceiver receiver = initShellOutputBuffer(header); getCurrentDevice().executeShellCommand(command, receiver); } catch (IOException e) { Log.e("DDMS", e); } catch (TimeoutException e) { Log.e("DDMS", e); } catch (AdbCommandRejectedException e) { Log.e("DDMS", e); } catch (ShellCommandUnresponsiveException e) { Log.e("DDMS", e); } } }, "Sysinfo Output Collector"); t.start(); }
From source file:com.android.glesv2debugger.MessageProcessor.java
License:Apache License
static void showError(final String message) { // need to call SWT from UI thread MessageDialog.openError(null, "MessageProcessor", message); }
From source file:com.android.glesv2debugger.SampleView.java
License:Apache License
public void showError(final Exception e) { viewer.getControl().getDisplay().syncExec(new Runnable() { @Override// ww w . j a v a 2s .c o m public void run() { MessageDialog.openError(viewer.getControl().getShell(), "GL ES 2.0 Debugger Client", e.getMessage()); } }); }
From source file:com.android.ide.eclipse.adt.AdtPlugin.java
License:Open Source License
/** * Displays an error dialog box. This dialog box is ran asynchronously in the ui thread, * therefore this method can be called from any thread. * @param title The title of the dialog box * @param message The error message//from www .j a v a 2 s.c o m */ public final static void displayError(final String title, final String message) { // get the current Display final Display display = getDisplay(); // dialog box only run in ui thread.. display.asyncExec(new Runnable() { @Override public void run() { Shell shell = display.getActiveShell(); MessageDialog.openError(shell, title, message); } }); }