use of org.eclipse.e4.ui.services.IStylingEngine in project aero.minova.rcp by minova-afis.
the class DateTimeField method create.
public static Control create(Composite composite, MField field, int row, int column, Locale locale, String timezone, MPerspective perspective, TranslationService translationService) {
Preferences preferences = InstanceScope.INSTANCE.getNode(ApplicationPreferences.PREFERENCES_NODE);
String dateUtil = (String) InstancePreferenceAccessor.getValue(preferences, ApplicationPreferences.DATE_UTIL, DisplayType.DATE_UTIL, "", locale);
String timeUtil = (String) InstancePreferenceAccessor.getValue(preferences, ApplicationPreferences.TIME_UTIL, DisplayType.TIME_UTIL, "", locale);
Label label = FieldLabel.create(composite, field);
TextAssistContentProvider contentProvider = new TextAssistContentProvider() {
@Override
public List<String> getContent(String entry) {
ArrayList<String> result = new ArrayList<>();
Instant date = DateTimeUtil.getDateTime(Instant.now(), entry, locale);
if (date == null && !entry.isEmpty()) {
result.add(translationService.translate("@msg.ErrorConverting", null));
} else {
result.add(DateTimeUtil.getDateTimeString(date, locale, dateUtil, timeUtil));
field.setValue(new Value(date), true);
}
return result;
}
};
TextAssist text = new TextAssist(composite, SWT.BORDER, contentProvider);
LocalDateTime of = LocalDateTime.of(LocalDate.of(2020, 12, 12), LocalTime.of(22, 55));
text.setMessage(DateTimeUtil.getDateTimeString(of.toInstant(ZoneOffset.UTC), locale, dateUtil, timeUtil));
text.setNumberOfLines(1);
text.setData(TRANSLATE_LOCALE, locale);
text.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
text.selectAll();
}
@Override
public void focusLost(FocusEvent e) {
if (text.getText().isBlank()) {
field.setValue(null, true);
}
}
});
text.setData(Constants.CONTROL_FIELD, field);
// ValueAccessor in den Context injecten, damit IStylingEngine über @Inject verfügbar ist (in AbstractValueAccessor)
IEclipseContext context = perspective.getContext();
DateTimeValueAccessor valueAccessor = new DateTimeValueAccessor(field, text);
ContextInjectionFactory.inject(valueAccessor, context);
field.setValueAccessor(valueAccessor);
FormData fd = new FormData();
fd.top = new FormAttachment(composite, MARGIN_TOP + row * COLUMN_HEIGHT);
fd.left = new FormAttachment(column == 0 ? 25 : 75);
fd.right = new FormAttachment(column == 0 ? 50 : 100, column == 0 ? -ICssStyler.CSS_SECTION_SPACING : -MARGIN_BORDER);
text.setLayoutData(fd);
text.setData(CssData.CSSDATA_KEY, new CssData(CssType.DATE_TIME_FIELD, column + 1, row, field.getNumberColumnsSpanned(), field.getNumberRowsSpanned(), false));
FieldLabel.layout(label, text, row, column, field.getNumberRowsSpanned());
return text;
}
use of org.eclipse.e4.ui.services.IStylingEngine in project aero.minova.rcp by minova-afis.
the class BooleanField method create.
public static Control create(Composite composite, MField field, int row, int column, Locale locale, MPerspective perspective) {
String labelText = field.getLabel() == null ? "" : field.getLabel();
Button button = ButtonFactory.newButton(SWT.CHECK).text(field.getLabel()).create(composite);
// ValueAccessor in den Context injecten, damit IStylingEngine über @Inject verfügbar ist (in AbstractValueAccessor)
IEclipseContext context = perspective.getContext();
BooleanValueAccessor valueAccessor = new BooleanValueAccessor(field, button);
ContextInjectionFactory.inject(valueAccessor, context);
field.setValueAccessor(valueAccessor);
FormData fd = new FormData();
fd.top = new FormAttachment(composite, MARGIN_TOP + row * COLUMN_HEIGHT);
fd.left = new FormAttachment((column == 0) ? 25 : 75);
fd.width = TEXT_WIDTH;
button.setLayoutData(fd);
button.setData(CssData.CSSDATA_KEY, new CssData(CssType.TEXT_FIELD, column + 1, row, 1, 1, false));
button.setData(CSSSWTConstants.CSS_CLASS_NAME_KEY, "Description");
button.setData(TRANSLATE_PROPERTY, labelText);
button.setData(TRANSLATE_LOCALE, locale);
button.setData(Constants.CONTROL_FIELD, field);
button.setData(Constants.CONTROL_DATATYPE, DataType.BOOLEAN);
button.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
field.setValue(new Value(button.getSelection()), true);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
field.setValue(new Value(button.getSelection()), true);
}
});
return button;
}
use of org.eclipse.e4.ui.services.IStylingEngine in project aero.minova.rcp by minova-afis.
the class ShortDateField method create.
public static Control create(Composite composite, MField field, int row, int column, Locale locale, String timezone, MPerspective perspective, TranslationService translationService) {
Preferences preferences = InstanceScope.INSTANCE.getNode(ApplicationPreferences.PREFERENCES_NODE);
String dateUtil = (String) InstancePreferenceAccessor.getValue(preferences, ApplicationPreferences.DATE_UTIL, DisplayType.DATE_UTIL, "", locale);
Label label = FieldLabel.create(composite, field);
TextAssistContentProvider contentProvider = new TextAssistContentProvider() {
@Override
public List<String> getContent(String entry) {
Preferences preferences = InstanceScope.INSTANCE.getNode(ApplicationPreferences.PREFERENCES_NODE);
String dateUtil = (String) InstancePreferenceAccessor.getValue(preferences, ApplicationPreferences.DATE_UTIL, DisplayType.DATE_UTIL, "", locale);
ArrayList<String> result = new ArrayList<>();
Instant date = DateUtil.getDate(entry, locale, dateUtil);
if (date == null) {
result.add(translationService.translate("@msg.ErrorConverting", null));
} else {
result.add(DateUtil.getDateString(date, locale, dateUtil));
field.setValue(new Value(date), true);
}
return result;
}
};
TextAssist text = new TextAssist(composite, SWT.BORDER, contentProvider);
LocalDateTime time = LocalDateTime.of(LocalDate.of(2000, 01, 01), LocalTime.of(11, 59));
text.setMessage(DateUtil.getDateString(time.toInstant(ZoneOffset.UTC), locale, dateUtil));
text.setNumberOfLines(1);
text.setData(TRANSLATE_LOCALE, locale);
text.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
text.selectAll();
}
@Override
public void focusLost(FocusEvent e) {
if (text.getText().isBlank()) {
field.setValue(null, true);
}
}
});
text.setData(Constants.CONTROL_FIELD, field);
// ValueAccessor in den Context injecten, damit IStylingEngine über @Inject verfügbar ist (in AbstractValueAccessor)
IEclipseContext context = perspective.getContext();
ShortDateValueAccessor valueAccessor = new ShortDateValueAccessor(field, text);
ContextInjectionFactory.inject(valueAccessor, context);
field.setValueAccessor(valueAccessor);
FormData fd = new FormData();
fd.top = new FormAttachment(composite, MARGIN_TOP + row * COLUMN_HEIGHT);
fd.left = new FormAttachment((column == 0) ? 25 : 75);
fd.width = SHORT_DATE_WIDTH;
text.setLayoutData(fd);
text.setData(CssData.CSSDATA_KEY, new CssData(CssType.DATE_FIELD, column + 1, row, field.getNumberColumnsSpanned(), field.getNumberRowsSpanned(), false));
FieldLabel.layout(label, text, row, column, field.getNumberRowsSpanned());
return text;
}
use of org.eclipse.e4.ui.services.IStylingEngine in project eclipse.platform.ui by eclipse-platform.
the class PerspectiveRenderer method createWidget.
@Override
public Widget createWidget(MUIElement element, Object parent) {
if (!(element instanceof MPerspective) || !(parent instanceof Composite))
return null;
Composite perspArea = new Composite((Composite) parent, SWT.NONE);
perspArea.setLayout(new FillLayout());
IStylingEngine stylingEngine = getContext(element).get(IStylingEngine.class);
// $NON-NLS-1$
stylingEngine.setClassname(perspArea, "perspectiveLayout");
return perspArea;
}
use of org.eclipse.e4.ui.services.IStylingEngine in project eclipse.platform.ui by eclipse-platform.
the class PerspectiveStackRenderer method createWidget.
@Override
public Object createWidget(MUIElement element, Object parent) {
if (!(element instanceof MPerspectiveStack) || !(parent instanceof Composite))
return null;
Composite perspStack = new Composite((Composite) parent, SWT.NONE);
IStylingEngine stylingEngine = getContext(element).get(IStylingEngine.class);
// $NON-NLS-1$
stylingEngine.setClassname(perspStack, "perspectiveLayout");
perspStack.setLayout(new StackLayout());
return perspStack;
}
Aggregations