List of usage examples for org.eclipse.jface.dialogs MessageDialog openWarning
public static void openWarning(Shell parent, String title, String message)
From source file:cn.edu.xmu.tidems.control.ui.views.components.MzCalibrationDialog.java
License:Open Source License
private boolean checkInput() { for (int i = 0; i < 3; i++) { try {// w ww .j ava 2s . c o m Double.parseDouble(txtTof[i].getText().trim()); } catch (final Exception e) { MessageDialog.openWarning(getShell(), "Warning", "Input must be a number"); txtTof[i].setFocus(); return false; } try { Double.parseDouble(txtMz[i].getText().trim()); } catch (final Exception e) { MessageDialog.openWarning(getShell(), "Warning", "Input must be a number"); txtMz[i].setFocus(); return false; } } return true; }
From source file:com.ah.filecompareassist.plugin.eclipse.handlers.CompareFileHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { try {/*w w w . j a va 2s.c om*/ DebugUtil.debug("--------- Trigger(Start) ----------"); IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); // get the project which need to compare with by current selected // menu String comparedPrjName = getComparePrjName(event); ISelection selection = HandlerUtil.getActiveMenuSelection(event); DebugUtil.debug("Selection class: " + selection.getClass()); // get the selection information // only handle the StructuredSelection or the TextSelection SelectionElement selectoionEl = CommandUtil.getSelectedElementInfo(window, selection); if (null == selectoionEl || selectoionEl.isNull()) { MessageDialog.openWarning(window.getShell(), "Locale Compare Warning", "Unknown error when compare with the project - " + comparedPrjName); return null; } // open compare editor openCompareEditor(window, comparedPrjName, selectoionEl); } finally { DebugUtil.debug("--------- Trigger(End) ----------"); } return null; }
From source file:com.ah.filecompareassist.plugin.eclipse.handlers.CompareFileHandler.java
License:Open Source License
private void openCompareEditor(IWorkbenchWindow window, String comparedPrjName, SelectionElement selectoionEl) { IPath workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation(); DebugUtil.debug("Append prj name to Root: " + workspacePath.append(selectoionEl.getPrjName()).toString()); if (!(null == comparedPrjName || comparedPrjName.trim().isEmpty())) { IPath comparedPrjPath = workspacePath.append(comparedPrjName); if (comparedPrjPath.toFile().exists()) { // get the compared file location string String nfileLocationStr = selectoionEl.getResourceLocation().toString().replace( workspacePath.append(selectoionEl.getPrjName()).toString(), comparedPrjPath.toString()); DebugUtil.debug("find the " + nfileLocationStr + " need to compare with."); if (new File(nfileLocationStr).exists()) { // mock the second resource according the selected sub menu IFile secondElement = ResourcesPlugin.getWorkspace().getRoot() .getFile(new Path(nfileLocationStr.replace(workspacePath.toString(), ""))); // invoke compare action CompareAction action = new CompareAction(window, new IResource[] { (IResource) selectoionEl.getElement(), secondElement }); action.execute();//from w w w . j av a 2 s . c o m } else { MessageDialog.openWarning(window.getShell(), "Locale Compare Warning", "The file - " + nfileLocationStr + " doesn't exists."); } } else { MessageDialog.openWarning(window.getShell(), "Locale Compare Warning", "The project - " + comparedPrjName + " doesn't exists."); } } }
From source file:com.aliyun.odps.eclipse.utils.DialogUtil.java
License:Apache License
public static void warn(String title, String msg) { MessageDialog.openWarning(Display.getDefault().getActiveShell(), title, msg); }
From source file:com.amalto.workbench.actions.XSDEditIdentityConstraintAction.java
License:Open Source License
public IStatus doAction() { try {/*ww w . j a va2 s . com*/ ISelection selection = page.getTreeViewer().getSelection(); constraint = (XSDIdentityConstraintDefinition) ((IStructuredSelection) selection).getFirstElement(); String oldName = constraint.getName(); InputDialog id = new InputDialog(page.getSite().getShell(), Messages.XSDEditIdentityXX_EditKey, Messages.XSDEditIdentityXX_EnterANameForKey, oldName, new EditXSDIdentityConstraintNameValidator(constraint) // new IInputValidator() { // public String isValid(String newText) { // if ((newText==null) || "".equals(newText)) return "The Entity Name cannot be empty"; // XSDSchema schema = XSDEditIdentityConstraintAction.this.constraint.getSchema(); // EList list = schema.getIdentityConstraintDefinitions(); // for (Iterator iter = list.iterator(); iter.hasNext(); ) { // XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) iter.next(); // if (icd.getName().equals(newText)) return "This Key already exists"; // } // return null; // }; // } ); id.setBlockOnOpen(true); int ret = id.open(); if (ret == Dialog.CANCEL) { return Status.CANCEL_STATUS; } if (XSDIdentityConstraintCategory.UNIQUE_LITERAL.equals(constraint.getIdentityConstraintCategory()) && !((XSDElementDeclaration) constraint.getContainer()).getName().equals(id.getValue())) { MessageDialog.openWarning(page.getSite().getShell(), Messages.Warning, Messages.XSDEditIdentityXX_WarningMsg); return Status.CANCEL_STATUS; } constraint.setName(id.getValue()); constraint.updateElement(); page.refresh(); page.markDirty(); } catch (Exception e) { log.error(e.getMessage(), e); MessageDialog.openError(page.getSite().getShell(), Messages._Error, Messages.bind(Messages.XSDEditIdentityXX_ErrorEditEntity, e.getLocalizedMessage())); return Status.CANCEL_STATUS; } return Status.OK_STATUS; }
From source file:com.amalto.workbench.detailtabs.sections.composites.EntityKeyConfigComposite.java
License:Open Source License
private void initListener2BtnRemoveField() { lBtnRemoveFieldListner = new SelectionAdapter() { @Override/* ww w .j a v a 2 s . c o m*/ public void widgetSelected(SelectionEvent e) { KeyWrapper[] selectedKeys = getSelectedKeys(); if (selectedKeys.length == 0) { return; } FieldWrapper[] selectedFields = getSelectedFields(); if (selectedFields.length == 0) { return; } if (getAllFields().length == selectedFields.length) { MessageDialog.openWarning(getShell(), Messages.Warning, Messages.EntityKeyConfigComposite_WarningMsg); return; } for (FieldWrapper eachRemovedField : selectedFields) { selectedKeys[0].removeField(eachRemovedField); } tvFields.setInput(Arrays.asList(selectedKeys[0].getFields())); if (section != null) { section.autoCommit(); } } }; }
From source file:com.amalto.workbench.detailtabs.sections.composites.LanguageInfoComposite.java
License:Open Source License
private void onMidifyLabelText() { LanguageInfo correspondLangInfo = getLangInfoBySelectionOfLangCombo(); if (correspondLangInfo == null) return;/*from w w w . j ava 2 s. c o m*/ if (correspondLangInfo.getLabel().equals(txtLabel.getText().trim())) return; if ("".equals(txtLabel.getText().trim())) { //$NON-NLS-1$ MessageDialog.openWarning(getShell(), Messages.Warning, Messages.LanguageInfoComposite_InfoCannotbeEmpty); txtLabel.setText(correspondLangInfo.getLabel()); } correspondLangInfo.setLabel(txtLabel.getText().trim()); tvInfos.refresh(); if (section != null) section.autoCommit(); }
From source file:com.amalto.workbench.detailtabs.sections.composites.LanguageInfoComposite.java
License:Open Source License
private void onAddLanguageInfo() { if ("".equals(txtLabel.getText().trim())) { //$NON-NLS-1$ MessageDialog.openWarning(getShell(), Messages.Warning, Messages.LanguageInfoComposite_InfoCannotbeEmpty); return;//from w w w . j av a2 s.c o m } LanguageInfo correspondLangInfo = getLangInfoBySelectionOfLangCombo(); if (correspondLangInfo == null) { LanguageInfo newLangInfo = new LanguageInfo(comboLanguage.getText(), Util.lang2iso.get(comboLanguage.getText()), txtLabel.getText().trim()); infos.add(newLangInfo); } else { correspondLangInfo.setLabel(txtLabel.getText().trim()); } tvInfos.refresh(); if (section != null) section.autoCommit(); }
From source file:com.amalto.workbench.dialogs.SelectImportedModulesDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { parent.getShell().setText(this.title); Composite composite = (Composite) super.createDialogArea(parent); GridLayout layout = (GridLayout) composite.getLayout(); layout.numColumns = 2;/*from ww w . j a va 2s . c o m*/ SashForm form = new SashForm(composite, SWT.HORIZONTAL); GridData data = new GridData(GridData.FILL, GridData.FILL, true, true, 1, 1); data.widthHint = 400; data.heightHint = 300; form.setLayoutData(data); entityViewer = createTableViewer(form, "Entities", entityprovider, new XSDTreeLabelProvider()); typeViewer = createTableViewer(form, "Types", typeprovider, new TypesLabelProvider()); form.setWeights(new int[] { 3, 5 }); Composite compositeBtn = new Composite(composite, SWT.FILL); compositeBtn.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false, 1, 1)); compositeBtn.setLayout(new GridLayout(1, false)); Button addXSDFromLocal = new Button(compositeBtn, SWT.PUSH | SWT.FILL); addXSDFromLocal.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false, 1, 1)); addXSDFromLocal.setText(Messages.AddXsdFromlocal); addXSDFromLocal.setToolTipText(Messages.AddXsdSchemaFromlocal); addXSDFromLocal.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) { }; public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { FileDialog fd = new FileDialog(shell.getShell(), SWT.SAVE); fd.setFilterExtensions(new String[] { "*.xsd" });//$NON-NLS-1$ fd.setText(Messages.ImportXSDSchema); String filename = fd.open(); if (filename == null) { return; } URL url = getSourceURL("file:///" + filename); addSchema(url, true); } }); if (exAdapter != null) { exAdapter.createDialogArea(compositeBtn); } Button impXSDFromExchange = new Button(compositeBtn, SWT.PUSH | SWT.FILL); impXSDFromExchange.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false, 1, 1)); impXSDFromExchange.setText(Messages.ImportFromExchangeServer); impXSDFromExchange.setToolTipText(Messages.ImportSchemaFromServer); impXSDFromExchange.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { StringBuffer repository = new StringBuffer(); ImportExchangeOptionsDialog dlg = new ImportExchangeOptionsDialog(shell.getShell(), null, false, repository); dlg.setBlockOnOpen(true); int ret = dlg.open(); if (ret == Window.OK) { File dir = new File(repository.toString()); File[] fs = dir.listFiles(new FileFilter() { public boolean accept(File pathname) { return pathname.getName().endsWith(".xsd"); } }); if (null == fs || fs.length == 0) { MessageDialog.openWarning(getShell(), Messages.import_schema_failed, Messages.no_schema_available); return; } for (File file : fs) { URL url = getSourceURL("file:///" + file.getPath()); addSchema(url, true); } } } }); Button addXSDFromInputDlg = new Button(compositeBtn, SWT.PUSH | SWT.FILL); addXSDFromInputDlg.setLayoutData(new GridData(SWT.FILL, SWT.NONE, false, false, 1, 1)); addXSDFromInputDlg.setText(Messages.AddXsdFromOther); addXSDFromInputDlg.setToolTipText(Messages.AddFromOtherSite); addXSDFromInputDlg.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent e) { }; public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { InputDialog id = new InputDialog(shell.getShell(), Messages.AddXsdFromOther, Messages.EnterTextUrl, "", new IInputValidator() { //$NON-NLS-1$ public String isValid(String newText) { if ((newText == null) || "".equals(newText)) { return Messages.NameNotEmpty; } return null; }; }); id.setBlockOnOpen(true); int ret = id.open(); if (ret == Window.CANCEL) { return; } URL url = getSourceURL(id.getValue()); addSchema(url, true); } }); entityViewer.setInput(addContent); typeViewer.setInput(addContent); return composite; }
From source file:com.amalto.workbench.dialogs.ValidationRuleDialog.java
License:Open Source License
private boolean doCheck() { if (checkNameIsDuplicated(struc, name)) { MessageDialog.openWarning(page.getSite().getShell(), Messages.Warning, Messages.ValidationRuleDialog_InputDuplicateName); return false; }/* ww w . j a v a 2s . co m*/ if (name == null || name.trim().equals("")) { //$NON-NLS-1$ MessageDialog.openWarning(page.getSite().getShell(), Messages.Warning, Messages.ValidationRuleDialog_InputBlankName); return false; } return true; }