use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode in project tdq-studio-se by Talend.
the class DQRepositoryViewLabelProvider method getImage.
@Override
public Image getImage(Object element) {
Image image = super.getImage(element);
if (element instanceof IRepositoryNode) {
IRepositoryNode node = (IRepositoryNode) element;
if (node instanceof ReportAnalysisRepNode) {
image = ImageLib.getImage(ImageLib.ANALYSIS_OBJECT);
} else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
image = ImageLib.getImage(ImageLib.EXCHANGE);
} else if (node instanceof RecycleBinRepNode) {
image = ImageLib.getImage(ImageLib.RECYCLEBIN_EMPTY);
} else {
IRepositoryViewObject viewObject = node.getObject();
ENodeType type = node.getType();
if (type.equals(ENodeType.SYSTEM_FOLDER)) {
if (EResourceConstant.REFERENCED_PROJECT.getName().equals(node.getProperties(EProperties.LABEL))) {
image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
} else {
String label = viewObject.getLabel();
if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
image = ImageLib.getImage(ImageLib.DATA_PROFILING);
} else if (label.equals(EResourceConstant.METADATA.getName())) {
image = ImageLib.getImage(ImageLib.METADATA);
} else if (node instanceof DBConnectionFolderRepNode) {
image = ImageLib.getImage(ImageLib.CONNECTION);
} else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
} else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
image = ImageLib.getImage(ImageLib.LIBRARIES);
} else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
image = ImageLib.getImage(ImageLib.EXCHANGE);
} else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
image = ImageLib.getImage(ImageLib.HADOOP_CLUSTER);
} else if (label.equals(EResourceConstant.CONTEXT.getName())) {
image = ImageLib.getImage(ImageLib.CONTEXT);
} else {
image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
}
}
} else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
} else if (type.equals(ENodeType.REFERENCED_PROJECT)) {
image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
} else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
// TDQ-7560 when the image is a overlay image,use originalImageName to get the corresponding one.
String originalImageName = null;
if (node instanceof DBConnectionRepNode) {
originalImageName = ImageLib.TD_DATAPROVIDER;
if (!RepositoryNodeHelper.isSupportedConnection(node) || isNeedAddDriverConnection(node)) {
image = ImageLib.createErrorIcon(originalImageName);
} else if (isInvalidJDBCConnection(node)) {
image = ImageLib.createInvalidIcon(originalImageName);
} else {
image = ImageLib.getImage(originalImageName);
}
} else if (node instanceof DFConnectionRepNode) {
originalImageName = ImageLib.FILE_DELIMITED;
} else if (node instanceof AnalysisRepNode) {
originalImageName = ImageLib.ANALYSIS_OBJECT;
image = addWarnIconIfNeeded(node, originalImageName);
} else if (node instanceof ReportRepNode) {
originalImageName = ImageLib.REPORT_OBJECT;
image = addWarnIconIfNeeded(node, originalImageName);
} else if (node instanceof SysIndicatorDefinitionRepNode) {
originalImageName = ImageLib.IND_DEFINITION;
} else if (node instanceof PatternRepNode) {
originalImageName = ImageLib.PATTERN_REG;
} else if (node instanceof RuleRepNode) {
if (((RuleRepNode) node).getRule() instanceof MatchRuleDefinition) {
originalImageName = ImageLib.MATCH_RULE_ICON;
} else {
originalImageName = ImageLib.DQ_RULE;
}
} else if (node instanceof SourceFileRepNode) {
originalImageName = ImageLib.SOURCE_FILE;
} else if (node instanceof HadoopClusterConnectionRepNode) {
originalImageName = ImageLib.HADOOP_CLUSTER;
} else if (node instanceof HDFSOfHCConnectionNode) {
originalImageName = ImageLib.HDFS;
} else if (node instanceof HiveOfHCConnectionNode) {
originalImageName = ImageLib.HIVE_LINK;
} else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
originalImageName = ImageLib.EXCHANGE;
} else if (node instanceof ContextRepNode) {
originalImageName = ImageLib.CONTEXT;
} else if (node instanceof RepositoryNode) {
// MOD qiongli 2011-1-18 get image for nodes in recycle bin
Image imageNode = getImageByContentType((RepositoryNode) node);
if (image != null) {
image = imageNode;
}
}
if (originalImageName != null && !(node instanceof DBConnectionRepNode || node instanceof AnalysisRepNode || node instanceof ReportRepNode)) {
image = ImageLib.getImage(originalImageName);
}
// exchange folder did not contain viewObject.
if (viewObject != null) {
// MOD yyi 2011-04-07 19696: "Lock element"
ERepositoryStatus status = ProxyRepositoryFactory.getInstance().getStatus(viewObject);
Context ctx = CoreRuntimePlugin.getInstance().getContext();
RepositoryContext rc = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
// will be enhanced later by TDI-29265.
if (rc.isEditableAsReadOnly()) {
if (status == ERepositoryStatus.LOCK_BY_USER) {
status = ERepositoryStatus.DEFAULT;
}
}
if (ERepositoryStatus.DEFAULT != status && originalImageName != null) {
if (ERepositoryStatus.LOCK_BY_USER == status) {
image = ImageLib.createLockedByOwnIcon(originalImageName);
} else if (ERepositoryStatus.LOCK_BY_OTHER == status) {
image = ImageLib.createLockedByOtherIcon(originalImageName);
}
}
}
} else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
if (node instanceof DBCatalogRepNode) {
image = ImageLib.getImage(ImageLib.CATALOG);
} else if (node instanceof DBSchemaRepNode) {
image = ImageLib.getImage(ImageLib.SCHEMA);
} else if (node instanceof DBTableFolderRepNode) {
image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
} else if (node instanceof DBViewFolderRepNode) {
image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
} else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
image = ImageLib.getImage(ImageLib.TABLE);
} else if (node instanceof DBViewRepNode) {
image = ImageLib.getImage(ImageLib.VIEW);
} else if (node instanceof DBColumnRepNode) {
if (((DBColumnRepNode) node).isKey()) {
image = ImageLib.getImage(ImageLib.PK_COLUMN);
} else {
image = ImageLib.getImage(ImageLib.TD_COLUMN);
}
} else if (node instanceof DFColumnRepNode) {
image = ImageLib.getImage(ImageLib.TD_COLUMN);
} else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
} else if (node instanceof JrxmlTempleteRepNode) {
image = ImageLib.getImage(ImageLib.JRXML_ICON);
}
}
}
}
return image;
}
use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode in project tdq-studio-se by Talend.
the class LocalRepositoryObjectCRUD method moveRepositoryNodes.
/**
* move RepositoryNodes to the target RepositoryNode.
*
* @param repositoryNodes
* @param targetNode
* @throws PersistenceException
*/
private void moveRepositoryNodes(IRepositoryNode[] repositoryNodes, IRepositoryNode targetNode) throws PersistenceException {
if (repositoryNodes != null) {
for (IRepositoryNode sourceNode : repositoryNodes) {
if (sourceNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
if (sourceNode instanceof AnalysisRepNode || sourceNode instanceof ConnectionRepNode) {
moveAnaConNode(sourceNode, targetNode);
} else if (sourceNode instanceof ReportRepNode) {
moveReportRepNode(sourceNode, targetNode);
} else {
IPath makeRelativeTo = getMakeRelativeTo(sourceNode);
IPath removeLastSegments = makeRelativeTo.removeLastSegments(1);
if (sourceNode instanceof SysIndicatorDefinitionRepNode) {
// SystemIndicatorDefinition can't be moved
if (!((SysIndicatorDefinitionRepNode) sourceNode).isSystemIndicator()) {
moveOthersNode(sourceNode, targetNode, removeLastSegments);
}
} else if (sourceNode instanceof PatternRepNode) {
moveOthersNode(sourceNode, targetNode, removeLastSegments);
} else if (sourceNode instanceof JrxmlTempleteRepNode) {
moveJrxmlFileRepNode(sourceNode, targetNode, makeRelativeTo);
} else if (sourceNode instanceof SourceFileRepNode || sourceNode instanceof RuleRepNode) {
moveOthersNode(sourceNode, targetNode, makeRelativeTo);
} else {
moveOthersNode(sourceNode, targetNode, removeLastSegments);
}
}
} else if (sourceNode.getType() == ENodeType.SIMPLE_FOLDER) {
moveFolderRepNode(sourceNode, targetNode);
}
// refresh the dq repository tree view
CorePlugin.getDefault().refreshDQView(targetNode.getParent());
// MOD qiongli 2012-4-23,only refresh the parent of source node at here.
CorePlugin.getDefault().refreshDQView(sourceNode.getParent());
}
}
}
use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode in project tdq-studio-se by Talend.
the class UDIUtils method createUdiCheckedTreeSelectionDialog.
/**
* DOC xqliu Comment method "createUdiCheckedTreeSelectionDialog".
*
* @param meIndicator
* @return
*/
public static CheckedTreeSelectionDialog createUdiCheckedTreeSelectionDialog(ModelElementIndicator meIndicator) {
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
dialog.addFilter(new FolderObjFilter());
DQRepositoryNode udiDialogInputData = AnalysisUtils.getSelectDialogInputData(EResourceConstant.USER_DEFINED_INDICATORS);
dialog.setInput(udiDialogInputData);
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
for (Object patte : selection) {
if (patte instanceof SysIndicatorDefinitionRepNode) {
SysIndicatorDefinitionRepNode udiNode = (SysIndicatorDefinitionRepNode) patte;
IndicatorDefinition indicatorDefinition = udiNode.getIndicatorDefinition();
boolean validStatus = TaggedValueHelper.getValidStatus(indicatorDefinition);
if (!validStatus) {
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString(// $NON-NLS-1$
"AnalysisColumnTreeViewer.chooseValidUdis"));
}
}
}
return new // $NON-NLS-1$
Status(// $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
PlatformUI.PLUGIN_ID, // $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
"", null);
}
});
dialog.setContainerMode(true);
dialog.setInitialSelections(getUDIFilesByIndicator(udiDialogInputData, meIndicator));
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.udiSelector"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.udis"));
dialog.setSize(80, 30);
return dialog;
}
use of org.talend.dq.nodes.SysIndicatorDefinitionRepNode 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.SysIndicatorDefinitionRepNode in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method addColumnUdi.
/**
* DOC xqliu Comment method "addColumnUdi". ADD xqliu 2010-02-23 feature 11617
*
* @param treeItem
* @param meIndicator
* @param columnIndex
* @return
*/
private TreeEditor addColumnUdi(final TreeItem treeItem, final ModelElementIndicator meIndicator, int columnIndex) {
TreeEditor addUdiEditor = new TreeEditor(tree);
// $NON-NLS-1$
Label addUdiLabl = createTreeItemLabel(tree, ImageLib.ADD_IND_DEFINITION, "AnalysisColumnTreeViewer.addUdi");
addUdiLabl.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
DataManager dm = getAnalysis().getContext().getConnection();
if (dm == null) {
masterPage.doSave(null);
}
CheckedTreeSelectionDialog dialog = UDIUtils.createUdiCheckedTreeSelectionDialog(meIndicator);
if (dialog.open() == Window.OK) {
// MOD qiongli 2012-10-24 TDQ-6308,just remove some deselected indicatorUnit then set dirty to
// true,just create new indicatorUnit for some new added UDI then set dirty to true.
List<IndicatorDefinition> allSelectedIndicatorDefinitions = new ArrayList<IndicatorDefinition>();
Set<String> allSelectedIndNames = new HashSet<String>();
for (Object obj : dialog.getResult()) {
if (obj instanceof SysIndicatorDefinitionRepNode) {
IndicatorDefinition udid = ((SysIndicatorDefinitionRepNode) obj).getIndicatorDefinition();
allSelectedIndicatorDefinitions.add(udid);
if (udid != null) {
allSelectedIndNames.add(udid.getName());
}
}
}
Set<String> oldSelectedIndNames = new HashSet<String>();
for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
Indicator indicator = indicatorUnit.getIndicator();
if (indicator instanceof UserDefIndicator) {
if (allSelectedIndNames.contains(indicator.getName())) {
oldSelectedIndNames.add(indicator.getName());
} else {
// remove the UDI from UI need to insert this UDI into removeList
deleteIndicatorItems(meIndicator, indicatorUnit);
if (!isDirty()) {
setDirty(true);
}
}
}
}
treeItem.removeAll();
for (IndicatorDefinition udid : allSelectedIndicatorDefinitions) {
if (udid != null && oldSelectedIndNames.contains(udid.getName())) {
continue;
}
IndicatorUnit[] addIndicatorUnits = null;
try {
addIndicatorUnits = UDIUtils.createIndicatorUnit(udid, meIndicator, getAnalysis());
} catch (Throwable e1) {
log.warn(e1, e1);
}
if (addIndicatorUnits != null && addIndicatorUnits.length > 0) {
for (IndicatorUnit unit : addIndicatorUnits) {
createOneUnit(treeItem, unit);
}
if (!isDirty()) {
setDirty(true);
}
}
}
treeItem.setExpanded(true);
masterPage.refreshTheTree(masterPage.getCurrentModelElementIndicators());
}
}
});
addUdiEditor.minimumWidth = addUdiLabl.getImage().getBounds().width;
addUdiEditor.setEditor(addUdiLabl, treeItem, columnIndex);
return addUdiEditor;
}
Aggregations