~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.callgraph.core/src/org/eclipse/linuxtools/internal/callgraph/core/SystemTapUIErrorMessages.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2009 Red Hat, Inc.
 
3
 * All rights reserved. This program and the accompanying materials
 
4
 * are made available under the terms of the Eclipse Public License v1.0
 
5
 * which accompanies this distribution, and is available at
 
6
 * http://www.eclipse.org/legal/epl-v10.html
 
7
 * 
 
8
 * Contributors:
 
9
 *     Red Hat - initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.linuxtools.internal.callgraph.core;
 
12
 
 
13
import org.eclipse.core.runtime.IProgressMonitor;
 
14
import org.eclipse.core.runtime.IStatus;
 
15
import org.eclipse.core.runtime.Status;
 
16
import org.eclipse.jface.dialogs.MessageDialog;
 
17
import org.eclipse.swt.widgets.Shell;
 
18
import org.eclipse.ui.IWorkbenchWindow;
 
19
import org.eclipse.ui.PlatformUI;
 
20
import org.eclipse.ui.progress.UIJob;
 
21
 
 
22
/**
 
23
 * Convenience class for opening an error dialog from a non-UI job.
 
24
 *
 
25
 */
 
26
public class SystemTapUIErrorMessages extends UIJob {
 
27
        private String title, message;
 
28
        private static boolean active = true;
 
29
 
 
30
        public SystemTapUIErrorMessages(String name, String title, String message) {
 
31
                super(name);
 
32
                this.title = title;
 
33
                this.message = message;
 
34
        }
 
35
 
 
36
        @Override
 
37
        public IStatus runInUIThread(IProgressMonitor monitor) {
 
38
                if (!active)
 
39
                        return Status.CANCEL_STATUS;
 
40
                //Test that this job is running in the UI thread 
 
41
                IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
 
42
                
 
43
                if (window == null) {
 
44
                        return Status.CANCEL_STATUS; //Something is wrong!
 
45
                }
 
46
                
 
47
                Shell sh = new Shell();
 
48
                
 
49
        
 
50
                MessageDialog.openError(sh, title, message);
 
51
                return Status.OK_STATUS;
 
52
        }
 
53
 
 
54
        
 
55
        public static boolean isActive() {
 
56
                return active;
 
57
        }
 
58
        
 
59
        public static void setActive(boolean val) {
 
60
                active = val;
 
61
        }
 
62
}