本文整理匯總了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.
}
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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() );
}
示例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;
}
};
}
示例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);
}
}
示例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;
}
});
}
示例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();
}
};
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
}