Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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 http://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;
 
 import java.awt.Font;
 
 
Main frame of CayenneModeler. Responsibilities include coordination of enabling/disabling of menu and toolbar.
 
 public class CayenneModelerFrame extends JFrame implements DataNodeDisplayListener,
 
     protected EditorView view;
     protected RecentFileMenu recentFileMenu;
     protected ActionManager actionManager;
     protected JLabel status;
 
     public CayenneModelerFrame(ActionManager actionManager) {
         super(.);
         this. = actionManager;
 
         initMenus();
         initToolbar();
        initStatusBar();
    }

    
Returns an action object associated with the key.
    private CayenneAction getAction(String key) {
        return .getAction(key);
    }
    protected void initMenus() {
        getContentPane().setLayout(new BorderLayout());
        JMenu fileMenu = new JMenu("File");
        JMenu projectMenu = new JMenu("Project");
        JMenu toolMenu = new JMenu("Tools");
        JMenu helpMenu = new JMenu("Help");
        if (!.) {
            fileMenu.setMnemonic(.);
            projectMenu.setMnemonic(.);
            toolMenu.setMnemonic(.);
            helpMenu.setMnemonic(.);
        }
        fileMenu.add(getAction(NewProjectAction.getActionName()).buildMenu());
        fileMenu.add(getAction(OpenProjectAction.getActionName()).buildMenu());
        fileMenu.add(getAction(ProjectAction.getActionName()).buildMenu());
        fileMenu.add(getAction(ImportDataMapAction.getActionName()).buildMenu());
        fileMenu.addSeparator();
        fileMenu.add(getAction(SaveAction.getActionName()).buildMenu());
        fileMenu.add(getAction(SaveAsAction.getActionName()).buildMenu());
        fileMenu.add(getAction(RevertAction.getActionName()).buildMenu());
        fileMenu.addSeparator();
         = new RecentFileMenu("Recent Files");
        fileMenu.add();
        fileMenu.addSeparator();
        fileMenu.add(getAction(ExitAction.getActionName()).buildMenu());
        projectMenu.add(getAction(ValidateAction.getActionName()).buildMenu());
        projectMenu.addSeparator();
        projectMenu.add(getAction(CreateDomainAction.getActionName()).buildMenu());
        projectMenu.add(getAction(CreateNodeAction.getActionName()).buildMenu());
        projectMenu.add(getAction(CreateDataMapAction.getActionName()).buildMenu());
        projectMenu.add(getAction(CreateObjEntityAction.getActionName()).buildMenu());
        projectMenu.add(getAction(CreateDbEntityAction.getActionName()).buildMenu());
        projectMenu.add(getAction(CreateDerivedDbEntityAction.getActionName())
                .buildMenu());
        projectMenu.add(getAction(CreateProcedureAction.getActionName()).buildMenu());
        projectMenu.add(getAction(CreateQueryAction.getActionName()).buildMenu());
        projectMenu.addSeparator();
        projectMenu.add(getAction(ObjEntitySyncAction.getActionName()).buildMenu());
        projectMenu.add(getAction(DerivedEntitySyncAction.getActionName()).buildMenu());
        projectMenu.addSeparator();
        projectMenu.add(getAction(RemoveAction.getActionName()).buildMenu());
        toolMenu.add(getAction(ImportDBAction.getActionName()).buildMenu());
        toolMenu.add(getAction(ImportEOModelAction.getActionName()).buildMenu());
        toolMenu.addSeparator();
        toolMenu.add(getAction(GenerateCodeAction.getActionName()).buildMenu());
        toolMenu.add(getAction(GenerateDBAction.getActionName()).buildMenu());
        toolMenu.addSeparator();
        toolMenu.add(getAction(ConfigurePreferencesAction.getActionName()).buildMenu());
        helpMenu.add(getAction(AboutAction.getActionName()).buildMenu());
        JMenuBar menuBar = new JMenuBar();
        menuBar.add(fileMenu);
        menuBar.add(projectMenu);
        menuBar.add(toolMenu);
        menuBar.add(helpMenu);
        setJMenuBar(menuBar);
    }
    protected void initStatusBar() {
         = new JLabel();
        .setFont(.getFont().deriveFont(., 10));
        JPanel statusBar = new JPanel(new FlowLayout(., 3, 1));
        // add placeholder
        statusBar.add(Box.createVerticalStrut(16));
        statusBar.add();
        getContentPane().add(statusBar.);
    }

    
Initializes main toolbar.
    protected void initToolbar() {
        JToolBar toolBar = new JToolBar();
        toolBar.add(getAction(NewProjectAction.getActionName()).buildButton());
        toolBar.add(getAction(OpenProjectAction.getActionName()).buildButton());
        toolBar.add(getAction(SaveAction.getActionName()).buildButton());
        toolBar.add(getAction(RemoveAction.getActionName()).buildButton());
        toolBar.addSeparator();
        toolBar.add(getAction(CreateDomainAction.getActionName()).buildButton());
        toolBar.add(getAction(CreateNodeAction.getActionName()).buildButton());
        toolBar.add(getAction(CreateDataMapAction.getActionName()).buildButton());
        toolBar.addSeparator();
        toolBar.add(getAction(CreateDbEntityAction.getActionName()).buildButton());
        toolBar.add(getAction(CreateDerivedDbEntityAction.getActionName()).buildButton());
        toolBar.add(getAction(CreateProcedureAction.getActionName()).buildButton());
        toolBar.addSeparator();
        toolBar.add(getAction(CreateObjEntityAction.getActionName()).buildButton());
        toolBar.add(getAction(CreateQueryAction.getActionName()).buildButton());
        toolBar.addSeparator();
        toolBar.add(getAction(NavigateBackwardAction.getActionName()).buildButton());
        toolBar.add(getAction(NavigateForwardAction.getActionName()).buildButton());
        getContentPane().add(toolBar.);
    }
    public void currentDataNodeChanged(DataNodeDisplayEvent e) {
    }
    public void currentDataMapChanged(DataMapDisplayEvent e) {
    }
    public void currentObjEntityChanged(EntityDisplayEvent e) {
    }
    public void currentDbEntityChanged(EntityDisplayEvent e) {
        boolean derived = e.getEntity() instanceof DerivedDbEntity;
        if (derived) {
            .derivedDbEntitySelected();
            getAction(DerivedEntitySyncAction.getActionName()).setEnabled(true);
        }
        else {
            .dbEntitySelected();
        }
    }
    public void currentQueryChanged(QueryDisplayEvent e) {
        .querySelected();
    }
    }

    
Returns the right side view panel.

Returns:
EditorView
    public EditorView getView() {
        return ;
    }
    public JLabel getStatus() {
        return ;
    }

    
Returns the recentFileMenu.

Returns:
RecentFileMenu
    public RecentFileMenu getRecentFileMenu() {
        return ;
    }

    
Adds editor view to the frame.
    public void setView(EditorView view) {
        boolean change = false;
        if (this. != null) {
            getContentPane().remove(this.);
            change = true;
        }
        this. = view;
        if (view != null) {
            getContentPane().add(view.);
            change = true;
        }
        if (change) {
            validate();
        }
    }
New to GrepCode? Check out our FAQ X