Search in sources :

Example 11 with Path

use of org.beanfabrics.Path in project grafikon by jub77.

the class NewModelDialog method initComponents.

private void initComponents() {
    ActionListener closeAction = e -> setVisible(false);
    java.awt.GridBagConstraints gridBagConstraints;
    javax.swing.JLabel jLabel1 = new javax.swing.JLabel();
    BnComboBox scaleComboBox = new BnComboBox();
    javax.swing.JLabel jLabel2 = new javax.swing.JLabel();
    BnComboBox ratioComboBox = new BnComboBox();
    javax.swing.JPanel panel1 = new javax.swing.JPanel();
    BnButton okButton = new BnButton();
    okButton.addActionListener(closeAction);
    JButton cancelButton = new JButton();
    cancelButton.addActionListener(closeAction);
    javax.swing.JLabel jLabel3 = new javax.swing.JLabel();
    BnComboBox templatesComboBox = new BnComboBox();
    // NOI18N
    setTitle(ResourceLoader.getString("newmodel"));
    setResizable(false);
    getContentPane().setLayout(new java.awt.GridBagLayout());
    // NOI18N
    jLabel1.setText(ResourceLoader.getString("modelinfo.scales"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 10, 0, 0);
    getContentPane().add(jLabel1, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(10, 2, 10, 10);
    getContentPane().add(scaleComboBox, gridBagConstraints);
    // NOI18N
    jLabel2.setText(ResourceLoader.getString("modelinfo.ratio"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 0);
    getContentPane().add(jLabel2, gridBagConstraints);
    ratioComboBox.setEditable(true);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(0, 2, 10, 10);
    getContentPane().add(ratioComboBox, gridBagConstraints);
    // NOI18N
    okButton.setText(ResourceLoader.getString("button.ok"));
    panel1.add(okButton);
    // NOI18N
    cancelButton.setText(ResourceLoader.getString("button.cancel"));
    panel1.add(cancelButton);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 5);
    getContentPane().add(panel1, gridBagConstraints);
    // NOI18N
    jLabel3.setText(ResourceLoader.getString("newmodel.template"));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(0, 10, 10, 0);
    getContentPane().add(jLabel3, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(0, 2, 10, 10);
    getContentPane().add(templatesComboBox, gridBagConstraints);
    // binding
    scaleComboBox.setModelProvider(provider);
    scaleComboBox.setPath(new Path("scale"));
    ratioComboBox.setModelProvider(provider);
    ratioComboBox.setPath(new Path("timeScale"));
    templatesComboBox.setModelProvider(provider);
    templatesComboBox.setPath(new Path("template"));
    okButton.setModelProvider(provider);
    okButton.setPath(new Path("ok"));
    pack();
}
Also used : ModelProvider(org.beanfabrics.ModelProvider) ActionListener(java.awt.event.ActionListener) JButton(javax.swing.JButton) TemplateLoader(net.parostroj.timetable.model.templates.TemplateLoader) LSException(net.parostroj.timetable.model.ls.LSException) Path(org.beanfabrics.Path) NewModelPM(net.parostroj.timetable.gui.pm.NewModelPM) Callable(java.util.concurrent.Callable) TrainDiagram(net.parostroj.timetable.model.TrainDiagram) BnButton(org.beanfabrics.swing.BnButton) ResourceLoader(net.parostroj.timetable.utils.ResourceLoader) BnComboBox(org.beanfabrics.swing.BnComboBox) Path(org.beanfabrics.Path) JButton(javax.swing.JButton) ActionListener(java.awt.event.ActionListener) BnComboBox(org.beanfabrics.swing.BnComboBox) BnButton(org.beanfabrics.swing.BnButton)

Example 12 with Path

use of org.beanfabrics.Path in project grafikon by jub77.

the class MainFrame method initComponents.

private void initComponents() {
    javax.swing.JTabbedPane tabbedPane = new javax.swing.JTabbedPane();
    trainsPane = new net.parostroj.timetable.gui.panes.TrainsPane();
    engineCyclesPane = new net.parostroj.timetable.gui.panes.TrainsCyclesPane();
    trainUnitCyclesPane = new net.parostroj.timetable.gui.panes.TrainsCyclesPane();
    driverCyclesPane = new net.parostroj.timetable.gui.panes.TrainsCyclesPane();
    netPane = new net.parostroj.timetable.gui.panes.NetPane();
    circulationPane = new net.parostroj.timetable.gui.panes.CirculationPane();
    freightNetPane2 = new net.parostroj.timetable.gui.panes.FreightNetPane2();
    statusBar = new net.parostroj.timetable.gui.StatusBar();
    javax.swing.JMenuBar menuBar = new javax.swing.JMenuBar();
    fileMenu = new javax.swing.JMenu();
    javax.swing.JMenu languageMenu = new javax.swing.JMenu();
    javax.swing.JMenu lookAndFeelMenu = new javax.swing.JMenu();
    javax.swing.JMenu diagramMenu = new javax.swing.JMenu();
    javax.swing.JMenu actionMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem oLanguageMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenu viewsMenu = new javax.swing.JMenu();
    javax.swing.JMenu specialMenu = new javax.swing.JMenu();
    scriptsMenuModel = new javax.swing.JMenu();
    scriptsMenuGui = new javax.swing.JMenu();
    javax.swing.JMenu settingsMenu = new javax.swing.JMenu();
    javax.swing.JMenu helpMenu = new javax.swing.JMenu();
    floatingDialogsList = FloatingWindowsFactory.createDialogs(this, model.getMediator(), model);
    floatingDialogsList.addToMenuItem(viewsMenu);
    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    setTitle(frameTitle.getTitleString(false));
    setLocationByPlatform(true);
    // NOI18N
    tabbedPane.addTab(ResourceLoader.getString("tab.trains"), trainsPane);
    // NOI18N
    tabbedPane.addTab(ResourceLoader.getString("tab.engine.cycles"), engineCyclesPane);
    // NOI18N
    tabbedPane.addTab(ResourceLoader.getString("tab.trainunit.cycle"), trainUnitCyclesPane);
    // NOI18N
    tabbedPane.addTab(ResourceLoader.getString("tab.driver.cycles"), driverCyclesPane);
    // NOI18N
    tabbedPane.addTab(ResourceLoader.getString("tab.net"), netPane);
    // NOI18N
    tabbedPane.addTab(ResourceLoader.getString("tab.circulations"), circulationPane);
    // NOI18N
    tabbedPane.addTab(ResourceLoader.getString("tab.freight.net"), freightNetPane2);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(tabbedPane, BorderLayout.CENTER);
    getContentPane().add(statusBar, BorderLayout.SOUTH);
    // NOI18N
    tabbedPane.getAccessibleContext().setAccessibleName(ResourceLoader.getString("tab.trains"));
    // NOI18N
    fileMenu.setText(ResourceLoader.getString("menu.file"));
    TemplateLoader<TrainDiagram> loader = TemplateLoader.getDefault(TrainDiagram.class);
    // NOI18N
    this.addMenuItem(fileMenu, "menu.file.new", new NewOpenAction(model, this, loader), "new", false, null);
    try {
        this.addMenuItem(fileMenu, "menu.file.new.default.url", new NewOpenAction(model, this, TemplateLoader.getFromUrl(new URL(model.getTemplatesBaseUrl()), TrainDiagram.class)), "new", false, // NOI18N
        null);
    } catch (MalformedURLException mue) {
        log.warn(mue.getMessage(), mue);
    }
    fileMenu.add(new javax.swing.JSeparator());
    // NOI18N
    this.addMenuItem(fileMenu, "menu.file.open", new NewOpenAction(model, this, null), "open", false, javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
    // NOI18N
    this.addMenuItem(fileMenu, "menu.file.save", new SaveAction(model), "save", true, javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
    // NOI18N
    this.addMenuItem(fileMenu, "menu.file.saveas", new SaveAction(model), "save_as", true, javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
    fileMenu.add(new javax.swing.JSeparator());
    // NOI18N
    javax.swing.JMenu importMenu = new javax.swing.JMenu(ResourceLoader.getString("menu.file.importmenu"));
    fileMenu.add(importMenu);
    // NOI18N
    this.addMenuItem(importMenu, "menu.file.exportimport", new ImportAction(model, this, false, true), null);
    // NOI18N
    this.addMenuItem(importMenu, "menu.file.exportimport.trains", new ImportAction(model, this, true, false), null);
    // NOI18N
    this.addMenuItem(importMenu, "menu.file.outputs.import.replace", new ImportReplaceOutputTemplatesAction(model), null);
    // NOI18N
    this.addMenuItem(importMenu, "menu.file.outputs.import.replace.default.url", new ImportReplaceOutputTemplatesUrlAction(model), null);
    // NOI18N
    this.addMenuItem(fileMenu, "menu.file.library.export", new ExportAction(model, this), null);
    fileMenu.add(new javax.swing.JSeparator());
    // NOI18N
    languageMenu.setText(ResourceLoader.getString("menu.language"));
    fileMenu.add(languageMenu);
    // NOI18N
    lookAndFeelMenu.setText(ResourceLoader.getString("menu.lookandfeel"));
    fileMenu.add(lookAndFeelMenu);
    fileMenu.add(new javax.swing.JSeparator());
    fileMenu.add(new javax.swing.JSeparator());
    // NOI18N
    this.addMenuItem(fileMenu, "menu.file.exit", new ExitAction(model, this), null, false);
    menuBar.add(fileMenu);
    // NOI18N
    diagramMenu.setText(ResourceLoader.getString("menu.diagram"));
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.file.settings", this::settingsMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.file.info", this::infoMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.file.traintypes", this::trainTypesMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.file.lineclasses", this::lineClassesMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.file.weighttables", this::weightTablesMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.file.penaltytable", this::penaltyTableMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.file.regions", this::regionsMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.companies", this::companiesMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "localization.languages", this::languagesMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.file.localization", this::localizationMenuItemActionPerformed, true);
    this.addMenuItem(diagramMenu, "menu.groups", new EditGroupsAction(model), null);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.file.images", this::imagesMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "menu.file.textitems", this::textItemsMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(diagramMenu, "gt.routes.edit", this::editRoutesMenuItemActionPerformed, true);
    menuBar.add(diagramMenu);
    // NOI18N
    actionMenu.setText(ResourceLoader.getString("menu.outputs"));
    // NOI18N
    oLanguageMenuItem.setText(ResourceLoader.getString("menu.language.output") + "...");
    actionMenu.add(oLanguageMenuItem);
    // NOI18N
    this.addMenuItemWithListener(actionMenu, "menu.action.user.output.templates", this::ouputTemplatesMenuItemActionPerformed, true);
    // NOI18N
    this.addMenuItemWithListener(actionMenu, "menu.action.user.outputs", this::ouputMenuItemActionPerformed, true);
    menuBar.add(actionMenu);
    // NOI18N
    viewsMenu.setText(ResourceLoader.getString("menu.views"));
    menuBar.add(viewsMenu);
    // NOI18N
    specialMenu.setText(ResourceLoader.getString("menu.special.scripts"));
    // NOI18N
    this.addMenuItem(specialMenu, "menu.special.execute.script", executeScriptAction, "");
    specialMenu.add(new javax.swing.JSeparator());
    // NOI18N
    scriptsMenuModel.setText(ResourceLoader.getString("menu.special.predefined.scripts.model"));
    specialMenu.add(scriptsMenuModel);
    // NOI18N
    scriptsMenuGui.setText(ResourceLoader.getString("menu.special.predefined.scripts.gui"));
    specialMenu.add(scriptsMenuGui);
    specialMenu.add(new javax.swing.JSeparator());
    // NOI18N
    this.addMenuItem(specialMenu, "menu.special.recalculate", new RecalculateAction(model), null);
    // NOI18N
    this.addMenuItem(specialMenu, "menu.special.recalculate.stops", new RecalculateStopsAction(model), null);
    // NOI18N
    this.addMenuItem(specialMenu, "menu.special.remove.weights", new RemoveWeightsAction(model), null);
    menuBar.add(specialMenu);
    // NOI18N
    settingsMenu.setText(ResourceLoader.getString("menu.settings"));
    // NOI18N
    this.addMenuItemWithListener(settingsMenu, "menu.settings.columns", evt -> trainsPane.editColumns(), false);
    // NOI18N
    this.addMenuItemWithListener(settingsMenu, "menu.settings.sort.columns", evt -> trainsPane.sortColumns(), false);
    // NOI18N
    this.addMenuItemWithListener(settingsMenu, "menu.settings.resize.columns", evt -> trainsPane.resizeColumns(), false);
    // NOI18N
    showGTViewMenuItem = this.addCheckMenuItem(settingsMenu, "menu.settings.show.gtview", this::showGTViewMenuItemActionPerformed, null, true);
    // NOI18N
    this.addMenuItemWithListener(settingsMenu, "menu.program.settings", this::programSettingsMenuItemActionPerformed, false);
    menuBar.add(settingsMenu);
    // NOI18N
    helpMenu.setText(ResourceLoader.getString("menu.help"));
    // NOI18N
    this.addMenuItemWithListener(helpMenu, "menu.help.about", this::aboutMenuItemActionPerformed, false);
    menuBar.add(Box.createHorizontalGlue());
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
    // enabled list
    enabledComponents.add(tabbedPane);
    enabledComponents.add(scriptsMenuModel);
    enabledComponents.add(scriptsMenuGui);
    setMinimumSize(new java.awt.Dimension(800, 600));
    setSize(getMinimumSize());
    trainUnitCyclesPane.setKey("cycles.trainunit");
    driverCyclesPane.setKey("cycles.driver");
    engineCyclesPane.setKey("cycles.engine");
    // add languages to menu
    LanguageMenuBuilder languageMenuBuilder = new LanguageMenuBuilder(model.getLanguageLoader());
    List<Pair<JRadioButtonMenuItem, Locale>> lItems = languageMenuBuilder.createLanguageMenuItems(ResourceLoader.getString("menu.language.system"), LanguagesType.GUI);
    BnButtonGroup<Locale> lBGroup = new BnButtonGroup<>();
    for (Pair<JRadioButtonMenuItem, Locale> item : lItems) {
        languageMenu.add(item.first);
        lBGroup.add(item.first, item.second);
    }
    lBGroup.setModelProvider(provider);
    lBGroup.setPath(new Path("locale"));
    // output language
    oLanguageMenuItem.addActionListener(e -> {
        String system = ResourceLoader.getString("menu.language.system");
        LanguageLoader languageLoader = model.getLanguageLoader();
        List<Wrapper<Locale>> values = languageLoader.createWrappers(languageLoader.getAvailableLocales(), system);
        Collections.sort(values);
        Locale oLocale = model.getOutputSettings().getLocale();
        Wrapper<?> selected = (Wrapper<?>) JOptionPane.showInputDialog(this, null, null, JOptionPane.QUESTION_MESSAGE, null, values.toArray(), oLocale == null ? Wrapper.getEmptyWrapper("") : Wrapper.getWrapper(oLocale));
        if (selected != null) {
            Locale sLocale = (Locale) selected.getElement();
            model.getOutputSettings().setLocale(sLocale);
        }
    });
    // look and feel
    BnButtonGroup<String> lafBGroup = new BnButtonGroup<>();
    for (String key : model.lookAndFeel.getValues()) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(model.lookAndFeel.getOptions().get(key));
        lafBGroup.add(item, key);
        lookAndFeelMenu.add(item);
    }
    lafBGroup.setModelProvider(provider);
    lafBGroup.setPath(new Path("lookAndFeel"));
}
Also used : MalformedURLException(java.net.MalformedURLException) BorderLayout(java.awt.BorderLayout) Wrapper(net.parostroj.timetable.gui.wrappers.Wrapper) BnButtonGroup(net.parostroj.timetable.gui.components.BnButtonGroup) URL(java.net.URL) Pair(net.parostroj.timetable.utils.Pair) Path(org.beanfabrics.Path) javax.swing(javax.swing)

Aggregations

Path (org.beanfabrics.Path)12 ActionListener (java.awt.event.ActionListener)7 ModelProvider (org.beanfabrics.ModelProvider)7 BnButton (org.beanfabrics.swing.BnButton)6 java.awt (java.awt)5 javax.swing (javax.swing)5 JLabel (javax.swing.JLabel)5 BnTextField (org.beanfabrics.swing.BnTextField)5 JPanel (javax.swing.JPanel)4 EmptyBorder (javax.swing.border.EmptyBorder)4 ResourceLoader (net.parostroj.timetable.gui.utils.ResourceLoader)4 BorderLayout (java.awt.BorderLayout)3 FlowLayout (java.awt.FlowLayout)3 Locale (java.util.Locale)3 TrainDiagram (net.parostroj.timetable.model.TrainDiagram)3 org.beanfabrics.swing (org.beanfabrics.swing)3 BnComboBox (org.beanfabrics.swing.BnComboBox)3 Window (java.awt.Window)2 Collection (java.util.Collection)2 JButton (javax.swing.JButton)2