/** * Activate/Deactivate Rotate-Button * * @param b */ public void activateRotation(boolean b) { if (showRotate && b) { rotatePanel.setVisible(b); rotateSlider.setValue(((ShapeItem) board.getSelectedItems()[0]).getRotation()); } else { rotatePanel.setVisible(false); } rotate.setEnabled(b); }
public void arriveACPForm(ACPFormEvent e) { if (e.getTransaction().equals(transaction)) { setEnabled(true); setVisible(true); if (!toolBar.isVisible()) { toolBar.setVisible(true); } } }
/** * Parse the toolbar preference setting and construct the toolbar GUI control. * * <p>Call this, if anything has changed in the toolbar settings and you want to refresh the * toolbar content (e.g. after registering actions in a plugin) */ public void refreshToolbarControl() { control.removeAll(); buttonActions.clear(); boolean unregisterTab = Shortcut.findShortcut(KeyEvent.VK_TAB, 0) != null; for (ActionDefinition action : getDefinedActions()) { if (action.isSeparator()) { control.addSeparator(); } else { final JButton b = addButtonAndShortcut(action); buttonActions.put(b, action); Icon i = action.getDisplayIcon(); if (i != null) { b.setIcon(i); } else { // hide action text if an icon is set later (necessary for delayed/background image // loading) action .getParametrizedAction() .addPropertyChangeListener( new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (Action.SMALL_ICON.equals(evt.getPropertyName())) { b.setHideActionText(evt.getNewValue() != null); } } }); } b.setInheritsPopupMenu(true); b.setFocusTraversalKeysEnabled(!unregisterTab); } } control.setFocusTraversalKeysEnabled(!unregisterTab); control.setVisible(control.getComponentCount() != 0); }
/** Shows/Hide Toolbar */ public void hideToolbar() { toolbar.setVisible(!this.toolbar.isVisible()); tbe.getMenu().setVisibleToolbar(!this.toolbar.isVisible()); }
/** Shows/Hide Sidebar */ public void hideSidebar() { sideBar.setVisible(!this.sideBar.isVisible()); tbe.getMenu().setVisibleSidebar(!this.sideBar.isVisible()); }
/** Install the Rotate-Button into the toolbar */ private void installRotateButton() { URL imgURL = ClassLoader.getSystemResource("ch/tbe/pics/rotate.gif"); ImageIcon rotateIcon = new ImageIcon(imgURL); rotate = new JButton(rotateIcon); rotate.setEnabled(false); rotatePanel = new JToolBar(); rotatePanel.setOrientation(1); rotatePanel.setLayout(new BorderLayout(0, 1)); rotateSlider = new JSlider(); rotateSlider.setMaximum(359); rotateSlider.setMinimum(0); rotateSlider.setMaximumSize(new Dimension(100, 100)); rotateSlider.setOrientation(1); Box box = Box.createVerticalBox(); sliderValue.setPreferredSize(new Dimension(30, 20)); rotateSlider.setAlignmentY(Component.TOP_ALIGNMENT); box.add(sliderValue); box.add(rotateSlider); sliderValue.setAlignmentY(Component.TOP_ALIGNMENT); rotatePanel.add(box, BorderLayout.NORTH); sliderValue.addFocusListener( new FocusListener() { private int oldValue = 0; public void focusGained(FocusEvent arg0) { oldValue = Integer.parseInt(sliderValue.getText()); } public void focusLost(FocusEvent arg0) { int newValue = 0; try { newValue = Integer.parseInt(sliderValue.getText()); } catch (Exception ex) { sliderValue.setText(Integer.toString(oldValue)); } if (newValue >= 0 && newValue <= 359) { RotateCommand rc = new RotateCommand(board.getSelectedItems()); ArrayList<Command> actCommands = new ArrayList<Command>(); actCommands.add(rc); TBE.getInstance().addCommands(actCommands); rotateSlider.setValue(newValue); } else { sliderValue.setText(Integer.toString(oldValue)); } } }); rotateSlider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { if (board.getSelectionCount() == 1 && board.getSelectionCells()[0] instanceof ShapeItem) { sliderValue.setText(Integer.toString(rotateSlider.getValue())); ShapeItem s = (ShapeItem) board.getSelectionCells()[0]; board.removeItem(new ItemComponent[] {s}); s.setRotation(rotateSlider.getValue()); board.addItem(s); } } }); rotateSlider.addMouseListener( new MouseAdapter() { private int value; public void mousePressed(MouseEvent e) { value = rotateSlider.getValue(); } public void mouseReleased(MouseEvent e) { if (value != rotateSlider.getValue()) { RotateCommand rc = new RotateCommand(board.getSelectedItems()); ArrayList<Command> actCommands = new ArrayList<Command>(); actCommands.add(rc); TBE.getInstance().addCommands(actCommands); rc.setRotation(value); } } }); rotate.setToolTipText(workingViewLabels.getString("rotate")); rotate.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (board.getSelectionCount() == 1 && board.getSelectedItems()[0] instanceof ShapeItem) { rotateSlider.setValue(((ShapeItem) board.getSelectedItems()[0]).getRotation()); } rotatePanel.setVisible(!rotatePanel.isVisible()); showRotate = !showRotate; } }); rotate.setContentAreaFilled(false); rotate.setBorderPainted(false); toolbar.add(rotate); rotatePanel.setVisible(false); this.add(rotatePanel, BorderLayout.EAST); }
public void setToolbarVisible(boolean visible) { toolbarVisible = visible; toolbar.setVisible(toolbarVisible); }