private void storeDAPVariables(DAPVariable[] dapVariables) { for (int i = 0; i < dapVariables.length; i++) { boolean contained = false; for (int j = 0; j < variableList.size(); j++) { if (dapVariables[i].equals(variableList.get(j))) { dapVariables[i] = variableList.get(j); contained = true; break; } } if (!contained) { variableList.add(dapVariables[i]); } } }
@Override public void valueChanged(ListSelectionEvent e) { CheckBoxListSelectionModelWithWrapper model = (CheckBoxListSelectionModelWithWrapper) e.getSource(); int anchorSelectionIndex = model.getAnchorSelectionIndex(); if (e.getValueIsAdjusting() || anchorSelectionIndex == -1) { return; } for (int i = 0; i < listModel.getSize(); i++) { DAPVariable variable = (DAPVariable) listModel.getElementAt(i); DAPVariable currentVariable = (DAPVariable) model.getModel().getElementAt(anchorSelectionIndex); if (variable.equals(currentVariable)) { boolean isSelected = model.isSelectedIndex(anchorSelectionIndex); setVariableSelected(currentVariable, isSelected); } } updateUI(true, true, true); } });
@Test public void testEquals() throws Exception { //preparation DAPVariable dapVariable2 = new DAPVariable(vName, vType, vDataType, vDimensions); final DArrayDimension otherDimension = new DArrayDimension(1000, "otherDimension"); DAPVariable dapVariable3 = new DAPVariable(vName, vType, vDataType, new DArrayDimension[]{otherDimension}); final DArrayDimension otherXDimension = new DArrayDimension(1121, "X"); final DArrayDimension otherYDimension = new DArrayDimension(812, "Y"); DArrayDimension[] otherDimensions = {otherYDimension, otherXDimension}; DAPVariable dapVariable4 = new DAPVariable(vName, vType, vDataType, otherDimensions); //verification assertTrue(dapVariable.equals(dapVariable2)); assertFalse(dapVariable.equals(dapVariable3)); assertTrue(dapVariable.equals(dapVariable4)); }