use of org.eclipse.ui.dialogs.CheckedTreeSelectionDialog in project tdq-studio-se by Talend.
the class SetJDBCDriverPreferencePage method createConnSelectDialog.
private CheckedTreeSelectionDialog createConnSelectDialog() {
RepositoryNode node = (RepositoryNode) RepositoryNodeHelper.getMetadataFolderNode(EResourceConstant.DB_CONNECTIONS);
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(getShell(), new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
dialog.setInput(node);
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof DBConnectionRepNode) {
return isJdbcConnectionNode((DBConnectionRepNode) element);
} else if (element instanceof DBConnectionSubFolderRepNode) {
return hasJdbcConnNodeChild((DBConnectionSubFolderRepNode) element);
}
return false;
}
});
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
for (Object object : selection) {
if (object instanceof DBConnectionRepNode) {
IRepositoryViewObject nodeObject = ((DBConnectionRepNode) object).getObject();
// when it's locked, can not modify
if (nodeObject != null && nodeObject.getProperty() != null && nodeObject.getProperty().getItem() != null && (nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER || nodeObject.getRepositoryStatus() == ERepositoryStatus.LOCK_BY_USER || RepositoryManager.isOpenedItemInEditor(nodeObject))) {
String displayName = nodeObject.getProperty().getDisplayName();
String version = nodeObject.getProperty().getVersion();
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.isLocked", // $NON-NLS-1$ //$NON-NLS-2$
displayName + " " + version));
}
}
}
return new // $NON-NLS-1$
Status(// $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
PlatformUI.PLUGIN_ID, // $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
"", null);
}
});
dialog.setContainerMode(true);
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.selectConnectionButton"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("SetJDBCDriverPreferencePage.ApplytoConnectionEditors"));
dialog.setSize(80, 30);
return dialog;
}
use of org.eclipse.ui.dialogs.CheckedTreeSelectionDialog in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method addColumnUdi.
/**
* DOC xqliu Comment method "addColumnUdi". ADD xqliu 2010-02-23 feature 11617
*
* @param treeItem
* @param meIndicator
* @param columnIndex
* @return
*/
private TreeEditor addColumnUdi(final TreeItem treeItem, final ModelElementIndicator meIndicator, int columnIndex) {
TreeEditor addUdiEditor = new TreeEditor(tree);
// $NON-NLS-1$
Label addUdiLabl = createTreeItemLabel(tree, ImageLib.ADD_IND_DEFINITION, "AnalysisColumnTreeViewer.addUdi");
addUdiLabl.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
DataManager dm = getAnalysis().getContext().getConnection();
if (dm == null) {
masterPage.doSave(null);
}
CheckedTreeSelectionDialog dialog = UDIUtils.createUdiCheckedTreeSelectionDialog(meIndicator);
if (dialog.open() == Window.OK) {
// MOD qiongli 2012-10-24 TDQ-6308,just remove some deselected indicatorUnit then set dirty to
// true,just create new indicatorUnit for some new added UDI then set dirty to true.
List<IndicatorDefinition> allSelectedIndicatorDefinitions = new ArrayList<IndicatorDefinition>();
Set<String> allSelectedIndNames = new HashSet<String>();
for (Object obj : dialog.getResult()) {
if (obj instanceof SysIndicatorDefinitionRepNode) {
IndicatorDefinition udid = ((SysIndicatorDefinitionRepNode) obj).getIndicatorDefinition();
allSelectedIndicatorDefinitions.add(udid);
if (udid != null) {
allSelectedIndNames.add(udid.getName());
}
}
}
Set<String> oldSelectedIndNames = new HashSet<String>();
for (IndicatorUnit indicatorUnit : meIndicator.getIndicatorUnits()) {
Indicator indicator = indicatorUnit.getIndicator();
if (indicator instanceof UserDefIndicator) {
if (allSelectedIndNames.contains(indicator.getName())) {
oldSelectedIndNames.add(indicator.getName());
} else {
// remove the UDI from UI need to insert this UDI into removeList
deleteIndicatorItems(meIndicator, indicatorUnit);
if (!isDirty()) {
setDirty(true);
}
}
}
}
treeItem.removeAll();
for (IndicatorDefinition udid : allSelectedIndicatorDefinitions) {
if (udid != null && oldSelectedIndNames.contains(udid.getName())) {
continue;
}
IndicatorUnit[] addIndicatorUnits = null;
try {
addIndicatorUnits = UDIUtils.createIndicatorUnit(udid, meIndicator, getAnalysis());
} catch (Throwable e1) {
log.warn(e1, e1);
}
if (addIndicatorUnits != null && addIndicatorUnits.length > 0) {
for (IndicatorUnit unit : addIndicatorUnits) {
createOneUnit(treeItem, unit);
}
if (!isDirty()) {
setDirty(true);
}
}
}
treeItem.setExpanded(true);
masterPage.refreshTheTree(masterPage.getCurrentModelElementIndicators());
}
}
});
addUdiEditor.minimumWidth = addUdiLabl.getImage().getBounds().width;
addUdiEditor.setEditor(addUdiLabl, treeItem, columnIndex);
return addUdiEditor;
}
use of org.eclipse.ui.dialogs.CheckedTreeSelectionDialog in project tdq-studio-se by Talend.
the class PatternLabelProvider method createPatternCheckedTreeSelectionDialog.
/**
* create CheckedTreeSelectionDialog for patterns.
*
* @param node Pattern root RepositoryNode.
* @return
*/
public static CheckedTreeSelectionDialog createPatternCheckedTreeSelectionDialog(IRepositoryNode node) {
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
dialog.setInput(node);
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
for (Object patte : selection) {
if (patte instanceof PatternRepNode) {
PatternRepNode patternNode = (PatternRepNode) patte;
Pattern findPattern = patternNode.getPattern();
boolean validStatus = TaggedValueHelper.getValidStatus(findPattern);
if (!validStatus) {
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString(// $NON-NLS-1$
"AnalysisColumnTreeViewer.chooseValidPatterns"));
}
}
}
return new // $NON-NLS-1$
Status(// $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
PlatformUI.PLUGIN_ID, // $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
"", null);
}
});
dialog.setContainerMode(true);
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.patternSelector"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.patterns"));
dialog.setSize(80, 30);
return dialog;
}
Aggregations