本文整理汇总了Java中org.eclipse.jface.dialogs.InputDialog类的典型用法代码示例。如果您正苦于以下问题:Java InputDialog类的具体用法?Java InputDialog怎么用?Java InputDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputDialog类属于org.eclipse.jface.dialogs包,在下文中一共展示了InputDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputObject
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
/**
* @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;
}
示例2: getNewInputObject
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
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;
}
示例3: execute
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
@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;
}
示例4: hookRenameAction
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的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.
}
}
}
示例5: run
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
@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();
}
}
}
示例6: saveList
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
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);
}
示例7: saveList
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
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);
}
示例8: run
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
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);
}
示例9: run
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的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);
}
}
示例10: openRefactorDialog
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
@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);
}
示例11: execute
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
@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();
}
}
示例12: execute
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
@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();
}
}
}
}
}
示例13: execute
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
@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();
}
}
}
}
}
示例14: execute
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的package包/类
@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();
}
}
}
}
}
示例15: widgetSelected
import org.eclipse.jface.dialogs.InputDialog; //导入依赖的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;
}
}