use of org.talend.dq.nodes.DBViewRepNode in project tdq-studio-se by Talend.
the class RespositoryDetailView method selectionChanged.
/*
* (non-Javadoc)
*
* @seeorg.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui. IWorkbenchPart,
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
clearContainer();
boolean isNeedcreateDefault = true;
try {
if (part instanceof DQRespositoryView) {
StructuredSelection sel = (StructuredSelection) selection;
// MOD by zshen for bug 15750 TODO 39(13) make Detail View can be used.
Object fe = sel.getFirstElement();
// MOD klliu 2011-02-24 if choose diffirent node ,that will load diffirent child ,so that not use up.
if (fe instanceof AnalysisRepNode || fe instanceof ReportRepNode || fe instanceof SysIndicatorDefinitionRepNode || fe instanceof PatternRepNode || fe instanceof RuleRepNode) {
fe = ((IRepositoryNode) fe).getObject();
}
if (fe instanceof IFile) {
IFile fe2 = (IFile) fe;
isNeedcreateDefault = createFileDetail(isNeedcreateDefault, fe2);
} else if (fe instanceof IRepositoryViewObject) {
isNeedcreateDefault = createFileDetail(isNeedcreateDefault, (IRepositoryViewObject) fe);
} else if (fe instanceof DBConnectionRepNode) {
DBConnectionRepNode connNode = (DBConnectionRepNode) fe;
// MOD sizhaoliu TDQ-6316
ConnectionItem connectionItem = (ConnectionItem) connNode.getObject().getProperty().getItem();
createDataProviderDetail(connectionItem);
isNeedcreateDefault = false;
} else if (fe instanceof DBCatalogRepNode) {
DBCatalogRepNode catalogNode = (DBCatalogRepNode) fe;
Catalog catalog = catalogNode.getCatalog();
createTdCatalogDetail(catalog);
isNeedcreateDefault = false;
} else if (fe instanceof DBSchemaRepNode) {
DBSchemaRepNode schemaNode = (DBSchemaRepNode) fe;
Schema schema = schemaNode.getSchema();
createTdSchemaDetail(schema);
isNeedcreateDefault = false;
} else if (fe instanceof DBTableRepNode) {
DBTableRepNode tableNode = (DBTableRepNode) fe;
// MOD gdbu 2011-9-14 TDQ-3243
if (!DQRepositoryNode.isOnFilterring()) {
tableNode.getChildren().get(0).getChildren();
}
// ~TDQ-3243
TdTable tdTable = tableNode.getTdTable();
createTableDetail(tdTable);
isNeedcreateDefault = false;
} else if (fe instanceof DBViewRepNode) {
DBViewRepNode viewNode = (DBViewRepNode) fe;
// MOD gdbu 2011-9-14 TDQ-3243
if (!DQRepositoryNode.isOnFilterring()) {
viewNode.getChildren().get(0).getChildren();
}
// ~TDQ-3243
createNameCommentDetail(viewNode.getTdView());
isNeedcreateDefault = false;
} else if (fe instanceof DBColumnRepNode) {
DBColumnRepNode columnNode = (DBColumnRepNode) fe;
TdColumn column = columnNode.getTdColumn();
createTdColumn(column);
isNeedcreateDefault = false;
} else if (fe instanceof IEcosComponent) {
IEcosComponent component = (IEcosComponent) fe;
createEcosComponent(component);
isNeedcreateDefault = false;
} else if (fe instanceof RegularExpression) {
// MOD mzhao 2009-04-20,Bug 6349.
RegularExpression regularExpression = (RegularExpression) fe;
createRegularExpression(regularExpression);
isNeedcreateDefault = false;
} else if (fe instanceof PatternLanguageRepNode) {
// MOD mzhao 2012-08-15,feature TDQ-4037.
PatternLanguageRepNode pattLangNode = (PatternLanguageRepNode) fe;
createRegularExpression(pattLangNode.getRegularExpression());
isNeedcreateDefault = false;
} else if (fe instanceof SourceFileRepNode) {
// MOD klliu 2001-02-28 bug 19154
IPath filePath = WorkbenchUtils.getFilePath((SourceFileRepNode) fe);
DQRepositoryNode node = (DQRepositoryNode) fe;
IFile file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(filePath);
createSqlFileDetail(file);
} else if (fe instanceof ExchangeComponentRepNode) {
// MOD klliu 2001-02-28 bug 19154
IEcosComponent ecosComponent = ((ExchangeComponentRepNode) fe).getEcosComponent();
IEcosComponent component = ecosComponent;
createEcosComponent(component);
isNeedcreateDefault = false;
// ADD by msjian 2011-5-12 21186: don't check whether the selected object is "MDMConnectionRepNode"
} else if (fe instanceof DFConnectionRepNode) {
DFConnectionRepNode dfNode = (DFConnectionRepNode) fe;
DelimitedFileConnection dfConnection = dfNode.getDfConnection();
createDFconnectionName(dfNode.getObject().getLabel());
createDataProviderDetail(dfConnection);
isNeedcreateDefault = false;
}
if (PluginChecker.isTDQLoaded()) {
if (fe instanceof EObject) {
createTechnicalDetail((EObject) fe);
} else if (fe instanceof IFile) {
createTechnicalDetail((IFile) fe);
} else if (fe instanceof IRepositoryViewObject) {
createTechnicalDetail((IRepositoryViewObject) fe);
} else {
createExtDefault();
}
}
if (!scomp.isDisposed()) {
scomp.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
composite.layout();
}
} else if (part instanceof CommonFormEditor) {
CommonFormEditor editor = (CommonFormEditor) part;
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFileEditorInput input = (IFileEditorInput) editorInput;
IFile file = input.getFile();
isNeedcreateDefault = createFileDetail(isNeedcreateDefault, file);
}
}
if (isNeedcreateDefault) {
createDefault();
}
// feature 19053
if (!gContainer.isDisposed()) {
gContainer.layout();
if (tContainer != null) {
tContainer.layout();
}
}
} catch (MissingDriverException e) {
if (PluginChecker.isOnlyTopLoaded()) {
MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), // $NON-NLS-1$
DefaultMessagesImpl.getString("RespositoryDetailView.warning"), e.getErrorMessage());
} else {
log.error(e, e);
}
}
}
use of org.talend.dq.nodes.DBViewRepNode in project tdq-studio-se by Talend.
the class TableViewerDND method installDND.
/**
* DOC xqliu Comment method "installDND".
*
* @param targetControl
*/
public static void installDND(final Tree targetControl) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
final CommonViewer commonViewer = findView.getCommonViewer();
final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
int operations = DND.DROP_COPY | DND.DROP_MOVE;
Transfer[] transfers = new Transfer[] { transfer };
DropTarget dropTarget = new DropTarget(targetControl, operations);
dropTarget.setTransfer(transfers);
DropTargetListener dndListener = new TreeDropTargetEffect(targetControl) {
ISelectionReceiver receiver = null;
@Override
public void dragEnter(DropTargetEvent event) {
super.dragEnter(event);
IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
Object object = selection.getFirstElement();
if (object instanceof RuleRepNode) {
receiver = new DQRuleReceiver();
}
if (object instanceof NamedColumnSet) {
receiver = new TableReceiver();
}
if (object instanceof DBTableRepNode) {
receiver = new TableReceiver();
}
if (object instanceof DBViewRepNode) {
receiver = new TableReceiver();
}
if (receiver == null) {
event.detail = DND.DROP_NONE;
} else {
event.feedback = DND.FEEDBACK_EXPAND;
receiver.doDropValidation(event, commonViewer);
}
}
@Override
public void dragOver(DropTargetEvent event) {
super.dragOver(event);
if (receiver != null) {
receiver.doDropValidation(event, commonViewer);
}
}
@Override
public void drop(DropTargetEvent event) {
int index = targetControl.getItemCount();
super.drop(event);
if (event.item == null) {
// TreeItem item = new TreeItem(targetControl, SWT.NONE);
// item.setText(texts);
// item.setText(text);
} else {
TreeItem item = (TreeItem) event.item;
TreeItem[] items = targetControl.getItems();
for (int i = 0; i < items.length; i++) {
if (items[i] == item) {
index = i;
break;
}
}
}
if (receiver != null) {
receiver.drop(event, commonViewer, index);
}
}
};
dropTarget.addDropListener(dndListener);
}
use of org.talend.dq.nodes.DBViewRepNode in project tdq-studio-se by Talend.
the class RepositoryNodeHelperRealTest method testCreateMysqlViewRepositoryNode.
/**
* Test method for
* {@link org.talend.dq.helper.RepositoryNodeHelper#createRepositoryNode(orgomg.cwm.objectmodel.core.ModelElement)}.
* mysql case find View node
*/
@Test
public void testCreateMysqlViewRepositoryNode() {
// $NON-NLS-1$
DatabaseConnectionItem createConnectionItem = createDataBaseConnection("conn1", null, false);
// $NON-NLS-1$
Catalog addCatalog = this.addCatalog(createConnectionItem.getConnection(), "catalog1");
// $NON-NLS-1$
TdView addView = this.addView(addCatalog, "view1");
try {
ProxyRepositoryFactory.getInstance().save(createConnectionItem, null);
} catch (PersistenceException e) {
log.error(e, e);
Assert.fail(e.getMessage());
}
RepositoryNode createRepositoryNode = RepositoryNodeHelper.createRepositoryNode(addView);
if (createRepositoryNode != null) {
IRepositoryViewObject object = createRepositoryNode.getObject();
Assert.assertTrue(createRepositoryNode instanceof DBViewRepNode);
Assert.assertTrue(object != null);
Assert.assertTrue(object instanceof TdViewRepositoryObject);
Assert.assertTrue(object.getId().equals(addView.getName()));
Assert.assertTrue(object.getLabel().equals(addView.getName()));
Assert.assertTrue(object.getRepositoryNode() != null);
Assert.assertTrue(createRepositoryNode.getProperties(EProperties.LABEL).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
Assert.assertTrue(createRepositoryNode.getProperties(EProperties.CONTENT_TYPE).equals(ERepositoryObjectType.METADATA_CON_COLUMN));
Assert.assertTrue(createRepositoryNode.getParent().getParent().getParent() != null);
}
}
use of org.talend.dq.nodes.DBViewRepNode in project tdq-studio-se by Talend.
the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis_4.
/**
* Test:4) when the selected nodes are: multiple columns from one same table/view, will be valid.
*/
@Test
public void testIsValidSelectionForMatchAnalysis_4() {
List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
DBTableRepNode table1 = mock(DBTableRepNode.class);
DBViewRepNode view1 = mock(DBViewRepNode.class);
DFTableRepNode dfTable = mock(DFTableRepNode.class);
ColumnRepNode col1 = mock(ColumnRepNode.class);
ColumnRepNode col2 = mock(ColumnRepNode.class);
when(col1.getParent()).thenReturn(table1);
when(col2.getParent()).thenReturn(table1);
nodes.clear();
nodes.add(col1);
nodes.add(col2);
Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
when(col1.getParent()).thenReturn(view1);
when(col2.getParent()).thenReturn(view1);
nodes.clear();
nodes.add(col1);
nodes.add(col2);
Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
when(col1.getParent()).thenReturn(dfTable);
when(col2.getParent()).thenReturn(dfTable);
nodes.clear();
nodes.add(col1);
nodes.add(col2);
Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
use of org.talend.dq.nodes.DBViewRepNode in project tdq-studio-se by Talend.
the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis_3.
/**
* Test: 3) when the selected node is: one single table/view/file table,will be valid;
*/
@Test
public void testIsValidSelectionForMatchAnalysis_3() {
List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
DBTableRepNode table1 = mock(DBTableRepNode.class);
DBViewRepNode view1 = mock(DBViewRepNode.class);
// 3) when the selected node is: one single table/view/file table,will be valid;
nodes.clear();
nodes.add(table1);
Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
nodes.clear();
nodes.add(view1);
Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
DFTableRepNode dfTable = mock(DFTableRepNode.class);
nodes.clear();
nodes.add(dfTable);
Assert.assertTrue(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
Aggregations