use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class DirectoryController method createControl.
/*
* (non-Javadoc)
*
* @see org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#
* createControl( org.eclipse.swt.widgets.Composite, org.talend.core.model.process.IElementParameter, int, int, int,
* org.eclipse.swt.widgets.Control)
*/
@Override
public Control createControl(final Composite subComposite, final IElementParameter param, final int numInRow, final int nbInRow, final int top, final Control lastControl) {
this.curParameter = param;
FormData data;
CLabel labelLabel = getWidgetFactory().createCLabel(subComposite, param.getDisplayName());
data = new FormData();
if (lastControl != null) {
data.left = new FormAttachment(lastControl, 0);
} else {
data.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
data.top = new FormAttachment(0, top);
labelLabel.setLayoutData(data);
if (numInRow != 1) {
labelLabel.setAlignment(SWT.RIGHT);
}
//$NON-NLS-1$
Button btnEdit = getWidgetFactory().createButton(subComposite, "", SWT.PUSH);
btnEdit.setImage(ImageProvider.getImage(CoreUIPlugin.getImageDescriptor(DOTS_BUTTON)));
data = new FormData();
data.left = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), -STANDARD_BUTTON_WIDTH);
data.right = new FormAttachment(((numInRow * MAX_PERCENT) / nbInRow), 0);
data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
data.height = STANDARD_HEIGHT - 2;
btnEdit.setLayoutData(data);
btnEdit.setData(NAME, DIRECTORY);
btnEdit.setData(PARAMETER_NAME, param.getName());
btnEdit.setEnabled(!param.isReadOnly());
btnEdit.addSelectionListener(listenerSelection);
DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, new SelectAllTextControlCreator());
if (param.isRequired()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
}
Control cLayout = dField.getLayoutControl();
Text labelText = (Text) dField.getControl();
cLayout.setBackground(subComposite.getBackground());
if (!elem.isReadOnly()) {
if (param.isRepositoryValueUsed()) {
addRepositoryPropertyListener(labelText);
}
labelText.setEditable(!param.isReadOnly() && !param.isRepositoryValueUsed());
} else {
labelText.setEditable(false);
}
labelText.setData(PARAMETER_NAME, param.getName());
editionControlHelper.register(param.getName(), labelText);
addDragAndDropTarget(labelText);
if (elem instanceof Node) {
labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
// **************************
data = new FormData();
int currentLabelWidth = STANDARD_LABEL_WIDTH;
GC gc = new GC(labelLabel);
Point labelSize = gc.stringExtent(param.getDisplayName());
gc.dispose();
if ((labelSize.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth) {
currentLabelWidth = labelSize.x + ITabbedPropertyConstants.HSPACE;
}
if (numInRow == 1) {
if (lastControl != null) {
data.left = new FormAttachment(lastControl, currentLabelWidth);
} else {
data.left = new FormAttachment(0, currentLabelWidth);
}
} else {
data.left = new FormAttachment(labelLabel, 0, SWT.RIGHT);
}
data.right = new FormAttachment(btnEdit, 0);
data.top = new FormAttachment(labelLabel, 0, SWT.CENTER);
cLayout.setLayoutData(data);
hashCurControls.put(param.getName(), labelText);
Point initialSize = dField.getLayoutControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
return btnEdit;
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class InsertionIndicator method createComponents.
/**
* DOC amaumont Comment method "createComponents".
*/
private void createComponents() {
leftArrowDraggingIndicator = new Composite(tablesZoneViewParent, SWT.NONE | SWT.NO_BACKGROUND);
leftArrowDraggingIndicator.setVisible(false);
leftArrowDraggingIndicator.setBackgroundMode(SWT.INHERIT_DEFAULT);
FormData formDataLeftArrow = new FormData();
formDataLeftArrow.width = 12;
formDataLeftArrow.height = HEIGHT_INDICATOR;
formDataLeftArrow.left = new FormAttachment(0, 0);
formDataLeftArrow.left = new FormAttachment(0, -formDataLeftArrow.width + 2);
formDataLeftArrow.top = new FormAttachment(0, 0);
leftArrowDraggingIndicator.setLayoutData(formDataLeftArrow);
rightArrowDraggingIndicator = new Composite(tablesZoneViewParent, SWT.NONE | SWT.NO_BACKGROUND);
rightArrowDraggingIndicator.setVisible(false);
rightArrowDraggingIndicator.setBackgroundMode(SWT.INHERIT_DEFAULT);
FormData formDataRightArrow = new FormData();
formDataRightArrow.width = 13;
formDataRightArrow.height = HEIGHT_INDICATOR;
// this property is recalculated at each top changement
formDataRightArrow.left = new FormAttachment(0, 0);
formDataRightArrow.top = new FormAttachment(0, 0);
rightArrowDraggingIndicator.setLayoutData(formDataRightArrow);
addListeners();
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class MapperManager method addRejectOutput.
public void addRejectOutput() {
String baseName = ERROR_REJECT;
IProcess process = getAbstractMapComponent().getProcess();
String tableName = baseName;
if (!process.checkValidConnectionName(baseName) && process instanceof IProcess2) {
final String uniqueName = ((IProcess2) process).generateUniqueConnectionName("row", baseName);
tableName = uniqueName;
((IProcess2) process).addUniqueConnectionName(uniqueName);
} else if (process instanceof IProcess2) {
tableName = baseName;
((IProcess2) process).addUniqueConnectionName(baseName);
}
IMetadataTable metadataTable = getNewMetadataTable();
metadataTable.setTableName(tableName);
MetadataColumn errorMessageCol = new MetadataColumn();
errorMessageCol.setLabel(ERROR_REJECT_MESSAGE);
errorMessageCol.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
errorMessageCol.setNullable(true);
errorMessageCol.setOriginalDbColumnName(ERROR_REJECT_MESSAGE);
errorMessageCol.setReadOnly(true);
errorMessageCol.setCustom(true);
errorMessageCol.setCustomId(0);
metadataTable.getListColumns().add(errorMessageCol);
MetadataColumn errorStackTrace = new MetadataColumn();
errorStackTrace.setLabel(ERROR_REJECT_STACK_TRACE);
errorStackTrace.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
errorStackTrace.setNullable(true);
errorStackTrace.setOriginalDbColumnName(ERROR_REJECT_STACK_TRACE);
errorStackTrace.setReadOnly(true);
errorStackTrace.setCustom(true);
errorStackTrace.setCustomId(1);
metadataTable.getListColumns().add(errorStackTrace);
OutputTable abstractDataMapTable = new OutputTable(this, metadataTable, tableName);
abstractDataMapTable.setErrorRejectTable(true);
abstractDataMapTable.initFromExternalData(null);
TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
DataMapTableView rejectDataMapTableView = uiManager.createNewOutputTableView(null, abstractDataMapTable, tablesZoneViewOutputs);
tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
List<DataMapTableView> outputsTablesView = uiManager.getOutputsTablesView();
int sizeList = outputsTablesView.size();
for (int i = 0; i < sizeList; i++) {
if (i + 1 < sizeList) {
FormData formData = (FormData) outputsTablesView.get(i + 1).getLayoutData();
formData.top = new FormAttachment(outputsTablesView.get(i));
}
}
CustomTableManager.addCustomManagementToTable(uiManager.getOutputMetaEditorView(), true);
tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
tablesZoneViewOutputs.layout();
uiManager.moveOutputScrollBarZoneToMax();
uiManager.refreshBackground(true, false);
uiManager.selectDataMapTableView(rejectDataMapTableView, true, false);
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class RuntimeGraphcsComposite method createControls.
@Override
protected void createControls(Composite parent) {
chartsPage = new Composite(parent, SWT.NULL);
parent.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
chartsPage.setBackground(parent.getBackground());
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = 0;
formLayout.marginHeight = 0;
chartsPage.setLayout(formLayout);
FormData pageData = new FormData();
pageData.top = new FormAttachment(0, 0);
pageData.bottom = new FormAttachment(100, 0);
pageData.left = new FormAttachment(0, 0);
pageData.right = new FormAttachment(100, 0);
chartsPage.setLayoutData(pageData);
mBeanServerChangeListener = new IMBeanServerChangeListener() {
@Override
public void serverChanged(MBeanServerEvent event) {
new RefreshJob(Messages.reconstructChartJobLabel, toString()) {
@Override
protected void refreshUI() {
IActiveJvm jvm = getJvm();
if (jvm != null) {
reconstructCharts(jvm, false);
}
}
}.schedule();
}
};
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.TIMELINE_PAGE);
}
use of org.eclipse.swt.layout.FormData in project tdi-studio-se by Talend.
the class RuntimeGraphcsComposite method createReportField.
/* private void createInfoField(Composite parent) {
infoComposite = createFlatFormComposite(parent, new FormToolkit(Display.getDefault()));
FormLayout reportLayout = new FormLayout();
reportLayout.marginWidth = 0;
reportLayout.marginHeight = 0;
infoComposite.setLayout(reportLayout);
FormData reportData = new FormData();
reportData.left = new FormAttachment(65, 5);
reportData.right = new FormAttachment(100, -5);
reportData.top = new FormAttachment(50, 0);
reportData.bottom = new FormAttachment(100, -5);
infoComposite.setLayoutData(reportData);
Group group = new Group(infoComposite, SWT.NULL);
FormLayout groupLayout = new FormLayout();
groupLayout.marginWidth = 0;
groupLayout.marginHeight = 0;
group.setLayout(groupLayout);
FormData groupData = new FormData();
groupData.left = new FormAttachment(0, 0);
groupData.right = new FormAttachment(100, 0);
groupData.top = new FormAttachment(0, 0);
groupData.bottom = new FormAttachment(100, 0);
group.setLayoutData(groupData);
group.setText("Run job Informations");
infoField = new Text(group, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
infoField.setEditable(false);
infoField.setBackground(group.getBackground());
FormData data;
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, 0);
infoField.setLayoutData(data);
}*/
private void createReportField(Composite parent) {
reportComposite = createFlatFormComposite(parent, new FormToolkit(Display.getDefault()));
FormLayout reportLayout = new FormLayout();
reportComposite.setLayout(reportLayout);
FormData reportData = new FormData();
reportData.left = new FormAttachment(65, 5);
reportData.right = new FormAttachment(100, -5);
reportData.top = new FormAttachment(0, 0);
reportData.bottom = new FormAttachment(100, -5);
reportComposite.setLayoutData(reportData);
Group group = new Group(reportComposite, SWT.NULL);
FormLayout groupLayout = new FormLayout();
group.setLayout(groupLayout);
FormData groupData = new FormData();
groupData.left = new FormAttachment(0, 0);
groupData.right = new FormAttachment(100, 0);
groupData.top = new FormAttachment(0, 0);
groupData.bottom = new FormAttachment(100, 0);
group.setLayoutData(groupData);
//$NON-NLS-1$
group.setText("Job execution information");
reportField = new StyledText(group, SWT.WRAP | SWT.V_SCROLL | SWT.READ_ONLY);
//may be CoreUIPlugin.setCSSClass can do this globally ,check later
reportField.setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
FormData data;
data = new FormData();
data.left = new FormAttachment(0, 0);
data.right = new FormAttachment(100, 0);
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(93, 0);
reportField.setLayoutData(data);
displayReportField();
//export button
Button exportButton = new Button(group, SWT.PUSH);
//$NON-NLS-1$
exportButton.setText("Export");
FormData exportData = new FormData();
exportData.left = new FormAttachment(100, -70);
exportData.right = new FormAttachment(100, 0);
exportData.bottom = new FormAttachment(100, -1);
exportButton.setLayoutData(exportData);
exportButton.setEnabled(true);
exportButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (messageManager == null || messageManager.getMessages().size() < 1) {
//$NON-NLS-1$ //$NON-NLS-2$
MessageDialog.openWarning(getShell(), "Warning", "No log to export.");
return;
}
UnboundedFifoBuffer messages = messageManager.getMessages();
Iterator iterator = messages.iterator();
StringBuilder content = new StringBuilder();
while (iterator.hasNext()) {
ReportMessage message = (ReportMessage) iterator.next();
content.append(message.getContent());
}
if (isMonitoring) {
//$NON-NLS-1$ //$NON-NLS-2$
MessageDialog.openWarning(getShell(), "Warning", "Waiting for job done.");
return;
}
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
//$NON-NLS-1$
dialog.setFilterPath(".");
String fileName = dialog.open();
if (fileName != null) {
FileWriter writer = null;
try {
writer = new FileWriter(fileName);
writer.write(content.toString());
} catch (IOException e1) {
e1.printStackTrace();
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
});
}
Aggregations