use of org.apache.commons.collections.bidimap.DualHashBidiMap in project tdi-studio-se by Talend.
the class DynamicComposite method addComponents.
/**
* Initialize all components for the defined section for this node.
*/
public void addComponents(boolean forceRedraw, boolean reInitialize, int height) {
checkErrorsWhenViewRefreshed = true;
int heightSize = 0, maxRowSize = 0, nbInRow, numInRow;
int maxRow;
boolean isCompute = false;
Map<String, Integer> groupPosition = new HashMap<String, Integer>();
List<? extends IElementParameter> listParam = elem.getElementParametersWithChildrens();
if (!forceRedraw) {
boolean needRedraw = isNeedRedraw();
if (!needRedraw) {
// System.out.println("no need redraw");
return;
}
}
Control lastControl = null;
if (reInitialize) {
if (currentComponent != null) {
disposeChildren();
}
} else {
heightSize = height;
}
hashCurControls = new DualHashBidiMap();
maxRow = 0;
for (int i = 0; i < listParam.size(); i++) {
if (listParam.get(i).getCategory() == section) {
if (listParam.get(i).getNumRow() > maxRow && listParam.get(i).isShow(listParam)) {
maxRow = listParam.get(i).getNumRow();
}
}
}
IElementParameter synchronizeSchemaParam = elem.getElementParameter(EParameterName.NOT_SYNCHRONIZED_SCHEMA.getName());
if (synchronizeSchemaParam != null) {
// if the node don't contains a schema type and accept an input flow and is not synchronized
// display a schema on the first line just the type to synchronize the schema
synchronizeSchemaParam.setShow(!((Node) elem).isSchemaSynchronized());
}
generator.initController(this);
// System.out.println("********************** NEW ADDCOMPONENTS
// **********************");
// TabbedPropertyComposite tabbedPropertyComposite = this.getTabbedPropertyComposite();
int additionalHeightSize = 0;
boolean hasDynamicRow = false;
for (int i = 0; i < listParam.size(); i++) {
IElementParameter curParam = listParam.get(i);
if (curParam.getCategory() == section) {
if (curParam.getFieldType() != EParameterFieldType.TECHNICAL) {
if (curParam.isShow(listParam)) {
AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
if (controller == null) {
continue;
}
if (controller.hasDynamicRowSize()) {
hasDynamicRow = true;
break;
}
}
}
}
}
if (hasDynamicRow) {
additionalHeightSize = estimatePropertyHeightSize(maxRow, listParam);
}
//$NON-NLS-1$
long lastTime = TimeMeasure.timeSinceBegin("DC:refresh:" + getCurrentComponent());
for (int curRow = 1; curRow <= maxRow; curRow++) {
nbInRow = 0;
for (int i = 0; i < listParam.size(); i++) {
IElementParameter curParam = listParam.get(i);
if (curParam.getCategory() == section) {
if (curParam.getNumRow() == curRow && curParam.isShow(listParam) && (curParam.getFieldType() != EParameterFieldType.TECHNICAL)) {
nbInRow++;
}
}
}
numInRow = 0;
lastControl = null;
curRowSize = 0;
for (int i = 0; i < listParam.size(); i++) {
IElementParameter curParam = listParam.get(i);
if (curParam.getCategory() == section) {
if (curParam.getNumRow() == curRow && (curParam.getFieldType() != EParameterFieldType.TECHNICAL)) {
// field:"+curParam.getField());
if (curParam.isShow(listParam)) {
// System.out.println("show:" + curParam.getName()+
// " field:"+curParam.getField());
numInRow++;
AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
if (controller == null) {
continue;
}
if (controller.hasDynamicRowSize()) {
controller.setAdditionalHeightSize(additionalHeightSize);
}
String groupName = curParam.getGroup();
Composite subComposite = null;
if (groupName != null) {
if (!hashCurControls.containsKey(groupName)) {
if (groupPosition.size() > 0) {
heightSize += DEFAULT_GROUP_HEIGHT;
}
new GroupController(this).createControl(composite, curParam, numInRow, nbInRow, heightSize, lastControl);
groupPosition.put(groupName, heightSize);
}
subComposite = (Composite) hashCurControls.get(groupName);
int h2 = heightSize - groupPosition.get(groupName);
lastControl = controller.createControl(subComposite, curParam, numInRow, nbInRow, h2, lastControl);
} else {
if (isCompactView()) {
int h3 = DEFAULT_GROUP_HEIGHT * (groupPosition.size() > 0 ? 1 : 0) + heightSize;
lastControl = controller.createControl(composite, curParam, numInRow, nbInRow, h3, lastControl);
} else {
if (numInRow > 1 && nbInRow > 1) {
heightSize += maxRowSize;
}
int h3 = DEFAULT_GROUP_HEIGHT * (groupPosition.size() > 0 ? 1 : 0) + heightSize;
lastControl = controller.createControl(composite, curParam, 1, 1, h3, null);
}
}
//$NON-NLS-1$
lastTime = TimeMeasure.timeSinceBegin("DC:refresh:" + getCurrentComponent()) - lastTime;
if (DynamicTabbedPropertySection.DEBUG_TIME) {
System.out.println(//$NON-NLS-1$ //$NON-NLS-2$
"DC;create:" + curParam.getFieldType().getName() + ";" + getCurrentComponent() + ";" + //$NON-NLS-1$
lastTime);
}
// System.out.println("param:" + curParam.getName()
// + " - curRowSize:" + curRowSize);
maxRowSize = 0;
if (curRowSize > maxRowSize) {
maxRowSize = curRowSize;
isCompute = true;
}
}
}
}
}
if (isCompute) {
heightSize += maxRowSize;
isCompute = false;
}
}
if (synchronizeSchemaParam != null) {
synchronizeSchemaParam.setShow(false);
}
resizeScrolledComposite();
}
use of org.apache.commons.collections.bidimap.DualHashBidiMap in project tdi-studio-se by Talend.
the class DynamicTabbedPropertySection method addComponents.
/**
* Initialize all components for the defined section for this node.
*/
public void addComponents(boolean forceRedraw, boolean reInitialize) {
registerListenerForRefreshingSection();
checkErrorsWhenViewRefreshed = true;
int heightSize = 0, maxRowSize = 0, nbInRow, numInRow;
int maxRow;
List<? extends IElementParameter> listParam = elem.getElementParameters();
oldQueryStoreType = (String) elem.getPropertyValue(EParameterName.QUERYSTORE_TYPE.getName());
if (oldQueryStoreType != null) {
if (oldQueryStoreType.equals(EmfComponent.REPOSITORY)) {
showQueryStoreRepositoryList(true);
updateRepositoryList();
} else {
showQueryStoreRepositoryList(false);
}
}
IElementParameter param = elem.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
if (param != null) {
oldPropertyType = (String) param.getValue();
if (param.isShow(elem.getElementParameters())) {
if (oldPropertyType.equals(EmfComponent.REPOSITORY)) {
showPropertyRepositoryList(true, false);
updateRepositoryList();
} else {
showPropertyRepositoryList(false, false);
}
} else {
showPropertyRepositoryList(false, false);
}
}
// param = elem.getElementParameter(extraPropertyTypeName);
if (param != null) {
oldPropertyType = (String) param.getValue();
if (param.isShow(elem.getElementParameters())) {
if (oldPropertyType.equals(EmfComponent.REPOSITORY)) {
showPropertyRepositoryList(true, true);
updateRepositoryList();
} else {
showPropertyRepositoryList(false, true);
}
} else {
showPropertyRepositoryList(false, true);
}
}
oldProcessType = (String) elem.getPropertyValue(EParameterName.PROCESS_TYPE_PROCESS.getName());
if (oldProcessType != null) {
String[] list = elem.getElementParameter(EParameterName.PROCESS_TYPE_PROCESS.getName()).getListItemsDisplayName();
if ((oldProcessType.equals("NO_PROCESS") || (list.length == 0))) {
//$NON-NLS-1$
updateProcessList();
updateContextList();
if (elem instanceof Node) {
((Node) elem).checkAndRefreshNode();
}
}
}
if (!forceRedraw) {
boolean needRedraw = false;
for (IElementParameter elementParameter : elem.getElementParametersWithChildrens()) {
if (elementParameter.getCategory().equals(section) && (elementParameter.getFieldType() != EParameterFieldType.SCHEMA_TYPE) && (elementParameter.getFieldType() != EParameterFieldType.SCHEMA_REFERENCE) && (elementParameter.getFieldType() != EParameterFieldType.QUERYSTORE_TYPE)) {
// if the component must be displayed, then check if the
// control exists or not.
boolean show = elementParameter.isShow(elem.getElementParameters());
Object control;
if (elementParameter.getParentParameter() == null) {
control = this.hashCurControls.get(elementParameter.getName());
} else {
control = this.hashCurControls.get(//$NON-NLS-1$
elementParameter.getParentParameter().getName() + ":" + elementParameter.getName());
}
if ((control == null && show) || (control != null && !show)) {
needRedraw = true;
break;
// System.out.println(elementParameter.getName() + "
// need redraw");
}
}
}
if (!needRedraw) {
// System.out.println("no need redraw");
return;
}
}
Control lastControl = null;
if (reInitialize) {
if (currentComponent != null && composite != null) {
Control[] ct = composite.getChildren();
for (Control element : ct) {
element.dispose();
}
}
} else {
// Control[] ct = composite.getChildren();
// int curY = 0, maxY = 0;
// for (int i = 0; i < ct.length; i++) {
// curY = ct[i].getLocation().y + ct[i].computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
// if (curY > maxY) {
// maxY = curY;
// }
// }
heightSize = curRowSize;
}
hashCurControls = new DualHashBidiMap();
maxRow = 0;
for (int i = 0; i < listParam.size(); i++) {
if (listParam.get(i).getCategory() == section) {
if (listParam.get(i).getNumRow() > maxRow && listParam.get(i).isShow(listParam)) {
maxRow = listParam.get(i).getNumRow();
}
}
}
generator.initController(this);
// System.out.println("********************** NEW ADDCOMPONENTS
// **********************");
TabbedPropertyComposite tabbedPropertyComposite = this.getTabbedPropertyComposite();
int additionalHeightSize = 0;
if (tabbedPropertyComposite != null && (!(elem instanceof org.talend.designer.core.ui.editor.connections.Connection))) {
boolean hasDynamicRow = false;
for (int i = 0; i < listParam.size(); i++) {
IElementParameter curParam = listParam.get(i);
if (curParam.getCategory() == section) {
if (curParam.getFieldType() != EParameterFieldType.TECHNICAL) {
if (curParam.isShow(listParam)) {
AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
if (controller == null) {
continue;
}
if (controller.hasDynamicRowSize()) {
hasDynamicRow = true;
break;
}
}
}
}
}
if (hasDynamicRow) {
additionalHeightSize = estimatePropertyHeightSize(maxRow, listParam, tabbedPropertyComposite);
}
}
//$NON-NLS-1$
long lastTime = TimeMeasure.timeSinceBegin("DTP:refresh:" + getCurrentComponent());
curRowSize = 0;
for (int curRow = 1; curRow <= maxRow; curRow++) {
maxRowSize = 0;
nbInRow = 0;
for (int i = 0; i < listParam.size(); i++) {
IElementParameter curParam = listParam.get(i);
if (curParam.getCategory() == section) {
if (curParam.getNumRow() == curRow && curParam.isShow(listParam) && (curParam.getFieldType() != EParameterFieldType.TECHNICAL)) {
nbInRow++;
}
}
}
numInRow = 0;
lastControl = null;
for (int i = 0; i < listParam.size(); i++) {
IElementParameter curParam = listParam.get(i);
if (curParam.getCategory() == section) {
if (curParam.getNumRow() == curRow && (curParam.getFieldType() != EParameterFieldType.TECHNICAL)) {
// field:"+curParam.getField());
if (curParam.isShow(listParam)) {
// System.out.println("show:" + curParam.getName()+
// " field:"+curParam.getField());
numInRow++;
AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
if (controller == null) {
continue;
}
if (controller.hasDynamicRowSize()) {
controller.setAdditionalHeightSize(additionalHeightSize);
}
lastControl = controller.createControl(composite, curParam, numInRow, nbInRow, heightSize, lastControl);
//$NON-NLS-1$
lastTime = TimeMeasure.timeSinceBegin("DTP:refresh:" + getCurrentComponent()) - lastTime;
if ((DynamicTabbedPropertySection.DEBUG_TIME) && !getCurrentComponent().equals("Job")) {
//$NON-NLS-1$
System.out.println(//$NON-NLS-1$ //$NON-NLS-2$
"DTP;create:" + curParam.getFieldType().getName() + ";" + getCurrentComponent() + ";" + //$NON-NLS-1$
lastTime);
}
if (curRowSize > maxRowSize) {
maxRowSize = curRowSize;
}
}
}
}
}
heightSize += maxRowSize;
}
resizeScrolledComposite();
}
use of org.apache.commons.collections.bidimap.DualHashBidiMap in project maven-plugins by apache.
the class IssuesReportHelper method getColumnIds.
/**
* Get a list of id:s for the columns that are to be included in the report. This method also handles deprecated
* column names, which will still work. If deprecated column names are used they generate a warning, indicating the
* replacement column name.
*
* @param columnNames The names of the columns
* @param allColumns A mapping from column name to column id
* @param deprecatedColumns A mapping from deprecated column name to column id
* @param log A log
* @return A List of column id:s
*/
public static List<Integer> getColumnIds(String columnNames, Map<String, Integer> allColumns, Map<String, Integer> deprecatedColumns, Log log) {
DualHashBidiMap bidiColumns = null;
List<Integer> columnIds = new ArrayList<Integer>();
String[] columnNamesArray = columnNames.split(",");
if (deprecatedColumns != null) {
bidiColumns = new DualHashBidiMap(allColumns);
}
// Loop through the names of the columns, to validate each of them and add their id to the list
for (String aColumnNamesArray : columnNamesArray) {
String columnName = aColumnNamesArray.trim();
if (allColumns.containsKey(columnName)) {
columnIds.add(allColumns.get(columnName));
} else if (deprecatedColumns != null && deprecatedColumns.containsKey(columnName)) {
Integer columnId = deprecatedColumns.get(columnName);
columnIds.add(columnId);
if (log != null) {
log.warn("The columnName '" + columnName + "' has been deprecated." + " Please use " + "the columnName '" + bidiColumns.getKey(columnId) + "' instead.");
}
}
}
return columnIds;
}
use of org.apache.commons.collections.bidimap.DualHashBidiMap in project tdi-studio-se by Talend.
the class MultipleThreadDynamicComposite method addComponents.
/**
* Initialize all components for the defined section for this node.
*/
public synchronized void addComponents(boolean forceRedraw, boolean reInitialize, int height) {
// achen modifed to fix feature 0005991 if composite.isDisposed return
if (elem == null || composite.isDisposed()) {
return;
}
checkErrorsWhenViewRefreshed = true;
int heightSize = 0, maxRowSize = 0, nbInRow, numInRow;
int maxRow;
boolean isCompute = false;
if (!forceRedraw) {
boolean needRedraw = isNeedRedraw();
if (!needRedraw) {
// System.out.println("no need redraw");
return;
}
}
Control lastControl = null;
if (reInitialize) {
if (currentComponent != null) {
disposeChildren();
}
} else {
heightSize = height;
}
final List<IElementParameter> currentValidParameters = new ArrayList<IElementParameter>(20);
hashCurControls = new DualHashBidiMap();
maxRow = 0;
List<? extends IElementParameter> listParam = elem.getElementParametersWithChildrens();
Map<String, Integer> groupPosition = new HashMap<String, Integer>();
for (int i = 0; i < listParam.size(); i++) {
IElementParameter param = listParam.get(i);
if (param.getCategory() == section && param.getFieldType() != EParameterFieldType.TECHNICAL && param.isShow(listParam)) {
currentValidParameters.add(param);
if (param.getNumRow() > maxRow) {
maxRow = param.getNumRow();
}
}
}
IElementParameter synchronizeSchemaParam = elem.getElementParameter(EParameterName.NOT_SYNCHRONIZED_SCHEMA.getName());
if (synchronizeSchemaParam != null) {
// if the node don't contains a schema type and accept an input flow and is not synchronized
// display a schema on the first line just the type to synchronize the schema
synchronizeSchemaParam.setShow(!((Node) elem).isSchemaSynchronized());
IElementParameter schemaTypeParam = synchronizeSchemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
if (schemaTypeParam != null) {
schemaTypeParam.setReadOnly(((Node) elem).isSchemaSynchronized());
}
}
generator.initController(this);
int additionalHeightSize = 0;
boolean hasDynamicRow = false;
for (int i = 0; i < currentValidParameters.size(); i++) {
IElementParameter curParam = currentValidParameters.get(i);
AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
if (controller == null) {
continue;
}
if (controller.hasDynamicRowSize()) {
hasDynamicRow = true;
break;
}
}
if (hasDynamicRow) {
additionalHeightSize = estimatePropertyHeightSize(maxRow, listParam);
}
for (int curRow = 1; curRow <= maxRow; curRow++) {
maxRowSize = 0;
nbInRow = 0;
for (int i = 0; i < currentValidParameters.size(); i++) {
IElementParameter curParam = currentValidParameters.get(i);
if (curParam.getNumRow() == curRow) {
nbInRow++;
}
}
numInRow = 0;
lastControl = null;
curRowSize = 0;
for (int i = 0; i < currentValidParameters.size(); i++) {
IElementParameter curParam = currentValidParameters.get(i);
updateParameter(curParam);
if (curParam.getNumRow() == curRow && isShouldDisParameter(curParam)) {
numInRow++;
AbstractElementPropertySectionController controller = generator.getController(curParam.getFieldType(), this);
if (controller == null) {
continue;
}
if (controller.hasDynamicRowSize()) {
controller.setAdditionalHeightSize(additionalHeightSize);
}
String groupName = curParam.getGroup();
Composite subComposite = null;
Control cutLastControl = lastControl;
int curNumInRow = numInRow;
int curNbInRow = nbInRow;
int curTop = 0;
if (!isCompactView()) {
if (numInRow > 1 && nbInRow > 1) {
heightSize += maxRowSize;
}
curNumInRow = 1;
curNbInRow = 1;
cutLastControl = null;
}
if (groupName != null) {
if (!hashCurControls.containsKey(groupName)) {
if (groupPosition.size() > 0) {
heightSize += DEFAULT_GROUP_HEIGHT;
}
new GroupController(this).createControl(composite, curParam, numInRow, nbInRow, heightSize, lastControl);
groupPosition.put(groupName, heightSize);
}
subComposite = (Composite) hashCurControls.get(groupName);
curTop = heightSize - groupPosition.get(groupName);
} else {
subComposite = composite;
curTop = DEFAULT_GROUP_HEIGHT * (groupPosition.size() > 0 ? 1 : 0) + heightSize;
}
lastControl = controller.createControl(subComposite, curParam, curNumInRow, curNbInRow, curTop, cutLastControl);
if (curRowSize > maxRowSize) {
maxRowSize = curRowSize;
}
}
}
heightSize += maxRowSize;
}
if (synchronizeSchemaParam != null) {
synchronizeSchemaParam.setShow(false);
}
minHeight = heightSize;
resizeScrolledComposite();
}
Aggregations