use of javax.swing.JToolBar in project processdash by dtuma.
the class ProxyEditor method buildToolbar.
private void buildToolbar() {
toolBar = new JToolBar();
toolBar.setFloatable(false);
toolBar.setMargin(new Insets(0, 0, 0, 0));
addToolbarButton(undoList.getUndoAction());
addToolbarButton(undoList.getRedoAction());
table.tweakClipboardActions(resources, IconFactory.getCopyProxyIcon(), IconFactory.getPasteProxyIcon());
addToolbarButton(table.CUT_ACTION);
addToolbarButton(table.COPY_ACTION);
addToolbarButton(table.PASTE_ACTION);
addToolbarButton(table.EXPAND_ACTION);
addToolbarButton(table.COLLAPSE_ACTION);
addToolbarButton(table.MOVEUP_ACTION);
addToolbarButton(table.MOVEDOWN_ACTION);
addToolbarButton(table.DELETE_ACTION);
toolBar.addSeparator();
if (!isEditable(teamProject)) {
IMPORT.setEnabled(false);
IMPORT_ORG.setEnabled(false);
}
TeamProcess teamProcess = teamProject.getTeamProcess();
if (ProxyLibraryEditor.orgAssetsAreAvailable(teamProcess))
addToolbarButton(IMPORT_ORG);
addToolbarButton(IMPORT);
addToolbarButton(EXPORT);
}
use of javax.swing.JToolBar in project litiengine by gurkenlabs.
the class Program method initToolBar.
private static JToolBar initToolBar() {
// create basic icon toolbar
JToolBar basicMenu = new JToolBar();
JButton cr = new JButton();
cr.setIcon(new ImageIcon(Resources.getImage("button-create.png")));
basicMenu.add(cr);
cr.addActionListener(a -> EditorScreen.instance().create());
JButton op = new JButton();
op.setIcon(new ImageIcon(Resources.getImage("button-load.png")));
basicMenu.add(op);
op.addActionListener(a -> EditorScreen.instance().load());
JButton sv = new JButton();
sv.setIcon(new ImageIcon(Resources.getImage("button-save.png")));
basicMenu.add(sv);
sv.addActionListener(a -> EditorScreen.instance().save(false));
basicMenu.addSeparator();
JButton undo = new JButton();
undo.setIcon(new ImageIcon(Resources.getImage("button-undo.png")));
basicMenu.add(undo);
undo.addActionListener(a -> UndoManager.instance().undo());
JButton redo = new JButton();
redo.setIcon(new ImageIcon(Resources.getImage("button-redo.png")));
basicMenu.add(redo);
redo.addActionListener(a -> UndoManager.instance().redo());
undo.setEnabled(false);
redo.setEnabled(false);
basicMenu.addSeparator();
JToggleButton place = new JToggleButton();
place.setIcon(new ImageIcon(Resources.getImage("button-placeobject.png")));
basicMenu.add(place);
JToggleButton ed = new JToggleButton();
ed.setIcon(new ImageIcon(Resources.getImage("button-edit.png")));
ed.setSelected(true);
JToggleButton mv = new JToggleButton();
mv.setIcon(new ImageIcon(Resources.getImage("button-move.png")));
mv.setEnabled(false);
ed.addActionListener(a -> {
ed.setSelected(true);
place.setSelected(false);
mv.setSelected(false);
isChanging = true;
EditorScreen.instance().getMapComponent().setEditMode(MapComponent.EDITMODE_EDIT);
isChanging = false;
Game.getScreenManager().getRenderComponent().setCursor(CURSOR, 0, 0);
});
basicMenu.add(ed);
basicMenu.add(mv);
place.addActionListener(a -> {
place.setSelected(true);
ed.setSelected(false);
mv.setSelected(false);
isChanging = true;
EditorScreen.instance().getMapComponent().setEditMode(MapComponent.EDITMODE_CREATE);
isChanging = false;
});
mv.addActionListener(a -> {
mv.setSelected(true);
ed.setSelected(false);
place.setSelected(false);
isChanging = true;
EditorScreen.instance().getMapComponent().setEditMode(MapComponent.EDITMODE_MOVE);
isChanging = false;
Game.getScreenManager().getRenderComponent().setCursor(CURSOR_MOVE, 0, 0);
});
EditorScreen.instance().getMapComponent().onEditModeChanged(i -> {
if (isChanging) {
return;
}
if (i == MapComponent.EDITMODE_CREATE) {
ed.setSelected(false);
mv.setSelected(false);
place.setSelected(true);
}
if (i == MapComponent.EDITMODE_EDIT) {
place.setSelected(false);
mv.setSelected(false);
ed.setSelected(true);
Game.getScreenManager().getRenderComponent().setCursor(CURSOR, 0, 0);
}
if (i == MapComponent.EDITMODE_MOVE) {
ed.setSelected(false);
place.setSelected(false);
mv.setSelected(true);
Game.getScreenManager().getRenderComponent().setCursor(CURSOR_MOVE, 0, 0);
}
});
JButton del = new JButton();
del.setIcon(new ImageIcon(Resources.getImage("button-delete.png")));
basicMenu.add(del);
del.setEnabled(false);
del.addActionListener(a -> EditorScreen.instance().getMapComponent().delete());
// copy
JButton cop = new JButton();
cop.setIcon(new ImageIcon(Resources.getImage("button-copy.png")));
basicMenu.add(cop);
cop.setEnabled(false);
ActionListener copyAction = a -> EditorScreen.instance().getMapComponent().copy();
cop.addActionListener(copyAction);
cop.getModel().setMnemonic('C');
KeyStroke keyStroke = KeyStroke.getKeyStroke('C', Event.CTRL_MASK, false);
cop.registerKeyboardAction(copyAction, keyStroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
// paste
JButton paste = new JButton();
paste.setIcon(new ImageIcon(Resources.getImage("button-paste.png")));
basicMenu.add(paste);
ActionListener pasteAction = a -> EditorScreen.instance().getMapComponent().paste();
paste.addActionListener(pasteAction);
paste.getModel().setMnemonic('V');
KeyStroke keyStrokePaste = KeyStroke.getKeyStroke('V', Event.CTRL_MASK, false);
paste.registerKeyboardAction(pasteAction, keyStrokePaste, JComponent.WHEN_IN_FOCUSED_WINDOW);
// cut
JButton cut = new JButton();
cut.setIcon(new ImageIcon(Resources.getImage("button-cut.png")));
basicMenu.add(cut);
cut.setEnabled(false);
ActionListener cutAction = a -> EditorScreen.instance().getMapComponent().cut();
cut.addActionListener(cutAction);
cut.getModel().setMnemonic('X');
KeyStroke keyStrokeCut = KeyStroke.getKeyStroke('X', Event.CTRL_MASK, false);
cut.registerKeyboardAction(cutAction, keyStrokeCut, JComponent.WHEN_IN_FOCUSED_WINDOW);
EditorScreen.instance().getMapComponent().onFocusChanged(mo -> {
if (mv.isSelected()) {
mv.setSelected(false);
ed.setSelected(true);
}
mv.setEnabled(mo != null);
del.setEnabled(mo != null);
cop.setEnabled(mo != null);
cut.setEnabled(mo != null);
undo.setEnabled(UndoManager.instance().canUndo());
redo.setEnabled(UndoManager.instance().canRedo());
paste.setEnabled(EditorScreen.instance().getMapComponent().getCopiedBlueprint() != null);
});
EditorScreen.instance().getMapComponent().onEditModeChanged(mode -> paste.setEnabled(EditorScreen.instance().getMapComponent().getCopiedBlueprint() != null));
UndoManager.onUndoStackChanged(manager -> {
EditorScreen.instance().getMapComponent().updateTransformControls();
undo.setEnabled(manager.canUndo());
redo.setEnabled(manager.canRedo());
});
basicMenu.addSeparator();
JButton colorButton = new JButton();
colorButton.setIcon(new ImageIcon(Resources.getImage("button-color.png")));
colorButton.setEnabled(false);
JTextField colorText = new JTextField();
colorText.setEnabled(false);
colorText.setMaximumSize(new Dimension(50, 50));
JSpinner spinnerAmbientAlpha = new JSpinner();
spinnerAmbientAlpha.setModel(new SpinnerNumberModel(0, 0, 255, 1));
spinnerAmbientAlpha.setFont(Program.TEXT_FONT);
spinnerAmbientAlpha.setMaximumSize(new Dimension(50, 50));
spinnerAmbientAlpha.setEnabled(false);
spinnerAmbientAlpha.addChangeListener(e -> {
if (Game.getEnvironment() == null || Game.getEnvironment().getMap() == null || isChanging) {
return;
}
Game.getEnvironment().getMap().setCustomProperty(MapProperty.AMBIENTALPHA, spinnerAmbientAlpha.getValue().toString());
Game.getEnvironment().getAmbientLight().setAlpha((int) spinnerAmbientAlpha.getValue());
});
colorButton.addActionListener(a -> {
if (Game.getEnvironment() == null || Game.getEnvironment().getMap() == null || isChanging) {
return;
}
Color color = null;
if (colorText.getText() != null && !colorText.getText().isEmpty()) {
Color solid = Color.decode(colorText.getText());
color = new Color(solid.getRed(), solid.getGreen(), solid.getBlue(), (int) spinnerAmbientAlpha.getValue());
}
Color result = ColorChooser.showRgbDialog("Select an ambient color.", color);
if (result == null) {
return;
}
String h = "#" + Integer.toHexString(result.getRGB()).substring(2);
colorText.setText(h);
spinnerAmbientAlpha.setValue(result.getAlpha());
Game.getEnvironment().getMap().setCustomProperty(MapProperty.AMBIENTCOLOR, colorText.getText());
Game.getEnvironment().getAmbientLight().setColor(result);
});
EditorScreen.instance().getMapComponent().onMapLoaded(map -> {
isChanging = true;
colorButton.setEnabled(map != null);
spinnerAmbientAlpha.setEnabled(map != null);
colorText.setText(map.getCustomProperty(MapProperty.AMBIENTCOLOR));
String alpha = map.getCustomProperty(MapProperty.AMBIENTALPHA);
if (alpha != null && !alpha.isEmpty()) {
spinnerAmbientAlpha.setValue((int) Double.parseDouble(alpha));
}
isChanging = false;
});
basicMenu.add(colorButton);
basicMenu.add(Box.createHorizontalStrut(5));
basicMenu.add(colorText);
basicMenu.add(Box.createHorizontalStrut(5));
basicMenu.add(spinnerAmbientAlpha);
return basicMenu;
}
use of javax.swing.JToolBar in project litiengine by gurkenlabs.
the class Program method setupInterface.
private static void setupInterface() {
MenuBar menuBar = new MenuBar();
JFrame window = ((JFrame) Game.getScreenManager());
Game.onTerminating(s -> {
boolean terminate = notifyPendingChanges();
if (terminate) {
getUserPreferences().setFrameState(((JFrame) Game.getScreenManager()).getExtendedState());
}
return terminate;
});
window.setResizable(true);
window.setMenuBar(menuBar);
if (userPreferences.getWidth() != 0 && userPreferences.getHeight() != 0) {
window.setSize(userPreferences.getWidth(), userPreferences.getHeight());
}
if (userPreferences.getFrameState() != JFrame.ICONIFIED && userPreferences.getFrameState() != JFrame.NORMAL) {
window.setExtendedState(userPreferences.getFrameState());
}
Canvas canvas = Game.getScreenManager().getRenderComponent();
canvas.setFocusable(true);
canvas.setSize((int) (window.getSize().width * 0.75), window.getSize().height);
window.remove(canvas);
JPanel renderPane = new JPanel(new BorderLayout());
renderPane.add(canvas);
renderPane.setMinimumSize(new Dimension(300, 0));
initCanvasPopupMenu(canvas);
JPanel contentPane = new JPanel(new BorderLayout());
window.setContentPane(contentPane);
horizontalScroll = new JScrollBar(JScrollBar.HORIZONTAL);
renderPane.add(horizontalScroll, BorderLayout.SOUTH);
verticalScroll = new JScrollBar(JScrollBar.VERTICAL);
renderPane.add(verticalScroll, BorderLayout.EAST);
horizontalScroll.addAdjustmentListener(e -> {
if (EditorScreen.instance().getMapComponent().isLoading()) {
return;
}
Point2D newFocus = new Point2D.Double(horizontalScroll.getValue(), Game.getCamera().getFocus().getY());
Game.getCamera().setFocus(newFocus);
});
verticalScroll.addAdjustmentListener(e -> {
if (EditorScreen.instance().getMapComponent().isLoading()) {
return;
}
Point2D newFocus = new Point2D.Double(Game.getCamera().getFocus().getX(), verticalScroll.getValue());
Game.getCamera().setFocus(newFocus);
});
MapObjectPanel mapEditorPanel = new MapObjectPanel();
MapSelectionPanel mapSelectionPanel = new MapSelectionPanel();
JSplitPane mapWrap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
mapWrap.setMinimumSize(new Dimension(300, 0));
mapWrap.setBottomComponent(mapEditorPanel);
mapWrap.setTopComponent(mapSelectionPanel);
mapWrap.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setSelectionEditSplitter(mapWrap.getDividerLocation()));
if (userPreferences.getSelectionEditSplitter() != 0) {
mapWrap.setDividerLocation(userPreferences.getSelectionEditSplitter());
}
JPanel bottomPanel = new JPanel(new BorderLayout());
JTabbedPane bottomTab = new JTabbedPane();
bottomTab.addTab(Resources.get("assettree_assets"), initAssetsComponent());
bottomTab.addTab("Console", initConsole());
bottomTab.setIconAt(0, new ImageIcon(Resources.getImage("asset.png")));
bottomTab.setIconAt(1, new ImageIcon(Resources.getImage("console.png")));
bottomPanel.add(bottomTab, BorderLayout.CENTER);
statusBar = new JLabel("");
statusBar.setPreferredSize(new Dimension(0, 16));
statusBar.setFont(new Font(ConsoleLogHandler.CONSOLE_FONT, Font.PLAIN, 10));
bottomPanel.add(statusBar, BorderLayout.SOUTH);
EditorScreen.instance().getMapComponent().onSelectionChanged(selection -> {
if (selection.isEmpty()) {
statusBar.setText("");
} else {
statusBar.setText(" " + selection.size() + " selected objects");
}
});
JSplitPane rendersplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, renderPane, bottomPanel);
if (userPreferences.getBottomSplitter() != 0) {
rendersplit.setDividerLocation(userPreferences.getBottomSplitter());
} else {
rendersplit.setDividerLocation((int) (window.getSize().height * 0.75));
}
rendersplit.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setBottomSplitter(rendersplit.getDividerLocation()));
rendersplit.setContinuousLayout(true);
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rendersplit, mapWrap);
split.setContinuousLayout(true);
split.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
userPreferences.setWidth(window.getWidth());
userPreferences.setHeight(window.getHeight());
}
});
split.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, evt -> userPreferences.setMainSplitter(split.getDividerLocation()));
contentPane.add(split, BorderLayout.CENTER);
split.setDividerLocation(userPreferences.getMainSplitterPosition() != 0 ? userPreferences.getMainSplitterPosition() : (int) (window.getSize().width * 0.75));
JToolBar toolbar = initToolBar();
contentPane.add(toolbar, BorderLayout.NORTH);
EditorScreen.instance().setMapEditorPanel(mapEditorPanel);
EditorScreen.instance().setMapSelectionPanel(mapSelectionPanel);
Menu mnFile = initFileMenu();
menuBar.add(mnFile);
Menu mnView = initViewMenu();
menuBar.add(mnView);
Menu mnProject = initProjectMenu();
menuBar.add(mnProject);
Menu mnMap = initMapMenu();
menuBar.add(mnMap);
}
use of javax.swing.JToolBar in project jgnash by ccavanaugh.
the class ExpandingAccountTablePanel method initComponents.
private void initComponents() {
accountPane = new ExpandingAccountTablePane();
JPanel toolPanel = new JPanel();
JToolBar toolBar = new JToolBar();
setLayout(new BorderLayout());
toolPanel.setLayout(new BorderLayout());
toolBar.setFloatable(false);
toolBar.setRollover(true);
newButton = new RollOverButton(rb.getString("Button.New"), IconUtils.getIcon("/jgnash/resource/document-new.png"));
newButton.setToolTipText(rb.getString("ToolTip.NewAccount"));
toolBar.add(newButton);
modifyButton = new RollOverButton(rb.getString("Button.Modify"), IconUtils.getIcon("/jgnash/resource/document-properties.png"));
modifyButton.setToolTipText(rb.getString("ToolTip.ModifyAccount"));
toolBar.add(modifyButton);
reconcileButton = new RollOverButton(rb.getString("Button.Reconcile"), IconUtils.getIcon("/jgnash/resource/view-refresh.png"));
reconcileButton.setToolTipText(rb.getString("ToolTip.ReconcileAccount"));
toolBar.add(reconcileButton);
deleteButton = new RollOverButton(rb.getString("Button.Delete"), IconUtils.getIcon("/jgnash/resource/edit-delete.png"));
deleteButton.setToolTipText(rb.getString("ToolTip.DeleteAccount"));
toolBar.add(deleteButton);
filterButton = new RollOverButton(rb.getString("Button.Filter"), IconUtils.getIcon("/jgnash/resource/preferences-system.png"));
filterButton.setToolTipText(rb.getString("ToolTip.FilterAccount"));
toolBar.add(filterButton);
zoomButton = new RollOverButton(rb.getString("Button.Zoom"), IconUtils.getIcon("/jgnash/resource/edit-find.png"));
toolBar.add(zoomButton);
toolPanel.add(toolBar, BorderLayout.NORTH);
toolPanel.add(new JSeparator(), BorderLayout.CENTER);
add(toolPanel, BorderLayout.NORTH);
accountPane.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
accountPane.setMinimumSize(new Dimension(200, 100));
accountPane.setAutoscrolls(true);
add(accountPane, BorderLayout.CENTER);
}
use of javax.swing.JToolBar in project freeplane by freeplane.
the class JToolbarComponentBuilder method visit.
@Override
public void visit(Entry entry) {
Component component = componentProvider.createComponent(entry);
if (component != null) {
final EntryAccessor entryAccessor = new EntryAccessor();
entryAccessor.setComponent(entry, component);
final AFreeplaneAction action = entryAccessor.getAction(entry);
if (action != null) {
final ActionEnabler actionEnabler = new ActionEnabler(component);
action.addPropertyChangeListener(actionEnabler);
entry.setAttribute(actionEnabler.getClass(), actionEnabler);
}
final Container container = (Container) new EntryAccessor().getAncestorComponent(entry);
if (container instanceof JToolBar)
container.add(component);
else
SwingUtilities.getAncestorOfClass(JToolBar.class, container).add(component);
}
}
Aggregations