All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.jface.action.SubContributionItem Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2000, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jface.action;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.ToolBar;

/**
 * A SubContributionItem is a wrapper for an IContributionItem.  
 * It is used within a SubContributionManager to control the visibility
 * of items.
 * 

* This class is not intended to be subclassed. *

* @noextend This class is not intended to be subclassed by clients. */ public class SubContributionItem implements IContributionItem { /** * The visibility of the item. */ private boolean visible; /** * The inner item for this contribution. */ private IContributionItem innerItem; /** * Creates a new SubContributionItem. * @param item the contribution item to be wrapped */ public SubContributionItem(IContributionItem item) { innerItem = item; } /** * The default implementation of this IContributionItem * delegates to the inner item. Subclasses may override. */ @Override public void dispose() { innerItem.dispose(); } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public void fill(Composite parent) { if (visible) { innerItem.fill(parent); } } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public void fill(Menu parent, int index) { if (visible) { innerItem.fill(parent, index); } } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public void fill(ToolBar parent, int index) { if (visible) { innerItem.fill(parent, index); } } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public String getId() { return innerItem.getId(); } /** * Returns the inner contribution item. * * @return the inner contribution item */ public IContributionItem getInnerItem() { return innerItem; } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public boolean isEnabled() { return innerItem.isEnabled(); } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public boolean isDirty() { return innerItem.isDirty(); } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public boolean isDynamic() { return innerItem.isDynamic(); } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public boolean isGroupMarker() { return innerItem.isGroupMarker(); } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public boolean isSeparator() { return innerItem.isSeparator(); } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public boolean isVisible() { return visible && innerItem.isVisible(); } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public void setParent(IContributionManager parent) { // do nothing, the parent of our inner item // is its SubContributionManager } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public void setVisible(boolean visible) { this.visible = visible; } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public void update() { innerItem.update(); } /* (non-Javadoc) * Method declared on IContributionItem. */ @Override public void update(String id) { innerItem.update(id); } /* (non-Javadoc) * @see org.eclipse.jface.action.IContributionItem#fill(org.eclipse.swt.widgets.CoolBar, int) */ @Override public void fill(CoolBar parent, int index) { if (visible) { innerItem.fill(parent, index); } } /* (non-Javadoc) * @see org.eclipse.jface.action.IContributionItem#saveWidgetState() */ @Override public void saveWidgetState() { } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy