Java Code Examples for org.eclipse.jface.dialogs.InputDialog#open()

The following examples show how to use org.eclipse.jface.dialogs.InputDialog#open() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExportElementToLibraryAction.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
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;
		}
	}
}
 
Example 2
Source File: NewNameQueries.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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();
		}
	};
}
 
Example 3
Source File: RenameTermHandler.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {			
	ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
	if (selection == null || !(selection instanceof IStructuredSelection)) {
		return null;
	}
	IStructuredSelection currentSelection = (IStructuredSelection) selection;
	if (currentSelection.size() == 1) {
		Term term = (Term) currentSelection.getFirstElement();	
		InputDialog dialog = new InputDialog(
				null,
				"Rename Term", 
				"Rename Term: " + term.getName() + " to:",
				term.getName(),
				null);
		dialog.setBlockOnOpen(true);
		if (dialog.open() == InputDialog.OK) {
			TermRenamer.rename(term, dialog.getValue());
		}
	}		
	return null;
}
 
Example 4
Source File: VGroupEditPart.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
	 * {@inheritDoc}
	 */
	@Override
	public void performRequestOpen() {
		VGroup group = (VGroup) this.getModel();
		ERDiagram diagram = this.getDiagram();

//		VGroup copyGroup = group.clone();

		InputDialog dialog = new InputDialog(
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
				"�O���[�v���ύX", "�O���[�v�����͂��ĉ������B", group.getName(), null);

		if (dialog.open() == IDialogConstants.OK_ID) {
			CompoundCommand command = new CompoundCommand();
			command.add(new ChangeVGroupNameCommand(diagram, group, dialog.getValue()));
			this.executeCommand(command.unwrap());
		}
	}
 
Example 5
Source File: SdkToolsControl.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private String editGroupName(String initialName, final Set<String> usedNames) {
    InputDialog dlg = new InputDialog(getShell(), Messages.SdkToolsControl_NewGroupName, 
            Messages.SdkToolsControl_EnterGroupName+':', initialName, 
            new IInputValidator() 
    {
        @Override
        public String isValid(String newText) {
            newText = newText.trim();
            if (newText.isEmpty()) {
                return Messages.SdkToolsControl_NameIsEmpty;
            } else if (usedNames.contains(newText)) {
                return Messages.SdkToolsControl_NameIsUsed;
            }
            return null;
        }
    });
    if (dlg.open() == Window.OK) {
        return dlg.getValue().trim();
    }
    return null;
}
 
Example 6
Source File: DjangoCreateApp.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@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 be created", "",
            validator);

    int retCode = d.open();
    if (retCode == InputDialog.OK) {
        createApp(d.getValue().trim());
    }
}
 
Example 7
Source File: ModelEditor.java    From olca-app with Mozilla Public License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void doSaveAs() {
	InputDialog diag = new InputDialog(UI.shell(), M.SaveAs, M.SaveAs,
			model.name + " - Copy", (name) -> {
				if (Strings.nullOrEmpty(name))
					return M.NameCannotBeEmpty;
				if (Strings.nullOrEqual(name, model.name))
					return M.NameShouldBeDifferent;
				return null;
			});
	if (diag.open() != Window.OK)
		return;
	String newName = diag.getValue();
	try {
		T clone = (T) model.clone();
		clone.name = newName;
		clone = dao.insert(clone);
		App.openEditor(clone);
		Navigator.refresh();
	} catch (Exception e) {
		log.error("failed to save " + model + " as " + newName, e);
	}
}
 
Example 8
Source File: LookupAccountHandler.java    From offspring with MIT License 5 votes vote down vote up
@Execute
public void execute(INxtService nxt, IStylingEngine engine,
    IUserService userService, UISynchronize sync) {

  InputDialog dialog = new InputDialog(Display.getCurrent().getActiveShell(),
      "Lookup Account", "Enter account number", "", new AccountValidator());
  if (dialog.open() == Window.OK) {
    Long id = Convert.parseUnsignedLong(dialog.getValue());
    InspectAccountDialog.show(id, nxt, engine, userService, sync,
        ContactsService.getInstance());
  }
}
 
Example 9
Source File: RenameXMLFileDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static boolean open(Shell shell, IRepositoryFileStore fileStore, TypedValidator<String, IStatus> validator) {
    String currentFileName = fileStore.getDisplayName();
    final InputDialog dialog = new InputDialog(shell, Messages.rename, Messages.renameFile,
            currentFileName, new InputValidatorWrapper(validator));
    if (dialog.open() == Dialog.OK && !currentFileName.equals(stripXmlExtension(dialog.getValue()))) {
        fileStore.renameLegacy(stripXmlExtension(dialog.getValue()) + ".xml");
    }

    return !Objects.equal(currentFileName, fileStore.getDisplayName());
}
 
Example 10
Source File: CreateCategoryAction.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private String getDialogValue() {
	InputDialog dialog = new InputDialog(UI.shell(), M.NewCategory,
			M.PleaseEnterTheNameOfTheNewCategory,
			M.NewCategory, null);
	int rc = dialog.open();
	if (rc == Window.OK)
		return dialog.getValue();
	return null;
}
 
Example 11
Source File: EditboxPreferencePage.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void widgetSelected(final SelectionEvent e) {
	final InputDialog dialog =
			new InputDialog(getShell(), "New Name", "File name pattern like *.java, my.xml:", null, newText -> {
				if (newText != null && newText.trim().length() > 0) { return null; }
				return "";
			});

	if (dialog.open() == Window.OK) {
		addFileName(dialog.getValue());
	}

}
 
Example 12
Source File: BrowserView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void navigateTo(){
	InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(),
        "", "Adresse eingeben", browser.getUrl(), null);
    if (dlg.open() == Window.OK) {
      browser.setUrl(dlg.getValue());
    }
}
 
Example 13
Source File: MakrosComposite.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void run(){
	InputDialog in =
		new InputDialog(getShell(), Messages.EnhancedTextField_newMacro,
		Messages.EnhancedTextField_enterNameforMacro, null, null);
	if (in.open() == Dialog.OK) {
		StringBuilder name = new StringBuilder(in.getValue());
		name.reverse();
		MakroDetailComposite.saveMakro(new MakroDTO(CoreHub.getLoggedInContact().getId(),
			"makros/" + name.toString(), in.getValue(), "Neues Makro"));
		if (viewer != null) {
			viewer.setInput(getUserMakros(CoreHub.getLoggedInContact()));
		}
	}
}
 
Example 14
Source File: SootConfigManagerDialog.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private void clonePressed(){
	if (getSelected() == null) return;
	
	String result = this.getSelected();
	
	IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
	
	// gets current number of configurations
	int config_count = 0;
	try {
		config_count = settings.getInt(Messages.getString("SootConfigManagerDialog.config_count")); //$NON-NLS-1$
	}
	catch (NumberFormatException e) {	
	}
	ArrayList currentNames = new ArrayList();
	for (int i = 1; i <= config_count; i++) {
		currentNames.add(settings.get(Messages.getString("SootConfigManagerDialog.soot_run_config")+i)); //$NON-NLS-1$
		
	}

	
	// sets validator to know about already used names 
	SootConfigNameInputValidator validator = new SootConfigNameInputValidator();
	validator.setAlreadyUsed(currentNames);
	
	InputDialog nameDialog = new InputDialog(this.getShell(), Messages.getString("SootConfigManagerDialog.Clone_Saved_Configuration"), Messages.getString("SootConfigManagerDialog.Enter_new_name"), result, validator);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	nameDialog.open();
	if (nameDialog.getReturnCode() == Dialog.OK){
		config_count++;
		settings.put(Messages.getString("SootConfigManagerDialog.soot_run_config")+config_count, nameDialog.getValue()); //$NON-NLS-1$
		settings.put(nameDialog.getValue(), settings.getArray(result));
		settings.put(Messages.getString("SootConfigManagerDialog.config_count"), config_count); //$NON-NLS-1$
		getTreeRoot().addChild(new SootConfiguration(nameDialog.getValue()));
		saveMainClass(nameDialog.getValue(), settings.get(result+"_mainClass"));
	}
	refreshTree();
}
 
Example 15
Source File: SootConfigManagerDialog.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private void renamePressed(){
	if (getSelected() == null) return;
	
	String result = this.getSelected();
	
	IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
	
	// gets current number of configurations
	int config_count = 0;
	int oldNameCount = 0;
	try {
		config_count = settings.getInt(Messages.getString("SootConfigManagerDialog.config_count")); //$NON-NLS-1$
	}
	catch (NumberFormatException e) {	
	}

	ArrayList currentNames = new ArrayList();
	for (int i = 1; i <= config_count; i++) {
		currentNames.add(settings.get(Messages.getString("SootConfigManagerDialog.soot_run_config")+i)); //$NON-NLS-1$
		if (((String)currentNames.get(i-1)).equals(result)){
			oldNameCount = i;
		}
	}

	
	// sets validator to know about already used names 
	SootConfigNameInputValidator validator = new SootConfigNameInputValidator();
	validator.setAlreadyUsed(currentNames);
	
	InputDialog nameDialog = new InputDialog(this.getShell(), Messages.getString("SootConfigManagerDialog.Rename_Saved_Configuration"), Messages.getString("SootConfigManagerDialog.Enter_new_name"), "", validator);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	nameDialog.open();
	if (nameDialog.getReturnCode() == Dialog.OK){
		settings.put(Messages.getString("SootConfigManagerDialog.soot_run_config")+oldNameCount, nameDialog.getValue()); //$NON-NLS-1$
		settings.put(nameDialog.getValue(), settings.getArray(result));
		getTreeRoot().renameChild(result, nameDialog.getValue());
		saveMainClass(nameDialog.getValue(), settings.get(result+"_mainClass"));
	}
	refreshTree();
}
 
Example 16
Source File: PyRenameResourceAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Return the new name to be given to the target resource.
 *
 * @return java.lang.String
 * @param resource the resource to query status on
 *
 * Fix from platform: was not checking return from dialog.open
 */
@Override
protected String queryNewResourceName(final IResource resource) {
    final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
    final IPath prefix = resource.getFullPath().removeLastSegments(1);
    IInputValidator validator = new IInputValidator() {
        @Override
        public String isValid(String string) {
            if (resource.getName().equals(string)) {
                return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent;
            }
            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;
        }
    };

    InputDialog dialog = new InputDialog(shell, IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle,
            IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage, resource.getName(), validator);
    dialog.setBlockOnOpen(true);
    if (dialog.open() == Window.OK) {
        return dialog.getValue();
    } else {
        return null;
    }
}
 
Example 17
Source File: InvoiceCorrectionView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private boolean changePriceDialog(LeistungDTO leistungDTO){
	Money oldPrice = leistungDTO.getPrice();
	String p = oldPrice.getAmountAsString();
	Money customPrice;
	InputDialog dlg = new InputDialog(UiDesk.getTopShell(),
		Messages.VerrechnungsDisplay_changePriceForService, //$NON-NLS-1$
		Messages.VerrechnungsDisplay_enterNewPrice, p, //$NON-NLS-1$
		null);
	if (dlg.open() == Dialog.OK) {
		try {
			String val = dlg.getValue().trim();
			if (val.endsWith("%") && val.length() > 1) { //$NON-NLS-1$
				val = val.substring(0, val.length() - 1);
				double percent = Double.parseDouble(val);
				double scaleFactor = 1.0 + (percent / 100.0);
				leistungDTO.setScale2(scaleFactor);
				customPrice = leistungDTO.getPrice();
			} else {
				customPrice = new Money(val);
				leistungDTO.setScale2(Double.valueOf(1));
			}
			if (customPrice != null) {
				leistungDTO.setTp(customPrice.getCents());
			}
			return true;
		} catch (ParseException ex) {
			log.error("price changing", ex);
			SWTHelper.showError(Messages.VerrechnungsDisplay_badAmountCaption, //$NON-NLS-1$
				Messages.VerrechnungsDisplay_badAmountBody); //$NON-NLS-1$
		}
	}
	return false;
}
 
Example 18
Source File: DFSActionImpl.java    From hadoop-gpu with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new sub-folder into an existing directory
 * 
 * @param selection
 */
private void mkdir(IStructuredSelection selection) {
  List<DFSFolder> folders = filterSelection(DFSFolder.class, selection);
  if (folders.size() >= 1) {
    DFSFolder folder = folders.get(0);
    InputDialog dialog =
        new InputDialog(Display.getCurrent().getActiveShell(),
            "Create subfolder", "Enter the name of the subfolder", "",
            null);
    if (dialog.open() == InputDialog.OK)
      folder.mkdir(dialog.getValue());
  }
}
 
Example 19
Source File: RenameModelHandlerDelegate.java    From tlaplus with MIT License 4 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
 {
     final ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
     if (selection != null && selection instanceof IStructuredSelection)
     {
         // model file
         final Model model = (Model) ((IStructuredSelection) selection).getFirstElement();

         // a) fail if model is in use
if (model.isRunning()) {
	MessageDialog.openError(UIHelper.getShellProvider().getShell(), "Could not rename models",
			"Could not rename the model " + model.getName()
					+ ", because it is being model checked.");
	return null;
}
if (model.isSnapshot()) {
	MessageDialog.openError(UIHelper.getShellProvider().getShell(), "Could not rename model",
			"Could not rename the model " + model.getName()
					+ ", because it is a snapshot.");
	return null;
}

         // b) open dialog prompting for new model name
         final IInputValidator modelNameInputValidator = new ModelNameValidator(model.getSpec());
         final InputDialog dialog = new InputDialog(UIHelper.getShell(), "Rename model...",
                 "Please input the new name of the model", model.getName(), modelNameInputValidator);
         dialog.setBlockOnOpen(true);
         if(dialog.open() == Window.OK) {
         	// c1) close model editor if open
             IEditorPart editor = model.getAdapter(ModelEditor.class);
             if(editor != null) {
             	reopenModelEditorAfterRename = true;
             	UIHelper.getActivePage().closeEditor(editor, true);
             }
             // c2) close snapshot model editors 
             final Collection<Model> snapshots = model.getSnapshots();
	for (Model snapshot : snapshots) {
		editor = snapshot.getAdapter(ModelEditor.class);
		if (editor != null) {
			UIHelper.getActivePage().closeEditor(editor, true);
		}
	}
             
	final WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
		@Override
		protected void execute(IProgressMonitor monitor)
				throws CoreException, InvocationTargetException, InterruptedException {
			// d) rename
			final String newModelName = dialog.getValue();
			model.rename(newModelName, monitor);

			// e) reopen (in UI thread)
			if (reopenModelEditorAfterRename) {
				UIHelper.runUIAsync(new Runnable() {
					/*
					 * (non-Javadoc)
					 * 
					 * @see java.lang.Runnable#run()
					 */
					public void run() {
						Map<String, String> parameters = new HashMap<String, String>();
						parameters.put(OpenModelHandler.PARAM_MODEL_NAME, newModelName);
						UIHelper.runCommand(OpenModelHandler.COMMAND_ID, parameters);
					}
				});
			}
		}
	};
	final IRunnableContext ctxt = new ProgressMonitorDialog(UIHelper.getShell());
	try {
		ctxt.run(true, false, operation);
	} catch (InvocationTargetException | InterruptedException e) {
		throw new ExecutionException(e.getMessage(), e);
	}
          }
     }
     return null;
 }
 
Example 20
Source File: PySearchInOpenDocumentsAction.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void run() {
    IDialogSettings settings = TextEditorPlugin.getDefault().getDialogSettings();
    IDialogSettings s = settings.getSection("org.eclipse.ui.texteditor.FindReplaceDialog");
    boolean caseSensitive = false;
    boolean wholeWord = false;
    boolean isRegEx = false;
    if (s != null) {
        caseSensitive = s.getBoolean("casesensitive"); //$NON-NLS-1$
        wholeWord = s.getBoolean("wholeword"); //$NON-NLS-1$
        isRegEx = s.getBoolean("isRegEx"); //$NON-NLS-1$
    }

    String searchText = "";
    if (parameters != null) {
        searchText = StringUtils.join(" ", parameters);
    }
    if (searchText.length() == 0) {
        PySelection ps = PySelectionFromEditor.createPySelectionFromEditor(edit);
        try {
            searchText = ps.getSelectedText();
        } catch (BadLocationException e) {
            searchText = "";
        }
    }
    IStatusLineManager statusLineManager = edit.getStatusLineManager();
    if (searchText.length() == 0) {
        InputDialog d = new InputDialog(EditorUtils.getShell(), "Text to search", "Enter text to search.", "",
                null);

        int retCode = d.open();
        if (retCode == InputDialog.OK) {
            searchText = d.getValue();
        }
    }

    if (searchText.length() >= 0) {
        if (wholeWord && !isRegEx && isWord(searchText)) {
            isRegEx = true;
            searchText = "\\b" + searchText + "\\b";
        }

        FindInOpenDocuments.findInOpenDocuments(searchText, caseSensitive, wholeWord, isRegEx, statusLineManager);
    }
}