Search in sources :

Example 1 with ResourceSelectionGroup

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

the class ResourceSelectionDialog 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 = (_fileExtensions == null || _fileExtensions.length == 0);
    _resourceSelectionGroup = new ResourceSelectionGroup(composite, this, _fileExtensions, showNewContainerActions);
    new Label(composite, SWT.NONE).setText("Resource Path:");
    _resourcePathText = new Text(composite, 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());
        _resourceSelectionGroup.setSelectedResource(_path);
    }
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) ResourceSelectionGroup(org.csstudio.ui.util.composites.ResourceSelectionGroup)

Example 2 with ResourceSelectionGroup

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

the class RelativePathSelectionDialog 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 = (_fileExtensions == null || _fileExtensions.length == 0);
    _resourceSelectionGroup = new ResourceSelectionGroup(composite, this, _fileExtensions, showNewContainerActions);
    new Label(composite, SWT.NONE).setText("Resource Path:");
    _resourcePathText = new Text(composite, 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(composite, 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)
                _resourcePathText.setText(ResourceUtil.buildRelativePath(refPath, _path).toString());
            else
                _resourcePathText.setText(_path.toString());
        }
    });
    return composite;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) URLPath(org.csstudio.opibuilder.persistence.URLPath) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) ResourceSelectionGroup(org.csstudio.ui.util.composites.ResourceSelectionGroup)

Example 3 with ResourceSelectionGroup

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

the class RelativePathSelectionDialog 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());
    if (event.type == SWT.MouseDoubleClick) {
        okPressed();
    }
}
Also used : ResourceSelectionGroup(org.csstudio.ui.util.composites.ResourceSelectionGroup)

Example 4 with ResourceSelectionGroup

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

the class ResourceAndContainerGroup method createContents.

/**
 * Creates this object's visual components.
 *
 * @param parent
 *            org.eclipse.swt.widgets.Composite
 * @param heightHint
 *            height hint for the container selection widget group
 * @param resourceLabelString
 *            resource label text.
 */
private void createContents(final Composite parent, final String resourceLabelString, final int heightHint) {
    // Font font = parent.getFont();
    // server name group
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    // container group
    if (heightHint == SWT.DEFAULT) {
        _containerGroup = new ResourceSelectionGroup(composite, this, null, null, _showClosedProjects);
    } else {
        _containerGroup = new ResourceSelectionGroup(composite, this, null, null, _showClosedProjects, true, heightHint, SIZING_TEXT_FIELD_WIDTH);
    }
    // resource name group
    Composite nameGroup = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    nameGroup.setLayout(layout);
    nameGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
    // nameGroup.setFont(font);
    Label label = new Label(nameGroup, SWT.NONE);
    label.setText(resourceLabelString);
    // label.setFont(font);
    // resource name entry field
    _resourceNameField = new Text(nameGroup, SWT.BORDER);
    _resourceNameField.addListener(SWT.Modify, this);
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;
    _resourceNameField.setLayoutData(data);
    _resourceNameField.setBackground(FieldAssistColors.getRequiredFieldBackgroundColor(_resourceNameField));
    // full path
    label = new Label(nameGroup, SWT.NONE);
    label.setText("Full path:");
    _fullPathLabel = new Label(nameGroup, SWT.NONE | SWT.WRAP);
    data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
    data.widthHint = SIZING_TEXT_FIELD_WIDTH;
    _fullPathLabel.setLayoutData(data);
    this.refreshFullPath();
    validateControls();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) ResourceSelectionGroup(org.csstudio.ui.util.composites.ResourceSelectionGroup)

Aggregations

ResourceSelectionGroup (org.csstudio.ui.util.composites.ResourceSelectionGroup)4 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 Label (org.eclipse.swt.widgets.Label)3 Text (org.eclipse.swt.widgets.Text)3 URLPath (org.csstudio.opibuilder.persistence.URLPath)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Button (org.eclipse.swt.widgets.Button)1