Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2005, 2007 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 7-28
Link Here
|
7 |
* |
7 |
* |
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
|
|
10 |
* Benjamin Cabe - bug 217333 |
10 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
11 |
package org.eclipse.pde.internal.ui.launcher; |
12 |
package org.eclipse.pde.internal.ui.launcher; |
12 |
|
13 |
|
|
|
14 |
import java.io.File; |
13 |
import org.eclipse.core.resources.*; |
15 |
import org.eclipse.core.resources.*; |
14 |
import org.eclipse.core.runtime.*; |
16 |
import org.eclipse.core.runtime.*; |
15 |
import org.eclipse.core.variables.IStringVariableManager; |
17 |
import org.eclipse.core.variables.IStringVariableManager; |
16 |
import org.eclipse.core.variables.VariablesPlugin; |
18 |
import org.eclipse.core.variables.VariablesPlugin; |
17 |
import org.eclipse.debug.ui.StringVariableSelectionDialog; |
19 |
import org.eclipse.debug.ui.StringVariableSelectionDialog; |
|
|
20 |
import org.eclipse.jface.dialogs.MessageDialog; |
18 |
import org.eclipse.jface.window.Window; |
21 |
import org.eclipse.jface.window.Window; |
19 |
import org.eclipse.osgi.util.NLS; |
22 |
import org.eclipse.osgi.util.NLS; |
|
|
23 |
import org.eclipse.pde.internal.ui.PDEPlugin; |
20 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
24 |
import org.eclipse.pde.internal.ui.PDEUIMessages; |
21 |
import org.eclipse.pde.internal.ui.util.SWTUtil; |
25 |
import org.eclipse.pde.internal.ui.util.SWTUtil; |
22 |
import org.eclipse.pde.ui.launcher.AbstractLauncherTab; |
26 |
import org.eclipse.pde.ui.launcher.AbstractLauncherTab; |
23 |
import org.eclipse.swt.SWT; |
27 |
import org.eclipse.swt.SWT; |
24 |
import org.eclipse.swt.events.*; |
28 |
import org.eclipse.swt.events.*; |
25 |
import org.eclipse.swt.layout.GridData; |
29 |
import org.eclipse.swt.layout.GridData; |
|
|
30 |
import org.eclipse.swt.program.Program; |
26 |
import org.eclipse.swt.widgets.*; |
31 |
import org.eclipse.swt.widgets.*; |
27 |
import org.eclipse.ui.dialogs.ContainerSelectionDialog; |
32 |
import org.eclipse.ui.dialogs.ContainerSelectionDialog; |
28 |
|
33 |
|
Lines 38-44
Link Here
|
38 |
|
43 |
|
39 |
protected Listener fListener = new Listener(); |
44 |
protected Listener fListener = new Listener(); |
40 |
|
45 |
|
41 |
protected Label fLocationLabel; |
46 |
protected Link fLocationLink; |
42 |
|
47 |
|
43 |
class Listener extends SelectionAdapter implements ModifyListener { |
48 |
class Listener extends SelectionAdapter implements ModifyListener { |
44 |
public void widgetSelected(SelectionEvent e) { |
49 |
public void widgetSelected(SelectionEvent e) { |
Lines 64-75
Link Here
|
64 |
} |
69 |
} |
65 |
|
70 |
|
66 |
protected void createText(Composite parent, String text, int indent) { |
71 |
protected void createText(Composite parent, String text, int indent) { |
67 |
fLocationLabel = new Label(parent, SWT.NONE); |
72 |
fLocationLink = new Link(parent, SWT.NONE); |
68 |
fLocationLabel.setText(text); |
73 |
fLocationLink.setText("<a>" + text + "</a>"); //$NON-NLS-1$ //$NON-NLS-2$ |
69 |
if (indent > 0) { |
74 |
if (indent > 0) { |
70 |
GridData gd = new GridData(); |
75 |
GridData gd = new GridData(); |
71 |
gd.horizontalIndent = indent; |
76 |
gd.horizontalIndent = indent; |
72 |
fLocationLabel.setLayoutData(gd); |
77 |
fLocationLink.setLayoutData(gd); |
73 |
} |
78 |
} |
74 |
|
79 |
|
75 |
fLocationText = new Text(parent, SWT.SINGLE | SWT.BORDER); |
80 |
fLocationText = new Text(parent, SWT.SINGLE | SWT.BORDER); |
Lines 77-82
Link Here
|
77 |
gd.widthHint = 400; |
82 |
gd.widthHint = 400; |
78 |
fLocationText.setLayoutData(gd); |
83 |
fLocationText.setLayoutData(gd); |
79 |
fLocationText.addModifyListener(fListener); |
84 |
fLocationText.addModifyListener(fListener); |
|
|
85 |
|
86 |
fLocationLink.addSelectionListener(new SelectionAdapter() { |
87 |
public void widgetSelected(SelectionEvent e) { |
88 |
try { |
89 |
String path = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(getLocation(), false); |
90 |
File f = new File(path); |
91 |
if (f.exists()) |
92 |
Program.launch(f.getCanonicalPath()); |
93 |
else |
94 |
MessageDialog.openWarning(PDEPlugin.getActiveWorkbenchShell(), isFile() ? PDEUIMessages.BaseBlock_fileTitle : PDEUIMessages.BaseBlock_directoryTitle, isFile() ? PDEUIMessages.BaseBlock_fileNotFoundMessage : PDEUIMessages.BaseBlock_directoryNotFoundMessage); // |
95 |
} catch (Exception ex) { |
96 |
MessageDialog.openWarning(PDEPlugin.getActiveWorkbenchShell(), isFile() ? PDEUIMessages.BaseBlock_fileTitle : PDEUIMessages.BaseBlock_directoryTitle, isFile() ? PDEUIMessages.BaseBlock_fileErrorMessage : PDEUIMessages.BaseBlock_directoryErrorMessage); // |
97 |
} |
98 |
} |
99 |
}); |
100 |
|
80 |
} |
101 |
} |
81 |
|
102 |
|
82 |
protected void createButtons(Composite parent, String[] buttonLabels) { |
103 |
protected void createButtons(Composite parent, String[] buttonLabels) { |
Lines 155-162
Link Here
|
155 |
|
176 |
|
156 |
protected abstract String getName(); |
177 |
protected abstract String getName(); |
157 |
|
178 |
|
|
|
179 |
/** |
180 |
* @return true if the block edits a file, false otherwise (i.e. directory) |
181 |
*/ |
182 |
protected abstract boolean isFile(); |
183 |
|
158 |
protected void enableBrowseSection(boolean enabled) { |
184 |
protected void enableBrowseSection(boolean enabled) { |
159 |
fLocationLabel.setEnabled(enabled); |
185 |
fLocationLink.setEnabled(enabled); |
160 |
fLocationText.setEnabled(enabled); |
186 |
fLocationText.setEnabled(enabled); |
161 |
fFileSystemButton.setEnabled(enabled); |
187 |
fFileSystemButton.setEnabled(enabled); |
162 |
fWorkspaceButton.setEnabled(enabled); |
188 |
fWorkspaceButton.setEnabled(enabled); |