Eclipse knows external tools (menu run->external tools) and I would like to show the list of external tools on a right click in my view so the user can select a tool which I then execute.
I however simply fail to find the external tools.
The code I have now dumps the commands (and there are plenty) but I do not find the external tools I created.
ICommandService commandService=PlatformUI.getWorkbench().getService(ICommandService.class);
Command[] allCommands = commandService.getDefinedCommands();
for(Command curCommand :allCommands) {
Category cat = curCommand.getCategory();
System.out.print(cat.getName()+" ");
System.out.println(curCommand.getName());
}
Where can I find a list of external tools?
Based on the info of greg I found the following to work in my case.
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = manager.getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"); //$NON-NLS-1$
ILaunchConfiguration[] lcs = manager.getLaunchConfigurations(type);
This works for program launch configurations because I use the key ("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType".
If you do not know which type is your command use getLaunchConfigurationTypes() to find all types and list the names to find the Type you need.
There are plenty.
Related
Can someone please help me with this, am trying to use OpenFileDialog class from System.Windows.Forms to open a file dialog and read the selected file. Then, this error showed up. I've referenced it but still the same, below is the code.
`using UnityEngine
using UnityEngine.UI
using System.Windows.Forms;
public class OpenFileButtonScript : MonoBehaviour
{
public TextFieldScript textFieldScript;
public void OpenFile()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
openFileDialog.FilterIndex = 1;
openFileDialog.Multiselect = false;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string filePath = openFileDialog.FileName;
string text = System.IO.File.ReadAllText(filePath);
textFieldScript.inputField.text = text;
}
}
}`
It may look like you have access to all of the native Window system libraries, but it just looks like it. In actuality, a lot of the time you're simply given stubs, or shims, that look like the full Window libraries, because there's a certain element that Unity wants to use from those namespaces. If you think about it, the code you present above, what do you think it should do on Android or Nintendo devices? The simple answer is, it simply won't work.
Generally in cases like this, you have to gain access to the native operating system, and perform those calls directly. For example, there is a file browser asset on the Asset Store, that does this for you. It's not free, because the process isn't trivial.
Depending on how much effort you want to put in, you CAN read files from the local file stores (to varying degrees based on platform). It's possible to read the list of files in a location, and use either uGUI or UIToolkit to create your own File Open Dialogue box. Again, this isn't a trivial task either. So you have to be sure that you'd want to go down that path.
I am developing a eclipse plugin to ease the development using a proprietary version control system.
Right now there is only a command prompt version of the system available for this VCS and its run in terminal. So from my eclipse plugin I want to provide a simple menu options to do the things like check-out and check-in and internally call these commands.
But to run these commands I need to pass the argument 'path' of the selected .java file in the editor/project explorer. How can I get the path of the source file to the plugin?
Get the current workbench page:
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
the workbench page implements ISelectionService so you can get the current selection:
ISelection selection = page.getSelection();
this will generally by an IStructuredSelection (but you need to check)
IStructuredSelection sel = (IStructuredSelection)selection;
See if this adapts to an IFile:
Object selObject = sel.getFirstElement(); // or iterate through all the selection elements
IFile file = Platform.getAdapterManager().getAdapter(selObject, IFile.class);
if you get a file the full path is:
String location = file.getLocation().toOSString();
If the current part is an editor then the selection you receive might be a text string. So you need to deal with editors separately:
IWorkbenchPart activePart = page.getActivePart();
if (activePart instanceof IEditorPart)
{
IEditorInput input = ((IEditorPart)activePart).getEditorInput();
if (input instanceof IFileEditorInput)
{
IFile file = ((IFileEditorInput)input).getFile();
...
}
}
I am doing netBeans platform application.when I creating top component I give it as "explorer" mode to start.But in default it start in "editor" mode.Here the annotations which top component automatically generated.
#ConvertAsProperties(
dtd = "-//MyApplication.windows//MyViewer//EN",
autostore = false)
#TopComponent.Description(
preferredID = "MyViewerTopComponent",
//iconBase="SET/PATH/TO/ICON/HERE",
persistenceType = TopComponent.PERSISTENCE_ALWAYS)
#TopComponent.Registration(mode = "explorer", openAtStartup = true)
#ActionID(category = "Window", id = "MyApplication.windows.MyViewerTopComponent")
#ActionReference(path = "Menu/Window" /*, position = 333 */)
#TopComponent.OpenActionRegistration(
displayName = "#CTL_MyViewerAction",
preferredID = "MyViewerTopComponent")
#Messages(
{
"CTL_MyViewerAction=MyViewer",
"CTL_MyViewerTopComponent=MyViewer Window",
"HINT_MyViewerTopComponent=This is a MyViewer window"
})
Please give me any suggestion for this problem.
I just had this problem. I unchecked a module dependency called RCP Platform and the windows would only open in editor position. I was trying to find the minimum modules needed to run my program.
You can see which modules are used by right clicking the project node and choosing properties. Look at libraries and expand the Platform node. Make sure RCP Platform is checked. If it gives an error, just click resolve. Make sure you do a clean and build afterwords.
There is one easier thing you should check first. When you run a NB platform program, it opens windows in the last used position. If you moved a window, it will reopen where you last moved it to. You have to do a clean and build to reset this.
This may not be possible but I'm looking for a way to add a button (or option in right click menu of project) that allows me to perform what would normally be multiple separate actions , specifically I would like an option that would:
perform a Maven clean on the current project
clean the project in eclipse
clean the server and rebuild (normally or Debug)
I have tried to Google this but I couldn't find anything that might help (I may not of phrased it correctly though as I am not sure what to search for)
All of the actions you listed can be done by separate builders. So you can create a launch config to run the Maven clean action, another launch config to run the Eclipse clean command and so on.
When you have all of those launch configs available, install the CDT launch group feature to run them together with one click: https://stackoverflow.com/a/11905444/44089
There have been a number of scripting attempts with eclipse, but not many of them are successful. You can always write your own command and handler, and from there you can execute any number of commands that you can specify:
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil
.getActiveWorkbenchWindowChecked(event);
IHandlerService handlerService = (IHandlerService) window
.getService(IHandlerService.class);
try {
handlerService.executeCommand(
IWorkbenchCommandConstants.HELP_ABOUT, null);
handlerService.executeCommand(
IWorkbenchCommandConstants.FILE_REFRESH, null);
} catch (NotDefinedException | NotEnabledException
| NotHandledException e) {
throw new ExecutionException("Failed", e);
}
return null;
}
Then you just need to track down command IDs that correspond to what you want to do. ALT+SHIFT+F2 and then selecting a menu item can provide the command ID (or action definition ID, which is the same thing).
I'm trying to create a plugin that annotates eclipse java projects based on external output. Currently, I'm traversing all of the open projects based on this tutorial: http://www.vogella.de/articles/EclipseJDT/article.html However, I'm looking for a way to get a full list of only the files that are currently open in the java editor. Is there a way or command for me to get that?
//get all active editor references,check if reference is of type java editor
IEditorReference[] ref = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage()
.getEditorReferences();
List<IEditorReference> javaEditors = new ArrayList<IEditorReference>();
for (IEditorReference reference : ref) {
if ("org.eclipse.jdt.ui.CompilationUnitEditor".equals(reference.getId())){
javaEditors.add(reference);
}
}