use of org.eclipse.swt.layout.FormAttachment in project cogtool by cogtool.
the class StoppableProgressBar method addBelowBar.
@Override
protected void addBelowBar() {
super.addBelowBar();
// box, tying it to the given pausable "process" object.
if (stopListener != null) {
stopButton = new Button(shell, SWT.PUSH);
stopButton.setText(STOP_LABEL);
stopButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent evt) {
stopListener.stop();
stopButton.setEnabled(false);
}
});
FormData data = new FormData();
// Replace positioning for cancelButton if present
if (cancelButton != null) {
data.left = new FormAttachment(50, 3);
data.top = new FormAttachment(bar, 5, SWT.BOTTOM);
cancelButton.setLayoutData(data);
data = new FormData();
data.right = new FormAttachment(50, -3);
data.top = new FormAttachment(bar, 5, SWT.BOTTOM);
} else {
data.left = new FormAttachment(bar, 0, SWT.CENTER);
data.top = new FormAttachment(bar, 5, SWT.BOTTOM);
}
stopButton.setLayoutData(data);
}
}
use of org.eclipse.swt.layout.FormAttachment in project tdi-studio-se by Talend.
the class TextController method createControl.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties2.editors.AbstractElementPropertySectionController#createControl()
*/
@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;
this.paramFieldType = param.getFieldType();
FormData data;
final 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);
}
if (canAddRepositoryDecoration(param)) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
//$NON-NLS-1$
decoration.setDescription(Messages.getString("TextController.decoration.description"));
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
}
Control cLayout = dField.getLayoutControl();
Text labelText = (Text) dField.getControl();
labelText.setData(PARAMETER_NAME, param.getName());
editionControlHelper.register(param.getName(), labelText);
cLayout.setBackground(subComposite.getBackground());
if (elem instanceof Node) {
labelText.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
if (!isReadOnly()) {
if (param.isRepositoryValueUsed() && !(elem instanceof org.talend.designer.core.ui.editor.process.Process || elem instanceof StatsAndLogsElement || elem instanceof ImplicitContextLoadElement)) {
addRepositoryPropertyListener(labelText);
}
if (param.isRequired()) {
labelText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
checkTextError(param, labelText, labelText.getText());
}
});
}
boolean editable = !param.isReadOnly() && (elem instanceof FakeElement || !param.isRepositoryValueUsed());
labelText.setEditable(editable);
} else {
labelText.setEditable(false);
}
addDragAndDropTarget(labelText);
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);
// *********************
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 * 2)) > currentLabelWidth) {
currentLabelWidth = labelSize.x + (ITabbedPropertyConstants.HSPACE * 2);
}
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((numInRow * MAX_PERCENT) / nbInRow, 0);
data.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
// **********************
hashCurControls.put(param.getName(), labelText);
Point initialSize = cLayout.computeSize(SWT.DEFAULT, SWT.DEFAULT);
// curRowSize = initialSize.y + ITabbedPropertyConstants.VSPACE;
dynamicProperty.setCurRowSize(initialSize.y + ITabbedPropertyConstants.VSPACE);
if (isInWizard()) {
labelLabel.setAlignment(SWT.RIGHT);
if (lastControl != null) {
data.right = new FormAttachment(lastControl, 0);
} else {
data.right = new FormAttachment(100, -ITabbedPropertyConstants.HSPACE);
}
data.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), currentLabelWidth + ITabbedPropertyConstants.HSPACE);
data = (FormData) labelLabel.getLayoutData();
data.right = new FormAttachment(cLayout, 0);
data.left = new FormAttachment((((nbInRow - numInRow) * MAX_PERCENT) / nbInRow), 0);
return labelLabel;
}
return cLayout;
}
use of org.eclipse.swt.layout.FormAttachment in project tdi-studio-se by Talend.
the class TreeTableController method createControl.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.core.ui.editor.properties.controllers.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 parentComposite, final IElementParameter param, final int numInRow, final int nbInRow, int top, final Control lastControlPrm) {
this.curParameter = param;
this.paramFieldType = param.getFieldType();
final Composite container = parentComposite;
final TreeViewer viewer = new TreeViewer(container, SWT.FULL_SELECTION | SWT.BORDER);
viewer.getTree().setHeaderVisible(true);
// key column
TreeColumn column = new TreeColumn(viewer.getTree(), SWT.LEFT);
column.setText("Key");
column.setWidth(150);
// columns for values
if (param.getValue() != null) {
List<Map<String, Object>> values = (List<Map<String, Object>>) param.getValue();
for (int i = 0; i < values.size(); i++) {
column = new TreeColumn(viewer.getTree(), SWT.LEFT);
column.setText("Value" + i);
column.setWidth(100);
}
}
viewer.setContentProvider(new MyTreeContentProvider(param));
viewer.setLabelProvider(new MyTableLableProvider(param));
viewer.setInput(param);
CLabel labelLabel2 = getWidgetFactory().createCLabel(container, param.getDisplayName());
FormData formData = new FormData();
if (lastControlPrm != null) {
formData.left = new FormAttachment(lastControlPrm, 0);
} else {
formData.left = new FormAttachment((((numInRow - 1) * MAX_PERCENT) / nbInRow), 0);
}
formData.top = new FormAttachment(0, top);
labelLabel2.setLayoutData(formData);
if (numInRow != 1) {
labelLabel2.setAlignment(SWT.RIGHT);
}
// *********************
formData = new FormData();
int currentLabelWidth2 = STANDARD_LABEL_WIDTH;
GC gc2 = new GC(labelLabel2);
Point labelSize2 = gc2.stringExtent(param.getDisplayName());
gc2.dispose();
boolean needOffset = true;
if ((labelSize2.x + ITabbedPropertyConstants.HSPACE) > currentLabelWidth2) {
currentLabelWidth2 = labelSize2.x + ITabbedPropertyConstants.HSPACE;
needOffset = false;
}
int tableHorizontalOffset = -5;
if (numInRow == 1) {
if (lastControlPrm != null) {
if (needOffset) {
formData.left = new FormAttachment(lastControlPrm, currentLabelWidth2 + tableHorizontalOffset);
} else {
formData.left = new FormAttachment(lastControlPrm, currentLabelWidth2);
}
} else {
if (needOffset) {
formData.left = new FormAttachment(0, currentLabelWidth2 + tableHorizontalOffset);
} else {
formData.left = new FormAttachment(0, currentLabelWidth2);
}
}
} else {
formData.left = new FormAttachment(labelLabel2, 0 + tableHorizontalOffset, SWT.RIGHT);
}
formData.right = new FormAttachment((numInRow * MAX_PERCENT) / nbInRow, 0);
formData.top = new FormAttachment(0, top);
int toolbarSize = 0;
if (!param.isBasedOnSchema()) {
Point size = viewer.getTree().computeSize(SWT.DEFAULT, SWT.DEFAULT);
toolbarSize = size.y - 95;
}
int currentHeightEditor = viewer.getTree().getHeaderHeight() + param.getListItemsValue().length * viewer.getTree().getItemHeight() + viewer.getTree().getItemHeight() + toolbarSize;
int minHeightEditor = viewer.getTree().getHeaderHeight() + getNumberLines(param) * viewer.getTree().getItemHeight() + viewer.getTree().getItemHeight() + toolbarSize;
int ySize2 = Math.max(currentHeightEditor, minHeightEditor);
formData.bottom = new FormAttachment(0, top + ySize2);
viewer.getTree().setLayoutData(formData);
this.dynamicProperty.setCurRowSize(ySize2 + ITabbedPropertyConstants.VSPACE);
top += this.dynamicProperty.getCurRowSize();
return null;
}
use of org.eclipse.swt.layout.FormAttachment in project tdi-studio-se by Talend.
the class ProcessView method createPartControl.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createPartControl(Composite parent) {
this.parent = parent;
parent.setLayout(new FillLayout());
sash = new SashForm(parent, SWT.HORIZONTAL | SWT.SMOOTH);
sash.setLayoutData(new GridData(GridData.FILL_BOTH));
sash.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
GridLayout layout = new GridLayout();
sash.setLayout(layout);
Composite left = new Composite(sash, SWT.NONE);
left.setLayout(new FillLayout());
Composite right = new Composite(sash, SWT.NONE);
right.setLayout(new FormLayout());
FormData layouDatag = new FormData();
layouDatag.left = new FormAttachment(0, 0);
layouDatag.width = 32;
layouDatag.top = new FormAttachment(0, 0);
layouDatag.bottom = new FormAttachment(100, 0);
final Composite buttonComposite = new Composite(right, SWT.ERROR);
buttonComposite.setLayoutData(layouDatag);
buttonComposite.setLayout(new GridLayout());
Composite cotextCom = new Composite(right, SWT.NONE);
layouDatag = new FormData();
layouDatag.left = new FormAttachment(0, 32);
layouDatag.right = new FormAttachment(100, 0);
layouDatag.top = new FormAttachment(0, 0);
layouDatag.bottom = new FormAttachment(100, 0);
cotextCom.setLayoutData(layouDatag);
cotextCom.setLayout(new GridLayout());
tabFactory.initComposite(left, false);
moveButton = new Button(buttonComposite, SWT.PUSH);
//$NON-NLS-1$
moveButton.setText(">>");
moveButton.setToolTipText(Messages.getString("ProcessComposite.hideContext"));
final GridData layoutData = new GridData();
layoutData.verticalAlignment = GridData.CENTER;
layoutData.horizontalAlignment = GridData.CENTER;
layoutData.grabExcessHorizontalSpace = true;
layoutData.grabExcessVerticalSpace = true;
moveButton.setLayoutData(layoutData);
addListeners();
sash.setSashWidth(5);
sash.setWeights(new int[] { 18, 5 });
contextComposite = new ProcessContextComposite(cotextCom, SWT.NONE);
contextComposite.setBackground(right.getDisplay().getSystemColor(SWT.COLOR_WHITE));
// processComposite = new ProcessComposite(tabFactory.getTabComposite(), SWT.H_SCROLL | SWT.V_SCROLL |
// SWT.NO_FOCUS);
// dc = processComposite;
// createBasicComposite(tabFactory.getTabComposite(), element, null);
tabFactory.getTabComposite().layout();
tabFactory.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
TalendPropertyTabDescriptor descriptor = (TalendPropertyTabDescriptor) selection.getFirstElement();
if (descriptor == null) {
return;
}
if (currentSelectedTab != null && (currentSelectedTab.getCategory() != descriptor.getCategory())) {
for (Control curControl : tabFactory.getTabComposite().getChildren()) {
curControl.dispose();
}
}
if (currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) {
currentSelectedTab = descriptor;
selectedPrimary = false;
createDynamicComposite(tabFactory.getTabComposite(), (Element) descriptor.getData(), descriptor.getCategory());
}
}
});
setElement();
IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
IHandler handler1;
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (brandingService.getBrandingConfiguration().isAllowDebugMode()) {
Action debugAction = new DebugAction();
handler1 = new ActionHandler(debugAction);
handlerService.activateHandler(debugAction.getActionDefinitionId(), handler1);
}
Action killAction = new KillAction();
handler1 = new ActionHandler(killAction);
handlerService.activateHandler(killAction.getActionDefinitionId(), handler1);
FocusListener fl = new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
//$NON-NLS-1$
log.trace(Messages.getString("ProcessView.gainFocusLog"));
IContextService contextService = (IContextService) RunProcessPlugin.getDefault().getWorkbench().getAdapter(IContextService.class);
//$NON-NLS-1$
ca = contextService.activateContext("talend.runProcess");
}
@Override
public void focusLost(FocusEvent e) {
//$NON-NLS-1$
log.trace(Messages.getString("ProcessView.lostFocusLog"));
if (ca != null) {
IContextService contextService = (IContextService) RunProcessPlugin.getDefault().getWorkbench().getAdapter(IContextService.class);
contextService.deactivateContext(ca);
}
}
};
addListenerOnChildren(parent, fl);
rubjobManager.setProcessShell(getSite().getShell());
contextManagerListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (RunProcessContextManager.PROP_ACTIVE.equals(evt.getPropertyName())) {
// rubjobManager.setBooleanTrace(false);
runningProcessChanged();
}
}
};
RunProcessPlugin.getDefault().getRunProcessContextManager().addPropertyChangeListener(contextManagerListener);
runAction = new RunAction();
}
use of org.eclipse.swt.layout.FormAttachment in project tdi-studio-se by Talend.
the class MemoryRuntimeComposite method initRuntimeGraphs.
private void initRuntimeGraphs(final Composite parent) {
ISelection processContextSelection = viewPart.getSite().getSelectionProvider() == null ? null : viewPart.getSelection();
setExpandHorizontal(true);
setExpandVertical(true);
FormData layouData = new FormData();
layouData.left = new FormAttachment(0, 0);
layouData.right = new FormAttachment(100, 0);
layouData.top = new FormAttachment(0, 0);
layouData.bottom = new FormAttachment(100, 0);
this.setBackground(parent.getBackground());
this.setLayout(new FormLayout());
setLayoutData(layouData);
monitorComposite = new Composite(this, SWT.NULL);
FormData baseData = new FormData();
baseData.left = new FormAttachment(0, 0);
baseData.right = new FormAttachment(100, 0);
baseData.top = new FormAttachment(0, 0);
baseData.bottom = new FormAttachment(100, 0);
monitorComposite.setLayout(new FormLayout());
monitorComposite.setLayoutData(layouData);
setContent(monitorComposite);
Group topGroup = createTopGroup(monitorComposite);
runtimeButton = new Button(topGroup, SWT.PUSH);
if (processContext != null) {
setRuntimeButtonByStatus(!processContext.isMonitoring());
} else {
setRuntimeButtonByStatus(true);
}
runtimeButton.setEnabled(true);
GridData runButtonData = new GridData();
Point execSize = null;
execSize = computeSize(runtimeButton.getText());
runButtonData.widthHint = execSize.x + 70;
runtimeButton.setLayoutData(runButtonData);
gcCheckButton = new Button(topGroup, SWT.CHECK);
GridData gcCheckButtonData = new GridData();
gcCheckButtonData.grabExcessHorizontalSpace = false;
gcCheckButton.setLayoutData(gcCheckButtonData);
gcCheckButton.setEnabled(true);
gcCheckButton.setSelection(isGCSelected);
Label periodLabel = new Label(topGroup, SWT.NULL);
//$NON-NLS-1$
periodLabel.setText(Messages.getString("ProcessView.moniorPeriod"));
periodLabel.setBackground(getBackground());
GridData periodLabelData = new GridData();
execSize = computeSize(periodLabel.getText());
periodLabelData.widthHint = execSize.x;
periodLabelData.grabExcessHorizontalSpace = false;
periodLabelData.horizontalAlignment = GridData.BEGINNING;
periodLabel.setLayoutData(periodLabelData);
periodCombo = new Combo(topGroup, SWT.READ_ONLY);
GridData periodData = new GridData();
execSize = computeSize("Select");
periodData.widthHint = execSize.x;
periodData.grabExcessHorizontalSpace = false;
periodData.horizontalAlignment = GridData.BEGINNING;
periodData.minimumWidth = execSize.x;
periodCombo.setLayoutData(periodData);
periodCombo.setItems(new String[] { "Select", "30 sec", "60 sec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"120 sec" });
periodCombo.setEnabled(isGCSelected);
if (isGCSelected) {
periodCombo.select(periodComboSelectionIndex);
} else {
periodCombo.select(0);
periodComboSelectionIndex = 0;
}
contextCombo = new ComboViewer(topGroup, SWT.BORDER | SWT.READ_ONLY);
contextCombo.getCombo().setLayout(new FormLayout());
GridData contextComboData = new GridData();
contextComboData.grabExcessHorizontalSpace = true;
contextComboData.horizontalAlignment = GridData.END;
//$NON-NLS-N$
execSize = computeSize("Default");
contextComboData.minimumWidth = execSize.x;
contextCombo.getCombo().setLayoutData(contextComboData);
contextCombo.setContentProvider(ArrayContentProvider.getInstance());
contextCombo.setLabelProvider(new ContextNameLabelProvider());
initContextInput();
chartComposite = new RuntimeGraphcsComposite(monitorComposite, processContextSelection, SWT.NULL);
FormLayout rgcLayout = new FormLayout();
FormData charLayData = new FormData();
charLayData.left = new FormAttachment(0, 10);
charLayData.right = new FormAttachment(100, 0);
charLayData.top = new FormAttachment(topGroup, 60, SWT.BOTTOM);
charLayData.bottom = new FormAttachment(100, 0);
chartComposite.setLayout(rgcLayout);
chartComposite.setLayoutData(charLayData);
}
Aggregations