List of usage examples for org.eclipse.jface.dialogs MessageDialog openConfirm
public static boolean openConfirm(Shell parent, String title, String message)
From source file:au.gov.ansto.bragg.kakadu.ui.util.KakaduDOM.java
License:Open Source License
/** * Open a confirm dialog window and receive boolean value. * @param messageText String text/*ww w . ja v a 2s. com*/ * @return boolean type * Created on 07/03/2008 */ public boolean confirm(final String messageText) { final String title = "Confirm"; // final IWorkbench workbench = PlatformUI.getWorkbench(); // final IWorkbenchWindow workbenchWindow = workbench // .getActiveWorkbenchWindow(); activePage.getWorkbenchWindow().getWorkbench().getDisplay().syncExec(new Runnable() { public void run() { // TODO Auto-generated method stub isConfirm = MessageDialog.openConfirm(activePage.getWorkbenchWindow().getShell(), title, messageText); } }); return isConfirm; }
From source file:au.gov.ansto.bragg.kakadu.ui.util.Util.java
License:Open Source License
public static String saveFilenameFromShell(Shell shell, String initName, String extensionName, String fileDescription) { // File currentDir = new File ("."); String fileFilterPath = null; if (currentSavingDir == defaultDir && currentSavingDir != currentDir) currentSavingDir = currentDir;/*from w w w . j a va 2 s. c om*/ try { fileFilterPath = currentSavingDir.getCanonicalPath();// + "\\.."; } catch (Exception e) { e.printStackTrace(); } FileDialog fileDialog = new FileDialog(shell, SWT.SAVE); fileDialog.setFilterPath(fileFilterPath); fileDialog.setFilterExtensions(new String[] { extensionName, "*.*" }); fileDialog.setFilterNames(new String[] { fileDescription, "Any" }); fileDialog.setFileName(initName); while (true) { String firstFileName = fileDialog.open(); if (firstFileName != null) { final File file = new File(firstFileName); if (!file.exists() || MessageDialog.openConfirm(shell, "File exists", "File '" + firstFileName + "' already exists, override?")) { currentSavingDir = file.getParentFile(); currentDir = currentSavingDir; return firstFileName; } } else { return null; } } }
From source file:au.gov.ansto.bragg.kakadu.ui.util.Util.java
License:Open Source License
public static String saveFilenameFromShell(Shell shell, String extensionName, String fileDescription, File dir) {// w ww . j av a2 s.co m // File currentDir = new File ("."); String fileFilterPath = null; try { fileFilterPath = dir.getCanonicalPath();// + "\\.."; } catch (Exception e) { e.printStackTrace(); } FileDialog fileDialog = new FileDialog(shell, SWT.SAVE); fileDialog.setFilterPath(fileFilterPath); fileDialog.setFilterExtensions(new String[] { "*." + extensionName, "*.*" }); fileDialog.setFilterNames(new String[] { fileDescription, "Any" }); while (true) { String firstFileName = fileDialog.open(); if (firstFileName != null) { final File file = new File(firstFileName); if (!file.exists() || MessageDialog.openConfirm(shell, "File exists", "File '" + firstFileName + "' already exists, override?")) { currentSavingDir = file.getParentFile(); currentDir = currentSavingDir; return firstFileName; } } else { return null; } } }
From source file:au.gov.ansto.bragg.kakadu.ui.util.Util.java
License:Open Source License
/** * Gets file name of specified type /* w w w. j ava2s. c o m*/ * @param shell shell reference * @param extensionNames array of extensions to be used for filtering. * Example: new String[]{"*.bmp", "*.gif", "*.jpg", "*.png", "*.tif"} * @param extensionDescriptions array of extension descriptions to be used for filtering. * Example: new String[]{"Windows Bitmap (*.bmp)", "Graphics Interchange Format (*.gif)", "JPEG File Interchange Format (*.jpg)", "Portable Network Graphics (*.png)", "Tag Image File Format (*.tif)"} * @return full canonical path to selected file name of null if operation was canceled. */ public static String getSaveFilenameFromShell(Shell shell, String[] extensionNames, String[] extensionDescriptions) { String fileFilterPath = null; if (currentSavingDir == defaultDir && currentSavingDir != currentDir) currentSavingDir = currentDir; try { fileFilterPath = currentSavingDir.getCanonicalPath(); } catch (Exception e) { e.printStackTrace(); } FileDialog fileDialog = new FileDialog(shell, SWT.SAVE); fileDialog.setFilterPath(fileFilterPath); fileDialog.setFilterExtensions(extensionNames); fileDialog.setFilterNames(extensionDescriptions); while (true) { String firstFileName = fileDialog.open(); if (firstFileName != null) { final File file = new File(firstFileName); if (!file.exists() || MessageDialog.openConfirm(shell, "File exists", "File '" + firstFileName + "' already exists, override?")) { currentSavingDir = file.getParentFile(); currentDir = currentSavingDir; return firstFileName; } } else { return null; } } }
From source file:au.gov.ansto.bragg.kakadu.ui.views.mask.MaskPropertiesComposite.java
License:Open Source License
private boolean cofirmApplyChangesAction() { return MessageDialog.openConfirm(getShell(), "Mask Editor", "Mask has been changed. Do you want to save changes before continue? Otherwise all the changes will be ignored."); }
From source file:au.gov.ansto.bragg.kakadu.ui.views.mask.MaskPropertiesComposite.java
License:Open Source License
private boolean confirmAllMasksRemoval() { return MessageDialog.openConfirm(getShell(), "Mask Properties", "Are you sure you want to remove ALL masks from the paremeter '" + currentParameterCombo.getText() + "'?"); }
From source file:au.gov.ansto.bragg.kakadu.ui.views.mask.MaskPropertiesComposite.java
License:Open Source License
private boolean confirmMaskRemoval() { return MessageDialog.openConfirm(getShell(), "Mask Properties", "Are you sure you want to remove mask '" + selectedRegion.toString() + "'?"); }
From source file:au.gov.ansto.bragg.kowari.ui.tasks.KowariTableScanTask.java
License:Open Source License
protected void saveTableCommand(Composite composite) throws IOException { FileDialog dialog = new FileDialog(composite.getShell(), SWT.SAVE); if (fileDialogPath == null) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); dialog.setFilterPath(root.getLocation().toOSString()); } else {// w ww . jav a 2s .co m dialog.setFilterPath(fileDialogPath); } dialog.setFilterExtensions(new String[] { "*.*" }); dialog.open(); if (dialog.getFileName() == null) { return; } String filePath = dialog.getFilterPath() + File.separator + dialog.getFileName(); File pickedFile = new File(filePath); if (pickedFile.exists() && pickedFile.isDirectory()) throw new IllegalAccessError("can not overwrite a folder"); else if (pickedFile.exists()) { if (!MessageDialog.openConfirm(composite.getShell(), "Confirm overwrite", "Do you want to overwrite " + filePath)) { return; } } fileDialogPath = pickedFile.getParent(); for (ISicsCommandElement command : getDataModel().getCommands()) { if (command instanceof SimpleTableScanCommand) { SimpleTableScanCommand tableCommand = (SimpleTableScanCommand) command; FileWriter outputfile = new FileWriter(pickedFile); String text = ""; // for (int i = 0; i < tableCommand.getNumberOfMotor(); i ++){ // text += tableCommand.getPNames().get(i) + ",\t"; // } // text += tableCommand.getScan_mode() + "\n"; if (tableCommand.getNumberOfMotor() >= 1) { text += (tableCommand.getColumn0() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 2) { text += (tableCommand.getColumn1() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 3) { text += (tableCommand.getColumn2() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 4) { text += (tableCommand.getColumn3() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 5) { text += (tableCommand.getColumn4() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 6) { text += (tableCommand.getColumn5() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 7) { text += (tableCommand.getColumn6() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 8) { text += (tableCommand.getColumn7() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 9) { text += (tableCommand.getColumn8() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 10) { text += (tableCommand.getColumn9() ? "1" : "0") + ",\t"; } text += "\n"; for (AbstractScanParameter parameter : tableCommand.getParameterList()) { if (parameter instanceof TableScanParameter) { TableScanParameter tableParameter = (TableScanParameter) parameter; for (int i = 0; i < tableCommand.getNumberOfMotor(); i++) { text += tableParameter.getP(i) + ",\t"; } text += Float.valueOf(tableParameter.getPreset()) + "\n"; } } outputfile.write(text); outputfile.close(); } } }
From source file:au.gov.ansto.bragg.nbi.ui.tasks.SimpleTableScanTask.java
License:Open Source License
protected void saveTableCommand(Composite composite) throws IOException { FileDialog dialog = new FileDialog(composite.getShell(), SWT.SAVE); if (fileDialogPath == null) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); dialog.setFilterPath(root.getLocation().toOSString()); } else {/*from w ww. j av a2 s. c om*/ dialog.setFilterPath(fileDialogPath); } dialog.setFilterExtensions(new String[] { "*.*" }); dialog.open(); if (dialog.getFileName() == null) { return; } String filePath = dialog.getFilterPath() + File.separator + dialog.getFileName(); File pickedFile = new File(filePath); if (pickedFile.exists() && pickedFile.isDirectory()) throw new IllegalAccessError("can not overwrite a folder"); else if (pickedFile.exists()) { if (!MessageDialog.openConfirm(composite.getShell(), "Confirm overwrite", "Do you want to overwrite " + filePath)) { return; } } fileDialogPath = pickedFile.getParent(); for (ISicsCommandElement command : getDataModel().getCommands()) { if (command instanceof SimpleTableScanCommand) { SimpleTableScanCommand tableCommand = (SimpleTableScanCommand) command; FileWriter outputfile = new FileWriter(pickedFile); String text = ""; for (int i = 0; i < tableCommand.getNumberOfMotor(); i++) { text += tableCommand.getPNames().get(i) + ",\t"; } text += tableCommand.getScan_mode() + "\n"; if (tableCommand.getNumberOfMotor() >= 1) { text += (tableCommand.getColumn0() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 2) { text += (tableCommand.getColumn1() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 3) { text += (tableCommand.getColumn2() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 4) { text += (tableCommand.getColumn3() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 5) { text += (tableCommand.getColumn4() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 6) { text += (tableCommand.getColumn5() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 7) { text += (tableCommand.getColumn6() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 8) { text += (tableCommand.getColumn7() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 9) { text += (tableCommand.getColumn8() ? "1" : "0") + ",\t"; } if (tableCommand.getNumberOfMotor() >= 10) { text += (tableCommand.getColumn9() ? "1" : "0") + ",\t"; } text += "\n"; for (AbstractScanParameter parameter : tableCommand.getParameterList()) { if (parameter instanceof TableScanParameter) { TableScanParameter tableParameter = (TableScanParameter) parameter; for (int i = 0; i < tableCommand.getNumberOfMotor(); i++) { text += tableParameter.getP(i) + ",\t"; } text += Float.valueOf(tableParameter.getPreset()) + "\n"; } } outputfile.write(text); outputfile.close(); } } }
From source file:au.gov.ansto.bragg.wombat.ui.views.WombatAnalysisControlViewOld.java
License:Open Source License
@Override public void createPartControl(Composite composite) { super.createPartControl(composite); AlgorithmTask task = getAlgorithmTask(); final Operation operation = task.getOperationManager(0).getOperation(NAVIGATION_PROCESSOR_NAME); final OperationParameter valueOnAxisParameter = operation.getOperationParameter(SCAN_VARIABLE_NAME); final Operation plotOperation = task.getOperationManager(0).getOperation(ONEDPLOT_PROCESSOR_NAME); final Operation geometryOperation = task.getOperationManager(0) .getOperation(CORRECTED_HISTOGRAM_PROCESSOR_NAME); final Operation integrationOperation = task.getOperationManager(0).getOperation(INTEGRATION_PROCESSOR_NAME); final OperationParameter applyToAllParameter = operation.getOperationParameter(APPLYTOALL_VARIABLE_NAME); final OperationParameter resetHistoryParameter = operation .getOperationParameter(RESET_HISTORY_VARIABLE_NAME); // final IPointLocatorListener mouseListener = new IPointLocatorListener(){ ////from ww w .ja v a 2s .c om // public void locationUpdated(double x, double y, double val) { // List<OperationParameterEditor> editors = parameterEditorsMap.get(operation.getName()); // for (OperationParameterEditor editor : editors){ // if (editor.getOperationParameter() == parameter){ //// parameter.setValue(new Double(x)); //// editor.loadData(); // if (editor instanceof OptionOperationParameterEditor) // ((OptionOperationParameterEditor) editor).setSelection(new Double(x)); // } // } // // applyParameters(); // } // }; final OperationParameterListener applyToAllListener = new OperationParameterListener() { public void serverDataUpdated(OperationParameter operationParameter, Object newData) { if (newData instanceof Boolean) { geometryOperation.setOperationDataListenerEnabled(!(Boolean) newData); integrationOperation.setOperationDataListenerEnabled(!(Boolean) newData); plotOperation.setOperationDataListenerEnabled(!(Boolean) newData); } } }; applyToAllParameter.addOperationParameterListener(applyToAllListener); // final KurandaMouseListener doubleClickListener = new KurandaMouseListener(){ // // public void mouseDoubleClick(EventData eventData) { // List<OperationParameterEditor> editors = parameterEditorsMap.get(operation.getName()); // for (OperationParameterEditor editor : editors){ // if (editor.getOperationParameter() == valueOnAxisParameter){ //// parameter.setValue(new Double(x)); //// editor.loadData(); // if (editor instanceof OptionOperationParameterEditor) // ((OptionOperationParameterEditor) editor).setSelection( //// new Position(String.valueOf(eventData.getX()))); // Double.valueOf(eventData.getX())); // } // } // // applyParameters(); // } // // public void mouseDown(EventData eventData) { // // } // // public void mouseUp(EventData eventData) { // // } // // }; // // PlotManager.addOpenNewPlotListener(new PlotManager.OpenNewPlotListener(){ // // public void newPlotOpened(Plot plot) { // if (plot.getOperaton() == plotOperation) //// plot.getCurrentPlotWidget().addPointLocatorListener(mouseListener); // plot.getCurrentPlotWidget().addMouseEventListener(doubleClickListener); // }}); final ChartMouseListener chartMouseListener = new ChartMouseListener() { @Override public void chartMouseMoved(ChartMouseEvent event) { // TODO Auto-generated method stub } @Override public void chartMouseClicked(ChartMouseEvent event) { if (event instanceof XYChartMouseEvent) { List<OperationParameterEditor> editors = parameterEditorsMap.get(operation.getName()); for (OperationParameterEditor editor : editors) { if (editor.getOperationParameter() == valueOnAxisParameter) { if (editor instanceof OptionOperationParameterEditor) ((OptionOperationParameterEditor) editor).setSelection( new Position(String.valueOf(((XYChartMouseEvent) event).getX()))); } } } } }; PlotManager.addOpenNewPlotListener(new PlotManager.OpenNewPlotListener() { public void newPlotOpened(au.gov.ansto.bragg.kakadu.ui.plot.Plot plot) { if (plot.getOperaton() == plotOperation) // plot.getCurrentPlotWidget().addPointLocatorListener(mouseListener); plot.getCurrentPlotWidget().addChartMouseListener(chartMouseListener); } }); configurationButton.removeSelectionListener(configurationSelectionListener); configurationButton.setText("Reset"); configurationButton.setToolTipText("clear all history data"); configurationButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent arg0) { } public void widgetSelected(SelectionEvent arg0) { if (MessageDialog.openConfirm(getSite().getShell(), "Confirm of Clearing History Data", "Do you want to clear all the history data?")) { try { algorithmTask.applyParameterChangesForAllDataItems(RESET_HISTORY_VARIABLE_NAME, true); algorithmTask.markOperationsActual(NAVIGATION_PROCESSOR_NAME, false); } catch (SetTunerException e) { Util.handleException(getSite().getShell(), e); } applyParameters(); } } }); }