Merge pull request #1595 from SiboVG/icons-sim-buttons
Add icons to buttons
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 912 B After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 860 B After Width: | Height: | Size: 2.1 KiB |
BIN
core/resources/pix/icons/edit-rename.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 713 B |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 906 B After Width: | Height: | Size: 1.8 KiB |
@ -83,12 +83,11 @@ public final class FlightConfigurationId implements Comparable<FlightConfigurati
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//extracted this method because maybe, just maybe, this info could be used somewhere else
|
|
||||||
/**
|
/**
|
||||||
* gets if the id is the default
|
* gets if the id is the default
|
||||||
* @return if the id is default
|
* @return if the id is default
|
||||||
*/
|
*/
|
||||||
private boolean isDefaultId() {
|
public boolean isDefaultId() {
|
||||||
return this.key == FlightConfigurationId.DEFAULT_VALUE_UUID;
|
return this.key == FlightConfigurationId.DEFAULT_VALUE_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ public class CustomExpressionPanel extends JPanel {
|
|||||||
//unitSelector = setLabelStyle(unitSelector);
|
//unitSelector = setLabelStyle(unitSelector);
|
||||||
//unitSelector.setBackground(Color.WHITE);
|
//unitSelector.setBackground(Color.WHITE);
|
||||||
|
|
||||||
JButton editButton = new SelectColorButton(Icons.EDIT);
|
JButton editButton = new SelectColorButton(Icons.EDIT_EDIT);
|
||||||
editButton.setToolTipText(trans.get("customExpression.Units.but.ttip.Edit"));
|
editButton.setToolTipText(trans.get("customExpression.Units.but.ttip.Edit"));
|
||||||
editButton.setBorderPainted(false);
|
editButton.setBorderPainted(false);
|
||||||
editButton.addActionListener(new ActionListener() {
|
editButton.addActionListener(new ActionListener() {
|
||||||
@ -234,7 +234,7 @@ public class CustomExpressionPanel extends JPanel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
JButton deleteButton = new SelectColorButton(Icons.DELETE);
|
JButton deleteButton = new SelectColorButton(Icons.EDIT_DELETE);
|
||||||
//// Remove this expression
|
//// Remove this expression
|
||||||
deleteButton.setToolTipText(trans.get("customExpression.Units.but.ttip.Delete"));
|
deleteButton.setToolTipText(trans.get("customExpression.Units.but.ttip.Delete"));
|
||||||
deleteButton.setBorderPainted(false);
|
deleteButton.setBorderPainted(false);
|
||||||
|
@ -62,6 +62,7 @@ import net.sf.openrocket.gui.util.Icons;
|
|||||||
import net.sf.openrocket.gui.util.OpenFileWorker;
|
import net.sf.openrocket.gui.util.OpenFileWorker;
|
||||||
import net.sf.openrocket.gui.util.SaveFileWorker;
|
import net.sf.openrocket.gui.util.SaveFileWorker;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||||
|
import net.sf.openrocket.gui.widgets.IconButton;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.logging.Markers;
|
import net.sf.openrocket.logging.Markers;
|
||||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
|
@ -4,9 +4,8 @@ import net.miginfocom.swing.MigLayout;
|
|||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
|
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
|
||||||
import net.sf.openrocket.gui.main.componenttree.ComponentTree;
|
import net.sf.openrocket.gui.main.componenttree.ComponentTree;
|
||||||
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
import net.sf.openrocket.gui.widgets.IconButton;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||||
import net.sf.openrocket.rocketcomponent.PodSet;
|
import net.sf.openrocket.rocketcomponent.PodSet;
|
||||||
@ -23,6 +22,7 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.JSplitPane;
|
import javax.swing.JSplitPane;
|
||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.ScrollPaneConstants;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
import javax.swing.event.TreeSelectionEvent;
|
import javax.swing.event.TreeSelectionEvent;
|
||||||
@ -183,24 +183,31 @@ public class DesignPanel extends JSplitPane {
|
|||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
JButton button = new SelectColorButton(parent.getRocketActions().getMoveUpAction());
|
JButton button = new IconButton();
|
||||||
|
button.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
|
RocketActions.tieActionToButton(button, parent.getRocketActions().getMoveUpAction());
|
||||||
panel.add(button, "sizegroup buttons, aligny 65%");
|
panel.add(button, "sizegroup buttons, aligny 65%");
|
||||||
|
|
||||||
button = new SelectColorButton(parent.getRocketActions().getMoveDownAction());
|
button = new IconButton();
|
||||||
|
button.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
|
RocketActions.tieActionToButton(button, parent.getRocketActions().getMoveDownAction());
|
||||||
panel.add(button, "sizegroup buttons, aligny 0%");
|
panel.add(button, "sizegroup buttons, aligny 0%");
|
||||||
|
|
||||||
button = new SelectColorButton(parent.getRocketActions().getEditAction());
|
button = new IconButton();
|
||||||
button.setIcon(null);
|
button.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
|
RocketActions.tieActionToButton(button, parent.getRocketActions().getEditAction());
|
||||||
button.setMnemonic(0);
|
button.setMnemonic(0);
|
||||||
panel.add(button, "sizegroup buttons, gaptop 20%");
|
panel.add(button, "sizegroup buttons, gaptop 20%");
|
||||||
|
|
||||||
button = new SelectColorButton(parent.getRocketActions().getDuplicateAction());
|
button = new IconButton();
|
||||||
button.setIcon(null);
|
button.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
|
RocketActions.tieActionToButton(button, parent.getRocketActions().getDuplicateAction());
|
||||||
button.setMnemonic(0);
|
button.setMnemonic(0);
|
||||||
panel.add(button, "sizegroup buttons");
|
panel.add(button, "sizegroup buttons");
|
||||||
|
|
||||||
button = new SelectColorButton(parent.getRocketActions().getDeleteAction());
|
button = new IconButton();
|
||||||
button.setIcon(null);
|
button.setHorizontalAlignment(SwingConstants.LEFT);
|
||||||
|
RocketActions.tieActionToButton(button, parent.getRocketActions().getDeleteAction());
|
||||||
button.setMnemonic(0);
|
button.setMnemonic(0);
|
||||||
panel.add(button, "sizegroup buttons");
|
panel.add(button, "sizegroup buttons");
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ import net.sf.openrocket.gui.main.flightconfigpanel.FlightConfigurablePanel;
|
|||||||
import net.sf.openrocket.gui.main.flightconfigpanel.MotorConfigurationPanel;
|
import net.sf.openrocket.gui.main.flightconfigpanel.MotorConfigurationPanel;
|
||||||
import net.sf.openrocket.gui.main.flightconfigpanel.RecoveryConfigurationPanel;
|
import net.sf.openrocket.gui.main.flightconfigpanel.RecoveryConfigurationPanel;
|
||||||
import net.sf.openrocket.gui.main.flightconfigpanel.SeparationConfigurationPanel;
|
import net.sf.openrocket.gui.main.flightconfigpanel.SeparationConfigurationPanel;
|
||||||
|
import net.sf.openrocket.gui.util.Icons;
|
||||||
|
import net.sf.openrocket.gui.widgets.IconButton;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurableComponent;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurableComponent;
|
||||||
@ -36,7 +38,6 @@ import net.sf.openrocket.rocketvisitors.ListComponents;
|
|||||||
import net.sf.openrocket.rocketvisitors.ListMotorMounts;
|
import net.sf.openrocket.rocketvisitors.ListMotorMounts;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class FlightConfigurationPanel extends JPanel implements StateChangeListener {
|
public class FlightConfigurationPanel extends JPanel implements StateChangeListener {
|
||||||
@ -98,19 +99,23 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
tabs.add(trans.get("edtmotorconfdlg.lbl.Stagetab"), separationConfigurationPanel);
|
tabs.add(trans.get("edtmotorconfdlg.lbl.Stagetab"), separationConfigurationPanel);
|
||||||
|
|
||||||
//// New configuration
|
//// New configuration
|
||||||
newConfButton = new SelectColorButton(newConfigAction);
|
newConfButton = new IconButton();
|
||||||
|
RocketActions.tieActionToButton(newConfButton, newConfigAction);
|
||||||
this.add(newConfButton,"skip 1,gapright para");
|
this.add(newConfButton,"skip 1,gapright para");
|
||||||
|
|
||||||
//// Rename configuration
|
//// Rename configuration
|
||||||
renameConfButton = new SelectColorButton(renameConfigAction);
|
renameConfButton = new IconButton();
|
||||||
|
RocketActions.tieActionToButton(renameConfButton, renameConfigAction);
|
||||||
this.add(renameConfButton,"gapright para");
|
this.add(renameConfButton,"gapright para");
|
||||||
|
|
||||||
//// Remove configuration
|
//// Remove configuration
|
||||||
removeConfButton = new SelectColorButton(deleteConfigAction);
|
removeConfButton = new IconButton();
|
||||||
|
RocketActions.tieActionToButton(removeConfButton, deleteConfigAction);
|
||||||
this.add(removeConfButton,"gapright para");
|
this.add(removeConfButton,"gapright para");
|
||||||
|
|
||||||
//// Duplicate configuration
|
//// Duplicate configuration
|
||||||
duplicateConfButton = new SelectColorButton(duplicateConfigAction);
|
duplicateConfButton = new IconButton();
|
||||||
|
RocketActions.tieActionToButton(duplicateConfButton, duplicateConfigAction);
|
||||||
this.add(duplicateConfButton, "wrap");
|
this.add(duplicateConfButton, "wrap");
|
||||||
|
|
||||||
tabs.addChangeListener(new ChangeListener() {
|
tabs.addChangeListener(new ChangeListener() {
|
||||||
@ -275,9 +280,10 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
private void updateButtonState() {
|
private void updateButtonState() {
|
||||||
FlightConfigurationId currentId = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
FlightConfigurationId currentId = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
||||||
// Enable the remove/rename/duplicate buttons only when a configuration is selected.
|
// Enable the remove/rename/duplicate buttons only when a configuration is selected.
|
||||||
removeConfButton.setEnabled(currentId.isValid());
|
boolean enabled = currentId.isValid() && !currentId.isDefaultId();
|
||||||
renameConfButton.setEnabled(currentId.isValid());
|
removeConfButton.setEnabled(enabled);
|
||||||
duplicateConfButton.setEnabled(currentId.isValid());
|
renameConfButton.setEnabled(enabled);
|
||||||
|
duplicateConfButton.setEnabled(enabled);
|
||||||
|
|
||||||
// Count the number of motor mounts
|
// Count the number of motor mounts
|
||||||
int motorMountCount = rocket.accept(new ListMotorMounts()).size();
|
int motorMountCount = rocket.accept(new ListMotorMounts()).size();
|
||||||
@ -353,6 +359,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
private class NewConfigAction extends AbstractAction {
|
private class NewConfigAction extends AbstractAction {
|
||||||
public NewConfigAction() {
|
public NewConfigAction() {
|
||||||
putValue(NAME, trans.get("edtmotorconfdlg.but.Newconfiguration"));
|
putValue(NAME, trans.get("edtmotorconfdlg.but.Newconfiguration"));
|
||||||
|
putValue(LARGE_ICON_KEY, Icons.FILE_NEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -364,6 +371,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
private class RenameConfigAction extends AbstractAction {
|
private class RenameConfigAction extends AbstractAction {
|
||||||
public RenameConfigAction() {
|
public RenameConfigAction() {
|
||||||
putValue(NAME, trans.get("edtmotorconfdlg.but.Renameconfiguration"));
|
putValue(NAME, trans.get("edtmotorconfdlg.but.Renameconfiguration"));
|
||||||
|
putValue(SMALL_ICON, Icons.EDIT_RENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -375,6 +383,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
private class DeleteConfigAction extends AbstractAction {
|
private class DeleteConfigAction extends AbstractAction {
|
||||||
public DeleteConfigAction() {
|
public DeleteConfigAction() {
|
||||||
putValue(NAME, trans.get("edtmotorconfdlg.but.Deleteconfiguration"));
|
putValue(NAME, trans.get("edtmotorconfdlg.but.Deleteconfiguration"));
|
||||||
|
putValue(SMALL_ICON, Icons.EDIT_DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -386,6 +395,7 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
private class DuplicateConfigAction extends AbstractAction {
|
private class DuplicateConfigAction extends AbstractAction {
|
||||||
public DuplicateConfigAction() {
|
public DuplicateConfigAction() {
|
||||||
putValue(NAME, trans.get("edtmotorconfdlg.but.Duplicateconfiguration"));
|
putValue(NAME, trans.get("edtmotorconfdlg.but.Duplicateconfiguration"));
|
||||||
|
putValue(SMALL_ICON, Icons.EDIT_DUPLICATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,6 +25,7 @@ import net.sf.openrocket.gui.components.StyledLabel;
|
|||||||
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
|
import net.sf.openrocket.gui.configdialog.ComponentConfigDialog;
|
||||||
import net.sf.openrocket.gui.dialogs.ScaleDialog;
|
import net.sf.openrocket.gui.dialogs.ScaleDialog;
|
||||||
import net.sf.openrocket.gui.util.Icons;
|
import net.sf.openrocket.gui.util.Icons;
|
||||||
|
import net.sf.openrocket.gui.widgets.IconButton;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.logging.Markers;
|
import net.sf.openrocket.logging.Markers;
|
||||||
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
import net.sf.openrocket.rocketcomponent.ComponentChangeEvent;
|
||||||
@ -75,7 +76,6 @@ public class RocketActions {
|
|||||||
private final RocketAction duplicateAction;
|
private final RocketAction duplicateAction;
|
||||||
private final RocketAction editAction;
|
private final RocketAction editAction;
|
||||||
private final RocketAction scaleAction;
|
private final RocketAction scaleAction;
|
||||||
private final RocketAction newStageAction;
|
|
||||||
private final RocketAction moveUpAction;
|
private final RocketAction moveUpAction;
|
||||||
private final RocketAction moveDownAction;
|
private final RocketAction moveDownAction;
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
@ -100,7 +100,6 @@ public class RocketActions {
|
|||||||
this.duplicateAction = new DuplicateAction();
|
this.duplicateAction = new DuplicateAction();
|
||||||
this.editAction = new EditAction();
|
this.editAction = new EditAction();
|
||||||
this.scaleAction = new ScaleAction();
|
this.scaleAction = new ScaleAction();
|
||||||
this.newStageAction = new NewStageAction();
|
|
||||||
this.moveUpAction = new MoveUpAction();
|
this.moveUpAction = new MoveUpAction();
|
||||||
this.moveDownAction = new MoveDownAction();
|
this.moveDownAction = new MoveDownAction();
|
||||||
|
|
||||||
@ -134,7 +133,6 @@ public class RocketActions {
|
|||||||
duplicateAction.clipboardChanged();
|
duplicateAction.clipboardChanged();
|
||||||
editAction.clipboardChanged();
|
editAction.clipboardChanged();
|
||||||
scaleAction.clipboardChanged();
|
scaleAction.clipboardChanged();
|
||||||
newStageAction.clipboardChanged();
|
|
||||||
moveUpAction.clipboardChanged();
|
moveUpAction.clipboardChanged();
|
||||||
moveDownAction.clipboardChanged();
|
moveDownAction.clipboardChanged();
|
||||||
}
|
}
|
||||||
@ -178,10 +176,6 @@ public class RocketActions {
|
|||||||
return scaleAction;
|
return scaleAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action getNewStageAction() {
|
|
||||||
return newStageAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action getMoveUpAction() {
|
public Action getMoveUpAction() {
|
||||||
return moveUpAction;
|
return moveUpAction;
|
||||||
}
|
}
|
||||||
@ -219,6 +213,34 @@ public class RocketActions {
|
|||||||
button.setAction(action);
|
button.setAction(action);
|
||||||
button.setIcon(null);
|
button.setIcon(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tie an action to a JButton, without using the text of the action for the button.
|
||||||
|
*
|
||||||
|
* For any smartass that wants to know why you don't just initialize the JButton with the action:
|
||||||
|
* this causes a bug where the text of the icon becomes much smaller than is intended.
|
||||||
|
*
|
||||||
|
* @param button button to tie the action to
|
||||||
|
* @param action action to tie to the button
|
||||||
|
* @param text text to display on the button
|
||||||
|
*/
|
||||||
|
public static void tieActionToButton(JButton button, Action action, String text) {
|
||||||
|
button.setAction(action);
|
||||||
|
button.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tie an action to a JButton.
|
||||||
|
*
|
||||||
|
* For any smartass that wants to know why you don't just initialize the JButton with the action:
|
||||||
|
* this causes a bug where the text of the icon becomes much smaller than is intended.
|
||||||
|
*
|
||||||
|
* @param button button to tie the action to
|
||||||
|
* @param action action to tie to the button
|
||||||
|
*/
|
||||||
|
public static void tieActionToButton(JButton button, Action action) {
|
||||||
|
button.setAction(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////// Helper methods for the actions
|
//////// Helper methods for the actions
|
||||||
@ -1009,46 +1031,6 @@ public class RocketActions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action to add a new stage to the rocket.
|
|
||||||
*/
|
|
||||||
private class NewStageAction extends RocketAction {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public NewStageAction() {
|
|
||||||
//// New stage
|
|
||||||
this.putValue(NAME, trans.get("RocketActions.NewStageAct.Newstage"));
|
|
||||||
//// Add a new stage to the rocket design.
|
|
||||||
this.putValue(SHORT_DESCRIPTION, trans.get("RocketActions.NewStageAct.Newstage"));
|
|
||||||
clipboardChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
|
|
||||||
ComponentConfigDialog.disposeDialog();
|
|
||||||
|
|
||||||
RocketComponent stage = new AxialStage();
|
|
||||||
|
|
||||||
//// Add stage
|
|
||||||
document.addUndoPosition("Add stage");
|
|
||||||
rocket.addChild(stage);
|
|
||||||
rocket.getSelectedConfiguration().setAllStages();
|
|
||||||
selectionModel.setSelectedComponent(stage);
|
|
||||||
ComponentConfigDialog.showDialog(parentFrame, document, stage);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clipboardChanged() {
|
|
||||||
this.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1061,6 +1043,7 @@ public class RocketActions {
|
|||||||
public MoveUpAction() {
|
public MoveUpAction() {
|
||||||
//// Move up
|
//// Move up
|
||||||
this.putValue(NAME, trans.get("RocketActions.MoveUpAct.Moveup"));
|
this.putValue(NAME, trans.get("RocketActions.MoveUpAct.Moveup"));
|
||||||
|
this.putValue(SMALL_ICON, Icons.UP);
|
||||||
//// Move this component upwards.
|
//// Move this component upwards.
|
||||||
this.putValue(SHORT_DESCRIPTION, trans.get("RocketActions.MoveUpAct.ttip.Moveup"));
|
this.putValue(SHORT_DESCRIPTION, trans.get("RocketActions.MoveUpAct.ttip.Moveup"));
|
||||||
clipboardChanged();
|
clipboardChanged();
|
||||||
@ -1136,6 +1119,7 @@ public class RocketActions {
|
|||||||
public MoveDownAction() {
|
public MoveDownAction() {
|
||||||
//// Move down
|
//// Move down
|
||||||
this.putValue(NAME, trans.get("RocketActions.MoveDownAct.Movedown"));
|
this.putValue(NAME, trans.get("RocketActions.MoveDownAct.Movedown"));
|
||||||
|
this.putValue(SMALL_ICON, Icons.DOWN);
|
||||||
//// Move this component downwards.
|
//// Move this component downwards.
|
||||||
this.putValue(SHORT_DESCRIPTION, trans.get("RocketActions.MoveDownAct.ttip.Movedown"));
|
this.putValue(SHORT_DESCRIPTION, trans.get("RocketActions.MoveDownAct.ttip.Movedown"));
|
||||||
clipboardChanged();
|
clipboardChanged();
|
||||||
|
@ -10,7 +10,6 @@ import java.awt.datatransfer.StringSelection;
|
|||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.InputEvent;
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
@ -38,6 +37,7 @@ import javax.swing.event.ListSelectionEvent;
|
|||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
|
||||||
|
import net.sf.openrocket.gui.widgets.IconButton;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -71,7 +71,6 @@ import net.sf.openrocket.startup.Application;
|
|||||||
import net.sf.openrocket.startup.Preferences;
|
import net.sf.openrocket.startup.Preferences;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
import net.sf.openrocket.util.AlphanumComparator;
|
import net.sf.openrocket.util.AlphanumComparator;
|
||||||
import net.sf.openrocket.gui.widgets.SelectColorButton;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class SimulationPanel extends JPanel {
|
public class SimulationPanel extends JPanel {
|
||||||
@ -126,32 +125,32 @@ public class SimulationPanel extends JPanel {
|
|||||||
//////// The simulation action buttons ////////
|
//////// The simulation action buttons ////////
|
||||||
|
|
||||||
//// New simulation button
|
//// New simulation button
|
||||||
JButton newButton = new SelectColorButton();
|
JButton newButton = new IconButton();
|
||||||
RocketActions.tieActionToButtonNoIcon(newButton, newSimulationAction, trans.get("simpanel.but.newsimulation"));
|
RocketActions.tieActionToButton(newButton, newSimulationAction, trans.get("simpanel.but.newsimulation"));
|
||||||
newButton.setToolTipText(trans.get("simpanel.but.ttip.newsimulation"));
|
newButton.setToolTipText(trans.get("simpanel.but.ttip.newsimulation"));
|
||||||
this.add(newButton, "skip 1, gapright para");
|
this.add(newButton, "skip 1, gapright para");
|
||||||
|
|
||||||
//// Edit simulation button
|
//// Edit simulation button
|
||||||
editButton = new SelectColorButton();
|
editButton = new IconButton();
|
||||||
RocketActions.tieActionToButtonNoIcon(editButton, editSimulationAction, trans.get("simpanel.but.editsimulation"));
|
RocketActions.tieActionToButton(editButton, editSimulationAction, trans.get("simpanel.but.editsimulation"));
|
||||||
editButton.setToolTipText(trans.get("simpanel.but.ttip.editsim"));
|
editButton.setToolTipText(trans.get("simpanel.but.ttip.editsim"));
|
||||||
this.add(editButton, "gapright para");
|
this.add(editButton, "gapright para");
|
||||||
|
|
||||||
//// Run simulations
|
//// Run simulations
|
||||||
runButton = new SelectColorButton();
|
runButton = new IconButton();
|
||||||
RocketActions.tieActionToButtonNoIcon(runButton, runSimulationAction, trans.get("simpanel.but.runsimulations"));
|
RocketActions.tieActionToButton(runButton, runSimulationAction, trans.get("simpanel.but.runsimulations"));
|
||||||
runButton.setToolTipText(trans.get("simpanel.but.ttip.runsimu"));
|
runButton.setToolTipText(trans.get("simpanel.but.ttip.runsimu"));
|
||||||
this.add(runButton, "gapright para");
|
this.add(runButton, "gapright para");
|
||||||
|
|
||||||
//// Delete simulations button
|
//// Delete simulations button
|
||||||
deleteButton = new SelectColorButton();
|
deleteButton = new IconButton();
|
||||||
RocketActions.tieActionToButtonNoIcon(deleteButton, deleteSimulationAction, trans.get("simpanel.but.deletesimulations"));
|
RocketActions.tieActionToButton(deleteButton, deleteSimulationAction, trans.get("simpanel.but.deletesimulations"));
|
||||||
deleteButton.setToolTipText(trans.get("simpanel.but.ttip.deletesim"));
|
deleteButton.setToolTipText(trans.get("simpanel.but.ttip.deletesim"));
|
||||||
this.add(deleteButton, "gapright para");
|
this.add(deleteButton, "gapright para");
|
||||||
|
|
||||||
//// Plot / export button
|
//// Plot / export button
|
||||||
plotButton = new SelectColorButton();
|
plotButton = new IconButton();
|
||||||
RocketActions.tieActionToButtonNoIcon(plotButton, plotSimulationAction, trans.get("simpanel.but.plotexport"));
|
RocketActions.tieActionToButton(plotButton, plotSimulationAction, trans.get("simpanel.but.plotexport"));
|
||||||
this.add(plotButton, "wrap para");
|
this.add(plotButton, "wrap para");
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ class SimulationOptionsPanel extends JPanel {
|
|||||||
this.add(button, "right");
|
this.add(button, "right");
|
||||||
}
|
}
|
||||||
|
|
||||||
button = new SelectColorButton(Icons.DELETE);
|
button = new SelectColorButton(Icons.EDIT_DELETE);
|
||||||
button.addActionListener(new ActionListener() {
|
button.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
@ -464,7 +464,7 @@ public class SimulationPlotPanel extends JPanel {
|
|||||||
this.add(axisSelector);
|
this.add(axisSelector);
|
||||||
|
|
||||||
|
|
||||||
JButton button = new SelectColorButton(Icons.DELETE);
|
JButton button = new SelectColorButton(Icons.EDIT_DELETE);
|
||||||
//// Remove this plot
|
//// Remove this plot
|
||||||
button.setToolTipText(trans.get("simplotpanel.but.ttip.Deletethisplot"));
|
button.setToolTipText(trans.get("simplotpanel.but.ttip.Deletethisplot"));
|
||||||
button.setBorderPainted(false);
|
button.setBorderPainted(false);
|
||||||
|
@ -7,6 +7,9 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Image;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -59,6 +62,7 @@ public class Icons {
|
|||||||
public static final Icon EDIT_UNDO = loadImageIcon("pix/icons/edit-undo.png", trans.get("Icons.Undo"));
|
public static final Icon EDIT_UNDO = loadImageIcon("pix/icons/edit-undo.png", trans.get("Icons.Undo"));
|
||||||
public static final Icon EDIT_REDO = loadImageIcon("pix/icons/edit-redo.png", trans.get("Icons.Redo"));
|
public static final Icon EDIT_REDO = loadImageIcon("pix/icons/edit-redo.png", trans.get("Icons.Redo"));
|
||||||
public static final Icon EDIT_EDIT = loadImageIcon("pix/icons/edit-edit.png", "Edit");
|
public static final Icon EDIT_EDIT = loadImageIcon("pix/icons/edit-edit.png", "Edit");
|
||||||
|
public static final Icon EDIT_RENAME = loadImageIcon("pix/icons/edit-rename.png", "Rename");
|
||||||
public static final Icon EDIT_CUT = loadImageIcon("pix/icons/edit-cut.png", "Cut");
|
public static final Icon EDIT_CUT = loadImageIcon("pix/icons/edit-cut.png", "Cut");
|
||||||
public static final Icon EDIT_COPY = loadImageIcon("pix/icons/edit-copy.png", "Copy");
|
public static final Icon EDIT_COPY = loadImageIcon("pix/icons/edit-copy.png", "Copy");
|
||||||
public static final Icon EDIT_PASTE = loadImageIcon("pix/icons/edit-paste.png", "Paste");
|
public static final Icon EDIT_PASTE = loadImageIcon("pix/icons/edit-paste.png", "Paste");
|
||||||
@ -81,8 +85,6 @@ public class Icons {
|
|||||||
|
|
||||||
public static final Icon PREFERENCES = loadImageIcon("pix/icons/preferences.png", "Preferences");
|
public static final Icon PREFERENCES = loadImageIcon("pix/icons/preferences.png", "Preferences");
|
||||||
|
|
||||||
public static final Icon DELETE = loadImageIcon("pix/icons/delete.png", "Delete");
|
|
||||||
public static final Icon EDIT = loadImageIcon("pix/icons/pencil.png", "Edit");
|
|
||||||
public static final Icon CONFIGURE = loadImageIcon("pix/icons/configure.png", "Configure");
|
public static final Icon CONFIGURE = loadImageIcon("pix/icons/configure.png", "Configure");
|
||||||
public static final Icon HELP = loadImageIcon("pix/icons/help-about.png", "Help");
|
public static final Icon HELP = loadImageIcon("pix/icons/help-about.png", "Help");
|
||||||
public static final Icon UP = loadImageIcon("pix/icons/up.png", "Up");
|
public static final Icon UP = loadImageIcon("pix/icons/up.png", "Up");
|
||||||
@ -124,4 +126,33 @@ public class Icons {
|
|||||||
}
|
}
|
||||||
return new ImageIcon(url, name);
|
return new ImageIcon(url, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scales an ImageIcon to the specified scale.
|
||||||
|
* @param icon icon to scale
|
||||||
|
* @param scale the scale to scale to (1 = no scale, < 1 = smaller, > 1 = bigger)
|
||||||
|
* @return scaled down icon. If <icon> is not an ImageIcon, the original icon is returned.
|
||||||
|
*/
|
||||||
|
public static Icon getScaledIcon(Icon icon, final double scale) {
|
||||||
|
if (!(icon instanceof ImageIcon)) {
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
final Image image = ((ImageIcon) icon).getImage();
|
||||||
|
return new ImageIcon(image) {
|
||||||
|
@Override
|
||||||
|
public int getIconWidth() {
|
||||||
|
return (int)(image.getWidth(null) * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIconHeight() {
|
||||||
|
return (int)(image.getHeight(null) * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||||
|
g.drawImage(image, x, y, getIconWidth(), getIconHeight(), c);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
70
swing/src/net/sf/openrocket/gui/widgets/IconButton.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package net.sf.openrocket.gui.widgets;
|
||||||
|
|
||||||
|
import net.sf.openrocket.gui.util.Icons;
|
||||||
|
|
||||||
|
import javax.swing.Action;
|
||||||
|
import javax.swing.Icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Button specifically for displaying an icon.
|
||||||
|
*
|
||||||
|
* @author Sibo Van Gool <sibo.vangool@hotmail.com>
|
||||||
|
*/
|
||||||
|
public class IconButton extends SelectColorButton {
|
||||||
|
private static final int ICON_GAP = 10;
|
||||||
|
private static final double ICON_SCALE = 0.9;
|
||||||
|
|
||||||
|
public IconButton() {
|
||||||
|
setIconTextGap(ICON_GAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IconButton(Icon icon) {
|
||||||
|
super(icon);
|
||||||
|
setIconTextGap(ICON_GAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IconButton(String text) {
|
||||||
|
super(text);
|
||||||
|
setIconTextGap(ICON_GAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IconButton(Action a) {
|
||||||
|
super(a);
|
||||||
|
setIconTextGap(ICON_GAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IconButton(String text, Icon icon) {
|
||||||
|
super(text, icon);
|
||||||
|
setIconTextGap(ICON_GAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getIcon() {
|
||||||
|
return Icons.getScaledIcon(super.getIcon(), IconButton.ICON_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getSelectedIcon() {
|
||||||
|
return Icons.getScaledIcon(super.getSelectedIcon(), IconButton.ICON_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getDisabledIcon() {
|
||||||
|
return Icons.getScaledIcon(super.getDisabledIcon(), IconButton.ICON_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getDisabledSelectedIcon() {
|
||||||
|
return Icons.getScaledIcon(super.getDisabledSelectedIcon(), IconButton.ICON_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getRolloverIcon() {
|
||||||
|
return Icons.getScaledIcon(super.getRolloverIcon(), IconButton.ICON_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Icon getRolloverSelectedIcon() {
|
||||||
|
return Icons.getScaledIcon(super.getRolloverSelectedIcon(), IconButton.ICON_SCALE);
|
||||||
|
}
|
||||||
|
}
|