use of org.eclipse.swt.widgets.Control 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.widgets.Control in project tdi-studio-se by Talend.
the class ErDiagramComposite method addErDiagramEditor.
/**
* admin Comment method "addErDiagramEditor".
*/
//$NON-NLS-1$
@SuppressWarnings("unchecked")
private void addErDiagramEditor(boolean isShowDesignerPage) {
GridData gridData = new GridData(GridData.FILL_BOTH);
this.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.verticalSpacing = 0;
layout.marginLeft = 0;
layout.marginRight = 0;
layout.marginBottom = 0;
layout.marginTop = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.numColumns = 1;
this.setLayout(layout);
editor = new ErdiagramDiagramEditor();
editor.createPartControl(this);
editor.getViewer().setContents(createErDiagram(isShowDesignerPage));
Control control = editor.getGraphicalControl();
if (control != null) {
control.setParent(this);
control.setLayoutData(gridData);
}
layout = new GridLayout();
layout.marginLeft = 0;
layout.marginRight = 0;
layout.marginBottom = 0;
layout.marginTop = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.heightHint = 30;
int textstyle = SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
sqlText = new ColorStyledText(this, textstyle, CorePlugin.getDefault().getPreferenceStore(), language);
sqlText.setLayoutData(gridData);
//$NON-NLS-1$
sqlText.setText("");
sqlText.setBackground(getBackground());
sqlText.addModifyListener(new ModifyListener() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
*/
public void modifyText(ModifyEvent e) {
sqlString = sqlText.getText();
}
});
}
use of org.eclipse.swt.widgets.Control in project tesb-studio-se by Talend.
the class RouteResourceSelectionDialog method createContents.
@Override
protected Control createContents(Composite parent) {
final Control c = super.createContents(parent);
getButton(IDialogConstants.OK_ID).setEnabled(false);
// avoid NPE in ISelectionChangedListener
if (null != selectedNodeId) {
final IRepositoryNode node = getNodeById((IRepositoryNode) repositoryTreeViewer.getInput(), selectedNodeId);
if (null != node) {
repositoryTreeViewer.setSelection(new StructuredSelection(node), true);
}
}
return c;
}
use of org.eclipse.swt.widgets.Control in project tesb-studio-se by Talend.
the class RouteResourceController method addVersionCombo.
/**
*
* @param subComposite
* @param param
* @param lastControl
* @param numInRow
* @param nbInRow
* @param top
* @return
*/
private Control addVersionCombo(Composite subComposite, IElementParameter param, Control lastControl, int numInRow, int nbInRow, int top) {
DecoratedField dField = new DecoratedField(subComposite, SWT.BORDER, cbCtrl);
if (param.isRequired()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED);
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.TOP, false);
}
if (param.isRepositoryValueUsed()) {
FieldDecoration decoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
//$NON-NLS-1$
decoration.setDescription("");
dField.addFieldDecoration(decoration, SWT.RIGHT | SWT.BOTTOM, false);
}
Control cLayout = dField.getLayoutControl();
CCombo combo = (CCombo) dField.getControl();
FormData data;
combo.setItems(getListToDisplay(param));
combo.setEditable(false);
cLayout.setBackground(subComposite.getBackground());
combo.setEnabled(!param.isReadOnly());
combo.addSelectionListener(listenerSelection);
combo.setData(PARAMETER_NAME, param.getName());
if (elem instanceof Node) {
combo.setToolTipText(VARIABLE_TOOLTIP + param.getVariableName());
}
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);
}
// *********************
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.top = new FormAttachment(0, top);
cLayout.setLayoutData(data);
// **********************
hashCurControls.put(param.getName(), combo);
return cLayout;
}
use of org.eclipse.swt.widgets.Control in project tdi-studio-se by Talend.
the class MultiPageSqlBuilderEditor method createContainer.
private CTabFolder createContainer(Composite parent) {
// use SWT.FLAT style so that an extra 1 pixel border is not reserved
// inside the folder
parent.setLayout(new FillLayout());
final CTabFolder newContainer = new CTabFolder(parent, SWT.BOTTOM | SWT.FLAT);
newContainer.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int newPageIndex = newContainer.indexOf((CTabItem) e.item);
pageChange(newPageIndex);
}
});
newContainer.addTraverseListener(new TraverseListener() {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=199499 : Switching tabs by Ctrl+PageUp/PageDown must not be caught on the inner tab set
@Override
public void keyTraversed(TraverseEvent e) {
switch(e.detail) {
case SWT.TRAVERSE_PAGE_NEXT:
case SWT.TRAVERSE_PAGE_PREVIOUS:
int detail = e.detail;
e.doit = true;
e.detail = SWT.TRAVERSE_NONE;
Control control = newContainer.getParent();
do {
if (control.traverse(detail))
return;
if (control.getListeners(SWT.Traverse).length != 0)
return;
if (control instanceof Shell)
return;
control = control.getParent();
} while (control != null);
}
}
});
return newContainer;
}
Aggregations