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.javadude.antlr3.visualizer.Log.java
License:Open Source License
/** * Log a warning.//from ww w . j av a2s . c o m * @param message the message * @param throwable an optional exception */ public static void warning(int code, final String message, Throwable throwable) { IStatus status = new Status(IStatus.WARNING, Activator.PLUGIN_ID, code, message, throwable); Activator.getDefault().getLog().log(status); Display.getDefault().asyncExec(new Runnable() { public void run() { MessageDialog.openWarning(null, "Warning: " + message, message); } }); }
From source file:com.javadude.antxr.eclipse.core.PluginUtil.java
License:Open Source License
/** * Log an error.//from w w w . j a va 2 s.c o m * @param message the message * @param throwable an optional exception */ public void error(int code, final String message, Throwable throwable) { IStatus status = new Status(IStatus.ERROR, pluginName_, code, message, throwable); log_.log(status); Display.getDefault().asyncExec(new Runnable() { public void run() { MessageDialog.openWarning(null, "Error: " + message, message); } }); }
From source file:com.javadude.antxr.eclipse.core.PluginUtil.java
License:Open Source License
/** * Log a warning./* w ww.j av a 2 s. c om*/ * @param message the message * @param throwable an optional exception */ public void warning(int code, final String message, Throwable throwable) { IStatus status = new Status(IStatus.WARNING, pluginName_, code, message, throwable); log_.log(status); Display.getDefault().asyncExec(new Runnable() { public void run() { MessageDialog.openWarning(null, "Warning: " + message, message); } }); }
From source file:com.kdmanalytics.toif.report.internal.handlers.TraceContributionHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { final IStructuredSelection s = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); final String lineNumber = event.getParameter("com.kdmanalytics.toif.report.lineNumber"); if (s.isEmpty()) { return null; }//from ww w . java 2 s . c o m Object element = s.getFirstElement(); if (element instanceof IToifReportEntry) { IToifReportEntry iToifReportEntry = (IToifReportEntry) element; FindingEntry fEntry = iToifReportEntry.getFindingEntry(); IProject activeProject = iToifReportEntry.getProject().getIProject(); try { FileGroup file = (FileGroup) fEntry.getParent().getParent().getParent(); IResource member = MemberUtil.findMembers(activeProject, file); if (member == null) { MessageDialog.openWarning(null, "No Source File Found!", "A source file could not be found for this location."); return null; } IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); HashMap<String, Object> map = new HashMap<String, Object>(); map.put(IMarker.LINE_NUMBER, Integer.parseInt(lineNumber)); IMarker marker = member.createMarker(IMarker.TEXT); marker.setAttributes(map); IDE.openEditor(page, marker); marker.delete(); } catch (CoreException exception) { exception.printStackTrace(); } } return null; }
From source file:com.kdmanalytics.toif.report.internal.listeners.ReportDoubleClickListener.java
License:Open Source License
@Override public void doubleClick(DoubleClickEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); Object element = selection.getFirstElement(); if (element instanceof IToifReportEntry) { IToifReportEntry iToifReportEntry = (IToifReportEntry) element; IProject activeProject = iToifReportEntry.getProject().getIProject(); try {// w ww .j a va 2s.c o m IToifReportEntry item = (IToifReportEntry) element; FindingEntry entry = item.getFindingEntry(); LocationGroup locationGroup = (LocationGroup) entry.getParent().getParent(); IFileGroup file = (IFileGroup) entry.getParent().getParent().getParent(); IResource member = MemberUtil.findMembers(activeProject, file); System.err.println("Member type " + member); if (member == null) { MessageDialog.openWarning(null, "No Source File Found!", "A source file could not be found for this location."); return; } IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); HashMap<String, Object> map = new HashMap<String, Object>(); if (element instanceof IFileGroup) { map.put(IMarker.LINE_NUMBER, 1); } else { map.put(IMarker.LINE_NUMBER, Integer.parseInt(locationGroup.getLineNumber())); } IMarker marker = member.createMarker(IMarker.TEXT); marker.setAttributes(map); IDE.openEditor(page, marker); marker.delete(); } catch (Exception e1) { e1.printStackTrace(); } } }
From source file:com.kdmanalytics.toif.ui.common.ResourceChangeDeltaPrinter.java
License:Open Source License
/** * //from w ww . j a v a2 s. c om * @param project * @param delta * @param res * @throws CoreException */ protected synchronized void visitResource(final IProject project, IResourceDelta delta, IResource res) throws CoreException { // Have we already warned on this project? if (project.getPersistentProperty(com.kdmanalytics.toif.ui.common.Activator.PROJECT_INCONSISTENT) == null) { // Set to true if the resource has PROPERLY changed boolean changed = false; switch (delta.getKind()) { case IResourceDelta.ADDED: case IResourceDelta.REMOVED: { // We cannot check the attributes for deleted items, so assume if we // get this far it is an interesting file. System.err.println("Changed 1"); changed = true; break; } case IResourceDelta.CHANGED: { // All resources should be read only, if it is not then the contents // have actually changed. ResourceAttributes attrs = res.getResourceAttributes(); if (!attrs.isReadOnly() && !attrs.isHidden() && !res.isDerived()) { System.err.println("Changed 2"); changed = true; } break; } } if (changed) { try { project.setPersistentProperty(com.kdmanalytics.toif.ui.common.Activator.PROJECT_INCONSISTENT, "true"); } catch (CoreException e) { e.printStackTrace(); } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); Shell shell = window.getShell(); MessageDialog.openWarning(shell, "Inconsistent TOIF data", "The source has changed possibly rendering the imported TOIF data inconsistent. Reload the '*.kdm' file to ensure the data is consistent"); } }); } } }
From source file:com.liferay.ide.hook.ui.wizard.CustomJSPsTableWizardSection.java
License:Open Source License
protected void handleAddFromPortalButtonSelected() { if (portalDir == null || !portalDir.exists()) { MessageDialog.openWarning(getShell(), Msgs.addJSP, Msgs.couldNotFindPortalRoot); return;/*from ww w .j av a 2 s .com*/ } IPath rootPath = new Path(portalDir.getPath()); ExternalFileSelectionDialog dialog = new ExternalFileSelectionDialog(getShell(), new JSPFileViewerFilter(portalDir, new String[] { "html" }), true, false); //$NON-NLS-1$ dialog.setTitle(Msgs.liferayCustomJSP); dialog.setMessage(Msgs.selectJSPToCustomize); dialog.setInput(portalDir); if (dialog.open() == Window.OK) { Object[] selected = dialog.getResult(); for (int i = 0; i < selected.length; i++) { IPath filePath = Path.fromOSString(((File) selected[i]).getPath()); addStringArray(new String[] { "/" + filePath.makeRelativeTo(rootPath).toPortableString() }); //$NON-NLS-1$ } } }
From source file:com.liferay.ide.service.ui.actions.BuildServicesActionHandler.java
License:Open Source License
@Override protected Object run(Presentation context) { IFile file = context.part().getModelElement().adapt(IFile.class); if (file != null && file.exists()) { if (ServiceUIUtil.shouldCreateServiceBuilderJob(file)) { new BuildServiceJob(file.getProject()).schedule(); }// w ww.j a va 2 s . com } else { MessageDialog.openWarning(((SwtPresentation) context).shell(), Msgs.buildServices, Msgs.ActionUnavailableImportProject); } return null; }
From source file:com.mercatis.lighthouse3.security.ui.wizards.pages.WizardNewLighthouseDomainSecurityPage.java
License:Apache License
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); initializeDialogUnits(parent);/*from w w w . j a va 2s .c o m*/ composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); GridData data = new GridData(GridData.FILL_HORIZONTAL); data.widthHint = SIZING_TEXT_FIELD_WIDTH; Group urlGroup = new Group(composite, SWT.NONE); urlGroup.setText("Security settings"); GridLayout urlLayout = new GridLayout(); urlLayout.numColumns = 2; urlGroup.setLayout(urlLayout); urlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Label urlLabel = new Label(urlGroup, SWT.NONE); urlLabel.setText("URL"); urlLabel.setFont(parent.getFont()); urlText = new Text(urlGroup, SWT.BORDER); urlText.setText(urlTextValue != null ? urlTextValue : "http://localhost:8081"); urlText.setLayoutData(data); urlText.setFont(parent.getFont()); urlText.addListener(SWT.Modify, modifyListener); urlText.setFocus(); Button testB = new Button(composite, SWT.PUSH); testB.setText("Test Connection"); testB.setLayoutData(new GridData(SWT.END, SWT.TOP, true, false)); testB.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { BufferedReader in = null; try { String txt = urlText.getText(); StringBuilder sb = new StringBuilder(txt); if (!txt.endsWith("/")) sb.append('/'); sb.append("Version"); URL url = new URL(sb.toString()); URLConnection conn = url.openConnection(); in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String inputLine = in.readLine(); Pattern p = Pattern.compile("^\\d.\\d.\\d(?:-SNAPSHOT)?$"); Matcher m = p.matcher(inputLine); if (m.matches()) MessageDialog.openInformation(getShell(), "Connection Test", "Connection test successful!\n\nLighthouse Server v" + inputLine + " was found."); else MessageDialog.openWarning(getShell(), "Connection Test", "Connection test failed!\n\nThere was a reply but it could not be validated."); } catch (Exception e1) { MessageDialog.openError(getShell(), "Connection Test", "Connection test failed!\n\n" + e1.getMessage()); } finally { if (in != null) try { in.close(); } catch (IOException e1) { /* ignore */ } } } public void widgetDefaultSelected(SelectionEvent e) { /* ignore */ } }); setPageComplete(validatePage()); // Show description on opening setErrorMessage(null); setMessage(null); setControl(composite); Dialog.applyDialogFont(composite); }
From source file:com.mercatis.lighthouse3.status.ui.wizards.StatusWizard.java
License:Apache License
public void addPages() { Set<Deployment> deps = statusCarrier.getAssociatedDeployments(); if (deps.size() == 0) { MessageDialog.openWarning(PlatformUI.getWorkbench().getDisplay().getActiveShell(), "New Status Wizard", "The selected " + statusCarrier.getRootElementName() + " does not have any deployment.\n\nUnable to create a status without a deployment."); //This RuntimeException will be catched by the UI framework and prevents this wizard from opening throw new RuntimeException("wizardkillerexception", null); }/*from www .j av a2s .c om*/ LighthouseDomain domain = CommonBaseActivator.getPlugin().getDomainService() .getLighthouseDomain(deps.iterator().next().getLighthouseDomain()); mainPage = new StatusWizardMainPage("Status", statusCarrier); mainPage.setTitle("Status"); mainPage.setDescription("Edit details of the Status."); okPage = new WizardEventTemplatePage("OK Template", domain, WizardEventTemplatePage.EventType.OK); okPage.setDeployments(statusCarrier.getAssociatedDeployments()); okPage.setTitle("OK Template"); okPage.setDescription("Define details of OK Template"); errorPage = new WizardEventTemplatePage("Error Template", domain, WizardEventTemplatePage.EventType.ERROR); errorPage.setDeployments(statusCarrier.getAssociatedDeployments()); errorPage.setTitle("Error Template"); errorPage.setDescription("Define details of Error Template"); notificationPage = new StatusWizardNotificationPage("Notification Channel", CommonBaseActivator.getPlugin().getDomainService().getLighthouseDomainByEntity(statusCarrier)); notificationPage.setTitle("Notification Channel"); notificationPage.setDescription("Edit the template for email notification"); addPage(mainPage); addPage(okPage); addPage(errorPage); addPage(notificationPage); }