I am working on Graphical Editor i.e (GEF Editor). Files having .graph extensions opens in Graphical Editor and on save action of editor it generates some xml and properties files. Now, my use-case is to achieve the same functionality to generate ".graph" related xml and properties files even if anyone edits ".graph" file using eclipse default text or xml editor.
Is there any way to achieve it?
You can use ResourceChangeListener
IResourceChangeListener listener = new IResourceChangeListener() {
#Override
public void resourceChanged(IResourceChangeEvent arg0) {
System.out.println("Text changed");
}
};
ResourcesPlugin.getWorkspace().addResourceChangeListener(listener);
Related
I just created my own editor in unity.
public class ShapeEditor : Editor
{
private void OnSceneGUI()
{
// Done something
}
}
I didn't place it in any editor folder. It's just somewhere within my project.
Why does that work? What do I get if I place it in an editor folder? Why should I?
It works in the Editor. But if you try to build an executable or app with that code, editor code will not work anymore (or even compile), because the Editor API's aren't available in Player versions.
That's why you need to put code that depends on Editor-specific API's in an Editor folder, so Unity can leave it out when building a player version.
I want to open a text editor in eclipse 4.4 programmatically. I've tried it using IDE class but it is not accessible in eclipse 4.4. How can I do this?
e4 only has parts, not editors and views. It also doesn't have any predefined text editors.
Assuming you want to have several editor parts open at the same time you need to define a 'Part Descriptor' in the application model for the editor.
You then create a part from the descriptor using:
#Inject
EPartService partService;
MPart part = partService.createPart("descriptor id");
You now need to add this to the application model. Usually this will be a child of an 'MPartStack':
#Inject
EModelService modelService;
#Inject
MApplication app;
MPartStack editorStack = (MPartStack)modelService.find("part stack id", app);
editorStack.getChildren().add(part);
Finally show the part:
partService.showPart(part, PartState.ACTIVATE);
The class you specify in the part descriptor for the editor will have to implement the text editor. You can use the JFace text editor classes but not the 'org.eclipse.ui.xxx' editor classes.
For a very simple text editor the TextViewer and Document classes are enough.
I am currently developing a RCP application in Eclipse. Right now it is very minimalistic and consists of only one part containing a Text object as such:
public class MainPart {
private Text txtInput;
#PostConstruct
public void createComposite(Composite parent) {
parent.setLayout(new GridLayout(1, false));
txtInput = new Text(parent, SWT.BORDER);
txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
}
I would like to add an auto-completion functionality to this minimalistic RCP, so that it works in the Text object. How do I approach this problem?
The auto-completion should, at least hopefully when it is finished, be able to auto-complete java code. So basically I want to copy the auto-completion that already exists in Eclipse, and put it in my minimalistic RCP. Just a poke in the right direction of where to begin when constructing an auto-completion functionality would also be much appriciated indeed.
Please note that I am new to the subject of RCP, and I have been searching a lot in different forums for answers, but i cannot really seem to find the core ingredients that are necessary to make an auto-completion functionality.
I am developing an interpreter for a visual programming language that I am implementing using Eclipse, EMF and GEF. I am currently creating an interpreter for the diagrams.
To execute a diagram, I decided to implement a launcher configuration. When the configuration is executed I want to read the EMF model from the active editor and interpret it. The problem I have is that the active editor can only be accessed from the UI thread, and I don't want the interpreter to execute in the UI tread since it may be a long process. This is the code that works but should not be used:
#Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException {
final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
#Override
public void run() {
IEditorPart activeEditor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
OPMGraphicalEditor editor = (OPMGraphicalEditor) activeEditor;
OPMObjectProcessDiagram opd = editor.getOPD();
Interpreter.INSTANCE.interpret(opd);
}
});
}
I'm sure there is a proper way to do this, but I haven't found it. The examples for launch configurations that I found in the internet use external programs, but I am (currently) implementing my interpreter as part of the workbench.
Thanks for the help.
You can use the above code with a ...getDisplay().syncExec(...) instead and then store the pointer to the editor into some enclosing object.
If you're launching your configuration from the editor directly (right-click, run as..) then you can just use an ILaunchShortcut and overwrite its void launch(IEditorPart editor, String mode) method to access the editor where the file is launched from.
a problem troubled me for several days. Would like to find the answer here... Thanks ahead!
I developed a plugin in Eclipse. When it starts up, it will open the files (with specific editors we developed) left at the last exiting. I wonder whether I can disable this auto-starting in code?
BTW, I have tried the option "Window->Preferences->General->Editors->Close editors automatically", however, with useless result.
Thanks for your advices!
Have you tried the 'Restore editor state on statup'?
If you're already creating your own WorkbenchAdvisor (if you're creating an RCP application), you have access to the workbench configurer which can change this property:
public void initialize (IWorkbenchConfigurer configurer) {
super.initialize (configurer);
getWorkbenchConfigurer ().setSaveAndRestore (false);
}
For a non-RCP application (ie: just a plugin), it's not recommended to do this since it is a global setting that will affect all editors. It can still be done though:
public void disableReopenEditors () {
String pref = org.eclipse.ui.IWorkbenchPreferenceConstants.CLOSE_EDITORS_ON_EXIT;
PlatformUI.getPreferenceStore().setValue(pref, true);
}
If you want to do it manually, you can follow Where does Eclipse save the list of files to open on startup? to delete the file the workbench uses to store this information.