Java Code Examples for org.eclipse.swt.SWT#Move

The following examples show how to use org.eclipse.swt.SWT#Move . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: nebula   File: MultiChoice.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void addListeners() {

		final int[] multiChoiceEvent = { SWT.Dispose, SWT.Move, SWT.Resize };
		for (final int element : multiChoiceEvent) {
			addListener(element, this.listener);
		}

		if ((getStyle() & SWT.READ_ONLY) == 0) {
			final Listener validationListener = new Listener() {

				@Override
				public void handleEvent(final Event event) {
					if (!MultiChoice.this.popup.isDisposed() && !MultiChoice.this.popup.isVisible()) {
						validateEntry();
					}
				}
			};
			this.text.addListener(SWT.FocusOut, validationListener);
		}

		final int[] buttonEvents = { SWT.Selection, SWT.FocusIn };
		for (final int buttonEvent : buttonEvents) {
			this.arrow.addListener(buttonEvent, this.listener);
		}
	}
 
Example 2
private void comboEvent(Event event){
	switch (event.type) {
	case SWT.Dispose:
		
		if ((popup != null) && !popup.isDisposed()) {
			popup.dispose();
		}
		
		popup = null;
		text = null;
		dp = null;
		arrow = null;
		
		break;
	
	case SWT.Move:
		dropDown(false);
		
		break;
	
	case SWT.Resize:
		internalLayout();
		
		break;
	}
}
 
Example 3
Source Project: nebula   File: CalculatorCombo.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void handleMultiChoiceEvent(final Event event) {
	switch (event.type) {
		case SWT.Dispose:
			if (popup != null && !popup.isDisposed()) {
				popup.dispose();
			}
			final Shell shell = getShell();
			shell.removeListener(SWT.Deactivate, listener);
			final Display display = getDisplay();
			display.removeFilter(SWT.FocusIn, filter);
			popup = null;
			arrow = null;
			break;
		case SWT.Move:
			hidePopupWindow(false);
			break;
		case SWT.Resize:
			if (isPopupVisible()) {
				hidePopupWindow(false);
			}
			break;
	}
}
 
Example 4
Source Project: birt   File: CCombo.java    License: Eclipse Public License 1.0 6 votes vote down vote up
void comboEvent (Event event) {
	switch (event.type) {
		case SWT.Dispose:
			if (popup != null && !popup.isDisposed ()) {
				list.removeListener(SWT.Dispose, listener);
				popup.dispose ();
			}
			popup = null;  
			text = null;  
			list = null;  
			arrow = null;
			break;
		case SWT.Move:
			dropDown(false);
			break;
		case SWT.Resize:
			internalLayout();
			break;
	}
}
 
Example 5
Source Project: birt   File: StyleCombo.java    License: Eclipse Public License 1.0 6 votes vote down vote up
void comboEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.Dispose :
			if ( popup != null && !popup.isDisposed( ) )
			{
				table.removeListener( SWT.Dispose, listener );
				popup.dispose( );
			}
			disposeImages( );
			popup = null;
			label = null;
			table = null;
			arrow = null;
			break;
		case SWT.Move :
			dropDown( false );
			break;
		case SWT.Resize :
			internalLayout( false );
			break;
	}
}
 
Example 6
Source Project: nebula   File: CustomCombo.java    License: Eclipse Public License 2.0 5 votes vote down vote up
void comboEvent(Event event) {
	switch (event.type) {
	case SWT.Dispose:
		if (popup != null && !popup.isDisposed()) {
			list.removeListener(SWT.Dispose, listener);
			popup.dispose();
		}
		Shell shell = getShell();
		shell.removeListener(SWT.Deactivate, listener);
		Display display = getDisplay();
		display.removeFilter(SWT.FocusIn, filter);
		popup = null;
		text = null;
		list = null;
		arrow = null;
		break;
	case SWT.FocusIn:
		Control focusControl = getDisplay().getFocusControl();
		if (focusControl == arrow || focusControl == list)
			return;
		if (isDropped()) {
			list.setFocus();
		} else {
			text.setFocus();
		}
		break;
	case SWT.Move:
		dropDown(false);
		break;
	case SWT.Resize:
		internalLayout(false);
		break;
	}
}
 
Example 7
Source Project: nebula   File: AbstractCombo.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Manages global combo events.
 * 
 * @param event event
 */
protected void comboEvent(Event event) {
	switch (event.type) {
		case SWT.Dispose: {
			removeListener(SWT.Dispose, listener);
			notifyListeners(SWT.Dispose, event);
			event.type = SWT.None;

			if (popup != null && !popup.isDisposed()) {
				popupContent.removeListener(SWT.Dispose, listener);
				popup.dispose();
			}
			getShell().removeListener(SWT.Deactivate, listener);
			getDisplay().removeFilter(SWT.FocusIn, filter);
			popup = null;
			text = null;
			popupContent = null;
			button = null;
			_shell = null;
			break;
		}
		case SWT.FocusIn: {
			Control focusControl = getDisplay().getFocusControl();
			if (focusControl == button || focusControl == popupContent)
				return;
			if (isDropped()) {
				popupContent.setFocus();
			} else {
				text.setFocus();
			}
			break;
		}
		case SWT.Move:
			dropDown(false);
			break;
	}
}
 
Example 8
Source Project: nebula   File: CTreeLayout.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void computeSize(int eventType, CTreeItem item) {
	if(SWT.Move != eventType) {
		computeContentHeight(eventType, item);
		size.x = headerSize.x;
		size.y = headerSize.y + contentHeight;
	}
}
 
Example 9
Source Project: nebula   File: CTreeCombo.java    License: Eclipse Public License 2.0 5 votes vote down vote up
void comboEvent(Event event) {
	switch (event.type) {
		case SWT.Dispose:
			if (popup != null && !popup.isDisposed()) {
				tree.removeListener(SWT.Dispose, listener);
				popup.dispose();
			}
			final Shell shell = getShell();
			shell.removeListener(SWT.Deactivate, listener);
			final Display display = getDisplay();
			display.removeFilter(SWT.FocusIn, filter);
			popup = null;
			text = null;
			tree = null;
			arrow = null;
			break;
		case SWT.FocusIn:
			final Control focusControl = getDisplay().getFocusControl();
			if (focusControl == arrow || focusControl == tree) {
				return;
			}
			if (isDropped()) {
				tree.setFocus();
			} else {
				text.setFocus();
			}
			break;
		case SWT.Move:
			dropDown(false);
			break;
		case SWT.Resize:
			internalLayout(false);
			break;
	}
}
 
Example 10
Source Project: nebula   File: BaseCombo.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void handleEvent(Event event) {
	switch (event.type) {
	case SWT.Move:
		if (isOpen()) {
			setOpen(false);
		}
		break;
	case SWT.Resize:
		if (isOpen()) {
			setOpen(false);
		}
		layout(true);
		break;
	}
}
 
Example 11
/**
 * Handle Combo events
 * @param event
 */
private void comboEvent(Event event) {
	switch (event.type) {
	case SWT.Dispose:
		removeListener(SWT.Dispose, listener);
		notifyListeners(SWT.Dispose, event);
		event.type = SWT.None;

		if (popup != null && !popup.isDisposed()) {
			table.removeListener(SWT.Dispose, listener);
			popup.dispose();
		}
		Shell shell = getShell();
		shell.removeListener(SWT.Deactivate, listener);
		Display display = getDisplay();
		display.removeFilter(SWT.FocusIn, focusFilter);
		popup = null;
		text = null;
		table = null;
		arrow = null;
		selectedImage = null;
		break;
	case SWT.FocusIn:
		Control focusControl = getDisplay().getFocusControl();
		if (focusControl == arrow || focusControl == table)
			return;
		if (isDropped()) {
			table.setFocus();
		} else {
			text.setFocus();
		}
		break;
	case SWT.Move:
		dropDown(false);
		break;
	case SWT.Resize:
		internalLayout(false);
		break;
	}
}
 
Example 12
/**
 * Handle Combo events
 * @param event
 */
private void comboEvent(Event event) {
	switch (event.type) {
	case SWT.Dispose:
		removeListener(SWT.Dispose, listener);
		notifyListeners(SWT.Dispose, event);
		event.type = SWT.None;

		if (popup != null && !popup.isDisposed()) {
			table.removeListener(SWT.Dispose, listener);
			popup.dispose();
		}
		Shell shell = getShell();
		shell.removeListener(SWT.Deactivate, listener);
		Display display = getDisplay();
		display.removeFilter(SWT.FocusIn, focusFilter);
		popup = null;
		text = null;
		table = null;
		arrow = null;
		selectedImage = null;
		break;
	case SWT.FocusIn:
		Control focusControl = getDisplay().getFocusControl();
		if (focusControl == arrow || focusControl == table)
			return;
		if (isDropped()) {
			table.setFocus();
		} else {
			text.setFocus();
		}
		break;
	case SWT.Move:
		dropDown(false);
		break;
	case SWT.Resize:
		internalLayout(false);
		break;
	}
}
 
Example 13
Source Project: Pydev   File: TableCombo.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Handle Combo events
 * @param event
 */
private void comboEvent(Event event) {
    switch (event.type) {
        case SWT.Dispose:
            removeListener(SWT.Dispose, listener);
            notifyListeners(SWT.Dispose, event);
            event.type = SWT.None;

            if (popup != null && !popup.isDisposed()) {
                table.removeListener(SWT.Dispose, listener);
                popup.dispose();
            }
            Shell shell = getShell();
            shell.removeListener(SWT.Deactivate, listener);
            Display display = getDisplay();
            display.removeFilter(SWT.FocusIn, focusFilter);
            popup = null;
            text = null;
            table = null;
            arrow = null;
            selectedImage = null;
            break;
        case SWT.FocusIn:
            Control focusControl = getDisplay().getFocusControl();
            if (focusControl == arrow || focusControl == table)
                return;
            if (isDropped()) {
                table.setFocus();
            } else {
                text.setFocus();
            }
            break;
        case SWT.Move:
            dropDown(false);
            break;
        case SWT.Resize:
            internalLayout(false);
            break;
    }
}
 
Example 14
Source Project: nebula   File: CTreeColumn.java    License: Eclipse Public License 2.0 4 votes vote down vote up
public CTreeColumn(CTree parent, int style) {
		super(parent, style);
		ctree = parent;
		ctree.addColumn(this, style);
		if(ctree.getNativeHeader()) {
			nativeColumn = new TableColumn(ctree.getInternalTable(), style);
			isNative = true;
			autoWidth = false;
		} else {
			isNative = false;
			autoWidth = true;
		}
		ctree.setSortColumn(this);
		ctree.setSortDirection(SWT.DOWN);
		Listener listener = new Listener() {
			public void handleEvent(Event e) {
				switch(e.type) {
				case SWT.Move:
					if(ctree.getNativeHeader()) {
						ctree.columnOrder = nativeColumn.getParent().getColumnOrder();
					}
					ctree.body.redraw();
				case SWT.Resize:
					ctree.layout(e.type, CTreeColumn.this);
					break;
//				case SWT.Selection:
//					if(ctree.internalGetSortColumn() == CTreeColumn.this) {
//						if(SWT.UP == ctree.getSortDirection()) {
//							ctree.setSortDirection(SWT.DOWN);
//						} else {
//							ctree.setSortDirection(SWT.UP);
//						}
//					} else {
//						ctree.setSortColumn(CTreeColumn.this);
//						ctree.setSortDirection(SWT.DOWN);
//					}
				}
			}
		};
		addListener(SWT.Move, listener);
		addListener(SWT.Resize, listener);
//		addListener(SWT.Selection, listener);
		
		addListener(SWT.Dispose, new Listener() {
			public void handleEvent(Event event) {
				doDispose();
			}
		});
	}
 
Example 15
Source Project: nebula   File: TableCombo.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Handle Combo events
 *
 * @param event
 */
private void comboEvent(final Event event) {
	switch (event.type) {
	case SWT.Dispose:
		removeListener(SWT.Dispose, listener);
		notifyListeners(SWT.Dispose, event);
		event.type = SWT.None;

		if (popup != null && !popup.isDisposed()) {
			if (!table.isDisposed()) {
				table.removeListener(SWT.Dispose, listener);
			}
			popup.dispose();
		}
		final Shell shell = getShell();
		if (!shell.isDisposed()) {
			shell.removeListener(SWT.Deactivate, listener);
		}
		final Display display = getDisplay();
		display.removeFilter(SWT.FocusIn, focusFilter);
		popup = null;
		text = null;
		table = null;
		arrow = null;
		selectedImage = null;
		break;
	case SWT.FocusIn:
		final Control focusControl = getDisplay().getFocusControl();
		if (focusControl == arrow || focusControl == table) {
			return;
		}
		if (!isDropped()) {
			text.setFocus();
		}
		break;
	case SWT.Move:
		dropDown(false);
		break;
	case SWT.Resize:
		internalLayout(false, true);
		break;
	}
}
 
Example 16
Source Project: nebula   File: CTreeCombo.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * The CTreeCombo class represents a selectable user interface object
 * that combines a text field and a tree and issues notification
 * when an item is selected from the tree.
 * <p>
 * Note that although this class is a subclass of <code>Composite</code>,
 * it does not make sense to add children to it, or set a layout on it.
 * </p>
 * <dl>
 * <dt><b>Styles:</b>
 * <dd>BORDER, READ_ONLY, FLAT</dd>
 * <dt><b>Events:</b>
 * <dd>DefaultSelection, Modify, Selection, Verify</dd>
 * </dl>
 */
public CTreeCombo(Composite parent, int style) {
	super(parent, style = checkStyle(style));

	int textStyle = SWT.SINGLE;
	if ((style & SWT.READ_ONLY) != 0) {
		textStyle |= SWT.READ_ONLY;
	}
	if ((style & SWT.FLAT) != 0) {
		textStyle |= SWT.FLAT;
	}
	text = new Text(this, textStyle);
	int arrowStyle = SWT.ARROW | SWT.DOWN;
	if ((style & SWT.FLAT) != 0) {
		arrowStyle |= SWT.FLAT;
	}
	arrow = new Button(this, arrowStyle);

	listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			if (popup == event.widget) {
				popupEvent(event);
				return;
			}
			if (text == event.widget) {
				textEvent(event);
				return;
			}
			if (tree == event.widget) {
				treeEvent(event);
				return;
			}
			if (arrow == event.widget) {
				arrowEvent(event);
				return;
			}
			if (CTreeCombo.this == event.widget) {
				comboEvent(event);
				return;
			}
			if (getShell() == event.widget) {
				getDisplay().asyncExec(new Runnable() {
					@Override
					public void run() {
						if (isDisposed()) {
							return;
						}
						handleFocus(SWT.FocusOut);
					}
				});
			}
		}
	};
	filter = (event) -> {
		final Shell shell = ((Control) event.widget).getShell();
		if (shell == CTreeCombo.this.getShell()) {
			handleFocus(SWT.FocusOut);
		}
	};

	final int[] comboEvents = { SWT.Dispose, SWT.FocusIn, SWT.Move, SWT.Resize };
	for (int i = 0; i < comboEvents.length; i++) {
		addListener(comboEvents[i], listener);
	}

	final int[] textEvents = { SWT.DefaultSelection, SWT.KeyDown, SWT.KeyUp, SWT.MenuDetect, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.MouseDoubleClick, SWT.MouseWheel, SWT.Traverse, SWT.FocusIn, SWT.Verify };
	for (int i = 0; i < textEvents.length; i++) {
		text.addListener(textEvents[i], listener);
	}

	final int[] arrowEvents = { SWT.MouseDown, SWT.MouseUp, SWT.Selection, SWT.FocusIn };
	for (int i = 0; i < arrowEvents.length; i++) {
		arrow.addListener(arrowEvents[i], listener);
	}

	createPopup(null, null);
	initAccessible();
}
 
Example 17
Source Project: nebula   File: TextAssist.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Constructs a new instance of this class given its parent and a style
 * value describing its behavior and appearance.
 * <p>
 * The style value is either one of the style constants defined in class
 * <code>SWT</code> which is applicable to instances of this class, or must
 * be built by <em>bitwise OR</em>'ing together (that is, using the
 * <code>int</code> "|" operator) two or more of those <code>SWT</code>
 * style constants. The class description lists the style constants that are
 * applicable to the class. Style bits are also inherited from superclasses.
 * </p>
 *
 * @param parent a composite control which will be the parent of the new
 *            instance (cannot be null)
 * @param style the style of control to construct
 * @param contentProvider the content provider
 *
 * @exception IllegalArgumentException
 *                <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 *                </ul>
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the parent</li>
 *                <li>ERROR_INVALID_SUBCLASS - if this class is not an
 *                allowed subclass</li>
 *                </ul>
 *
 * @see SWT#SINGLE
 * @see SWT#MULTI
 * @see SWT#READ_ONLY
 * @see SWT#WRAP
 * @see SWT#LEFT
 * @see SWT#RIGHT
 * @see SWT#CENTER
 * @see SWT#PASSWORD
 * @see SWT#SEARCH
 * @see SWT#ICON_SEARCH
 * @see SWT#ICON_CANCEL
 * @see Widget#checkSubclass
 * @see Widget#getStyle
 */
public TextAssist(final Composite parent, final int style, final TextAssistContentProvider contentProvider) {
	super(parent, SWT.NONE);
	this.contentProvider = contentProvider;
	this.contentProvider.setTextAssist(this);

	setLayout(new FillLayout());
	numberOfLines = 10;
	text = new Text(this, style);
	popup = new Shell(getDisplay(), SWT.ON_TOP);
	popup.setLayout(new FillLayout());
	table = new Table(popup, SWT.SINGLE);

	addTextListener();
	addTableListener();

	final int[] events = new int[] { SWT.Move, SWT.FocusOut };
	for (final int event : events) {
		getShell().addListener(event, e -> {
			popup.setVisible(false);
		});
	}

}
 
Example 18
Source Project: birt   File: DataItemCombo.java    License: Eclipse Public License 1.0 4 votes vote down vote up
void comboEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.Dispose :
			removeListener( SWT.Dispose, listener );
			notifyListeners( SWT.Dispose, event );
			event.type = SWT.None;

			if ( popup != null && !popup.isDisposed( ) )
			{
				list.removeListener( SWT.Dispose, listener );
				popup.dispose( );
			}
			Shell shell = getShell( );
			shell.removeListener( SWT.Deactivate, listener );
			Display display = getDisplay( );
			display.removeFilter( SWT.FocusIn, filter );
			popup = null;
			text = null;
			list = null;
			arrow = null;
			_shell = null;
			break;
		case SWT.FocusIn :
			Control focusControl = getDisplay( ).getFocusControl( );
			if ( focusControl == arrow || focusControl == list )
				return;
			if ( isDropped( ) )
			{
				list.setFocus( );
			}
			else
			{
				text.setFocus( );
			}
			break;
		case SWT.Move :
			dropDown( false );
			break;
		case SWT.Resize :
			internalLayout( false );
			break;
	}
}
 
Example 19
Source Project: birt   File: CCombo.java    License: Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Constructs a new instance of this class given its parent
 * and a style value describing its behavior and appearance.
 * <p>
 * The style value is either one of the style constants defined in
 * class <code>SWT</code> which is applicable to instances of this
 * class, or must be built by <em>bitwise OR</em>'ing together 
 * (that is, using the <code>int</code> "|" operator) two or more
 * of those <code>SWT</code> style constants. The class description
 * lists the style constants that are applicable to the class.
 * Style bits are also inherited from superclasses.
 * </p>
 *
 * @param parent a widget which will be the parent of the new instance (cannot be null)
 * @param style the style of widget to construct
 *
 * @exception IllegalArgumentException <ul>
 *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 * </ul>
 * @exception SWTException <ul>
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
 * </ul>
 *
 * @see SWT#BORDER
 * @see SWT#READ_ONLY
 * @see SWT#FLAT
 * @see Widget#getStyle()
 */
public CCombo (Composite parent, int style) {
	super (parent, style = checkStyle (style));
	
	int textStyle = SWT.SINGLE;
	if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY;
	if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT;
	text = new Text (this, textStyle);
	int arrowStyle = SWT.ARROW | SWT.DOWN;
	if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT;
	arrow = new Button (this, arrowStyle);

	listener = new Listener () {
		public void handleEvent (Event event) {
			if (popup == event.widget) {
				popupEvent (event);
				return;
			}
			if (text == event.widget) {
				textEvent (event);
				return;
			}
			if (list == event.widget) {
				listEvent (event);
				return;
			}
			if (arrow == event.widget) {
				arrowEvent (event);
				return;
			}
			if (CCombo.this == event.widget) {
				comboEvent (event);
				return;
			}

		}
	};
	
	
	int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
	for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
	
	int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn, SWT.FocusOut};
	for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
	
	int [] arrowEvents = {SWT.Selection, SWT.FocusIn, SWT.FocusOut};
	for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
	
	createPopup(null, -1);
	initAccessible();
	
}
 
Example 20
Source Project: nebula   File: CTreeLayout.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Layout the Content area after the given item has experienced an event of the given type.
 * Because an event has occurred, indicating a change in content, computeSize will be called.
 * <p>
 *  Event types:
 *  <ul>
 *   <li>SWT.Collapse</li>
 *   <li>SWT.Expand</li>
 *   <li>SWT.Hide</li>
 *   <li>SWT.Move</li>
 *   <li>SWT.Show</li>
 *  </ul>
 * </p>
 * Note that subclasses do not have to handle all types and may also implement more of necessary.
 * @param eventType
 * @param item
 */
void layout(int eventType, CTreeItem item) {
	if(SWT.Move != eventType) {
		computeSize(eventType, item);
	}
	layoutContent(eventType, item);
	if(SWT.Move != eventType) {
		updateScrollBars();
	}
}