use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ImportWizardPage method textModified.
/**
* DOC sgandon Comment method "dirTextModified".
*/
protected void textModified(String pathStr) {
IPath path = new Path(pathStr);
if (path.toFile().exists()) {
ItemRecord input = writer.computeInput(path);
migrate();
repositoryTree.setInput(input);
repositoryTree.expandAll();
TreeItem[] topItems = repositoryTree.getTree().getItems();
for (TreeItem treeItem : topItems) {
repositoryTree.setSubtreeChecked(treeItem.getData(), true);
}
repositoryTree.refresh();
} else {
repositoryTree.setInput(null);
}
populateElement();
checkforErrors();
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ImportWizardPage 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) {
archTxt.setText(result);
}
}
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();
}
});
overwriteBTN.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// MOD msjian 2012-2-29 TDQ-4701: fixed another issue, when the user checked the overwrite checkbox, do
// not do migration
populateElement();
checkforErrors();
// TDQ-4701 ~
}
});
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()) {
ItemRecord findRecord = ItemRecord.findRecord(file);
if (findRecord != null) {
repositoryTree.setChecked(findRecord, checked);
}
}
} else {
ModelElement element = record.getElement();
List<ModelElement> dependencyClients;
if (element != null) {
dependencyClients = EObjectHelper.getDependencyClients(element);
ImportAndExportUtils.iterateUncheckClientDependency(dependencyClients, repositoryTree);
} 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);
}
}
}
populateElement();
repositoryTree.refresh();
checkforErrors();
}
});
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ImportWizardPage method getElements.
/**
* DOC bZhou Comment method "getElements".
*
* @return
*/
public ItemRecord[] getElements() {
List<ItemRecord> itemRecords = new ArrayList<ItemRecord>();
Object[] checkedElements = repositoryTree.getCheckedElements();
for (Object obj : checkedElements) {
if (obj instanceof ItemRecord) {
ItemRecord record = (ItemRecord) obj;
// MOD qiongli 2012-4-20,add related subreport jrxml/jasper file to elements.
File file = record.getFile();
if (file.isFile()) {
itemRecords.add(record);
if (file.getName().endsWith(FactoriesUtil.JRXML)) {
addSubRepToElements(record, itemRecords);
}
// if it is Mean Indicator, import it's dependency Sum Indicator also
// $NON-NLS-1$
String meanIndicatorUuid = "_ccI48RF2Ed2PKb6nEJEvhw";
ModelElement element = record.getElement();
if (element != null && element instanceof IndicatorDefinition && meanIndicatorUuid.equals(ResourceHelper.getUUID(element))) {
File sumIndicatorFile = getSumIndicatorFile(element);
if (sumIndicatorFile != null) {
itemRecords.add(new ItemRecord(sumIndicatorFile, record.getRootFolderPath()));
}
}
}
}
}
return itemRecords.toArray(new ItemRecord[itemRecords.size()]);
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class ImportWizardPage 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);
File parentFile = file.getParentFile().getParentFile();
if (parentFile == null || !parentFile.exists()) {
return;
}
File subRepFolder = new Path(parentFile.getPath() + IPath.SEPARATOR + subrepName).toFile();
if (subRepFolder == null || !subRepFolder.exists()) {
return;
}
Map<String, List<String>> mainSubRepMap = ReportFileHelper.getMainSubRepMap();
String fName;
for (File f : subRepFolder.listFiles()) {
fName = f.getName();
if (f.getName().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, record.getRootFolderPath());
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, record.getRootFolderPath());
itemRecords.add(itemRecord);
}
}
}
}
}
use of org.talend.dataprofiler.core.ui.imex.model.ItemRecord in project tdq-studio-se by Talend.
the class FileTreeLabelProviderTest method testGetImageObjectCase1.
/**
* Test method for {@link org.talend.dataprofiler.core.ui.imex.FileTreeLabelProvider#getImage(java.lang.Object)}.
* case 1 :element is match rule
*/
@Test
public void testGetImageObjectCase1() {
File file = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(createTDQMatchRuleItem.getMatchRule().eResource().getURI().toPlatformString(false))).getLocation().toFile();
ItemRecord itemRecord = new ItemRecord(file);
FileTreeLabelProvider fileTreeLabelProvider = new FileTreeLabelProvider();
Image image = fileTreeLabelProvider.getImage(itemRecord);
Assert.assertEquals(ImageLib.getImage(ImageLib.MATCH_RULE_ICON), image);
}
Aggregations