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


Java ListDialog.OK属性代码示例

本文整理汇总了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;

  }
 
开发者ID:Talend,项目名称:avro-schema-editor,代码行数:39,代码来源:UIUtils.java

示例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$
        }
    }
 
开发者ID:subclipse,项目名称:subclipse,代码行数:47,代码来源:NewMergeFileAssociationWizardPage.java

示例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$
    }
}
 
开发者ID:subclipse,项目名称:subclipse,代码行数:52,代码来源:DiffMergePreferencePage.java

示例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);
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:62,代码来源:AbstractInterpreterPreferencesPage.java

示例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;
}
 
开发者ID:d-case,项目名称:d-case_editor,代码行数:61,代码来源:SelectModuleContributionItem.java


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