use of com.servoy.j2db.smart.dataui.CellAdapter in project servoy-client by Servoy.
the class FixedJTable method isCellEditable.
/*
* @see javax.swing.JTable#isCellEditable(int, int)
*/
@Override
public boolean isCellEditable(int row, int column) {
Object o = getCellEditor(row, column);
if (o instanceof CellAdapter) {
Component comp = ((CellAdapter) o).getEditor();
boolean isReadOnlyEditor = (comp instanceof IDelegate) && (((IDelegate) comp).getDelegate() instanceof JEditorPane) && !((JEditorPane) ((IDelegate) comp).getDelegate()).isEditable();
if ((comp instanceof JButton || comp instanceof JLabel || isReadOnlyEditor) && comp.isEnabled()) {
return true;
}
}
return super.isCellEditable(row, column);
}
use of com.servoy.j2db.smart.dataui.CellAdapter in project servoy-client by Servoy.
the class TableView method moveColumnInSameGroup.
private boolean moveColumnInSameGroup(TableColumn column, int offset) {
Component editor = ((CellAdapter) column).getEditor();
String groupId = (String) fc.getComponentProperty(editor, ComponentFactory.GROUPID_COMPONENT_PROPERTY);
if (groupId == null) {
return false;
}
// find the columns offsetted to this column in the original columns
int orgIindex = tableColumnsBeforeDrag.indexOf(column);
if (orgIindex == -1) {
// strange, should not happen
return false;
}
if ((offset < 0 && orgIindex + offset < 0) || (offset > 0 && orgIindex + offset >= tableColumnsBeforeDrag.size())) {
// no more columns in original set
return false;
}
int currIndex = indexOfColumn(column);
if (currIndex == -1) {
// strange, should not happen
return false;
}
TableColumn column2 = tableColumnsBeforeDrag.get(orgIindex + offset);
Component editor2 = ((CellAdapter) column2).getEditor();
if (!groupId.equals(fc.getComponentProperty(editor2, ComponentFactory.GROUPID_COMPONENT_PROPERTY))) {
// original column at offset is not part of the same group
return false;
}
int currIndex2 = indexOfColumn(column2);
if (currIndex2 == -1) {
// strange, should not happen
return false;
}
// move this one next to the prev
if (offset < 0) {
if (currIndex2 > currIndex) {
if (currIndex2 != currIndex + offset + 1) {
getColumnModel().moveColumn(currIndex2, currIndex + offset + 1);
}
} else {
if (currIndex2 != currIndex + offset) {
getColumnModel().moveColumn(currIndex2, currIndex + offset);
}
}
} else {
if (currIndex2 < currIndex) {
if (currIndex2 != currIndex + offset - 1) {
getColumnModel().moveColumn(currIndex2, currIndex + offset - 1);
}
} else {
if (currIndex2 != currIndex + offset) {
getColumnModel().moveColumn(currIndex2, currIndex + offset);
}
}
}
// moved
return true;
}
use of com.servoy.j2db.smart.dataui.CellAdapter in project servoy-client by Servoy.
the class TableView method isCellEditable.
@Override
public boolean isCellEditable(int row, int column) {
boolean isCellEditable = super.isCellEditable(row, column);
if (isCellEditable) {
Object o = getCellEditor(row, column);
if (o instanceof CellAdapter && ((CellAdapter) o).getEditor() instanceof IScriptableProvider && ((IScriptableProvider) ((CellAdapter) o).getEditor()).getScriptObject() instanceof ISupportOnRenderCallback) {
Object value = getValueAt(row, column);
boolean isSelected = isCellSelected(row, column);
Component c = ((CellAdapter) o).getTableCellEditorComponent(this, value, isSelected, row, column);
if (c instanceof IScriptableProvider) {
IScriptable scriptable = ((IScriptableProvider) c).getScriptObject();
if (scriptable instanceof ISupportOnRenderCallback) {
RenderEventExecutor renderEventExecutor = ((ISupportOnRenderCallback) scriptable).getRenderEventExecutor();
if (renderEventExecutor != null) {
renderEventExecutor.fireOnRender(false);
isCellEditable = c.isEnabled();
}
}
}
}
}
return isCellEditable;
}
use of com.servoy.j2db.smart.dataui.CellAdapter in project servoy-client by Servoy.
the class TableView method getDragSource.
public IComponent getDragSource(Point xy) {
int columnNrAtXY = columnAtPoint(xy);
int rowNrAtXY = rowAtPoint(xy);
if (columnNrAtXY > -1 && rowNrAtXY > -1) {
CellAdapter column = (CellAdapter) getColumnModel().getColumn(columnNrAtXY);
Component renderer = column.getTableCellRendererComponent(this, null, false, false, rowNrAtXY, columnNrAtXY);
if (renderer instanceof IComponent && renderer.isEnabled())
return (IComponent) renderer;
}
return this;
}
use of com.servoy.j2db.smart.dataui.CellAdapter in project servoy-client by Servoy.
the class TableView method setSortStatus.
public boolean setSortStatus(IFoundSetInternal foundset) {
if (foundset != null) {
List<SortColumn> sortCols = foundset.getSortColumns();
if (sortCols != null && sortCols.size() > 0) {
boolean found = false;
for (SortColumn sc : sortCols) {
for (int i = 0; (i < getColumnModel().getColumnCount()); i++) {
TableColumn tc = getColumnModel().getColumn(i);
if (tc instanceof CellAdapter) {
CellAdapter ca = (CellAdapter) tc;
if (ca.getDataProviderID() != null) {
List<String> sortingProviders = null;
Component renderer = ca.getRenderer();
if (renderer instanceof ISupportValueList && ((ISupportValueList) renderer).getValueList() != null) {
try {
sortingProviders = DBValueList.getShowDataproviders(((ISupportValueList) renderer).getValueList().getValueList(), (Table) foundset.getTable(), ca.getDataProviderID(), application.getFoundSetManager());
} catch (RepositoryException ex) {
Debug.error(ex);
}
}
if (sortingProviders == null) {
// no related sort, use sort on dataProviderID instead
sortingProviders = Collections.singletonList(ca.getDataProviderID());
}
for (String sortingProvider : sortingProviders) {
SortColumn existingSc;
try {
FoundSetManager fsm = (FoundSetManager) foundset.getFoundSetManager();
existingSc = fsm.getSortColumn(foundset.getTable(), sortingProvider, false);
} catch (Exception e) {
Debug.error(e);
continue;
}
if (sc.equalsIgnoreSortorder(existingSc)) {
if (!found) {
// clear old sort
updateSortStatus(-1, true);
}
found = true;
updateSortStatus(ca.getModelIndex(), sc.getSortOrder() == SortColumn.ASCENDING);
}
}
}
}
}
}
return found;
}
}
return false;
}
Aggregations