Search in sources :

Example 1 with ResourceSelectionGroup

use of org.csstudio.platform.ui.composites.resourcefilter.ResourceSelectionGroup in project yamcs-studio by yamcs.

the class FilePathDialogWithFilter method handleEvent.

@Override
public void handleEvent(Event event) {
    ResourceSelectionGroup widget = (ResourceSelectionGroup) event.widget;
    path = widget.getFullPath();
    if (path == null) {
        return;
    }
    if (relative) {
        resourcePathText.setText(ResourceUtil.buildRelativePath(refPath, path).toString());
    } else {
        resourcePathText.setText(path.toString());
    }
    displayOverview(widget.getFullPath());
}
Also used : ResourceSelectionGroup(org.csstudio.platform.ui.composites.resourcefilter.ResourceSelectionGroup)

Example 2 with ResourceSelectionGroup

use of org.csstudio.platform.ui.composites.resourcefilter.ResourceSelectionGroup in project yamcs-studio by yamcs.

the class FilePathDialogWithFilter method createDialogArea.

/**
 * {@inheritDoc}
 */
@Override
protected Control createDialogArea(final Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(1, false));
    if (message != null) {
        Label label = new Label(composite, SWT.WRAP);
        label.setText(message);
        GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER);
        data.horizontalSpan = 2;
        data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
        label.setLayoutData(data);
    }
    // The New Project and New Folder actions will be shown if there are
    // no file extensions, i.e. if the dialog is opened to select a folder.
    boolean showNewContainerActions = (filters == null || filters.length == 0);
    resourceSelectionGroup = new ResourceSelectionGroup(composite, this, filters, showNewContainerActions);
    Group wrapper = new Group(composite, SWT.NONE);
    wrapper.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    GridLayout gridLayout = new GridLayout(2, false);
    wrapper.setLayout(gridLayout);
    Label text = new Label(wrapper, SWT.NONE);
    text.setText("Resource Path:");
    // Image overview
    imgOverview = new Label(wrapper, SWT.NONE);
    GridData gridData = new GridData();
    gridData.widthHint = MAX_ICON_WIDTH;
    gridData.verticalSpan = 4;
    gridData.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
    gridData.grabExcessVerticalSpace = false;
    gridData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_CENTER;
    gridData.grabExcessHorizontalSpace = false;
    imgOverview.setLayoutData(gridData);
    resourcePathText = new Text(wrapper, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
    resourcePathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    if (path != null && !path.isEmpty()) {
        resourcePathText.setText(path.toString());
        if (!(path instanceof URLPath)) {
            if (relative) {
                resourceSelectionGroup.setSelectedResource(refPath.append(path));
            } else {
                resourceSelectionGroup.setSelectedResource(path);
            }
        }
    }
    // the check box for relative path
    final Button checkBox = new Button(wrapper, SWT.CHECK);
    checkBox.setSelection(relative);
    checkBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    checkBox.setText("Return relative path");
    checkBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            relative = checkBox.getSelection();
            if (relative && path != null) {
                resourcePathText.setText(ResourceUtil.buildRelativePath(refPath, path).toString());
            } else {
                resourcePathText.setText(path.toString());
            }
        }
    });
    // the check box for name filter
    final Button filterCheckBox = new Button(wrapper, SWT.CHECK);
    filterCheckBox.setSelection(filtered);
    filterCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    filterCheckBox.setText("Filter file name with PV name");
    filterCheckBox.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            filtered = filterCheckBox.getSelection();
            if (filtered) {
                resourceSelectionGroup.refreshTreeWithFilter(filters);
            } else {
                resourceSelectionGroup.refreshTreeWithFilter(IMAGE_EXTENSIONS);
            }
        }
    });
    return composite;
}
Also used : Group(org.eclipse.swt.widgets.Group) ResourceSelectionGroup(org.csstudio.platform.ui.composites.resourcefilter.ResourceSelectionGroup) Composite(org.eclipse.swt.widgets.Composite) URLPath(org.csstudio.opibuilder.persistence.URLPath) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ResourceSelectionGroup(org.csstudio.platform.ui.composites.resourcefilter.ResourceSelectionGroup)

Aggregations

ResourceSelectionGroup (org.csstudio.platform.ui.composites.resourcefilter.ResourceSelectionGroup)2 URLPath (org.csstudio.opibuilder.persistence.URLPath)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1