Search in sources :

Example 46 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.

the class URLTarget method createControls.

/**
 * @see eu.esdihumboldt.hale.ui.io.ExportTarget#createControls(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createControls(Composite parent) {
    parent.setLayout(new GridLayout(3, false));
    // source file
    targetURL = new URLTargetURIFieldEditor("targetURL", "Target URL", parent) {

        @Override
        protected void onHistorySelected(URI location) {
            updateState();
        }
    };
    targetURL.setPage(getPage());
    targetURL.setPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(FieldEditor.IS_VALID)) {
                getPage().setMessage(null);
                updateState();
            } else if (event.getProperty().equals(FieldEditor.VALUE)) {
                getPage().setMessage(null);
                updateState();
            }
        }
    });
    // content type selection
    // label
    Label typesLabel = new Label(parent, SWT.NONE);
    typesLabel.setText("Content type");
    // types combo
    Composite group = new Composite(parent, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
    group.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
    types = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY);
    types.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    types.setContentProvider(ArrayContentProvider.getInstance());
    types.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IContentType) {
                return ((IContentType) element).getName();
            }
            return super.getText(element);
        }
    });
    // process selection changes
    types.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            // update content type
            ISelection sel = event.getSelection();
            if (sel.isEmpty() || !(sel instanceof IStructuredSelection)) {
                setContentType(null);
            } else {
                setContentType((IContentType) ((IStructuredSelection) sel).getFirstElement());
            }
        }
    });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) IContentType(org.eclipse.core.runtime.content.IContentType) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) URI(java.net.URI) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) ISelection(org.eclipse.jface.viewers.ISelection) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 47 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.

the class URLSource method createControls.

/**
 * @see ImportSource#createControls(Composite)
 */
@Override
public void createControls(Composite parent) {
    parent.setLayout(new GridLayout(3, false));
    detectImage = HALEUIPlugin.getImageDescriptor("icons/find_obj.gif").createImage();
    // source file
    sourceURL = new URLSourceURIFieldEditor("sourceURL", "Source URL:", parent) {

        @Override
        protected void onHistorySelected(URI location, IContentType contentType) {
            // select the content type associated with the recent URL
            types.setSelection(new StructuredSelection(contentType));
            updateState(false);
        }
    };
    sourceURL.setPage(getPage());
    // set content types for file field
    Collection<IOProviderDescriptor> factories = getConfiguration().getFactories();
    supportedTypes = new HashSet<IContentType>();
    for (IOProviderDescriptor factory : factories) {
        supportedTypes.addAll(factory.getSupportedTypes());
    }
    sourceURL.setContentTypes(supportedTypes);
    sourceURL.setPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(FieldEditor.IS_VALID)) {
                getPage().setMessage(null);
                updateState(false);
            } else if (event.getProperty().equals(FieldEditor.VALUE)) {
                getPage().setMessage(null);
                updateState(false);
            }
        }
    });
    // content type selection
    // label
    Label typesLabel = new Label(parent, SWT.NONE);
    typesLabel.setText("Content type");
    // types combo
    Composite group = new Composite(parent, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
    group.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
    types = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY);
    types.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    types.setContentProvider(ArrayContentProvider.getInstance());
    types.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IContentType) {
                return ((IContentType) element).getName();
            }
            return super.getText(element);
        }
    });
    types.setInput(supportedTypes);
    // process selection changes
    types.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateState(true);
        }
    });
    // detect button
    detect = new Button(group, SWT.PUSH);
    detect.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    detect.setText("Detect");
    detect.setImage(detectImage);
    detect.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            runDetectContentType();
        }
    });
    // provider selection
    // label
    Label providerLabel = new Label(parent, SWT.NONE);
    providerLabel.setText("Import as");
    // create provider combo
    ComboViewer providers = createProviders(parent);
    providers.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    // initial state update
    updateState(true);
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IOProviderDescriptor(eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Label(org.eclipse.swt.widgets.Label) IContentType(org.eclipse.core.runtime.content.IContentType) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) URI(java.net.URI) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 48 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.

the class FileSource method createControls.

/**
 * @see ImportSource#createControls(Composite)
 */
@Override
public void createControls(Composite parent) {
    parent.setLayout(new GridLayout(4, false));
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    projectLocation = ps.getLoadLocation() == null ? null : ps.getLoadLocation();
    boolean projectLocAvailable = projectLocation != null && "file".equals(projectLocation.getScheme());
    // source file
    sourceFile = new FileSourceFileFieldEditor("sourceFile", "Source file:", FileFieldEditor.VALIDATE_ON_KEY_STROKE, parent, projectLocation);
    sourceFile.setEmptyStringAllowed(false);
    sourceFile.setPage(getPage());
    // set content types for file field
    Collection<IOProviderDescriptor> factories = getConfiguration().getFactories();
    supportedTypes = new HashSet<IContentType>();
    for (IOProviderDescriptor factory : factories) {
        supportedTypes.addAll(factory.getSupportedTypes());
    }
    sourceFile.setContentTypes(supportedTypes);
    sourceFile.setPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(FieldEditor.IS_VALID)) {
                updateState(true);
            } else if (event.getProperty().equals(FieldEditor.VALUE)) {
                updateState(true);
            }
        }
    });
    // provider selection
    // label
    Label providerLabel = new Label(parent, SWT.NONE);
    providerLabel.setText("Import as");
    // create provider combo
    ComboViewer providers = createProviders(parent);
    providers.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 3, 1));
    final Button relativeCheck = new Button(parent, SWT.CHECK);
    String text = "Use relative paths if possible.";
    relativeCheck.setText("Use relative paths if possible.");
    relativeCheck.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            sourceFile.setUseRelativeIfPossible(relativeCheck.getSelection());
        }
    });
    if (!projectLocAvailable) {
        relativeCheck.setEnabled(false);
        text += " Only available once the project is saved to a file.";
    }
    relativeCheck.setText(text);
    relativeCheck.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 4, 1));
    // initial state update
    updateState(true);
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IOProviderDescriptor(eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) IContentType(org.eclipse.core.runtime.content.IContentType) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 49 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.

the class AbstractProjectDetailsPage method createContent.

/**
 * @see HaleWizardPage#createContent(Composite)
 */
@Override
protected void createContent(Composite page) {
    page.setLayout(new GridLayout(2, false));
    // name
    name = new StringFieldEditor("name", "Project name:", page);
    name.setEmptyStringAllowed(false);
    name.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    name.setErrorMessage("The project name must be specified.");
    name.setPage(this);
    // author
    author = new StringFieldEditor("author", "Project author:", page);
    author.setEmptyStringAllowed(false);
    author.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE);
    author.setPage(this);
    // description
    Label descLabel = new Label(page, SWT.NONE);
    descLabel.setText("Description:");
    descLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).create());
    description = new Text(page, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
    description.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(500, SWT.DEFAULT).create());
    // listen for state changes on field editors
    IPropertyChangeListener stateListener = new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(StringFieldEditor.IS_VALID)) {
                updateState();
            }
        }
    };
    name.setPropertyChangeListener(stateListener);
    author.setPropertyChangeListener(stateListener);
    // listen for provider changes
    getWizard().addIOWizardListener(new IOWizardListener<P, E>() {

        @Override
        public void providerDescriptorChanged(IOProviderDescriptor providerFactory) {
            // update fields as the provider will have changed
            updateFields();
        }

        @Override
        public void contentTypeChanged(IContentType contentType) {
        // ignore
        }
    });
    updateState();
    updateFields();
}
Also used : StringFieldEditor(org.eclipse.jface.preference.StringFieldEditor) IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) GridLayout(org.eclipse.swt.layout.GridLayout) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IOProviderDescriptor(eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) IContentType(org.eclipse.core.runtime.content.IContentType)

Example 50 with IPropertyChangeListener

use of org.eclipse.jface.util.IPropertyChangeListener in project hale by halestudio.

the class DefaultSchemaTypePage method createContent.

/**
 * @see HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void createContent(Composite parent) {
    Composite holder = new Composite(parent, SWT.NONE);
    holder.setLayout(GridLayoutFactory.fillDefaults().create());
    sc = new DynamicScrolledComposite(holder, SWT.V_SCROLL);
    sc.setExpandHorizontal(true);
    sc.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
    Composite page = new Composite(sc, SWT.NONE);
    page.setLayout(new GridLayout(2, false));
    sfe = new TypeNameField("typename", "Typename", page);
    sfe.setEmptyStringAllowed(false);
    // sfe.setErrorMessage("Please enter a valid Type Name");
    sfe.setPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(StringFieldEditor.IS_VALID)) {
                setPageComplete(isValid());
            }
        }
    });
    sfe.setStringValue(defaultString);
    // sfe.setPage(this);
    group = new Group(page, SWT.NONE);
    group.setText("Properties");
    group.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    group.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).equalWidth(false).margins(5, 5).create());
    sc.setContent(page);
    sc.layout();
// setPageComplete(sfe.isValid());
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

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