org.eclipse.swt.widgets.Shell#addPaintListener ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Shell#addPaintListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gef   文件: AbstractContainmentExample.java
/**
 *
 */
public AbstractContainmentExample(String title) {
	Display display = new Display();
	shell = new Shell(display, SWT.SHELL_TRIM | SWT.DOUBLE_BUFFERED);
	shell.setText(title);
	shell.setBounds(0, 0, 640, 480);
	shell.setBackground(
			Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

	// open the shell before creating the controllable shapes so that their
	// default coordinates are not changed due to the resize of their canvas
	shell.open();

	controllableShape1 = createControllableShape1(shell);
	controllableShape2 = createControllableShape2(shell);

	shell.addPaintListener(this);
	shell.redraw(); // triggers a PaintEvent platform independently

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
源代码2 项目: tracecompass   文件: DrawableToolTip.java
/**
 * Creates a drawable tool tip instance.
 *
 * @param parent The parent composite.
 */
public DrawableToolTip(Composite parent) {
    fToolTipShell = new Shell(parent.getShell(), SWT.ON_TOP);
    fToolTipShell.setLayout(new RowLayout());
    fToolTipShell.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
    fToolTipShell.addPaintListener(this);
    fToolTipShell.setSize(SHELL_WIDTH, SHELL_HEIGHT);
    fToolTipShell.addDisposeListener((e) -> {
        for (int i = 0; i < fColors.length; i++) {
            fColors[i].dispose();
        }
    });

    fColors = new Color[NUMBER_STEPS];
    int greenBlue = BASE_GREEN_BLUE_VALUE;
    final int step = COLOR_STEP;
    for (int i = 0; i < fColors.length; i++) {
        fColors[i] = new Color(Display.getDefault(), BASE_RED_VALUE, greenBlue, greenBlue);
        greenBlue -= step;
    }
}
 
源代码3 项目: gef   文件: AbstractIntersectionExample.java
/**
 *
 */
public AbstractIntersectionExample(String title, String... infos) {
	Display display = new Display();

	shell = new Shell(display, SWT.SHELL_TRIM | SWT.DOUBLE_BUFFERED);
	shell.setText(title);
	shell.setBounds(0, 0, 640, 480);
	shell.setLayout(new FormLayout());
	shell.setBackground(
			Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

	Label infoLabel = new Label(shell, SWT.NONE);
	FormData infoLabelFormData = new FormData();
	infoLabelFormData.right = new FormAttachment(100, -10);
	infoLabelFormData.bottom = new FormAttachment(100, -10);
	infoLabel.setLayoutData(infoLabelFormData);

	String infoText = "You can...";
	for (int i = 0; i < infos.length; i++) {
		infoText += "\n..." + infos[i];
	}
	infoLabel.setText(infoText);

	// open the shell before creating the controllable shapes so that their
	// default coordinates are not changed due to the resize of their canvas
	shell.open();

	controllableShape1 = createControllableShape1(shell);
	controllableShape2 = createControllableShape2(shell);

	shell.addPaintListener(this);
	shell.redraw(); // triggers a PaintEvent platform independently

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
源代码4 项目: gef   文件: AbstractScaleRotateExample.java
/**
 *
 */
public AbstractScaleRotateExample(String title) {
	Display display = new Display();
	shell = new Shell(display, SWT.SHELL_TRIM | SWT.DOUBLE_BUFFERED);
	shell.setText(title);
	shell.setBounds(0, 0, 640, 480);
	shell.setBackground(
			Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));

	// open the shell before creating the controllable shapes so that their
	// default coordinates are not changed due to the resize of their canvas
	shell.open();

	shape = createShape(shell);

	shell.addPaintListener(this);
	shell.addMouseListener(this);
	shell.addMouseMoveListener(this);
	shell.addMouseWheelListener(this);
	shell.addListener(SWT.Resize, this);
	shell.redraw(); // triggers a PaintEvent platform independently

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
源代码5 项目: xtext-eclipse   文件: RenameRefactoringPopup.java
public void open() {
	
	// Must cache here, since editor context is not available in menu from popup shell:
	openDialogBinding = getOpenDialogBinding();
	Shell workbenchShell = editor.getSite().getShell();
	final Display display = workbenchShell.getDisplay();
	popup = new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
	popupLayout = new GridLayout(2, false);
	popupLayout.marginWidth = 1;
	popupLayout.marginHeight = 1;
	popupLayout.marginLeft = 4;
	popupLayout.horizontalSpacing = 0;
	popup.setLayout(popupLayout);
	createContent(popup);
	updatePopupLocation();
	new PopupVisibilityManager().start();

	// Leave linked mode when popup loses focus
	// (except when focus goes back to workbench window or menu is open):
	popup.addShellListener(new ShellAdapter() {
		@Override
		public void shellDeactivated(ShellEvent e) {
			if (iSMenuUp)
				return;

			final Shell editorShell = editor.getSite().getShell();
			display.asyncExec(new Runnable() {
				// post to UI thread since editor shell only gets activated after popup has lost focus
				@Override
				public void run() {
					Shell activeShell = display.getActiveShell();
					if (activeShell != editorShell) {
						controller.cancelLinkedMode();
					}
				}
			});
		}
	});

	if (!MAC) { // carbon and cocoa draw their own border...
		popup.addPaintListener(new PaintListener() {
			@Override
			public void paintControl(PaintEvent pe) {
				pe.gc.drawPolygon(getPolygon(true));
			}
		});
	}

	UIJob delayJob = new UIJob(display, "Delayed RenameInformationPopup") {
		@Override
		public IStatus runInUIThread(IProgressMonitor monitor) {
			delayJobFinished = true;
			if (popup != null && !popup.isDisposed()) {
				updateVisibility();
			}
			return Status.OK_STATUS;
		}
	};
	delayJob.setSystem(true);
	delayJob.setPriority(Job.INTERACTIVE);
	delayJob.schedule(POPUP_VISIBILITY_DELAY);
}
 
源代码6 项目: gef   文件: AbstractExample.java
public AbstractExample(String title, String... infos) {
	Display display = new Display();

	shell = new Shell(display, SWT.SHELL_TRIM | SWT.DOUBLE_BUFFERED);
	shell.setText(title);
	shell.setBounds(0, 0, 640, 480);
	shell.setLayout(new FormLayout());

	if (infos.length > 0) {
		Label infoLabel = new Label(shell, SWT.NONE);
		FormData infoLabelFormData = new FormData();
		infoLabelFormData.right = new FormAttachment(100, -10);
		infoLabelFormData.bottom = new FormAttachment(100, -10);
		infoLabel.setLayoutData(infoLabelFormData);

		String infoText = "You can...";
		for (int i = 0; i < infos.length; i++) {
			infoText += "\n..." + infos[i];
		}
		infoLabel.setText(infoText);
	}

	// open the shell before creating the controllable shapes so that their
	// default coordinates are not changed due to the resize of their canvas
	shell.setBackground(
			Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
	shell.open();

	viewer = new ControllableShapeViewer(shell);
	for (ControllableShape cs : getControllableShapes()) {
		viewer.addShape(cs);
	}

	onInit();

	shell.addPaintListener(this);
	shell.redraw(); // triggers a PaintEvent platform independently

	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) {
			display.sleep();
		}
	}
}
 
源代码7 项目: typescript.java   文件: RenameInformationPopup.java
public void open() {
		// Must cache here, since editor context is not available in menu from popup shell:
		fOpenDialogBinding= getOpenDialogBinding();

		Shell workbenchShell= fEditor.getSite().getShell();
		final Display display= workbenchShell.getDisplay();

		fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
		fPopupLayout= new GridLayout(3, false);
		fPopupLayout.marginWidth= 1;
		fPopupLayout.marginHeight= 1;
		fPopupLayout.marginLeft= 4;
		fPopupLayout.horizontalSpacing= 0;
		fPopup.setLayout(fPopupLayout);

		createContent(fPopup);
		updatePopupLocation(true);
		new PopupVisibilityManager().start();

		// Leave linked mode when popup loses focus
		// (except when focus goes back to workbench window or menu is open):
		fPopup.addShellListener(new ShellAdapter() {
			@Override
			public void shellDeactivated(ShellEvent e) {
				if (fIsMenuUp)
					return;

				final Shell editorShell= fEditor.getSite().getShell();
				display.asyncExec(new Runnable() {
					// post to UI thread since editor shell only gets activated after popup has lost focus
					@Override
					public void run() {
						Shell activeShell= display.getActiveShell();
						if (activeShell != editorShell) {
							fRenameLinkedMode.cancel();
						}
					}
				});
			}
		});

		if (! MAC) { // carbon and cocoa draw their own border...
			fPopup.addPaintListener(new PaintListener() {
				@Override
				public void paintControl(PaintEvent pe) {
					pe.gc.drawPolygon(getPolygon(true));
				}
			});
		}

//		fPopup.moveBelow(null); // make sure hovers are on top of the info popup
// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
//		fPopup.moveBelow(workbenchShell.getShells()[0]);

		UIJob delayJob= new UIJob(display, RefactoringMessages.RenameInformationPopup_delayJobName) {
			@Override
			public IStatus runInUIThread(IProgressMonitor monitor) {
				fDelayJobFinished= true;
				if (fPopup != null && ! fPopup.isDisposed()) {
					updateVisibility();
				}
				return Status.OK_STATUS;
			}
		};
		delayJob.setSystem(true);
		delayJob.setPriority(Job.INTERACTIVE);
		delayJob.schedule(POPUP_VISIBILITY_DELAY);
	}
 
public void open() {
		// Must cache here, since editor context is not available in menu from popup shell:
		fOpenDialogBinding= getOpenDialogBinding();

		Shell workbenchShell= fEditor.getSite().getShell();
		final Display display= workbenchShell.getDisplay();

		fPopup= new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);
		fPopupLayout= new GridLayout(2, false);
		fPopupLayout.marginWidth= 1;
		fPopupLayout.marginHeight= 1;
		fPopupLayout.marginLeft= 4;
		fPopupLayout.horizontalSpacing= 0;
		fPopup.setLayout(fPopupLayout);

		createContent(fPopup);
		updatePopupLocation(true);
		new PopupVisibilityManager().start();

		// Leave linked mode when popup loses focus
		// (except when focus goes back to workbench window or menu is open):
		fPopup.addShellListener(new ShellAdapter() {
			@Override
			public void shellDeactivated(ShellEvent e) {
				if (fIsMenuUp)
					return;

				final Shell editorShell= fEditor.getSite().getShell();
				display.asyncExec(new Runnable() {
					// post to UI thread since editor shell only gets activated after popup has lost focus
					public void run() {
						Shell activeShell= display.getActiveShell();
						if (activeShell != editorShell) {
							fRenameLinkedMode.cancel();
						}
					}
				});
			}
		});

		if (! MAC) { // carbon and cocoa draw their own border...
			fPopup.addPaintListener(new PaintListener() {
				public void paintControl(PaintEvent pe) {
					pe.gc.drawPolygon(getPolygon(true));
				}
			});
		}

//		fPopup.moveBelow(null); // make sure hovers are on top of the info popup
// XXX workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=170774
//		fPopup.moveBelow(workbenchShell.getShells()[0]);

		UIJob delayJob= new UIJob(display, ReorgMessages.RenameInformationPopup_delayJobName) {
			@Override
			public IStatus runInUIThread(IProgressMonitor monitor) {
				fDelayJobFinished= true;
				if (fPopup != null && ! fPopup.isDisposed()) {
					updateVisibility();
				}
				return Status.OK_STATUS;
			}
		};
		delayJob.setSystem(true);
		delayJob.setPriority(Job.INTERACTIVE);
		delayJob.schedule(POPUP_VISIBILITY_DELAY);
	}