Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » EditorPart and close button
EditorPart and close button [message #449461] Mon, 24 January 2005 21:48 Go to next message
Eclipse UserFriend
Originally posted by: wiz.vball.net

Hi,
I know for Views you can do the following
getViewLayout( PrioritiesView.ID_VIEW).setCloseable( false );

which gets rid of the close button for the view and the tab simply
shows name and icon... can this be applied to EditorPart... so i could
open an editor part and display its name and icon but not close button
so it can not be closed.

thanks,
Parwiz
Re: EditorPart and close button [message #449478 is a reply to message #449461] Tue, 25 January 2005 12:48 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
This is a UI workbench question. You should probably ask on the
eclipse.platform newsgroup:

news://news.eclipse.org/eclipse.platform

"FireFly" <wiz@vball.net> wrote in message
news:46rav0hglpesip8ifblf2fab8oocg7742n@4ax.com...
> Hi,
> I know for Views you can do the following
> getViewLayout( PrioritiesView.ID_VIEW).setCloseable( false );
>
> which gets rid of the close button for the view and the tab simply
> shows name and icon... can this be applied to EditorPart... so i could
> open an editor part and display its name and icon but not close button
> so it can not be closed.
>
> thanks,
> Parwiz
Re: EditorPart and close button [message #449537 is a reply to message #449461] Tue, 25 January 2005 23:15 Go to previous message
Eclipse UserFriend
Originally posted by: barry.rapidmoney.com

FireFly wrote:

> Hi,
> I know for Views you can do the following
> getViewLayout( PrioritiesView.ID_VIEW).setCloseable( false );

> which gets rid of the close button for the view and the tab simply
> shows name and icon... can this be applied to EditorPart... so i could
> open an editor part and display its name and icon but not close button
> so it can not be closed.

> thanks,
> Parwiz


You can do it, but it's painful (at least the way I did it.) It basically
comes down to plugging in your own custom PresentationFactory. The way I
did it was in 4 steps:

1. Add an extension in your plugin.xml that looks like the following:

<extension
point="org.eclipse.ui.presentationFactories">
<factory
class="com.my.MySpecialPresentationFactory"
name="My Special Presentation"
id="my.SpecialPresentation"/>
</extension>


2. Write your PresentationFactory class, which subclasses the default
"WorkbenchPresentationFactory". You only need to override one method,
which is called "createEditorPresentation(...)" What I did was to copy
the source from the original method, and replace the first few lines with
the following...

public class MySpecialPresentationFactory extends
WorkbenchPresentationFactory {

public StackPresentation createEditorPresentation(Composite parent,
IStackPresentationSite site) {
DefaultTabFolder folder = new MySpecialTabFolder(parent, SWT.BORDER,
site.supportsState(IStackPresentationSite.STATE_MINIMIZED),
site.supportsState(IStackPresentationSite.STATE_MAXIMIZED));

... rest of method remains unchanged ...


3. Create your MySpecialTabFolder class as follows:

public class MySpecialTabFolder extends DefaultTabFolder {

public MySpecialTabFolder(Composite parent, int flags, boolean allowMin,
boolean allowMax) {
super(parent, flags, allowMin, allowMax);
}

public AbstractTabItem add(int index, int flags) {
// in our "special" editor tabs don't want "close" controls, so
// we remove them here
return super.add(index, flags ^ SWT.CLOSE);
}

}

4. Register your presentation factory. In your WorkbenchAdvisor class,
add the following line. (I added it in the preWindowOpen() method)

configurer.setPresentationFactory(new MySpecialPresentationFactory());


So, basically, this "special" tab folder removes the "CLOSE" bit from the
style flag, and you end up with a editor tab that cannot be closed by the
user.

Yes, a lot of steps, but it does work nicely.

Let me know if you have any more questions about this.
Previous Topic:SWT Rotated text
Next Topic:"scroll out" composite
Goto Forum:
  


Current Time: Fri Apr 19 13:30:21 GMT 2024

Powered by FUDForum. Page generated in 0.01880 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top