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.FIBTable;
47  import org.openflexo.gina.swing.editor.controller.FIBEditorController;
48  import org.openflexo.gina.swing.editor.view.FIBSwingEditableView;
49  import org.openflexo.gina.swing.editor.view.FIBSwingEditableViewDelegate;
50  import org.openflexo.gina.swing.view.widget.JFIBTableWidget;
51  import org.openflexo.gina.swing.view.widget.JTablePanel;
52  import org.openflexo.logging.FlexoLogger;
53  
54  public class JFIBEditableTableWidget<T> extends JFIBTableWidget<T> implements FIBSwingEditableView<FIBTable, JTablePanel<T>> {
55  
56  	@SuppressWarnings("unused")
57  	private static final Logger logger = FlexoLogger.getLogger(JFIBEditableTableWidget.class.getPackage().getName());
58  
59  	private final FIBSwingEditableViewDelegate<FIBTable, JTablePanel<T>> delegate;
60  
61  	private final FIBEditorController editorController;
62  
63  	@Override
64  	public JComponent getDraggableComponent() {
65  		return getTechnologyComponent();
66  	}
67  
68  	@Override
69  	public FIBEditorController getEditorController() {
70  		return editorController;
71  	}
72  
73  	public JFIBEditableTableWidget(FIBTable model, FIBEditorController editorController) {
74  		super(model, editorController.getController());
75  		this.editorController = editorController;
76  
77  		delegate = new FIBSwingEditableViewDelegate<>(this);
78  	}
79  
80  	@Override
81  	public synchronized void delete() {
82  		delegate.delete();
83  		super.delete();
84  	}
85  
86  	@Override
87  	public FIBSwingEditableViewDelegate<FIBTable, JTablePanel<T>> getDelegate() {
88  		return delegate;
89  	}
90  
91  	private boolean operatorContentsStart = false;
92  
93  	// TODO: avoid code duplication in FIBSwingEditableView
94  	@Override
95  	public boolean isOperatorContentsStart() {
96  		return operatorContentsStart;
97  	}
98  
99  	// TODO: avoid code duplication in FIBSwingEditableView
100 	@Override
101 	public void setOperatorContentsStart(boolean operatorContentsStart) {
102 		if (operatorContentsStart != this.operatorContentsStart) {
103 			this.operatorContentsStart = operatorContentsStart;
104 			FIBSwingEditableView.updateOperatorContentsStart(this, operatorContentsStart);
105 			getPropertyChangeSupport().firePropertyChange("operatorContentsStart", !operatorContentsStart, operatorContentsStart);
106 		}
107 	}
108 
109 }