Search in sources :

Example 96 with IPropertyChangeListener

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;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) SourceValidator(eu.esdihumboldt.hale.ui.util.source.SourceValidator) SourceViewerPanel(eu.esdihumboldt.hale.ui.util.source.SourceViewerPanel) IVerticalRuler(org.eclipse.jface.text.source.IVerticalRuler) GridData(org.eclipse.swt.layout.GridData)

Example 97 with IPropertyChangeListener

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();
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IOWizardAction(eu.esdihumboldt.hale.ui.io.action.IOWizardAction)

Example 98 with IPropertyChangeListener

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());
}
Also used : TransformationVariableReplacer(eu.esdihumboldt.hale.ui.transformation.TransformationVariableReplacer) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) DefinitionLabelFactory(eu.esdihumboldt.hale.ui.common.definition.DefinitionLabelFactory) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) EditorChooserEditor(eu.esdihumboldt.hale.ui.common.definition.editors.EditorChooserEditor) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)

Example 99 with IPropertyChangeListener

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();
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) GridLayout(org.eclipse.swt.layout.GridLayout) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) SaveFileFieldEditor(eu.esdihumboldt.hale.ui.util.io.SaveFileFieldEditor)

Example 100 with IPropertyChangeListener

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);
    });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) Text(org.eclipse.swt.widgets.Text) ArchiPlugin(com.archimatetool.editor.ArchiPlugin) GC(org.eclipse.swt.graphics.GC) Event(org.eclipse.swt.widgets.Event) PlatformUtils(com.archimatetool.editor.utils.PlatformUtils) Composite(org.eclipse.swt.widgets.Composite) Listener(org.eclipse.swt.widgets.Listener) StringUtils(com.archimatetool.editor.utils.StringUtils) SWT(org.eclipse.swt.SWT) FontData(org.eclipse.swt.graphics.FontData) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) Font(org.eclipse.swt.graphics.Font) Control(org.eclipse.swt.widgets.Control)

Aggregations

IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)126 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)120 Composite (org.eclipse.swt.widgets.Composite)55 GridData (org.eclipse.swt.layout.GridData)44 Label (org.eclipse.swt.widgets.Label)39 GridLayout (org.eclipse.swt.layout.GridLayout)37 SelectionEvent (org.eclipse.swt.events.SelectionEvent)31 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)25 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 Button (org.eclipse.swt.widgets.Button)22 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)21 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)20 ColorSelector (org.eclipse.jface.preference.ColorSelector)14 ComboViewer (org.eclipse.jface.viewers.ComboViewer)12 Text (org.eclipse.swt.widgets.Text)11 Iterator (java.util.Iterator)10 ISelection (org.eclipse.jface.viewers.ISelection)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)10 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)9 SashForm (org.eclipse.swt.custom.SashForm)9