Commit e3430674 authored by Johannes Eder's avatar Johannes Eder
Browse files

removed unused classes

Issue-Ref: 3886
Issue-Url: https://af3-developer.fortiss.org/issues/3886

Signed-off-by: Johannes Eder's avatarJohannes Eder <eder@fortiss.org>
parent b9d2c808
/*-------------------------------------------------------------------------+
| Copyright 2014 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.utils;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Class for handling the rows of type T and their index in the GUI table.
*
* @author teufl
*/
public class TableRowIndexMap<T> {
/** Map of rows and their row index in a GUI table. */
private Map<T, Integer> tableRowIndexMap;
/** Constructor */
public TableRowIndexMap() {
this.tableRowIndexMap = new HashMap<T, Integer>();
}
/**
* Associates the rows with their row index in this map.
*
* @param row
* the row
* @param index
* the row index
*/
public void put(T row, Integer index) {
tableRowIndexMap.put(row, index);
}
/**
* Gets the row index for a row.
*
* @param row
* the row
* @return the row index
*/
public Integer get(T row) {
return tableRowIndexMap.get(row);
}
/**
* Remove a row from the index map.
*
* @param row
* the row
*/
public void remove(T row) {
tableRowIndexMap.remove(row);
}
/**
* Get iterator over rows.
*
* @return iterator over the rows
*/
public Set<T> rowSet() {
return tableRowIndexMap.keySet();
}
/**
* Adjust item index map to corresponding index.
*
* @param index
* the index to remove
*/
public void removeIndex(int index) {
for(T row : rowSet()) {
if(tableRowIndexMap.get(row).intValue() > index) {
tableRowIndexMap.put(row, tableRowIndexMap.get(row).intValue() - 1);
}
}
}
/**
* Return the row of a given index.
*
* @param index
* the index
* @return row
*/
public T getRowWithIndex(int index) {
for(T row : rowSet()) {
if(tableRowIndexMap.get(row).intValue() == index) {
return row;
}
}
throw new IllegalArgumentException("No entry at row " + index);
}
/**
* Checks if map contains row.
*
* @param row
* the row
* @return map contains row
*/
public boolean containsRow(T row) {
return tableRowIndexMap.containsKey(row);
}
}
/*-------------------------------------------------------------------------+
| Copyright 2014 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.ui.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.swt.widgets.Button;
/**
* Class for managing the selection buttons for rows of type T in the GUI table.
*
* @author teufl
*/
public class TableRowSelectionButtonMap<T> {
/** Selection buttons list. */
private ArrayList<Button> selectionButtons;
/** Selected relation */
private T selectedRow;
/** Hashmap connecting rows and selection buttons. */
private Map<T, Button> rowsButtonsMap;
/** Constructor. */
public TableRowSelectionButtonMap() {
this.selectionButtons = new ArrayList<Button>();
this.selectedRow = null;
this.rowsButtonsMap = new HashMap<T, Button>();
}
/** Add a new selection button */
public void addNewSelectionButton(Button button) {
selectionButtons.add(button);
}
/**
* Connect rows and buttons.
*
* @param tableRowIndexMap
* map storing all rows and their index in the gui table
*/
public void connectTableRowsAndSelectionButtons(TableRowIndexMap<T> tableRowIndexMap) {
selectedRow = null;
for(int i = 0; i < selectionButtons.size(); i++) {
rowsButtonsMap.put(tableRowIndexMap.getRowWithIndex(i), selectionButtons.get(i));
}
}
/**
* Set a selected row.
*
* @param row
* the row
*/
public void setSelectedRow(T row) {
// if another radio button was selected already, deselect it
if(selectedRow != null) {
for(Button b : rowsButtonsMap.values()) {
b.setSelection(false);
}
}
selectedRow = row;
}
/**
* Get the selected row.
*
* @return selected row
*/
public T getSelectedRow() {
return selectedRow;
}
/**
* Add row to hash maps.
*
* @param row
* the row
* @param index
* the index
*/
public void addRowToRowButtonMap(T row, int index) {
rowsButtonsMap.put(row, selectionButtons.get(index));
}
/** Remove selected row from hash maps. */
public void removeRowFromRowButtonMap() {
rowsButtonsMap.remove(selectedRow);
selectedRow = null;
}
/** Refresh check buttons. */
public void refreshSelectionButtons() {
for(Iterator<Button> buttons = selectionButtons.iterator(); buttons.hasNext();) {
if(buttons.next().isDisposed())
buttons.remove();
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment