Pokazywanie postów oznaczonych etykietą PDE. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą PDE. Pokaż wszystkie posty

poniedziałek, 12 października 2015

[PDE] How to find out all plugins that given extension point is used

There are two ways to do so from PDE UI level. First is by opening "Open Plug-in Artifact" view (Ctrl + Shift + A) - technically org.eclipse.pde.internal.ui.search.dialogs.FilteredPluginArtifactsSelectionDialog class.

Once you type "expressions.propertyTesters" in filter box and deselect all but "Show Extension" item hidden under black triangle on the right, the matching items will contain all plugins are using "org.eclipse.core.expressions.propertyTesters" extension point.

The another way is using default Search Dialog (Ctrl + H). The last tab is "Plug-in Search".

  • Search For: Extension Point
  • Limit To: References
This time you need type fully qualified id or use wild card (*expressions.propertyTesters)

wtorek, 17 marca 2015

How to run a long operation with a spinner/hourglass indicator within eclipse plugin (swt application) ?

From time to time there is a need to run some relatively long operation synchronously. In such a case will be good to indicate the fact to the user. There is very simple way of doing this with BusyIndicator class. Just replace syncExec with BusyIndicator.showWhile.
Display.getCurrent().syncExec(new Runnable() {
    @Override
    public void run() {
           // long operation
    }
});
with the following:
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
    @Override
    public void run() {
           // long operation
    }
});

poniedziałek, 2 lutego 2015

How to obtain Eclipse absolute installation path programmatically

The easiest way is to use org.eclipse.core.runtime.Platform class and its static getInstallLocation method.
Location installLocation = Platform.getInstallLocation();
A Location interface is defined in OSGi specification and basically represents an java.net.URL object. Additionally it allows creating nested locations and mechanism for locking locations. The default and the only one shipped implementation is BasicLocation, but it is internal class and just pure implementation (no other fancy features ;) To obtain path as a String user the following code:
String absolutePath = Platform.getInstallLocation().getURL().getFile();
Alternatively you can read the content
InputStream is = Platform.getInstallLocation().getURL().getContent();

środa, 4 czerwca 2014

Binding key strokes to eclipse commands

The key is specified as uppercased character. However, there can be also specified other keys, which can be also no printable.
The following special literals are available :
  • SPACE, TAB, CR, DEL, ESC, BREAK, BS, CAPS_LOCK, END, HOME, INSERT, PAGE_UP, PAGE_DOWN
  • ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, ARROW_UP
  • F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, FF
  • NUM_LOCK, NUMPAD_0, NUMPAD_1, NUMPAD_2, NUMPAD_3, NUMPAD_4, NUMPAD_5, NUMPAD_6, NUMPAD_7, NUMPAD_8, NUMPAD_9, NUMPAD_ADD, NUMPAD_DECIMAL, NUMPAD_DIVIDE, NUMPAD_ENTER, NUMPAD_EQUAL, NUMPAD_MULTIPLY, NUMPAD_SUBTRACT
  • LF, NUL, , PAUSE, PRINT_SCREEN, SCROLL_LOCK, and VT

czwartek, 8 maja 2014

Eclipse PDE - all about Eclipse Commands

The goal of this site is gather most useful locationURI's one can like to attach custom command for Eclipse environment.

menu:org.eclipse.ui.views.ProblemView
menu:window?after=newEditor
popup:org.eclipse.ui.menus.showInMenu popup:#TextEditorContext?after=copy popup:#TextEditorContext?endof=group.find popup:#TextEditorContext?after=group.open popup:#TextEditorContext?after=group.edit

Useful commands

  • org.eclipse.ui.ide
    • org.eclipse.ui.edit.text.openLocalFile (Open a local file)
    • org.eclipse.ui.navigate.goToResource (Go to particulare resource in the active window)
    • org.eclipse.ui.navigate.openResource (Open an editor on a praticular resource)
      • handler: org.eclipse.ui.internal.ide.handlers.OpenResourceHandler
      • param: filePath
    • org.eclipse.ui.edit.addTask (Add a task)
      • defaultHandler:  no
    • org.eclipse.jdt.ui.edit.text.java.correction.assist.proposals (Suggest possible fixes for a problem)
      • deafultHander: no
    • org.eclipse.ui.navigate.showResourceByPath (Show a resource in the Navigator given its path)
      • defaultHandler: org.eclipse.ui.internal.ide.handlers.ShowResourceByPathHandler
      • resourcePath
    • org.eclipse.ui.ide.copyBuildIdCommand (Copies the build id to the clipboard)
      • defaultHandler: org.eclipse.ui.internal.ide.commands.CopyBuildIdToClipboardHandler
  • org.eclipse.ui
    • org.eclipse.ui.newWizard (Open wizard)
      • param: newWizardId
    • org.eclipse.ui.file.import
      • param:  importWizardId
    • org.eclipse.ui.file.export
      • param: exportWizardId

Invoke programmatically

ICommandService commandService = (ICommandService) PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow().getService(ICommandService.class);

IEvaluationService evaluationService = (IEvaluationService) PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow().getService(IEvaluationService.class);
try {
 Command c = commandService.getCommand("org.eclipse.ui.newWizard");

 Map<String, String> params = new HashMap<String, String>();
 params.put("newWizardId", "mywizard.id");

 c.executeWithChecks(new ExecutionEvent(c, params, null, evaluationService.getCurrentState()));

} catch (Exception ex) {
 throw new RuntimeException("Open new wizard command not found");
}

 Menus


   
      
         
             
             
             
             
         
      
   



   
      
         
           
         
      
      
        
      
   



   
      
      
         
            
            
         
      
   



   


piątek, 9 kwietnia 2010

IHandler - How to obtain current selection based on ExecutionEvent object

The most common method of implementing custom handler is to subclass AbstractHandler. This very handy class reduce our work to fill just one method: execute(ExecutionEvent event). The entire stub looks as following:

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;

public class MyCustomHandler extends AbstractHandler {

 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
  // TODO Auto-generated method stub
  return null;
 }
}

The question is how to obtain selection? Actually it is fairly simple and needs employ HandlerUtil class. This class is particularity interesting as delivers couple of utility method for working with ExecutionEvent object.

Two exemplary methods for obtaining current selection looks as below:

// the most straightforward ;>
ISelection selection = HandlerUtil.getCurrentSelection(event);

// and another more elaborate
ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();

ExecutionEvent javadoc:

The data object to pass to the command (and its handler) as it executes. This
carries information about the current state of the application, and the
application context in which the command was executed.

An execution event carries three blocks of data: the parameters, the trigger,
and the application context. How these blocks are used is application
dependent. In the Eclipse workbench, the trigger is an SWT event, and the
application context contains information about the selection and active part.

more..

And someshing more about handlers: org.eclipse.ui.handlers

piątek, 2 kwietnia 2010

How to force line numbering when opening a file with TextEditor?

Generally Eclipse workbench use global setting for line-numbering feature. Thus one need to perform following code to on the numbering.


IPreferenceStore store = EditorsUI.getPreferenceStore();
store.setValue(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, true);

But remember: DO not happing others by force ;). Thus if for some reason you decide your editor absolutely needs the numbering, take care to reset the setting then close the editor.

static private String NUMBERING = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER;
private boolean numbering;

...

IPreferenceStore store = EditorsUI.getPreferenceStore();
numbering = store.getBoolean(NUMBERING);
store.setValue(NUMBERING, true);

...

// when dispose
IPreferenceStore store= EditorsUI.getPreferenceStore();
store.setValue(NUMBERING, numbering);
  
super.dispose();