List of usage examples for org.eclipse.jface.dialogs MessageDialog QUESTION
int QUESTION
To view the source code for org.eclipse.jface.dialogs MessageDialog QUESTION.
Click Source Link
From source file:net.sf.vex.editor.DocumentTypeSelectionDialog.java
License:Open Source License
/** * Class constructor.//from w w w. j a v a 2 s .c o m * @param parentShell Parent Shell with respect to which this dialog is modal. */ protected DocumentTypeSelectionDialog(Shell parentShell, String title, String message) { super(parentShell, title, null, message, MessageDialog.QUESTION, new String[] { Messages.getString("DocumentTypeSelectionDialog.ok"), //$NON-NLS-1$ Messages.getString("DocumentTypeSelectionDialog.cancel") }, //$NON-NLS-1$ 0); this.setShellStyle(SWT.RESIZE); }
From source file:net.sourceforge.eclipseccase.DialogMessageRunnable.java
License:Open Source License
public void run() { Shell activeShell = PlatformUI.getWorkbench().getDisplay().getActiveShell(); MessageDialog checkoutQuestion = new MessageDialog(activeShell, operationType, null, msg, MessageDialog.QUESTION, new String[] { "Yes", "No", "Cancel" }, 0); returnCode = checkoutQuestion.open(); }
From source file:net.tourbook.database.TourDatabase.java
License:Open Source License
/** * this must be implemented or updated when the database version must be updated */// w ww. j a v a 2s.c o m private boolean updateDbDesign(final Connection conn, int currentDbVersion, final IProgressMonitor monitor) { /* * confirm update */ // define buttons with default to NO final String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }; if ((new MessageDialog(Display.getDefault().getActiveShell(), Messages.Database_Confirm_update_title, null, NLS.bind(Messages.Database_Confirm_update, new Object[] { currentDbVersion, TOURBOOK_DB_VERSION, _databasePath }), MessageDialog.QUESTION, buttons, 1).open()) != Window.OK) { // no update -> close application PlatformUI.getWorkbench().close(); return false; } /* * do an additional check because version 20 is restructuring the data series */ if (currentDbVersion < 20) { if ((new MessageDialog(Display.getDefault().getActiveShell(), Messages.Database_Confirm_update_title, null, NLS.bind(Messages.Database_Confirm_Update20, _databasePath), MessageDialog.QUESTION, buttons, 1).open()) != Window.OK) { // no update -> close application PlatformUI.getWorkbench().close(); return false; } } int newVersion = currentDbVersion; final int oldVersion = currentDbVersion; /* * database update */ try { if (currentDbVersion == 1) { updateDbDesign_001_002(conn); currentDbVersion = newVersion = 2; } if (currentDbVersion == 2) { updateDbDesign_002_003(conn); currentDbVersion = newVersion = 3; } if (currentDbVersion == 3) { updateDbDesign_003_004(conn, monitor); currentDbVersion = newVersion = 4; } boolean isPostUpdate5 = false; if (currentDbVersion == 4) { updateDbDesign_004_005(conn, monitor); currentDbVersion = newVersion = 5; isPostUpdate5 = true; } if (currentDbVersion == 5) { updateDbDesign_005_006(conn, monitor); currentDbVersion = newVersion = 6; } if (currentDbVersion == 6) { updateDbDesign_006_007(conn, monitor); currentDbVersion = newVersion = 7; } if (currentDbVersion == 7) { updateDbDesign_007_008(conn, monitor); currentDbVersion = newVersion = 8; } boolean isPostUpdate9 = false; if (currentDbVersion == 8) { updateDbDesign_008_009(conn, monitor); currentDbVersion = newVersion = 9; isPostUpdate9 = true; } if (currentDbVersion == 9) { updateDbDesign_009_010(conn, monitor); currentDbVersion = newVersion = 10; } boolean isPostUpdate11 = false; if (currentDbVersion == 10) { currentDbVersion = newVersion = updateDbDesign_010_011(conn, monitor); isPostUpdate11 = true; } if (currentDbVersion == 11) { currentDbVersion = newVersion = updateDbDesign_011_012(conn, monitor); } boolean isPostUpdate13 = false; if (currentDbVersion == 12) { currentDbVersion = newVersion = updateDbDesign_012_013(conn, monitor); isPostUpdate13 = true; } if (currentDbVersion == 13) { currentDbVersion = newVersion = updateDbDesign_013_014(conn, monitor); } if (currentDbVersion == 14) { currentDbVersion = newVersion = updateDbDesign_014_015(conn, monitor); } if (currentDbVersion == 15) { currentDbVersion = newVersion = updateDbDesign_015_to_016(conn, monitor); } if (currentDbVersion == 16) { currentDbVersion = newVersion = updateDbDesign_016_to_017(conn, monitor); } if (currentDbVersion == 17) { currentDbVersion = newVersion = updateDbDesign_017_to_018(conn, monitor); } if (currentDbVersion == 18) { currentDbVersion = newVersion = updateDbDesign_018_to_019(conn, monitor); } boolean isPostUpdate20 = false; if (currentDbVersion == 19) { currentDbVersion = newVersion = updateDbDesign_019_to_020(conn, monitor); isPostUpdate20 = true; } /* * 21 */ if (currentDbVersion == 20) { currentDbVersion = newVersion = updateDbDesign_020_to_021(conn, monitor); } /* * 22 */ boolean isPostUpdate22 = false; if (currentDbVersion == 21) { currentDbVersion = newVersion = updateDbDesign_021_to_022(conn, monitor); isPostUpdate22 = true; } /* * 23 */ boolean isPostUpdate23 = false; if (currentDbVersion == 22) { currentDbVersion = newVersion = updateDbDesign_022_to_023(conn, monitor); isPostUpdate23 = true; } /* * 24 */ if (currentDbVersion == 23) { currentDbVersion = newVersion = updateDbDesign_023_to_024(conn, monitor); } /* * 24 -> 25 */ boolean isPostUpdate25 = false; if (currentDbVersion == 24) { isPostUpdate25 = true; currentDbVersion = newVersion = updateDbDesign_024_to_025(conn, monitor); } /* * 25 -> 26 */ if (currentDbVersion == 25) { currentDbVersion = newVersion = updateDbDesign_025_to_026(conn, monitor); } /* * 26 -> 27 */ if (currentDbVersion == 26) { currentDbVersion = newVersion = updateDbDesign_026_to_027(conn, monitor); } /* * 27 -> 28 */ boolean isPostUpdate28 = false; if (currentDbVersion == 27) { isPostUpdate28 = true; currentDbVersion = newVersion = updateDbDesign_027_to_028(conn, monitor); } /* * 28 -> 29 */ boolean isPostUpdate29 = false; if (currentDbVersion == 28) { isPostUpdate29 = true; currentDbVersion = newVersion = updateDbDesign_028_to_029(conn, monitor); } /* * 29 -> 30 */ if (currentDbVersion == 29) { currentDbVersion = newVersion = updateDbDesign_029_to_030(conn, monitor); } /* * 30 -> 31 */ if (currentDbVersion == 30) { currentDbVersion = newVersion = updateDbDesign_030_to_031(conn, monitor); } /* * 31 -> 32 */ boolean isPostUpdate32 = false; if (currentDbVersion == 31) { isPostUpdate32 = true; currentDbVersion = newVersion = updateDbDesign_031_to_032(conn, monitor); } /* * update version number */ updateDbDesign_VersionNumber(conn, newVersion); /** * Do post update after the version number is updated because the post update uses * connections and entitymanager which is checking the version number. * <p> * Also the data structure must be updated otherwise the entity manager fails because * the data structure in the programm code MUST be the same as in the database. */ if (isPostUpdate5) { TourDatabase.computeComputedValuesForAllTours(monitor); TourManager.getInstance().removeAllToursFromCache(); } if (isPostUpdate9) { updateDbDesign_008_009_PostUpdate(conn, monitor); } if (isPostUpdate11) { updateDbDesign_010_011_PostUpdate(conn, monitor); } if (isPostUpdate13) { updateDbDesign_012_013_PostUpdate(conn, monitor); } if (isPostUpdate20) { updateDbDesign_019_to_020_PostUpdate(conn, monitor); } if (isPostUpdate22) { updateDbDesign_021_to_022_PostUpdate(conn, monitor); } if (isPostUpdate23) { updateDbDesign_022_to_023_PostUpdate(conn, monitor); } if (isPostUpdate25) { updateDbDesign_024_to_025_PostUpdate(conn, monitor); } if (isPostUpdate28) { updateDbDesign_027_to_028_PostUpdate(conn, monitor); } if (isPostUpdate29) { updateDbDesign_028_to_029_PostUpdate(conn, monitor); } if (isPostUpdate32) { updateDbDesign_031_to_032_PostUpdate(conn, monitor); } } catch (final SQLException e) { UI.showSQLException(e); _isSQLUpdateError = true; return false; } // display info for the successful update MessageDialog.openInformation(Display.getCurrent().getActiveShell(), Messages.tour_database_version_info_title, NLS.bind(Messages.Tour_Database_UpdateInfo, oldVersion, newVersion)); return true; }
From source file:net.tourbook.importdata.RawDataManager.java
License:Open Source License
private String importRawData_20_CopyFile(final TourbookDevice device, final String sourceFileName, final String destinationPath, final boolean buildNewFileName, final FileCollisionBehavior fileCollision) { String destFileName = new File(sourceFileName).getName(); if (buildNewFileName) { destFileName = null;//from w ww . j av a 2 s. co m try { destFileName = device.buildFileNameFromRawData(sourceFileName); } catch (final Exception e) { TourLogManager.logEx(e); } finally { if (destFileName == null) { MessageDialog .openError(Display.getDefault().getActiveShell(), Messages.Import_Data_Error_CreatingFileName_Title, NLS.bind(Messages.Import_Data_Error_CreatingFileName_Message, // new Object[] { sourceFileName, new org.eclipse.core.runtime.Path(destinationPath) .addTrailingSeparator().toString(), TEMP_IMPORTED_FILE })); destFileName = TEMP_IMPORTED_FILE; } } } final File newFile = new File( (new org.eclipse.core.runtime.Path(destinationPath).addTrailingSeparator().toString() + destFileName)); // get source file final File fileIn = new File(sourceFileName); // check if file already exist if (newFile.exists()) { // TODO allow user to rename the file boolean keepFile = false; // for MessageDialog result if (fileCollision.value == FileCollisionBehavior.ASK) { final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final MessageDialog messageDialog = new MessageDialog(shell, Messages.Import_Wizard_Message_Title, null, NLS.bind(Messages.Import_Wizard_Message_replace_existing_file, newFile), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL }, 0); messageDialog.open(); final int returnCode = messageDialog.getReturnCode(); switch (returnCode) { case 1: // YES_TO_ALL fileCollision.value = FileCollisionBehavior.REPLACE; break; case 3: // NO_TO_ALL fileCollision.value = FileCollisionBehavior.KEEP; case 2: // NO keepFile = true; break; default: break; } } if (fileCollision.value == FileCollisionBehavior.KEEP || keepFile) { _isImportCanceled = true; fileIn.delete(); return null; } } // copy source file into destination file FileInputStream inReader = null; FileOutputStream outReader = null; try { inReader = new FileInputStream(fileIn); outReader = new FileOutputStream(newFile); int c; while ((c = inReader.read()) != -1) { outReader.write(c); } inReader.close(); outReader.close(); } catch (final FileNotFoundException e) { TourLogManager.logEx(e); return null; } catch (final IOException e) { TourLogManager.logEx(e); return null; } finally { // close the files if (inReader != null) { try { inReader.close(); } catch (final IOException e) { TourLogManager.logEx(e); return null; } } if (outReader != null) { try { outReader.close(); } catch (final IOException e) { TourLogManager.logEx(e); return null; } } } // delete source file fileIn.delete(); return newFile.getAbsolutePath(); }
From source file:net.tourbook.photo.ImageGallery.java
License:Open Source License
public void handlePrefStoreModifications(final PropertyChangeEvent event) { final String property = event.getProperty(); if (property.equals(IPhotoPreferences.PHOTO_VIEWER_PREF_EVENT_IMAGE_QUALITY_IS_MODIFIED)) { _display.asyncExec(new Runnable() { @Override/*from w w w . j a v a 2s . c om*/ public void run() { final MessageDialog messageDialog = new MessageDialog(_display.getActiveShell(), Messages.Pic_Dir_Dialog_CleanupStoreImages_Title, null, Messages.Pic_Dir_Dialog_CleanupStoreImages_Message, MessageDialog.QUESTION, new String[] { Messages.Pic_Dir_Dialog_CleanupStoreImages_KeepImages, Messages.Pic_Dir_Dialog_CleanupStoreImages_DiscardImages }, 0); if (messageDialog.open() == 1) { // discard all imaged disposeAndDeleteAllImages(); } _galleryMT20.updateGallery(false, _galleryMT20.getGalleryPosition()); if (_galleryActionBar != null) { _galleryActionBar.updateUI_ImageIndicatorTooltip(); } } }); } else if (property.equals(IPhotoPreferences.PHOTO_VIEWER_PREF_EVENT_IMAGE_VIEWER_UI_IS_MODIFIED) || property.equals(IPhotoPreferences.PHOTO_VIEWER_PREF_EVENT_FULLSIZE_VIEWER_IS_MODIFIED)) { updateUI_FromPrefStore(true); updateUI_AfterZoomInOut(_galleryMT20.getItemWidth()); } else if (property.equals(IPhotoPreferences.PHOTO_VIEWER_FONT)) { onModifyFont(); } }
From source file:net.tourbook.preferences.PrefPageTags.java
License:Open Source License
private void onReset() { final MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), Messages.pref_tourtag_dlg_reset_title, null, Messages.pref_tourtag_dlg_reset_message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); if (dialog.open() != Window.OK) { setFocusToViewer();//from w w w. j av a 2 s. co m return; } try { System.out.println("RESET TAG STRUCTURE"); //$NON-NLS-1$ final StringBuilder sb = new StringBuilder(); final Connection conn = TourDatabase.getInstance().getConnection(); /* * remove join table tag->category */ sb.append("DELETE FROM "); //$NON-NLS-1$ sb.append(TourDatabase.JOINTABLE__TOURTAGCATEGORY_TOURTAG); int result = conn.createStatement().executeUpdate(sb.toString()); System.out.println("Deleted " //$NON-NLS-1$ + result + " entries from " //$NON-NLS-1$ + TourDatabase.JOINTABLE__TOURTAGCATEGORY_TOURTAG); /* * remove jointable category<->category */ sb.setLength(0); sb.append("DELETE FROM "); //$NON-NLS-1$ sb.append(TourDatabase.JOINTABLE__TOURTAGCATEGORY_TOURTAGCATEGORY); result = conn.createStatement().executeUpdate(sb.toString()); System.out.println("Deleted " //$NON-NLS-1$ + result + " entries from " //$NON-NLS-1$ + TourDatabase.JOINTABLE__TOURTAGCATEGORY_TOURTAGCATEGORY); /* * set tags to root */ sb.setLength(0); sb.append("UPDATE "); //$NON-NLS-1$ sb.append(TourDatabase.TABLE_TOUR_TAG); sb.append(" SET isRoot=1"); //$NON-NLS-1$ result = conn.createStatement().executeUpdate(sb.toString()); System.out.println("Set " + result + " tour tags to root"); //$NON-NLS-1$ //$NON-NLS-2$ /* * set categories to root */ sb.setLength(0); sb.append("UPDATE "); //$NON-NLS-1$ sb.append(TourDatabase.TABLE_TOUR_TAG_CATEGORY); sb.append(" SET isRoot=1"); //$NON-NLS-1$ result = conn.createStatement().executeUpdate(sb.toString()); System.out.println("Set " + result + " tour categories to root"); //$NON-NLS-1$ //$NON-NLS-2$ conn.close(); // update the tag viewer _rootItem = new TVIPrefTagRoot(_tagViewer); updateTagViewer(); _isModified = true; } catch (final SQLException e) { UI.showSQLException(e); } setFocusToViewer(); }
From source file:net.tourbook.preferences.PrefPageTourTypes.java
License:Open Source License
private void onDeleteTourType() { final TourTypeColorDefinition selectedColorDefinition = getSelectedColorDefinition(); final TourType selectedTourType = selectedColorDefinition.getTourType(); // confirm deletion final String[] buttons = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }; final MessageDialog dialog = new MessageDialog(this.getShell(), Messages.Pref_TourTypes_Dlg_delete_tour_type_title, null, NLS.bind(Messages.Pref_TourTypes_Dlg_delete_tour_type_msg, selectedTourType.getName()), MessageDialog.QUESTION, buttons, 1); if (dialog.open() != Window.OK) { setFocusToViewer();/* w w w. j a v a2 s .c o m*/ return; } // remove entity from the db if (deleteTourType(selectedTourType)) { // update model _dbTourTypes.remove(selectedTourType); _colorDefinitions.remove(selectedColorDefinition); // update UI _tourTypeViewer.remove(selectedColorDefinition); _isModified = true; } setFocusToViewer(); }
From source file:net.tourbook.ui.UI.java
License:Open Source License
/** * @param file/*from w ww . j a va 2 s .c om*/ * @return Returns <code>true</code> when the file should be overwritten, otherwise * <code>false</code> */ public static boolean confirmOverwrite(final File file) { final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final MessageDialog dialog = new MessageDialog(// shell, Messages.app_dlg_confirmFileOverwrite_title, null, NLS.bind(Messages.app_dlg_confirmFileOverwrite_message, file.getPath()), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0); dialog.open(); return dialog.getReturnCode() == 0; }
From source file:net.tourbook.ui.UI.java
License:Open Source License
public static boolean confirmOverwrite(final FileCollisionBehavior fileCollision, final File file) { final boolean[] isOverwrite = { false }; final int fileCollisionValue = fileCollision.value; if (fileCollisionValue == FileCollisionBehavior.REPLACE_ALL) { // overwrite is already confirmed isOverwrite[0] = true;//from www . jav a 2 s. co m } else if (fileCollisionValue == FileCollisionBehavior.ASK || fileCollisionValue == FileCollisionBehavior.REPLACE || fileCollisionValue == FileCollisionBehavior.KEEP) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { final Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); final MessageDialog dialog = new MessageDialog(// shell, Messages.app_dlg_confirmFileOverwrite_title, null, NLS.bind(Messages.app_dlg_confirmFileOverwrite_message, file.getPath()), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.NO_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }, 0); dialog.open(); final int returnCode = dialog.getReturnCode(); switch (returnCode) { case -1: // dialog was canceled case 4: fileCollision.value = FileCollisionBehavior.DIALOG_IS_CANCELED; break; case 0: // YES fileCollision.value = FileCollisionBehavior.REPLACE; isOverwrite[0] = true; break; case 1: // YES_TO_ALL fileCollision.value = FileCollisionBehavior.REPLACE_ALL; isOverwrite[0] = true; break; case 2: // NO fileCollision.value = FileCollisionBehavior.KEEP; break; case 3: // NO_TO_ALL fileCollision.value = FileCollisionBehavior.KEEP_ALL; break; default: break; } } }); } return isOverwrite[0]; }
From source file:net.tourbook.ui.views.tourDataEditor.TourDataEditorView.java
License:Open Source License
/** * @return Returns <code>true</code> when the tour should be discarded<br> * returns <code>false</code> when the tour is invalid but should be saved<br> *//* w ww . ja va 2s . com*/ private boolean isDiscardTour() { final MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), Messages.tour_editor_dlg_save_tour_title, null, NLS.bind(Messages.tour_editor_dlg_save_invalid_tour, TourManager.getTourDateFull(_tourData)), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 1); final int result = dialog.open(); if (result == 0) { // discard modifications return true; } else { // save modifications return false; } }