import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class SpreadsheetModel {
+ final private static String OPERATIONMODE = "Operation Mode";
+ final private static String EDITMODE = "Edit Mode";
+
final private Adaptable serverInterface;
final private ClientModel clientModel;
final private ActiveSelectionProvider selectionProvider;
CellEditor editor = serverInterface.getAdapter(CellEditor.class);
if (editor != null) {
- if (arg0.getStateChange() == ItemEvent.SELECTED)
- editor.edit(null, ClientModel.SHEETS, ClientModel.SHEETS_CURRENT, arg0.getItem(), null,
- null);
+ if (arg0.getStateChange() == ItemEvent.SELECTED) {
+ editor.edit(null, ClientModel.SHEETS, ClientModel.SHEETS_CURRENT, arg0.getItem(), null, null);
+ HashSet<String> targets = new HashSet<>();
+ targets.add(ClientModel.MODE);
+ resetSelections(editor, targets);
+ }
}
}
};
CellEditor editor = serverInterface.getAdapter(CellEditor.class);
if(editor != null) {
- if(arg0.getStateChange() == ItemEvent.SELECTED)
+ if(arg0.getStateChange() == ItemEvent.SELECTED) {
editor.edit(null, ClientModel.SOURCES, ClientModel.SOURCES_CURRENT, arg0.getItem(), null, null);
+ }
}
}
OperationMode currentMode = clientModel.getPropertyAt(ClientModel.MODE, ClientModel.MODE_CURRENT);
String text;
if (currentMode.equals(OperationMode.OPERATION))
- text = "Operation Mode";
+ text = OPERATIONMODE;
else
- text = "Edit Mode";
+ text = EDITMODE;
operationMode = new JToggleButton(text);
operationMode.addActionListener(new ActionListener() {
}
+ private void resetSelections(CellEditor editor, HashSet<String> targets) {
+ if(targets.contains(ClientModel.MODE)) {
+ editor.edit(null, ClientModel.MODE, ClientModel.MODE_CURRENT, OperationMode.OPERATION, null, null);
+ operationMode.setText(OPERATIONMODE);
+ }
+ }
+
private boolean isRectangularSelection(SpreadsheetTable table) {
int[] selectedColumns = table.getSelectedColumns();
int[] selectedRows = table.getSelectedRows();