use of com.servoy.j2db.IView in project servoy-client by Servoy.
the class SwingForm method prepareForSave.
public void prepareForSave(boolean looseFocus) {
final Component currentFocusHolder = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
Component component = currentFocusHolder;
if (component instanceof JRootPane || component instanceof JFrame) {
// do not give focus to swing form as will transfer it to first field
// component = this;
} else
while (component != null && !(component instanceof Window) && !(component instanceof IView) && !isPartOfSlider(component) && !isPartOfTabPanel(component)) {
component = component.getParent();
}
if (component != null && currentFocusHolder != component && !(component instanceof TableView) && !(component instanceof ListView && !((ListView) component).isEditing())) {
// this used to be in invokelater, however reverted the change because it interfered with js focus calls
component.requestFocus();
}
}
use of com.servoy.j2db.IView in project servoy-client by Servoy.
the class CellAdapter method getBgColor.
private Color getBgColor(JTable jtable, boolean isSelected, int row, boolean isEdited) {
Color bgColor = null;
IRecordInternal state = ((IFoundSetInternal) jtable.getModel()).getRecord(row);
boolean specialStateCase = (state instanceof PrototypeState || state instanceof FindState || state == null || state.getRawData() == null);
if (/* !(renderer instanceof JButton) && */
!specialStateCase) {
ISwingFoundSet foundset = (ISwingFoundSet) jtable.getModel();
bgColor = (Color) getStyleAttributeForRow(jtable, isSelected, row, ISupportRowStyling.ATTRIBUTE.BGCOLOR);
String strRowBGColorProvider = null;
List<Object> rowBGColorArgs = null;
if (jtable instanceof IView) {
strRowBGColorProvider = ((IView) jtable).getRowBGColorScript();
rowBGColorArgs = ((IView) jtable).getRowBGColorArgs();
}
// $NON-NLS-1$
if (strRowBGColorProvider == null)
strRowBGColorProvider = "servoy_row_bgcolor";
boolean isRowBGColorCalculation = state.getRawData().containsCalculation(strRowBGColorProvider);
if (// $NON-NLS-1$
!isRowBGColorCalculation && strRowBGColorProvider.equals("servoy_row_bgcolor")) {
// $NON-NLS-1$
strRowBGColorProvider = "";
}
if (// $NON-NLS-1$
strRowBGColorProvider != null && !"".equals(strRowBGColorProvider)) {
Object bg_color = null;
// TODO this should be done better....
Record.VALIDATE_CALCS.set(Boolean.FALSE);
try {
String type = (editor instanceof IScriptableProvider && ((IScriptableProvider) editor).getScriptObject() instanceof IRuntimeComponent) ? ((IRuntimeComponent) ((IScriptableProvider) editor).getScriptObject()).getElementType() : null;
String nm = (editor instanceof IDisplayData) ? ((IDisplayData) editor).getDataProviderID() : null;
if (isRowBGColorCalculation) {
bg_color = foundset.getCalculationValue(state, strRowBGColorProvider, Utils.arrayMerge((new Object[] { new Integer(row), new Boolean(isSelected), type, nm, new Boolean(isEdited) }), Utils.parseJSExpressions(rowBGColorArgs)), null);
} else {
try {
FormController currentForm = dal.getFormController();
bg_color = currentForm.executeFunction(strRowBGColorProvider, Utils.arrayMerge((new Object[] { new Integer(row), new Boolean(isSelected), type, nm, currentForm.getName(), state, new Boolean(isEdited) }), Utils.parseJSExpressions(rowBGColorArgs)), false, null, true, null);
} catch (Exception ex) {
Debug.error(ex);
}
}
} finally {
Record.VALIDATE_CALCS.set(null);
}
if (bg_color != null && !(bg_color.toString().trim().length() == 0) && !(bg_color instanceof Undefined)) {
bgColor = PersistHelper.createColor(bg_color.toString());
}
}
}
return bgColor;
}
Aggregations