Project

General

Profile

« Previous | Next » 

Revision 2d137e2c

Added by Patrick Plitzner almost 5 years ago

ref #6913 Remove dependency to WorkbenchWindow from utility class

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/SetPublishFlagForSubtreeHandlerE4.java
27 27
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator;
28 28
import eu.etaxonomy.cdm.model.taxon.Classification;
29 29
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
30
import eu.etaxonomy.taxeditor.model.AbstractUtility;
31 30
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
32 31
import eu.etaxonomy.taxeditor.navigation.navigator.operation.SetPublishForSubtreeOperation;
33 32
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
......
94 93
        configurator = new PublishForSubtreeConfigurator(taxonNode.getUuid());
95 94
        SetPublishForSubtreeWizard wizard = new SetPublishForSubtreeWizard(configurator);
96 95

  
97
        WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(), wizard);
96
        WizardDialog dialog = new WizardDialog(shell, wizard);
98 97

  
99 98
        if (dialog.open() == Window.OK) {
100 99
            return Status.OK_STATUS;
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/SetSecReferenceForSubtreeHandlerE4.java
26 26
import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator;
27 27
import eu.etaxonomy.cdm.model.taxon.Classification;
28 28
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
29
import eu.etaxonomy.taxeditor.model.AbstractUtility;
30 29
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
31 30
import eu.etaxonomy.taxeditor.navigation.navigator.operation.SetSecundumForSubtreeOperation;
32 31
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
......
89 88
        configurator = new SecundumForSubtreeConfigurator(taxonNode.getUuid());
90 89
        SetSecundumForSubtreeConfigurationWizard wizard = new SetSecundumForSubtreeConfigurationWizard(configurator);
91 90

  
92
        WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(), wizard);
91
        WizardDialog dialog = new WizardDialog(shell, wizard);
93 92

  
94 93
        if (dialog.open() == Window.OK) {
95 94
            return Status.OK_STATUS;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
14 14
import java.io.FileOutputStream;
15 15
import java.io.OutputStreamWriter;
16 16
import java.io.Writer;
17
import java.lang.reflect.InvocationTargetException;
18 17
import java.text.SimpleDateFormat;
19 18
import java.util.ArrayList;
20 19
import java.util.Calendar;
......
44 43
import org.eclipse.core.runtime.OperationCanceledException;
45 44
import org.eclipse.core.runtime.Status;
46 45
import org.eclipse.core.runtime.SubProgressMonitor;
47
import org.eclipse.core.runtime.jobs.ISchedulingRule;
48 46
import org.eclipse.core.runtime.jobs.Job;
49 47
import org.eclipse.e4.ui.di.UISynchronize;
50 48
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
51 49
import org.eclipse.e4.ui.workbench.modeling.EPartService;
52 50
import org.eclipse.jface.action.IStatusLineManager;
53
import org.eclipse.jface.operation.IRunnableWithProgress;
54 51
import org.eclipse.jface.resource.ColorRegistry;
55 52
import org.eclipse.jface.resource.FontRegistry;
56 53
import org.eclipse.jface.viewers.IStructuredSelection;
......
60 57
import org.eclipse.swt.widgets.Display;
61 58
import org.eclipse.swt.widgets.Shell;
62 59
import org.eclipse.ui.IWorkbench;
63
import org.eclipse.ui.IWorkbenchWindow;
64 60
import org.eclipse.ui.PlatformUI;
65 61
import org.eclipse.ui.handlers.IHandlerService;
66 62
import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
......
125 121
        return TaxeditorStorePlugin.getDefault().getWorkbench();
126 122
    }
127 123

  
128
    public static IWorkbenchWindow getWorkbenchWindow() {
129
        if (getWorkbench().getWorkbenchWindowCount() > 1) {
130
            throw new IllegalStateException("More than one workbench window");
131
        }
132
        return getWorkbench().getWorkbenchWindows()[0];
133
    }
134

  
135

  
136 124
    public static Object getService(Class api) {
137 125
        return TaxeditorStorePlugin.getDefault().getWorkbench().getService(api);
138 126
    }
......
524 512
        newMonitor.worked(steps);
525 513
    }
526 514

  
527
    public static void runInUI(IRunnableWithProgress runnable,
528
            ISchedulingRule rule) throws InvocationTargetException,
529
            InterruptedException {
530
        getProgressService().runInUI(getWorkbenchWindow(), runnable, rule);
531
    }
532

  
533 515
    public static IProgressService getProgressService() {
534 516
        IWorkbench workbench = PlatformUI.getWorkbench();
535 517
        return workbench.getProgressService();

Also available in: Unified diff