In eclipse have a function that when I'm modifying a class that will implements a * in the title like this:
And when I select Save button that * is no more.
The question is I want add that function into my application but have no idea or any key word to search it on google. Any suggestion?
Implement IEditorPart interface in your own editor and override its isDirty() and doSave() methods. Send notifications about content changes to workbench with firePropertyChange() (with PROP_DIRTY argument).
Don't forget to contribute your editor to org.eclipse.ui.editors extension point.
Related
I'm developing plugin for IDEA. It need to select public abstract methods with no parameters, and allow user to choose subset of them. I found MemberChooser dialog, but cannot see similar thing for methods.
So if I have List<PsiMethod> how to show dialog for choosing subset of them?
You can use MemberChooser.selectElements with your list.
That is, if you create a PsiMethodMember from each PsiMethod.
I am writing an Eclipse plugin (Indigo/Juno) that contains a text editor for a custom text format. I am following the tutorial here: http://www.realsolve.co.uk/site/tech/jface-text.php
So far I have everything working. Eclipse will use my editor to edit files. I have partitioning, damaging, repairing, syntax highlighting all working.
I added a preferences page with color pickers to control syntax highlighting. It works mostly correct. If I update the colors, the editor uses them the next time I open or reopen a file.
How do I get an editor tab to update itself without opening a new one? The built-in JDT Java editor does this, but so far I have not been able to decipher how (it is a very large and complex editor).
I gather that I need to create a preferences listener (http://www.vogella.com/articles/EclipsePreferences/article.html). I have done this and can verify that my listener code is being invoked when I set a breakpoint in it.
The missing piece is the wiring between the listener and reinitializing the editor. I have tried reconstructing the partitioning logic, the color logic, the damager/repairer, etc. but nothing seems to work. It either does nothing I can see or at worst will corrupt the display until I scroll the current text out of view to repaint it... with the old colors.
Any ideas?
I think SourceViewer.invalidatePresentation() needs to be called.
It may be already late to you, but if you want you could use LiClipse for that (http://brainwy.github.io/liclipse/) -- one of its targets is easily doing an editor with syntax highlighting, basic code-completion, outline, etc targeting Eclipse.
No java skills are required to add a new language (mostly creating a new .liclipse -- which is a YAML -- file in the proper place and creating some basic rules to say how to partition your language -- i.e.: usually just separating code from comments from strings -- and specifying the keywords you have in the partition would already give you proper syntax highlighting).
If you download it, there are a number of examples at plugins\com.brainwy.liclipse.editor\languages and there's some basic documentation at http://brainwy.github.io/liclipse/supported_languages.html and http://brainwy.github.io/liclipse/scope_definition.html on how to do it.
For anyone coming across this as I did:
My solution involved adding the following lines into the Constructor of my Editor
Activator.getActivator().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() {
#Override
public void propertyChange(PropertyChangeEvent event) {
getSourceViewer().invalidateTextPresentation();
handlePreferenceStoreChanged(event);
}
});
and then creating a custom class that extended IToken. In the constructor I pass the String of the preference field and then in the 'getObject' method I create the TextAttribute: snippets below
public class MyToken extends Token implements IToken {
public MyToken(Object data) {
super(data);
}
#Override
public Object getData() {
String dataString = (String) super.getData();
return getAttributeFromColorName(dataString);
}
private TextAttribute getAttributeFromColorName(String preferenceField) {
Color color = new Color(Display.getCurrent(), StringConverter.asRGB(Activator.getActivator().getPreferenceStore().getString(preferenceField)));
return new TextAttribute(color);
}
}
When I generate my Rules I have all of my tokens as my custom class and this allowed me to change syntax color dynamically.
I also added an example for updating the coloring if the preference changes to https://www.vogella.com/tutorials/EclipseEditors/article.html#exercise-allow-user-to-customize-the-colors
This is using the Generic editor (currently the best approach to implement a customer editor) but it should be possible to adjust this to any Eclipse editor implementation.
I have a class implementing IEditorPart as a page in my MultiPageEditorPart.
Now I'd like to extend its functionality with ActionBarContributor and other Eclipse editor extensions.
For that purpose, I've defined an extension for org.eclipse.ui.editors, that points to my class.
This extension never get invoked as I create an instance of my class explicitly with new operator. Workbench allows creation of editors, but opens them in a new editor window.
How should an IEditorPart be created so that all extensions are applied to it and it can be used as MultiPageEditorPart.addPage() argument?
I am writing a custom Eclipse editor by subclassing TextEditor, and I can't use the Format action that I configured.
I read the 3 parts in Creating a commercial quality IDE, and I know about SourceViewerConfiguration. I implemented the required method:
override def getContentFormatter(viewer: ISourceViewer) = {
val formatter = new MultiPassContentFormatter(getConfiguredDocumentPartitioning(viewer), IDocument.DEFAULT_CONTENT_TYPE)
formatter.setMasterStrategy(new ScalaFormattingStrategy(textEditor))
formatter
}
However, I can't find Format anywhere in the menu, contextual menu, toolbar, etc. The Java shortcut (CMD-Shift-F) does not work either.
Edit: I have implemented other methods in the SourceViewerConfiguration subclass I created, and everything else works as expected in my editor (completion, hyperlinking, reconciliation).
What is the preferred way to expose the formatter? Do I need to do anything more?
Quoting the Eclipse formatter FAQ:
Finally, you will need to create an action that invokes the formatter.
No generic formatting action is defined by the text infrastructure,
but it is quite easy to create one of your own. The action’s run
method can simply call the following on the source viewer to invoke
the formatter:
sourceViewer.doOperation(ISourceViewer.FORMAT);
I am working on an Eclipse RCP-based application, and we have decided that we do not want any of the menu items to display icons next to the text. The problem we are seeing is that the standard actions like Undo, Redo, Cut, Copy, Paste, and so on all display the default icons for the corresponding actions.
Is there any way to tell the action management infrastructure to ignore the icons? My brute force solution to this was to rebuild the SWT so that MenuItem.setImage() was a no-op, and then include our own copy of the SWT in the final product, but it seems like there should be a lighter-weight solution.
This turned out to be easier than I had hoped.
Create a subclass of org.eclipse.ui.application.ActionBarAdvisor. Override the method register like this:
protected void register(IAction action) {
super.register(action);
action.setImageDescriptor(null);
}
Then, create a subclass of org.eclipse.ui.application.WorkbenchWindowAdvisor that overrides createActionBarAdvisor:
public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
return new MyActionBarAdvisor(configurer);
}
That's it. All actions will no longer have icons.
I believe you want to further examine going into the manifest and looking into
org.eclipse.ui.views and seeing if there is anything in there for removing icons
What is the reason for not including icons?
A lot of effort went into creating a standard interface, what would be the benefit of deviating from the standard? Do you think their omission increases usability?
Having said all that you could try contributing a fragment with some AspectJ around advice to intercept calls to setImage() and veto them.
You can do this by going to the extension tab in plugin.xml.add the extension org.eclipse.ui.menu (if not present).Right click create a new menu contribution.again right click and create a new menu.here u have the option to change the images with the ones saved in your icon folder in your class path