/* * (c) Copyright 2010-2011 AgileBirds * * This file is part of OpenFlexo. * * OpenFlexo is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * OpenFlexo is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with OpenFlexo. If not, see <http://www.gnu.org/licenses/>. * */ package org.openflexo.vpm.palette; import javax.swing.JTabbedPane; import org.openflexo.fge.view.DrawingView; import org.openflexo.foundation.viewpoint.ViewPointPalette; import org.openflexo.localization.FlexoLocalization; import org.openflexo.selection.SelectionManagingDrawingController; import org.openflexo.vpm.controller.VPMController; public class CalcPaletteController extends SelectionManagingDrawingController<CalcPaletteRepresentation> { private VPMController _controller; private PalettePalette _commonPalette; private CalcPaletteModuleView _moduleView; public CalcPaletteController(VPMController controller, ViewPointPalette palette, boolean readOnly) { super(new CalcPaletteRepresentation(palette, readOnly), controller.getSelectionManager()); _controller = controller; if (!readOnly) { _commonPalette = new PalettePalette(controller.getEditor()); registerPalette(_commonPalette); activatePalette(_commonPalette); } } @Override public void delete() { if (_controller != null) { if (getDrawingView() != null && _moduleView != null) { _controller.removeModuleView(_moduleView); } } super.delete(); getDrawing().delete(); } @Override public DrawingView<CalcPaletteRepresentation> makeDrawingView(CalcPaletteRepresentation drawing) { return new DrawingView<CalcPaletteRepresentation>(drawing, this); } public VPMController getCEDController() { return _controller; } public CalcPaletteModuleView getModuleView() { if (_moduleView == null) { _moduleView = new CalcPaletteModuleView(this); } return _moduleView; } public PalettePalette getCommonPalette() { return _commonPalette; } private JTabbedPane paletteView; public JTabbedPane getPaletteView() { if (paletteView == null) { paletteView = new JTabbedPane(); paletteView.add(FlexoLocalization.localizedForKey("Common", getCommonPalette().getPaletteViewInScrollPane()), getCommonPalette().getPaletteViewInScrollPane()); } return paletteView; } public ViewPointPalette getCalcPalette() { return getDrawing().getModel(); } }