use of com.revolsys.swing.field.Field in project com.revolsys.open by revolsys.
the class BaseStylePanel method newField.
@SuppressWarnings("unchecked")
protected Field newField(final String fieldName, final Class<?> fieldClass, final Object value) {
Field field;
if (fieldName.equals("visible")) {
this.visibleField = new CheckBox(fieldName, value);
field = this.visibleField;
} else if (fieldName.equals("textFaceName")) {
field = new FontChooserField(fieldName, (String) value);
} else if (fieldName.endsWith("HorizontalAlignment")) {
field = newHorizontalAlignmentField(fieldName, (String) value);
} else if (fieldName.endsWith("VerticalAlignment")) {
field = newVerticalAlignmentField(fieldName, (String) value);
} else if (fieldName.equals("lineCap")) {
field = newLineCapField((LineCap) value);
} else if (fieldName.equals("lineJoin")) {
field = newLineJoinField((LineJoin) value);
} else if (fieldName.equals("lineDashArray")) {
field = new DashField(fieldName, (List<Quantity<Length>>) value);
} else if (fieldName.equals("queryFilter")) {
final AbstractRecordLayer layer = getLayer();
field = new QueryFilterField(layer, fieldName, (String) value);
field.setFieldValue(value);
Property.addListener(field, fieldName, this);
} else if (fieldName.equals("marker")) {
field = new MarkerField(fieldName, value);
} else if (fieldName.endsWith("OrientationType")) {
final ComboBox<String> orientationTypeField = ComboBox.newComboBox(fieldName, "auto", "none");
orientationTypeField.setFieldValue(value);
field = orientationTypeField;
} else if (fieldName.equals("markerPlacementType")) {
final ComboBox<String> placementField = ComboBox.newComboBox(fieldName, "auto", "center", "vertex(0)", "vertex(n)", "vertices", "segment(0)", "segment(n)", "segments");
placementField.setFieldValue(value);
field = placementField;
} else if (fieldName.equals("textPlacementType")) {
final ComboBox<String> placementField = ComboBox.newComboBox(fieldName, "auto", "center", "vertex(0)", "vertex(n)", "segment(0)", "segment(n)");
placementField.setFieldValue(value);
field = placementField;
} else if (fieldName.endsWith("Scale")) {
field = newScaleField(fieldName, (Long) value);
} else if (Color.class.equals(fieldClass)) {
field = new ColorChooserField(fieldName, (Color) value);
} else if (Boolean.TYPE.equals(fieldClass) || Boolean.class.equals(fieldClass)) {
field = new CheckBox(fieldName, value);
} else if (Quantity.class.equals(fieldClass)) {
field = new LengthMeasureTextField(fieldName, (Quantity<Length>) value, CustomUnits.PIXEL);
} else {
field = new TextField(fieldName, value, 40);
}
return field;
}
use of com.revolsys.swing.field.Field in project com.revolsys.open by revolsys.
the class RecordTableCellEditor method stopCellEditing.
@Override
public boolean stopCellEditing() {
boolean stopped = false;
try {
if (this.editorComponent instanceof Field) {
final Field field = (Field) this.editorComponent;
field.updateFieldValue();
}
stopped = super.stopCellEditing();
} catch (final IndexOutOfBoundsException e) {
return true;
} catch (final Throwable t) {
final int result = JOptionPane.showConfirmDialog(this.editorComponent, "<html><p><b>'" + getCellEditorValue() + "' is not a valid " + this.dataType.getValidationName() + ".</b></p><p>Discard changes (Yes) or edit field (No).</p></html>", "Invalid value", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
if (result == JOptionPane.YES_OPTION) {
cancelCellEditing();
return true;
} else {
return false;
}
} finally {
if (stopped) {
if (this.editorComponent != null) {
this.editorComponent.removeMouseListener(this.mouseListeners);
this.editorComponent.removeKeyListener(this);
if (this.editorComponent instanceof JComboBox) {
final JComboBox<?> comboBox = (JComboBox<?>) this.editorComponent;
final ComboBoxEditor editor = comboBox.getEditor();
final Component comboEditorComponent = editor.getEditorComponent();
comboEditorComponent.removeKeyListener(this);
comboEditorComponent.removeMouseListener(this.mouseListeners);
} else if (this.editorComponent instanceof AbstractRecordQueryField) {
final AbstractRecordQueryField queryField = (AbstractRecordQueryField) this.editorComponent;
final TextField searchField = queryField.getSearchField();
searchField.removeKeyListener(this);
searchField.removeMouseListener(this.mouseListeners);
}
if (this.popupMenuListener != null) {
this.popupMenuListener.close();
this.popupMenuListener = null;
}
}
}
}
return stopped;
}
use of com.revolsys.swing.field.Field in project com.revolsys.open by revolsys.
the class BaseTableCellEditor method stopCellEditing.
@Override
public boolean stopCellEditing() {
boolean stopped = false;
try {
if (this.editorComponent instanceof Field) {
final Field field = (Field) this.editorComponent;
field.updateFieldValue();
}
stopped = super.stopCellEditing();
} catch (final IndexOutOfBoundsException e) {
return true;
} catch (final Throwable t) {
final int result = JOptionPane.showConfirmDialog(this.editorComponent, "<html><p><b>'" + getCellEditorValue() + "' is not a valid " + this.dataType.getValidationName() + ".</b></p><p>Discard changes (Yes) or edit field (No).</p></html>", "Invalid value", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
if (result == JOptionPane.YES_OPTION) {
cancelCellEditing();
return true;
} else {
return false;
}
} finally {
if (stopped) {
if (this.editorComponent != null) {
this.editorComponent.removeMouseListener(this.mouseListeners);
this.editorComponent.removeKeyListener(this);
if (this.editorComponent instanceof JComboBox) {
final JComboBox<?> comboBox = (JComboBox<?>) this.editorComponent;
final ComboBoxEditor editor = comboBox.getEditor();
final Component comboEditorComponent = editor.getEditorComponent();
comboEditorComponent.removeKeyListener(this);
comboEditorComponent.removeMouseListener(this.mouseListeners);
}
}
}
}
return stopped;
}
use of com.revolsys.swing.field.Field in project com.revolsys.open by revolsys.
the class RecordTableCellEditor method getTableCellEditorComponent.
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, int rowIndex, int columnIndex) {
rowIndex = table.convertRowIndexToModel(rowIndex);
columnIndex = table.convertColumnIndexToModel(columnIndex);
this.oldValue = value;
final AbstractRecordTableModel model = getTableModel();
this.fieldName = model.getColumnFieldName(rowIndex, columnIndex);
final RecordDefinition recordDefinition = model.getRecordDefinition();
this.dataType = recordDefinition.getFieldType(this.fieldName);
final Field field = newField(this.fieldName);
this.editorComponent = (JComponent) field;
if (this.editorComponent instanceof JTextField) {
final JTextField textField = (JTextField) this.editorComponent;
textField.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(WebColors.LightSteelBlue), BorderFactory.createEmptyBorder(1, 2, 1, 2)));
} else if (this.editorComponent instanceof AbstractRecordQueryField) {
final AbstractRecordQueryField queryField = (AbstractRecordQueryField) this.editorComponent;
queryField.setSearchFieldBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(WebColors.LightSteelBlue), BorderFactory.createEmptyBorder(1, 2, 1, 2)));
}
this.editorComponent.setOpaque(false);
SwingUtil.setFieldValue(this.editorComponent, value);
this.rowIndex = rowIndex;
this.columnIndex = columnIndex;
this.editorComponent.addKeyListener(this);
this.editorComponent.addMouseListener(this.mouseListeners);
if (this.editorComponent instanceof JComboBox) {
final JComboBox<?> comboBox = (JComboBox<?>) this.editorComponent;
final ComboBoxEditor editor = comboBox.getEditor();
final Component comboEditorComponent = editor.getEditorComponent();
comboEditorComponent.addKeyListener(this);
comboEditorComponent.addMouseListener(this.mouseListeners);
} else if (this.editorComponent instanceof AbstractRecordQueryField) {
final AbstractRecordQueryField queryField = (AbstractRecordQueryField) this.editorComponent;
final TextField searchField = queryField.getSearchField();
searchField.addKeyListener(this);
searchField.addMouseListener(this.mouseListeners);
}
this.popupMenuListener = ShowMenuMouseListener.addListener(this.editorComponent, this.popupMenuFactory);
return this.editorComponent;
}
use of com.revolsys.swing.field.Field in project com.revolsys.open by revolsys.
the class MenuFactory method getPopupMenuFactory.
public static MenuFactory getPopupMenuFactory(final JComponent component) {
synchronized (component) {
MenuFactory menuFactory = (MenuFactory) component.getClientProperty(KEY_POPUP_MENU);
if (menuFactory == null) {
String name = "Field";
if (component instanceof Field) {
final Field field = (Field) component;
name += " " + field.getFieldName();
}
menuFactory = new MenuFactory(name);
addToComponent(component, menuFactory);
}
return menuFactory;
}
}
Aggregations