/** * Creates new dialog * * @param app application */ public ToolbarConfigDialog(AppD app) { super(app.getFrame(), false); this.app = app; setTitle(app.getMenu("Toolbar.Customize")); // list with panels JComboBox switcher = new JComboBox(); switcher.addItem(new KeyValue(-1, app.getPlain("General"))); DockPanel[] panels = ((LayoutD) ((GuiManagerD) app.getGuiManager()).getLayout()).getDockManager().getPanels(); for (DockPanel panel : panels) { if (panel.hasToolbar()) { switcher.addItem(new KeyValue(panel.getViewId(), app.getPlain(panel.getViewTitle()))); } } switcher.addActionListener(this); // add at the end to not be notified about items being added JPanel switcherPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); switcherPanel.add(switcher); getContentPane().setLayout(new BorderLayout(5, 5)); getContentPane().add(switcherPanel, BorderLayout.NORTH); confPanel = new ToolbarConfigPanel(app); getContentPane().add(confPanel, BorderLayout.CENTER); getContentPane().add(createButtonPanel(), BorderLayout.SOUTH); pack(); setLocationRelativeTo(app.getFrame()); }
/** Switch panel for which we want to change the toolbar. */ public void actionPerformed(ActionEvent e) { int id = ((KeyValue) ((JComboBox) e.getSource()).getSelectedItem()).getKey(); if (id == -1) { confPanel.setToolbar(null, ((GuiManagerD) app.getGuiManager()).getToolbarDefinition()); } else { DockPanel panel = ((GuiManagerD) app.getGuiManager()).getLayout().getDockManager().getPanel(id); confPanel.setToolbar(panel, panel.getToolbarString()); } }