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.ide.eclipse.gldebugger.GLFramesView.java
License:Apache License
public void showError(final Exception e) { mViewer.getControl().getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openError(mViewer.getControl().getShell(), "GL ES 2.0 Debugger Client", e.getMessage());/* w w w.jav a 2 s .c o m*/ } }); }
From source file:com.android.ide.eclipse.gltrace.CollectTraceAction.java
License:Apache License
private void connectToDevice() { Shell shell = Display.getDefault().getActiveShell(); GLTraceOptionsDialog dlg = new GLTraceOptionsDialog(shell); if (dlg.open() != Window.OK) { return;/*from ww w . j a v a 2 s .c o m*/ } TraceOptions traceOptions = dlg.getTraceOptions(); IDevice device = getDevice(traceOptions.device); String apiLevelString = device.getProperty(IDevice.PROP_BUILD_API_LEVEL); int apiLevel; try { apiLevel = Integer.parseInt(apiLevelString); } catch (NumberFormatException e) { apiLevel = MIN_API_LEVEL; } if (apiLevel < MIN_API_LEVEL) { MessageDialog.openError(shell, "GL Trace", String.format( "OpenGL Tracing is only supported on devices at API Level %1$d." + "The selected device '%2$s' provides API level %3$s.", MIN_API_LEVEL, traceOptions.device, apiLevelString)); return; } try { setupForwarding(device, LOCAL_FORWARDED_PORT); } catch (Exception e) { MessageDialog.openError(shell, "Setup GL Trace", "Error while setting up port forwarding: " + e.getMessage()); return; } try { if (!SYSTEM_APP.equals(traceOptions.appToTrace)) { startActivity(device, traceOptions.appToTrace, traceOptions.activityToTrace, traceOptions.isActivityNameFullyQualified); } } catch (Exception e) { MessageDialog.openError(shell, "Setup GL Trace", "Error while launching application: " + e.getMessage()); return; } // if everything went well, the app should now be waiting for the gl debugger // to connect startTracing(shell, traceOptions, LOCAL_FORWARDED_PORT); // once tracing is complete, remove port forwarding disablePortForwarding(device, LOCAL_FORWARDED_PORT); // and finally open the editor to view the file openInEditor(shell, traceOptions.traceDestination); }
From source file:com.android.ide.eclipse.gltrace.CollectTraceAction.java
License:Apache License
@SuppressWarnings("resource") // Closeables.closeQuietly public static void startTracing(Shell shell, TraceOptions traceOptions, int port) { Socket socket = new Socket(); DataInputStream traceDataStream = null; DataOutputStream traceCommandsStream = null; try {/*from w w w . ja va 2s . c o m*/ socket.connect(new java.net.InetSocketAddress("127.0.0.1", port)); //$NON-NLS-1$ socket.setTcpNoDelay(true); traceDataStream = new DataInputStream(socket.getInputStream()); traceCommandsStream = new DataOutputStream(socket.getOutputStream()); } catch (IOException e) { MessageDialog.openError(shell, "OpenGL Trace", "Unable to connect to remote GL Trace Server: " + e.getMessage()); return; } // create channel to send trace commands to device TraceCommandWriter traceCommandWriter = new TraceCommandWriter(traceCommandsStream); try { traceCommandWriter.setTraceOptions(traceOptions.collectFbOnEglSwap, traceOptions.collectFbOnGlDraw, traceOptions.collectTextureData); } catch (IOException e) { MessageDialog.openError(shell, "OpenGL Trace", "Unexpected error while setting trace options: " + e.getMessage()); closeSocket(socket); return; } FileOutputStream fos = null; try { fos = new FileOutputStream(traceOptions.traceDestination, false); } catch (FileNotFoundException e) { // input path is valid, so this cannot occur } // create trace writer that writes to a trace file TraceFileWriter traceFileWriter = new TraceFileWriter(fos, traceDataStream); traceFileWriter.start(); GLTraceCollectorDialog dlg = new GLTraceCollectorDialog(shell, traceFileWriter, traceCommandWriter, traceOptions); dlg.open(); traceFileWriter.stopTracing(); traceCommandWriter.close(); closeSocket(socket); }
From source file:com.android.ide.eclipse.gltrace.editors.GLFunctionTraceViewer.java
License:Apache License
public void setInput(Shell shell, String tracePath) { ProgressMonitorDialog dlg = new ProgressMonitorDialog(shell); TraceFileParserTask parser = new TraceFileParserTask(mFilePath); try {/*from ww w . jav a 2s.c om*/ dlg.run(true, true, parser); } catch (InvocationTargetException e) { // exception while parsing, display error to user MessageDialog.openError(shell, "Error parsing OpenGL Trace File", e.getCause().getMessage()); return; } catch (InterruptedException e) { // operation canceled by user, just return return; } mTrace = parser.getTrace(); mShowContextSwitcher = (mTrace == null) ? false : mTrace.getContexts().size() > 1; if (mStateViewPage != null) { mStateViewPage.setInput(mTrace); } if (mFrameSummaryViewPage != null) { mFrameSummaryViewPage.setInput(mTrace); } if (mDetailsPage != null) { mDetailsPage.setInput(mTrace); } if (mDurationMinimap != null) { mDurationMinimap.setInput(mTrace); } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { refreshUI(); } }); }
From source file:com.android.ide.eclipse.gltrace.GLTraceCollectorDialog.java
License:Apache License
@Override protected Control createDialogArea(Composite parent) { parent.setLayout(new GridLayout()); setTitle(TITLE);/* w ww .ja v a 2 s . c om*/ setMessage(DEFAULT_MESSAGE); Group controlGroup = new Group(parent, SWT.BORDER); controlGroup.setLayout(new GridLayout(2, false)); controlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); controlGroup.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE)); controlGroup.setText("Trace Options"); createLabel(controlGroup, "Collect Framebuffer contents on eglSwapBuffers()"); final Button eglSwapCheckBox = createButton(controlGroup, mTraceOptions.collectFbOnEglSwap); createLabel(controlGroup, "Collect Framebuffer contents on glDraw*()"); final Button glDrawCheckBox = createButton(controlGroup, mTraceOptions.collectFbOnGlDraw); createLabel(controlGroup, "Collect texture data for glTexImage*()"); final Button glTexImageCheckBox = createButton(controlGroup, mTraceOptions.collectTextureData); SelectionListener l = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { boolean eglSwap = eglSwapCheckBox.getSelection(); boolean glDraw = glDrawCheckBox.getSelection(); boolean glTexImage = glTexImageCheckBox.getSelection(); try { mTraceCommandWriter.setTraceOptions(eglSwap, glDraw, glTexImage); } catch (IOException e) { eglSwapCheckBox.setEnabled(false); glDrawCheckBox.setEnabled(false); glTexImageCheckBox.setEnabled(false); MessageDialog.openError(Display.getDefault().getActiveShell(), "OpenGL ES Trace", "Error while setting trace options: " + e.getMessage()); } // update the text on the button if (!(event.getSource() instanceof Button)) { return; } Button sourceButton = (Button) event.getSource(); sourceButton.setText(getToggleActionText(sourceButton.getSelection())); sourceButton.pack(); } }; eglSwapCheckBox.addSelectionListener(l); glDrawCheckBox.addSelectionListener(l); glTexImageCheckBox.addSelectionListener(l); Group statusGroup = new Group(parent, SWT.NONE); statusGroup.setLayout(new GridLayout(2, false)); statusGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); statusGroup.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE)); statusGroup.setText("Trace Status"); createLabel(statusGroup, "Frames Collected:"); mFramesCollectedLabel = createLabel(statusGroup, ""); createLabel(statusGroup, "Trace File Size:"); mTraceFileSizeLabel = createLabel(statusGroup, ""); ProgressBar pb = new ProgressBar(statusGroup, SWT.INDETERMINATE); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; pb.setLayoutData(gd); mRefreshTask = new StatusRefreshTask(); new Thread(mRefreshTask, "Trace Status Refresh Thread").start(); return super.createDialogArea(parent); }
From source file:com.android.ide.eclipse.gltrace.OpenGLTraceAction.java
License:Apache License
private void openEditorFor(String fname) { IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(fname)); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try {//from w w w.j ava2s .co m IDE.openEditorOnFileStore(page, fileStore); } catch (PartInitException e) { MessageDialog.openError(Display.getDefault().getActiveShell(), "Error opening GL Trace File", "Unexpected error while opening GL Trace file: " + e.getMessage()); } }
From source file:com.android.ide.eclipse.hierarchyviewer.HierarchyViewerPlugin.java
License:Apache License
@Override public void start(BundleContext context) throws Exception { super.start(context); sPlugin = this; // set the consoles. final MessageConsole messageConsole = new MessageConsole("Hierarchy Viewer", null); //$NON-NLS-1$ ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { messageConsole }); final MessageConsoleStream consoleStream = messageConsole.newMessageStream(); final MessageConsoleStream errorConsoleStream = messageConsole.newMessageStream(); mRedColor = new Color(Display.getDefault(), 0xFF, 0x00, 0x00); // because this can be run, in some cases, by a non UI thread, and // because/*from w w w . jav a 2s .c o m*/ // changing the console properties update the UI, we need to make this // change // in the UI thread. Display.getDefault().asyncExec(new Runnable() { @Override public void run() { errorConsoleStream.setColor(mRedColor); } }); // set up the ddms log to use the ddms console. Log.setLogOutput(new ILogOutput() { @Override public void printLog(LogLevel logLevel, String tag, String message) { if (logLevel.getPriority() >= LogLevel.ERROR.getPriority()) { printToStream(errorConsoleStream, tag, message); ConsolePlugin.getDefault().getConsoleManager().showConsoleView(messageConsole); } else { printToStream(consoleStream, tag, message); } } @Override public void printAndPromptLog(final LogLevel logLevel, final String tag, final String message) { printLog(logLevel, tag, message); // dialog box only run in UI thread.. Display.getDefault().asyncExec(new Runnable() { @Override public void run() { Shell shell = Display.getDefault().getActiveShell(); if (logLevel == LogLevel.ERROR) { MessageDialog.openError(shell, tag, message); } else { MessageDialog.openWarning(shell, tag, message); } } }); } }); final HierarchyViewerDirector director = HierarchyViewerPluginDirector.createDirector(); director.startListenForDevices(); // make the director receive change in ADB. AndroidDebugBridge.addDebugBridgeChangeListener(new IDebugBridgeChangeListener() { @Override public void bridgeChanged(AndroidDebugBridge bridge) { director.acquireBridge(bridge); } }); // get the current ADB if any director.acquireBridge(AndroidDebugBridge.getBridge()); // populate the UI with current devices (if any) in a thread new Thread() { @Override public void run() { director.populateDeviceSelectionModel(); } }.start(); }
From source file:com.android.ide.eclipse.traceview.editors.TraceviewEditor.java
License:Apache License
private IFileStore copy(Shell shell, URI source, URI dest) { IFileStore destFileStore = null;/* w w w . j a v a 2 s. c o m*/ IFileStore sourceFileStore = null; try { destFileStore = EFS.getStore(dest); sourceFileStore = EFS.getStore(source); sourceFileStore.copy(destFileStore, EFS.OVERWRITE, null); } catch (CoreException ex) { String title = "Problems During Save As..."; String msg = String.format("Save could not be completed. %s", ex.getMessage()); MessageDialog.openError(shell, title, msg); return null; } return destFileStore; }
From source file:com.android.sdkuilib.internal.repository.LocalPackagesPage.java
License:Apache License
private void onDeleteSelected() { ISelection sel = mTableViewerPackages.getSelection(); if (sel instanceof IStructuredSelection) { Object elem = ((IStructuredSelection) sel).getFirstElement(); if (elem instanceof Package) { String title = "Delete SDK Package"; String error = null;//from www. j a va 2 s . c om Package p = (Package) elem; Archive[] archives = p.getArchives(); if (archives.length == 1 && archives[0] != null && archives[0].isLocal()) { Archive archive = archives[0]; String osPath = archive.getLocalOsPath(); File dir = new File(osPath); if (dir.isDirectory()) { String msg = String.format( "Are you sure you want to delete '%1$s' at '%2$s'? This cannot be undone.", p.getShortDescription(), osPath); if (MessageDialog.openQuestion(getShell(), title, msg)) { archive.deleteLocal(); // refresh list onRefreshSelected(); } } else { error = "Directory not found for this package"; } } else { error = "No local archive found for this package"; } if (error != null) { MessageDialog.openError(getShell(), title, error); } return; } } }
From source file:com.android.sdkuilib.internal.repository.SwtUpdaterData.java
License:Apache License
@Override protected void displayInitError(String error) { // We may not have any UI. Only display a dialog if there's a window shell available. if (mWindowShell != null && !mWindowShell.isDisposed()) { MessageDialog.openError(mWindowShell, "Android Virtual Devices Manager", error); } else {/*from www . ja va 2s . com*/ super.displayInitError(error); } }