Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Which renderer renders the MinMax buttons for the Part Stack?(Which renderer renders the MinMax buttons for the Part Stack?)
Which renderer renders the MinMax buttons for the Part Stack? [message #965938] Wed, 31 October 2012 16:20 Go to next message
Alex Kipling is currently offline Alex KiplingFriend
Messages: 257
Registered: July 2012
Senior Member
I am trying to find out which renderer renders the MinMax buttons on the Part-Stack.
I will try to hide this Buttons in a pure e4 Application, where no MinMax Addon is present.

I thougth it would be the org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer but did not find any code, responsible for Min/Max Buttons.

Which renderer is responsible for rendering the Part-Stack?
Re: Which renderer renders the MinMax buttons for the Part Stack? [message #966097 is a reply to message #965938] Wed, 31 October 2012 18:59 Go to previous messageGo to next message
Rushan Gilmullin is currently offline Rushan GilmullinFriend
Messages: 61
Registered: June 2011
Member
>>Which renderer is responsible for rendering the Part-Stack?

StackRenderer. But setting the minmax buttons is doing in MinMaxAddon. See this two methods: adjustCTFButtons, setCTFButtons bellow. The adjustCTFButtons is called from widget event handler which handle setWidget() event for tab folder in StackRenderer.createWidget() method. The adjustCTFButton call setCTFButtons and tune buttons as bellow:

/**
	 * Set the state of the min / max buttons on the CTF based on the model element's state. The
	 * input is expected to be the element that contains the min/max state info which should either
	 * be an MPartStack or an MPlaceholder for the shared area.
	 * 
	 * @param element
	 *            The element to test
	 */
	private void adjustCTFButtons(MUIElement element) {
		if (!(element instanceof MPartStack) && !(element instanceof MPlaceholder))
			return;

		CTabFolder ctf = getCTFFor(element);
		if (ctf == null)
			return;

		if (element instanceof MPlaceholder) {
			setCTFButtons(ctf, element, false);
		} else {
			MArea area = getAreaFor((MPartStack) element);
			if (area == null) {
				setCTFButtons(ctf, element, false);
			}
		}
	}

private void setCTFButtons(CTabFolder ctf, MUIElement stateElement, boolean hideButtons) {
		if (hideButtons) {
			ctf.setMinimizeVisible(false);
			ctf.setMaximizeVisible(false);
		} else {
			if (stateElement.getTags().contains(MINIMIZED)) {
				ctf.setMinimizeVisible(false);
				ctf.setMaximizeVisible(true);
				ctf.setMaximized(true);
			} else if (stateElement.getTags().contains(MAXIMIZED)) {
				ctf.setMinimizeVisible(true);
				ctf.setMaximizeVisible(true);
				ctf.setMaximized(true);
			} else {
				ctf.setMinimizeVisible(true);
				ctf.setMaximizeVisible(true);
				ctf.setMinimized(false);
				ctf.setMaximized(false);
				ctf.layout();
			}
		}
	}


As we can see the buttons is enabled in setCTFButtons method by calling setMinimizeVisible and setMaximizeVisible in tabfolder object. What you can do to disable this buttons? Forexample you can add widget listener and disable this buttons in same way as above. Just copy widgetListener from MinMaxAddon and register it as in hookListeners method of this class. As well as the minmax addon is not presented in your application, your code that tuning buttons will be unique and all will be ok.
Re: Which renderer renders the MinMax buttons for the Part Stack? [message #968523 is a reply to message #966097] Fri, 02 November 2012 14:25 Go to previous message
Alex Kipling is currently offline Alex KiplingFriend
Messages: 257
Registered: July 2012
Senior Member
Thnx for help!
i did it this way: I introduced an own renderer, which on default disables the MinMax Buttons.

public class StackRendererIvu extends StackRenderer {

    /**
     * The Application model tag, which displays min/max Buttons in the right/upper corner of the
     * CTabFolder.
     */
    private static final String WINDOWTAG_MINMAX = "minmax";

    private static final Logger LOG = LoggerFactory.getLogger(StackRendererIvu.class);

    @Override
    public Object createWidget(MUIElement element, Object parent) {

        Object o = super.createWidget(element, parent);

        // the super class, which is the native renderer - renders a CTabFolder for the MPartStack
        try {

            MPartStack stack = (MPartStack) element;
            CTabFolder ctf = (CTabFolder) o;

            if (!stack.getTags().contains(WINDOWTAG_MINMAX)) {
                ctf.setMinimizeVisible(false);
                ctf.setMaximizeVisible(false);
            }

        } catch (Exception e) {
            LOG.warn("Failed to cast the Widget, which was rendered for a MPartStack to a CTabFolder");
        }
        return o;
    }
}


This renderer I registerd as describe in Lar's tutorial, here:
http://www.vogella.com/articles/EclipseRCP/article.html#context_who

Previous Topic:Tooltip black background with no text
Next Topic:Eclipse RCP update from indigo-SR2 to juno-SR1
Goto Forum:
  


Current Time: Mon Nov 24 08:37:21 GMT 2014

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

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