Skip to content

Commit e498291

Browse files
committed
add comment from plugin.xml in .ui project. Related to #26
1 parent 0914d8f commit e498291

File tree

2 files changed

+223
-223
lines changed

2 files changed

+223
-223
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,108 @@
1-
package org.nodeclipse.debug.launch;
2-
3-
import org.eclipse.core.resources.IFile;
4-
import org.eclipse.core.runtime.CoreException;
5-
import org.eclipse.debug.core.DebugPlugin;
6-
import org.eclipse.debug.core.ILaunchConfiguration;
7-
import org.eclipse.debug.core.ILaunchConfigurationType;
8-
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
9-
import org.eclipse.debug.core.ILaunchManager;
10-
import org.eclipse.debug.internal.ui.DebugUIPlugin;
11-
import org.eclipse.debug.ui.DebugUITools;
12-
import org.eclipse.debug.ui.ILaunchShortcut;
13-
import org.eclipse.jface.dialogs.MessageDialog;
14-
import org.eclipse.jface.viewers.ISelection;
15-
import org.eclipse.jface.viewers.IStructuredSelection;
16-
import org.eclipse.ui.IEditorPart;
17-
import org.eclipse.ui.IEditorInput;
18-
import org.eclipse.ui.IFileEditorInput;
19-
import org.nodeclipse.debug.util.Constants;
20-
21-
/**
22-
* Using "Run As" --> "Node Application" will lead here.
23-
**/
24-
public class LaunchShortcut implements ILaunchShortcut {
25-
26-
/**
27-
* (non-Javadoc)
28-
*
29-
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers
30-
* .ISelection, java.lang.String)
31-
**/
32-
@Override
33-
public void launch(ISelection selection, String mode) {
34-
try {
35-
Object selectObj = ((IStructuredSelection) selection).getFirstElement();
36-
if (selectObj instanceof IFile) {
37-
launchFile((IFile) selectObj, mode);
38-
} else {
39-
MessageDialog.openWarning(null, "Warning", "Not implemeneted yet!");
40-
}
41-
} catch (CoreException e) {
42-
}
43-
}
44-
45-
/**
46-
* (non-Javadoc)
47-
*
48-
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart,
49-
* java.lang.String)
50-
**/
51-
@Override
52-
public void launch(IEditorPart editor, String mode) {
53-
try {
54-
IEditorInput editorInput = editor.getEditorInput();
55-
if (editorInput instanceof IFileEditorInput) {
56-
IFile selectObj = ((IFileEditorInput) editorInput).getFile();
57-
launchFile((IFile) selectObj, mode);
58-
} else {
59-
MessageDialog.openWarning(null, "Warning", "Not implemeneted yet!");
60-
}
61-
} catch (CoreException e) {
62-
}
63-
}
64-
65-
/**
66-
* Launch an file,using the file information, which means using default
67-
* launch configurations.
68-
*
69-
* @param file
70-
* @param mode
71-
*/
72-
private void launchFile(IFile file, String mode) throws CoreException {
73-
// check for an existing launch config for the file
74-
String path = file.getFullPath().toString();
75-
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
76-
ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(Constants.LAUNCH_CONFIGURATION_TYPE_ID);
77-
ILaunchConfiguration configuration = createLaunchConfiguration(type, path, file);
78-
DebugUITools.launch(configuration, mode);
79-
}
80-
81-
/**
82-
* Create a new configuration and set useful data.
83-
*
84-
* @param type
85-
* @param path
86-
* @param file
87-
* @return
88-
* @throws CoreException
89-
*/
90-
private ILaunchConfiguration createLaunchConfiguration(ILaunchConfigurationType type, String path, IFile file) throws CoreException {
91-
String configname = file.getFullPath().toString().replace('/', '-');
92-
if(configname.startsWith("-")) {
93-
configname = configname.substring(1);
94-
}
95-
96-
ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(type);
97-
for(ILaunchConfiguration config : configs) {
98-
if(configname.equals(config.getName())) {
99-
return config;
100-
}
101-
}
102-
103-
// create a new configuration for the file
104-
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, configname);
105-
workingCopy.setAttribute(Constants.KEY_FILE_PATH, path);
106-
return workingCopy.doSave();
107-
}
108-
}
1+
package org.nodeclipse.debug.launch;
2+
3+
import org.eclipse.core.resources.IFile;
4+
import org.eclipse.core.runtime.CoreException;
5+
import org.eclipse.debug.core.DebugPlugin;
6+
import org.eclipse.debug.core.ILaunchConfiguration;
7+
import org.eclipse.debug.core.ILaunchConfigurationType;
8+
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
9+
import org.eclipse.debug.core.ILaunchManager;
10+
import org.eclipse.debug.internal.ui.DebugUIPlugin;
11+
import org.eclipse.debug.ui.DebugUITools;
12+
import org.eclipse.debug.ui.ILaunchShortcut;
13+
import org.eclipse.jface.dialogs.MessageDialog;
14+
import org.eclipse.jface.viewers.ISelection;
15+
import org.eclipse.jface.viewers.IStructuredSelection;
16+
import org.eclipse.ui.IEditorPart;
17+
import org.eclipse.ui.IEditorInput;
18+
import org.eclipse.ui.IFileEditorInput;
19+
import org.nodeclipse.debug.util.Constants;
20+
21+
/**
22+
* Using "Run As" --> "Node Application" will lead here from plugin.xml in .ui project.
23+
**/
24+
public class LaunchShortcut implements ILaunchShortcut {
25+
26+
/**
27+
* (non-Javadoc)
28+
*
29+
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers
30+
* .ISelection, java.lang.String)
31+
**/
32+
@Override
33+
public void launch(ISelection selection, String mode) {
34+
try {
35+
Object selectObj = ((IStructuredSelection) selection).getFirstElement();
36+
if (selectObj instanceof IFile) {
37+
launchFile((IFile) selectObj, mode);
38+
} else {
39+
MessageDialog.openWarning(null, "Warning", "Not implemeneted yet!");
40+
}
41+
} catch (CoreException e) {
42+
}
43+
}
44+
45+
/**
46+
* (non-Javadoc)
47+
*
48+
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart,
49+
* java.lang.String)
50+
**/
51+
@Override
52+
public void launch(IEditorPart editor, String mode) {
53+
try {
54+
IEditorInput editorInput = editor.getEditorInput();
55+
if (editorInput instanceof IFileEditorInput) {
56+
IFile selectObj = ((IFileEditorInput) editorInput).getFile();
57+
launchFile((IFile) selectObj, mode);
58+
} else {
59+
MessageDialog.openWarning(null, "Warning", "Not implemeneted yet!");
60+
}
61+
} catch (CoreException e) {
62+
}
63+
}
64+
65+
/**
66+
* Launch an file,using the file information, which means using default
67+
* launch configurations.
68+
*
69+
* @param file
70+
* @param mode
71+
*/
72+
private void launchFile(IFile file, String mode) throws CoreException {
73+
// check for an existing launch config for the file
74+
String path = file.getFullPath().toString();
75+
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
76+
ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(Constants.LAUNCH_CONFIGURATION_TYPE_ID);
77+
ILaunchConfiguration configuration = createLaunchConfiguration(type, path, file);
78+
DebugUITools.launch(configuration, mode);
79+
}
80+
81+
/**
82+
* Create a new configuration and set useful data.
83+
*
84+
* @param type
85+
* @param path
86+
* @param file
87+
* @return
88+
* @throws CoreException
89+
*/
90+
private ILaunchConfiguration createLaunchConfiguration(ILaunchConfigurationType type, String path, IFile file) throws CoreException {
91+
String configname = file.getFullPath().toString().replace('/', '-');
92+
if(configname.startsWith("-")) {
93+
configname = configname.substring(1);
94+
}
95+
96+
ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(type);
97+
for(ILaunchConfiguration config : configs) {
98+
if(configname.equals(config.getName())) {
99+
return config;
100+
}
101+
}
102+
103+
// create a new configuration for the file
104+
ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, configname);
105+
workingCopy.setAttribute(Constants.KEY_FILE_PATH, path);
106+
return workingCopy.doSave();
107+
}
108+
}

0 commit comments

Comments
 (0)