blob: f677d897833dbd93d289ca496346adc16c4e8fbe [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2013 Oracle.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Oracle - initial API and implementation
*******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal.handlers;
import java.util.Iterator;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.ui.handlers.HandlerUtil;
public class RemovePersistentClassHandler extends AbstractHandler
{
@SuppressWarnings("unchecked")
public Object execute(ExecutionEvent executionEvent) throws ExecutionException {
IStructuredSelection selection =
(IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(executionEvent);
// only applies for multiply selected OrmPersistentType objects in a tree
for (Iterator<OrmPersistentType> stream = selection.iterator(); stream.hasNext(); ) {
OrmPersistentType persistentType = stream.next();
((EntityMappings) persistentType.getMappingFileRoot()).removeManagedType(persistentType);
}
return null;
}
}