dialog.setBlockOnOpen(true); dialog.open(); if (dialog.getReturnCode() == Window.CANCEL) { returnValue[0] = null; } else {
private void addIgnore() { InputDialog dialog = new InputDialog(getShell(), TeamUIMessages.IgnorePreferencePage_enterPatternShort, TeamUIMessages.IgnorePreferencePage_enterPatternLong, null, null); // dialog.open(); if (dialog.getReturnCode() != Window.OK) return; String pattern = dialog.getValue(); if (pattern.equals("")) return; //$NON-NLS-1$ // Check if the item already exists TableItem[] items = ignoreTable.getItems(); for (int i = 0; i < items.length; i++) { if (items[i].getText().equals(pattern)) { MessageDialog.openWarning(getShell(), TeamUIMessages.IgnorePreferencePage_patternExistsShort, TeamUIMessages.IgnorePreferencePage_patternExistsLong); // return; } } TableItem item = new TableItem(ignoreTable, SWT.NONE); item.setText(TextProcessor.process(pattern, ".*")); //$NON-NLS-1$ item.setChecked(true); }
private void addIgnore() { InputDialog dialog = new InputDialog(getShell(), TeamUIMessages.IgnorePreferencePage_enterPatternShort, TeamUIMessages.IgnorePreferencePage_enterPatternLong, null, null) { @Override protected Control createDialogArea(Composite parent) { Control control = super.createDialogArea(parent); PlatformUI.getWorkbench().getHelpSystem().setHelp(control, IHelpContextIds.IGNORE_PREFERENCE_PAGE); return control; } }; dialog.open(); if (dialog.getReturnCode() != Window.OK) return; String pattern = dialog.getValue(); if (pattern.equals("")) return; //$NON-NLS-1$ // Check if the item already exists TableItem[] items = ignoreTable.getItems(); for (int i = 0; i < items.length; i++) { if (items[i].getText().equals(pattern)) { MessageDialog.openWarning(getShell(), TeamUIMessages.IgnorePreferencePage_patternExistsShort, TeamUIMessages.IgnorePreferencePage_patternExistsLong); return; } } TableItem item = new TableItem(ignoreTable, SWT.NONE); item.setText(TextProcessor.process(pattern, ".*")); //$NON-NLS-1$ item.setChecked(true); }
/** * {@inheritDoc} */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { FormRootEditor editor = (FormRootEditor) HandlerUtil.getActiveEditor(event); Shell shell = HandlerUtil.getActiveShell(event); IInputValidator inputValidator = new IInputValidator() { @Override public String isValid(String newText) { if (StringUtils.isEmpty(newText)) { return "Name of the view is required"; } return null; } }; InputDialog inputDialog = new InputDialog(shell, "Rename View", "Please enter new name for the active view", editor.getPartName(), inputValidator); inputDialog.open(); if (inputDialog.getReturnCode() == Window.OK) { String name = inputDialog.getValue(); editor.updateEditorName(name); } return null; }