List of usage examples for org.eclipse.jface.dialogs MessageDialog ERROR
int ERROR
To view the source code for org.eclipse.jface.dialogs MessageDialog ERROR.
Click Source Link
From source file:net.bpelunit.toolsupport.editors.BPELUnitEditor.java
License:Open Source License
public Definition getWsdlForFile(String wsdl) throws WSDLReadingException { IPath path = new Path(wsdl); IResource resource = null;/* w w w . j a v a 2s . co m*/ // try to find from current dir: resource = this.getCurrentDirectory().findMember(wsdl); // try to find from project dir: if (this.notFound(resource)) { resource = this.getCurrentProject().findMember(path); } if (this.notFound(resource)) { resource = ResourcesPlugin.getWorkspace().getRoot().findMember(path); } // all hope failed... if (this.notFound(resource)) { throw new WSDLReadingException("Cannot find WSDL file with file path " + wsdl); } IFile file = (IFile) resource; // TODO caching probably NOT a good idea at all. Definition definition = this.fWSDLDefinitions.get(file); if (definition == null) { String fileName = file.getRawLocation().toFile().toString(); // load WSDL try { WSDLFactory factory = WSDLFactory.newInstance(); WSDLReader reader = factory.newWSDLReader(); // reader.setFeature(Constants.FEATURE_VERBOSE, false); definition = reader.readWSDL(null, fileName); this.fWSDLDefinitions.put(file, definition); WSDLParser parser = new WSDLParser(definition); this.fWSDLParser.put(definition, parser); } catch (WSDLException e) { throw new WSDLReadingException("Error loading WSDL file for partner", e); } catch (SAXException e) { MessageDialog dialog = new MessageDialog(this.getShell(), "Invalid Schema", null, e.getMessage(), MessageDialog.ERROR, new String[] { "OK" }, 0); dialog.open(); throw new WSDLReadingException("Error reading Schemata in WSDL: " + e.getMessage(), e); } catch (TransformerException e) { MessageDialog dialog = new MessageDialog(this.getShell(), "Invalid Schema", null, e.getMessage(), MessageDialog.ERROR, new String[] { "OK" }, 0); dialog.open(); throw new WSDLReadingException("Error reading Schemata in WSDL: " + e.getMessage(), e); } } return definition; }
From source file:net.leboxondelex.daplomb.utils.Utils.java
License:Open Source License
/** * Opens an error dialog with a the inner i18n system. * @param parent/*from w w w . j av a 2 s .c o m*/ * @param title * @param message */ public static void showError(Shell parent, String title, String message) { MessageDialog dialog = new MessageDialog(parent, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 0); dialog.open(); }
From source file:net.refractions.udig.ui.ZoomingDialog.java
License:Open Source License
public static void openErrorMessage(Rectangle start, Shell parentShell, String dialogTitle, String dialogMessage) {/*from w w w . j av a 2 s. c o m*/ openMessageDialog(start, parentShell, dialogTitle, null, dialogMessage, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 1); }
From source file:net.sf.eclipsensis.util.Common.java
License:Open Source License
public static void openError(Shell parent, String title, String message, Image icon) { MessageDialog dialog = new MessageDialog(parent, title, icon, message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); dialog.open();//from w w w . j a v a 2 s . c o m }
From source file:net.sf.freeqda.common.handler.LoadProjectHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell(); //TODO check for active project and close if exists // File standard dialog FileDialog fileDialog = new FileDialog(shell, SWT.OPEN); // Initialise the dialog fileDialog.setText(DIALOG_TEXT);//w w w .j ava 2 s .c o m fileDialog.setFilterNames(new String[] { MessageFormat.format(Messages.LoadProjectHandler_Filter_FQDAProjects, new Object[] { SUFFIX_FQDA_PROJECTS }), MessageFormat.format(Messages.LoadProjectHandler_Filter_AllFiles, new Object[] { SUFFIX_ALL_FILES }) }); fileDialog.setFilterExtensions(new String[] { SUFFIX_FQDA_PROJECTS, SUFFIX_ALL_FILES }); //TODO create platform dependent wildcards! // Open Dialog and save result of selection String selected = fileDialog.open(); /* * Check if dialog has been canceled */ if (selected == null) { new MessageDialog(shell, DIALOG_LOAD_CANCELED_TITLE, null, DIALOG_LOAD_CANCELED_MESSAGE, MessageDialog.WARNING, new String[] { DIALOG_LOAD_CANCELED_BUTTONS }, 0).open(); return null; } /* * Load selected project file */ try { ProjectManager.getInstance().load(new File(selected)); new MessageDialog(shell, DIALOG_PROJECT_LOADED_TITLE, null, MessageFormat.format(Messages.LoadProjectHandler_DialogProjectLoaded_Message, new Object[] { selected }), MessageDialog.INFORMATION, new String[] { DIALOG_PROJECT_LOADED_BUTTONS }, 0).open(); } catch (IOException e) { new MessageDialog(shell, DIALOG_LOADING_FAILED_TITLE, null, MessageFormat.format(Messages.LoadProjectHandler_DialogProjectLoadingFailed_Message, new Object[] { selected }), MessageDialog.ERROR, new String[] { DIALOG_LOADING_FAILED_BUTTONS }, 0).open(); e.printStackTrace(); } return null; }
From source file:net.sf.freeqda.common.handler.SaveProjectHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell(); /*//from w w w . jav a 2 s . c om * Load selected project file */ try { /* * Save project data */ JAXBUtils.saveProject(PM.getProjectFile()); ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(shell); /* * Save dirty editors */ for (IEditorPart editor : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getDirtyEditors()) { if (editor instanceof StyledEditor) { StyledEditor styledEditor = (StyledEditor) editor; styledEditor.doSave(progressMonitor.getProgressMonitor()); } else if (editor instanceof TaggedPassagesEditor) { TaggedPassagesEditor taggedPassagesEditor = (TaggedPassagesEditor) editor; taggedPassagesEditor.doSave(progressMonitor.getProgressMonitor()); } else { new MessageDialog(shell, SAVE_PROJECT_UNHANDLED_TITLE, null, SAVE_PROJECT_UNHANDLED_MESSAGE, MessageDialog.ERROR, new String[] { SAVE_PROJECT_UNHANDLED_BUTTON_CONFIRM }, 0).open(); } } new MessageDialog(shell, SAVE_PROJECT_SUCCESS_TITLE, null, SAVE_PROJECT_SUCCESS_MESSAGE, MessageDialog.INFORMATION, new String[] { SAVE_PROJECT_SUCCESS_BUTTON_CONFIRM }, 0).open(); } catch (IOException e) { new MessageDialog(shell, SAVE_PROJECT_FAILED_TITLE, null, MessageFormat.format(Messages.SaveProjectHandler_SaveProjectFailed_Message, new Object[] { PM.getProjectFile().getAbsolutePath() }), MessageDialog.ERROR, new String[] { SAVE_PROJECT_FAILED_BUTTON_CONFIRM }, 0).open(); e.printStackTrace(); } return null; }
From source file:net.sf.jmoney.copier.actions.CutSessionAction.java
License:Open Source License
/** * The action has been activated. The argument of the * method represents the 'real' action sitting * in the workbench UI.// w ww .ja v a2 s.c o m * @see IWorkbenchWindowActionDelegate#run */ public void run(IAction action) { DatastoreManager sessionManager = JMoneyPlugin.getDefault().getSessionManager(); if (sessionManager == null) { MessageDialog waitDialog = new MessageDialog(window.getShell(), "Menu item unavailable", null, // accept the default window icon "No session is open. " + "This action is used to copy session data from one session to another. " + "You must first use this action to save the contents of the current session. " + "You must then open another session and then select the 'Paste Contents' action. " + "The contents of the session will then be copied into the new session.", MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); waitDialog.open(); return; } // We call canClose now so that we are sure // that we can later close the session without // further user input. If the user does not // provide at this time all the information required // to close the session then we terminate the operation // now. if (!sessionManager.canClose(window)) { return; } // Save the session in a static location. // The session is left open so that we can // later read the data from it. CopierPlugin.setSessionManager(sessionManager); /* * Close this window but leave the session open. * * This ensures that the session cannot be closed before * it is pasted into the new location. */ // TODO: There is a problem with this. If the session is // never pasted then it is never closed. Better may be to // leave the window open, requiring the user to create a // target session in another window, and giving an error if // a paste is done after the source session was closed. try { window.getActivePage().close(); window.openPage(null); } catch (WorkbenchException e) { // TODO: Uncomment this when this becomes a handler // throw new ExecutionException("Workbench exception occured while closing window.", e); //$NON-NLS-1$ } }
From source file:net.sf.jmoney.copier.actions.PasteContentsAction.java
License:Open Source License
/** * The action has been activated. The argument of the * method represents the 'real' action sitting * in the workbench UI./*from w w w. j a va 2 s . c om*/ * @see IWorkbenchWindowActionDelegate#run */ public void run(IAction action) { DatastoreManager destinationSessionManager = JMoneyPlugin.getDefault().getSessionManager(); if (destinationSessionManager == null) { MessageDialog waitDialog = new MessageDialog(window.getShell(), "Menu item unavailable", null, // accept the default window icon "No session is open. " + "This action is used to copy session data from one session to another. " + "You must open a new session into which the session contents can be copied.", MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); waitDialog.open(); return; } DatastoreManager sourceSessionManager = CopierPlugin.getSessionManager(); if (sourceSessionManager == null) { MessageDialog waitDialog = new MessageDialog(window.getShell(), "Menu item unavailable", null, // accept the default window icon "No session has been cut. " + "Before using this action, you must first use the 'Cut Session' action " + "while the source session is open.", MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); waitDialog.open(); return; } // Copy the data across. CopierPlugin.getDefault().populateSession(destinationSessionManager.getSession(), sourceSessionManager.getSession()); // Confirm copy. }
From source file:net.sf.jmoney.entrytable.BaseEntryRowControl.java
License:Open Source License
/** * Validate the changes made by the user to this row and, if they are valid, * commit them./*w w w. j av a 2 s . c o m*/ * <P> * The changes may not be committed for a number of reasons. Perhaps they * did not meet the restrictions imposed by a validating listener, or * perhaps the user responded to a dialog in a way that indicated that the * changes should not be committed. * <P> * If false is returned then the caller should not move the selection off * this row. * * @return true if the changes are either valid and were committed or were * discarded by the user, false if the changes were neither committed * nor discarded (and thus remain outstanding) */ public boolean commitChanges(String transactionLabel) { // If changes have been made then check they are valid and ask // the user if the changes should be committed. if (transactionManager.hasChanges()) { // Validate the transaction. // TODO: itemWithError is not actually used. See if there is an // easy way of accessing the relevant controls. Otherwise we should // delete this. try { baseValidation(uncommittedEntryData.getEntry().getTransaction()); // Do any specific processing in derived classes. specificValidation(); } catch (InvalidUserEntryException e) { MessageDialog dialog = new MessageDialog(getShell(), Messages.BaseEntryRowControl_ErrorTitle, null, // accept the default window icon e.getLocalizedMessage(), MessageDialog.ERROR, new String[] { Messages.BaseEntryRowControl_Discard, IDialogConstants.CANCEL_LABEL }, 1); int result = dialog.open(); if (result == 0) { // Discard // TODO: Some of this code is duplicated below. transactionManager = new TransactionManager(committedEntryData.getBaseSessionManager()); Entry entryInTransaction; if (committedEntryData.getEntry() == null) { Transaction newTransaction = transactionManager.getSession().createTransaction(); entryInTransaction = createNewEntry(newTransaction); } else { entryInTransaction = transactionManager.getCopyInTransaction(committedEntryData.getEntry()); } // Update the controls. /* * We create a new EntryData object. This is important so * that we start over with the 'fluid' fields and other * stuff. These are reset when we set the input. We reset * the input to the same value to get the 'fluid' fields * reset. We are re-using the objects for the new entry, but * if fields have been set to be not fluid then we must * ensure they are fluid again. Without this calculated * values are not being calculated. */ uncommittedEntryData = createUncommittedEntryData(entryInTransaction, transactionManager); uncommittedEntryData.setIndex(committedEntryData.getIndex()); uncommittedEntryData.setBalance(committedEntryData.getBalance()); for (final IPropertyControl<? super T> control : controls.values()) { control.load(uncommittedEntryData); } this.setInput(uncommittedEntryData); return true; } else { // Cancel the selection change if (e.getItemWithError() != null) { e.getItemWithError().setFocus(); } return false; } } // Commit the changes to the transaction transactionManager.commit(transactionLabel); // Sound the tone // clip.play(); /* * It may be that this was a new entry not previously committed. If * so, the committed entry in the EntryData object will be null. In * this case we now clear out the controls so that it is ready for * the next new transaction. (A new row will have been created for * the new entry that we have just committed because the table is * listening for new entries). * * This listener should also have caused the balance for the new * entry row to be updated. */ if (committedEntryData.getEntry() == null) { Transaction newTransaction = transactionManager.getSession().createTransaction(); Entry entryInTransaction = createNewEntry(newTransaction); // Update the controls. uncommittedEntryData = createUncommittedEntryData(entryInTransaction, transactionManager); uncommittedEntryData.setIndex(committedEntryData.getIndex()); uncommittedEntryData.setBalance(committedEntryData.getBalance()); // Load all top level controls with this data. for (final IPropertyControl<? super T> control : controls.values()) { control.load(uncommittedEntryData); } } } return true; }
From source file:net.sf.jmoney.jdbcdatastore.JDBCDatastorePlugin.java
License:Open Source License
/** * @param window//from w ww . j a va 2s. c o m * @return */ public SessionManager readSession(IWorkbenchWindow window) { SessionManager result = null; // The following lines cannot return a null value because if // no value is set then the default value set in // the above initializeDefaultPreferences method will be returned. String driver = getPreferenceStore().getString("driver"); String subprotocol = getPreferenceStore().getString("subProtocol"); String subprotocolData = getPreferenceStore().getString("subProtocolData"); String url = "jdbc:" + subprotocol + ":" + subprotocolData; String user = getPreferenceStore().getString("user"); String password = getPreferenceStore().getString("password"); if (getPreferenceStore().getBoolean("promptEachTime")) { // TODO: Put up a dialog box so the user can change // the connection options for this connection only. } try { Class.forName(driver).newInstance(); } catch (InstantiationException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } catch (IllegalAccessException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } catch (ClassNotFoundException e2) { String title = JDBCDatastorePlugin.getResourceString("errorTitle"); String message = JDBCDatastorePlugin.getResourceString("driverNotFound"); MessageDialog waitDialog = new MessageDialog(window.getShell(), title, null, // accept the default window icon message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); waitDialog.open(); return null; } try { result = new SessionManager(url, user, password); } catch (SQLException e3) { if (e3.getSQLState().equals("08000")) { // A connection error which means the database server is probably not running. String title = JDBCDatastorePlugin.getResourceString("errorTitle"); String message = JDBCDatastorePlugin.getResourceString("connectionFailed") + e3.getMessage() + " Check that the database server is running."; MessageDialog waitDialog = new MessageDialog(window.getShell(), title, null, // accept the default window icon message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); waitDialog.open(); } else if (e3.getSQLState().equals("S1000")) { // The most likely cause of this error state is that the database is not attached. String title = JDBCDatastorePlugin.getResourceString("errorTitle"); String message = e3.getMessage() + " " + JDBCDatastorePlugin.getResourceString("databaseNotFound"); MessageDialog waitDialog = new MessageDialog(window.getShell(), title, null, // accept the default window icon message, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); waitDialog.open(); } else { throw new RuntimeException(e3); } } return result; }