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:org.eclipse.birt.report.designer.internal.ui.views.attributes.provider.BindingGroupDescriptorProvider.java
License:Open Source License
public void save(Object saveValue) throws SemanticException { if (saveValue instanceof BindingInfo) { BindingInfo info = (BindingInfo) saveValue; int type = info.getBindingType(); BindingInfo oldValue = (BindingInfo) load(); switch (type) { case ReportItemHandle.DATABINDING_TYPE_NONE: case ReportItemHandle.DATABINDING_TYPE_DATA: if (info.equals(NullDatasetChoice)) { info = null;//from w ww. ja va 2s. co m } int ret = 0; if (!NullDatasetChoice.equals(info)) ret = 4; if ((!NullDatasetChoice.equals(oldValue) || getReportItemHandle().getColumnBindings().iterator().hasNext()) && !(info != null && info.equals(oldValue))) { MessageDialog prefDialog = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("dataBinding.title.changeDataSet"), //$NON-NLS-1$ null, Messages.getString("dataBinding.message.changeDataSet"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("AttributeView.dialg.Message.Yes"), //$NON-NLS-1$ Messages.getString("AttributeView.dialg.Message.No"), //$NON-NLS-1$ Messages.getString("AttributeView.dialg.Message.Cancel") }, //$NON-NLS-1$ 0); ret = prefDialog.open(); } switch (ret) { // Clear binding info case 0: resetDataSetReference(info, true); break; // Doesn't clear binding info case 1: resetDataSetReference(info, false); break; // Cancel. case 2: section.load(); break; case 4: updateDataSetReference(info); break; } break; case ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF: String value = info.getBindingValue().toString(); if (value.equals(NONE) || value == null) { value = null; } else if (referMap.get(value).getName() == null) { MessageDialog dialog = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("dataBinding.title.haveNoName"), //$NON-NLS-1$ null, Messages.getString("dataBinding.message.haveNoName"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("dataBinding.button.OK")//$NON-NLS-1$ }, 0); dialog.open(); section.load(); return; } int ret1 = 0; if (!NullReportItemChoice.equals(((BindingInfo) load()).getBindingValue().toString()) || getReportItemHandle().getColumnBindings().iterator().hasNext()) { MessageDialog prefDialog = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("dataBinding.title.changeDataSet"), //$NON-NLS-1$ null, Messages.getString("dataBinding.message.changeReference"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("AttributeView.dialg.Message.Yes"), //$NON-NLS-1$ Messages.getString("AttributeView.dialg.Message.Cancel") }, //$NON-NLS-1$ 0); ret1 = prefDialog.open(); } switch (ret1) { // Clear binding info case 0: resetReference(value); break; // Cancel. case 1: section.load(); } } } }
From source file:org.eclipse.birt.report.designer.internal.ui.views.attributes.provider.DataSetColumnBindingsFormHandleProvider.java
License:Open Source License
private void generateOutputParmsBindings(DataSetHandle datasetHandle) { List<DataSetParameterHandle> outputParams = new ArrayList<DataSetParameterHandle>(); for (Iterator iter = datasetHandle.parametersIterator(); iter.hasNext();) { Object obj = iter.next(); if ((obj instanceof DataSetParameterHandle) && ((DataSetParameterHandle) obj).isOutput() == true) { outputParams.add((DataSetParameterHandle) obj); }//from ww w .j a v a 2 s .c o m } int ret = -1; if (outputParams.size() > 0) { MessageDialog prefDialog = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("dataBinding.title.generateOutputParam"), //$NON-NLS-1$ null, Messages.getString("dataBinding.msg.generateOutputParam"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("AttributeView.dialg.Message.Yes"), //$NON-NLS-1$ Messages.getString("AttributeView.dialg.Message.No") }, //$NON-NLS-1$ 0);//$NON-NLS-1$ ret = prefDialog.open(); } if (ret == 0) for (int i = 0; i < outputParams.size(); i++) { DataSetParameterHandle param = outputParams.get(i); ComputedColumn bindingColumn = StructureFactory.newComputedColumn(bindingObject, param.getName()); bindingColumn.setDataType(param.getDataType()); String groupType = DEUtil.getGroupControlType(bindingObject); List groupList = DEUtil.getGroups(bindingObject); ExpressionUtility.setBindingColumnExpression(param, bindingColumn, true); if (bindingObject instanceof ReportItemHandle) { try { ((ReportItemHandle) bindingObject).addColumnBinding(bindingColumn, false); } catch (SemanticException e) { ExceptionHandler.handle(e); } continue; } if (ExpressionUtil.hasAggregation(bindingColumn.getExpression())) { if (groupType.equals(DEUtil.TYPE_GROUP_GROUP)) bindingColumn.setAggregrateOn(((GroupHandle) groupList.get(0)).getName()); else if (groupType.equals(DEUtil.TYPE_GROUP_LISTING)) bindingColumn.setAggregrateOn(null); } } }
From source file:org.eclipse.birt.report.designer.internal.ui.wizards.PublishCSSWizard.java
License:Open Source License
private boolean publishiCSSFile() { // copy to resource folder if (!(new File(filePath).exists())) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishCSSAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishCSSAction.wizard.message.SourceFileNotExist")); //$NON-NLS-1$ return true; }// w w w. ja v a 2 s. c o m File targetFolder = new File(folderName); if (targetFolder.exists() && (!targetFolder.isDirectory())) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishCSSAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishCSSAction.wizard.notvalidfolder")); //$NON-NLS-1$ //$NON-NLS-1$ return true; } boolean folderExists = targetFolder.exists(); if (!folderExists) { // if creating dirs fails, it'll return false. folderExists = targetFolder.mkdirs(); } if (!folderExists) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishCSSAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishCSSAction.wizard.msgDirErr")); //$NON-NLS-1$ return false; } File targetFile = new File(targetFolder, fileName); if (new File(filePath).compareTo(targetFile) == 0) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishCSSAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishCSSAction.wizard.message")); //$NON-NLS-1$ return false; } int overwrite = Window.OK; try { if (targetFile.exists()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String question = Messages.getFormattedString("SaveAsDialog.overwriteQuestion", //$NON-NLS-1$ new Object[] { targetFile.getAbsolutePath() }); MessageDialog d = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("SaveAsDialog.Question"), //$NON-NLS-1$ null, question, MessageDialog.QUESTION, buttons, 0); overwrite = d.open(); } if (overwrite == Window.OK && (targetFile.exists() || (!targetFile.exists() && targetFile.createNewFile()))) { copyFile(filePath, targetFile); IReportResourceSynchronizer synchronizer = ReportPlugin.getDefault() .getResourceSynchronizerService(); if (synchronizer != null) { synchronizer.notifyResourceChanged( new ReportResourceChangeEvent(this, Path.fromOSString(targetFile.getAbsolutePath()), IReportResourceChangeEvent.NewResource)); } } } catch (IOException e) { ExceptionHandler.handle(e); } return overwrite != 1; }
From source file:org.eclipse.birt.report.designer.internal.ui.wizards.PublishLibraryWizard.java
License:Open Source License
private boolean publishiLibrary() { // copy to library folder if (!(new File(filePath).exists())) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishLibraryAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishLibraryAction.wizard.message.SourceFileNotExist")); //$NON-NLS-1$ return true; }//from w w w . j a v a2 s . c om File targetFolder = new File(folderName); if (targetFolder.exists() && (!targetFolder.isDirectory())) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishLibraryAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishLibraryAction.wizard.notvalidfolder")); //$NON-NLS-1$ //$NON-NLS-1$ return true; } boolean folderExists = targetFolder.exists(); if (!folderExists) { folderExists = targetFolder.mkdirs(); } if (!folderExists) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishLibraryAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishLibraryAction.wizard.msgDirErr")); //$NON-NLS-1$ return false; } File targetFile = new File(targetFolder, fileName); if (new File(filePath).compareTo(targetFile) == 0) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishLibraryAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishLibraryAction.wizard.message")); //$NON-NLS-1$ return false; } int overwrite = Window.OK; try { if (targetFile.exists()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String question = Messages.getFormattedString("SaveAsDialog.overwriteQuestion", //$NON-NLS-1$ new Object[] { targetFile.getAbsolutePath() }); MessageDialog d = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("SaveAsDialog.Question"), //$NON-NLS-1$ null, question, MessageDialog.QUESTION, buttons, 0); overwrite = d.open(); } if (overwrite == Window.OK && (targetFile.exists() || (!targetFile.exists() && targetFile.createNewFile()))) { copyFile(filePath, targetFile); IReportResourceSynchronizer synchronizer = ReportPlugin.getDefault() .getResourceSynchronizerService(); if (synchronizer != null) { synchronizer.notifyResourceChanged( new ReportResourceChangeEvent(this, Path.fromOSString(targetFile.getAbsolutePath()), IReportResourceChangeEvent.NewResource)); } } } catch (IOException e) { ExceptionHandler.handle(e); } return overwrite != 1; }
From source file:org.eclipse.birt.report.designer.internal.ui.wizards.PublishTemplateWizard.java
License:Open Source License
public boolean performFinish() { // copy to template folder String templateFolderPath = ReportPlugin.getDefault().getTemplatePreference(); String filePath = handle.getFileName(); if (!(new File(filePath).exists())) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishTemplateAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishTemplateAction.wizard.message.SourceFileNotExist")); //$NON-NLS-1$ return true; }//from w w w . ja v a 2 s . c o m String fileName = filePath.substring(filePath.lastIndexOf(File.separator) + 1); File targetFolder = new File(templateFolderPath); // if ( !targetFolder.isDirectory( ) ) // { // ExceptionHandler.openErrorMessageBox( Messages.getString( "PublishTemplateAction.wizard.errorTitle" ), //$NON-NLS-1$ // Messages.getString( "PublishTemplateAction.wizard.notvalidfolder" ) ); //$NON-NLS-1$ // return true; // } boolean folderExists = targetFolder.exists(); if (!folderExists) { folderExists = targetFolder.mkdirs(); } if (!folderExists) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishTemplateAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishTemplateAction.wizard.msgDirErr")); //$NON-NLS-1$ return true; } String targetFileName = fileName; if (ReportPlugin.getDefault().isReportDesignFile(fileName)) { int index = fileName.lastIndexOf("."); //$NON-NLS-1$ targetFileName = fileName.substring(0, index) + ".rpttemplate"; //$NON-NLS-1$ } File targetFile = new File(targetFolder, targetFileName); if (new File(filePath).compareTo(targetFile) == 0) { ExceptionHandler.openErrorMessageBox(Messages.getString("PublishTemplateAction.wizard.errorTitle"), //$NON-NLS-1$ Messages.getString("PublishTemplateAction.wizard.message")); //$NON-NLS-1$ return true; } int overwrite = Window.OK; try { if (targetFile.exists()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String question = Messages.getFormattedString("SaveAsDialog.overwriteQuestion", //$NON-NLS-1$ new Object[] { targetFile.getAbsolutePath() }); MessageDialog d = new MessageDialog(getShell(), Messages.getString("SaveAsDialog.Question"), //$NON-NLS-1$ null, question, MessageDialog.QUESTION, buttons, 0); overwrite = d.open(); } if (overwrite == Window.OK && (targetFile.exists() || (!targetFile.exists() && targetFile.createNewFile()))) { copyFile(filePath, targetFile); try { setDesignFile(targetFile.getAbsolutePath()); } catch (DesignFileException e) { ExceptionHandler.handle(e); return false; } catch (SemanticException e) { ExceptionHandler.handle(e); return false; } catch (IOException e) { ExceptionHandler.handle(e); return false; } IReportResourceSynchronizer synchronizer = ReportPlugin.getDefault() .getResourceSynchronizerService(); if (synchronizer != null) { synchronizer.notifyResourceChanged( new ReportResourceChangeEvent(this, Path.fromOSString(targetFile.getAbsolutePath()), IReportResourceChangeEvent.NewResource)); } } } catch (IOException e) { ExceptionHandler.handle(e); } return overwrite != 1; }
From source file:org.eclipse.birt.report.designer.ui.dialogs.ColumnBindingDialog.java
License:Open Source License
private void generateOutputParmsBindings(DataSetHandle datasetHandle) { List<DataSetParameterHandle> outputParams = new ArrayList<DataSetParameterHandle>(); for (Iterator iter = datasetHandle.parametersIterator(); iter.hasNext();) { Object obj = iter.next(); if ((obj instanceof DataSetParameterHandle) && ((DataSetParameterHandle) obj).isOutput() == true) { outputParams.add((DataSetParameterHandle) obj); }/*from ww w . j a va 2s . c om*/ } int ret = -1; if (outputParams.size() > 0) { MessageDialog prefDialog = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("dataBinding.title.generateOutputParam"), //$NON-NLS-1$ null, Messages.getString("dataBinding.msg.generateOutputParam"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("AttributeView.dialg.Message.Yes"), //$NON-NLS-1$ Messages.getString("AttributeView.dialg.Message.No") }, //$NON-NLS-1$ 0);//$NON-NLS-1$ ret = prefDialog.open(); } if (ret == 0) for (int i = 0; i < outputParams.size(); i++) { DataSetParameterHandle param = outputParams.get(i); ComputedColumn bindingColumn = StructureFactory.newComputedColumn(inputElement, param.getName()); bindingColumn.setDataType(param.getDataType()); ExpressionUtility.setBindingColumnExpression(param, bindingColumn, true); try { inputElement.addColumnBinding(bindingColumn, false); } catch (SemanticException e) { ExceptionHandler.handle(e); } continue; } }
From source file:org.eclipse.birt.report.designer.ui.dialogs.ColumnBindingDialog.java
License:Open Source License
public void save(Object saveValue) throws SemanticException { if (saveValue instanceof BindingInfo) { BindingInfo info = (BindingInfo) saveValue; int type = info.getBindingType(); String value = info.getBindingValue().toString(); switch (type) { case ReportItemHandle.DATABINDING_TYPE_DATA: if (value.equals(NullDatasetChoice)) { value = null;//from www. jav a 2s .c o m } int ret = 0; if (!NullDatasetChoice.equals(((BindingInfo) loadValue()).getBindingValue().toString()) || inputElement.getColumnBindings().iterator().hasNext()) { MessageDialog prefDialog = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("dataBinding.title.changeDataSet"), //$NON-NLS-1$ null, Messages.getString("dataBinding.message.changeDataSet"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("AttributeView.dialg.Message.Yes"), //$NON-NLS-1$ Messages.getString("AttributeView.dialg.Message.No"), //$NON-NLS-1$ Messages.getString("AttributeView.dialg.Message.Cancel") }, //$NON-NLS-1$ 0); ret = prefDialog.open(); } switch (ret) { // Clear binding info case 0: resetDataSetReference(value, true); break; // Doesn't clear binding info case 1: resetDataSetReference(value, false); break; // Cancel. case 2: load(); } break; case ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF: if (value.equals(NullReportItemChoice)) { value = null; } else if (referMap.get(value).getName() == null) { MessageDialog dialog = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("dataBinding.title.haveNoName"), //$NON-NLS-1$ null, Messages.getString("dataBinding.message.haveNoName"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("dataBinding.button.OK")//$NON-NLS-1$ }, 0); dialog.open(); load(); return; } int ret1 = 0; if (!NullReportItemChoice.equals(((BindingInfo) loadValue()).getBindingValue().toString()) || inputElement.getColumnBindings().iterator().hasNext()) { MessageDialog prefDialog = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("dataBinding.title.changeDataSet"), //$NON-NLS-1$ null, Messages.getString("dataBinding.message.changeReference"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("AttributeView.dialg.Message.Yes"), //$NON-NLS-1$ Messages.getString("AttributeView.dialg.Message.Cancel") }, //$NON-NLS-1$ 0); ret1 = prefDialog.open(); } switch (ret1) { // Clear binding info case 0: resetReference(value); break; // Cancel. case 1: load(); } } } }
From source file:org.eclipse.birt.report.designer.ui.editors.IDEMultiPageReportEditor.java
License:Open Source License
public void partActivated(IWorkbenchPart part) { super.partActivated(part); if (part != this) return;/*from www .ja v a 2 s . c o m*/ if (isWorkspaceResource) { final IFile file = ((IFileEditorInput) getEditorInput()).getFile(); if (!file.exists()) { Shell shell = getSite().getShell(); String title = DLG_SAVE_TITLE; String message = DLG_SAVE_CONFIRM_DELETE; String[] buttons = { DLG_SAVE_BUTTON_SAVE, DLG_SAVE_BUTTON_CLOSE }; if (closedStatus.contains(file)) { return; } MessageDialog dialog = new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, buttons, 0); closedStatus.add(file); int result = dialog.open(); if (result == 0) { doSaveAs(); partActivated(part); } else { closeEditor(false); } Display.getDefault().asyncExec(new Runnable() { public void run() { closedStatus.remove(file); } }); } } }
From source file:org.eclipse.birt.report.designer.ui.editors.MultiPageReportEditor.java
License:Open Source License
protected void confirmSave() { if (fIsHandlingActivation) return;/*from ww w .ja v a 2 s . com*/ if (!isExistModelFile() && !isClose) { // Thread.dumpStack( ); fIsHandlingActivation = true; MessageDialog dialog = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("MultiPageReportEditor.ConfirmTitle"), //$NON-NLS-1$ null, Messages.getString("MultiPageReportEditor.SaveConfirmMessage"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("MultiPageReportEditor.SaveButton"), //$NON-NLS-1$ Messages.getString("MultiPageReportEditor.CloseButton") }, //$NON-NLS-1$ 0); try { if (dialog.open() == 0) { doSave(null); isClose = false; } else { Display display = getSite().getShell().getDisplay(); display.asyncExec(new Runnable() { public void run() { closeEditor(false); } }); isClose = true; } } finally { fIsHandlingActivation = false; needReset = false; needReload = false; } } }
From source file:org.eclipse.birt.report.designer.ui.ide.wizards.WizardSaveAsPage.java
License:Open Source License
/** * Get the saving path//from w ww . ja va2s .com * * @return the saving path */ public IPath getResult() { IPath path = resourceGroup.getContainerFullPath().append(resourceGroup.getResource()); // If the user does not supply a file extension and if the save // as dialog was provided a default file name append the extension // of the default filename to the new name if (path.getFileExtension() == null) { if (originalFile != null && originalFile.getFileExtension() != null) path = path.addFileExtension(originalFile.getFileExtension()); else if (originalName != null) { int pos = originalName.lastIndexOf('.'); if (++pos > 0 && pos < originalName.length()) path = path.addFileExtension(originalName.substring(pos)); } } // If the path already exists then confirm overwrite. IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (file.exists()) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; String question = Messages.getFormattedString("WizardSaveAsPage.OverwriteQuestion", //$NON-NLS-1$ new Object[] { path.toOSString() }); MessageDialog d = new MessageDialog(getShell(), Messages.getString("WizardSaveAsPage.Question"), //$NON-NLS-1$ null, question, MessageDialog.QUESTION, buttons, 0); int overwrite = d.open(); switch (overwrite) { case 0: // Yes break; case 1: // No return null; case 2: // Cancel default: return Path.EMPTY; } } return path; }