本文整理汇总了Java中org.eclipse.ui.dialogs.ListDialog.OK属性的典型用法代码示例。如果您正苦于以下问题:Java ListDialog.OK属性的具体用法?Java ListDialog.OK怎么用?Java ListDialog.OK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.ui.dialogs.ListDialog
的用法示例。
在下文中一共展示了ListDialog.OK属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pickAvroSchemaEditorFromEditorParts
public static AvroSchemaEditor pickAvroSchemaEditorFromEditorParts() {
AvroSchemaEditor editor = null;
List<IEditorReference> schemaEditorRefList = new ArrayList<>();
IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
for (IEditorReference editorRef : editorReferences) {
IEditorPart editorPart = editorRef.getEditor(false);
if (editorPart != null && editorPart instanceof IWithAvroSchemaEditor) {
schemaEditorRefList.add(editorRef);
}
}
if (schemaEditorRefList.size() == 1) {
editor = ((IWithAvroSchemaEditor) schemaEditorRefList.get(0).getEditor(false)).getEditor();
} else if (schemaEditorRefList.size() > 1) {
// we have to ask the user to choose an editor
// with a dialog
ListDialog dialog = new ListDialog(Display.getCurrent().getActiveShell());
dialog.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return ((IEditorReference) element).getPartName();
}
});
dialog.setContentProvider(new ArrayContentProvider());
dialog.setInput(schemaEditorRefList);
int result = dialog.open();
if (result == ListDialog.OK) {
Object[] selectedEditor = dialog.getResult();
IEditorReference selectedEditorRef = (IEditorReference) selectedEditor[0];
editor = ((IWithAvroSchemaEditor) selectedEditorRef.getEditor(false)).getEditor();
}
}
return editor;
}
示例2: addVariables
private void addVariables(Text target, Map bindings) {
final List variables = new ArrayList(bindings.size());
ILabelProvider labelProvider = new LabelProvider() {
public String getText(Object element) {
return ((StringPair) element).s1
+ " - " + ((StringPair) element).s2; //$NON-NLS-1$
}
};
IStructuredContentProvider contentsProvider = new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return variables.toArray(new StringPair[variables.size()]);
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput,
Object newInput) {
}
};
for (Iterator it = bindings.keySet().iterator(); it.hasNext();) {
StringPair variable = new StringPair();
variable.s1 = (String) it.next(); // variable
variable.s2 = (String) bindings.get(variable.s1); // description
variables.add(variable);
}
ListDialog dialog = new ListDialog(this.getShell());
dialog.setContentProvider(contentsProvider);
dialog.setAddCancelButton(true);
dialog.setLabelProvider(labelProvider);
dialog.setInput(variables);
dialog.setTitle(Policy
.bind("DiffMergePreferencePage.addVariableDialogTitle")); //$NON-NLS-1$
if (dialog.open() != ListDialog.OK)
return;
Object[] result = dialog.getResult();
for (int i = 0; i < result.length; i++) {
target.insert("${" + ((StringPair) result[i]).s1 + "}"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
示例3: addVariables
/**
* Add another variable to the given target. The variable is inserted at
* current position A ListSelectionDialog is shown and the choose the
* variables to add
*/
private void addVariables(Text target, Map bindings) {
final List variables = new ArrayList(bindings.size());
ILabelProvider labelProvider = new LabelProvider() {
public String getText(Object element) {
return ((StringPair) element).s1
+ " - " + ((StringPair) element).s2; //$NON-NLS-1$
}
};
IStructuredContentProvider contentsProvider = new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
return variables.toArray(new StringPair[variables.size()]);
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput,
Object newInput) {
}
};
for (Iterator it = bindings.keySet().iterator(); it.hasNext();) {
StringPair variable = new StringPair();
variable.s1 = (String) it.next(); // variable
variable.s2 = (String) bindings.get(variable.s1); // description
variables.add(variable);
}
ListDialog dialog = new ListDialog(this.getShell());
dialog.setContentProvider(contentsProvider);
dialog.setAddCancelButton(true);
dialog.setLabelProvider(labelProvider);
dialog.setInput(variables);
dialog.setTitle(Policy
.bind("DiffMergePreferencePage.addVariableDialogTitle")); //$NON-NLS-1$
if (dialog.open() != ListDialog.OK)
return;
Object[] result = dialog.getResult();
for (int i = 0; i < result.length; i++) {
target.insert("${" + ((StringPair) result[i]).s1 + "}"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
示例4: restoreInterpreterInfos
/**
* Restores the modules. Is called when the user changed something in the editor and applies the change.
*
* Gathers all the info and calls the hook that really restores things within a thread, so that the user can
* get information on the progress.
*
* Only the information on the default interpreter is stored.
*
* @param editorChanged whether the editor was changed (if it wasn't, we'll ask the user what to restore).
* @return true if the info was restored and false otherwise.
*/
protected void restoreInterpreterInfos(boolean editorChanged) {
final Set<String> interpreterNamesToRestore = pathEditor.getInterpreterExeOrJarToRestoreAndClear();
final IInterpreterInfo[] exesList = pathEditor.getExesList();
if (!editorChanged && interpreterNamesToRestore.size() == 0) {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
SelectionDialog listDialog = createChooseIntepreterInfoDialog(workbenchWindow, exesList,
"Select interpreters to be restored", true);
int open = listDialog.open();
if (open != ListDialog.OK) {
return;
}
Object[] result = listDialog.getResult();
if (result == null || result.length == 0) {
return;
}
for (Object o : result) {
interpreterNamesToRestore.add(((IInterpreterInfo) o).getExecutableOrJar());
}
}
//this is the default interpreter
ProgressMonitorDialog monitorDialog = new AsynchronousProgressMonitorDialog(this.getShell());
monitorDialog.setBlockOnOpen(false);
try {
IRunnableWithProgress operation = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Restoring PYTHONPATH", IProgressMonitor.UNKNOWN);
try {
pathEditor.pushExpectedSetInfos();
//clear all but the ones that appear
getInterpreterManager().setInfos(exesList, interpreterNamesToRestore, monitor);
} finally {
pathEditor.popExpectedSetInfos();
monitor.done();
}
}
};
monitorDialog.run(true, true, operation);
} catch (Exception e) {
Log.log(e);
}
}
示例5: selectAttachment
/**
* Selects the attachment.
*
* @param parent
* the parent shell.
* @param currentAttachment
* the original attachment.
* @param basicNode
* the node.
* @return the selected attachment.
*
* @see net.dependableos.dcase.diagram.ui.AttributeDialog.IAttachmentSelector#selectAttachment(java.lang.String)
*/
public String selectAttachment(Shell parent, String currentAttachment,
BasicNode basicNode) {
if (basicNode instanceof Goal || basicNode instanceof Userdef005 ||
basicNode instanceof Userdef001) {
ListDialog dialog = new ListDialog(parent);
dialog.setTitle("Select from Modules..."); //$NON-NLS-1$
dialog.setMessage("Select from the following Modules..."); //$NON-NLS-1$
dialog.setContentProvider(new ArrayContentProvider());
dialog.setLabelProvider(new LabelProvider());
// get data
argumentEditPart = DcaseEditorUtil.getCurrentArgumentEditPart();
boolean isGoalNode = (basicNode instanceof Goal);
ArrayList<String> data = new ArrayList<String>();
Map<String, String> map = null;
try {
map = ModuleUtil.getModulesAndNodes(argumentEditPart,
isGoalNode);
} catch (CoreException e) {
MessageWriter.writeMessageToConsole(
Messages.SelectModuleContributionItem_0,
MessageTypeImpl.SELECT_MODULE_FAILED);
return null;
}
IFile modelFile = DcaseEditorUtil.getModelFile(argumentEditPart);
String moduleName = ModuleUtil.getModuleName(modelFile);
for (Map.Entry<String, String> entry : map.entrySet()) {
String name = entry.getKey();
if (moduleName.equals(ModuleUtil.getModuleName(name))) {
continue;
}
if (isGoalNode && !ModuleUtil.isPublicNodeName(name)) {
continue;
}
data.add(name);
}
dialog.setInput(data.toArray());
if (dialog.open() == ListDialog.OK) {
Object[] result = dialog.getResult();
if (result.length == 1) {
return (String) result[0];
}
}
}
return null;
}