blob: ed401f84a3701e2f2f80c0b934ac42db54728700 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.ui.internal.presentations;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.internal.WorkbenchMessages;
import org.eclipse.ui.presentations.IPresentablePart;
import org.eclipse.ui.presentations.IStackPresentationSite;
/**
* This convenience class provides a "close" system menu item that closes
* the currently selected pane in a presentation. Presentations can use
* this to add a close item to their system menu.
*
* @since 3.0
*/
public final class SystemMenuClose extends Action implements ISelfUpdatingAction {
private IStackPresentationSite site;
public SystemMenuClose(IStackPresentationSite site) {
this.site = site;
setText(WorkbenchMessages.getString("PartPane.close")); //$NON-NLS-1$
}
public void dispose() {
site = null;
}
public void run() {
IPresentablePart part = site.getSelectedPart();
if (part != null) {
site.close(new IPresentablePart[]{part});
}
}
public void update() {
IPresentablePart presentablePart = site.getSelectedPart();
setEnabled(presentablePart != null && site.isCloseable(presentablePart));
}
public boolean shouldBeVisible() {
return true;
}
}