use of org.talend.dq.nodes.ReportAnalysisRepNode 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.ReportAnalysisRepNode in project tdq-studio-se by Talend.
the class LocalRepositoryObjectCRUD method isForbidNode.
/**
* check whether the node is forbidden to drag.
*
* @param sourceNode
* @return
*/
private boolean isForbidNode(IRepositoryNode sourceNode) {
ENodeType type = sourceNode.getType();
// MOD xqliu 2012-05-22 TDQ-4831 allow user to drag Jrxml file
boolean flag = (type != null && type == ENodeType.SYSTEM_FOLDER) || sourceNode instanceof ReportFileRepNode || sourceNode instanceof ReportAnalysisRepNode;
// ~ TDQ-4831
if (!flag) {
RepositoryNode parent = sourceNode.getParent();
if (parent != null) {
flag = parent instanceof AnalysisRepNode || parent instanceof ReportRepNode || (parent instanceof AnalysisSubFolderRepNode && ((AnalysisSubFolderRepNode) parent).getObject() == null);
}
}
return flag;
}
use of org.talend.dq.nodes.ReportAnalysisRepNode in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method createTreeMenu.
/**
* DOC qzhang Comment method "createTreeMenu". MOD qiongli bug 16252.Add a param of 'isColumnSetMenu'
*
* @param newTree
* @param containEdit
*/
public void createTreeMenu(boolean isColumnSetMenu) {
Menu oldMenu = tree.getMenu();
if (oldMenu != null && !oldMenu.isDisposed()) {
oldMenu.dispose();
}
Menu menu = new Menu(tree);
if (isSelectedColumn(tree.getSelection())) {
if (!isMetadataColumnSelected(tree.getSelection())) {
MenuItem previewMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
previewMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.previewDQElement"));
previewMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
previewMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected (org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
previewSelectedElements(tree);
}
});
}
if (isColumnSetMenu) {
MenuItem createColumnAnalysisMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
createColumnAnalysisMenuItem.setText(DefaultMessagesImpl.getString("CreateColumnAnalysisAction.columnAnalysis"));
createColumnAnalysisMenuItem.setImage(ImageLib.getImage(ImageLib.ACTION_NEW_ANALYSIS));
createColumnAnalysisMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
createColumnAnalysis(tree);
}
});
}
MenuItem showLocationMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
showLocationMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.showDQElement"));
showLocationMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
showLocationMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org.eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
showSelectedElements(tree);
}
});
}
if (isSelectedIndicator(tree.getSelection()) && !isMetadataColumnIndicatorSelected(tree.getSelection())) {
// MOD 2009-01-04 mzhao
MenuItem showQueryMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
showQueryMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.viewQuery"));
showQueryMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
showQueryMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected (org.eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
viewQueryForSelectedElement(tree);
}
});
}
if (isSelectedPatternIndicator(tree.getSelection())) {
MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.editPattern"));
editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
editPatternMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org .eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
editPattern(tree);
}
});
}
// judge to indicator whether is frequency
if (isSelectedFrequencyIndicator(tree.getSelection()) && PluginChecker.isTDCPLoaded()) {
MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.generateJob"));
editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.ICON_PROCESS));
editPatternMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final IDatabaseJobService service = (IDatabaseJobService) GlobalServiceRegister.getDefault().getService(IJobService.class);
if (service != null) {
service.setIndicator(getSelectedIndicator(tree.getSelection()));
IRepositoryNode anaNode = getAnalysis2();
Analysis ana;
if (anaNode instanceof ReportAnalysisRepNode) {
ana = ((ReportAnalysisRepNode) anaNode).getAnalysis();
} else {
ana = ((AnalysisRepNode) anaNode).getAnalysis();
}
service.setAnalysis(ana);
service.executeJob();
}
}
});
}
if (isSelectedUDIndicator(tree.getSelection())) {
MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.editUDIndicator"));
editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.IND_DEFINITION));
editPatternMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org .eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
editUDIndicator(tree);
}
});
}
// add common menu to the tree
MenuItem addTaskItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
addTaskItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.AddTask"));
addTaskItem.setImage(ImageLib.getImage(ImageLib.ADD_ACTION));
addTaskItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org .eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = tree.getSelection();
if (selection.length > 0) {
IRepositoryNode ana = getAnalysis2();
// MOD qiongli 2011-1-12 feature 16796 :handle the case of ModelElement name is null
(new TdAddTaskAction(tree.getShell(), ana)).run();
}
}
});
MenuItem deleteMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
deleteMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.removeElement"));
deleteMenuItem.setImage(ImageLib.getImage(ImageLib.DELETE_ACTION));
deleteMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org .eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
removeSelectedElements2(tree);
}
});
tree.setMenu(menu);
}
use of org.talend.dq.nodes.ReportAnalysisRepNode in project tdq-studio-se by Talend.
the class RemoveAnalysisActionProvider method fillContextMenu.
@Override
public void fillContextMenu(IMenuManager menu) {
// MOD mzhao user readonly role on svn repository mode.
if (!isShowMenu()) {
return;
}
TreeSelection treeSelection = ((TreeSelection) this.getContext().getSelection());
if (!treeSelection.isEmpty()) {
Iterator iterator = treeSelection.iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof ReportAnalysisRepNode) {
ReportAnalysisRepNode repAnaNode = (ReportAnalysisRepNode) obj;
TDQReportItem reportItem = repAnaNode.getReportItem();
if (CorePlugin.getDefault().itemIsOpening(reportItem, false)) {
// if the report's editor is opening, don't show the menu
return;
}
} else {
// if include other type node, don't show the menu
return;
}
}
}
// show the menu
menu.add(new RemoveAnalysisAction());
}
Aggregations