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());
}
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;
}
Aggregations