use of jmri.util.iharder.dnd.FileDrop in project JMRI by JMRI.
the class AppsLaunchPane method setJynstrumentSpace.
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only one application at a time")
protected void setJynstrumentSpace() {
_jynstrumentSpace = new JPanel();
_jynstrumentSpace.setLayout(new FlowLayout());
new FileDrop(_jynstrumentSpace, new Listener() {
@Override
public void filesDropped(File[] files) {
for (int i = 0; i < files.length; i++) {
ynstrument(files[i].getPath());
}
}
});
}
use of jmri.util.iharder.dnd.FileDrop in project JMRI by JMRI.
the class ThrottleFrame method initGUI.
/**
* Place and initialize the GUI elements.
* <ul>
* <li> ControlPanel
* <li> FunctionPanel
* <li> AddressPanel
* <li> JMenu
* </ul>
*
*/
private void initGUI() {
frameListener = new FrameListener();
controlPanel = new ControlPanel();
controlPanel.setResizable(true);
controlPanel.setClosable(true);
controlPanel.setIconifiable(true);
controlPanel.setTitle(Bundle.getMessage("ThrottleMenuViewControlPanel"));
controlPanel.pack();
controlPanel.setVisible(true);
controlPanel.setEnabled(false);
controlPanel.addInternalFrameListener(frameListener);
functionPanel = new FunctionPanel();
functionPanel.setResizable(true);
functionPanel.setClosable(true);
functionPanel.setIconifiable(true);
functionPanel.setTitle(Bundle.getMessage("ThrottleMenuViewFunctionPanel"));
// assumes button width of 54, height of 30 (set in class FunctionButton) with
// horiz and vert gaps of 5 each (set in FunctionPanel class)
// with 3 buttons across and 6 rows high
// = 192
int width = 3 * (FunctionButton.BUT_WDTH) + 2 * 3 * 5 + 10;
// = 240 (but there seems to be another 10 needed for some LAFs)
int height = 6 * (FunctionButton.BUT_HGHT) + 2 * 6 * 5 + 20;
if (jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingExThrottle() && jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingFunctionIcon()) {
width = FunctionButton.BUT_WDTH * 3 + 2 * 3 * 5 + 10;
height = FunctionButton.BUT_IMG_SIZE * 2 + FunctionButton.BUT_HGHT * 4 + 2 * 6 * 5 + 20;
}
functionPanel.setSize(width, height);
functionPanel.setLocation(controlPanel.getWidth(), 0);
functionPanel.setVisible(true);
functionPanel.setEnabled(false);
functionPanel.addInternalFrameListener(frameListener);
addressPanel = new AddressPanel();
addressPanel.setResizable(true);
addressPanel.setClosable(true);
addressPanel.setIconifiable(true);
addressPanel.setTitle(Bundle.getMessage("ThrottleMenuViewAddressPanel"));
addressPanel.pack();
// if (addressPanel.getWidth()<functionPanel.getWidth()) {addressPanel.setSize(functionPanel.getWidth(),addressPanel.getHeight());}
addressPanel.setLocation(controlPanel.getWidth(), functionPanel.getHeight());
addressPanel.setVisible(true);
addressPanel.addInternalFrameListener(frameListener);
// so the function panel can get access to the roster
functionPanel.setAddressPanel(addressPanel);
controlPanel.setAddressPanel(addressPanel);
if (controlPanel.getHeight() < functionPanel.getHeight() + addressPanel.getHeight()) {
controlPanel.setSize(controlPanel.getWidth(), functionPanel.getHeight() + addressPanel.getHeight());
}
if (controlPanel.getHeight() > functionPanel.getHeight() + addressPanel.getHeight()) {
addressPanel.setSize(addressPanel.getWidth(), controlPanel.getHeight() - functionPanel.getHeight());
}
if (!(jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingExThrottle() && jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingFunctionIcon()) && (functionPanel.getWidth() < addressPanel.getWidth())) {
functionPanel.setSize(addressPanel.getWidth(), functionPanel.getHeight());
}
addressPanel.addAddressListener(controlPanel);
addressPanel.addAddressListener(functionPanel);
addressPanel.addAddressListener(this);
addressPanel.addAddressListener(jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesListPanel().getTableModel());
add(controlPanel, PANEL_LAYER_FRAME);
add(functionPanel, PANEL_LAYER_FRAME);
add(addressPanel, PANEL_LAYER_FRAME);
if (jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingExThrottle()) {
/* if ( jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingTransparentCtl() ) {
setTransparent(functionPanel);
setTransparent(addressPanel);
setTransparent(controlPanel);
}*/
if (jmri.jmrit.throttle.ThrottleFrameManager.instance().getThrottlesPreferences().isUsingRosterImage()) {
backgroundPanel = new BackgroundPanel();
// reusing same way to do it than existing thing in functionPanel
backgroundPanel.setAddressPanel(addressPanel);
// backgroudPanel warned when desktop resized
addComponentListener(backgroundPanel);
addressPanel.addAddressListener(backgroundPanel);
// so that it's changeable when browsing through rosters
addressPanel.setBackgroundPanel(backgroundPanel);
add(backgroundPanel, BACKPANEL_LAYER);
}
// to force sub windows repositionning
addComponentListener(this);
}
frameList = new JInternalFrame[NUM_FRAMES];
frameList[ADDRESS_PANEL_INDEX] = addressPanel;
frameList[CONTROL_PANEL_INDEX] = controlPanel;
frameList[FUNCTION_PANEL_INDEX] = functionPanel;
activeFrame = ADDRESS_PANEL_INDEX;
setPreferredSize(new Dimension(Math.max(controlPanel.getWidth() + functionPanel.getWidth(), controlPanel.getWidth() + addressPanel.getWidth()), Math.max(addressPanel.getHeight() + functionPanel.getHeight(), controlPanel.getHeight())));
// #JYNSTRUMENT# Bellow prepare drag'n drop receptacle:
new FileDrop(this, new Listener() {
@Override
public void filesDropped(File[] files) {
if (isEditMode) {
for (int i = 0; i < files.length; i++) {
ynstrument(files[i].getPath());
}
}
}
});
KeyListenerInstaller.installKeyListenerOnAllComponents(new FrameCyclingKeyListener(), this);
try {
addressPanel.setSelected(true);
} catch (java.beans.PropertyVetoException ex) {
log.error("Error selecting InternalFrame:" + ex);
}
}
use of jmri.util.iharder.dnd.FileDrop in project JMRI by JMRI.
the class ThrottleWindow method initializeToolbar.
private void initializeToolbar() {
throttleToolBar = new JToolBar("Throttles toolbar");
jbNew = new JButton();
// nouveau.setText(Bundle.getMessage("ThrottleToolBarNew"));
jbNew.setIcon(new NamedIcon("resources/icons/throttles/add.png", "resources/icons/throttles/add.png"));
jbNew.setToolTipText(Bundle.getMessage("ThrottleToolBarNewToolTip"));
jbNew.setVerticalTextPosition(JButton.BOTTOM);
jbNew.setHorizontalTextPosition(JButton.CENTER);
jbNew.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addThrottleFrame();
}
});
throttleToolBar.add(jbNew);
jbClose = new JButton();
// close.setText(Bundle.getMessage("ThrottleToolBarClose"));
jbClose.setIcon(new NamedIcon("resources/icons/throttles/remove.png", "resources/icons/throttles/remove.png"));
jbClose.setToolTipText(Bundle.getMessage("ThrottleToolBarCloseToolTip"));
jbClose.setVerticalTextPosition(JButton.BOTTOM);
jbClose.setHorizontalTextPosition(JButton.CENTER);
jbClose.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeThrottleFrame();
}
});
throttleToolBar.add(jbClose);
throttleToolBar.addSeparator();
jbPreviousRunning = new JButton();
jbPreviousRunning.setIcon(new NamedIcon("resources/icons/throttles/previous-jump.png", "resources/icons/throttles/previous-jump.png"));
jbPreviousRunning.setVerticalTextPosition(JButton.BOTTOM);
jbPreviousRunning.setHorizontalTextPosition(JButton.CENTER);
jbPreviousRunning.setToolTipText(Bundle.getMessage("ThrottleToolBarPrevRunToolTip"));
jbPreviousRunning.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
previousRunningThrottleFrame();
}
});
throttleToolBar.add(jbPreviousRunning);
jbPrevious = new JButton();
jbPrevious.setIcon(new NamedIcon("resources/icons/throttles/previous.png", "resources/icons/throttles/previous.png"));
jbPrevious.setVerticalTextPosition(JButton.BOTTOM);
jbPrevious.setHorizontalTextPosition(JButton.CENTER);
jbPrevious.setToolTipText(Bundle.getMessage("ThrottleToolBarPrevToolTip"));
jbPrevious.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
previousThrottleFrame();
}
});
throttleToolBar.add(jbPrevious);
jbNext = new JButton();
// next.setText(Bundle.getMessage("ThrottleToolBarNext"));
jbNext.setIcon(new NamedIcon("resources/icons/throttles/next.png", "resources/icons/throttles/next.png"));
jbNext.setToolTipText(Bundle.getMessage("ThrottleToolBarNextToolTip"));
jbNext.setVerticalTextPosition(JButton.BOTTOM);
jbNext.setHorizontalTextPosition(JButton.CENTER);
jbNext.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nextThrottleFrame();
}
});
throttleToolBar.add(jbNext);
jbNextRunning = new JButton();
jbNextRunning.setIcon(new NamedIcon("resources/icons/throttles/next-jump.png", "resources/icons/throttles/next-jump.png"));
jbNextRunning.setToolTipText(Bundle.getMessage("ThrottleToolBarNextRunToolTip"));
jbNextRunning.setVerticalTextPosition(JButton.BOTTOM);
jbNextRunning.setHorizontalTextPosition(JButton.CENTER);
jbNextRunning.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nextRunningThrottleFrame();
}
});
throttleToolBar.add(jbNextRunning);
throttleToolBar.addSeparator();
throttleToolBar.add(new StopAllButton());
if (powerMgr != null) {
throttleToolBar.add(new LargePowerManagerButton());
}
throttleToolBar.addSeparator();
jbMode = new JButton();
jbMode.setIcon(new NamedIcon("resources/icons/throttles/edit-view.png", "resources/icons/throttles/edit-view.png"));
jbMode.setToolTipText(Bundle.getMessage("ThrottleToolBarEditToolTip"));
jbMode.setVerticalTextPosition(JButton.BOTTOM);
jbMode.setHorizontalTextPosition(JButton.CENTER);
jbMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
switchMode();
}
});
throttleToolBar.add(jbMode);
throttleToolBar.addSeparator();
jbThrottleList = new JButton();
jbThrottleList.setIcon(new NamedIcon("resources/icons/throttles/list.png", "resources/icons/throttles/list.png"));
jbThrottleList.setToolTipText(Bundle.getMessage("ThrottleToolBarOpenThrottleListToolTip"));
jbThrottleList.setVerticalTextPosition(JButton.BOTTOM);
jbThrottleList.setHorizontalTextPosition(JButton.CENTER);
jbThrottleList.addActionListener(new ThrottlesListAction());
throttleToolBar.add(jbThrottleList);
// Receptacle for Jynstruments
new FileDrop(throttleToolBar, new Listener() {
@Override
public void filesDropped(File[] files) {
for (int i = 0; i < files.length; i++) {
ynstrument(files[i].getPath());
}
}
});
add(throttleToolBar, BorderLayout.PAGE_START);
}
use of jmri.util.iharder.dnd.FileDrop in project JMRI by JMRI.
the class Apps method setJynstrumentSpace.
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only one application at a time")
protected void setJynstrumentSpace() {
_jynstrumentSpace = new JPanel();
_jynstrumentSpace.setLayout(new FlowLayout());
new FileDrop(_jynstrumentSpace, new Listener() {
@Override
public void filesDropped(File[] files) {
for (int i = 0; i < files.length; i++) {
ynstrument(files[i].getPath());
}
}
});
}
Aggregations