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.andmore.internal.editors.layout.gle2.ExportScreenshotAction.java
License:Open Source License
@Override public void run() { Shell shell = AndmoreAndroidPlugin.getShell(); ImageOverlay imageOverlay = mCanvas.getImageOverlay(); BufferedImage image = imageOverlay.getAwtImage(); if (image != null) { FileDialog dialog = new FileDialog(shell, SWT.SAVE); dialog.setFilterExtensions(new String[] { "*.png" }); //$NON-NLS-1$ String path = dialog.open(); if (path != null) { if (!path.endsWith(DOT_PNG)) { path = path + DOT_PNG;// w w w . ja v a 2 s . co m } File file = new File(path); if (file.exists()) { MessageDialog d = new MessageDialog(null, "File Already Exists", null, String.format("%1$s already exists.\nWould you like to replace it?", path), MessageDialog.QUESTION, new String[] { // Yes will be moved to the end because it's the default "Yes", "No" }, 0); int result = d.open(); if (result != 0) { return; } } try { ImageIO.write(image, "PNG", file); //$NON-NLS-1$ } catch (IOException e) { AndmoreAndroidPlugin.log(e, null); } } } else { MessageDialog.openError(shell, "Error", "Image not available"); } }
From source file:org.eclipse.andmore.internal.editors.layout.gre.ClientRulesEngine.java
License:Open Source License
@Override public String displayFragmentSourceInput() { try {//ww w . ja va2 s .co m // Compute a search scope: We need to merge all the subclasses // android.app.Fragment and android.support.v4.app.Fragment IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); IProject project = mRulesEngine.getProject(); final IJavaProject javaProject = BaseProjectHelper.getJavaProject(project); if (javaProject != null) { IType oldFragmentType = javaProject.findType(CLASS_V4_FRAGMENT); // First check to make sure fragments are available, and if not, // warn the user. IAndroidTarget target = Sdk.getCurrent().getTarget(project); // No, this should be using the min SDK instead! if (target.getVersion().getApiLevel() < 11 && oldFragmentType == null) { // Compatibility library must be present MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "Fragment Warning", null, "Fragments require API level 11 or higher, or a compatibility " + "library for older versions.\n\n" + " Do you want to install the compatibility library?", MessageDialog.QUESTION, new String[] { "Install", "Cancel" }, 1 /* default button: Cancel */); int answer = dialog.open(); if (answer == 0) { if (!AddSupportJarAction.install(project)) { return null; } } else { return null; } } // Look up sub-types of each (new fragment class and compatibility fragment // class, if any) and merge the two arrays - then create a scope from these // elements. IType[] fragmentTypes = new IType[0]; IType[] oldFragmentTypes = new IType[0]; if (oldFragmentType != null) { ITypeHierarchy hierarchy = oldFragmentType.newTypeHierarchy(new NullProgressMonitor()); oldFragmentTypes = hierarchy.getAllSubtypes(oldFragmentType); } IType fragmentType = javaProject.findType(CLASS_FRAGMENT); if (fragmentType != null) { ITypeHierarchy hierarchy = fragmentType.newTypeHierarchy(new NullProgressMonitor()); fragmentTypes = hierarchy.getAllSubtypes(fragmentType); } IType[] subTypes = new IType[fragmentTypes.length + oldFragmentTypes.length]; System.arraycopy(fragmentTypes, 0, subTypes, 0, fragmentTypes.length); System.arraycopy(oldFragmentTypes, 0, subTypes, fragmentTypes.length, oldFragmentTypes.length); scope = SearchEngine.createJavaSearchScope(subTypes, IJavaSearchScope.SOURCES); } Shell parent = AndmoreAndroidPlugin.getShell(); final AtomicReference<String> returnValue = new AtomicReference<String>(); final AtomicReference<SelectionDialog> dialogHolder = new AtomicReference<SelectionDialog>(); final SelectionDialog dialog = JavaUI.createTypeDialog(parent, new ProgressMonitorDialog(parent), scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false, // Use ? as a default filter to fill dialog with matches "?", //$NON-NLS-1$ new TypeSelectionExtension() { @Override public Control createContentArea(Composite parentComposite) { Composite composite = new Composite(parentComposite, SWT.NONE); composite.setLayout(new GridLayout(1, false)); Button button = new Button(composite, SWT.PUSH); button.setText("Create New..."); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String fqcn = createNewFragmentClass(javaProject); if (fqcn != null) { returnValue.set(fqcn); dialogHolder.get().close(); } } }); return composite; } @Override public ITypeInfoFilterExtension getFilterExtension() { return new ITypeInfoFilterExtension() { @Override public boolean select(ITypeInfoRequestor typeInfoRequestor) { int modifiers = typeInfoRequestor.getModifiers(); if (!Flags.isPublic(modifiers) || Flags.isInterface(modifiers) || Flags.isEnum(modifiers) || Flags.isAbstract(modifiers)) { return false; } return true; } }; } }); dialogHolder.set(dialog); dialog.setTitle("Choose Fragment Class"); dialog.setMessage("Select a Fragment class (? = any character, * = any string):"); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } if (returnValue.get() != null) { return returnValue.get(); } Object[] types = dialog.getResult(); if (types != null && types.length > 0) { return ((IType) types[0]).getFullyQualifiedName(); } } catch (JavaModelException e) { AndmoreAndroidPlugin.log(e, null); } catch (CoreException e) { AndmoreAndroidPlugin.log(e, null); } return null; }
From source file:org.eclipse.birt.chart.integration.wtp.ui.internal.dialogs.WebArtifactOverwriteQuery.java
License:Open Source License
/** * Open confirm dialog//from w w w . j a v a 2s . c o m * * @param file * @return */ private int openDialog(final String item) { final int[] result = { IDialogConstants.CANCEL_ID }; shell.getDisplay().syncExec(new Runnable() { public void run() { String title = BirtWTPMessages.BIRTOverwriteQuery_webartifact_title; String msg = NLS.bind(BirtWTPMessages.BIRTOverwriteQuery_webartifact_message, item); String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.YES_TO_ALL_LABEL, IDialogConstants.CANCEL_LABEL }; MessageDialog dialog = new MessageDialog(shell, title, null, msg, MessageDialog.QUESTION, options, 0); result[0] = dialog.open(); } }); return result[0]; }
From source file:org.eclipse.birt.chart.reportitem.ui.StandardChartDataSheet.java
License:Open Source License
@SuppressWarnings("unchecked") public void handleEvent(Event event) { // When user select expression in drop&down list of live preview // area, the event will be handled to update related column color. if (event.type == IChartDataSheet.EVENT_QUERY) { if (event.detail == IChartDataSheet.DETAIL_UPDATE_COLOR_AND_TEXT) { updateColorAndText();//from ww w.j a v a 2 s.c om } else if (event.detail == IChartDataSheet.DETAIL_UPDATE_COLOR && event.data instanceof ISelectDataComponent) { refreshTableColor(); } return; } // Right click to display the menu. Menu display by clicking // application key is triggered by os, so do nothing. // bug 261340, now we use the field doit to indicate whether it's menu // initialization or event triggering. if (event.type == CustomPreviewTable.MOUSE_RIGHT_CLICK_TYPE) { if (getDataServiceProvider().getDataSet() != null || getDataServiceProvider().getInheritedDataSet() != null) { if (event.widget instanceof Button) { Button header = (Button) event.widget; // Bind context menu to each header button boolean isSharingChart = dataProvider.checkState(IDataServiceProvider.SHARE_CHART_QUERY); if (header.getMenu() == null && !isSharingChart) { header.setMenu(createMenuManager(event.data).createContextMenu(tablePreview)); } if (event.doit && !isSharingChart) { header.getMenu().setVisible(true); } } } } else if (event.type == SWT.Selection) { if (event.widget instanceof MenuItem) { MenuItem item = (MenuItem) event.widget; IAction action = (IAction) item.getData(); action.setChecked(!action.isChecked()); action.run(); } else if (event.widget == btnFilters) { if (invokeEditFilter() == Window.OK) { refreshDataPreviewPane(); // Update preview via event fireEvent(btnFilters, EVENT_PREVIEW); } } else if (event.widget == btnParameters) { if (invokeEditParameter() == Window.OK) { refreshDataPreviewPane(); // Update preview via event fireEvent(btnParameters, EVENT_PREVIEW); } } else if (event.widget == btnBinding) { if (invokeDataBinding() == Window.OK) { refreshDataPreviewPane(); // Update preview via event fireEvent(btnBinding, EVENT_PREVIEW); } } try { if (event.widget == btnInherit) { ColorPalette.getInstance().restore(); // Skip when selection is false if (!btnInherit.getSelection()) { return; } // Avoid duplicate loading data set. if (bIsInheritSelected) { return; } bIsInheritSelected = true; getDataServiceProvider().setReportItemReference(null); getDataServiceProvider().setDataCube(null); getDataServiceProvider().setDataSet(null); switchDataSet(); cmbDataItems.select(0); currentDataReference = null; cmbDataItems.setEnabled(false); cmbInherit.setEnabled( !isInheritingSummaryTable() && getDataServiceProvider().getInheritedDataSet() != null && ChartItemUtil.isContainerInheritable(itemHandle)); setEnabledForButtons(); updateDragDataSource(); updatePredefinedQueries(); } else if (event.widget == btnUseData) { // Skip when selection is false if (!btnUseData.getSelection()) { return; } // Avoid duplicate loading data set. if (!bIsInheritSelected) { return; } bIsInheritSelected = false; getDataServiceProvider().setReportItemReference(null); getDataServiceProvider().setDataSet(null); selectDataSet(); cmbDataItems.setEnabled(true); cmbInherit.setEnabled(false); setEnabledForButtons(); updateDragDataSource(); updatePredefinedQueries(); } else if (event.widget == cmbInherit) { getContext().setInheritColumnsOnly(cmbInherit.getSelectionIndex() == 1); setEnabledForButtons(); // Fire event to update outside UI fireEvent(btnBinding, EVENT_QUERY); refreshDataPreviewPane(); } else if (event.widget == cmbDataItems) { ColorPalette.getInstance().restore(); int selectedIndex = cmbDataItems.getSelectionIndex(); Integer selectState = selectDataTypes.get(selectedIndex); switch (selectState.intValue()) { case SELECT_NONE: // Inherit data from container btnInherit.setSelection(true); btnUseData.setSelection(false); btnInherit.notifyListeners(SWT.Selection, new Event()); break; case SELECT_NEXT: selectedIndex++; selectState = selectDataTypes.get(selectedIndex); cmbDataItems.select(selectedIndex); break; } switch (selectState.intValue()) { case SELECT_DATA_SET: DataSetInfo dataInfo = (DataSetInfo) ((List<Object>) cmbDataItems.getData()) .get(selectedIndex); if (getDataServiceProvider().getReportItemReference() == null && getDataServiceProvider().getDataSet() != null && getDataServiceProvider().getDataSetInfo().equals(dataInfo)) { return; } getDataServiceProvider().setDataSet(dataInfo); currentDataReference = dataInfo; switchDataSet(); setEnabledForButtons(); updateDragDataSource(); break; case SELECT_DATA_CUBE: getDataServiceProvider().setDataCube(cmbDataItems.getText()); currentDataReference = cmbDataItems.getText(); // Since cube has no group, it needs to clear group // flag in category and optional Y of chart model. clearGrouping(); updateDragDataSource(); setEnabledForButtons(); // Update preview via event DataDefinitionTextManager.getInstance().refreshAll(); fireEvent(tablePreview, EVENT_PREVIEW); break; case SELECT_REPORT_ITEM: if (cmbDataItems.getText().equals(getDataServiceProvider().getReportItemReference())) { return; } if (getDataServiceProvider().isNoNameItem(cmbDataItems.getText())) { MessageDialog dialog = new MessageDialog(UIUtil.getDefaultShell(), org.eclipse.birt.report.designer.nls.Messages .getString("dataBinding.title.haveNoName"), //$NON-NLS-1$ null, org.eclipse.birt.report.designer.nls.Messages .getString("dataBinding.message.haveNoName"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { org.eclipse.birt.report.designer.nls.Messages .getString("dataBinding.button.OK")//$NON-NLS-1$ }, 0); dialog.open(); btnInherit.setSelection(true); btnUseData.setSelection(false); btnInherit.notifyListeners(SWT.Selection, new Event()); return; } getDataServiceProvider().setReportItemReference(cmbDataItems.getText()); // TED 10163 // Following calls will revise chart model for // report item sharing case, in older version of // chart, it is allowed to set grouping on category // series when sharing report item, but now it isn't // allowed, so this calls will revise chart model to // remove category series grouping flag for the // case. ChartReportItemUtil.reviseChartModel(ChartReportItemUtil.REVISE_REFERENCE_REPORT_ITEM, this.getContext().getModel(), itemHandle); // Bugzilla 265077. if (this.getDataServiceProvider().checkState(IDataServiceProvider.SHARE_CHART_QUERY)) { ChartAdapter.beginIgnoreNotifications(); this.getDataServiceProvider().update(ChartUIConstants.COPY_SERIES_DEFINITION, null); ChartAdapter.endIgnoreNotifications(); } currentDataReference = cmbDataItems.getText(); // selectDataSet( ); // switchDataSet( cmbDataItems.getText( ) ); // Update preview via event DataDefinitionTextManager.getInstance().refreshAll(); fireEvent(tablePreview, EVENT_PREVIEW); setEnabledForButtons(); updateDragDataSource(); break; case SELECT_NEW_DATASET: // Bring up the dialog to create a dataset int result = invokeNewDataSet(); if (result == Window.CANCEL) { if (currentDataReference == null) { cmbDataItems.select(0); } else { cmbDataItems.setText(getDataSetName(currentDataReference)); } return; } cmbDataItems.removeAll(); List<Object> dataItems = new ArrayList<Object>(); cmbDataItems.setItems(createDataComboItems(dataItems)); List<Object> oldDataItems = (List<Object>) cmbDataItems.getData(); cmbDataItems.setData(dataItems); // select the newly created data set for user DataSetInfo[] datasets = getDataServiceProvider().getAllDataSets(); int index = 0; for (index = datasets.length - 1; index >= 0; index--) { if (!oldDataItems.contains(datasets[index])) { break; } } currentDataReference = datasets[index]; getDataServiceProvider().setDataSet((DataSetInfo) currentDataReference); cmbDataItems.setText(getDataSetName(currentDataReference)); setEnabledForButtons(); updateDragDataSource(); break; case SELECT_NEW_DATACUBE: if (getDataServiceProvider().getAllDataSets().length == 0) { invokeNewDataSet(); } int count = getDataServiceProvider().getAllDataCubes().length; if (getDataServiceProvider().getAllDataSets().length != 0) { new NewCubeAction().run(); } String[] datacubes = getDataServiceProvider().getAllDataCubes(); cmbDataItems.removeAll(); dataItems = new ArrayList<Object>(); cmbDataItems.setItems(createDataComboItems(dataItems)); cmbDataItems.setData(dataItems); if (datacubes.length == count) { if (currentDataReference == null) { cmbDataItems.select(0); } else { cmbDataItems.setText(getDataSetName(currentDataReference)); } return; } // select the newly created data cube for user. currentDataReference = datacubes[datacubes.length - 1]; getDataServiceProvider().setDataCube(currentDataReference.toString()); cmbDataItems.setText(getDataSetName(currentDataReference)); updateDragDataSource(); setEnabledForButtons(); // Update preview via event DataDefinitionTextManager.getInstance().refreshAll(); fireEvent(tablePreview, EVENT_PREVIEW); break; } updatePredefinedQueries(); // autoSelect( true ); } else if (event.widget == btnShowDataPreviewA || event.widget == btnShowDataPreviewB) { Button w = (Button) event.widget; getContext().setShowingDataPreview(Boolean.valueOf(w.getSelection())); updateDragDataSource(); } checkDataBinding(); ChartWizard.removeException(ChartWizard.StaChartDSh_switch_ID); } catch (ChartException e1) { ChartWizard.showException(ChartWizard.StaChartDSh_switch_ID, e1.getLocalizedMessage()); } } }
From source file:org.eclipse.birt.data.oda.mongodb.ui.impl.MongoDBDataSetWizardPage.java
License:Open Source License
private void createCollectionSelectionArea(Composite topArea) { Group collGroup = new Group(topArea, SWT.NONE); GridLayout layout = new GridLayout(3, false); layout.horizontalSpacing = 12;// w ww . j a v a 2 s. c o m collGroup.setLayout(layout); collGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); collGroup.setText(Messages.getString("MongoDBDataSetWizardPage.label.DBCollection")); //$NON-NLS-1$ sysCollOption = new Button(collGroup, SWT.CHECK); sysCollOption.setText(Messages.getString("MongoDBDataSetWizardPage.Button.text.IncludeSystemCollection")); //$NON-NLS-1$ sysCollOption.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { includeSysColl = sysCollOption.getSelection(); } public void widgetDefaultSelected(SelectionEvent e) { } }); collectionCombo = new Combo(collGroup, SWT.BORDER); collectionCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); collectionCombo.setVisibleItemCount(20); collectionSelectionListener = new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (selectedFields.size() == 0) { if (!collectionCombo.getText().equals(oldCollectionName)) { modelChanged = true; collectionName = collectionCombo.getText().trim(); oldCollectionName = collectionName; resetOpTypeComboItems(); doUpdateAvailableFieldsArea(); validateData(); } } else if (!collectionCombo.getText().equals(oldCollectionName)) { if (MessageDialog.open(MessageDialog.QUESTION, getShell(), Messages.getString("MongoDBDataSetWizardPage.MessageBox.title.PromptToKeepSelections"), //$NON-NLS-1$ Messages.getString( "MongoDBDataSetWizardPage.MessageBox.message.PromptToKeepSelections"), //$NON-NLS-1$ SWT.NONE)) { selectedFields.clear(); modelChanged = true; collectionName = collectionCombo.getText().trim(); resetOpTypeComboItems(); doUpdateAvailableFieldsArea(); validateData(); } else { collectionCombo.setText(oldCollectionName); } } resetExprBtnStatus(); } public void widgetDefaultSelected(SelectionEvent e) { } }; collectionModifyListener = new ModifyListener() { public void modifyText(ModifyEvent e) { oldCollectionName = collectionName; collectionName = collectionCombo.getText().trim(); resetOpTypeComboItems(); modelChanged = true; resetExprBtnStatus(); validateData(); } }; addCollectionComboListeners(); refreshBtn = new Button(collGroup, SWT.PUSH); refreshBtn.setText(Messages.getString("MongoDBDataSetWizardPage.Button.Refresh")); //$NON-NLS-1$ refreshBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { BusyIndicator.showWhile(Display.getDefault(), new Runnable() { public void run() { collectionList = metaData.getCollectionsList(!includeSysColl); } }); resetCollectionComboItems(); collectionName = collectionCombo.getText().trim(); resetOpTypeComboItems(); validateData(); } public void widgetDefaultSelected(SelectionEvent e) { } }); }
From source file:org.eclipse.birt.data.oda.mongodb.ui.impl.MongoDBDataSetWizardPage.java
License:Open Source License
private void createCommandOpArea(Composite topArea) { commandOpArea = new Group(topArea, SWT.NONE); GridLayout layout = new GridLayout(3, false); layout.horizontalSpacing = 12;//from w w w. j a v a 2 s.com commandOpArea.setLayout(layout); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.horizontalSpan = 3; commandOpArea.setLayoutData(layoutData); commandOpArea.setText(Messages.getString("MongoDBDataSetWizardPage.group.text")); //$NON-NLS-1$ opTypeLabel = new Label(commandOpArea, SWT.NONE); opTypeLabel.setText(Messages.getString("MongoDBDataSetWizardPage.label.OperationType")); //$NON-NLS-1$ opTypeCombo = new Combo(commandOpArea, SWT.BORDER | SWT.READ_ONLY); opTypeCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); opTypeSelectionListener = new SelectionListener() { public void widgetSelected(SelectionEvent e) { if (opType != null && opType.displayName().trim().equals(opTypeCombo.getText().trim())) { return; } doOpTypeChanged(); handleCommandOperationSelection(); if (opTypeCombo.getText().trim().length() == 0 && collectionCombo.getText().trim().length() > 0 && MessageDialog.open(MessageDialog.QUESTION, getShell(), Messages.getString( "MongoDBDataSetWizardPage.MessageBox.title.PromptToRefreshAvailableFields"), //$NON-NLS-1$ Messages.getString( "MongoDBDataSetWizardPage.MessageBox.message.PromptToRefreshAvailableFields"), //$NON-NLS-1$ SWT.NONE)) { doUpdateAvailableFieldsArea(); } modelChanged = true; validateData(); } public void widgetDefaultSelected(SelectionEvent e) { } }; opTypeCombo.addSelectionListener(opTypeSelectionListener); cmdExprBtn = new Button(commandOpArea, SWT.PUSH); cmdExprBtn.setText(Messages.getString("MongoDBDataSetWizardPage.Button.text.CommandExpression")); //$NON-NLS-1$ cmdExprBtn.setToolTipText(Messages.getString("MongoDBDataSetWizardPage.Button.tooltip.CommandExpression")); //$NON-NLS-1$ cmdExprBtn.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { MDBCommandExpressionBuilder cmdExprDialog = new MDBCommandExpressionBuilder( Display.getDefault().getActiveShell(), opType); cmdExprDialog.setExpressionText(cmdExprValue); if (cmdExprDialog.open() == Window.OK) { String oldCmdExpr = cmdExprValue; cmdExprValue = cmdExprDialog.getExprText(); if (cmdExprValue != null && !cmdExprValue.equals(oldCmdExpr)) { modelChanged = true; queryProps.setOperationExpression(cmdExprValue); if (UIHelper.isEmptyString(collectionName) && allAvailableFields.size() == 0) { doUpdateAvailableFieldsArea(); } else if (MessageDialog.open(MessageDialog.QUESTION, getShell(), Messages.getString( "MongoDBDataSetWizardPage.MessageBox.title.PromptToRefreshAvailableFields"), //$NON-NLS-1$ Messages.getString( "MongoDBDataSetWizardPage.MessageBox.message.PromptToRefreshAvailableFields"), //$NON-NLS-1$ SWT.NONE)) { doUpdateAvailableFieldsArea(); } validateData(); } } } public void widgetDefaultSelected(SelectionEvent e) { } }); }
From source file:org.eclipse.birt.report.designer.internal.ui.dialogs.BindingPage.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) loadValue(); switch (type) { case ReportItemHandle.DATABINDING_TYPE_NONE: case ReportItemHandle.DATABINDING_TYPE_DATA: if (info.equals(NullDatasetChoice)) { info = null;// w w w . ja va 2s. c om } 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: load(); break; case 4: updateDataSetReference(info); break; } break; case ReportItemHandle.DATABINDING_TYPE_REPORT_ITEM_REF: String value = info.getBindingValue().toString(); 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()) || 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: load(); } } } }
From source file:org.eclipse.birt.report.designer.internal.ui.dialogs.DataColumnBindingDialog.java
License:Open Source License
protected void okPressed() { try {// ww w. ja va 2s . c om ComputedColumnHandle newBindingColumn = null; if (bindingColumn != null) { if (dialogHelper.differs(bindingColumn)) { if (isNeedPrompt() && isBindingMultipleReferenced()) { MessageDialog dialog = new MessageDialog(UIUtil.getDefaultShell(), Messages.getString("DataColumnBindingDialog.NewBindingDialogTitle"), //$NON-NLS-1$ null, Messages.getString("DataColumnBindingDialog.NewBindingDialogMessage"), //$NON-NLS-1$ MessageDialog.QUESTION, new String[] { Messages.getString("DataColumnBindingDialog.NewBindingDialogButtonYes"), //$NON-NLS-1$ Messages.getString("DataColumnBindingDialog.NewBindingDialogButtonNo"), //$NON-NLS-1$ Messages.getString("DataColumnBindingDialog.NewBindingDialogButtonCancel") //$NON-NLS-1$ }, 0); int dialogClick = dialog.open(); if (dialogClick == 0) { InputDialog inputDialog = new InputDialog(UIUtil.getDefaultShell(), Messages.getString("DataColumnBindingDialog.NewBindingDialogInputNewNameTitle"), //$NON-NLS-1$ Messages.getString( "DataColumnBindingDialog.NewBindingDialogInputNewNameMessage"), //$NON-NLS-1$ "", //$NON-NLS-1$ new IInputValidator() { public String isValid(String newText) { for (Iterator iterator = DEUtil.getBindingHolder(bindingObject) .getColumnBindings().iterator(); iterator.hasNext();) { ComputedColumnHandle computedColumn = (ComputedColumnHandle) iterator .next(); if (computedColumn.getName().equals(newText)) { return Messages.getFormattedString( "BindingDialogHelper.error.nameduplicate", //$NON-NLS-1$ new Object[] { newText }); } } return null; } }); if (inputDialog.open() == Window.OK) { bindingColumn = dialogHelper.newBinding(DEUtil.getBindingHolder(bindingObject), inputDialog.getValue()); super.okPressed(); return; } else { return; } } else if (dialogClick == 2) { return; } } if (!dialogHelper.canProcessWithWarning()) return; bindingColumn = dialogHelper.editBinding(bindingColumn); } } else { if (!dialogHelper.canProcessWithWarning()) return; if (bindSelf) bindingColumn = dialogHelper.newBinding(bindingObject, null); else bindingColumn = dialogHelper.newBinding(DEUtil.getBindingHolder(bindingObject), null); newBindingColumn = bindingColumn; } if (ExtendedDataModelUIAdapterHelper.isBoundToExtendedData(DEUtil.getBindingHolder(bindingObject))) { DataModelAdapterStatus status = DataModelAdapterUtil .validateRelativeTimePeriod(DEUtil.getBindingHolder(bindingObject), bindingColumn); if (status.getStatus() == DataModelAdapterStatus.Status.FAIL) { MessageDialog.openError(UIUtil.getDefaultShell(), null, status.getMessage()); removeColumnBinding(newBindingColumn); return; } } super.okPressed(); } catch (Exception e) { ExceptionHandler.handle(e); } }
From source file:org.eclipse.birt.report.designer.internal.ui.dialogs.resource.ExportElementDialog.java
License:Open Source License
private int confirmOverride(String confirmTitle, String confirmMsg) { String[] buttons = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; if (confirmTitle == null || confirmTitle.trim().length() == 0) { confirmTitle = Messages.getString("ExportElementDialog.WarningMessageDuplicate.Title"); //$NON-NLS-1$ }// ww w.ja va 2s .com if (confirmMsg == null || confirmMsg.trim().length() == 0) { confirmMsg = Messages.getFormattedString("ExportElementDialog.WarningMessageDuplicate.Message", //$NON-NLS-1$ buttons); } MessageDialog dialog = new MessageDialog(UIUtil.getDefaultShell(), confirmTitle, null, confirmMsg, MessageDialog.QUESTION, buttons, 0); return dialog.open(); }
From source file:org.eclipse.birt.report.designer.internal.ui.editors.wizards.WizardSaveAsPage.java
License:Open Source License
public IPath getResult() { IPath path = support.getFileLocationFullPath().append(support.getFileName()); // 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 (ReportPlugin.getDefault().isReportDesignFile(support.getInitialFileName()) && !ReportPlugin.getDefault().isReportDesignFile(path.toOSString())) { String[] parts = support.getInitialFileName().split("\\."); //$NON-NLS-1$ path = path.addFileExtension(parts[parts.length - 1]); } else if (support.getInitialFileName().endsWith(IReportEditorContants.TEMPLATE_FILE_EXTENTION) && !path.toOSString().endsWith(IReportEditorContants.TEMPLATE_FILE_EXTENTION)) { path = path.addFileExtension("rpttemplate"); //$NON-NLS-1$ }//from ww w . j a va 2 s .c o m // If the path already exists then confirm overwrite. File file = path.toFile(); if (file.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[] { path.toOSString() }); MessageDialog d = new MessageDialog(getShell(), Messages.getString("SaveAsDialog.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; }