blob: 9afcb404eb4ff6a88a0bf39ab7f43b62def96d00 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008, 2017 xored software, Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* xored software, Inc. - initial API and Implementation (Alex Panchenko)
*******************************************************************************/
package org.eclipse.dltk.internal.ui.typehierarchy;
import org.eclipse.dltk.core.ModelException;
import org.eclipse.dltk.ui.actions.OpenAction;
import org.eclipse.ui.IWorkbenchSite;
public class HierarchyOpenAction extends OpenAction {
/**
* @param site
*/
public HierarchyOpenAction(IWorkbenchSite site) {
super(site);
}
@Override
protected boolean checkElement(Object element) {
return element instanceof CumulativeType
|| element instanceof CumulativeType.Part
|| super.checkElement(element);
}
@Override
public void run(Object[] elements) {
if (elements.length == 1 && elements[0] instanceof CumulativeType) {
selectAndOpen(((CumulativeType) elements[0]).getTypes());
} else {
super.run(elements);
}
}
@Override
public Object getElementToOpen(Object object) throws ModelException {
if (object instanceof CumulativeType.Part) {
return ((CumulativeType.Part) object).type;
}
return super.getElementToOpen(object);
}
}