001    // This file is part of the Attempto Java Packages.
002    // Copyright 2008, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch).
003    //
004    // The Attempto Java Packages is free software: you can redistribute it and/or modify it under the
005    // terms of the GNU Lesser General Public License as published by the Free Software Foundation,
006    // either version 3 of the License, or (at your option) any later version.
007    //
008    // The Attempto Java Packages is distributed in the hope that it will be useful, but WITHOUT ANY
009    // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
010    // PURPOSE. See the GNU Lesser General Public License for more details.
011    //
012    // You should have received a copy of the GNU Lesser General Public License along with the Attempto
013    // Java Packages. If not, see http://www.gnu.org/licenses/.
014    
015    package ch.uzh.ifi.attempto.acewiki.gui.editor;
016    
017    import nextapp.echo2.app.Alignment;
018    import nextapp.echo2.app.Border;
019    import nextapp.echo2.app.Color;
020    import nextapp.echo2.app.ContentPane;
021    import nextapp.echo2.app.Extent;
022    import nextapp.echo2.app.Font;
023    import nextapp.echo2.app.Insets;
024    import ch.uzh.ifi.attempto.echocomp.Style;
025    import ch.uzh.ifi.attempto.echocomp.WindowPane;
026    import echopointng.ButtonEx;
027    import echopointng.TabbedPane;
028    import echopointng.tabbedpane.DefaultTabModel;
029    
030    /**
031     * This class represents the word editor that is used to create or modify words. It can contain
032     * several tabs for several word forms.
033     * 
034     * @author Tobias Kuhn
035     */
036    public class WordEditorWindow extends WindowPane {
037            
038            private static final long serialVersionUID = 6805275173727379038L;
039            
040            private TabbedPane tabbedPane = new TabbedPane();
041            
042            private WordEditorWindow(String title) {
043                    setModal(true);
044                    setTitle(title);
045                    setTitleFont(new Font(Style.fontTypeface, Font.ITALIC, new Extent(13)));
046                    setWidth(new Extent(753));
047                    setHeight(new Extent(503));
048                    setResizable(false);
049                    setTitleBackground(Style.windowTitleBackground);
050                    setStyleName("Default");
051                    
052                    tabbedPane.setOutsets(new Insets(10));
053                    tabbedPane.setTabPlacement(Alignment.TOP);
054                    tabbedPane.setBorder(new Border(1, Color.BLACK, Border.STYLE_INSET));
055                    tabbedPane.setHeight(new Extent(400));
056                    
057                    add(tabbedPane);
058            }
059            
060            /**
061             * Creates a new word editor window.
062             * 
063             * @return The new word editor window.
064             */
065            public static WordEditorWindow createEditorWindow() {
066                    return new WordEditorWindow("Word Editor");
067            }
068            
069            /**
070             * Creates a new word creator window.
071             * 
072             * @return The new word creator window.
073             */
074            public static WordEditorWindow createCreatorWindow() {
075                    return new WordEditorWindow("Word Creator");
076            }
077            
078            /**
079             * Adds a new tab to the window. The toString() value is used as the title of the tab.
080             * 
081             * @param pane The pane that should be shown in the new tab.
082             */
083            public void addTab(ContentPane pane) {
084                    DefaultTabModel tabModel = (DefaultTabModel) tabbedPane.getModel();
085                    ButtonEx tab = new ButtonEx(pane.toString(), null);
086                    tab.setStyle(DefaultTabModel.DEFAULT_TOP_ALIGNED_STYLE);
087                    tab.setFont(new Font(Style.fontTypeface, Font.ITALIC, new Extent(13)));
088                    tab.setInsets(new Insets(5, 2));
089                    tabModel.addTab(tab, pane);
090            }
091            
092    }