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.hudson.hibernatesynchronizer.util.SynchronizerThread.java
License:GNU General Public License
public static void writeClass(String velocityTemplate, Context context, IPackageFragmentRoot fragmentRoot, String packageName, String className, boolean force) throws JavaModelException { IPackageFragment fragment = fragmentRoot.getPackageFragment(packageName); String fileName = className + ".java"; try {// w w w . j a v a 2 s . c o m if (null != fragment) { if (!fragment.exists()) { fragment = fragmentRoot.createPackageFragment(packageName, false, null); } ICompilationUnit unit = fragment.getCompilationUnit(fileName); if (!unit.exists() && !force) { Template template = Constants.templateGenerator.getTemplate(velocityTemplate); StringWriter sw = new StringWriter(); template.merge(context, sw); try { unit = fragment.createCompilationUnit(fileName, addContent(sw.toString(), className), false, null); } catch (JavaModelException e) { } } else { if (force) { org.apache.velocity.Template template = Constants.templateGenerator .getTemplate(velocityTemplate); StringWriter sw = new StringWriter(); template.merge(context, sw); try { if (unit.exists()) { String existingContent = unit.getBuffer().getContents(); if (null != existingContent && existingContent.equals(sw.toString())) return; } unit = createCompilationUnit(fragment, unit, fileName, addContent(sw.toString(), className), true, null); } catch (JavaModelException e) { } } } } } catch (Exception e) { e.printStackTrace(); if (e instanceof JavaModelException) throw (JavaModelException) e; else MessageDialog.openWarning(null, "An error has occured: " + e.getClass(), e.getMessage()); } }
From source file:com.hudson.hibernatesynchronizer.util.SynchronizerThread.java
License:GNU General Public License
private static void writeProxyClass(String templateName, String contentTemplateName, Context context, IPackageFragmentRoot fragmentRoot, String packageName, String className) throws JavaModelException { IPackageFragment fragment = fragmentRoot.getPackageFragment(packageName); String fileName = className + ".java"; try {/*from w w w.ja va 2s . c om*/ if (null != fragment) { if (!fragment.exists()) { fragment = fragmentRoot.createPackageFragment(packageName, false, null); } ICompilationUnit unit = fragment.getCompilationUnit(fileName); if (unit.exists()) { String content = unit.getSource(); MarkerContents mc = HSUtil.getMarkerContents(content, "GENERATED CONTENT MARKER"); if (null != mc) { try { Template template = Constants.templateGenerator.getTemplate(contentTemplateName); StringWriter sw = new StringWriter(); template.merge(context, sw); if (null != mc.getContents() && mc.getContents().trim().equals(sw.toString().trim())) return; content = mc.getPreviousContents() + sw.toString() + mc.getPostContents(); createCompilationUnit(fragment, unit, fileName, content, true, null); } catch (JavaModelException e) { } } } else { try { Template template = Constants.templateGenerator.getTemplate(contentTemplateName); StringWriter sw = new StringWriter(); template.merge(context, sw); VelocityContext subContext = new VelocityContext(context); subContext.put("contents", sw.toString()); template = Constants.templateGenerator.getTemplate(templateName); sw = new StringWriter(); template.merge(subContext, sw); unit = fragment.createCompilationUnit(fileName, addContent(sw.toString(), className), true, null); } catch (JavaModelException e) { } } } } catch (Exception e) { if (e instanceof JavaModelException) throw (JavaModelException) e; else MessageDialog.openWarning(null, "An error has occured: " + e.getClass(), e.getMessage()); } }
From source file:com.hudson.hibernatesynchronizer.util.SynchronizerThread.java
License:GNU General Public License
private static boolean writeCustom(IProject project, IPackageFragmentRoot fragmentRoot, ProjectTemplate projectTemplate, HibernateClass hc, Context context, IFile syncFile, boolean force) { context.remove("custom_placeholder"); try {/*from w w w . j a v a 2 s . co m*/ if (projectTemplate.getTemplate().isJavaClass()) { StringWriter sw = new StringWriter(); Constants.customGenerator.evaluate(context, sw, Velocity.class.getName(), projectTemplate.getName()); String className = sw.toString(); String fileName = className + ".java"; context.put("className", className); sw = new StringWriter(); Constants.customGenerator.evaluate(context, sw, Velocity.class.getName(), projectTemplate.getLocation()); String packageName = sw.toString(); IPackageFragment fragment = fragmentRoot.getPackageFragment(packageName); if (null != fragment) { context.put("package", packageName); sw = new StringWriter(); Constants.customGenerator.evaluate(context, sw, Velocity.class.getName(), packageName); String location = sw.toString(); if (!fragment.exists()) { fragment = fragmentRoot.createPackageFragment(packageName, false, null); } ICompilationUnit unit = fragment.getCompilationUnit(fileName); sw = new StringWriter(); Constants.customGenerator.evaluate(context, sw, Velocity.class.getName(), projectTemplate.getTemplate().getContent()); try { String trimmed = sw.toString().trim(); if (NO_SAVE.equals(trimmed)) { return false; } else if (trimmed.startsWith(WARNING)) { String message = trimmed.substring(WARNING.length(), trimmed.length()); if (null != syncFile) { String key = WARNING + syncFile.getName() + message; if (null == context.get(key)) { context.put(key, Boolean.TRUE); EditorUtil.addWarningMarker(syncFile, message, 0); } } return false; } else if (trimmed.startsWith(ERROR)) { String message = trimmed.substring(ERROR.length(), trimmed.length()); if (null != syncFile) { String key = ERROR + syncFile.getName() + message; if (null == context.get(key)) { context.put(key, Boolean.TRUE); EditorUtil.addProblemMarker(syncFile, message, 0); } } return false; } else if (trimmed.startsWith(FATAL)) { String message = trimmed.substring(FATAL.length(), trimmed.length()); if (null != syncFile) { String key = FATAL + syncFile.getName() + message; if (null == context.get(key)) { context.put(key, Boolean.TRUE); EditorUtil.addProblemMarker(syncFile, message, 0); } } return true; } else { if (!unit.exists()) { unit = fragment.createCompilationUnit(fileName, addContent(sw.toString(), className), false, null); } else { String content = addContent(sw.toString(), className); if (force || projectTemplate.shouldOverride()) { unit = createCompilationUnit(fragment, unit, fileName, content, true, null); } } } } catch (JavaModelException e) { } context.remove("package"); } context.remove("className"); } else { StringWriter sw = new StringWriter(); Constants.customGenerator.evaluate(context, sw, Velocity.class.getName(), projectTemplate.getName()); String name = sw.toString(); sw = new StringWriter(); Constants.customGenerator.evaluate(context, sw, Velocity.class.getName(), projectTemplate.getLocation()); String location = sw.toString(); location = location.replace('\\', '/'); if (!location.startsWith("/")) { location = "/" + location; } if (location.endsWith("/")) { location = location.substring(0, location.length() - 1); } context.put("path", location); context.put("fileName", name); sw = new StringWriter(); Constants.customGenerator.evaluate(context, sw, Velocity.class.getName(), projectTemplate.getTemplate().getContent()); String content = sw.toString(); String trimmed = sw.toString().trim(); if (NO_SAVE.equals(trimmed)) { return false; } else if (trimmed.startsWith(WARNING)) { String message = trimmed.substring(WARNING.length(), trimmed.length()); if (null != syncFile) { String key = WARNING + syncFile.getName() + message; if (null == context.get(key)) { context.put(key, Boolean.TRUE); EditorUtil.addWarningMarker(syncFile, message, 0); } } return false; } else if (trimmed.startsWith(ERROR)) { String message = trimmed.substring(ERROR.length(), trimmed.length()); if (null != syncFile) { String key = ERROR + syncFile.getName() + message; if (null == context.get(key)) { context.put(key, Boolean.TRUE); EditorUtil.addProblemMarker(syncFile, message, 0); } } return false; } else if (trimmed.startsWith(FATAL)) { String message = trimmed.substring(FATAL.length(), trimmed.length()); if (null != syncFile) { String key = FATAL + syncFile.getName() + message; if (null == context.get(key)) { context.put(key, Boolean.TRUE); EditorUtil.addProblemMarker(syncFile, message, 0); } } return true; } else { IFile file = project.getFile(location + "/" + name); if (!file.exists()) { StringTokenizer st = new StringTokenizer(location, "/"); StringBuffer sb = new StringBuffer(); while (st.hasMoreTokens()) { if (sb.length() > 0) sb.append('/'); sb.append(st.nextToken()); IFolder folder = project.getFolder(sb.toString()); if (!folder.exists()) folder.create(false, true, null); } file.create(new ByteArrayInputStream(sw.toString().getBytes()), (projectTemplate.shouldOverride() || force), null); } else { if (force || projectTemplate.shouldOverride()) { try { if (file.exists()) { String existingContent = HSUtil.getStringFromStream(file.getContents()); if (null != existingContent && existingContent.equals(sw.toString())) return false; } } catch (JavaModelException jme) { } file.setContents(new ByteArrayInputStream(sw.toString().getBytes()), (projectTemplate.shouldOverride() || force), false, null); } } } context.remove("path"); } } catch (Exception e) { MessageDialog.openWarning(null, "An error has occured while creating custom template: " + projectTemplate.getTemplate().getName(), e.getMessage()); } return false; }
From source file:com.ibm.developerworks.google.views.SearchView.java
public void createPartControl(Composite parent) { GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 3;//w w w .j a v a 2 s.co m gridLayout.marginHeight = 5; gridLayout.marginWidth = 5; parent.setLayout(gridLayout); Label searchLabel = new Label(parent, SWT.NONE); searchLabel.setText("Search:"); searchText = new Text(parent, SWT.BORDER); searchText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); Button searchButton = new Button(parent, SWT.PUSH); searchButton.setText(" Search "); searchButton.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { String licenseKey = LicenseKeyWizard.getLicenseKey(); if (licenseKey == null) { MessageDialog.openError(e.display.getActiveShell(), "License Key", "You must define a Google API license key."); return; } GoogleSearch search = new GoogleSearch(); search.setKey(licenseKey); search.setQueryString(searchText.getText()); try { GoogleSearchResult result = search.doSearch(); tableViewer.setInput(model); tableViewer.add(result.getResultElements()); } catch (GoogleSearchFault ex) { MessageDialog.openWarning(e.display.getActiveShell(), "Google Error", ex.getMessage()); } } public void widgetDefaultSelected(SelectionEvent e) { } }); GridData gridData = new GridData(); gridData.verticalAlignment = GridData.FILL; gridData.horizontalSpan = 3; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.horizontalAlignment = GridData.FILL; tableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER); tableViewer.setLabelProvider(new SearchViewLabelProvider()); tableViewer.setContentProvider(new ViewContentProvider()); tableViewer.setInput(model); tableViewer.getControl().setLayoutData(gridData); tableViewer.addDoubleClickListener(this); Table table = tableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); TableColumn titleColumn = new TableColumn(table, SWT.NONE); titleColumn.setText("Title"); titleColumn.setWidth(250); TableColumn urlColumn = new TableColumn(table, SWT.NONE); urlColumn.setText("URL"); urlColumn.setWidth(200); }
From source file:com.ibm.xsp.extlib.designer.bluemix.action.OpenAction.java
License:Open Source License
private void openInBrowser() { if (ToolbarAction.project != null) { // Check for a valid configuration BluemixConfig config = ConfigManager.getInstance().getConfig(ToolbarAction.project); if (config.isValid(true)) { if (StringUtil.isNotEmpty(config.uri)) { try { // Check is the user lanching an XPage if (StringUtil.isNotEmpty(ToolbarAction.xpage)) { // Yes - Adjust the URL BluemixUtil.openUrlInDefaultBrowser(new URL(config.uri + "/" + ToolbarAction.xpage)); } else { // No - Open the base URL BluemixUtil.openUrlInDefaultBrowser(new URL(config.uri)); }/*from ww w.j a v a 2 s. c o m*/ } catch (MalformedURLException e) { if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) { BluemixLogger.BLUEMIX_LOGGER.errorp(this, "openInBrowser", e, "URL is Malformed"); // $NON-NLS-1$ $NLE-OpenAction.URLisMalformed-2$ } } } else { MessageDialog.openWarning(null, "Open in Default System Browser", "This application has not been deployed or there is no route to it."); // $NLX-OpenAction.OpeninDefaultSystemBrowser.1-1$ $NLX-OpenAction.Thisapplicationhasnotbeendeployed-2$ } } else { MessageDialog.openWarning(null, "Open in Default System Browser", "This application is not configured for deployment."); // $NLX-OpenAction.OpeninDefaultSystemBrowser.1-1$ $NLX-OpenAction.Thisapplicationisnotconfiguredfor-2$ } } else { MessageDialog.openError(null, "Open in Default System Browser", "No application has been selected or the selected application is not open."); // $NLX-OpenAction.OpeninDefaultSystemBrowser.1-1$ $NLX-OpenAction.Noapplicationhasbeenselectedorthe-2$ } }
From source file:com.ibm.xsp.extlib.designer.bluemix.wizard.ConfigBluemixWizard.java
License:Open Source License
static public void launch() { // Check there's an open project if (ToolbarAction.project != null) { // Check that the Server details are configured if (BluemixUtil.isServerConfigured()) { // Check is the manifest open ManifestMultiPageEditor editor = BluemixUtil.getManifestEditor(ToolbarAction.project); if (editor != null) { MessageDialog.openWarning(null, _WIZARD_TITLE, "The Manifest for this application is open. You must close the Manifest before running the Configuration Wizard."); // $NLX-ConfigBluemixWizard.TheManifestforthisapplicat-1$ } else { // Launch the Bluemix Config Wizard ConfigBluemixWizard wiz = new ConfigBluemixWizard(); WizardDialog dialog = new WizardDialog(null, wiz); dialog.addPageChangingListener(wiz); dialog.open();/*from w ww. jav a2 s .c om*/ } } else { BluemixUtil.displayConfigureServerDialog(); } } else { MessageDialog.openError(null, _WIZARD_TITLE, "No application has been selected or the selected application is not open."); // $NLX-ConfigBluemixWizard.Noapplicationhasbeenselectedorthe-1$ } }
From source file:com.ibm.xsp.extlib.designer.tooling.palette.applicationlayout.AlwPropertiesPage.java
License:Open Source License
protected void saveData() { if (hasFooter()) { addFooterLinks();/*from ww w.java 2 s .c om*/ } Object o = _dynamicComposite.getData("pprops"); //$NON-NLS-1$ if (o instanceof PreservingProperties) { PreservingProperties pp = (PreservingProperties) o; if (pp.isDirty()) { if (_propsOpenInEditor) { MessageDialog.openWarning(getShell(), ProductUtil.getProductName(), "The Xsp Properties editor is currently open for editing. Therefore the application theme you specified will not be applied.\n\nPlease choose a theme in the Xsp Properties editor (General tab)."); // $NLX-ApplicationLayoutDropDialog.Youcannotchangetheapplicationtheme-1$ } else { pp.save(); } } } }
From source file:com.ibm.xsp.extlib.designer.tooling.palette.applicationlayout.ApplicationLayoutDropDialog.java
License:Open Source License
@Override protected boolean performDialogOperation(IProgressMonitor arg0) { if (hasFooter()) { addFooterLinks();/* ww w .ja v a 2s . c o m*/ } Object o = dynamicComposite.getData("pprops"); //$NON-NLS-1$ if (o instanceof PreservingProperties) { PreservingProperties pp = (PreservingProperties) o; if (pp.isDirty()) { if (propsOpenInEditor) { MessageDialog.openWarning(getShell(), "Domino Designer", // $NLX-ApplicationLayoutDropDialog.Dominodesigner-1$ "The Xsp Properties editor is currently open for editing. Therefore the application theme you specified will not be applied.\n\nPlease choose a theme in the Xsp Properties editor (General tab)."); // $NLX-ApplicationLayoutDropDialog.Youcannotchangetheapplicationtheme-1$ } else { pp.save(); } } } return true; }
From source file:com.iw.plugins.spindle.project.TapestryProject.java
License:Mozilla Public License
/** * @see com.iw.plugins.spindle.project.ITapestryProject#setProjectStorage(IStorage) *//*ww w. j a v a2 s . c o m*/ public void setProjectStorage(IStorage file) throws CoreException { projectResource = file; TapestryLookup lookup = getLookup(); IPackageFragment fragment = null; try { fragment = lookup.findPackageFragment(file); } catch (JavaModelException e) { } if (fragment == null) { MessageDialog.openWarning(TapestryPlugin.getDefault().getActiveWorkbenchShell(), "Spindle Warning", "The project Application/Library '" + projectResource.getFullPath().toString() + "'\nis located outside of the project classpath.\n You must move it back or Spindle will break."); } try { saveProperties(saveProjectResourcePathAsXML(projectResource)); } catch (IOException e) { SpindleStatus status = new SpindleStatus(e); status.setError("Could not save .spindle file"); throw new CoreException(status); } }
From source file:com.javadude.antlr3.visualizer.Log.java
License:Open Source License
/** * Log an error./*from w w w.j av a 2 s. c om*/ * @param message the message * @param throwable an optional exception */ public static void error(int code, final String message, Throwable throwable) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, code, message, throwable); Activator.getDefault().getLog().log(status); Display.getDefault().asyncExec(new Runnable() { public void run() { MessageDialog.openWarning(null, "Error: " + message, message); } }); }