120 lines
3.3 KiB
Java
120 lines
3.3 KiB
Java
package org.hwo.ui.netplan;
|
|
|
|
import java.awt.BorderLayout;
|
|
import java.awt.FlowLayout;
|
|
|
|
import javax.swing.JButton;
|
|
import javax.swing.JDialog;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.border.EmptyBorder;
|
|
|
|
import java.awt.GridBagLayout;
|
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
import java.awt.GridBagConstraints;
|
|
import java.awt.event.ActionListener;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.Dialog.ModalExclusionType;
|
|
|
|
import javax.swing.ScrollPaneConstants;
|
|
|
|
import org.hwo.datetime.Date;
|
|
import org.hwo.datetime.DateTime;
|
|
import org.hwo.datetime.TimeOfDay;
|
|
|
|
import java.awt.Color;
|
|
import java.awt.Font;
|
|
|
|
public class JNetPlanTestDialog extends JDialog {
|
|
|
|
private final JPanel contentPanel = new JPanel();
|
|
private JNetPlan netPlan;
|
|
|
|
/**
|
|
* Create the dialog.
|
|
*/
|
|
public JNetPlanTestDialog() {
|
|
setModal(true);
|
|
setTitle("JNetPlan Test Dialog");
|
|
setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
|
|
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
setBounds(100, 100, 975, 481);
|
|
getContentPane().setLayout(new BorderLayout());
|
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
|
GridBagLayout gbl_contentPanel = new GridBagLayout();
|
|
gbl_contentPanel.columnWidths = new int[]{0, 0};
|
|
gbl_contentPanel.rowHeights = new int[]{0, 0};
|
|
gbl_contentPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
gbl_contentPanel.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
contentPanel.setLayout(gbl_contentPanel);
|
|
{
|
|
JScrollPane scrollPane = new JScrollPane();
|
|
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
|
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
|
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
|
gbc_scrollPane.gridx = 0;
|
|
gbc_scrollPane.gridy = 0;
|
|
contentPanel.add(scrollPane, gbc_scrollPane);
|
|
{
|
|
netPlan = new JNetPlan();
|
|
netPlan.setDays(45);
|
|
netPlan.setFont(new Font("Courier 10 Pitch", Font.PLAIN, 12));
|
|
netPlan.setBackground(Color.WHITE);
|
|
scrollPane.setViewportView(netPlan);
|
|
}
|
|
}
|
|
{
|
|
JPanel buttonPane = new JPanel();
|
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
|
{
|
|
JButton okButton = new JButton("OK");
|
|
okButton.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent e) {
|
|
setVisible(false);
|
|
}
|
|
});
|
|
okButton.setActionCommand("OK");
|
|
buttonPane.add(okButton);
|
|
getRootPane().setDefaultButton(okButton);
|
|
}
|
|
{
|
|
JButton cancelButton = new JButton("Cancel");
|
|
cancelButton.setActionCommand("Cancel");
|
|
buttonPane.add(cancelButton);
|
|
}
|
|
}
|
|
|
|
|
|
this.initialize();
|
|
}
|
|
|
|
private void initialize(){
|
|
for (int i=0;i<10;i++){
|
|
BaseNetPlanResource res = new BaseNetPlanResource(String.format("Resource %d",i), "-");
|
|
if (i == 3)
|
|
res.setMaxParallelUsage(2);
|
|
netPlan.addNetPlanResource(res);
|
|
}
|
|
|
|
Date d = new Date();
|
|
|
|
d.addDays(3);
|
|
|
|
BaseNetPlanObject o = new BaseNetPlanObject();
|
|
o.setStartTime(new DateTime(d, new TimeOfDay()));
|
|
o.setEndTime(new DateTime(d, TimeOfDay.beforeMidnight()));
|
|
|
|
o.setShortLabel("Eine Aufgabe");
|
|
o.addResource(netPlan.getNetPlanResources()[3]);
|
|
|
|
netPlan.addNetPlanObject(o);
|
|
|
|
|
|
|
|
}
|
|
}
|