use of com.mucommander.ui.chooser.SizeChooser in project mucommander by mucommander.
the class ProgressDialog method initUI.
private void initUI() {
Container contentPane = getContentPane();
totalProgressBar = new JProgressBar();
totalProgressBar.setStringPainted(true);
totalProgressBar.setAlignmentX(LEFT_ALIGNMENT);
currentFileLabel = new JLabel(job.getStatusString());
currentFileLabel.setAlignmentX(LEFT_ALIGNMENT);
YBoxPanel yPanel = new YBoxPanel();
// 2 progress bars
if (transferFileJob != null) {
yPanel.add(currentFileLabel);
currentFileProgressBar = new JProgressBar();
currentFileProgressBar.setStringPainted(true);
yPanel.add(currentFileProgressBar);
yPanel.addSpace(10);
totalTransferredLabel = new JLabel(Translator.get("progress_dialog.starting"));
yPanel.add(totalTransferredLabel);
yPanel.add(totalProgressBar);
} else // Single progress bar
{
yPanel.add(currentFileLabel);
yPanel.add(totalProgressBar);
}
yPanel.addSpace(10);
elapsedTimeLabel = new JLabel(Translator.get("progress_dialog.elapsed_time") + ": ");
elapsedTimeLabel.setIcon(IconManager.getIcon(IconManager.STATUS_BAR_ICON_SET, StatusBar.WAITING_ICON));
yPanel.add(elapsedTimeLabel);
if (transferFileJob != null) {
JPanel tempPanel = new JPanel(new BorderLayout());
this.currentSpeedLabel = new JLabel();
updateCurrentSpeedLabel("");
currentSpeedLabel.setIcon(IconManager.getIcon(IconManager.PROGRESS_ICON_SET, CURRENT_SPEED_ICON));
tempPanel.add(currentSpeedLabel, BorderLayout.WEST);
YBoxPanel advancedPanel = new YBoxPanel();
this.speedGraph = new SpeedGraph();
speedGraph.setPreferredSize(new Dimension(0, SPEED_GRAPH_HEIGHT));
advancedPanel.add(speedGraph);
advancedPanel.addSpace(5);
JPanel tempPanel2 = new JPanel(new BorderLayout());
this.limitSpeedCheckBox = new JCheckBox(Translator.get("progress_dialog.limit_speed") + ":", false);
limitSpeedCheckBox.addItemListener(this);
tempPanel2.add(limitSpeedCheckBox, BorderLayout.WEST);
speedChooser = new SizeChooser(true);
speedChooser.setEnabled(false);
speedChooser.addChangeListener(this);
tempPanel2.add(speedChooser, BorderLayout.EAST);
advancedPanel.add(tempPanel2);
advancedPanel.addSpace(5);
this.collapseExpandButton = new CollapseExpandButton(Translator.get("progress_dialog.advanced"), advancedPanel, true);
collapseExpandButton.setExpandedState(MuConfigurations.getPreferences().getVariable(MuPreference.PROGRESS_DIALOG_EXPANDED, MuPreferences.DEFAULT_PROGRESS_DIALOG_EXPANDED));
tempPanel.add(collapseExpandButton, BorderLayout.EAST);
yPanel.add(tempPanel);
yPanel.addSpace(5);
yPanel.add(advancedPanel);
}
closeWhenFinishedCheckBox = new JCheckBox(Translator.get("progress_dialog.close_when_finished"));
closeWhenFinishedCheckBox.setSelected(MuConfigurations.getPreferences().getVariable(MuPreference.PROGRESS_DIALOG_CLOSE_WHEN_FINISHED, MuPreferences.DEFAULT_PROGRESS_DIALOG_CLOSE_WHEN_FINISHED));
yPanel.add(closeWhenFinishedCheckBox);
yPanel.add(Box.createVerticalGlue());
contentPane.add(yPanel, BorderLayout.CENTER);
pauseResumeButton = new JButton(Translator.get("pause"), IconManager.getIcon(IconManager.PROGRESS_ICON_SET, PAUSE_ICON));
pauseResumeButton.addActionListener(this);
if (transferFileJob != null) {
skipButton = new JButton(Translator.get("skip"), IconManager.getIcon(IconManager.PROGRESS_ICON_SET, SKIP_ICON));
skipButton.addActionListener(this);
}
stopButton = new JButton(Translator.get("stop"), IconManager.getIcon(IconManager.PROGRESS_ICON_SET, STOP_ICON));
stopButton.addActionListener(this);
hideButton = new JButton(Translator.get("progress_dialog.hide"), IconManager.getIcon(IconManager.PROGRESS_ICON_SET, HIDE_ICON));
hideButton.addActionListener(this);
this.buttonsChoicePanel = new ButtonChoicePanel(skipButton == null ? Arrays.asList(pauseResumeButton, stopButton, hideButton) : Arrays.asList(pauseResumeButton, skipButton, stopButton, hideButton), 0, getRootPane());
contentPane.add(buttonsChoicePanel, BorderLayout.SOUTH);
// Cancel button receives initial focus
setInitialFocusComponent(stopButton);
// Enter triggers cancel button
getRootPane().setDefaultButton(stopButton);
}
Aggregations