use of org.eclipse.swt.widgets.Display in project tdi-studio-se by Talend.
the class DataMapTableView method createComponents.
private void createComponents() {
final Display display = this.getDisplay();
if (WindowSystem.isGTK()) {
Color systemColor = display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
setBackground(new Color(display, systemColor.getRed(), systemColor.getGreen(), systemColor.getBlue()));
setBackgroundMode(SWT.INHERIT_NONE);
} else {
Color listBackground = display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
this.setBackground(listBackground);
}
GridLayout mainLayout = new GridLayout();
int marginMainLayout = 0;
mainLayout.marginLeft = marginMainLayout;
mainLayout.marginRight = marginMainLayout;
mainLayout.marginTop = marginMainLayout;
mainLayout.marginBottom = marginMainLayout;
mainLayout.marginWidth = marginMainLayout;
mainLayout.marginHeight = marginMainLayout;
int spacingMainLayout = 2;
mainLayout.horizontalSpacing = spacingMainLayout;
mainLayout.verticalSpacing = spacingMainLayout;
setLayout(mainLayout);
headerComposite = new Composite(this, SWT.NONE);
GridData headerGridData = new GridData(GridData.FILL_HORIZONTAL);
headerGridData.heightHint = getHeaderHeight();
headerComposite.setLayoutData(headerGridData);
GridLayout headerLayout = new GridLayout();
int margin = 0;
headerLayout.marginLeft = 3;
headerLayout.marginRight = margin;
headerLayout.marginTop = margin;
headerLayout.marginBottom = margin;
headerLayout.marginWidth = margin;
headerLayout.marginHeight = margin;
int spacing = 2;
headerLayout.horizontalSpacing = spacing;
headerLayout.verticalSpacing = spacing;
headerComposite.setLayout(headerLayout);
nameLabel = new Label(headerComposite, SWT.NONE);
nameLabel.setFont(FontProviderMapper.getFont(FontInfo.FONT_SYSTEM_BOLD));
nameLabel.setText(getTitle());
nameLabel.setToolTipText(getTitle());
nameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL));
int rightStyle = toolbarNeedToHaveRightStyle() ? SWT.RIGHT : SWT.NONE;
toolBarActions = new ToolBar(headerComposite, SWT.FLAT | rightStyle);
toolBarActions.setFont(FontProviderMapper.getFont(FontInfo.FONT_SYSTEM));
if (addToolItems()) {
addToolItemSeparator();
}
minimizeButton = new ToolItem(toolBarActions, SWT.PUSH);
realToolbarSize.x += 45;
Point sizeToolBar = toolBarActions.computeSize(SWT.DEFAULT, SWT.DEFAULT);
GridData gridDataToolbar = new GridData();
if (toolbarNeedToHaveRightStyle() && WindowSystem.isWIN32()) {
if (realToolbarSize != null) {
gridDataToolbar.widthHint = realToolbarSize.x;
}
}
if (WindowSystem.isGTK()) {
gridDataToolbar.heightHint = 26;
} else {
// gridDataToolbar.heightHint = 30; // Win32
}
if (WindowSystem.isGTK()) {
toolBarActions.setLayoutData(gridDataToolbar);
} else {
toolBarActions.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL));
}
headerLayout.numColumns = headerComposite.getChildren().length;
centerComposite = new Composite(this, SWT.NONE);
GridData centerData = new GridData(GridData.FILL_BOTH);
centerComposite.setLayoutData(centerData);
GridLayout centerLayout = new GridLayout();
int marginCenterLayout = 0;
centerLayout.marginLeft = marginCenterLayout;
centerLayout.marginRight = marginCenterLayout;
centerLayout.marginTop = marginCenterLayout;
centerLayout.marginBottom = marginCenterLayout;
centerLayout.marginWidth = marginCenterLayout;
centerLayout.marginHeight = marginCenterLayout;
int spacingCenterLayout = 2;
centerLayout.horizontalSpacing = spacingCenterLayout;
centerLayout.verticalSpacing = spacingCenterLayout;
centerComposite.setLayout(centerLayout);
initTableFilters(centerComposite);
createTableForColumns(centerComposite);
new DragNDrop(mapperManager, tableForEntries, true, true);
Composite footerComposite = new Composite(this, SWT.NONE);
GridData footerGridData = new GridData(10, 2);
footerComposite.setLayoutData(footerGridData);
headerComposite.moveAbove(nameLabel);
if (WindowSystem.isGTK()) {
sizeToolBar = toolBarActions.computeSize(SWT.DEFAULT, SWT.DEFAULT);
gridDataToolbar.widthHint = sizeToolBar.x + 20;
headerComposite.layout();
}
}
use of org.eclipse.swt.widgets.Display in project tdi-studio-se by Talend.
the class InsertionIndicator method isLeftArrowMustBeRefreshed.
/**
* DOC amaumont Comment method "isIntersect".
*
* @param boundsPopupFromMapperShellOrigin
* @return
*/
public boolean isLeftArrowMustBeRefreshed(Rectangle boundsPopupFromMapperShellOrigin) {
Shell parentShell = tablesZoneViewParent.getShell();
Display display = parentShell.getDisplay();
Point positionFromMapperShellOrigin = display.map(leftArrowDraggingIndicator, parentShell, new Point(0, 0));
Rectangle leftArrowDraggingIndicatorBounds = leftArrowDraggingIndicator.getBounds();
Rectangle boundsFromPositionOrigin = new Rectangle(positionFromMapperShellOrigin.x - 4, positionFromMapperShellOrigin.y - 4, leftArrowDraggingIndicatorBounds.width + 8, leftArrowDraggingIndicatorBounds.height + 8);
Rectangle rectangleIntersect = boundsFromPositionOrigin.intersection(boundsPopupFromMapperShellOrigin);
int nPixelsCoveredByPopup = rectangleIntersect.width * rectangleIntersect.height;
boolean response = false;
if (nPixelsCoveredByPopup < this.lastNPixelsCovered) {
response = true;
}
this.lastNPixelsCovered = nPixelsCoveredByPopup;
return response;
}
use of org.eclipse.swt.widgets.Display in project tdi-studio-se by Talend.
the class TalendPaletteViewer method filterPalette.
private void filterPalette(final Text text) {
final List<Text> disposed = new ArrayList<Text>();
final Display display = DisplayUtils.getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
TalendPaletteViewer.this.setCursor(Display.getDefault().getSystemCursor(SWT.CURSOR_APPSTARTING));
prepareFilterPalette(text, disposed);
}
});
if (!currentFilterText.equals(SEARCH_COMPONENT)) {
ComponentPaletteUtilities.filterPalette(currentFilterText.trim());
}
filters.removeAll(disposed);
display.asyncExec(new Runnable() {
@Override
public void run() {
TalendPaletteViewer.this.setCursor(null);
}
});
}
use of org.eclipse.swt.widgets.Display in project tdi-studio-se by Talend.
the class AbstractJobSettingsPage method save.
protected void save() {
List<String> checkedObjects = new ArrayList<String>();
List<IRepositoryViewObject> allProcess = null;
try {
allProcess = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS);
} catch (PersistenceException e1) {
ExceptionHandler.process(e1);
}
for (IRepositoryViewObject object : allProcess) {
if (isStatUseProjectSetting(object)) {
if (!checkedObjects.contains(object.getProperty().getId())) {
checkedObjects.add(object.getProperty().getId());
if (!checkedNodeObject.contains(object)) {
checkedNodeObject.add(object);
}
}
}
}
List<IProcess2> allOpenedProcessList = CorePlugin.getDefault().getDesignerCoreService().getOpenedProcess(getEditors());
if (allOpenedProcessList != null) {
for (int i = 0; i < allOpenedProcessList.size(); i++) {
if (checkedObjects.contains(allOpenedProcessList.get(i).getProperty().getId())) {
openedProcessList.add(allOpenedProcessList.get(i));
}
}
}
//
final IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(getTaskMessages(), (checkedNodeObject.size()) * 100);
final Map<String, Set<String>> contextVars = DetectContextVarsUtils.detectByPropertyType(elem, true);
// must init this
addContextModel = false;
if (!contextVars.isEmpty()) {
// boolean showDialog = false;
Set<String> contextSet = new HashSet<String>();
for (String key : contextVars.keySet()) {
contextSet = contextVars.get(key);
break;
}
Connection connection = null;
IElementParameter ptParam = elem.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
if (ptParam != null) {
IElementParameter propertyElem = ptParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName());
Object proValue = propertyElem.getValue();
if (proValue instanceof String && ((String) proValue).equalsIgnoreCase(EmfComponent.REPOSITORY)) {
IElementParameter repositoryElem = ptParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
String value = (String) repositoryElem.getValue();
ConnectionItem connectionItem = UpdateRepositoryUtils.getConnectionItemByItemId(value);
connection = connectionItem.getConnection();
if (connection != null && connection.isContextMode()) {
addContextModel = true;
// ContextItem contextItem =
// ContextUtils.getContextItemById(connection.getContextId());
// for (IProcess process : openedProcessList) {
// Set<String> addedContext =
// ConnectionContextHelper.checkAndAddContextVariables(contextItem,
// contextSet, process.getContextManager(), false);
// if (addedContext != null && !addedContext.isEmpty()) {
// showDialog = true;
// break;
// }
// }
}
}
}
if (addContextModel) {
// if the context is not existed in job, will add or not.
Display disp = Display.getCurrent();
if (disp == null) {
disp = Display.getDefault();
}
if (disp != null) {
disp.syncExec(new Runnable() {
@Override
public void run() {
showContextAndCheck(contextVars);
}
});
} else {
showContextAndCheck(contextVars);
}
}
}
monitor.worked(10);
IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
for (IRepositoryViewObject object : checkedNodeObject) {
saveProcess(object, addContextModel, contextVars, monitor);
}
}
};
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
workspace.run(workspaceRunnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
monitor.done();
}
};
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(true, true, runnable);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.
the class TestMovePage method main.
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell();
shell.setLayout(new FillLayout());
final Composite TabFolderComp = new Composite(shell, SWT.NONE);
GridLayout layout = new GridLayout(1, true);
layout.verticalSpacing = 1;
TabFolderComp.setLayout(layout);
for (int i = 0; i < 3; i++) {
final Composite TabPageComp = new Composite(TabFolderComp, SWT.NONE);
TabPageComp.setLayoutData(new GridData(GridData.FILL_BOTH));
final GridLayout gridLayout = new GridLayout(1, true);
gridLayout.verticalSpacing = 1;
gridLayout.marginHeight = 1;
gridLayout.marginRight = 1;
gridLayout.marginWidth = 1;
TabPageComp.setLayout(gridLayout);
Button TabItemButton = new Button(TabPageComp, SWT.FLAT);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.heightHint = 20;
TabItemButton.setLayoutData(gd);
final Composite TabItemComp = new Composite(TabPageComp, SWT.FLAT | SWT.CENTER | SWT.BORDER);
TabItemComp.setLayoutData(new GridData(GridData.FILL_BOTH));
TabItemButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
boolean b = TabItemComp.getVisible();
if (!b) {
TabPageComp.setLayoutData(new GridData(GridData.FILL_BOTH));
} else {
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.heightHint = 20;
TabPageComp.setLayoutData(gd);
}
TabItemComp.setVisible(!b);
TabFolderComp.layout();
}
});
}
shell.setSize(50, 300);
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
Aggregations