/** * @param current * @return */ protected String getInputObject(final String current) { final InputDialog dialog = new InputDialog(this.getShell(), JVM_NEW_LABEL, JVM_ENTER_LABEL, current, null); String param = null; final int dialogCode = dialog.open(); if (dialogCode == 0) { param = dialog.getValue(); if (param != null) { param = param.trim(); if (param.length() == 0) { return null; } } } return param; }
protected String getNewInputObject(){ String returnvalue = null; ProxyInputDialog inputDialog = new ProxyInputDialog(getShell()); if (inputDialog.open() == InputDialog.OK) { // check for valid Input try { String name = inputDialog.getName(); String host = inputDialog.getHost(); String port = inputDialog.getPort(); String inputText = name + "," + host + "," + port; // parse String for empty fields ProxyItem.createFromString(inputText); returnvalue = inputText; } catch (Exception e) { MessageDialog.openError(getShell(), "Wrong entry", "None of the fields must be left blank"); } } return returnvalue; }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { NamedElement element = refactoring.getContextObject(); if (element != null) { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); InputDialog dialog = new InputDialog(window.getShell(), "Rename..", "Please enter new name:", element.getName(), new NameUniquenessValidator(element)); if (dialog.open() == Window.OK) { String newName = dialog.getValue(); if (newName != null) { ((RenameRefactoring)refactoring).setNewName(newName); refactoring.execute(); } } } return null; }
private void hookRenameAction() { DockerContainerElement elem = getSelectedElement(); if(elem != null && getClient() != null){ IInputValidator validator = new IInputValidator() { public String isValid(String newText) { if (newText.contains("\\") || newText.contains(":") || newText.contains("/") ) return newText + " is not a valid Docker container's name."; else return null; } }; InputDialog dialog = new InputDialog(viewer.getControl().getShell(), "Rename an existing container", "New name:", elem.getNames().get(0)+"2", validator); if (dialog.open() == Window.OK) { String newName = dialog.getValue(); //@ TODO docker client does not provide renaming API now. } } }
@Override public void run() { InputDialog inputDialog = new InputDialog(null, "Provide String", "Provide a new Name for the EClass", eclass.getName(), null); int open = inputDialog.open(); if (open == Dialog.OK) { String newName = inputDialog.getValue(); Resource resource = eclass.eResource(); ResourceSet resourceSet = resource.getResourceSet(); TransactionalEditingDomain domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet); try{ if (domain != null){ Command setCommand = domain.createCommand(SetCommand.class, new CommandParameter(eclass, EcorePackage.Literals.ENAMED_ELEMENT__NAME, newName)); domain.getCommandStack().execute(setCommand); try { resource.save(Collections.emptyMap()); } catch (IOException e) { e.printStackTrace(); } } }finally{ domain.dispose(); } } }
protected void saveList() { ClosedPart[] partList = tabArea.getClosedPartList(); List/*<EditorInfo>*/ infos = new ArrayList(); for (int i = 0; i < partList.length; i++) { EditorInfo info = partList[i].getEditorInfo(); if(info != null && info.isConsistent()){ info.setNumber(i); infos.add(info); } } if(infos.isEmpty()){ // TODO show message return; } IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); InputDialog dialog = new InputDialog(window.getShell(), "Save session", "Enter session name", null, new SessionNameValidator(true)); int result = dialog.open(); if(result == Window.CANCEL){ return; } Sessions.getInstance().createSession(dialog.getValue(), infos); }
protected void saveList() { IPresentablePart[] partList = tabArea.getPartList(); VSStackPresentation presentation = tabArea.getPresentation(); List/*<EditorInfo>*/ infos = new ArrayList(); for (int i = 0; i < partList.length; i++) { EditorInfo info = presentation.createEditorInfo(partList[i]); if(info != null){ infos.add(info); } } if(infos.isEmpty()){ // TODO show message return; } IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); InputDialog dialog = new InputDialog(window.getShell(), "Save session", "Enter session name", null, new SessionNameValidator(true)); int result = dialog.open(); if(result == Window.CANCEL){ return; } Sessions.getInstance().createSession(dialog.getValue(), infos); }
public void run() { IPresentablePart[] partList = site.getPartList(); List/*<EditorInfo>*/ infos = new ArrayList(); for (int i = 0; i < partList.length; i++) { EditorInfo info = presentation.createEditorInfo(partList[i]); if(info != null){ infos.add(info); } } if(infos.isEmpty()){ // TODO show message return; } boolean createNew = sessionName == null; if(createNew){ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); InputDialog dialog = new InputDialog(window.getShell(), "Save session", "Enter session name", null, new SessionNameValidator(true)); int result = dialog.open(); if(result == Window.CANCEL){ return; } sessionName = dialog.getValue(); } Sessions.getInstance().createSession(sessionName, infos, !createNew); }
/** * @see org.eclipse.jface.action.Action#run() */ @Override public void run() { KeyTreeNode node = getNodeSelection(); String key = node != null ? node.getMessageKey() : "new_key"; String msgHead = Messages.dialog_add_head; String msgBody = Messages.dialog_add_body; InputDialog dialog = new InputDialog(getShell(), msgHead, msgBody, key, new IInputValidator() { public String isValid(String newText) { if (getBundleGroup().isMessageKey(newText)) { return Messages.dialog_error_exists; } return null; } }); dialog.open(); if (dialog.getReturnCode() == Window.OK) { String inputKey = dialog.getValue(); MessagesBundleGroup messagesBundleGroup = getBundleGroup(); messagesBundleGroup.addMessages(inputKey); } }
@Override public void openRefactorDialog(String projectName, String resourceBundleId,String oldKey, String enumName) { KeyRefactoringDialog dialog = new KeyRefactoringDialog(Display.getDefault().getActiveShell()); DialogConfiguration config = dialog.new DialogConfiguration(); config.setPreselectedKey(oldKey); config.setPreselectedBundle(resourceBundleId); config.setProjectName(projectName); dialog.setDialogConfiguration(config); if (dialog.open() != InputDialog.OK) { return; } refactorKey(projectName, resourceBundleId, config.getSelectedLocale(),oldKey, config.getNewKey(), enumName); }
@Override public void execute() { newDataset = (JRDesignDataset) originalDataset.clone(); boolean operationAborted = false; try { while (jrDesign.getDatasetMap().containsKey(newDataset.getName()) && !operationAborted) { String defaultName = ModelUtils.getDefaultName(jrDesign.getDatasetMap(), "CopyOfDataset_"); //$NON-NLS-1$ InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), Messages.CreateFieldCommand_field_name, Messages.CreateFieldCommand_field_name_text_dialog, defaultName, null); if (dlg.open() == InputDialog.OK) { newDataset.setName(dlg.getValue()); } else operationAborted = true; } if (!operationAborted) jrDesign.addDataset(newDataset); } catch (JRException e) { e.printStackTrace(); } }
@Override public void execute() { if (jrParameter == null) { this.jrParameter = MParameter.createJRParameter(jrDataset); } if (jrParameter != null) { try { if (index < 0 || index > jrDataset.getParametersList().size()) jrDataset.addParameter(jrParameter); else jrDataset.addParameter(index, jrParameter); } catch (JRException e) { e.printStackTrace(); if (e.getMessage().startsWith("Duplicate declaration")) { //$NON-NLS-1$ String defaultName = ModelUtils.getDefaultName(jrDataset.getParametersMap(), "CopyOFParameter_"); //$NON-NLS-1$ InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), Messages.CreateParameterCommand_parameter_name, Messages.CreateParameterCommand_parameter_name_dialog_text, defaultName, null); if (dlg.open() == InputDialog.OK) { jrParameter.setName(dlg.getValue()); execute(); } } } } }
@Override public void execute() { if (jrStyle == null) { this.jrStyle = MStyle.createJRStyle(jrDesign); } if (jrStyle != null) { try { if (index < 0 || index > jrDesign.getStylesList().size()) jrDesign.addStyle(jrStyle); else jrDesign.addStyle(index, jrStyle); } catch (JRException e) { e.printStackTrace(); if (e.getMessage().startsWith("Duplicate declaration")) { //$NON-NLS-1$ String defaultName = ModelUtils.getDefaultName(jrDesign.getStylesMap(), "CopyOf_"+jrStyle.getName()); //$NON-NLS-1$ InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), Messages.CreateStyleCommand_style_name, Messages.CreateStyleCommand_style_name_dialog_text, defaultName, null); if (dlg.open() == InputDialog.OK) { jrStyle.setName(dlg.getValue()); execute(); } } } } }
@Override public void execute() { if (jrScriptlet == null) { this.jrScriptlet = MScriptlet.createJRScriptlet(jrDataset); } if (jrScriptlet != null) { try { if (index >= 0 && index < jrDataset.getScriptletsList().size()) jrDataset.addScriptlet(index, jrScriptlet); else jrDataset.addScriptlet(jrScriptlet); } catch (JRException e) { e.printStackTrace(); if (e.getMessage().startsWith("Duplicate declaration")) { //$NON-NLS-1$ String defaultName = ModelUtils.getDefaultName(jrDataset.getScriptletsMap(), "CopyOFScriptlet_"); //$NON-NLS-1$ InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), Messages.CreateScriptletCommand_scriptlet_name, Messages.CreateScriptletCommand_scriptlet_name_dialog_text, defaultName, null); if (dlg.open() == InputDialog.OK) { jrScriptlet.setName(dlg.getValue()); execute(); } } } } }
@Override public void widgetSelected(final SelectionEvent e) { final InputDialog dialog = new InputDialog(getShell(), "New Category", "Name:", null, new IInputValidator() { @Override public String isValid(final String newText) { if (newText != null && newText.trim().length() > 0 && !contains(categoryList.getItems(), newText)) { return null; } return "Unique name required"; } }); if (dialog.open() == Window.OK) { newTab(dialog.getValue()); providersChanged = true; } }
@Override public void widgetSelected(final SelectionEvent e) { final InputDialog dialog = new InputDialog(getShell(), "New Name", "File name pattern like *.java, my.xml:", null, new IInputValidator() { @Override public String isValid(final String newText) { if (newText != null && newText.trim().length() > 0) { return null; } return ""; } }); if (dialog.open() == Window.OK) { addFileName(dialog.getValue()); } }
/** * Return the new name to be given to the target resource. * * @return java.lang.String * @param resource * the resource to query status on */ protected String queryNewResourceName(final IResource resource) { final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace(); final IPath prefix = resource.getFullPath().removeLastSegments(1); final IInputValidator validator = string -> { if (resource.getName() .equals(string)) { return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent; } final IStatus status = workspace.validateName(string, resource.getType()); if (!status.isOK()) { return status.getMessage(); } if (workspace.getRoot() .exists(prefix.append(string))) { return IDEWorkbenchMessages.RenameResourceAction_nameExists; } return null; }; final InputDialog dialog = new InputDialog(WorkbenchHelper.getShell(), IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle, IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage, resource.getName(), validator); dialog.setBlockOnOpen(true); final int result = dialog.open(); if (result == Window.OK) return dialog.getValue(); return null; }
@Override public String getInput(String title, String description, String defaultText) { InputDialog dlgName = new InputDialog(Display.getCurrent().getActiveShell(), title, description, defaultText, null); if (dlgName.open() == Window.OK) { // User clicked OK; update the label with the input return dlgName.getValue(); } else { return null; } }
private static void promptForCommitInsideDisplayThread(Shell shell, Optional<String> name) { InputDialog dialog = new InputDialog( shell, "Commit Message", "Please enter a commit message" + name.map(n -> " for the diagram: " + n).orElse(StringUtils.EMPTY) + ".", StringUtils.EMPTY, EditorLauncherBase::isValidCommitMessage); dialog.setBlockOnOpen(true); if (dialog.open() != InputDialog.OK) { return; } String commitMessage = dialog.getValue(); try { transformationManager.handleEditorMerge(commitMessage); } catch (CommitException e) { LOGGER.error("Failed to merge branch into master.", e); ErrorDialog.openError(shell, "Commit failed", "The requested commit failed. " + "The changes stay in the temporary branch but will not appear on the master branch.", new Status(Status.ERROR, null, "Merging of branches failed.", e)); } }
@Override public void execute(Event event) { final ERDiagram diagram = getDiagram(); final List<?> selectedEditParts = getTreeViewer().getSelectedEditParts(); final EditPart editPart = (EditPart) selectedEditParts.get(0); final Object model = editPart.getModel(); if (model instanceof ERVirtualDiagram) { final ERVirtualDiagram vdiagram = (ERVirtualDiagram) model; final InputVirtualDiagramNameValidator validator = new InputVirtualDiagramNameValidator(diagram, vdiagram.getName()); final InputDialog dialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Rename", "Input new name", vdiagram.getName(), validator); if (dialog.open() == IDialogConstants.OK_ID) { final ChangeVirtualDiagramNameCommand command = new ChangeVirtualDiagramNameCommand(vdiagram, dialog.getValue()); execute(command); } } }
private void onRenameFilterSet() { final TourTypeFilter filter = (TourTypeFilter) ((StructuredSelection) _filterViewer.getSelection()) .getFirstElement(); final InputDialog inputDialog = new InputDialog( getShell(), Messages.Pref_TourTypeFilter_dlg_rename_title, Messages.Pref_TourTypeFilter_dlg_rename_message, filter.getFilterName(), null); inputDialog.open(); if (inputDialog.getReturnCode() != Window.OK) { return; } // update model filter.setName(inputDialog.getValue().trim()); // update viewer _filterViewer.update(filter, null); _isModified = true; }
/** * @see org.eclipse.jface.action.Action#run() */ public void run() { KeyTreeNode node = getNodeSelection(); String key = node.getMessageKey(); String msgHead = MessagesEditorPlugin.getString("dialog.add.head"); String msgBody = MessagesEditorPlugin.getString("dialog.add.body"); InputDialog dialog = new InputDialog( getShell(), msgHead, msgBody, key, new IInputValidator() { public String isValid(String newText) { if (getBundleGroup().isMessageKey(newText)) { return MessagesEditorPlugin.getString( "dialog.error.exists"); } return null; } }); dialog.open(); if (dialog.getReturnCode() == Window.OK ) { String inputKey = dialog.getValue(); MessagesBundleGroup messagesBundleGroup = getBundleGroup(); messagesBundleGroup.addMessages(inputKey); } }
@Override public Object execute(ExecutionEvent event) { ISelection selection = HandlerUtil.getCurrentSelection(event); EList<EPlanElement> elements = getSelectedTemporalElements(selection); if (elements.size() > 0) { IEditorPart editor = getActiveEditor(); if (editor == null) { return null; } CopyManyTimesInputValidator validator = new CopyManyTimesInputValidator(); InputDialog d = new InputDialog(editor.getSite().getShell(), actionName, "How many copies do you want to make?", "", validator); int code = d.open(); int nCopies = validator.getValue(); // this line must be after d.open(); if ((code == Window.OK) && (nCopies > 0) && (nCopies < 101)) { ECollections.sort(elements, TemporalChainUtils.CHAIN_ORDER); makinCopies(elements, nCopies); } } return null; }
private static INewNameQuery createStaticQuery(final IInputValidator validator, final String message, final String initial, final Shell shell){ return new INewNameQuery(){ public String getNewName() throws OperationCanceledException { InputDialog dialog= new InputDialog(shell, ReorgMessages.ReorgQueries_nameConflictMessage, message, initial, validator) { /* (non-Javadoc) * @see org.eclipse.jface.dialogs.InputDialog#createDialogArea(org.eclipse.swt.widgets.Composite) */ @Override protected Control createDialogArea(Composite parent) { Control area= super.createDialogArea(parent); TextFieldNavigationHandler.install(getText()); return area; } }; if (dialog.open() == Window.CANCEL) throw new OperationCanceledException(); return dialog.getValue(); } }; }
@Override protected String getNewInputObject() { IInputValidator validator = new IInputValidator() { public String isValid(String newText) { if(newText.contains("\t \n\r")) return "No whitespace characters allowed in architecture name"; else return null; } }; InputDialog dialog = new InputDialog(getShell(), "Name of new architecture", "Please specify the name of the new architectire. \n" + "I must a name known to buildif, e.g. arm, ppc, x86", null, validator); if(dialog.open() == Window.OK) { return dialog.getValue(); }else{ return null; } }
@Override protected String getNewInputObject() { IInputValidator validator = new IInputValidator() { public String isValid(String newText) { if(newText.contains("\t \n\r")) return "No whitespace characters allowed in architecture name"; else return null; } }; InputDialog dialog = new InputDialog(getShell(), "Name of new instrument", "Please specify the name of the new instrument. \n" + "This instrument name will be used in directory \n" + "names for projects that have been marked as \n" + "instrument specific in projects properties and when \n" + "assembling the installation path.", null, validator); if(dialog.open() == Window.OK) { return dialog.getValue(); }else{ return null; } }
protected int getGraphingRadius(int defaultSize) { Shell shell = new Shell(); InputDialog dlg = new InputDialog( shell, "Graph Radius", "How many edges from anchor?", "" + defaultSize, null); dlg.open(); if (dlg.getReturnCode() == Window.CANCEL) { throw new CancellationException(); } if (dlg.getReturnCode() != Window.OK) { return defaultSize; } String strval = dlg.getValue(); try { int intVal = Integer.parseInt(strval.trim()); return intVal; } catch (Throwable t) { t.printStackTrace(); } return defaultSize; }
private void addJumpToRevisionAction(IToolBarManager menuManager) { Action jumpTo = new Action() { @Override public void run() { final InputDialog inputDialog = new InputDialog(getSite().getShell(), "Go to revision", "Revision", "", null); if (inputDialog.open() == Window.OK) { if (projectSpace != null) { PrimaryVersionSpec versionSpec = resolveVersion(inputDialog.getValue()); if (versionSpec != null) { showAll(true); centerVersion = versionSpec; refresh(); } } } } }; jumpTo.setImageDescriptor(Activator.getImageDescriptor("/icons/magnifier.png")); jumpTo.setToolTipText("Go to revision..."); menuManager.add(jumpTo); }
/** * Shows a dialog so that the user can provide a name for the imported project. * * @param initialProjectName the name of the project that should be shown when opening the dialog * @return the entered project name */ private String showProjectNameDialog(String initialProjectName) { IInputValidator inputValidator = new IInputValidator() { public String isValid(String newText) { if (newText == null || newText.equals("") || newText.matches("\\s*")) { return "No project name provided!"; } return null; } }; InputDialog inputDialog = new InputDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Project Name", "Please enter a name for the imported project:", initialProjectName, inputValidator); if (inputDialog.open() == Dialog.OK) { return inputDialog.getValue(); } else { return null; } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); String title = "Connect to remote actor"; String question = "What is the address of the remote actor?"; InputDialog dialog = new InputDialog(shell, title, question, null, null); dialog.open(); if (dialog.getReturnCode() == Window.OK) { String path = dialog.getValue(); try { PluginHelper.start(path); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }
private void handleDefaultValueEditEvent( ) { InputDialog dialog = new InputDialog(this.getShell( ), DEFAULTVALUE_EDIT_TITLE, DEFAULTVALUE_EDIT_LABEL, DEUtil.resolveNull( input.getDefaultValue( )), null); if(dialog.open( ) == Window.OK){ String value = dialog.getValue( ); try { if(value==null || value.trim( ).length( ) == 0) input.setDefaultValue( null ); else input.setDefaultValue( value.trim( ) ); defaultValueViewer.refresh( ); } catch ( SemanticException e ) { ExceptionHandler.handle( e ); } } }
/** * @deprecated */ private InputDialog createInputDialog( ReportElementHandle handle, String title, String message ) { InputDialog inputDialog = new InputDialog( getShell( ), title, message, handle.getName( ), null ) { public int open( ) { return super.open( ); } }; inputDialog.create( ); return inputDialog; }
private void doRename( ) { if ( selectedObj instanceof DesignElementHandle || selectedObj instanceof EmbeddedImageHandle ) { initOriginalName( ); InputDialog inputDialog = new InputDialog( UIUtil.getDefaultShell( ), Messages.getString( "ExportElementToLibraryAction.DialogTitle" ), //$NON-NLS-1$ Messages.getString( "ExportElementToLibraryAction.DialogMessage" ), //$NON-NLS-1$ originalName, null ); inputDialog.create( ); clickOK = false; if ( inputDialog.open( ) == Window.OK ) { saveChanges( inputDialog.getValue( ).trim( ) ); clickOK = true; } } }
private void askForColumnPrefixes() { // filter empty lines... InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "Column name prefix filters", "Enter a comma separated list of prefix filters to apply on column names", prefixFiltersString, null); if (dlg.open() == Dialog.OK) { computePrefixFilterList(dlg.getValue()); for (IPluginModelBase p : columnsCache.keySet()) { TreeViewerColumn tc = columnsCache.get(p); String newTitle = getColumnName(p); if (!tc.getColumn().isDisposed() && !tc.getColumn().getText().equals(newTitle)) { tc.getColumn().setText(newTitle); tc.getColumn().pack(); } } tv.refresh(); } }
public static Integer openAskInt(String title, String message, int initial) { Shell shell = EditorUtils.getShell(); String initialValue = "" + initial; IInputValidator validator = new IInputValidator() { @Override public String isValid(String newText) { if (newText.length() == 0) { return "At least 1 char must be provided."; } try { Integer.parseInt(newText); } catch (Exception e) { return "A number is required."; } return null; } }; InputDialog dialog = new InputDialog(shell, title, message, initialValue, validator); dialog.setBlockOnOpen(true); if (dialog.open() == Window.OK) { return Integer.parseInt(dialog.getValue()); } return null; }
@Override public void run(IAction action) { IInputValidator validator = new IInputValidator() { @Override public String isValid(String newText) { if (newText.trim().length() == 0) { return "Name cannot be empty"; } return null; } }; InputDialog d = new InputDialog(EditorUtils.getShell(), "App name", "Name of the django app to makemigrations on", "", validator); int retCode = d.open(); if (retCode == InputDialog.OK) { createApp(d.getValue().trim()); } }