use of org.talend.designer.mapper.external.data.ExternalMapperUiProperties in project tdi-studio-se by Talend.
the class MapperUI method createWindow.
/**
* DOC amaumont Comment method "createUI".
*
* @param display
*/
public Shell createWindow(final Display display, MapperModel model) {
Shell activeShell = display.getActiveShell();
Shell mapperShell = null;
int style = SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX | SWT.APPLICATION_MODAL | SWT.RESIZE;
if (activeShell == null) {
mapperShell = new Shell(mapperShell, style);
} else {
mapperShell = new Shell(activeShell, style);
}
this.mapperUIParent = mapperShell;
final Shell mapperShellFinal = mapperShell;
mapperShell.addShellListener(new ShellListener() {
public void shellActivated(ShellEvent e) {
}
public void shellClosed(ShellEvent e) {
UIManager uiManager = mapperManager.getUiManager();
if (uiManager.getMapperResponse() == SWT.NONE) {
for (DataMapTableView dataMapTableView : uiManager.getInputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
for (DataMapTableView dataMapTableView : uiManager.getOutputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
for (DataMapTableView dataMapTableView : uiManager.getVarsTablesView()) {
dataMapTableView.notifyFocusLost();
}
uiManager.setMapperResponse(SWT.CANCEL);
uiManager.prepareClosing(uiManager.getMapperResponse());
}
if (!mapperManager.componentIsReadOnly() && mapperManager.isDataChanged() && !mapperManager.getUiManager().isCloseWithoutPrompt()) {
boolean closeWindow = MessageDialog.openConfirm(mapperShellFinal, //$NON-NLS-1$
Messages.getString("MapperUI.CancelWithoutSaveModifications.Title"), //$NON-NLS-1$
Messages.getString("MapperUI.CancelWithoutSaveModifications.Message"));
if (!closeWindow) {
e.doit = false;
} else {
mapperManager.getAbstractMapComponent().setExternalData(mapperManager.getOriginalExternalData());
mapperManager.getUiManager().prepareClosing(SWT.CANCEL);
}
}
}
public void shellDeactivated(ShellEvent e) {
}
public void shellDeiconified(ShellEvent e) {
}
public void shellIconified(ShellEvent e) {
}
});
MapperComponent component = (MapperComponent) mapperManager.getAbstractMapComponent();
ExternalMapperUiProperties uiProperties = mapperManager.getUiManager().getUiProperties();
mapperShell.setImage(CoreImageProvider.getComponentIcon(component.getComponent(), ICON_SIZE.ICON_32));
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
String productName = brandingService.getFullProductName();
mapperShell.setText(Messages.getString("MapperMain.ShellTitle", productName, component.getComponent().getName(), //$NON-NLS-1$
component.getUniqueName()));
Rectangle boundsMapper = uiProperties.getBoundsMapper();
if (uiProperties.isShellMaximized()) {
mapperShell.setMaximized(uiProperties.isShellMaximized());
} else {
if (uiProperties.getBoundsMapper().equals(ExternalMapperUiProperties.DEFAULT_BOUNDS_MAPPER)) {
mapperShell.setMaximized(true);
// boundsMapper = display.getBounds(); //no need this, will cause the full problems.
} else {
// // move shell at outer of display zone to avoid visual effect on loading
// Rectangle tmpBoundsMapper = new Rectangle(-boundsMapper.width, boundsMapper.y, boundsMapper.width,
// boundsMapper.height);
// shell.setBounds(tmpBoundsMapper);
boundsMapper = uiProperties.getBoundsMapper();
if (boundsMapper.x < 0) {
boundsMapper.x = 0;
}
if (boundsMapper.y < 0) {
boundsMapper.y = 0;
}
mapperShell.setBounds(boundsMapper);
}
}
createCompositeContent(model);
mapperShell.open();
return mapperShell;
}
use of org.talend.designer.mapper.external.data.ExternalMapperUiProperties in project tdi-studio-se by Talend.
the class UIManager method saveCurrentUIProperties.
/**
* DOC amaumont Comment method "saveUiProperties".
*/
private void saveCurrentUIProperties() {
uiProperties = new ExternalMapperUiProperties();
uiProperties.setWeightsMainSashForm(mapperUI.getMainSashForm().getWeights());
uiProperties.setWeightsDatasFlowViewSashForm(mapperUI.getDatasFlowViewSashForm().getWeights());
uiProperties.setShellMaximized(getMapperContainer().getShell().getMaximized());
if (!uiProperties.isShellMaximized()) {
uiProperties.setBoundsMapper(getMapperContainer().getBounds());
}
}
use of org.talend.designer.mapper.external.data.ExternalMapperUiProperties in project tdi-studio-se by Talend.
the class MapperComponent method buildExternalData.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.process.AbstractExternalNode#setExternalXmlData(java.io.InputStream)
*/
// public void loadDataIn(InputStream in, Reader stringReader) throws IOException, ClassNotFoundException {
//
// if (stringReader != null) {
// Unmarshaller unmarshaller = new Unmarshaller(ExternalMapperData.class);
// unmarshaller.setWhitespacePreserve(true);
// try {
// externalData = (ExternalMapperData) unmarshaller.unmarshal(stringReader);
// } catch (MarshalException e) {
// ExceptionHandler.process(e);
// } catch (ValidationException e) {
// ExceptionHandler.process(e);
// } finally {
// if (stringReader != null) {
// stringReader.close();
// }
// }
// }
//
// }
/*
* (non-Javadoc)
*
* @see org.talend.core.model.process.IExternalNode#loadDataOut(java.io.OutputStream, java.io.Writer)
*/
// public void loadDataOut(final OutputStream out, Writer writer) throws IOException {
// // System.out.println("loadDataOut");
//
// initMapperMain(false);
//
// mapperMain.createModelFromExternalData(getIncomingConnections(), getOutgoingConnections(), externalData,
// getMetadataList(), false);
// ExternalMapperData data = mapperMain.buildExternalData();
// if (mapperMain != null && data != null) {
//
// try {
// Marshaller marshaller = new Marshaller(writer);
// marshaller.marshal(externalData);
//
// } catch (MarshalException e) {
// ExceptionHandler.process(e);
// } catch (ValidationException e) {
// ExceptionHandler.process(e);
// } catch (IOException e) {
// ExceptionHandler.process(e);
// } finally {
// if (writer != null) {
// writer.close();
// }
// }
//
// // ObjectOutputStream objectOut = null;
// // try {
// // objectOut = new ObjectOutputStream(out);
// // objectOut.writeObject(data);
// // } catch (IOException e) {
// // ExceptionHandler.process(e);
// // } finally {
// // if (objectOut != null) {
// // objectOut.close();
// // }
// // }
// }
// }
@Override
public void buildExternalData(AbstractExternalData abstractData) {
externalData = new ExternalMapperData();
if (abstractData instanceof MapperData) {
MapperData mapperData = (MapperData) abstractData;
List<ExternalMapperTable> externalTables = new ArrayList<ExternalMapperTable>();
// input
for (InputTable pTable : mapperData.getInputTables()) {
ExternalMapperTable externalTable = new ExternalMapperTable();
setExternalTable(externalTable, pTable);
externalTable.setLookupMode(pTable.getLookupMode());
externalTable.setMatchingMode(pTable.getMatchingMode());
externalTable.setInnerJoin(pTable.isInnerJoin());
externalTable.setPersistent(pTable.isPersistent());
externalTable.setGlobalMapKeysValues(getExternalEntities(pTable.getGlobalMapKeysValues()));
externalTables.add(externalTable);
}
externalData.setInputTables(externalTables);
// output
externalTables = new ArrayList<ExternalMapperTable>();
for (OutputTable pTable : mapperData.getOutputTables()) {
ExternalMapperTable externalTable = new ExternalMapperTable();
setExternalTable(externalTable, pTable);
externalTable.setReject(pTable.isReject());
externalTable.setRejectInnerJoin(pTable.isRejectInnerJoin());
externalTable.setErrorRejectTable(pTable.isIsErrorRejectTable());
externalTable.setIsJoinTableOf(pTable.getIsJoinTableOf());
externalTables.add(externalTable);
}
externalData.setOutputTables(externalTables);
// var tables
externalTables = new ArrayList<ExternalMapperTable>();
for (VarTable varTable : mapperData.getVarTables()) {
ExternalMapperTable externalTable = new ExternalMapperTable();
externalTable.setSizeState(varTable.getSizeState().getLiteral());
externalTable.setMinimized(varTable.isMinimized());
externalTable.setName(varTable.getName());
externalTable.setMetadataTableEntries(getExternalEntities(varTable.getMapperTableEntries()));
externalTables.add(externalTable);
}
externalData.setVarsTables(externalTables);
ExternalMapperUiProperties uiProperties = new ExternalMapperUiProperties();
UiProperties uiPro = mapperData.getUiProperties();
if (uiPro != null) {
uiProperties.setShellMaximized(uiPro.isShellMaximized());
}
}
this.setExternalData(externalData);
}
use of org.talend.designer.mapper.external.data.ExternalMapperUiProperties in project tdi-studio-se by Talend.
the class MapperUI method createCompositeContent.
public void createCompositeContent(MapperModel mapperModel) {
// long time1 = System.currentTimeMillis();
// CommandStack commandStack = new CommandStackForComposite(this.mapperUIParent);
// mapperManager.setCommandStack(commandStack);
updateBackgroundEnabled = false;
List<? extends IConnection> inConnections = mapperManager.getAbstractMapComponent().getIncomingConnections();
List<? extends IConnection> outConnections = mapperManager.getAbstractMapComponent().getOutgoingConnections();
// see bug 7471, record the precolumns value
for (IConnection conn : inConnections) {
conn.getMetadataTable();
if (conn.getMetadataTable() != null) {
List<IMetadataColumn> inputColumns = conn.getMetadataTable().getListColumns();
for (IMetadataColumn inputColumn : inputColumns) {
Set<String> columnSet = preColumnSet.get(conn);
if (columnSet == null) {
columnSet = new HashSet<String>();
preColumnSet.put(conn, columnSet);
}
columnSet.add(inputColumn.getLabel());
preColumnSet.put(conn, columnSet);
}
}
}
for (IConnection conn : outConnections) {
if (conn.getMetadataTable() != null) {
List<IMetadataColumn> outputColumns = conn.getMetadataTable().getListColumns();
for (IMetadataColumn outputColumn : outputColumns) {
Set<String> columnSet = preColumnSet.get(conn);
if (columnSet == null) {
columnSet = new HashSet<String>();
preColumnSet.put(conn, columnSet);
}
columnSet.add(outputColumn.getLabel());
preColumnSet.put(conn, columnSet);
}
}
}
final UIManager uiManager = mapperManager.getUiManager();
final ExternalMapperUiProperties uiProperties = uiManager.getUiProperties();
addParentListeners(uiManager, uiProperties);
bgColorLinksZone = ColorProviderMapper.getColor(ColorInfo.COLOR_BACKGROUND_LINKS_ZONE);
GridLayout parentLayout = new GridLayout(1, true);
mapperUIParent.setLayout(parentLayout);
addKeyListener(uiManager, display);
addBackgroundRefreshLimiters(display);
this.dropTargetOperationListener = new DropTargetOperationListener(mapperManager);
dropTargetOperationListener.addControl(this.mapperUIParent.getShell());
mainSashForm = new SashForm(mapperUIParent, SWT.SMOOTH | SWT.VERTICAL);
GridData mainSashFormGridData = new GridData(GridData.FILL_BOTH);
mainSashForm.setLayoutData(mainSashFormGridData);
datasFlowViewSashForm = new SashForm(mainSashForm, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
datasFlowViewSashForm.setBackgroundMode(SWT.INHERIT_FORCE);
initBackgroundComponents();
if (WindowSystem.isGTK()) {
datasFlowViewSashForm.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
}
// dropTargetOperationListener.addControl(datasFlowViewSashForm);
// datasFlowViewSashForm.addControlListener(new ControlListener() {
//
// public void controlMoved(ControlEvent e) {
// }
//
// public void controlResized(ControlEvent e) {
// createBgImages();
// updateBackground(true, false);
// }
//
// });
/* Create the tabs */
tabFolderEditors = new TabFolderEditors(mainSashForm, SWT.BORDER, mapperManager);
createInputZoneWithTables(mapperModel, display);
createVarsZoneWithTables(mapperModel, display);
createOutputZoneWithTables(mapperModel, uiManager, display);
uiManager.parseAllExpressionsForAllTables();
mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
mapperManager.getProblemsManager().checkLookupExpressionProblem();
this.draggingInfosPopup = DraggingInfosPopup.getNewShell(this.mapperUIParent.getShell());
configureZoneScrollBars(display);
int[] weightsDatasFlowViewSashForm = uiProperties.getWeightsDatasFlowViewSashForm();
datasFlowViewSashForm.setWeights(weightsDatasFlowViewSashForm.length != 0 ? weightsDatasFlowViewSashForm : ExternalMapperUiProperties.DEFAULT_WEIGHTS_DATAS_FLOW_SASH_FORM);
int[] weightsMainSashForm = uiProperties.getWeightsMainSashForm();
weightsMainSashForm = weightsMainSashForm.length != 0 ? weightsMainSashForm : ExternalMapperUiProperties.DEFAULT_WEIGHTS_MAIN_SASH_FORM;
mainSashForm.setWeights(weightsMainSashForm);
footerComposite = new FooterComposite(this.mapperUIParent, SWT.NONE, mapperManager);
selectFirstInOutTablesView();
updateBackgroundEnabled = true;
updateBackground(true, false);
// List<DataMapTableView> inputsTablesView = uiManager.getInputsTablesView();
// for (DataMapTableView table : inputsTablesView) {
//
// table.showTableGlobalMap(false);
// table.showTableGlobalMap(true);
//
// // table.updateGridDataHeightForTableGlobalMap();
// // table.resizeAtExpandedSize();
// }
}
Aggregations