use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method createTree.
/**
* @param parent
*/
private Tree createTree(Composite parent) {
final Tree newTree = new TooltipTree(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION) {
@Override
protected boolean isValidItem(TreeItem item) {
if (item == null) {
return false;
}
Object itemData = item.getData(INDICATOR_UNIT_KEY);
Object columnItemData = item.getData(MODELELEMENT_INDICATOR_KEY);
if (itemData != null) {
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
if (indicatorUnit != null && !(indicatorUnit.getIndicator() instanceof CompositeIndicator)) {
return true;
}
return false;
} else {
if (columnItemData != null) {
ModelElementIndicator modelElementIndicator = (ModelElementIndicator) columnItemData;
IRepositoryNode modelElementRepositoryNode = modelElementIndicator.getModelElementRepositoryNode();
return modelElementRepositoryNode == null ? false : true;
}
return false;
}
}
@Override
protected String getItemTooltipText(TreeItem item) {
String expCont = isExpressionNull(item);
if (expCont == null) {
// $NON-NLS-1$
return DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.queryNotGen");
}
return expCont;
}
};
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(newTree);
newTree.setHeaderVisible(true);
// $NON-NLS-1$
createTreeItem(newTree, 300, "AnalysisColumnTreeViewer.analyzedColumns");
createTreeDataminingItem(newTree);
// $NON-NLS-1$
createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.pattern");
// $NON-NLS-1$
createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.udi");
// $NON-NLS-1$
createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.operation");
// TDQ-11622 : add a column here, let the width = 1 and text = EMPTY_STRING TODO need to find a better solution!
TreeColumn blankColumn = new TreeColumn(newTree, SWT.CENTER);
blankColumn.setWidth(1);
// ~ TDQ-11622
parent.layout();
AbstractAnalysisActionHandler actionHandler = new AbstractAnalysisActionHandler(parent) {
@Override
protected void handleRemove() {
removeSelectedElements(newTree);
}
};
parent.setData(AbstractMetadataFormPage.ACTION_HANDLER, actionHandler);
ColumnViewerDND.installDND(newTree);
this.addTreeListener(newTree);
newTree.setData(this);
return newTree;
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method openIndicatorSelectDialog.
/**
* Open the dialog for select indicator
*
* @param shell
* @return The array of ModelElementIndicator which selected by user if user click ok button. If cancel button be
* clicked then the size of return array will be zero. If have a Where Clause is error will return null
*/
public ModelElementIndicator[] openIndicatorSelectDialog(Shell shell) {
List<Object[]> previewData = masterPage.getSampleTable().getExistPreviewData();
final IndicatorSelectDialog dialog = new IndicatorSelectDialog(shell, DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.indicatorSelection"), masterPage.getCurrentModelElementIndicators(), // $NON-NLS-1$
previewData);
dialog.setLimitNumber(this.masterPage.getPreviewLimit());
dialog.create();
if (!DQPreferenceManager.isBlockWeb()) {
dialog.getShell().addShellListener(new ShellAdapter() {
@Override
public void shellActivated(ShellEvent e) {
dialog.getShell().setFocus();
IContext context = HelpSystem.getContext(HelpPlugin.getDefault().getIndicatorSelectorHelpContextID());
PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
}
});
dialog.getShell().addHelpListener(new HelpListener() {
public void helpRequested(HelpEvent e) {
IContext context = HelpSystem.getContext(HelpPlugin.getDefault().getIndicatorSelectorHelpContextID());
PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
}
});
}
if (dialog.open() == Window.OK) {
isGridPreviewColumnMoved = dialog.isGridPreviewColumnMoved();
ModelElementIndicator[] result = dialog.getResult();
for (ModelElementIndicator modelElementIndicator : result) {
modelElementIndicator.storeTempIndicator();
}
return result;
} else {
ModelElementIndicator[] result = dialog.getResult();
for (ModelElementIndicator modelElementIndicator : result) {
modelElementIndicator.getTempIndicator().clear();
}
return null;
}
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method canDrop.
@Override
public boolean canDrop(IRepositoryNode metadataRepositoryNode) {
IRepositoryViewObject metadataRepObject = metadataRepositoryNode.getObject();
ConnectionItem connItem = (ConnectionItem) metadataRepObject.getProperty().getItem();
// MOD qiongli 2010-8-19,bug 14436:could not come from diffrent connection
Connection tdProvider = connItem.getConnection();
if (tdProvider == null) {
return false;
} else if (this.getAnalysis().getContext().getConnection() != null && !ResourceHelper.areSame(tdProvider, this.getAnalysis().getContext().getConnection())) {
return false;
}
// MOD mzhao, 2010-07-23 bug 14014: If the editor is dirty, save it firstly before drag and drop an elements.
if (masterPage.isDirty()) {
masterPage.doSave(new NullProgressMonitor());
return false;
}
List<ModelElement> existModelElements = new ArrayList<ModelElement>();
for (ModelElementIndicator modelElementIndicator : this.getAllTheElementIndicator()) {
ModelElement me = RepositoryNodeHelper.getModelElementFromRepositoryNode(modelElementIndicator.getModelElementRepositoryNode());
existModelElements.add(me);
}
// MOD mzhao 9848 2010-01-14, allowing to drag and drop table.
if (metadataRepObject instanceof MetadataTableRepositoryObject) {
MetadataTableRepositoryObject tableRepObject = (MetadataTableRepositoryObject) metadataRepObject;
return !existModelElements.containsAll(ColumnSetHelper.getColumns((TdTable) tableRepObject.getTable()));
}
if (metadataRepObject instanceof MetadataColumnRepositoryObject) {
if (existModelElements.contains(((MetadataColumnRepositoryObject) metadataRepObject).getTdColumn())) {
return false;
}
}
if (metadataRepObject instanceof MetadataXmlElementTypeRepositoryObject) {
return !metadataRepositoryNode.hasChildren();
}
return true;
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method previewSelectedElements.
/**
* DOC Zqin Comment method "previewSelectedElements".
*
* @param newTree
*/
private void previewSelectedElements(Tree newTree) {
TreeItem[] items = newTree.getSelection();
ModelElement[] mes = new ModelElement[items.length];
for (int i = 0; i < items.length; i++) {
ModelElementIndicator meIndicator = (ModelElementIndicator) items[i].getData(AbstractColumnDropTree.MODELELEMENT_INDICATOR_KEY);
ModelElement me = ((MetadataColumnRepositoryObject) meIndicator.getModelElementRepositoryNode().getObject()).getTdColumn();
mes[i] = me;
}
new PreviewColumnAction(mes).run();
}
use of org.talend.dataprofiler.core.model.ModelElementIndicator in project tdq-studio-se by Talend.
the class UDIUtils method createIndicatorUnit.
public static IndicatorUnit[] createIndicatorUnit(IndicatorDefinition udid, ModelElementIndicator meIndicator, Analysis analysis) throws Throwable {
List<IndicatorUnit> addIndicatorUnits = new ArrayList<IndicatorUnit>();
// can't add the same user defined indicator
for (Indicator indicator : meIndicator.getIndicators()) {
// MOD xwang 2011-08-01 bug TDQ-2730
if (udid.getName().equals(indicator.getName()) && indicator instanceof UserDefIndicator) {
// $NON-NLS-1$
MessageUI.openWarning(DefaultMessagesImpl.getString("UDIUtils.UDISelected", udid.getName()));
return null;
}
}
Indicator udi = UDIFactory.createUserDefIndicator(udid);
udi.setIndicatorDefinition(udid);
// MOD mzhao feature 11128, Handle Java User Defined Indicator.
Indicator judi = UDIHelper.adaptToJavaUDI(udi);
if (judi != null) {
udi = judi;
}
IEditorPart activeEditor = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor == null || !(activeEditor instanceof AnalysisEditor)) {
return null;
}
ExecutionLanguage executionLanguage = ((AnalysisEditor) activeEditor).getUIExecuteEngin();
boolean isJavaEngin = ExecutionLanguage.JAVA.equals(executionLanguage);
DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(analysis, executionLanguage);
Expression returnExpression = dbmsLanguage.getExpression(udi);
String executeType = isJavaEngin ? executionLanguage.getName() : dbmsLanguage.getDbmsName();
// MOD qiongli 2013.5.22 TDQ-7282.if don't find a valid java expression for JUDI,should also pop this dialog.
boolean finddExpression = true;
if (isJavaEngin && judi == null || !isJavaEngin && returnExpression == null) {
finddExpression = false;
}
if (!finddExpression) {
// open the editor
boolean openUDI = MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("PatternUtilities.Warning"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("UDIUtils.NoExpression", executeType));
if (openUDI) {
RepositoryNode node = RepositoryNodeHelper.recursiveFind(udid);
if (RepositoryNodeHelper.canOpenEditor(node)) {
new OpenItemEditorAction(new IRepositoryNode[] { node }).run();
}
}
return null;
}
// dbmsLanguage
IndicatorParameters parameters = udi.getParameters();
if (parameters == null) {
parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
udi.setParameters(parameters);
}
Domain indicatorValidDomain = parameters.getIndicatorValidDomain();
if (indicatorValidDomain == null) {
// $NON-NLS-1$
indicatorValidDomain = DomainHelper.createDomain("JAVA_UDI_PARAMETERS");
parameters.setIndicatorValidDomain(indicatorValidDomain);
}
List<IndicatorDefinitionParameter> indicatorDefs = udid.getIndicatorDefinitionParameter();
for (IndicatorDefinitionParameter idp : indicatorDefs) {
JavaUDIIndicatorParameter judip = DomainHelper.createJavaUDIIndicatorParameter(idp.getKey(), idp.getValue());
indicatorValidDomain.getJavaUDIIndicatorParameter().add(judip);
}
IndicatorEnum indicatorType = IndicatorEnum.findIndicatorEnum(udi.eClass());
addIndicatorUnits.add(meIndicator.addSpecialIndicator(indicatorType, udi));
DependenciesHandler.getInstance().setUsageDependencyOn(analysis, udid);
return addIndicatorUnits.toArray(new IndicatorUnit[addIndicatorUnits.size()]);
}
Aggregations