List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning
public static void openWarning(Shell parent, String title, String message)
From source file:com.amitinside.e4.rcp.todo.handlers.UpdateHandler.java
License:Apache License
@Execute public void execute(final IProvisioningAgent agent, final Shell parent, final UISynchronize sync, final IWorkbench workbench) { Job j = new Job("Update Job") { private boolean doInstall = false; /*/*from www.j av a 2s .c o m*/ * (non-Javadoc) * * @see * org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime * .IProgressMonitor) */ @Override protected IStatus run(final IProgressMonitor monitor) { /* 1. Prepare update plumbing */ final ProvisioningSession session = new ProvisioningSession(agent); final UpdateOperation operation = new UpdateOperation(session); // Create uri URI uri = null; try { uri = new URI(REPOSITORY_LOC); } catch (final URISyntaxException e) { sync.syncExec(new Runnable() { @Override public void run() { MessageDialog.openError(parent, "URI invalid", e.getMessage()); } }); return Status.CANCEL_STATUS; } // Set location of artifact and metadata repo // (Explain difference between meta und artifact repo) operation.getProvisioningContext().setArtifactRepositories(new URI[] { uri }); operation.getProvisioningContext().setMetadataRepositories(new URI[] { uri }); /* 2. Check for updates */ // Run update checks causing I/O final IStatus status = operation.resolveModal(monitor); // Failed to find updates (inform user and exit) if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) { sync.syncExec(new Runnable() { /* * (non-Javadoc) * * @see java.lang.Runnable#run() */ @Override public void run() { MessageDialog.openWarning(parent, "No update", "No updates for the current installation have been found"); } }); return Status.CANCEL_STATUS; } /* 3. Ask if updates should be installed and run installation */ // found updates, ask user if to install? if (status.isOK() && status.getSeverity() != IStatus.ERROR) { sync.syncExec(new Runnable() { /* * (non-Javadoc) * * @see java.lang.Runnable#run() */ @Override public void run() { String updates = ""; Update[] possibleUpdates = operation.getPossibleUpdates(); for (Update update : possibleUpdates) { updates += update + "\n"; } doInstall = MessageDialog.openQuestion(parent, "Relly install updates?", updates); } }); } // Install! (causing I/0) if (doInstall) { final ProvisioningJob provisioningJob = operation.getProvisioningJob(monitor); // Updates cannot run from within Eclipse IDE!!! if (provisioningJob == null) { System.err.println("Running update from within Eclipse IDE? This won't work!!!"); throw new NullPointerException(); } // Register a job change listener to track // installation progress and notify user upon success provisioningJob.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { if (event.getResult().isOK()) { sync.syncExec(new Runnable() { @Override public void run() { boolean restart = MessageDialog.openQuestion(parent, "Updates installed, restart?", "Updates have been installed successfully, do you want to restart?"); if (restart) { workbench.restart(); } } }); } super.done(event); } }); provisioningJob.schedule(); } return Status.OK_STATUS; } }; j.schedule(); }
From source file:com.android.ddms.UIThread.java
License:Apache License
/** * Create SWT objects and drive the user interface event loop. * @param ddmsParentLocation location of the folder that contains ddms. *//*from ww w .ja v a2 s. c om*/ public void runUI(String ddmsParentLocation) { Display.setAppName(APP_NAME); mDisplay = Display.getDefault(); final Shell shell = new Shell(mDisplay, SWT.SHELL_TRIM); // create the image loaders for DDMS and DDMUILIB mDdmUiLibLoader = ImageLoader.getDdmUiLibLoader(); shell.setImage(ImageLoader.getLoader(this.getClass()).loadImage(mDisplay, "ddms-128.png", //$NON-NLS-1$ 100, 50, null)); Log.setLogOutput(new ILogOutput() { @Override public void printAndPromptLog(final LogLevel logLevel, final String tag, final String message) { Log.printLog(logLevel, tag, message); // dialog box only run in UI thread.. mDisplay.asyncExec(new Runnable() { @Override public void run() { Shell activeShell = mDisplay.getActiveShell(); if (logLevel == LogLevel.ERROR) { MessageDialog.openError(activeShell, tag, message); } else { MessageDialog.openWarning(activeShell, tag, message); } } }); } @Override public void printLog(LogLevel logLevel, String tag, String message) { Log.printLog(logLevel, tag, message); } }); // set the handler for hprof dump ClientData.setHprofDumpHandler(new HProfHandler(shell)); ClientData.setMethodProfilingHandler(new MethodProfilingHandler(shell)); // [try to] ensure ADB is running // in the new SDK, adb is in the platform-tools, but when run from the command line // in the Android source tree, then adb is next to ddms. String adbLocation; if (ddmsParentLocation != null && ddmsParentLocation.length() != 0) { // check if there's a platform-tools folder File platformTools = new File(new File(ddmsParentLocation).getParent(), "platform-tools"); //$NON-NLS-1$ if (platformTools.isDirectory()) { adbLocation = platformTools.getAbsolutePath() + File.separator + SdkConstants.FN_ADB; } else { // we're in the Android source tree, then adb is in $ANDROID_HOST_OUT/bin/adb String androidOut = System.getenv("ANDROID_HOST_OUT"); if (androidOut != null) { adbLocation = androidOut + File.separator + "bin" + File.separator + SdkConstants.FN_ADB; } else { adbLocation = SdkConstants.FN_ADB; } } } else { adbLocation = SdkConstants.FN_ADB; } AndroidDebugBridge.init(true /* debugger support */); AndroidDebugBridge.createBridge(adbLocation, true /* forceNewBridge */); // we need to listen to client change to be notified of client status (profiling) change AndroidDebugBridge.addClientChangeListener(this); shell.setText("Dalvik Debug Monitor"); setConfirmClose(shell); createMenus(shell); createWidgets(shell); shell.pack(); setSizeAndPosition(shell); shell.open(); Log.d("ddms", "UI is up"); while (!shell.isDisposed()) { if (!mDisplay.readAndDispatch()) mDisplay.sleep(); } if (useOldLogCatView()) { mLogPanel.stopLogCat(true); } mDevicePanel.dispose(); for (TablePanel panel : mPanels) { if (panel != null) { panel.dispose(); } } ImageLoader.dispose(); mDisplay.dispose(); Log.d("ddms", "UI is down"); }
From source file:com.android.glesv2debugger.ShaderEditor.java
License:Apache License
void uploadShader() { current.source = styledText.getText(); // optional syntax check by glsl_compiler, built from external/mesa3d if (new File("./glsl_compiler").exists()) try {//from w w w. j av a2s. c om File file = File.createTempFile("shader", current.type == GLEnum.GL_VERTEX_SHADER ? ".vert" : ".frag"); FileWriter fileWriter = new FileWriter(file, false); fileWriter.write(current.source); fileWriter.close(); ProcessBuilder processBuilder = new ProcessBuilder("./glsl_compiler", "--glsl-es", file.getAbsolutePath()); final Process process = processBuilder.start(); InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line; String infolog = ""; styledText.setLineBackground(0, styledText.getLineCount(), null); while ((line = br.readLine()) != null) { infolog += line; if (!line.startsWith("0:")) continue; String[] details = line.split(":|\\(|\\)"); final int ln = Integer.parseInt(details[1]); if (ln > 0) // usually line 0 means errors other than syntax styledText.setLineBackground(ln - 1, 1, new Color(Display.getCurrent(), 255, 230, 230)); } file.delete(); if (infolog.length() > 0) { if (!MessageDialog.openConfirm(getShell(), "Shader Syntax Error, Continue?", infolog)) return; } } catch (IOException e) { sampleView.showError(e); } // add the initial command, which when read by server will set // expectResponse for the message loop and go into message exchange synchronized (shadersToUpload) { for (GLShader shader : shadersToUpload) { if (shader.context.context.contextId != current.context.context.contextId) continue; MessageDialog.openWarning(this.getShell(), "Context 0x" + Integer.toHexString(current.context.context.contextId), "Previous shader upload not complete, try again"); return; } shadersToUpload.add(current); final int contextId = current.context.context.contextId; Message.Builder builder = getBuilder(contextId); MessageParserEx.instance.parse(builder, String.format("glShaderSource(%d,1,\"%s\",0)", current.name, current.source)); sampleView.messageQueue.addCommand(builder.build()); } }
From source file:com.android.glesv2debugger.ShaderEditor.java
License:Apache License
public boolean processMessage(final MessageQueue queue, final Message msg) throws IOException { GLShader shader = null;// w w w . jav a 2s . c om final int contextId = msg.getContextId(); synchronized (shadersToUpload) { if (shadersToUpload.size() == 0) return false; boolean matchingContext = false; for (int i = 0; i < shadersToUpload.size(); i++) { shader = shadersToUpload.get(i); for (Context ctx : shader.context.context.shares) if (ctx.contextId == contextId) { matchingContext = true; break; } if (matchingContext) { shadersToUpload.remove(i); break; } } if (!matchingContext) return false; } // glShaderSource was already sent to trigger set expectResponse assert msg.getType() == Type.AfterGeneratedCall; assert msg.getFunction() == Function.glShaderSource; exchangeMessage(contextId, queue, "glCompileShader(%d)", shader.name); // the 0, "" and {0} are dummies for the parser Message rcv = exchangeMessage(contextId, queue, "glGetShaderiv(%d, GL_COMPILE_STATUS, {0})", shader.name); assert rcv.hasData(); if (rcv.getData().asReadOnlyByteBuffer().getInt() == 0) { // compile failed rcv = exchangeMessage(contextId, queue, "glGetShaderInfoLog(%d, 0, 0, \"\")", shader.name); final String title = String.format("Shader %d in 0x%s failed to compile", shader.name, Integer.toHexString(shader.context.context.contextId)); final String message = rcv.getData().toStringUtf8(); sampleView.getSite().getShell().getDisplay().syncExec(new Runnable() { @Override public void run() { MessageDialog.openWarning(getShell(), title, message); } }); } else for (int programName : shader.programs) { GLProgram program = shader.context.getProgram(programName); exchangeMessage(contextId, queue, "glLinkProgram(%d)", program.name); rcv = exchangeMessage(contextId, queue, "glGetProgramiv(%d, GL_LINK_STATUS, {0})", program.name); assert rcv.hasData(); if (rcv.getData().asReadOnlyByteBuffer().getInt() != 0) continue; // link failed rcv = exchangeMessage(contextId, queue, "glGetProgramInfoLog(%d, 0, 0, \"\")", program.name); final String title = String.format("Program %d in 0x%s failed to link", program.name, Integer.toHexString(program.context.context.contextId)); final String message = rcv.getData().toStringUtf8(); sampleView.getSite().getShell().getDisplay().syncExec(new Runnable() { @Override public void run() { MessageDialog.openWarning(getShell(), title, message); } }); // break; } // TODO: add to upload results if failed Message.Builder builder = getBuilder(contextId); builder.setExpectResponse(false); if (queue.getPartialMessage(contextId) != null) // the glShaderSource interrupted a BeforeCall, so continue builder.setFunction(Function.CONTINUE); else builder.setFunction(Function.SKIP); queue.sendMessage(builder.build()); return true; }
From source file:com.android.ide.eclipse.adt.AdtPlugin.java
License:Open Source License
/** * Displays a warning 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 warning message/*from w w w.j a v a 2 s . c om*/ */ public final static void displayWarning(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.openWarning(shell, title, message); } }); }
From source file:com.android.ide.eclipse.adt.internal.lint.EclipseLintRunner.java
License:Open Source License
/** * Run Lint for an Export APK action. If it succeeds (no fatal errors) * returns true, and if it fails it will display an error message and return * false.//from w w w . j ava 2 s . c o m * * @param shell the parent shell to show error messages in * @param project the project to run lint on * @return true if the lint run succeeded with no fatal errors */ public static boolean runLintOnExport(Shell shell, IProject project) { if (AdtPrefs.getPrefs().isLintOnExport()) { boolean fatal = EclipseLintRunner.runLint(Collections.singletonList(project), null, null, true /*fatalOnly*/); if (fatal) { MessageDialog.openWarning(shell, "Export Aborted", "Export aborted because fatal lint errors were found. These " + "are listed in the Lint View. Either fix these before " + "running Export again, or turn off \"Run full error check " + "when exporting app\" in the Android > Lint Error Checking " + "preference page."); return false; } } return true; }
From source file:com.android.ide.eclipse.adt.internal.lint.LintRunner.java
License:Open Source License
/** * Run Lint for an Export APK action. If it succeeds (no fatal errors) * returns true, and if it fails it will display an error message and return * false.//from w w w. ja va 2s . c o m * * @param shell the parent shell to show error messages in * @param project the project to run lint on * @return true if the lint run succeeded with no fatal errors */ public static boolean runLintOnExport(Shell shell, IProject project) { if (AdtPrefs.getPrefs().isLintOnExport()) { boolean fatal = LintRunner.runLint(project, null, true /*fatalOnly*/); if (fatal) { MessageDialog.openWarning(shell, "Export Aborted", "Export aborted because fatal lint errors were found. These " + "are listed in the Problems view. Either fix these before " + "running Export again, or turn off \"Run full error check " + "when exporting app\" in the Android > Lint Error Checking " + "preference page."); return false; } } return true; }
From source file:com.android.ide.eclipse.adt.internal.lint.RunLintAction.java
License:Open Source License
/** Returns the Android project(s) to apply a lint run to. */ static List<IProject> getProjects(ISelection selection, boolean warn) { List<IProject> projects = AdtUtils.getSelectedProjects(selection); if (projects.isEmpty() && warn) { MessageDialog.openWarning(AdtPlugin.getShell(), "Lint", "Could not run Lint: Select an Android project first."); }//from ww w .j a v a2 s . com return projects; }
From source file:com.android.ide.eclipse.auidt.internal.lint.RunLintAction.java
License:Open Source License
/** Returns the Android project(s) to apply a lint run to. */ static List<IProject> getProjects(ISelection selection, boolean warn) { List<IProject> projects = AdtUtils.getSelectedProjects(selection); if (projects.isEmpty() && warn) { MessageDialog.openWarning(AdtPlugin.getDisplay().getActiveShell(), "Lint", "Could not run Lint: Select an Android project first."); }/*from w ww. j av a2s .c o m*/ return projects; }
From source file:com.android.ide.eclipse.ddms.DdmsPlugin.java
License:Apache License
@Override public void start(BundleContext context) throws Exception { super.start(context); final Display display = getDisplay(); // get the eclipse store final IPreferenceStore eclipseStore = getPreferenceStore(); AndroidDebugBridge.addDeviceChangeListener(this); DdmUiPreferences.setStore(eclipseStore); //DdmUiPreferences.displayCharts(); // set the consoles. mDdmsConsole = new MessageConsole("DDMS", null); //$NON-NLS-1$ ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { mDdmsConsole }); final MessageConsoleStream consoleStream = mDdmsConsole.newMessageStream(); final MessageConsoleStream errorConsoleStream = mDdmsConsole.newMessageStream(); mRed = new Color(display, 0xFF, 0x00, 0x00); // because this can be run, in some cases, by a non UI thread, and because // changing the console properties update the UI, we need to make this change // in the UI thread. display.asyncExec(new Runnable() { @Override//from ww w . ja v a 2 s. c om public void run() { errorConsoleStream.setColor(mRed); } }); // 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); showConsoleView(mDdmsConsole); } 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.asyncExec(new Runnable() { @Override public void run() { Shell shell = display.getActiveShell(); if (logLevel == LogLevel.ERROR) { MessageDialog.openError(shell, tag, message); } else { MessageDialog.openWarning(shell, tag, message); } } }); } }); // set up the ddms console to use this objects DdmConsole.setConsole(new IDdmConsole() { @Override public void printErrorToConsole(String message) { printToStream(errorConsoleStream, null, message); showConsoleView(mDdmsConsole); } @Override public void printErrorToConsole(String[] messages) { for (String m : messages) { printToStream(errorConsoleStream, null, m); } showConsoleView(mDdmsConsole); } @Override public void printToConsole(String message) { printToStream(consoleStream, null, message); } @Override public void printToConsole(String[] messages) { for (String m : messages) { printToStream(consoleStream, null, m); } } }); // set the listener for the preference change eclipseStore.addPropertyChangeListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { // get the name of the property that changed. String property = event.getProperty(); if (PreferenceInitializer.ATTR_DEBUG_PORT_BASE.equals(property)) { DdmPreferences .setDebugPortBase(eclipseStore.getInt(PreferenceInitializer.ATTR_DEBUG_PORT_BASE)); } else if (PreferenceInitializer.ATTR_SELECTED_DEBUG_PORT.equals(property)) { DdmPreferences.setSelectedDebugPort( eclipseStore.getInt(PreferenceInitializer.ATTR_SELECTED_DEBUG_PORT)); } else if (PreferenceInitializer.ATTR_THREAD_INTERVAL.equals(property)) { DdmUiPreferences.setThreadRefreshInterval( eclipseStore.getInt(PreferenceInitializer.ATTR_THREAD_INTERVAL)); } else if (PreferenceInitializer.ATTR_LOG_LEVEL.equals(property)) { DdmPreferences.setLogLevel(eclipseStore.getString(PreferenceInitializer.ATTR_LOG_LEVEL)); } else if (PreferenceInitializer.ATTR_TIME_OUT.equals(property)) { DdmPreferences.setTimeOut(eclipseStore.getInt(PreferenceInitializer.ATTR_TIME_OUT)); } else if (PreferenceInitializer.ATTR_USE_ADBHOST.equals(property)) { DdmPreferences.setUseAdbHost(eclipseStore.getBoolean(PreferenceInitializer.ATTR_USE_ADBHOST)); } else if (PreferenceInitializer.ATTR_ADBHOST_VALUE.equals(property)) { DdmPreferences .setAdbHostValue(eclipseStore.getString(PreferenceInitializer.ATTR_ADBHOST_VALUE)); } } }); // do some last initializations // set the preferences. PreferenceInitializer.setupPreferences(); // this class is set as the main source revealer and will look at all the implementations // of the extension point. see #reveal(String, String, int) StackTracePanel.setSourceRevealer(this); /* * Load the extension point implementations. * The first step is to load the IConfigurationElement representing the implementations. * The 2nd step is to use these objects to instantiate the implementation classes. * * Because the 2nd step will trigger loading the plug-ins providing the implementations, * and those plug-ins could access DDMS classes (like ADT), this 2nd step should be done * in a Job to ensure that DDMS is loaded, so that the other plug-ins can load. * * Both steps could be done in the 2nd step but some of DDMS UI rely on knowing if there * is an implementation or not (DeviceView), so we do the first steps in start() and, in * some case, record it. * */ // get the IConfigurationElement for the debuggerConnector right away. final IConfigurationElement[] dcce = findConfigElements("com.android.ide.eclipse.ddms.debuggerConnector"); //$NON-NLS-1$ mHasDebuggerConnectors = dcce.length > 0; // get the other configElements and instantiante them in a Job. new Job(Messages.DdmsPlugin_DDMS_Post_Create_Init) { @Override protected IStatus run(IProgressMonitor monitor) { try { // init the lib AndroidDebugBridge.init(true /* debugger support */); // get the available adb locators IConfigurationElement[] elements = findConfigElements( "com.android.ide.eclipse.ddms.toolsLocator"); //$NON-NLS-1$ IToolsLocator[] locators = instantiateToolsLocators(elements); for (IToolsLocator locator : locators) { try { String adbLocation = locator.getAdbLocation(); String traceviewLocation = locator.getTraceViewLocation(); String hprofConvLocation = locator.getHprofConvLocation(); if (adbLocation != null && traceviewLocation != null && hprofConvLocation != null) { // checks if the location is valid. if (setToolsLocation(adbLocation, hprofConvLocation, traceviewLocation)) { AndroidDebugBridge.createBridge(sAdbLocation, true /* forceNewBridge */); // no need to look at the other locators. break; } } } catch (Throwable t) { // ignore, we'll just not use this implementation. } } // get the available debugger connectors mDebuggerConnectors = instantiateDebuggerConnectors(dcce); // get the available Traceview Launchers. elements = findConfigElements("com.android.ide.eclipse.ddms.traceviewLauncher"); //$NON-NLS-1$ mTraceviewLaunchers = instantiateTraceviewLauncher(elements); return Status.OK_STATUS; } catch (CoreException e) { return e.getStatus(); } } }.schedule(); }