View Javadoc
1   /**
2    * 
3    * Copyright (c) 2013-2014, Openflexo
4    * Copyright (c) 2011-2012, AgileBirds
5    * 
6    * This file is part of Gina-swing-editor, a component of the software infrastructure 
7    * developed at Openflexo.
8    * 
9    * 
10   * Openflexo is dual-licensed under the European Union Public License (EUPL, either 
11   * version 1.1 of the License, or any later version ), which is available at 
12   * https://joinup.ec.europa.eu/software/page/eupl/licence-eupl
13   * and the GNU General Public License (GPL, either version 3 of the License, or any 
14   * later version), which is available at http://www.gnu.org/licenses/gpl.html .
15   * 
16   * You can redistribute it and/or modify under the terms of either of these licenses
17   * 
18   * If you choose to redistribute it and/or modify under the terms of the GNU GPL, you
19   * must include the following additional permission.
20   *
21   *          Additional permission under GNU GPL version 3 section 7
22   *
23   *          If you modify this Program, or any covered work, by linking or 
24   *          combining it with software containing parts covered by the terms 
25   *          of EPL 1.0, the licensors of this Program grant you additional permission
26   *          to convey the resulting work. * 
27   * 
28   * This software is distributed in the hope that it will be useful, but WITHOUT ANY 
29   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
30   * PARTICULAR PURPOSE. 
31   *
32   * See http://www.openflexo.org/license.html for details.
33   * 
34   * 
35   * Please contact Openflexo (openflexo-contacts@openflexo.org)
36   * or visit www.openflexo.org if you need additional information.
37   * 
38   */
39  
40  package org.openflexo.gina.swing.editor.view.widget;
41  
42  import java.util.logging.Logger;
43  
44  import javax.swing.JComponent;
45  
46  import org.openflexo.gina.model.widget.FIBCustom;
47  import org.openflexo.gina.model.widget.FIBCustom.FIBCustomComponent;
48  import org.openflexo.gina.swing.editor.controller.FIBEditorController;
49  import org.openflexo.gina.swing.editor.view.FIBSwingEditableView;
50  import org.openflexo.gina.swing.editor.view.FIBSwingEditableViewDelegate;
51  import org.openflexo.gina.swing.view.widget.JFIBCustomWidget;
52  import org.openflexo.gina.swing.view.widget.JFIBCustomWidget.JCustomComponentPanel;
53  import org.openflexo.logging.FlexoLogger;
54  
55  public class JFIBEditableCustomWidget<CC extends JComponent & FIBCustomComponent<T>, T> extends JFIBCustomWidget<CC, T>
56  		implements FIBSwingEditableView<FIBCustom, JCustomComponentPanel<CC, T>> {
57  
58  	@SuppressWarnings("unused")
59  	private static final Logger logger = FlexoLogger.getLogger(JFIBEditableCustomWidget.class.getPackage().getName());
60  
61  	private final FIBSwingEditableViewDelegate<FIBCustom, JCustomComponentPanel<CC, T>> delegate;
62  
63  	private final FIBEditorController editorController;
64  
65  	@Override
66  	public JComponent getDraggableComponent() {
67  		return getTechnologyComponent();
68  	}
69  
70  	@Override
71  	public FIBEditorController getEditorController() {
72  		return editorController;
73  	}
74  
75  	public JFIBEditableCustomWidget(FIBCustom model, FIBEditorController editorController) {
76  		super(model, editorController.getController());
77  		this.editorController = editorController;
78  
79  		delegate = new FIBSwingEditableViewDelegate<>(this);
80  	}
81  
82  	@Override
83  	public synchronized void delete() {
84  		delegate.delete();
85  		super.delete();
86  	}
87  
88  	@Override
89  	public FIBSwingEditableViewDelegate<FIBCustom, JCustomComponentPanel<CC, T>> getDelegate() {
90  		return delegate;
91  	}
92  
93  	private boolean operatorContentsStart = false;
94  
95  	// TODO: avoid code duplication in FIBSwingEditableView
96  	@Override
97  	public boolean isOperatorContentsStart() {
98  		return operatorContentsStart;
99  	}
100 
101 	// TODO: avoid code duplication in FIBSwingEditableView
102 	@Override
103 	public void setOperatorContentsStart(boolean operatorContentsStart) {
104 		if (operatorContentsStart != this.operatorContentsStart) {
105 			this.operatorContentsStart = operatorContentsStart;
106 			FIBSwingEditableView.updateOperatorContentsStart(this, operatorContentsStart);
107 			getPropertyChangeSupport().firePropertyChange("operatorContentsStart", !operatorContentsStart, operatorContentsStart);
108 		}
109 	}
110 
111 }