Skip to content

Package: DialogOpener

DialogOpener

nameinstructionbranchcomplexitylinemethod
openDialog(Dialog, ECPDialogExecutor)
M: 19 C: 24
56%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 6 C: 7
54%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: *
14: *******************************************************************************/
15: package org.eclipse.emf.ecp.edit.internal.swt.util;
16:
17: import org.eclipse.core.runtime.CoreException;
18: import org.eclipse.core.runtime.IConfigurationElement;
19: import org.eclipse.core.runtime.Platform;
20: import org.eclipse.emf.ecp.edit.internal.swt.Activator;
21: import org.eclipse.emf.ecp.edit.spi.swt.util.ECPDialogExecutor;
22: import org.eclipse.jface.dialogs.Dialog;
23:
24: /**
25: * @author Eugen Neufeld
26: *
27: */
28: public final class DialogOpener {
29:
30:         private DialogOpener() {
31:
32:         }
33:
34:         /**
35:          * The provided {@link Dialog} is opened and the result is returned via the provided {@link ECPDialogExecutor}.
36:          * This method searches for a DialogWrapper which will wrap the code in order to allow opening JFace dialogs in RAP.
37:          *
38:          * @param dialog the JFace Dialog to open
39:          * @param callBack the {@link ECPDialogExecutor} called to handle the result
40:          */
41:         public static void openDialog(Dialog dialog, ECPDialogExecutor callBack) {
42:                 DialogWrapper wrapper = null;
43:                 final IConfigurationElement[] controls = Platform.getExtensionRegistry().getConfigurationElementsFor(
44:                         "org.eclipse.emf.ecp.edit.swt.dialogWrapper"); //$NON-NLS-1$
45:•                for (final IConfigurationElement e : controls) {
46:                         try {
47:                                 wrapper = (DialogWrapper) e.createExecutableExtension("class"); //$NON-NLS-1$
48:                                 break;
49:                         } catch (final CoreException e1) {
50:                                 Activator.logException(e1);
51:                         }
52:                 }
53:•                if (wrapper == null) {
54:                         callBack.handleResult(dialog.open());
55:                         return;
56:                 }
57:                 wrapper.openDialog(dialog, callBack);
58:         }
59: }