final JPanel orderByElementsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
orderByElementsPanel.setOpaque(false);
// walk through orderBy elements of the select operator...
for(int i = 0; i < operator.getOrderByList().size(); ++i) {
SortContainer sortContainer = operator.getOrderByList().get(i);
// add spacer if this is not the first element...
if(this.orderByElementsList.size() > 0) {
orderByElementsPanel.add(Box.createRigidArea(new Dimension(10, 3)));
}
// determine right selectedIndex for ComboBox...
int selectedIndex = (sortContainer.isDesc()) ? 1 : 0;
// create new orderBy element panel and set the initial state...
JPanel orderByElement = this.createOrderByElement(orderBy, i, sortContainer, selectedIndex, sortContainer.getSortString());
orderByElementsPanel.add(orderByElement); // add orderBy element
// panel to row panel
}
orderByPanel.add(orderByElementsPanel); // add panel for orderBy
// elements to row panel
final LinkedList<JComponent> needsEnableList = new LinkedList<JComponent>();
if(operator.getOrderByList().size() == 0) {
SortContainer sortContainer = null;
try {
sortContainer = new SortContainer(((VisualGraphOperatorWithPrefix) this.parent).prefix, false, "");
sortContainer.setOperator(operator);
}
catch(ModificationException me) {
me.printStackTrace();
}
// create new orderBy element panel and set the initial state...
JPanel orderByElement = this.createOrderByElement(true, operator.getOrderByList().size(), sortContainer, 0, "");
orderByElement.setVisible(orderBy);
orderByElementsPanel.add(orderByElement); // add orderBy element
// panel to row panel
needsEnableList.add(orderByElement);
}
// create add button...
final JLabel addLabel = new JLabel(this.parent.addIcon);
addLabel.setVisible(orderBy);
addLabel.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent me) {
// add spacer if this is not the first element...
if(orderByElementsList.size() > 0) {
orderByElementsPanel.add(Box.createRigidArea(new Dimension(10, 3)));
}
SortContainer sortContainer = null;
try {
sortContainer = new SortContainer(((VisualGraphOperatorWithPrefix) parent).prefix, false, "");
sortContainer.setOperator(operator);
}
catch(ModificationException mex) {
mex.printStackTrace();
}
operator.addOrderByElement(sortContainer);
// create new orderBy element panel and set the initial state...
JPanel orderByElement = createOrderByElement(true, operator.getOrderByList().size(), sortContainer, 0, "");
orderByElementsPanel.add(orderByElement); // add orderBy element
// panel to row
// panel
updateSize(); // update the size of the RetrieveDataPanel
}
});
orderByPanel.add(addLabel); // add add button to row panel
needsEnableList.add(addLabel);
// define listener for orderBy CheckBox...
orderByCB.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ie) {
// get new state...
boolean selected = (ie.getStateChange() == ItemEvent.SELECTED);
elementStatus.put("orderBy", selected);
// walk through fromNamed TextFields...
for(int i = 0; i < orderByComboBoxesList.size(); ++i) {
JComboBox jCoBo = orderByComboBoxesList.get(i);
JTextField jTF = orderByElementsList.get(i);
// set new state to current elements...
jCoBo.setEnabled(selected);
jTF.setEnabled(selected);
if(selected) { // if state is selected and field is not
// empty...
// create SortContainer for current elements...
SortContainer sc = null;
try {
sc = new SortContainer(((VisualGraphOperatorWithPrefix) parent).prefix, (jCoBo.getSelectedIndex() == 1), jTF.getText());
sc.setOperator(operator);
}
catch(ModificationException me) {
int n = AbstractGuiComponent.showCorrectIgnoreOptionDialog(parent, me.getMessage());
if(n == JOptionPane.YES_OPTION) {