List of usage examples for javax.swing JToolBar getComponent
public Component getComponent(int n)
From source file:org.pmedv.blackboard.EditorUtils.java
/** * Updates the toolbar button states.//from w w w. jav a 2s . c o m * * @param editor */ public static void setToolbarButtonState(BoardEditor editor) { final ApplicationContext ctx = AppContext.getContext(); final ApplicationToolbarProvider provider = (ApplicationToolbarProvider) ctx.getBean("toolBarProvider"); JToolBar toolbar = provider.getToolbar(); for (int i = 0; i < toolbar.getComponentCount(); i++) { if (toolbar.getComponent(i) instanceof CmdJButton) { CmdJButton button = (CmdJButton) toolbar.getComponent(i); if (button.getAction() instanceof SetDrawModeCommand) { button.setBorderPainted(editor.getEditorMode().equals(EditorMode.DRAW_LINE)); } if (button.getAction() instanceof SetSelectModeCommand) { button.setBorderPainted(editor.getEditorMode().equals(EditorMode.SELECT)); } if (button.getAction() instanceof SetDrawRectangleModeCommand) { button.setBorderPainted(editor.getEditorMode().equals(EditorMode.DRAW_RECTANGLE)); } if (button.getAction() instanceof SetDrawEllipseModeCommand) { button.setBorderPainted(editor.getEditorMode().equals(EditorMode.DRAW_ELLIPSE)); } if (button.getAction() instanceof SetConnectionCheckModeCommand) { button.setBorderPainted(editor.getEditorMode().equals(EditorMode.CHECK_CONNECTIONS)); } if (button.getAction() instanceof SetDrawMeasureModeCommand) { button.setBorderPainted(editor.getEditorMode().equals(EditorMode.DRAW_MEASURE)); } if (button.getAction() instanceof SetMoveModeCommand) { button.setBorderPainted(editor.getEditorMode().equals(EditorMode.MOVE)); } } } }
From source file:org.pmedv.blackboard.EditorUtils.java
/** * Initializes the toolbar/* w w w . j av a 2 s . c o m*/ */ public static void initToolbar() { ApplicationToolbarProvider provider = ctx.getBean(ApplicationToolbarProvider.class); JToolBar toolbar = provider.getToolbar(); for (int i = 0; i < toolbar.getComponentCount(); i++) { if (toolbar.getComponent(i) instanceof CmdJButton) { CmdJButton button = (CmdJButton) toolbar.getComponent(i); if (button.getAction() instanceof SetDrawModeCommand || button.getAction() instanceof SetSelectModeCommand || button.getAction() instanceof SetDrawRectangleModeCommand || button.getAction() instanceof SetDrawEllipseModeCommand || button.getAction() instanceof SetConnectionCheckModeCommand || button.getAction() instanceof SetDrawMeasureModeCommand || button.getAction() instanceof ToggleMagneticCommand || button.getAction() instanceof ToggleGridCommand || button.getAction() instanceof ToggleMirrorCommand || button.getAction() instanceof ToggleSnapToGridCommand || button.getAction() instanceof SetMoveModeCommand) button.setShowFeedback(false); if (button.getAction() instanceof SetDrawModeCommand) button.setBorderPainted(true); } } }
From source file:org.pmedv.core.commands.OpenPerspectiveCommand.java
@Override public void execute(ActionEvent e) { final ApplicationContext ctx = AppContext.getContext(); final ApplicationWindow win = ctx.getBean(ApplicationWindow.class); final ApplicationWindowAdvisor advisor = ctx.getBean(ApplicationWindowAdvisor.class); final AbstractPerspective perspective = (AbstractPerspective) ctx.getBean(id); JMenuBar appMenuBar = win.getAppMenuBar(); for (int i = 0; i < appMenuBar.getMenuCount(); i++) { JMenuWithId menu = (JMenuWithId) appMenuBar.getMenu(i); if (menu.getId() != null && (menu.getId().equals("common") || menu.getId().equals(perspective.ID) || menu.getId().equals("languages"))) menu.setVisible(true);//w w w . j av a 2s . c om else menu.setVisible(false); } JToolBar appToolbar = win.getToolBar(); for (int i = 0; i < appToolbar.getComponentCount(); i++) { if (appToolbar.getComponent(i) instanceof CmdJButton) { CmdJButton button = (CmdJButton) appToolbar.getComponent(i); if (button.getId().equals("common") || button.getId().equals(perspective.ID)) button.setVisible(true); else button.setVisible(false); } } log.info("Setting current editor area to " + perspective.getEditorArea()); advisor.setCurrentEditorArea(perspective.getEditorArea()); advisor.setCurrentPerspective(perspective); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { InputStream is = getClass().getClassLoader().getResourceAsStream("application.properties"); Properties properties = new Properties(); try { properties.load(is); } catch (IOException e1) { properties.setProperty("version", "not set"); } // String title = resources.getResourceByKey(perspective.ID+".title"); // win.setTitle(configProvider.getConfig().getTitle()+" - "+title+" Version "+Constants.VERSION); win.setTitle(AppContext.getName() + " " + properties.getProperty("version")); win.getLayoutPane().removeAll(); win.getLayoutPane().add(perspective, BorderLayout.CENTER); win.getLayoutPane().revalidate(); win.getLayoutPane().repaint(); } }); }