diff options
Diffstat (limited to 'bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyElementAction.java')
-rw-r--r-- | bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyElementAction.java | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyElementAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyElementAction.java deleted file mode 100644 index 56e41d8a4c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyElementAction.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2006 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.wst.xsd.ui.internal.common.actions; - -import java.util.Iterator; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAnyElementCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDWildcard; - -public class AddXSDAnyElementAction extends XSDBaseAction -{ - public static String ID = "org.eclipse.wst.xsd.ui.AddXSDAnyElementAction"; //$NON-NLS-1$ - - public AddXSDAnyElementAction(IWorkbenchPart part) - { - super(part); - setText(Messages._UI_ACTION_ADD_ANY_ELEMENT); - setId(ID); - } - - public void run() - { - XSDModelGroup modelGroup = getModelGroup(); - if (modelGroup != null) - { - AddXSDAnyElementCommand command = new AddXSDAnyElementCommand(getText(), modelGroup); - getCommandStack().execute(command); - } - } - - private XSDModelGroup getModelGroup() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - if (selection instanceof XSDModelGroup) - { - return (XSDModelGroup) selection; - } - return null; - } - - protected boolean calculateEnabled() - { - boolean rc = super.calculateEnabled(); - if (rc) - { - XSDModelGroup modelGroup = getModelGroup(); - if (modelGroup != null) - { - boolean hasAnyElement = false; - for (Iterator i = modelGroup.getContents().iterator(); i.hasNext();) - { - XSDParticle obj = (XSDParticle) i.next(); - if (obj.getContent() instanceof XSDWildcard) - { - hasAnyElement = true; - break; - } - } - return !hasAnyElement; - } - } - return rc; - } - -} |