| /***************************************************************** |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * https://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| ****************************************************************/ |
| package org.apache.cayenne.modeler.action; |
| |
| import org.apache.cayenne.configuration.ConfigurationNode; |
| import org.apache.cayenne.modeler.Application; |
| import org.apache.cayenne.modeler.ProjectController; |
| import org.apache.cayenne.modeler.editor.ObjEntityAttributePanel; |
| import org.apache.cayenne.modeler.editor.dbentity.DbEntityAttributePanel; |
| import javax.swing.JComponent; |
| |
| public class CopyAttributeRelationshipAction extends CopyAction implements MultipleObjectsAction { |
| |
| private CopyAttributeAction copyAttributeAction; |
| private CopyRelationshipAction copyRelationshipAction; |
| private JComponent currentSelectedPanel; |
| |
| protected CopyAttributeRelationshipAction(Application application) { |
| super(application); |
| copyAttributeAction = new CopyAttributeAction(application); |
| copyRelationshipAction = new CopyRelationshipAction(application); |
| } |
| |
| public JComponent getCurrentSelectedPanel() { |
| return currentSelectedPanel; |
| } |
| |
| public void setCurrentSelectedPanel(JComponent currentSelectedPanel) { |
| this.currentSelectedPanel = currentSelectedPanel; |
| } |
| |
| public String getActionName(boolean multiple) { |
| if (currentSelectedPanel instanceof ObjEntityAttributePanel || currentSelectedPanel instanceof DbEntityAttributePanel) { |
| return copyAttributeAction.getActionName(multiple); |
| } else { |
| return copyRelationshipAction.getActionName(multiple); |
| } |
| } |
| |
| public boolean enableForPath(ConfigurationNode object) { |
| if (currentSelectedPanel instanceof ObjEntityAttributePanel || currentSelectedPanel instanceof DbEntityAttributePanel) { |
| return copyAttributeAction.enableForPath(object); |
| } else { |
| return copyRelationshipAction.enableForPath(object); |
| } |
| } |
| |
| public Object copy(ProjectController mediator) { |
| if (currentSelectedPanel instanceof ObjEntityAttributePanel || currentSelectedPanel instanceof DbEntityAttributePanel) { |
| return copyAttributeAction.copy(mediator); |
| } else { |
| return copyRelationshipAction.copy(mediator); |
| } |
| } |
| |
| } |