| Chunk |
|---|
| Conflicting content |
|---|
rendererPane.paintComponent(g, c, this, cellRect);
}
<<<<<<< HEAD
public ISpreadCellRenderer getCellRenderer(int row, int column) {
=======
protected ICellRenderer getCellRenderer(int row, int column) {
>>>>>>> e4ac311a4eceeba109998fab156d16b85fe12991
return defaultCellRenderer;
}
|
| Solution content |
|---|
rendererPane.paintComponent(g, c, this, cellRect);
}
public ISpreadCellRenderer getCellRenderer(int row, int column) {
return defaultCellRenderer;
}
|
| File |
|---|
| JSpread.java |
| Developer's decision |
|---|
| Version 1 |
| Kind of conflict |
|---|
| Method signature |
| Chunk |
|---|
| Conflicting content |
|---|
<<<<<<< HEAD
renderer.setBorder(border);
renderer.setBackground(this.getCellBackground(isSelected, hasFocus, row, col));
renderer.setHorizontalAlignment(this.getHorizontalAlignment(row, col));
Component c = renderer.getSpreadCellRendererComponent(this, s, isSelected, hasFocus, row, col);
return c;
}
/*
* methods related to cell editing
*/
public ISpreadCellEditor getCellEditor(int row, int col) {
ISpreadCellEditor editor = getCellEditor();
if(editor == null) {
editor = getDefaultCellEditor();
}
return editor;
}
/**
* Returns the active cell editor
* @return
*/
public ISpreadCellEditor getCellEditor() {
return cellEditor;
}
public void setCellEditor(ISpreadCellEditor cellEditor) {
this.cellEditor = cellEditor;
}
public ISpreadCellEditor getDefaultCellEditor() {
return defaultCellEditor;
}
private Component getEditorComponent() {
return editorComponent;
}
public boolean editCellAt(int row, int column) {
return editCellAt(row, column, null);
}
public boolean editCellAt(int row, int column, EventObject e){
if (row < 0 || row >= getRowCount() || column < 0 || column >= getColumnCount()) {
return false;
}
ISpreadCellEditor editor = getCellEditor(row, column);
editorComponent = prepareEditor(editor, row, column);
editorComponent.setBounds(getCellRect(row, column));
add(editorComponent);
editorComponent.validate();
setCellEditor(editor);
editor.addCellEditorListener(this);
return true;
}
public Component prepareEditor(ISpreadCellEditor editor, int row, int column) {
Object value = getModel().getValueAt(row, column);
boolean hasFocus = getFocusModel().isCellFocused(row, column);
Component comp = editor.getCellEditorComponent(this, value, hasFocus, row, column);
/*
if (comp instanceof JComponent) {
JComponent jComp = (JComponent)comp;
if (jComp.getNextFocusableComponent() == null) {
jComp.setNextFocusableComponent(this); }
}
*/
return comp;
}
public void removeEditor() {
ISpreadCellEditor editor = getCellEditor();
if(editor != null) {
editor.removeCellEditorListener(this);
}
if (editorComponent != null) {
remove(editorComponent);
//Rectangle cellRect = getCellRect(editingRow, editingColumn, false);
setCellEditor(null);
//setEditingColumn(-1);
//setEditingRow(-1);
editorComponent = null;
//repaint(cellRect);
}
}
@Override
protected boolean processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed){
boolean retValue = super.processKeyBinding(ks, e, condition, pressed);
if (!retValue && condition == WHEN_ANCESTOR_OF_FOCUSED_COMPONENT &&
isFocusOwner()) {
Component editorComponent = getEditorComponent();
if(editorComponent == null) {
// Only attempt to install the editor on a KEY_PRESSED,
if (e == null || e.getID() != KeyEvent.KEY_PRESSED) {
return false;
}
// Don't start when just a modifier is pressed
int code = e.getKeyCode();
if (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL || code == KeyEvent.VK_ALT) {
return false;
}
// Try to install the editor
//int leadRow = getSelectionModel().getLeadSelectionIndex();
//int leadColumn = getColumnModel().getSelectionModel().getLeadSelectionIndex();
//if (leadRow != -1 && leadColumn != -1 && !isEditing()) {
int row = getFocusModel().getRowIndex();
int col = getFocusModel().getColumnIndex();
if (!editCellAt(row, col)) {
return false;
}
editorComponent = getEditorComponent();
if (editorComponent == null) {
return false;
}
}
if (editorComponent instanceof JComponent) {
//retValue = ((JComponent)editorComponent).processKeyBinding(ks, e, WHEN_FOCUSED, pressed);
//if (getSurrendersFocusOnKeystroke()) {
editorComponent.requestFocus();
//}
}
}
return retValue;
}
@Override
public void editingCanceled(ChangeEvent arg0) {
removeEditor();
}
@Override
public void editingStopped(ChangeEvent arg0) {
ISpreadCellEditor editor = getCellEditor();
if (editor != null) {
Object value = editor.getCellEditorValue();
getModel().setValueAt(value, editingRow, editingColumn);
removeEditor();
}
=======
Component c = renderer.getCellRendererComponent(this, s, isSelected, hasFocus, row, col);
return c;
>>>>>>> e4ac311a4eceeba109998fab156d16b85fe12991
}
} |
| Solution content |
|---|
renderer.setBorder(border);
renderer.setBackground(this.getCellBackground(isSelected, hasFocus, row, col));
renderer.setHorizontalAlignment(this.getHorizontalAlignment(row, col));
Component c = renderer.getSpreadCellRendererComponent(this, s, isSelected, hasFocus, row, col);
return c;
}
/*
* methods related to cell editing
*/
public ISpreadCellEditor getCellEditor(int row, int col) {
ISpreadCellEditor editor = getCellEditor();
if(editor == null) {
editor = getDefaultCellEditor();
}
return editor;
}
/**
* Returns the active cell editor
* @return
*/
public ISpreadCellEditor getCellEditor() {
return cellEditor;
}
public void setCellEditor(ISpreadCellEditor cellEditor) {
this.cellEditor = cellEditor;
}
public ISpreadCellEditor getDefaultCellEditor() {
return defaultCellEditor;
}
private Component getEditorComponent() {
return editorComponent;
}
public boolean editCellAt(int row, int column) {
return editCellAt(row, column, null);
}
public boolean editCellAt(int row, int column, EventObject e){
if (row < 0 || row >= getRowCount() || column < 0 || column >= getColumnCount()) {
return false;
}
ISpreadCellEditor editor = getCellEditor(row, column);
editorComponent = prepareEditor(editor, row, column);
editorComponent.setBounds(getCellRect(row, column));
add(editorComponent);
editorComponent.validate();
setCellEditor(editor);
editor.addCellEditorListener(this);
return true;
}
public Component prepareEditor(ISpreadCellEditor editor, int row, int column) {
Object value = getModel().getValueAt(row, column);
boolean hasFocus = getFocusModel().isCellFocused(row, column);
Component comp = editor.getCellEditorComponent(this, value, hasFocus, row, column);
/*
if (comp instanceof JComponent) {
JComponent jComp = (JComponent)comp;
if (jComp.getNextFocusableComponent() == null) {
jComp.setNextFocusableComponent(this); }
}
*/
return comp;
}
public void removeEditor() {
ISpreadCellEditor editor = getCellEditor();
if(editor != null) {
editor.removeCellEditorListener(this);
}
if (editorComponent != null) {
remove(editorComponent);
//Rectangle cellRect = getCellRect(editingRow, editingColumn, false);
setCellEditor(null);
//setEditingColumn(-1);
//setEditingRow(-1);
editorComponent = null;
//repaint(cellRect);
}
}
@Override
protected boolean processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed){
boolean retValue = super.processKeyBinding(ks, e, condition, pressed);
if (!retValue && condition == WHEN_ANCESTOR_OF_FOCUSED_COMPONENT &&
isFocusOwner()) {
Component editorComponent = getEditorComponent();
if(editorComponent == null) {
// Only attempt to install the editor on a KEY_PRESSED,
if (e == null || e.getID() != KeyEvent.KEY_PRESSED) {
return false;
}
// Don't start when just a modifier is pressed
int code = e.getKeyCode();
if (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL || code == KeyEvent.VK_ALT) {
return false;
}
// Try to install the editor
//int leadRow = getSelectionModel().getLeadSelectionIndex();
//int leadColumn = getColumnModel().getSelectionModel().getLeadSelectionIndex();
//if (leadRow != -1 && leadColumn != -1 && !isEditing()) {
int row = getFocusModel().getRowIndex();
int col = getFocusModel().getColumnIndex();
if (!editCellAt(row, col)) {
return false;
}
editorComponent = getEditorComponent();
if (editorComponent == null) {
return false;
}
}
if (editorComponent instanceof JComponent) {
//retValue = ((JComponent)editorComponent).processKeyBinding(ks, e, WHEN_FOCUSED, pressed);
//if (getSurrendersFocusOnKeystroke()) {
editorComponent.requestFocus();
//}
}
}
return retValue;
}
@Override
public void editingCanceled(ChangeEvent arg0) {
removeEditor();
}
@Override
public void editingStopped(ChangeEvent arg0) {
ISpreadCellEditor editor = getCellEditor();
if (editor != null) {
Object value = editor.getCellEditorValue();
getModel().setValueAt(value, editingRow, editingColumn);
removeEditor();
}
}
} |
| File |
|---|
| JSpread.java |
| Developer's decision |
|---|
| Version 1 |
| Kind of conflict |
|---|
| Annotation |
| Comment |
| If statement |
| Method declaration |
| Method invocation |
| Method signature |
| Return statement |
| Variable |