use of org.eclipse.jface.util.IPropertyChangeListener 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;
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class ImportAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
if (Display.getCurrent() == null) {
// execute in display thread
PlatformUI.getWorkbench().getDisplay().asyncExec(this);
return;
}
if (actionId == null)
return;
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive();
IOWizardAction action = new IOWizardAction(actionId);
if (action.isEnabled()) {
action.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (IAction.RESULT.equals(event.getProperty()))
notifyResult((Boolean) event.getNewValue());
}
});
action.run();
} else {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "Action disabled", action.getFactory().getDisabledReason());
notifyResult(false);
}
action.dispose();
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class AssignParameterPage method createContent.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createContent(Composite page) {
this.page = page;
page.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create());
// is created)
if (getWizard().getUnfinishedCell().getTarget() != null) {
EntityDefinition entityDef = getWizard().getUnfinishedCell().getTarget().values().iterator().next().getDefinition();
PropertyDefinition propDef = (PropertyDefinition) entityDef.getDefinition();
title = new Composite(page, SWT.NONE);
title.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).margins(0, 0).create());
// title.setLayoutData(GridDataFactory.swtDefaults().align(SWT.END, SWT.END).create());
DefinitionLabelFactory dlf = PlatformUI.getWorkbench().getService(DefinitionLabelFactory.class);
dlf.createLabel(title, propDef, false);
Label label = new Label(title, SWT.NONE);
label.setText(" = ");
editor = PlatformUI.getWorkbench().getService(AttributeEditorFactory.class).createEditor(page, propDef, entityDef, false);
editor.setVariableReplacer(new TransformationVariableReplacer());
editor.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
editor.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(AttributeEditor.IS_VALID))
setPageComplete((Boolean) event.getNewValue());
}
});
}
if (editor != null && initialValue != null) {
editor.setAsText(initialValue.as(String.class));
if (editor instanceof EditorChooserEditor)
((EditorChooserEditor<?>) editor).selectEditor(initialValue.getType());
}
if (editor != null)
setPageComplete(editor.isValid());
}
use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.
the class FileTarget method createControls.
@Override
public void createControls(Composite parent) {
getPage().setDescription("Please select a destination file for the export");
parent.setLayout(new GridLayout(3, false));
targetFile = new SaveFileFieldEditor("targetFile", "Target file:", true, FileFieldEditor.VALIDATE_ON_KEY_STROKE, parent);
targetFile.setEmptyStringAllowed(false);
targetFile.setAllowUri(true);
targetFile.setPage(getPage());
targetFile.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(FieldEditor.IS_VALID)) {
updateState();
} else if (event.getProperty().equals(FieldEditor.VALUE)) {
updateContentType();
}
}
});
updateState();
}
use of org.eclipse.jface.util.IPropertyChangeListener in project archi by archimatetool.
the class UIUtils method applyFontChangePreferenceListener.
/**
* Apply a font change preference listener on a control. The control will update when preference changes.
* @param control
* @param prefsKey
*/
public static void applyFontChangePreferenceListener(Control control, String prefsKey) {
IPropertyChangeListener listener = (event) -> {
if (prefsKey == event.getProperty()) {
setFontFromPreferences(control, prefsKey, false);
}
};
ArchiPlugin.PREFERENCES.addPropertyChangeListener(listener);
control.addDisposeListener((e) -> {
ArchiPlugin.PREFERENCES.removePropertyChangeListener(listener);
});
}
Aggregations