blob: 3380d4f44797349fdc9e25feaa0a984be17f9893 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Istvan Rath and Daniel Varro
* 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:
* Istvan Rath - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.frameworkgui.actions;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.viatra2.frameworkgui.content.FrameworkContainer;
import org.eclipse.viatra2.frameworkgui.views.FrameworkTreeView;
public class DisposeFrameworkAction extends AbstractFrameworkGUIAction {
private boolean isEnabled = true;
public DisposeFrameworkAction(FrameworkTreeView part) {
super();
setupInternals(part);
setText("Dispose framework");
setToolTipText("Dispose a framework; CAUTION: do not dispose of frameworks which are currently in use by an editor!");
setImageDescriptor(PlatformUI.getWorkbench().getSharedImages()
.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
}
public void run() {
ISelection sel = iFT.getSelection();
if (sel instanceof IStructuredSelection) {
Object o = ((IStructuredSelection) sel).getFirstElement();
if (o instanceof FrameworkContainer)
{
iViatraFramework = ((FrameworkContainer)o).getFramework();
try {
iFT.getFrameWorkManager().disposeFramework(
iViatraFramework.getId());
iFT.refreshViewer(null);
} catch (Exception e) {
iFT.showMessage(e.getMessage());
}
}
}
}
public boolean isEnabled() {
return isEnabled;
}
public void calculateEnabled() {
ISelection sel = iFT.getSelection();
if (sel instanceof IStructuredSelection) {
Object o = ((IStructuredSelection) sel).getFirstElement();
isEnabled = (o instanceof FrameworkContainer);
} else
isEnabled = false;
this.setEnabled(isEnabled);
iFT.updateLocalToolBar();
}
}