use of eu.esdihumboldt.hale.ui.util.source.SourceViewerPanel in project hale by halestudio.
the class SourceViewerPage method createContent.
@Override
protected void createContent(Composite page) {
// init editor
IVerticalRuler ruler = createVerticalRuler();
IOverviewRuler overviewRuler = createOverviewRuler();
SourceViewerPanel<C> panel = new SourceViewerPanel<C>(page, ruler, overviewRuler, new SourceValidator() {
@Override
public boolean validate(String content) {
return SourceViewerPage.this.validate(content);
}
}, compiler);
viewer = panel.getViewer();
viewer.getTextWidget().setFont(JFaceResources.getTextFont());
viewer.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (ValidatingSourceViewer.PROPERTY_VALID.equals(event.getProperty())) {
getShell().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
setPageComplete((Boolean) event.getNewValue());
}
});
} else if (ValidatingSourceViewer.PROPERTY_VALIDATION_ENABLED.equals(event.getProperty())) {
if (!((Boolean) event.getNewValue())) {
// if validation is disabled, automatically set the page
// to be complete
setPageComplete(true);
}
}
}
});
configure(viewer);
SourceViewerKeyBindings.installDefault(viewer);
viewer.getDocument().set(initialValue);
addActions(panel.getToolbar(), viewer);
}
use of eu.esdihumboldt.hale.ui.util.source.SourceViewerPanel in project hale by halestudio.
the class SourceViewerParameterPage method createAndLayoutTextField.
/**
* @see SourceListParameterPage#createAndLayoutTextField(Composite)
*/
@Override
protected SourceViewer createAndLayoutTextField(Composite parent) {
// init editor
IVerticalRuler verticalRuler = createVerticalRuler();
IOverviewRuler overviewRuler = createOverviewRuler();
SourceViewerPanel<?> panel = new SourceViewerPanel<Void>(parent, verticalRuler, overviewRuler, new SourceValidator() {
@Override
public boolean validate(String content) {
return SourceViewerParameterPage.this.validate(content);
}
}, null);
viewer = panel.getViewer();
panel.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
viewer.getTextWidget().setFont(JFaceResources.getTextFont());
viewer.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (ValidatingSourceViewer.PROPERTY_VALID.equals(event.getProperty())) {
getShell().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
setPageComplete((Boolean) event.getNewValue());
}
});
}
if (ValidatingSourceViewer.PROPERTY_VALIDATION_ENABLED.equals(event.getProperty())) {
if (!((Boolean) event.getNewValue())) {
// if validation is disabled, automatically set the page
// to be complete
setPageComplete(true);
}
}
}
});
SourceViewerKeyBindings.installDefault(viewer);
addActions(panel.getToolbar(), viewer);
return viewer;
}
Aggregations