blob: 46c8441f593eb82b58ccdca7c7ed16c6185a6ada (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*******************************************************************************
* Copyright (c) 2004 - 2006 University Of British Columbia and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
package org.eclipse.mylar.internal.tasks.ui.actions;
import java.util.Iterator;
import org.eclipse.mylar.tasks.core.AbstractQueryHit;
import org.eclipse.mylar.tasks.core.AbstractTaskContainer;
import org.eclipse.mylar.tasks.core.ITask;
import org.eclipse.mylar.tasks.ui.TasksUiUtil;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
/**
* @author Mik Kersten
* @author Rob Elves
*/
public class OpenWithBrowserAction extends BaseSelectionListenerAction {
private static final String LABEL = "Open with Browser";
public static final String ID = "org.eclipse.mylar.tasklist.actions.open.browser";
public OpenWithBrowserAction() {
super(LABEL);
setToolTipText(LABEL);
setId(ID);
}
@SuppressWarnings("unchecked")
@Override
public void run() {
if (super.getStructuredSelection() != null) {
for (Iterator iter = super.getStructuredSelection().iterator(); iter.hasNext();) {
runWithSelection(iter.next());
}
}
}
private void runWithSelection(Object selectedObject) {
String urlString = null;
if (selectedObject instanceof ITask) {
ITask task = (ITask)selectedObject;
if (task != null && task.hasValidUrl()) {
urlString = task.getTaskUrl();
}
} else if (selectedObject instanceof AbstractQueryHit) {
AbstractQueryHit hit = (AbstractQueryHit) selectedObject;
urlString = hit.getUrl();
} else if (selectedObject instanceof AbstractTaskContainer) {
AbstractTaskContainer query = (AbstractTaskContainer) selectedObject;
urlString = query.getUrl();
}
if (urlString != null) {
TasksUiUtil.openUrl(urlString, false);
}
}
}
|