当前位置: 首页>>代码示例>>Java>>正文


Java IInputValidator类代码示例

本文整理汇总了Java中org.eclipse.jface.dialogs.IInputValidator的典型用法代码示例。如果您正苦于以下问题:Java IInputValidator类的具体用法?Java IInputValidator怎么用?Java IInputValidator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IInputValidator类属于org.eclipse.jface.dialogs包,在下文中一共展示了IInputValidator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hookRenameAction

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
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.
		} 
	}
}
 
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:22,代码来源:DockerContainersView.java

示例2: run

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
/**
 * @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);
    }
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:26,代码来源:AddKeyAction.java

示例3: widgetSelected

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
@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;
	}

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:22,代码来源:EditboxPreferencePage.java

示例4: queryNewResourceName

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:30,代码来源:RenameResourceAction.java

示例5: showCustomInputDialog

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
/**
 * Show a custom input dialog with a message and configurable buttons.
 * @param title The dialog window's title.
 * @param message The message to display in the dialog
 * @param icon The icon to display next to the message, or null to not show
 * an icon.
 * @param validator Class to check a the entered text is valid. Must be set.
 * @param initial The initial text of the input text box.
 * @param defaultOption The default option (button)
 * @param options The different options (buttons) the dialog should have.
 * @return The dialog option that was selected.
 */
public static CustomResult showCustomInputDialog( String title, String message, 
   Icon icon,
   IInputValidator validator, String initial,
   DialogOption defaultOption, DialogOption ... options )
{
   DialogRunner runner = new DialogRunner( 
      DialogType.CUSTOM, title, message
   );
   runner.setIcon( icon );
   runner.setValidator( validator );
   runner.setInitialString( initial );
   runner.setDefaultOption( defaultOption );
   runner.setOptions( options );
   
   SWTUtil.exec( runner );
   
   return new CustomResult( runner.getResultString(), runner.getResultOption() );
}
 
开发者ID:brocade,项目名称:vTM-eclipse,代码行数:31,代码来源:ZDialog.java

示例6: InputURLDialog

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
/**
   * Creates an input URL dialog with OK and Cancel buttons. Note that the dialog
   * will have no visual representation (no widgets) until it is told to open.
   * <p>
   * Note that the <code>open</code> method blocks for input dialogs.
   * </p>
   * 
   * @param parentShell
   *            the parent shell, or <code>null</code> to create a top-level
   *            shell
   * @param dialogTitle
   *            the dialog title, or <code>null</code> if none
   * @param dialogMessage
   *            the dialog message, or <code>null</code> if none
   * @param initialValue
   *            the initial input value, or <code>null</code> if none
   *            (equivalent to the empty string)
   */
  public InputURLDialog(Shell parentShell, String dialogTitle,
          String dialogMessage, String initialValue) {
      super(parentShell);
      this.title = dialogTitle;
      message = dialogMessage;
      if (initialValue == null) {
	value = StringUtil.EMPTY;
} else {
	value = initialValue;
}
      this.validator = new IInputValidator() {
	public String isValid(String newText) {
		try {
			new URI(newText).toURL();
		} catch (Exception e) {
			return EplMessages.InputURLDialog_InvalidURL;
		}
		return null;
	}
      };
  }
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:40,代码来源:InputURLDialog.java

示例7: run

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
/**
 * @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);
    }
}
 
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:26,代码来源:AddKeyAction.java

示例8: getWaiverRationaleDialog

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
public static WaiverRationaleDialog getWaiverRationaleDialog(Shell shell, String dialogMessage) {
	return new WaiverRationaleDialog(shell,
			"Waiver Rationale",
			dialogMessage,
			"Not specified", new IInputValidator() {
				@Override
				public String isValid(String newText) {
					// Don't allow '<' '>' characters
					String invalidChars = newText.replaceAll("[^><]", "");
					if (!StringUtils.isEmpty(invalidChars)) {
						return "Please remove the following invalid character(s): '" + invalidChars + "'";
					}
					return null;
				}
			});
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:CreateWaiverOperation.java

示例9: createStaticQuery

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
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();
		}
	};
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:NewNameQueries.java

示例10: createResourceNameValidator

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
private static IInputValidator createResourceNameValidator(final IResource res){
	IInputValidator validator= new IInputValidator(){
		public String isValid(String newText) {
			if (newText == null || "".equals(newText) || res.getParent() == null) //$NON-NLS-1$
				return INVALID_NAME_NO_MESSAGE;
			if (res.getParent().findMember(newText) != null)
				return ReorgMessages.ReorgQueries_resourceWithThisNameAlreadyExists;
			if (! res.getParent().getFullPath().isValidSegment(newText))
				return ReorgMessages.ReorgQueries_invalidNameMessage;
			IStatus status= res.getParent().getWorkspace().validateName(newText, res.getType());
			if (status.getSeverity() == IStatus.ERROR)
				return status.getMessage();

			if (res.getName().equalsIgnoreCase(newText))
				return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;

			return null;
		}
	};
	return validator;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:NewNameQueries.java

示例11: createCompilationUnitNameValidator

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
private static IInputValidator createCompilationUnitNameValidator(final ICompilationUnit cu) {
	IInputValidator validator= new IInputValidator(){
		public String isValid(String newText) {
			if (newText == null || "".equals(newText)) //$NON-NLS-1$
				return INVALID_NAME_NO_MESSAGE;
			String newCuName= JavaModelUtil.getRenamedCUName(cu, newText);
			IStatus status= JavaConventionsUtil.validateCompilationUnitName(newCuName, cu);
			if (status.getSeverity() == IStatus.ERROR)
				return status.getMessage();
			RefactoringStatus refStatus;
			refStatus= Checks.checkCompilationUnitNewName(cu, newText);
			if (refStatus.hasFatalError())
				return refStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL);

			if (cu.getElementName().equalsIgnoreCase(newCuName))
				return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;

			return null;
		}
	};
	return validator;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:NewNameQueries.java

示例12: createPackageNameValidator

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
private static IInputValidator createPackageNameValidator(final IPackageFragment pack) {
	IInputValidator validator= new IInputValidator(){
		public String isValid(String newText) {
			if (newText == null || "".equals(newText)) //$NON-NLS-1$
				return INVALID_NAME_NO_MESSAGE;
			IStatus status= JavaConventionsUtil.validatePackageName(newText, pack);
			if (status.getSeverity() == IStatus.ERROR)
				return status.getMessage();

			IJavaElement parent= pack.getParent();
			try {
				if (parent instanceof IPackageFragmentRoot){
					if (! RenamePackageProcessor.isPackageNameOkInRoot(newText, (IPackageFragmentRoot)parent))
						return ReorgMessages.ReorgQueries_packagewithThatNameexistsMassage;
				}
			} catch (CoreException e) {
				return INVALID_NAME_NO_MESSAGE;
			}
			if (pack.getElementName().equalsIgnoreCase(newText))
				return ReorgMessages.ReorgQueries_resourceExistsWithDifferentCaseMassage;

			return null;
		}
	};
	return validator;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:27,代码来源:NewNameQueries.java

示例13: getNewInputObject

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
@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;
	}
}
 
开发者ID:rungemar,项目名称:cmake4cdt,代码行数:24,代码来源:AvailArchsEditor.java

示例14: getNewInputObject

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
@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;
	}
}
 
开发者ID:rungemar,项目名称:cmake4cdt,代码行数:27,代码来源:TargetDevicesEditor.java

示例15: showProjectNameDialog

import org.eclipse.jface.dialogs.IInputValidator; //导入依赖的package包/类
/**
 * 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;
	}

}
 
开发者ID:edgarmueller,项目名称:emfstore-rest,代码行数:29,代码来源:ImportProjectHandler.java


注:本文中的org.eclipse.jface.dialogs.IInputValidator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。