use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor in project tdq-studio-se by Talend.
the class CommonEditorPartListener method partOpened.
@Override
public void partOpened(IWorkbenchPart part) {
// Added TDQ-7531 20130718 add lock support for sql source file/jrxml file
if (part.getClass().getName().equals(SqlExplorerUtils.SQLEDITOR_ID)) {
lockFile(part);
super.partOpened(part);
return;
}
// MOD mzhao bug 12497 Firstly check if the part is TDQ common form editor.
if (!isCommonFormEditor(part)) {
return;
}
Item item = getItem((IEditorPart) part);
if (item == null) {
return;
}
CorePlugin.getDefault().refreshWorkSpace();
// (when remote and ask user: when the user select unlock should be also not editable)
if (!ProxyRepositoryFactory.getInstance().isEditableAndLockIfPossible(item)) {
// MOD yyi 2010-11-29 15686: Make the editor readonly when the login user has no sufficient previlege.
lockCommonFormEditor(part);
WorkspaceResourceHelper.refreshItem(item);
return;
}
WorkspaceResourceHelper.refreshItem(item);
if (part instanceof AnalysisEditor) {
((AnalysisEditor) part).getMasterPage().autoRefreshPreviewData();
}
super.partOpened(part);
}
use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor 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()]);
}
use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor in project tdq-studio-se by Talend.
the class DataFilterDND method installDND.
public static void installDND(final Text 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);
dropTarget.addDropListener(new DropTargetAdapter() {
@Override
public void dragEnter(DropTargetEvent event) {
Object obj = ((IStructuredSelection) commonViewer.getSelection()).getFirstElement();
if (!(obj instanceof DBColumnRepNode)) {
event.detail = DND.DROP_NONE;
} else {
event.detail = DND.DROP_MOVE;
event.feedback = DND.FEEDBACK_INSERT_AFTER;
}
}
@Override
public void dropAccept(DropTargetEvent event) {
// do nothing until now
}
@Override
public void drop(DropTargetEvent event) {
if (event.detail != DND.DROP_NONE) {
IStructuredSelection selection = (IStructuredSelection) commonViewer.getSelection();
if (!selection.isEmpty()) {
List list = selection.toList();
IEditorPart currentActiveEditor = CorePlugin.getDefault().getCurrentActiveEditor();
if (currentActiveEditor instanceof AnalysisEditor) {
AnalysisEditor editor = (AnalysisEditor) currentActiveEditor;
AnalysisItemEditorInput input = (AnalysisItemEditorInput) editor.getEditorInput();
for (Object object : list) {
DBColumnRepNode node = (DBColumnRepNode) object;
DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage((Analysis) input.getModel());
MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) node.getObject();
String name = columnObject.getTdColumn().getName();
targetControl.insert(language.quote(name));
// Focus text.
targetControl.forceFocus();
}
}
}
}
}
});
}
use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor in project tdq-studio-se by Talend.
the class CorePlugin method getCurrentOpenAnalysisEditor.
public List<AnalysisEditor> getCurrentOpenAnalysisEditor() {
IWorkbenchPage activePage = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorReferences = activePage.getEditorReferences();
List<AnalysisEditor> result = new ArrayList<AnalysisEditor>();
for (IEditorReference iEditorReference : editorReferences) {
IEditorPart editor = iEditorReference.getEditor(false);
if (editor instanceof AnalysisEditor) {
result.add((AnalysisEditor) editor);
}
}
return result;
}
use of org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor in project tdq-studio-se by Talend.
the class MatchAnalysisAction method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
PackagesAnalyisParameter packaFilterParameter = new PackagesAnalyisParameter();
if (needselection) {
IRepositoryNode firstElement = (RepositoryNode) this.selection.getFirstElement();
IRepositoryViewObject viewObject = firstElement.getObject();
Item item = viewObject.getProperty().getItem();
ConnectionItem connectionItem = (ConnectionItem) item;
Connection connection = connectionItem.getConnection();
IRepositoryNode repositoryNode = RepositoryNodeHelper.recursiveFind(connection);
packaFilterParameter.setConnectionRepNode(repositoryNode);
}
if (openMatchAnalysisDialog(packaFilterParameter) == Window.OK) {
AnalysisEditor editor = (AnalysisEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editor != null) {
MatchAnalysisDetailsPage page = (MatchAnalysisDetailsPage) editor.getMasterPage();
IRepositoryNode[] columns = getColumns();
if (this.needselection && columns.length > 0) {
page.updateAnalyzeDataLabel(columns[0]);
page.setSelectedNodes(columns);
}
page.doSave(null);
}
}
}
Aggregations