/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2015 ForgeRock AS
*/
/**
* This component displays three list (one available list and two selected
* lists) with some buttons to move the components of one list to the other.
*
* @param <T> the type of the objects in the list.
*/
{
private boolean ignoreListEvents;
/**
* Mask used as display option. If the provided display options contain
* this mask, the panel will display the remove all button.
*/
/**
* Mask used as display option. If the provided display options contain
* this mask, the panel will display the add all button.
*/
/**
* Constructor of the default double add remove panel (including 'Add All' and
* 'Remove All' buttons).
* The class is required to avoid warnings in compilation.
* @param theClass the class of the objects in the panel.
*/
{
}
/**
* Constructor of the double add remove panel allowing the user to provide
* some display options.
* The class is required to avoid warnings in compilation.
* @param displayOptions the display options.
* @param theClass the class of the objects in the panel.
*/
{
super(new GridBagLayout());
setOpaque(false);
{
/** {@inheritDoc} */
{
}
/** {@inheritDoc} */
{
}
/** {@inheritDoc} */
{
}
};
{
/** {@inheritDoc} */
public void mouseClicked(MouseEvent e) {
{
if (e.getSource() == availableList)
{
{
}
}
else if (e.getSource() == selectedList1)
{
{
}
}
else if (e.getSource() == selectedList2
{
}
}
}
};
availableListModel = new SortableListModel<>();
availableList = new JList<>();
selectedListModel1 = new SortableListModel<>();
selectedList1 = new JList<>();
selectedListModel2 = new SortableListModel<>();
selectedList2 = new JList<>();
if (displayOptions != 0)
{
}
// FIXME how can this be any different than 0? Ditto everywhere else down below
if (displayOptions != 0)
{
}
{
/** {@inheritDoc} */
{
}
});
if (displayOptions != 0)
{
{
{
}
});
}
{
{
}
});
if (displayOptions != 0)
{
removeAll1.setOpaque(false);
{
/** {@inheritDoc} */
{
}
});
}
{
/** {@inheritDoc} */
{
}
});
if (displayOptions != 0)
{
{
/** {@inheritDoc} */
{
}
});
}
{
/** {@inheritDoc} */
{
}
});
if (displayOptions != 0)
{
removeAll2.setOpaque(false);
{
/** {@inheritDoc} */
{
}
});
}
if (displayOptions != 0)
{
gbc.gridheight ++;
}
if (displayOptions != 0)
{
gbc.gridheight ++;
}
if (displayOptions != 0)
{
gbc.gridheight ++;
}
if (displayOptions != 0)
{
gbc.gridheight ++;
}
{
{
}
};
add1.setEnabled(false);
remove1.setEnabled(false);
add2.setEnabled(false);
remove2.setEnabled(false);
// Set preferred size for the scroll panes.
"The cell that we want to display", 0, true, true);
}
/**
* Enables the state of the components in the panel.
* @param enable whether to enable the components in the panel or not.
*/
{
super.setEnabled(enable);
}
/**
* Returns the available label contained in the panel.
* @return the available label contained in the panel.
*/
{
return availableLabel;
}
/**
* Returns the list of elements in the available list.
* @return the list of elements in the available list.
*/
{
return availableListModel;
}
/**
* Returns the first selected label contained in the panel.
* @return the first selected label contained in the panel.
*/
{
return selectedLabel1;
}
/**
* Returns the list of elements in the first selected list.
* @return the list of elements in the first selected list.
*/
{
return selectedListModel1;
}
/**
* Returns the second selected label contained in the panel.
* @return the second selected label contained in the panel.
*/
{
return selectedLabel2;
}
/**
* Returns the list of elements in the second selected list.
* @return the list of elements in the second selected list.
*/
{
return selectedListModel2;
}
private void listSelectionChanged()
{
if (ignoreListEvents)
{
return;
}
ignoreListEvents = true;
{
for (T element : unmovableItems)
{
{
{
// This check is necessary since the selection model might not
// be in sync with the list model.
{
indexes[i]);
}
}
}
}
}
ignoreListEvents = false;
{
}
if (removeAll1 != null)
{
}
if (removeAll2 != null)
{
}
}
{
}
{
}
/**
* Returns the available list.
* @return the available list.
*/
{
return availableList;
}
/**
* Returns the first selected list.
* @return the first selected list.
*/
{
return selectedList1;
}
/**
* Returns the second selected list.
* @return the second selected list.
*/
{
return selectedList2;
}
{
{
}
}
private void remove1Clicked()
{
}
private void remove2Clicked()
{
}
{
{
}
}
/**
* Sets the list of items that cannot be moved from one list to the others.
* @param unmovableItems the list of items that cannot be moved from one
* list to the others.
*/
{
this.unmovableItems.clear();
}
{
}
}