Create editor with multiple parts in Eclipse 4.x - eclipse

I want to create an application that can open files. When opening a file, an editor should open like in the normal Eclipse IDE. but i want in this Editor multiple Parts (e.g. TreeView of the opened data and data in plaintext)
Is there a way to describe the contents of this editor in the Application.e4xmi and then just opening this "view"?
like this:
Application.e4xmi:
PartStack (id = "editor.partstack")
|- Part (DataTreeViewer.java)
|- Part (PlaintextViewer.java)
\- Part (ImagePart.java)
OpenHandler.java:
PartStack ps = openPartStack("editor.partstack");
addToMainPartstack(ps);
Or do i have to describe the editor contents programmatically in the OpenHandler? like this:
OpenHandler.java:
PartStack ps = createNewPartStack();
ps.add(new DataTreeViewer());
ps.add(new PlainTextViewer());
ps.add(new ImagePart());
addToMainPartstack(ps);

I just used a PartDescriptor for the editor part and an ordinary CTabFolder for the pages in the editor.

Related

How to activate Fluid (TYPO3) autocompletion in Netbeans?

I did what it said here: Extbase and Fluid Autocompletion
In NetBeans right-click your Extension project and choose Properties
in the opened context menu to edit the project properties. Select the
category PHP Include Path and use Add Folder... to add the directories
of Extbase and Fluid.
So I added the Fluid and Extbase Folders which I previously copied onto my computer from the Server at /var/www/typo3_src/typo3_src-6.2.25/typo3/sysext:
but it didn't work - here's my Project:
And here is fluid stuff that the editor still doesn't recognize:
What am I doing or thinking wrong?
Found info here, works for me:
It's an old topic but I have a trick so that you can add Auto-complete
function for fluid, vhs, flux.
First of all, download the XSD schema files from here :
https://fluidtypo3.org/viewhelpers/fluid/master.html put them
somewhere locally.
Next step, in Netbeans, go to menu Tools > DTD and XML Schemas, add
your 3 DTD in user catalog :
Flux : Public ID = http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers URI
= path to your flux XDS file
Fluid : Public ID = http://typo3.org/ns/TYPO3/Fluid/ViewHelpers URI =
path to your fluid XDS file
Vhs : Public ID = http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers URI =
path to your flux VHS file
Next, in project properties, go to 'testing' menu and add the folder
where you stored your DTD.
Now, in your Project > Test Files, add a new XML Document and choose
"XML Schema-Constrained Document" on next step, click the button
'Browse' and By File > Your Project > Test Files and select import for
all the xsd schema files.
Then, change the prefix f for fluid, flux for flux and vhs for vhs
choose fluid as primary and finish.
A file is created with this content :
And into the section <f:alias>, you have the auto-completion for
fluid, vhs and flux.
<f:alias
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:f='http://typo3.org/ns/TYPO3/Fluid/ViewHelpers'
xmlns:vhs='http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers'
xmlns:flux='http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers'
xsi:schemaLocation='http://typo3.org/ns/TYPO3/Fluid/ViewHelpers file:/home/florian/Documents/Docs/Netbeans/Autocomplete%20Fluid/Schemas/Fluid.xsd
http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers file:/home/florian/Documents/Docs/Netbeans/Autocomplete%20Fluid/Schemas/Vhs.xsd
http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers file:/home/florian/Documents/Docs/Netbeans/Autocomplete%20Fluid/Schemas/Flux.xsd'>
Auto-completion here
</f:alias>
http://netbeans-org.1045718.n5.nabble.com/Schemas-for-code-completion-with-xsd-tt5752294.html#none
take files from https://fluidtypo3.org/schemas/
Some more info Use Netbeans to Create Sample XML from XSD
From a project that contains the .xsd:
Click New File on the tool bar or File > New File from the menu
Choose XML > XML Document
Name your file, click next
Choose XML Schema-Constrained Document, click next
Click the Browse button and use By File to navigate to the .xsd
Click the Import check box beside the file name, click next
Review the options available and click Finish to generate
You can use more than one .xsd file to generate the .xml. In this case it will use whichever .xsd file you choose as Primary to resolve any conflicts.

Apply code format style to large Java project in Eclipse

Recently I did something wrong and it ruined my project's code style format, my eyes bleed with the new code style format and I neither can read or edit my code. I fixed the project settings by restoring to default, but pre-formatted code resits the new Eclipse Format and I have to fix every Java file one by one by hand...
This is how all my sources look like after the mistake
dropDat.setItemId(Integer
.parseInt(attrs
.getNamedItem(
"itemid")
.getNodeValue()));
dropDat.setMinDrop(Integer
.parseInt(attrs
.getNamedItem(
"min")
.getNodeValue()));
dropDat.setMaxDrop(Integer
.parseInt(attrs
.getNamedItem(
"max")
.getNodeValue()));
dropDat.setChance(Integer
.parseInt(attrs
.getNamedItem(
"chance")
.getNodeValue()));
The same code should look like:
dropDat.setItemId(Integer.parseInt(attrs.getNamedItem("itemid").getNodeValue()));
...
dropDat.setItemId(Integer.parseInt(attrs.getNamedItem("chance").getNodeValue()));
My whole project is destroyed (30.000+ Java files) into this annoying coding style... What should I do to automatically fix it?
Create a formatter profile here Windows > Preferences > Java > Code Style > Formatter.
Then in package explorer view right click on project then select Source > Format.
You can also create your source clean up profile here Windows > Preferences > Java > Code Style > Clean Up
Then in package explorer view right click on project then select Source > Clean up.
You have to repeat it for all projects.
If you have many many projects then try this solution

Eclipse RCP: programmatically associate file type with Editor?

How programmatically associate file type with Editor?
That is what Eclipse-RCP Java code can do what is archived with the following UI interaction:
Window -> Preferences
General -> Editors -> File Associations
Add... > File type: *.json
Select *.json file type
Add... (Associated editors) > JavaScript Editor
Make it default
Ralated to Q
https://stackoverflow.com/questions/12429221/eclipse-file-associations-determine-which-editor-in-list-of-associated-editors
Eclipse: associate an editor with a content type
Get associated file extensions for an Eclipse editor
Opening a default editor, on a treeviewer selection eclipse rcp(eg: as eclipse knows that j.java files must be opened in text editor)
eclipse rcp change icon for xml configuration file
I know your questions says "programmatically" but I'll give a complete run down of the methods.
If you are writing the plugin that provides the editor, then you should simply declare the extension in your plugin.xml.
<extension
point="org.eclipse.ui.editors">
<editor
...
extensions="json"
...
If you are distributing a complete RPC application, you can edit the plugin.xml for the plugin that provides the editor or add a plugin that just refers to that editor.
But, if you have to do it programmatically, you are manipulating the internals of an RPC instance. Eclipse does not provide a public API for that but this code will do it:
// error handling is omitted for brevity
String extension = "json";
String editorId = "theplugin.editors.TheEditor";
EditorRegistry editorReg = (EditorRegistry)PlatformUI.getWorkbench().getEditorRegistry();
EditorDescriptor editor = (EditorDescriptor) editorReg.findEditor(editorId);
FileEditorMapping mapping = new FileEditorMapping(extension);
mapping.addEditor(editor);
mapping.setDefaultEditor(editor);
IFileEditorMapping[] mappings = editorReg.getFileEditorMappings();
FileEditorMapping[] newMappings = new FileEditorMapping[mappings.length+1];
for (int i = 0; i < mappings.length; i++) {
newMappings[i] = (FileEditorMapping) mappings[i];
}
newMappings[mappings.length] = mapping;
editorReg.setFileEditorMappings(newMappings);
Associating file type means associating content of ur editor with a predefined one.
This can be easily achieved via plugin.xml..
Just follow the following link:-
Eclipse help Documentation
http://help.eclipse.org/indigo/index.jsp
and search for org.eclipse.core.contenttype.contentTypes.

Customize T4 Scaffolding With PowerShell

I want to create a Custom Scaffolder that uses arbitrary PowerShell logic. It can render T4 templates (multiple ones if I want), with the result being output:
As a new file in your project
as a new code block inserted into an existing class
my PowerShell logic can use Visual Studio’s “code model” API to manipulate files and code elements in other arbitrary ways.
How to Customize T4 Scaffolding With PowerShell?
From http://blog.stevensanderson.com/2011/04/07/mvcscaffolding-creating-custom-scaffolders/:
In Package Manager Console of Visual Studio execute the following
command :
Scaffold CustomScaffolder ClassName
This adds a CodeTemplates folder to your project, containing files for
the new scaffolder.
As you can see, we’ve got two files:
A PowerShell script (.ps1), where we can put arbitrary logic to decide what templates get rendered and where the output goes. By
default, it renders a T4 template and uses the output to create a new
file called ExampleOutput in the root of your project.
A T4 template (.t4), i.e., the thing that the default .ps1 file renders. By default this generates a simple C#/VB class (depending on
your project type). If you want to see this working, you can run the
custom scaffolder right away:
Scaffold ClassName
This will generate a new class file, ExampleOutput.cs, in the root
folder of your project. That’s really just to show you how it works.
We don’t really want that, so don’t run the new scaffolder yet, or if
you already have done, delete ExampleOutput.cs

How to add content control in a Word 2007 document using OpenXML

I want to create a word 2007 document without using object model. So I would prefer to create it using open xml format. So far I have been able to create the document. Now I want to add a content control in it and map it to xml. Can anybody guide me regarding the same???
Anoop,
You said that you are able to creat the document using OpenXmlSdk. With that assumption, you can use the following code to create the content control to add to the Wordprocessing.Body element of your Document.
//praragraph to be added to the rich text content control
Run run = new Run(new Text("Insert any text Here") { Space = StaticTextConstants.Preserve });
Paragraph paragraph = new Paragraph(run);
SdtProperties sdtPr = new SdtProperties(
new Alias { Val = "MyContentCotrol" },
new Tag { Val = "_myContentControl" });
SdtContentBlock sdtCBlock = new SdtContentBlock(paragraph);
SdtBlock sdtBlock = new SdtBlock(sdtPr, sdtCBlock);
//add this content control to the body of the word document
WordprocessingDocument wDoc = WordprocessingDocument.Open(path, true); //path is where your word 2007 file is
Body mBody = wDoc.MainDocumentPart.Document.Body;
mBody.AppendChild(sdtBlock);
wDoc.MainDocumentPart.Document.Save();
wDoc.Dispose();
I hope this answers a part of your question. I did not understand what you ment by "Map it to XML". Did you mean to say you want to create CustomXmlBlock and add the ContentControl to it?
Have a look for the Word Content Control Toolkit on www.codeplex.com.
Here is a very brief explanation on how to do what you are attempting.
You need to have access to the developer tab on the Word ribbon. To get this working click on the Office (Round thingy) in the top left hand corner and Select Word Options at the bottom of the menu. On the first options page there is a checkbox to show the developer toolbar.
Use the developer toolbar to add the Content controls you want on the page. Click the properties button in the Content controls section of the developer bar and set the name and tag properties (I stick to naming the name and tag fields with the same name).
Save and close the word document.
Open the Content control toolkit and then open your document with the toolkit. Use the left hand pain to create some custom xml to link to your controls.
Now use the bind view to drag and drop the mappings between your custom xml and the custom controls that are displayed in the right panel of the toolkit.
You can use the openxml sdk 1.0 or 2.0 (still in ctp) to open your word document in code and access the custom xml file that is contained as part of the word document.
If you want to have a look at how your word document looks as xml. Make a copy of your word document and then rename it to say "a.zip". Double click on the zip file and then navigate the folder structure. The main content of the word document is held under the word folder in a file called "document.xml". The custom xml part of the document is held under the customXml folder and is generally found in the file named "item1.xml".
I hope this brief explanation get you up and running.