I've just started playing with Eclipse RCP.
A few things that I would like to accomplish:
How do I maximize the initial size of the application?
I would like to create a sidebar type view on my left and would like to fix the size of that view and remove any title bar, minimize/ maximize/ close from that side-bar.
Can anyone help me please?
Thank you.
First, some tutorials like Vogella's are a must read ;)
RCP Tutorial
JFace Tutorial
For 1/, this has to do with the IWorkbenchWindowConfigurer, like:
configurer.getWindow().getShell().setMaximized( true );
on postWindowOpen( IWorkbenchWindowConfigurer configurer ) of your WorkbenchAdvisor.
This thread has other alternatives.
For 2/, you can do it declaratively or by program, like this thread shows:
You can do it in plugin.xml, by providing extension to point org.eclipse.ui.perspectiveExtensions by specifying showTitle="false" on the view element.
or You can do it programmatically in Your PerspectiveFactory implementation:
public void createInitialLayout(IPageLayout layout) {
...
layout.addStandaloneView(View.ID, false,
IPageLayout.LEFT, 1.0f, editorArea);
...
}
Sidebar can be create via using viewpart and adjust in perspective using IPerspective in right or left side and given window size.
Related
I am creating a RCP in Eclipse Indigo 3.7. I want an editor-view link just like Adobe Flash Builder Design editor and view properties field i.e on opening an editor, its related view should also open without changing perspective and on closing editor, view should dispose.
I tried placing placeholders for views in editor but had no luck.
Also tried adding listener to view part but didn't got satisfactory response.
Please help me with your response.
A code snippet will also be helpful..
Thank you in advance.
I have not tested this, but...
In createPartControl(...) you should call IWorkbenchPage.showView(String viewId, String secondaryId, int mode) and in dispose() you should call IWorkbenchPage.hideView(IViewPart view). The later viewPart is the return value from showView(...).
I'm new to RCP and I'm trying to create a new View or Editor. At the current state I'm extending ViewPart.
The Layout I want to achieve is a SashForm where both sides have a CTabFolder. One of the sides of the SashForm is basically a MultiPageEditorPart. One of it's tabs should be an editor for a specific language with syntax highlighting and similar features. From what I understand I could extend AbstractTextEditor for that (and maybe use it as one tab of a MultiPageEditorPart).
If I try to achieve this layout with a ViewPart as top level container which contains a SashForm, I can't add an EditorPart to one of the sides of the SashForm. Of course I could implement this editor from scratch as Composite but I want to avoid that.
I am also willing to use an EditorPart or MultiPageEditorPart as top level container but then I'd have to find a way to get the SashForm layout working. The whole editor should be splited first and then each side should have tabs.
Does anyone have an idea how to solve this?
If anything is unclear please ask. I've got the feeling I've put this into words a little complicatedly.
I think you should just make a ViewPart that has a text editing component of some kind on the left, instead of trying to find a way to use an EditorPart. All that EditorPart is really buying you is dirty flag management and Save support; syntax highlight and so forth you can add to the text editing component yourself (I was surprised at how few drop-in text components I found while poking around the internet just now; I expected to find "a few" and instead I found "basically none").
You can see one way to do very rudimentary syntax highlighting with a StyledText component here: JavaSourceCodeViewer
To see a more robust implementation of things like syntax highlight and autocomplete, take a look at the class that Eclipse uses for the editing of Java source code: CompilationUnitEditor
I think what you are trying to achieve is quite complicated and might require a lot of extra work. See an editor is not just different controls laid out in some order, but it has a lot of additional features that any editor class expects to work. These include things like selection service and action bars etc, that you will need to hook in to ensure smooth running.
That said, it should be possible to achieve what you are hoping for. You can have a look at the source code of the MultiPageEditorPart itself to see how it converts a single editor into a multi page editor, which is capable of hosting a completely independent editor on each of its pages. You would need to achieve something similar if you want your editor to host two MultiPageEditorParts separated by a sash. If you want to carry on, you should start implementing some stuff and if you run into any problems, post them here. You would be able to get a lot better help then.
You need something like MultiPageEditorSite. Use it for inspiration when implementing an EditorSiteDelegate. MultiPageEditorSite has support for separate keybindings between the pages, for example.
class ChildEditorSite implements IEditorSite {
IEditorSite parent;
public Object method() {
return parent.method();
}
}
Using this class, you can easily do the following in your main EditorPart:
class MyCoolPart extends EditorPart {
public void createControl(Composite parent) {
EditorPart child1 = new MyChild();
child1.init(new ChildEditorSite(getEditorSite()), myInput);
EditorPart child2 = new MyChild();
child2.init(new ChildEditorSite(getEditorSite()), myInput);
child1.createPartControl(parent);
child2.createPartControl(parent);
}
}
Be sure to also dispose of your children correctly when you dispose of your MyCoolPart. Please note that this only works in the most basic of cases. An EditorPart that is a DocumentEditor or that relies on IPersistablePart or implements listeners/adapters for confirming a save is probably going to require a lot more Lifecycle management...
Using Eclipse RCP to build an application. I would like the toolbar to be vertical and on the left hand side of the window. So far I managed to make it vertical in the ApplicationActionBarAdvisor.
#Override
protected void fillCoolBar(ICoolBarManager coolBar) {
ToolBarManager toolbar = new ToolBarManager(coolBar.getStyle()
| SWT.HORIZONTAL);
coolBar.add(toolbar);
}
However, it is still on top of the editors and view. I cannot find any way to move it to the left. Does anybody know if it is possible at all and how to do that?
Thanks,
Martin
You can use the extension point o.e.ui.menu, and use the locationURIs "toolbar:org.eclipse.ui.trim.vertical1" for left trim and "toolbar:org.eclipse.ui.trim.vertical2" for the right trim. You can your tool items there.
Also see the contribution examples plugin for more samples: http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.ui.examples.contributions/
HI,
I am facing some problem.. I want to hide the menu when eclipse workbench starts.
But the problem is menu is not hiding when the eclipse workbench starts. It is hiding only
when some refresh is happened. for example: when I change the default perspective to some other perspective, I am getting the desired out put. That means menu is hiding.
But when the eclipse workbench is loaded it is not hiding the menu. Below is my code.
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
public void run() {
try {
IWorkbenchWindow window = Workbench.getInstance().getActiveWorkbenchWindow()
if(window instanceof WorkbenchWindow) {
MenuManager menuManager = ((WorkbenchWindow)window).getMenuManager();
IContributionItem[] items = menuManager.getItems();
for(IContributionItem item:items){
System.out.println("item.getId()::: "+item.getId());
menuManager.remove("org.eclipse.ui.run");
menuManager.remove("help");
menuManager.remove("project");
}
}
}`
}
};
Given that you are looking to hide some features, I don't think that this is the best approach. (Not I am using the term feature here in the colloquial way, not as an Eclipse feature.
I would recommend one of two avenues:
Perspectives: See the extension point org.eclipse.ui.perspectives. This allows you to create a new perspective like the debug perspective or the Java perspective. Using a perspective, you can select exactly what menu items and views are shown and which ones are hidden.
Capabilities (aka activites): See the extension point org.eclipse.ui.activities. This allows you to have some fairly fine-grained control over what features are available in the workspace. See more info here: http://wiki.eclipse.org/Galileo_Capabilities
Put Your code in org.eclipse.ui.startup extention point. Make a Startup class after implementing the interface IStartup. For Details follow this link:-
Eclipse plugin : disable/enable dynamically an action from main menubar
I don't know RCP very well yet, but I've been reading a lot of the docs. I don't know if my question makes sense; I apologize if not and beg that you try to work out what I mean and come up with some kind of answer.
I have a tree view element, which has a double click listener on it. In another part of the window there is a layout folder which contains views that are supposed to be inspectors for the items double-clicked on.
The only way I know to make another inspector appear is:
getActivePage().showView(Inspector.ID).
showView() doesn't give any opportunity to pass extra information to the view, so can it know which element to inspect?
Pointers in different directions appreciated. The Vogel tutorial doesn't seem to cover this, or I don't understand it.
You could check if the article "Link to Editor" can help you here.
That is, instead of trying to access the right view, define a Listener for the Editors:
private IPartListener2 partListener2 = new IPartListener2() {
public void partActivated(IWorkbenchPartReference ref) {
if (ref.getPart(true) instanceof IEditorPart)
editorActivated(getViewSite().getPage().getActiveEditor());
}
That way, you can get back the right Editor, and ask that Editor all you need for your View to update accordingly.
You can use the SelectionService. The Inspector view should register as a SelectionListener. And the other view with the tree should register a SelectionProvider. This view should listen for the double click in the tree and then update the selection