Search in sources :

Example 1 with TypeDefinitionSelector

use of eu.esdihumboldt.hale.ui.common.definition.selector.TypeDefinitionSelector in project hale by halestudio.

the class InstanceExportConfigurationPage method onShowPage.

@Override
protected void onShowPage(boolean firstShow) {
    if (firstShow) {
        ViewerFilter[] filters = { validTypesToSelect };
        typeSelector = new TypeDefinitionSelector(page, "Select the corresponding schema type", getWizard().getProvider().getTargetSchema(), filters);
        typeSelector.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create());
        typeSelector.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                setPageComplete(!(event.getSelection().isEmpty()));
                if (typeSelector.getSelectedObject() != null) {
                    // TypeDefinition type =
                    // typeSelector.getSelectedObject();
                    // label.getParent().layout();
                    page.layout();
                    page.pack();
                }
            }
        });
    }
    page.layout();
    page.pack();
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TypeDefinitionSelector(eu.esdihumboldt.hale.ui.common.definition.selector.TypeDefinitionSelector) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 2 with TypeDefinitionSelector

use of eu.esdihumboldt.hale.ui.common.definition.selector.TypeDefinitionSelector in project hale by halestudio.

the class TypeSelectionPage method onShowPage.

/**
 * @see HaleWizardPage#onShowPage(boolean)
 */
@Override
protected void onShowPage(boolean firstShow) {
    super.onShowPage(firstShow);
    if (firstShow) {
        selector = new TypeDefinitionSelector(page, "Select the corresponding schema type", getWizard().getProvider().getSourceSchema(), null);
        selector.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create());
        selector.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                validateSelection();
            }
        });
        page.layout();
        page.pack();
    }
    LocatableInputSupplier<? extends InputStream> currentSource = getWizard().getProvider().getSource();
    if (!currentSource.equals(lastSource)) {
        // if the source has changed
        lastSource = currentSource;
        lastType = ShapeSchemaReader.readShapeType(lastSource);
        if (selector.getSelectedObject() == null) {
            // try to find a candidate for default selection
            if (lastType != null) {
                Pair<TypeDefinition, Integer> pt = ShapeInstanceReader.getMostCompatibleShapeType(getWizard().getProvider().getSourceSchema(), lastType, lastType.getName().getLocalPart());
                if (pt != null) {
                    selector.setSelection(new StructuredSelection(pt.getFirst()));
                }
            }
        }
        validateSelection();
    }
}
Also used : TypeDefinitionSelector(eu.esdihumboldt.hale.ui.common.definition.selector.TypeDefinitionSelector) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 3 with TypeDefinitionSelector

use of eu.esdihumboldt.hale.ui.common.definition.selector.TypeDefinitionSelector in project hale by halestudio.

the class TypeSelectionPage method createContent.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void createContent(Composite page) {
    page.setLayout(new GridLayout(2, false));
    // XXX needed?
    GridData layoutData = new GridData();
    layoutData.widthHint = 200;
    label = new Label(page, SWT.NONE);
    label.setText("Choose your Type:");
    SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
    sel = new TypeDefinitionSelector(page, "Select the corresponding schema type", ss.getSchemas(SchemaSpaceID.SOURCE), null);
    sel.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create());
    sel.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            setPageComplete(!(event.getSelection().isEmpty()));
            if (sel.getSelectedObject() != null) {
                TypeDefinition type = sel.getSelectedObject();
                CSVConfiguration conf = type.getConstraint(CSVConfiguration.class);
                Boolean skip = conf.skipFirst();
                button.setSelection(skip);
                label.getParent().layout();
            }
        }
    });
    button = new Button(page, SWT.CHECK);
    button.setText("Skip first line");
    button.setSelection(true);
    page.pack();
    setPageComplete(false);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) CSVConfiguration(eu.esdihumboldt.hale.io.csv.reader.internal.CSVConfiguration) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) Button(org.eclipse.swt.widgets.Button) TypeDefinitionSelector(eu.esdihumboldt.hale.ui.common.definition.selector.TypeDefinitionSelector) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Aggregations

TypeDefinitionSelector (eu.esdihumboldt.hale.ui.common.definition.selector.TypeDefinitionSelector)3 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)3 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)2 CSVConfiguration (eu.esdihumboldt.hale.io.csv.reader.internal.CSVConfiguration)1 SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Label (org.eclipse.swt.widgets.Label)1