本文整理匯總了Java中org.eclipse.jface.dialogs.InputDialog.getReturnCode方法的典型用法代碼示例。如果您正苦於以下問題:Java InputDialog.getReturnCode方法的具體用法?Java InputDialog.getReturnCode怎麽用?Java InputDialog.getReturnCode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.dialogs.InputDialog
的用法示例。
在下文中一共展示了InputDialog.getReturnCode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
示例2: onRenameFilterSet
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
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;
}
示例3: run
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的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);
}
}
示例4: getGraphingRadius
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
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;
}
示例5: execute
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
@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;
}
示例6: widgetSelected
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
@Override
public void widgetSelected(final SelectionEvent e) {
final MultiStatus multistatus = statusHelper.createMultiStatus("Status of uninstalling npm dependencies.");
final InputDialog dialog = new InputDialog(UIUtils.getShell(), "npm Uninstall",
"Specify an npm package name to uninstall:", initalValue.get(), validator.get());
dialog.open();
final String packageName = dialog.getValue();
if (!StringExtensions.isNullOrEmpty(packageName) && dialog.getReturnCode() == Window.OK) {
try {
new ProgressMonitorDialog(UIUtils.getShell()).run(true, false, monitor -> {
multistatus.merge(uninstallAction.apply(Arrays.asList(packageName), monitor));
});
} catch (final InvocationTargetException | InterruptedException exc) {
multistatus.merge(
statusHelper.createError("Error while uninstalling npm dependency: '" + packageName + "'.",
exc));
} finally {
if (!multistatus.isOK()) {
N4JSActivator.getInstance().getLog().log(multistatus);
getDisplay().asyncExec(() -> openError(
UIUtils.getShell(),
"npm Uninstall Failed",
"Error while uninstalling '" + packageName
+ "' npm package.\nPlease check your Error Log view for the detailed npm log about the failure."));
}
}
}
}
示例7: renamePressed
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
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();
}
示例8: clonePressed
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
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();
}
示例9: onNewFilterSet
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
private void onNewFilterSet() {
final InputDialog inputDialog = new InputDialog(
getShell(),
Messages.Pref_TourTypeFilter_dlg_new_title,
Messages.Pref_TourTypeFilter_dlg_new_message,
UI.EMPTY_STRING,
null);
inputDialog.open();
if (inputDialog.getReturnCode() != Window.OK) {
return;
}
// create new filterset
final TourTypeFilterSet filterSet = new TourTypeFilterSet();
filterSet.setName(inputDialog.getValue().trim());
final TourTypeFilter tourTypeFilter = new TourTypeFilter(filterSet);
// update model and viewer
_filterViewer.add(tourTypeFilter);
_filterList.add(tourTypeFilter);
// select new set
_filterViewer.setSelection(new StructuredSelection(tourTypeFilter), true);
_tourTypeViewer.getTable().setFocus();
_isModified = true;
}
示例10: getNewInputObject
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
@Override
protected String getNewInputObject()
{
final InputDialog inputDialog = new InputDialog(getShell(), "Exclude classes",
"Enter class exclusion filter", null, new IInputValidator()
{
@Override
public String isValid(final String newText)
{
// TODO: Perform better validation
final String delimiter = PreferenceInitializer.EVENT_FILTER_DELIMITER;
if (newText.contains(delimiter))
{
return "The filter cannot contain the delimiter: " + delimiter;
}
else if (newText.isEmpty())
{
return "The filter cannot be empty";
}
else
{
return null;
}
}
});
inputDialog.open();
if (inputDialog.getReturnCode() == Window.OK)
{
return inputDialog.getValue();
}
else
{
return null;
}
}
示例11: fillContextMenu
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
private void fillContextMenu(IMenuManager manager) {
manager.add(new Separator());
drillDownAdapter.addNavigationActions(manager);
// Other plug-ins can contribute there actions here
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
Action runAction = new Action("Run with arguments...") {
@Override
public void runWithEvent(Event event) {
InputDialog dialog = new InputDialog(getSite().getShell(), "Task Arguments", "Enter task run arguments", "", null);
dialog.open();
if (dialog.getReturnCode() == InputDialog.CANCEL) {
return;
}
String args = dialog.getValue();
String[] argsArr = args.split(" ");
runSelectedTask(argsArr);
}
};
runAction.setEnabled(((IStructuredSelection) viewer.getSelection()).getFirstElement() != null);
// add the actions.
manager.add(runAction);
}
示例12: askInput
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
/**
* ask the user for some text input, and block until it has been provided
* @param title
* @param message
* @return the users input, or null if cancelled
*/
public static String askInput(String title, String message)
{
InputDialog dialog = new InputDialog(getShell(),title, message,null,null);
dialog.setBlockOnOpen(true);
dialog.open();
String input = dialog.getValue();
if (dialog.getReturnCode() == Window.CANCEL) input = null;
return input;
}
示例13: renameKeyOrGroup
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
/**
* Renames a key or group of key.
*/
protected void renameKeyOrGroup() {
KeyTreeItem selectedItem = getSelection();
String key = selectedItem.getId();
String msgHead = null;
String msgBody = null;
if (selectedItem.getChildren().size() == 0) {
msgHead = RBEPlugin.getString(
"dialog.rename.head.single"); //$NON-NLS-1$
msgBody = RBEPlugin.getString(
"dialog.rename.body.single", key); //$NON-NLS-1$
} else {
msgHead = RBEPlugin.getString(
"dialog.rename.head.multiple"); //$NON-NLS-1$
msgBody = RBEPlugin.getString(
"dialog.rename.body.multiple", //$NON-NLS-1$
selectedItem.getName());
}
// Rename single item
InputDialog dialog = new InputDialog(getShell(), msgHead, msgBody, key, null);
dialog.open();
if (dialog.getReturnCode() == Window.OK ) {
String newKey = dialog.getValue();
BundleGroup bundleGroup = tree.getBundleGroup();
Collection<KeyTreeItem> items = new ArrayList<KeyTreeItem>();
items.add(selectedItem);
items.addAll(selectedItem.getNestedChildren());
for (KeyTreeItem item : items) {
String oldItemKey = item.getId();
if (oldItemKey.startsWith(key)) {
String newItemKey = newKey + oldItemKey.substring(key.length());
bundleGroup.renameKey(oldItemKey, newItemKey);
}
}
}
}
示例14: copyKeyOrGroup
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
/**
* Copies a key or group of key.
*/
protected void copyKeyOrGroup() {
KeyTreeItem selectedItem = getSelection();
String key = selectedItem.getId();
String msgHead = null;
String msgBody = null;
if (selectedItem.getChildren().size() == 0) {
msgHead = RBEPlugin.getString(
"dialog.duplicate.head.single"); //$NON-NLS-1$
msgBody = RBEPlugin.getString(
"dialog.duplicate.body.single", key); //$NON-NLS-1$
} else {
msgHead = RBEPlugin.getString(
"dialog.duplicate.head.multiple"); //$NON-NLS-1$
msgBody = RBEPlugin.getString(
"dialog.duplicate.body.multiple", //$NON-NLS-1$
selectedItem.getName());
}
// Rename single item
InputDialog dialog = new InputDialog(getShell(), msgHead, msgBody, key, null);
dialog.open();
if (dialog.getReturnCode() == Window.OK ) {
String newKey = dialog.getValue();
BundleGroup bundleGroup = tree.getBundleGroup();
Collection<KeyTreeItem> items = new ArrayList<KeyTreeItem>();
items.add(selectedItem);
items.addAll(selectedItem.getNestedChildren());
for (KeyTreeItem item : items) {
String origItemKey = item.getId();
if (origItemKey.startsWith(key)) {
String newItemKey =
newKey + origItemKey.substring(key.length());
bundleGroup.copyKey(origItemKey, newItemKey);
}
}
}
}
示例15: newPressed
import org.eclipse.jface.dialogs.InputDialog; //導入方法依賴的package包/類
private void newPressed() {
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
// gets current number of configurations before adding any
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 - but it doesn't use
// them because then editing a file cannot use same file name
SootConfigNameInputValidator validator = new SootConfigNameInputValidator();
validator.setAlreadyUsed(currentNames);
// create dialog to get name
InputDialog nameDialog = new InputDialog(this.getShell(), Messages.getString("SootConfigManagerDialog.Saving_Configuration_Name"), Messages.getString("SootConfigManagerDialog.Enter_name_to_save_configuration_with"), "", validator); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
nameDialog.open();
if (nameDialog.getReturnCode() == Dialog.OK) {
setEditDefs(null);
int returnCode = displayOptions(nameDialog.getValue(), "soot.Main");
//handle selection of main class here
if (returnCode != Dialog.CANCEL) {
getTreeRoot().addChild(new SootConfiguration(nameDialog.getValue()));
refreshTree();
}
}
else {
// cancel and do nothing
}
}