package art.client.GUI.components.devices.window.colors.rtz32.configuration.components;
import art.library.gui.FlatGUI;
import art.library.gui.flat.FlatButton;
import art.library.gui.flat.FlatDialog;
import art.library.gui.flat.FlatLabel;
import art.library.gui.flat.FlatMenuItem;
import art.library.gui.flat.FlatPanel;
import art.library.gui.flat.FlatPopup;
import art.library.gui.flat.FlatTableInput;
import art.library.gui.flat.FlatWindow;
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration;
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Group;
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Program;
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Program_Trolley_Cancellation;
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Program_Trolley_Correlation_Master;
import art.library.model.devices.colors.controller.RTZ32.configuration.RTZ32_Configuration_Program_Trolley_Correlation_Slave;
import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Distribution_Group;
import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Distribution_Group_Hidden;
import art.library.model.devices.colors.controller.RTZ32.types.RTZ32_Distribution_Group_Segment;
import art.servers.Shared;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.util.List;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.border.CompoundBorder;
import javax.swing.border.LineBorder;
public class Diagram_Distribution_Bars extends JPanel
{
private RTZ32_Configuration configuration = null;
public Diagram_Distribution distribution = null;
public int programNumber = 0;
private boolean editable = false;
private Diagram_Distribution_Bars_Header_Timeline diagram_Distribution_Bars_Header_Timeline = null;
private Diagram_Distribution_Bars_Content_Groups diagram_Distribution_Bars_Content_Groups = null;
private Diagram_Distribution_Bars_Header_Groups diagram_Distribution_Bars_Header_Groups = null;
private Diagram_Distribution_Bars_Content_Saturation_Correlations diagram_Distribution_Bars_Content_Saturation_Correlations = null;
private Diagram_Distribution_Bars_Content_Variables_Cancellations diagram_Distribution_Bars_Content_Variables_Cancellations = null;
private Diagram_Distribution_Bars_Content_Retractables diagram_Distribution_Bars_Content_Retractables = null;
private PopupHidden popupHidden = null;
private PopupSegment popupSegment = null;
private int numberBars = 0;
public boolean information = false;
protected int currentTime = 0;
protected int currentBar = 0;
protected RTZ32_Configuration_Group currentGroup = null;
protected RTZ32_Distribution_Group_Hidden currentHidden = null;
protected RTZ32_Distribution_Group_Segment currentSegment = null;
private boolean mouseDragging = false;
public Diagram_Distribution_Bars(RTZ32_Configuration configuration, int programNumber, Diagram_Distribution distribution)
{
this.configuration = configuration;
this.programNumber = programNumber;
this.distribution = distribution;
this.diagram_Distribution_Bars_Header_Timeline = new Diagram_Distribution_Bars_Header_Timeline(configuration, programNumber);
this.diagram_Distribution_Bars_Content_Groups = new Diagram_Distribution_Bars_Content_Groups(configuration, programNumber, distribution);
this.diagram_Distribution_Bars_Header_Groups = new Diagram_Distribution_Bars_Header_Groups(configuration);
this.diagram_Distribution_Bars_Content_Saturation_Correlations = new Diagram_Distribution_Bars_Content_Saturation_Correlations(configuration, programNumber);
this.diagram_Distribution_Bars_Content_Variables_Cancellations = new Diagram_Distribution_Bars_Content_Variables_Cancellations(configuration, programNumber);
this.diagram_Distribution_Bars_Content_Retractables = new Diagram_Distribution_Bars_Content_Retractables(configuration, programNumber);
this.popupHidden = new PopupHidden();
this.popupSegment = new PopupSegment();
this.addComponentListener(new ComponentAdapter()
{
public void componentResized(ComponentEvent e)
{
RTZ32_Configuration_Program program = configuration.getProgram(programNumber);
int w = Diagram_Distribution_Bars.this.getWidth();
int h = Diagram_Distribution_Bars.this.getHeight();
int dy = (h - 100) - ((int)((h - 100)/configuration.groups.length) * configuration.groups.length);
diagram_Distribution_Bars_Header_Timeline.setBounds(315, 75, w - 315, h);
diagram_Distribution_Bars_Content_Groups.setBounds(315, 100, w - 315, h - 100 - dy);
diagram_Distribution_Bars_Header_Groups.setBounds(0, 100, 315, h - 100 - dy);
diagram_Distribution_Bars_Content_Saturation_Correlations.setBounds(315, 0, w - 315, h);
diagram_Distribution_Bars_Content_Variables_Cancellations.setBounds(315, 25, w - 315, h);
diagram_Distribution_Bars_Content_Retractables.setBounds(315, 50, w - 315, h - 50);
}
});
this.addMouseMotionListener(new MyMouseMotionListener());
this.addMouseListener(new MyMouseListener());
}
public void editable(boolean value)
{
this.editable = value;
}
public void selected(RTZ32_Distribution_Group group, int time)
{
currentTime = time;
repaint();
}
public void paintComponent(Graphics graphics)
{
super.paintComponent(graphics);
Graphics2D g2 = (Graphics2D)graphics;
Diagram_Distribution.format(g2);
int w = getWidth();
int h = getHeight();
numberBars = Diagram_Distribution.getNumberBars(configuration);
g2.setBackground(Color.white);
g2.clearRect(diagram_Distribution_Bars_Content_Groups.getX(), diagram_Distribution_Bars_Content_Groups.getY(), getWidth(), getHeight());
g2.translate(0, 100);
diagram_Distribution_Bars_Header_Groups.paint(g2, currentBar);
g2.translate(0, -100);
g2.translate(315, 75);
diagram_Distribution_Bars_Header_Timeline.paintTimeline(g2);
g2.translate(0, 25);
diagram_Distribution_Bars_Content_Groups.paintBars(g2, numberBars, currentSegment);
g2.translate(-315, -100);
// Borders, texts
g2.draw(new Rectangle2D.Double(0,0,w,h));
g2.draw(new Line2D.Double(315,0,315,h));
g2.draw(new Rectangle2D.Double(0,0,w,25));
g2.draw(new Rectangle2D.Double(0,25,w,25));
g2.draw(new Rectangle2D.Double(0,50,w,25));
g2.draw(new Rectangle2D.Double(0,75,w,25));
Font font = new FlatLabel().getLook().font;
g2.setColor(FlatGUI.lookDesign.getColor("label.color.background").darker());
g2.setColor(FlatGUI.lookDesign.getColor("label.color.foreground").darker());
Diagram_Distribution.drawLeftString(g2, Shared.getMessage("Correlations, Saturations"), new Rectangle2D.Double(5, 0, 315, 25), font);
Diagram_Distribution.drawLeftString(g2, Shared.getMessage("Variables, Cancellations"), new Rectangle2D.Double(5, 25, 315, 25), font);
Diagram_Distribution.drawLeftString(g2, Shared.getMessage("Rectractables"), new Rectangle2D.Double(5, 50, 315, 25), font);
// Phases
g2.translate(315, 0);
diagram_Distribution_Bars_Content_Saturation_Correlations.paint(g2);
g2.translate(0, 25);
diagram_Distribution_Bars_Content_Variables_Cancellations.paint(g2);
g2.translate(0, 25);
diagram_Distribution_Bars_Content_Retractables.paint(g2);
g2.translate(-315, -50);
// Focus, hiddens
g2.translate(315, 100);
diagram_Distribution_Bars_Content_Groups.paintHidden(g2, numberBars, currentHidden);
diagram_Distribution_Bars_Content_Groups.paintFocus(g2, numberBars, currentTime);
g2.translate(-315, -100);
}
//
private class MyMouseListener implements MouseListener
{
public void mouseClicked(MouseEvent e)
{
}
public void mousePressed(MouseEvent e)
{
if (editable == false) return;
int x = e.getX();
int y = e.getY();
// Selection retractables
if (mouseInside(x, y, diagram_Distribution_Bars_Content_Retractables))
{
Diagram_Distribution_Bars.this.setCursor(FlatGUI.lookDesign.getCursor("cursor.drag"));
Diagram_Distribution_Bars.this.repaint();
return;
}
// Selection variables
if (mouseInside(x, y, diagram_Distribution_Bars_Content_Variables_Cancellations))
{
Diagram_Distribution_Bars.this.setCursor(FlatGUI.lookDesign.getCursor("cursor.drag"));
Diagram_Distribution_Bars.this.repaint();
return;
}
mouseAction(e.getX(), e.getY());
}
public void mouseReleased(MouseEvent e)
{
mouseDragging = false;
if (e.isPopupTrigger() == true)
{
Object selected = null;
if (diagram_Distribution_Bars_Content_Retractables.currentRetractable != null) selected = diagram_Distribution_Bars_Content_Retractables.currentRetractable;
else if (diagram_Distribution_Bars_Content_Variables_Cancellations.currentVariable != null) selected = diagram_Distribution_Bars_Content_Variables_Cancellations.currentVariable;
else if (diagram_Distribution_Bars_Content_Variables_Cancellations.currentCancellation != null) selected = diagram_Distribution_Bars_Content_Variables_Cancellations.currentCancellation;
else if (diagram_Distribution_Bars_Content_Saturation_Correlations.currentSaturation != null) selected = diagram_Distribution_Bars_Content_Saturation_Correlations.currentSaturation;
else if (diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationMaster != null) selected = diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationMaster;
else if (diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationSlave != null) selected = diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationSlave;
if (selected != null)
{
PopupOptions popupOptions = new PopupOptions(selected);
popupOptions.show(Diagram_Distribution_Bars.this, e.getX(), e.getY());
}
}
if (editable == false) return;
mouseAction(e.getX(), e.getY());
if ((diagram_Distribution_Bars_Content_Retractables.currentRetractable != null) ||
(diagram_Distribution_Bars_Content_Variables_Cancellations.currentVariable != null) ||
(diagram_Distribution_Bars_Content_Variables_Cancellations.currentCancellation != null) ||
(diagram_Distribution_Bars_Content_Saturation_Correlations.currentSaturation != null) ||
(diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationMaster != null) ||
(diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationSlave != null))
{
distribution.changeMade();
distribution.reevaluate();
repaint();
}
}
public void mouseEntered(MouseEvent e)
{
mouseAction(e.getX(), e.getY());
}
public void mouseExited(MouseEvent e)
{
currentTime = 0;
currentBar = 0;
popupHidden.setVisible(false);
popupSegment.setVisible(false);
repaint();
}
}
private class MyMouseMotionListener extends MouseMotionAdapter
{
public void mouseMoved(MouseEvent e)
{
mouseAction(e.getX(), e.getY());
}
public void mouseDragged(MouseEvent e)
{
if (editable == false)
{
mouseAction(e.getX(), e.getY());
return;
}
mouseDragging = true;
currentTime = diagram_Distribution_Bars_Content_Groups.getCurrentTime(e.getX() - diagram_Distribution_Bars_Content_Groups.getX());
if (diagram_Distribution_Bars_Content_Retractables.currentRetractable != null)
{
diagram_Distribution_Bars_Content_Retractables.setCurrentTime(currentTime);
}
else if (diagram_Distribution_Bars_Content_Variables_Cancellations.currentVariable != null)
{
diagram_Distribution_Bars_Content_Variables_Cancellations.setCurrentTime(currentTime);
}
else if (diagram_Distribution_Bars_Content_Variables_Cancellations.currentCancellation != null)
{
diagram_Distribution_Bars_Content_Variables_Cancellations.setCurrentTime(currentTime);
}
else if (diagram_Distribution_Bars_Content_Saturation_Correlations.currentSaturation != null)
{
diagram_Distribution_Bars_Content_Saturation_Correlations.setCurrentTime(currentTime);
}
else if (diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationMaster != null)
{
diagram_Distribution_Bars_Content_Saturation_Correlations.setCurrentTime(currentTime);
}
else if (diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationSlave != null)
{
diagram_Distribution_Bars_Content_Saturation_Correlations.setCurrentTime(currentTime);
}
Diagram_Distribution_Bars.this.repaint();
mouseAction(e.getX(), e.getY());
}
}
private boolean mouseInside(int x, int y, JPanel panel)
{
return ((x > panel.getX()) && (y > panel.getY()) && (x < (panel.getX() + panel.getWidth())) && (y < (panel.getY() + panel.getHeight())));
}
private void mouseAction(int x, int y)
{
try
{
if ((editable == true) && (mouseDragging == true)) return;
Diagram_Distribution_Bars.this.setCursor(FlatGUI.lookDesign.getCursor("cursor.hand"));
// Selection Bars
if (mouseInside(x, y, diagram_Distribution_Bars_Content_Groups) == true)
{
Diagram_Distribution_Bars.this.setCursor(FlatGUI.lookDesign.getCursor("cursor.point"));
x = x - diagram_Distribution_Bars_Content_Groups.getX();
y = y - diagram_Distribution_Bars_Content_Groups.getY();
currentTime = diagram_Distribution_Bars_Content_Groups.getCurrentTime(x);
currentBar = diagram_Distribution_Bars_Content_Groups.getCurrentBar(y, numberBars);
currentGroup = diagram_Distribution_Bars_Content_Groups.getCurrentGroup(x, y, numberBars);
currentHidden = diagram_Distribution_Bars_Content_Groups.getCurrentHidden(x, y, numberBars);
if (currentHidden == null)
{
currentSegment = diagram_Distribution_Bars_Content_Groups.getCurrentSegment(x, y, numberBars);
}
else
{
currentSegment = null;
}
if (currentHidden != null)
{
popupHidden.update(currentGroup, currentHidden);
if (information == true)
{
int posx = this.getWidth() - popupHidden.getWidth();
int posy = this.getHeight() - popupHidden.getHeight();
if (((x + diagram_Distribution_Bars_Content_Groups.getX()) >= posx) && ((x + diagram_Distribution_Bars_Content_Groups.getX()) <= (posx + popupHidden.getWidth())))
{
posx = diagram_Distribution_Bars_Content_Groups.getX() + 1;
}
popupHidden.show(Diagram_Distribution_Bars.this, posx, posy);
}
}
else if (currentSegment != null)
{
popupSegment.update(currentGroup, currentSegment);
if (information == true)
{
int posx = this.getWidth() - popupSegment.getWidth();
int posy = this.getHeight() - popupSegment.getHeight();
if (((x + diagram_Distribution_Bars_Content_Groups.getX()) >= posx) && ((x + diagram_Distribution_Bars_Content_Groups.getX()) <= (posx + popupSegment.getWidth())))
{
posx = diagram_Distribution_Bars_Content_Groups.getX() + 1;
}
popupSegment.show(Diagram_Distribution_Bars.this, posx, posy);
}
}
else
{
popupHidden.setVisible(false);
popupSegment.setVisible(false);
}
}
else
{
currentGroup = null;
currentBar = 0;
popupHidden.setVisible(false);
popupSegment.setVisible(false);
}
// Selection retractables
if (mouseInside(x, y, diagram_Distribution_Bars_Content_Retractables) == true)
{
x = x - diagram_Distribution_Bars_Content_Retractables.getX();
y = y - diagram_Distribution_Bars_Content_Retractables.getY();
diagram_Distribution_Bars_Content_Retractables.updateCurrentRetractable(x, y);
if (diagram_Distribution_Bars_Content_Retractables.currentRetractable != null)
{
Diagram_Distribution_Bars.this.setCursor(FlatGUI.lookDesign.getCursor("cursor.point"));
if (diagram_Distribution_Bars_Content_Retractables.order == 0)
{
currentTime = diagram_Distribution_Bars_Content_Retractables.currentRetractable.startTime;
}
else if (diagram_Distribution_Bars_Content_Retractables.order == 1)
{
currentTime = diagram_Distribution_Bars_Content_Retractables.currentRetractable.endTime;
}
}
}
else
{
diagram_Distribution_Bars_Content_Retractables.currentRetractable = null;
}
// Selection variables, cancellations
if (mouseInside(x, y, diagram_Distribution_Bars_Content_Variables_Cancellations) == true)
{
x = x - diagram_Distribution_Bars_Content_Variables_Cancellations.getX();
y = y - diagram_Distribution_Bars_Content_Variables_Cancellations.getY();
diagram_Distribution_Bars_Content_Variables_Cancellations.updateCurrentVariableCancellation(x, y);
if (diagram_Distribution_Bars_Content_Variables_Cancellations.currentVariable != null)
{
Diagram_Distribution_Bars.this.setCursor(FlatGUI.lookDesign.getCursor("cursor.point"));
if (diagram_Distribution_Bars_Content_Variables_Cancellations.order == 0)
{
currentTime = diagram_Distribution_Bars_Content_Variables_Cancellations.currentVariable.startTime;
}
else if (diagram_Distribution_Bars_Content_Variables_Cancellations.order == 1)
{
currentTime = diagram_Distribution_Bars_Content_Variables_Cancellations.currentVariable.endTime;
}
}
else if (diagram_Distribution_Bars_Content_Variables_Cancellations.currentCancellation != null)
{
Diagram_Distribution_Bars.this.setCursor(FlatGUI.lookDesign.getCursor("cursor.point"));
currentTime = diagram_Distribution_Bars_Content_Variables_Cancellations.currentCancellation.time;
}
}
else
{
diagram_Distribution_Bars_Content_Variables_Cancellations.currentVariable = null;
diagram_Distribution_Bars_Content_Variables_Cancellations.currentCancellation = null;
}
// Selection saturations, correlations
if (mouseInside(x, y, diagram_Distribution_Bars_Content_Saturation_Correlations) == true)
{
x = x - diagram_Distribution_Bars_Content_Saturation_Correlations.getX();
y = y - diagram_Distribution_Bars_Content_Saturation_Correlations.getY();
diagram_Distribution_Bars_Content_Saturation_Correlations.updateCurrentSaturationCorrelation(x, y);
if (diagram_Distribution_Bars_Content_Saturation_Correlations.currentSaturation != null)
{
Diagram_Distribution_Bars.this.setCursor(FlatGUI.lookDesign.getCursor("cursor.point"));
if (diagram_Distribution_Bars_Content_Saturation_Correlations.order == 0)
{
currentTime = diagram_Distribution_Bars_Content_Saturation_Correlations.currentSaturation.startTime;
}
else if (diagram_Distribution_Bars_Content_Saturation_Correlations.order == 1)
{
currentTime = diagram_Distribution_Bars_Content_Saturation_Correlations.currentSaturation.endTime;
}
}
else if (diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationMaster != null)
{
Diagram_Distribution_Bars.this.setCursor(FlatGUI.lookDesign.getCursor("cursor.point"));
currentTime = diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationMaster.time;
}
else if (diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationSlave != null)
{
Diagram_Distribution_Bars.this.setCursor(FlatGUI.lookDesign.getCursor("cursor.point"));
currentTime = diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationSlave.time;
}
}
else
{
diagram_Distribution_Bars_Content_Saturation_Correlations.currentSaturation = null;
diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationMaster = null;
diagram_Distribution_Bars_Content_Saturation_Correlations.currentCorrelationSlave = null;
}
}
catch (Exception exception)
{
}
Diagram_Distribution_Bars.this.repaint();
}
//
//
private class PopupSegment extends JPopupMenu
{
private FlatTableInput table1 = null;
private RTZ32_Configuration_Group group = null;
private RTZ32_Distribution_Group_Segment segment = null;
public PopupSegment()
{
initialise();
}
public void update(RTZ32_Configuration_Group group, RTZ32_Distribution_Group_Segment segment)
{
this.group = group;
this.segment = segment;
if ((group != null) && (segment != null))
{
table1.setValue(Shared.getMessage("Group"), group.number + " ( " + group.type + " )");
table1.setValue(Shared.getMessage("Start time"), segment.startTime);
table1.setValue(Shared.getMessage("End time"), segment.endTime);
table1.setValue(Shared.getMessage("Duration"), segment.getDuration());
table1.setValue(Shared.getMessage("Color"), segment.getColorName());
table1.revalidate();
}
}
private void initialise()
{
table1 = new FlatTableInput(100);
{
table1.addTextField(Shared.getMessage("Group"), 16);
table1.addTextField(Shared.getMessage("Start time"), 16);
table1.addTextField(Shared.getMessage("End time"), 16);
table1.addTextField(Shared.getMessage("Duration"), 16);
table1.addTextField(Shared.getMessage("Color"), 16);
table1.setEditable(false);
table1.revalidate();
}
this.setBorder(new CompoundBorder(new LineBorder(Color.white, 10), new LineBorder(table1.getLook().colorBorder, 1)));
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(275, table1.getDimensionHeight() + 7 + 15));
this.add(table1.getScrollPane(), BorderLayout.CENTER);
}
}
private class PopupHidden extends JPopupMenu
{
private FlatTableInput table1 = null;
private RTZ32_Configuration_Group group = null;
private RTZ32_Distribution_Group_Hidden hidden = null;
public PopupHidden()
{
initialise();
}
public void update(RTZ32_Configuration_Group group, RTZ32_Distribution_Group_Hidden hidden)
{
this.group = group;
this.hidden = hidden;
if ((group != null) && (hidden != null))
{
table1.setValue(Shared.getMessage("Group"), group.number + " ( " + group.type + " )");
table1.setValue(Shared.getMessage("Time"), hidden.time);
table1.setValue(Shared.getMessage("Color order"), hidden.colorOrder);
table1.setValue(Shared.getMessage("Color name"), hidden.colorName);
table1.revalidate();
}
}
private void initialise()
{
table1 = new FlatTableInput(100);
{
table1.addTextField(Shared.getMessage("Group"), 16);
table1.addTextField(Shared.getMessage("Time"), 16);
table1.addTextField(Shared.getMessage("Color order"), 16);
table1.addTextField(Shared.getMessage("Color name"), 16);
table1.setEditable(false);
table1.revalidate();
}
this.setBorder(new CompoundBorder(new LineBorder(Color.white, 10), new LineBorder(table1.getLook().colorBorder, 1)));
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(275, table1.getDimensionHeight() + 7 + 15));
this.add(table1.getScrollPane(), BorderLayout.CENTER);
}
}
private class PopupOptions extends FlatPopup
{
private Object selected = null;
private FlatTableInput table1 = null;
public PopupOptions(Object selected)
{
this.selected = selected;
initialise();
}
private void initialise()
{
if (selected instanceof RTZ32_Configuration_Program_Trolley_Correlation_Master == true)
{
RTZ32_Configuration_Program_Trolley_Correlation_Master correlation = (RTZ32_Configuration_Program_Trolley_Correlation_Master)selected;
FlatPanel panel1 = new FlatPanel();
{
FlatButton button1 = new FlatButton(Shared.getMessage("Delete"));
JLabel label1 = new JLabel();
{
label1.setPreferredSize(new Dimension(4,4));
}
panel1.setPreferredSize(new Dimension(0, 40));
panel1.setLayout(new BorderLayout());
panel1.add(button1, BorderLayout.CENTER);
panel1.add(label1, BorderLayout.SOUTH);
panel1.setRaisedBorder(0,0,1,0);
button1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
setVisible(false);
delete();
}
});
}
FlatPanel panel2 = new FlatPanel();
{
table1 = new FlatTableInput(150);
{
table1.addTextField(Shared.getMessage("Description"), 22);
table1.setEditable(Diagram_Distribution_Bars.this.editable);
table1.revalidate();
table1.setValue(Shared.getMessage("Description"), correlation.description);
table1.setField(Shared.getMessage("Description"), correlation, "description");
}
panel2.setLayout(new BorderLayout());
panel2.add(table1.getScrollPane(), BorderLayout.CENTER);
}
if (Diagram_Distribution_Bars.this.editable == false)
{
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(512, table1.getDimensionHeight() + 8));
this.add(panel2, BorderLayout.CENTER);
}
else
{
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(512, 40 + table1.getDimensionHeight() + 8));
this.add(panel1, BorderLayout.NORTH);
this.add(panel2, BorderLayout.CENTER);
}
}
else if (selected instanceof RTZ32_Configuration_Program_Trolley_Correlation_Slave == true)
{
RTZ32_Configuration_Program_Trolley_Correlation_Slave correlation = (RTZ32_Configuration_Program_Trolley_Correlation_Slave)selected;
FlatPanel panel1 = new FlatPanel();
{
FlatButton button1 = new FlatButton(Shared.getMessage("Delete"));
JLabel label1 = new JLabel();
{
label1.setPreferredSize(new Dimension(4,4));
}
panel1.setPreferredSize(new Dimension(0, 40));
panel1.setLayout(new BorderLayout());
panel1.add(button1, BorderLayout.CENTER);
panel1.add(label1, BorderLayout.SOUTH);
panel1.setRaisedBorder(0,0,1,0);
button1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
setVisible(false);
delete();
}
});
}
FlatPanel panel2 = new FlatPanel();
{
table1 = new FlatTableInput(150);
{
table1.addTextField(Shared.getMessage("Description"), 22);
table1.addNumericTextField(Shared.getMessage("Slave timeout"), 0, 255, 22);
table1.setEditable(Diagram_Distribution_Bars.this.editable);
table1.revalidate();
table1.setValue(Shared.getMessage("Description"), correlation.description);
table1.setValue(Shared.getMessage("Slave timeout"), correlation.timeout);
table1.setField(Shared.getMessage("Description"), correlation, "description");
table1.setField(Shared.getMessage("Slave timeout"), correlation, "timeout");
}
panel2.setLayout(new BorderLayout());
panel2.add(table1.getScrollPane(), BorderLayout.CENTER);
}
if (Diagram_Distribution_Bars.this.editable == false)
{
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(512, table1.getDimensionHeight() + 8));
this.add(panel2, BorderLayout.CENTER);
}
else
{
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(512, 40 + table1.getDimensionHeight() + 8));
this.add(panel1, BorderLayout.NORTH);
this.add(panel2, BorderLayout.CENTER);
}
}
else if (selected instanceof RTZ32_Configuration_Program_Trolley_Cancellation == true)
{
RTZ32_Configuration_Program_Trolley_Cancellation cancellation = (RTZ32_Configuration_Program_Trolley_Cancellation)selected;
FlatPanel panel1 = new FlatPanel();
{
FlatButton button1 = new FlatButton(Shared.getMessage("Delete"));
JLabel label1 = new JLabel();
{
label1.setPreferredSize(new Dimension(4,4));
}
panel1.setPreferredSize(new Dimension(0, 40));
panel1.setLayout(new BorderLayout());
panel1.add(button1, BorderLayout.CENTER);
panel1.add(label1, BorderLayout.SOUTH);
panel1.setRaisedBorder(0,0,1,0);
button1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
setVisible(false);
delete();
}
});
}
FlatPanel panel2 = new FlatPanel();
{
table1 = new FlatTableInput(150);
{
Object[] FACTORS = new String[]{"1.0", "1.5", "2.0", "2.5", "3.0"};
table1.addNumericTextField(Shared.getMessage("Wait time - normal"), 0, 50, 22);
table1.addCheckList(Shared.getMessage("Factor"), FACTORS, 100);
table1.addTextField(Shared.getMessage("Wait time - double"), 22);
table1.setEditable(Diagram_Distribution_Bars.this.editable);
table1.setEditable(Shared.getMessage("Wait time - double"), false);
table1.revalidate();
table1.setValue(Shared.getMessage("Wait time - normal"), "" + cancellation.getNormalTimeout());
table1.setValue(Shared.getMessage("Factor"), cancellation.getFactorTimeout());
table1.setValue(Shared.getMessage("Wait time - double"), "" + cancellation.getDoubleTimeout());
table1.setField("Wait time - normal", this, "cancellation");
table1.setField("Factor", this, "cancellation");
}
panel2.setLayout(new BorderLayout());
panel2.add(table1.getScrollPane(), BorderLayout.CENTER);
}
if (Diagram_Distribution_Bars.this.editable == false)
{
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(272, table1.getDimensionHeight() + 8));
this.add(panel2, BorderLayout.CENTER);
}
else
{
this.setLayout(new BorderLayout());
this.setPreferredSize(new Dimension(272, 40 + table1.getDimensionHeight() + 8));
this.add(panel1, BorderLayout.NORTH);
this.add(panel2, BorderLayout.CENTER);
}
}
else
{
if (Diagram_Distribution_Bars.this.editable == false)
{
this.setVisible(false);
return;
}
FlatMenuItem menuitem = new FlatMenuItem(Shared.getMessage("Delete"));
this.add(menuitem);
this.setPreferredSize(new Dimension(150, 36));
menuitem.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
setVisible(false);
delete();
}
});
}
}
private void delete()
{
if (Diagram_Distribution_Bars.this.editable == true)
{
FlatWindow window = (FlatWindow)SwingUtilities.getRoot(Diagram_Distribution_Bars.this);
int answer = FlatDialog.showDialog(window, Shared.getMessage("Deleting"), Shared.getMessage("Do you really want to delete?"), true, FlatDialog.DIALOG_QUESTION);
if (answer == JOptionPane.YES_OPTION)
{
RTZ32_Configuration_Program program = configuration.getProgram(programNumber);
program.trolley.clear(selected);
program.clear(selected);
distribution.changeMade();
distribution.reevaluate();
}
}
}
private void cancellation(Object object)
{
try
{
int timeout = Integer.parseInt((String)table1.getValue("Wait time - normal"));
List factorlist = (List)table1.getValue("Factor");
double factor = Double.parseDouble(((String)(factorlist.get(0))).replace("]", "").replace("[", "").trim());
RTZ32_Configuration_Program_Trolley_Cancellation cancellation = (RTZ32_Configuration_Program_Trolley_Cancellation)selected;
cancellation.setTimeout(timeout, factor);
table1.setValue(Shared.getMessage("Wait time - double"), "" + cancellation.getDoubleTimeout());
}
catch (Exception exception)
{
table1.setValue(Shared.getMessage("Wait time - double"), "");
}
}
}
//
}