use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ExportWizard method performFinish.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
if (!exportPage.canFinish()) {
return false;
}
final IExportWriter writer = exportPage.getWriter();
final ItemRecord[] records = exportPage.getElements();
IRunnableWithProgress op = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// $NON-NLS-1$
monitor.beginTask("Export Item", records.length);
writer.write(records, monitor);
monitor.done();
}
};
try {
ProgressUI.popProgressDialog(op);
} catch (Exception e) {
log.error(e, e);
}
return true;
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ExportWizardPage method createUtilityButtons.
/**
* DOC bZhou Comment method "createUtilityButtons".
*
* @param treeComposite
*/
protected void createUtilityButtons(Composite treeComposite) {
Composite utilityComposite = new Composite(treeComposite, SWT.NONE);
utilityComposite.setLayout(new GridLayout());
utilityComposite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
Composite btnsComposite = new Composite(utilityComposite, SWT.NONE);
btnsComposite.setLayout(new GridLayout());
GridData gd = new GridData();
gd.verticalAlignment = SWT.BEGINNING;
gd.horizontalIndent = 0;
gd.horizontalSpan = 0;
btnsComposite.setLayoutData(gd);
selectAllBTN = new Button(btnsComposite, SWT.PUSH);
selectAllBTN.setText(SELECT_ALL);
selectAllBTN.setToolTipText(SELECT_ALL);
deselectAllBTN = new Button(btnsComposite, SWT.PUSH);
deselectAllBTN.setText(DESELECT_ALL);
deselectAllBTN.setToolTipText(DESELECT_ALL);
addRequireBTN = new Button(btnsComposite, SWT.PUSH);
addRequireBTN.setText(INCLUDE_DEPENDANCY);
addRequireBTN.setToolTipText(INCLUDE_DEPENDANCY);
Composite infoComposite = new Composite(utilityComposite, SWT.NONE);
infoComposite.setLayout(new GridLayout());
gd = new GridData(GridData.FILL_BOTH);
gd.verticalAlignment = SWT.BOTTOM;
gd.horizontalIndent = 0;
gd.horizontalSpan = 0;
infoComposite.setLayoutData(gd);
final Button showSelectBTN = new Button(infoComposite, SWT.CHECK);
showSelectBTN.setText(SHOW_ONLY_SELECTED);
showSelectBTN.setToolTipText(SHOW_ONLY_SELECTED);
Button[] utilityBTNs = new Button[] { selectAllBTN, deselectAllBTN, addRequireBTN };
for (Button btn : utilityBTNs) {
gd = new GridData();
gd.widthHint = 170;
gd.verticalIndent = 0;
gd.horizontalIndent = 0;
btn.setLayoutData(gd);
}
selectAllBTN.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] topItems = repositoryTree.getTree().getItems();
for (TreeItem treeItem : topItems) {
repositoryTree.setSubtreeChecked(treeItem.getData(), true);
}
repositoryTree.refresh();
updatePageStatus();
}
});
deselectAllBTN.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] topItems = repositoryTree.getTree().getItems();
for (TreeItem treeItem : topItems) {
repositoryTree.setSubtreeChecked(treeItem.getData(), false);
}
repositoryTree.refresh();
updatePageStatus();
}
});
addRequireBTN.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (showSelectBTN.getSelection()) {
filterUncheckedItems(false);
}
ItemRecord[] records = getElements();
for (ItemRecord record : records) {
for (File depFile : record.getDependencySet()) {
// ignore it(means not export it).
if (!DqFileUtils.isLocalProjectFile(depFile)) {
continue;
}
// TDQ-12245~
ItemRecord depRecord = ItemRecord.findRecord(depFile);
if (!repositoryTree.getChecked(depRecord)) {
repositoryTree.setChecked(depRecord, true);
}
}
}
if (showSelectBTN.getSelection()) {
filterUncheckedItems(true);
}
checkForErrors();
}
});
showSelectBTN.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
filterUncheckedItems(showSelectBTN.getSelection());
}
});
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ExportWizardPage method addSubRepToElements.
/**
* add related subReport jrxml/jasper file to List.
*
* @param record
* @param itemRecords
*/
private void addSubRepToElements(ItemRecord record, List<ItemRecord> itemRecords) {
File file = record.getFile();
if (record.getProperty() == null) {
return;
}
String version = record.getProperty().getVersion();
String nameWithoutVersion = file.getName().replaceAll(underlineStr + version, PluginConstant.EMPTY_STRING).replaceAll(PluginConstant.DOT_STRING + FactoriesUtil.JRXML, PluginConstant.EMPTY_STRING);
IFile iFile = ResourceManager.getJRXMLFolder().getFile(subrepName);
File subRepFolder = WorkspaceUtils.ifileToFile(iFile);
if (subRepFolder == null || !subRepFolder.exists()) {
return;
}
Map<String, List<String>> mainSubRepMap = ReportFileHelper.getMainSubRepMap();
String fName;
for (File f : subRepFolder.listFiles()) {
fName = f.getName();
if (fName.equalsIgnoreCase(file.getName())) {
continue;
}
// add the same name jasper file when the sub-report jrxml is checked on UI.
if (fName.equalsIgnoreCase(nameWithoutVersion + PluginConstant.DOT_STRING + PluginConstant.JASPER_STRING)) {
ItemRecord itemRecord = new ItemRecord(f);
itemRecords.add(itemRecord);
continue;
}
// add sub-reports jrxml and jasper when the main-report is checked on UI.
List<String> subLsFromMap = mainSubRepMap.get(nameWithoutVersion);
if (subLsFromMap != null) {
for (String name : subLsFromMap) {
if (fName.startsWith(name)) {
ItemRecord itemRecord = new ItemRecord(f);
itemRecords.add(itemRecord);
}
}
}
}
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ExportWizardPage method addListeners.
/**
* DOC bZhou Comment method "addListeners".
*/
private void addListeners() {
SelectionListener modeSwitchListener = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setDirState(isDirState());
setArchState(!isDirState());
}
};
dirBTN.addSelectionListener(modeSwitchListener);
archBTN.addSelectionListener(modeSwitchListener);
ModifyListener populateListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
updateBasePath();
}
};
dirTxt.addModifyListener(populateListener);
archTxt.addModifyListener(populateListener);
browseDirBTN.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String result = openDirectoryDialog();
if (result != null) {
dirTxt.setText(result);
}
}
private String openDirectoryDialog() {
DirectoryDialog dialog = new DirectoryDialog(Display.getDefault().getActiveShell());
if (dirTxt.getText() != null) {
dialog.setFilterPath(dirTxt.getText());
}
return dialog.open();
}
});
browseArchBTN.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String result = openFileDialog();
if (result != null) {
IPath path = new Path(result);
if (StringUtils.isBlank(path.getFileExtension())) {
// $NON-NLS-1$
path = path.addFileExtension("zip");
}
archTxt.setText(path.toOSString());
}
}
private String openFileDialog() {
FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell());
dialog.setFilterExtensions(FILE_EXPORT_MASK);
if (archTxt.getText() != null) {
dialog.setFileName(archTxt.getText());
}
return dialog.open();
}
});
repositoryTree.getTree().addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem item = (TreeItem) e.item;
ItemRecord record = (ItemRecord) item.getData();
if (record.getFile().isFile()) {
// MOD qiongli TDQ-5368 only uncheck the client dependecy when uncheck an item,not supplier
// dependency.
boolean checked = item.getChecked();
if (checked) {
for (File file : record.getDependencySet()) {
// ignore it(means not export it).
if (!DqFileUtils.isLocalProjectFile(file)) {
continue;
}
// TDQ-12245~
ItemRecord findRecord = ItemRecord.findRecord(file);
if (findRecord != null) {
repositoryTree.setChecked(findRecord, checked);
} else {
// $NON-NLS-1$
log.error("Can't find the file: " + file.getAbsolutePath());
}
}
} else {
ModelElement element = record.getElement();
List<ModelElement> dependencyClients;
if (element != null) {
dependencyClients = EObjectHelper.getDependencyClients(element);
} else {
// for context,the dependency should include related Connection
Property property = record.getProperty();
dependencyClients = ImportAndExportUtils.getContextClientDepend(property.getId());
}
if (!dependencyClients.isEmpty()) {
ImportAndExportUtils.iterateUncheckClientDependency(dependencyClients, repositoryTree);
}
}
}
repositoryTree.refresh();
checkForErrors();
}
});
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ImportAndExportUtils method getContextClientDepend.
/**
* Find client dependencies by contextId. it might be Connection
*
* @param contextId
* @return
*/
public static List<ModelElement> getContextClientDepend(String contextId) {
List<ModelElement> modelElementLs = new ArrayList<ModelElement>();
if (StringUtils.isEmpty(contextId)) {
return modelElementLs;
}
for (ItemRecord record : ItemRecord.getAllItemRecords()) {
Property property = record.getProperty();
if (property == null) {
continue;
}
Item item = property.getItem();
if (item instanceof ConnectionItem) {
Connection connection = ((ConnectionItem) item).getConnection();
if (connection.isContextMode() && contextId.equals(connection.getContextId())) {
modelElementLs.add(record.getElement());
}
}
}
return modelElementLs;
}
Aggregations