use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.
the class SpecificWorkspaceResourceDialog method openFileSelection.
public static IFile openFileSelection(Shell parent, String title, String message, IPath suggestedPath, Collection<ViewerFilter> viewerFilters, String newFileExtension) {
final SpecificWorkspaceResourceDialog dialog = new SpecificWorkspaceResourceDialog(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
dialog.setNewFileExtension(newFileExtension);
dialog.setAllowMultiple(false);
dialog.setTitle(title != null ? title : CommonUIPlugin.INSTANCE.getString("_UI_NewFile_title"));
dialog.setMessage(message);
dialog.setShowNewFolderControl(true);
dialog.setShowFileControl(true);
dialog.addFilter(dialog.createDefaultViewerFilter(true));
if (viewerFilters != null) {
for (ViewerFilter viewerFilter : viewerFilters) {
dialog.addFilter(viewerFilter);
}
}
if (suggestedPath != null) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = root.findMember(suggestedPath);
if (resource != null && resource.isAccessible()) {
if (resource instanceof IContainer) {
dialog.setInitialSelection(resource);
} else {
dialog.setInitialSelection(resource.getParent());
dialog.setFileText(resource.getName());
}
} else {
if (suggestedPath.segmentCount() > 1) {
if (resource == null) {
resource = root.getFile(suggestedPath);
}
if (resource.getProject().isAccessible()) {
IContainer container = resource.getParent();
for (; !container.isAccessible() && container != resource.getProject(); container = container.getParent()) {
// Do nothing
}
dialog.setInitialSelection(container);
suggestedPath = suggestedPath.removeFirstSegments(container.getFullPath().segmentCount());
dialog.setFileText(suggestedPath.toString());
suggestedPath = null;
}
}
if (suggestedPath != null) {
String fileText = suggestedPath.isAbsolute() ? suggestedPath.removeFirstSegments(1).toString() : suggestedPath.toString();
dialog.setFileText(fileText);
}
}
}
dialog.loadContents();
return dialog.open() == Window.OK ? dialog.getFile() : null;
}
use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.
the class DatabaseImportWizardPage method createControl.
/* (non-Javadoc)
* @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#createAdvancedControls(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(3, false));
lblError = new Label(composite, SWT.NONE);
lblError.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
lblError.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
Label lblDbVendor = new Label(composite, SWT.NONE);
lblDbVendor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblDbVendor.setText("DB Vendor :");
comboDbVendor = new Combo(composite, SWT.NONE);
comboDbVendor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label lblHost = new Label(composite, SWT.NONE);
lblHost.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblHost.setText("Host :");
txtHost = new Text(composite, SWT.BORDER);
txtHost.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label lblPort = new Label(composite, SWT.NONE);
lblPort.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblPort.setText("Port :");
txtPort = new Text(composite, SWT.BORDER);
txtPort.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
final Label lblDatabase = new Label(composite, SWT.NONE);
lblDatabase.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblDatabase.setText("Database :");
txtDatabase = new Text(composite, SWT.BORDER);
txtDatabase.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label lblSchema = new Label(composite, SWT.NONE);
lblSchema.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblSchema.setText("Schema :");
txtSchema = new Text(composite, SWT.BORDER);
txtSchema.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label lblUser = new Label(composite, SWT.NONE);
lblUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblUser.setText("User :");
txtUser = new Text(composite, SWT.BORDER);
txtUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label lblPassword = new Label(composite, SWT.NONE);
lblPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblPassword.setText("Password :");
txtPassword = new Text(composite, SWT.BORDER);
txtPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
Label lblUrl = new Label(composite, SWT.NONE);
lblUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblUrl.setText("URL :");
txtUrl = new Text(composite, SWT.BORDER);
txtUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
comboDbVendor.setItems(DB_VENDOR_CHOICES);
comboDbVendor.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
txtSchema.setEnabled(!DB_MYSQL_5.equals(comboDbVendor.getText()));
txtHost.setEnabled(!DB_H2_13.equals(comboDbVendor.getText()));
txtPort.setEnabled(!DB_H2_13.equals(comboDbVendor.getText()));
}
});
txtSchema.setEnabled(!DB_MYSQL_5.equals(comboDbVendor.getText()));
Label lblModelFile = new Label(composite, SWT.NONE);
lblModelFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblModelFile.setText("New model file :");
txtModelFile = new Text(composite, SWT.BORDER);
txtModelFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtModelFile.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
setPageComplete(checkStatus());
}
});
Button btnBrowseFile = new Button(composite, SWT.NONE);
btnBrowseFile.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
btnBrowseFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Collection<ViewerFilter> filters = new ArrayList<ViewerFilter>();
filters.add(new FileExtensionsViewerFilter(new String[] { DATABASE_FILE_EXTENSION }));
IResource selectedResource = SpecificWorkspaceResourceDialog.openFileSelection(getShell(), "Output model", "Specify the file to create", new Path(txtModelFile.getText()), filters, DATABASE_FILE_EXTENSION);
if (selectedResource != null) {
txtModelFile.setText(selectedResource.getFullPath().toString());
}
}
});
btnBrowseFile.setText("Browse...");
btnBrowseFile.setSize(62, 23);
Label lblReferencedModelFiles = new Label(composite, SWT.NONE);
lblReferencedModelFiles.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
lblReferencedModelFiles.setText("Referenced files :");
final List<ViewerFilter> filters = new ArrayList<ViewerFilter>();
filters.add(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof IFile) {
IResource workspaceResource = (IResource) element;
return referencedFiles.contains(workspaceResource) == false && DATABASE_FILE_EXTENSION.equals(workspaceResource.getFileExtension());
}
return true;
}
});
Button btnAddReferencedFile = new Button(composite, SWT.NONE);
btnAddReferencedFile.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
btnAddReferencedFile.setText("Add...");
btnAddReferencedFile.setSize(62, 23);
btnAddReferencedFile.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
IFile[] selectedFiles = WorkspaceResourceDialog.openFileSelection(getShell(), "Add referenced file", "Select the referenced files (*." + DATABASE_FILE_EXTENSION + ")", true, null, filters);
for (IFile selectedFile : selectedFiles) {
referencedFiles.add(selectedFile);
}
listReferencedModelFiles.refresh();
}
});
Button btnRemoveReferencedFile = new Button(composite, SWT.NONE);
btnRemoveReferencedFile.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
btnRemoveReferencedFile.setText("Remove");
btnRemoveReferencedFile.setSize(62, 23);
btnRemoveReferencedFile.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
StructuredSelection selectedFile = (StructuredSelection) listReferencedModelFiles.getSelection();
if (selectedFile.getFirstElement() instanceof IFile) {
referencedFiles.remove((IFile) selectedFile.getFirstElement());
listReferencedModelFiles.refresh();
}
}
});
listReferencedModelFiles = new ListViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
listReferencedModelFiles.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
listReferencedModelFiles.setContentProvider(new ArrayContentProvider());
listReferencedModelFiles.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
IFile file = (IFile) element;
return file.getFullPath().toString();
}
});
setControl(composite);
initInput();
bindValues();
}
use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.
the class ComplexNamedTypePropertiesEditionPartImpl method createTypesAdvancedTableComposition.
/**
* @param container
*/
protected Composite createTypesAdvancedTableComposition(Composite parent) {
this.types = new ReferencesTable(getDescription(TypeslibraryViewsRepository.ComplexNamedType.Properties.types, TypeslibraryMessages.ComplexNamedTypePropertiesEditionPart_TypesLabel), new ReferencesTableListener() {
public void handleAdd() {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ComplexNamedTypePropertiesEditionPartImpl.this, TypeslibraryViewsRepository.ComplexNamedType.Properties.types, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, null));
types.refresh();
}
public void handleEdit(EObject element) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ComplexNamedTypePropertiesEditionPartImpl.this, TypeslibraryViewsRepository.ComplexNamedType.Properties.types, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, element));
types.refresh();
}
public void handleMove(EObject element, int oldIndex, int newIndex) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ComplexNamedTypePropertiesEditionPartImpl.this, TypeslibraryViewsRepository.ComplexNamedType.Properties.types, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.MOVE, element, newIndex));
types.refresh();
}
public void handleRemove(EObject element) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ComplexNamedTypePropertiesEditionPartImpl.this, TypeslibraryViewsRepository.ComplexNamedType.Properties.types, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.REMOVE, null, element));
types.refresh();
}
public void navigateTo(EObject element) {
}
});
for (ViewerFilter filter : this.typesFilters) {
this.types.addFilter(filter);
}
this.types.setHelpText(propertiesEditionComponent.getHelpContent(TypeslibraryViewsRepository.ComplexNamedType.Properties.types, TypeslibraryViewsRepository.SWT_KIND));
this.types.createControls(parent);
this.types.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.item != null && e.item.getData() instanceof EObject) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ComplexNamedTypePropertiesEditionPartImpl.this, TypeslibraryViewsRepository.ComplexNamedType.Properties.types, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SELECTION_CHANGED, null, e.item.getData()));
}
}
});
GridData typesData = new GridData(GridData.FILL_HORIZONTAL);
typesData.horizontalSpan = 3;
this.types.setLayoutData(typesData);
this.types.setLowerBound(0);
this.types.setUpperBound(-1);
types.setID(TypeslibraryViewsRepository.ComplexNamedType.Properties.types);
// $NON-NLS-1$
types.setEEFType("eef::AdvancedTableComposition");
// End of user code
return parent;
}
use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.
the class LoopPropertiesEditionPartImpl method createSubActivitiesAdvancedTableComposition.
/**
* @param container
*/
protected Composite createSubActivitiesAdvancedTableComposition(Composite parent) {
this.subActivities = new ReferencesTable(getDescription(GraalViewsRepository.Loop.Properties.subActivities, GraalMessages.LoopPropertiesEditionPart_SubActivitiesLabel), new ReferencesTableListener() {
public void handleAdd() {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(LoopPropertiesEditionPartImpl.this, GraalViewsRepository.Loop.Properties.subActivities, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, null));
subActivities.refresh();
}
public void handleEdit(EObject element) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(LoopPropertiesEditionPartImpl.this, GraalViewsRepository.Loop.Properties.subActivities, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, element));
subActivities.refresh();
}
public void handleMove(EObject element, int oldIndex, int newIndex) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(LoopPropertiesEditionPartImpl.this, GraalViewsRepository.Loop.Properties.subActivities, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.MOVE, element, newIndex));
subActivities.refresh();
}
public void handleRemove(EObject element) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(LoopPropertiesEditionPartImpl.this, GraalViewsRepository.Loop.Properties.subActivities, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.REMOVE, null, element));
subActivities.refresh();
}
public void navigateTo(EObject element) {
}
});
for (ViewerFilter filter : this.subActivitiesFilters) {
this.subActivities.addFilter(filter);
}
this.subActivities.setHelpText(propertiesEditionComponent.getHelpContent(GraalViewsRepository.Loop.Properties.subActivities, GraalViewsRepository.SWT_KIND));
this.subActivities.createControls(parent);
this.subActivities.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.item != null && e.item.getData() instanceof EObject) {
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(LoopPropertiesEditionPartImpl.this, GraalViewsRepository.Loop.Properties.subActivities, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SELECTION_CHANGED, null, e.item.getData()));
}
}
});
GridData subActivitiesData = new GridData(GridData.FILL_HORIZONTAL);
subActivitiesData.horizontalSpan = 3;
this.subActivities.setLayoutData(subActivitiesData);
this.subActivities.setLowerBound(0);
this.subActivities.setUpperBound(-1);
subActivities.setID(GraalViewsRepository.Loop.Properties.subActivities);
// $NON-NLS-1$
subActivities.setEEFType("eef::AdvancedTableComposition");
// End of user code
return parent;
}
use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.
the class EObjectLinksView method createPartControl.
/**
* This is a callback that will allow us
* to create the viewer and initialize it.
*/
public void createPartControl(Composite parent) {
Composite viewContainer = new Composite(parent, SWT.NONE);
viewContainer.setLayout(new GridLayout());
eobjectLabel = new Label(viewContainer, SWT.NONE);
eobjectLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite tableContainer = new Composite(viewContainer, SWT.NONE);
tableContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
TableColumnLayout layout = new TableColumnLayout();
tableContainer.setLayout(layout);
viewer = new TableViewer(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
addColumns();
contentProvider = createContentProvider();
viewer.setContentProvider(contentProvider);
List<ViewerFilter> filters = createFilters();
if (filters.size() > 0) {
for (ViewerFilter viewerFilter : filters) {
viewer.addFilter(viewerFilter);
}
}
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
for (ViewListener listener : listeners) {
listener.fireSelectionChanged(getSelectedEntries());
}
}
});
ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE);
listener = new ViewpointSelectionListener() {
/**
* {@inheritDoc}
* @see org.obeonetwork.tools.linker.ui.view.util.ViewpointSelectionListener#eObjectSelected(org.eclipse.emf.ecore.EObject)
*/
@Override
protected void eObjectSelected(EObject selectedEObject) {
update(selectedEObject);
}
};
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(listener);
makeActions();
fillLocalActionBar();
fillLocalPullDown();
hookDoubleClickAction();
}
Aggregations