// .getTaskSelectionManager().getSelectedTasks().isEmpty());
// myExportSettings.setStartDate(myStartDate);
// myExportSettings.setEndDate(myEndDate);
myPrintable = new GanttPrintable(myChart.getChart(myExportSettings),
GanttPrintable.REDUCE_FACTOR_DEFAULT);
JToolBar tb = new JToolBar();
JToolBar tb2 = new JToolBar();
JButton bPrint = new TestGanttRolloverButton(new ImageIcon(getClass()
.getResource("/icons/print_16.gif")));
bPrint.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
print();
}
});
JButton bClose = bClose = new TestGanttRolloverButton(new ImageIcon(
getClass().getResource("/icons/exit_16.gif")));
bClose.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
dispose();
}
});
final JButton bPortrait = new TestGanttRolloverButton(new ImageIcon(
getClass().getResource("/icons/portrait_16.gif")));
final JButton bLandscape = new TestGanttRolloverButton(new ImageIcon(
getClass().getResource("/icons/landscape_16.gif")));
bPortrait.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
run(new Runnable() {
public void run() {
changePageOrientation(PageFormat.PORTRAIT);
bLandscape.setEnabled(true);
bPortrait.setEnabled(false);
}
});
}
});
bLandscape.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
run(new Runnable() {
public void run() {
changePageOrientation(PageFormat.LANDSCAPE);
bLandscape.setEnabled(false);
bPortrait.setEnabled(true);
}
});
}
});
bLandscape.setEnabled(false);
String[] scales = { "10 %", "25 %", "50 %", "100 %" };
myComboScale = new JComboBox(scales);
myComboScale.setSelectedIndex(2);
myComboScale.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
run(new Runnable() {
public void run() {
changeScale();
}
});
}
});
myComboScale.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent arg0) {
run(new Runnable() {
public void run() {
changeScale();
}
});
}
});
Dimension dim = myComboScale.getPreferredSize();
dim.setSize(dim.getWidth() + 20, dim.getHeight());
myComboScale.setMaximumSize(dim);
myComboScale.setPreferredSize(dim);
myComboScale.setEditable(true);
boolean isDate = start != null && end != null;
ImageIcon icon = new ImageIcon(getClass().getResource(
"/icons/calendar_16.gif"));
myStart.lock();
myFinish.lock();
if (isDate) {
/*
myStartDateButton = new JButton(new GanttCalendar(myStartDate)
.toString(), icon);
myStartDateButton.setHorizontalTextPosition(SwingConstants.RIGHT);
myStartDateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myStartDialogDate = new GanttDialogDate(new JDialog(),
new GanttCalendar(myStartDate), false);
myStartDialogDate.setVisible(true);
if (myStartDialogDate.getValue() == GanttDialogDate.OK) {
myStartDate = myStartDialogDate.getDate().getTime();
myStartDateButton
.setText(new GanttCalendar(myStartDate)
.toString());
myExportSettings.setStartDate(myStartDate);
updateSourceImage(myChart.getChart(myExportSettings));
}
}
});
myEndDateButton = new JButton(new GanttCalendar(myEndDate)
.toString(), icon);
myEndDateButton.setHorizontalTextPosition(SwingConstants.RIGHT);
myEndDateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myEndDialogDate = new GanttDialogDate(new JDialog(),
new GanttCalendar(myEndDate), false);
myEndDialogDate.setVisible(true);
if (myEndDialogDate.getValue() == GanttDialogDate.OK) {
myEndDate = myEndDialogDate.getDate().getTime();
myEndDateButton.setText(new GanttCalendar(myEndDate)
.toString());
myExportSettings.setEndDate(myEndDate);
updateSourceImage(myChart.getChart(myExportSettings));
}
}
});
*/
myWholeProjectButton = new JButton(language.getText("wholeProject"));
myWholeProjectButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
myStart.setValue(myChart.getStartDate());
myFinish.setValue(myChart.getEndDate());
/*
myStartDate = myChart.getStartDate();
myEndDate = myChart.getEndDate();
myExportSettings.setStartDate(myStartDate);
myExportSettings.setEndDate(myEndDate);
myEndDateButton.setText(new GanttCalendar(myExportSettings
.getEndDate()).toString());
myStartDateButton.setText(new GanttCalendar(
myExportSettings.getStartDate()).toString());
myEndDialogDate = new GanttDialogDate(new JDialog(),
new GanttCalendar(myEndDate), false);
myStartDialogDate = new GanttDialogDate(new JDialog(),
new GanttCalendar(myStartDate), false);
updateSourceImage(myChart.getChart(myExportSettings));
*/
}
});
}
Vector vMedia = new Vector();
;
// try {
// vMedia = getAllMediaSizeNameAvailable();
vMedia.add(MediaSizeName.ISO_A0);
vMedia.add(MediaSizeName.ISO_A1);
vMedia.add(MediaSizeName.ISO_A2);
vMedia.add(MediaSizeName.ISO_A3);
vMedia.add(MediaSizeName.ISO_A4);
vMedia.add(MediaSizeName.ISO_A5);
vMedia.add(MediaSizeName.ISO_A6);
// } catch (ClassNotFoundException e1) {
// // TODO Auto-generated catch block
// e1.printStackTrace();
// }
if (vMedia != null) {
myComboMediaSize = new JComboBox(vMedia);
dim = myComboMediaSize.getPreferredSize();
dim.setSize(dim.getWidth() + 20, dim.getHeight());
myComboMediaSize.setMaximumSize(dim);
myComboMediaSize.setPreferredSize(dim);
myComboMediaSize.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent arg0) {
run(new Runnable() {
public void run() {
Object selectedItem = myComboMediaSize
.getSelectedItem();
if (selectedItem != null) {
myMediaSizeName = (MediaSizeName) selectedItem;
MediaSize ms = MediaSize
.getMediaSizeForName(myMediaSizeName);
Paper p = new Paper();
float[] size = ms.getSize(MediaSize.INCH);
p.setSize(size[0] * 72, size[1] * 72);
p.setImageableArea(72, 72,
p.getWidth() - 72 * 2,
p.getHeight() - 72 * 2);
myPageFormat.setPaper(p);
changePageOrientation(myOrientation);
statusBar.setText1(ms.getX(MediaSize.MM)
+ " x " + ms.getY(MediaSize.MM));
myPreviewContainer.repaint();
}
}
});
}
});
}
bPrint.setToolTipText(GanttProject.getToolTip(GanttProject
.correctLabel(language.getText("printProject"))));
bPortrait.setToolTipText(GanttProject.getToolTip(GanttProject
.correctLabel(language.getText("portrait"))));
bLandscape.setToolTipText(GanttProject.getToolTip(GanttProject
.correctLabel(language.getText("landscape"))));
bClose.setToolTipText(GanttProject.getToolTip(GanttProject
.correctLabel(language.getText("close"))));
final JButton bZoomOut;
final JButton bZoomIn;
if (isDate) {
myWholeProjectButton.setToolTipText(GanttProject
.getToolTip(GanttProject.correctLabel(language
.getText("displayWholeProject"))));
/*
myStartDateButton.setToolTipText(GanttProject
.getToolTip(GanttProject.correctLabel(language
.getText("setStartDate"))));
myEndDateButton.setToolTipText(GanttProject.getToolTip(GanttProject
.correctLabel(language.getText("setEndDate"))));
*/
//GanttProject gp = Mediator.getGanttProjectSingleton();
final ZoomManager zoomManager = myUIfacade.getZoomManager();
final Action zoomOut = new ZoomOutAction(zoomManager, "16");
final Action zoomIn = new ZoomInAction(zoomManager, "16");
bZoomOut = new JButton((Icon) zoomOut.getValue(Action.SMALL_ICON));
bZoomIn = new JButton((Icon) zoomIn.getValue(Action.SMALL_ICON));
bZoomOut.setHorizontalTextPosition(SwingConstants.RIGHT);
bZoomOut.setText(language.getText("narrowChart"));
bZoomOut.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
run(new Runnable() {
public void run() {
zoomOut.actionPerformed(null);
updateSourceImage();
bZoomOut.setEnabled(zoomManager.canZoomOut());
bZoomIn.setEnabled(zoomManager.canZoomIn());
}
});
}
});
bZoomIn.setHorizontalTextPosition(SwingConstants.RIGHT);
bZoomIn.setText(language.getText("widenChart"));
bZoomIn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
run(new Runnable() {
public void run() {
zoomIn.actionPerformed(null);
updateSourceImage();
bZoomOut.setEnabled(zoomManager.canZoomOut());
bZoomIn.setEnabled(zoomManager.canZoomIn());
}
});
}
});
} else {
bZoomOut = null;
bZoomIn = null;
}
tb2.setFloatable(false);
tb.setFloatable(false);
tb.add(bClose);
tb.addSeparator(new Dimension(16, 16));
tb.add(bPrint);
tb.addSeparator(new Dimension(16, 16));
tb.add(bPortrait);
tb.add(bLandscape);
tb.addSeparator(new Dimension(16, 16));
tb.add(new JLabel(language.getText("zoom") + " "));
tb.add(myComboScale);
if (vMedia != null && !vMedia.isEmpty()) {
tb.addSeparator(new Dimension(16, 16));
tb.add(new JLabel(language.getText("choosePaperFormat") + " "));
tb.addSeparator(new Dimension(0, 10));
tb.add(myComboMediaSize);
}
if (isDate) {
tb2.add(bZoomOut);
tb2.addSeparator(new Dimension(5, 0));
tb2.add(bZoomIn);
tb2.addSeparator(new Dimension(20, 0));
tb2.add(myWholeProjectButton);
tb2.addSeparator(new Dimension(16, 16));
OptionsPageBuilder builder = new OptionsPageBuilder();
builder.setOptionKeyPrefix("");
tb2.add(builder.createStandaloneOptionPanel(myStart));
URL iconArrow = this.getClass().getClassLoader().getResource(
"icons/fromto.gif");
tb2.add(new JLabel(new ImageIcon(iconArrow)));
tb2.add(builder.createStandaloneOptionPanel(myFinish));
}
JPanel topPanel = new JPanel(new BorderLayout());
tb.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
tb2.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
topPanel.add(tb, BorderLayout.NORTH);
topPanel.add(tb2, BorderLayout.SOUTH);
getContentPane().add(topPanel, BorderLayout.NORTH);