use of org.obeonetwork.dsl.database.ViewElement in project InformationSystem by ObeoNetwork.
the class ViewElementItemProvider method getText.
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public String getText(Object object) {
String type;
EObject element = (EObject) object;
if (element.eContainingFeature().equals(DatabasePackage.Literals.VIEW__TABLES)) {
type = "_UI_Table_type";
} else if (element.eContainingFeature().equals(DatabasePackage.Literals.VIEW__COLUMNS)) {
type = "_UI_Column_type";
} else {
type = "_UI_ViewElement_type";
}
String label = ((ViewElement) object).getName();
return label == null || label.length() == 0 ? getString(type) : getString(type) + " " + label;
}
use of org.obeonetwork.dsl.database.ViewElement in project InformationSystem by ObeoNetwork.
the class DatabaseServices method initializeViewContent.
/**
* Initialize the content of a view.
*
* Tables and Columns are transient and not saved.
* They need to be be computed at the opening of the diagram.
* @param view to initialize.
*/
private void initializeViewContent(View view) {
/* The tables and the columns references are transient.
* Initializing the transient reference is a workaround
* to avoid some diagram refresh problems.
* The initializing need to be done only one time.
*/
ViewSpec viewSpec = (ViewSpec) view;
if (viewSpec.initialized == false) {
// Clear view content
if (viewSpec.getColumns() != null) {
viewSpec.getColumns().clear();
}
if (viewSpec.getTables() != null) {
viewSpec.getTables().clear();
}
// Parse new query and update view content
String query = viewSpec.getQuery();
if (!Strings.isNullOrEmpty(query)) {
ViewContentProvider viewContentProvider = new ViewContentProvider();
viewContentProvider.parseViewQuery(viewSpec.getQuery());
List<ColObject> listOfColumns = viewContentProvider.getColumns();
if (listOfColumns != null) {
for (ColObject column : listOfColumns) {
ViewElement elem = DatabaseFactory.eINSTANCE.createViewElement();
elem.setName(column.getName());
elem.setAlias(column.getAlias());
viewSpec.getColumns().add(elem);
}
}
List<String> listOfTables = viewContentProvider.getTables();
if (listOfTables != null) {
for (String table : listOfTables) {
ViewElement elem = DatabaseFactory.eINSTANCE.createViewElement();
elem.setName(table);
viewSpec.getTables().add(elem);
}
}
}
// The initialization was done update boolean.
viewSpec.initialized = true;
}
}
use of org.obeonetwork.dsl.database.ViewElement in project InformationSystem by ObeoNetwork.
the class ViewQueryChangeTrigger method localChangesAboutToCommit.
@Override
public Option<Command> localChangesAboutToCommit(Collection<Notification> notifications) {
Iterable<Notification> querySetNotification = Iterables.filter(notifications, IS_QUERY_SET);
for (Notification notification : querySetNotification) {
view = (View) notification.getNotifier();
query = view.getQuery();
final Session session = SessionManager.INSTANCE.getSession(view);
final TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
if (!Strings.isNullOrEmpty(query)) {
final Command result = new RecordingCommand(domain) {
@Override
protected void doExecute() {
if (view.getColumns() != null) {
view.getColumns().clear();
}
if (view.getTables() != null) {
view.getTables().clear();
}
// Parse new query
ViewContentProvider viewContentProvider = new ViewContentProvider();
viewContentProvider.parseViewQuery(query);
List<ColObject> listOfColumns = viewContentProvider.getColumns();
if (listOfColumns != null) {
for (ColObject column : listOfColumns) {
ViewElement elem = DatabaseFactory.eINSTANCE.createViewElement();
elem.setName(column.getName());
elem.setAlias(column.getAlias());
view.getColumns().add(elem);
}
}
List<String> listOfTables = viewContentProvider.getTables();
if (listOfTables != null) {
for (String table : listOfTables) {
ViewElement elem = DatabaseFactory.eINSTANCE.createViewElement();
elem.setName(table);
view.getTables().add(elem);
}
}
}
};
return Options.newSome(result);
} else if (Strings.isNullOrEmpty(query)) {
final Command result = new RecordingCommand(domain) {
@Override
protected void doExecute() {
if (view.getColumns() != null) {
view.getColumns().clear();
}
if (view.getTables() != null) {
view.getTables().clear();
}
}
};
return Options.newSome(result);
}
}
return Options.newNone();
}
use of org.obeonetwork.dsl.database.ViewElement in project InformationSystem by ObeoNetwork.
the class ViewPropertiesEditionComponent method initPart.
/**
* {@inheritDoc}
*
* @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
* org.eclipse.emf.ecore.resource.ResourceSet)
*/
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
setInitializing(true);
if (editingPart != null && key == partKey) {
editingPart.setContext(elt, allResource);
final View view = (View) elt;
final ViewPropertiesEditionPart viewPart = (ViewPropertiesEditionPart) editingPart;
// init values
if (isAccessible(DatabaseViewsRepository.View.Properties.name))
viewPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, view.getName()));
if (isAccessible(DatabaseViewsRepository.View.Properties.query))
viewPart.setQuery(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, view.getQuery()));
if (isAccessible(DatabaseViewsRepository.View.Properties.comments))
viewPart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, view.getComments()));
if (isAccessible(DatabaseViewsRepository.View.Properties.columns)) {
columnsSettings = new ReferencesTableSettings(view, DatabasePackage.eINSTANCE.getView_Columns());
viewPart.initColumns(columnsSettings);
}
if (isAccessible(DatabaseViewsRepository.View.Properties.tables)) {
tablesSettings = new ReferencesTableSettings(view, DatabasePackage.eINSTANCE.getView_Tables());
viewPart.initTables(tablesSettings);
}
if (isAccessible(DatabaseViewsRepository.View.Properties.columns)) {
viewPart.addFilterToColumns(new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
// $NON-NLS-1$
return (element instanceof String && element.equals("")) || (element instanceof ViewElement);
}
});
// Start of user code for additional businessfilters for columns
// End of user code
}
if (isAccessible(DatabaseViewsRepository.View.Properties.tables)) {
viewPart.addFilterToTables(new ViewerFilter() {
/**
* {@inheritDoc}
*
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
// $NON-NLS-1$
return (element instanceof String && element.equals("")) || (element instanceof ViewElement);
}
});
// Start of user code for additional businessfilters for tables
// End of user code
}
// init values for referenced views
// init filters for referenced views
}
setInitializing(false);
}
Aggregations