org.eclipse.swt.widgets.Event Java Examples

The following examples show how to use org.eclipse.swt.widgets.Event. 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 File: StyledTextCellEditor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 添加标记样式改变监听 ;
 */
private void addTagStyleChangeListener() {
	final TagStyleManager tagStyleManager = xliffEditor.getTagStyleManager();
	final Listener tagStyleChangeListener = new Listener() {
		public void handleEvent(Event event) {
			if (event.data != null && event.data instanceof TagStyle) {
				viewer.setTagStyle((TagStyle) event.data);
			}
		}
	};
	tagStyleManager.addTagStyleChangeListener(tagStyleChangeListener);

	viewer.getTextWidget().addDisposeListener(new DisposeListener() {
		public void widgetDisposed(DisposeEvent e) {
			tagStyleManager.removeTagStyleChangeListener(tagStyleChangeListener);
		}
	});
}
 
Example #2
Source File: StyledTextActionHandler.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public void handleEvent(Event event) {
	switch (event.type) {
		case SWT.Activate :
			styledText = (StyledText) event.widget;
			updateActionsEnableState();
			break;
		case SWT.Deactivate :
			styledText = null;
			updateActionsEnableState();
			break;
		default :
			break;
	}
}
 
Example #3
Source File: FindReplaceDialog.java    From pmTrans with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void renderTransparency(final Shell shell) {
	Group group = new Group(shell, SWT.NONE);
	group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 6, 1));
	group.setLayout(new GridLayout(1, false));
	group.setText("Transparency");
	final Scale transparencySlider = new Scale(group, SWT.HORIZONTAL);
	transparencySlider.setMinimum(20);
	transparencySlider.setMaximum(100);
	transparencySlider.setPageIncrement(90);
	transparencySlider.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
	transparencySlider.setSelection(100);
	transparencySlider.addListener(SWT.Selection, new Listener() {

		@Override
		public void handleEvent(Event event) {
			shell.setAlpha(255 * transparencySlider.getSelection() / 100);
		}
	});
}
 
Example #4
Source File: SpeedGraphic.java    From BiglyBT with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void initialize(Canvas canvas) {
	super.initialize(canvas);

	drawCanvas.addPaintListener(new PaintListener() {
	@Override
	public void paintControl(PaintEvent e) {
		if (bufferImage != null && !bufferImage.isDisposed()) {
			Rectangle bounds = bufferImage.getBounds();
			if (bounds.width >= ( e.width + e.x ) && bounds.height >= ( e.height + e.y )) {

				e.gc.drawImage(bufferImage, e.x, e.y, e.width, e.height, e.x, e.y,
						e.width, e.height);
			}
		}
	}
});

	drawCanvas.addListener(SWT.Resize, new Listener() {
	@Override
	public void handleEvent(Event event) {
		drawChart(true);
	}
});
}
 
Example #5
Source File: ResourceDependencySection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
@Override
public void handleEvent(Event event) {
  if (event.widget == addButton) {
    handleAdd();
  } else if (event.widget == removeButton
          || (event.type == SWT.KeyUp && event.character == SWT.DEL)) {
    handleRemove();
  } else if (event.widget == editButton || event.type == SWT.MouseDoubleClick) {
    handleEdit();
  }
  // else if (event.type == SWT.MouseDown && event.button == 3) {
  // handleTableContextMenuRequest(event);
  // }
  else if (event.type == SWT.MouseHover) {
    handleTableHoverHelp(event);
  } else if (event.type == SWT.Selection) {
    editor.getResourcesPage().getResourceBindingsSection().enable();
  }
  enable();
}
 
Example #6
Source File: ContextMenuHelper.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
private static void click(final MenuItem menuItem) {
  final Event event = new Event();
  event.time = (int) System.currentTimeMillis();
  event.widget = menuItem;
  event.display = menuItem.getDisplay();
  event.type = SWT.Selection;

  UIThreadRunnable.asyncExec(
      menuItem.getDisplay(),
      new VoidResult() {
        @Override
        public void run() {
          menuItem.notifyListeners(SWT.Selection, event);
        }
      });
}
 
Example #7
Source File: KeyBindingHelper.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public static void handleEvent(Event e)
{
	IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);

	Listener keyDownFilter = ((BindingService) bindingService).getKeyboard().getKeyDownFilter();
	boolean enabled = bindingService.isKeyFilterEnabled();
	Control focusControl = e.display.getFocusControl();
	try
	{
		bindingService.setKeyFilterEnabled(true);
		keyDownFilter.handleEvent(e);
	}
	finally
	{
		if (focusControl == e.display.getFocusControl()) // $codepro.audit.disable useEquals
		{
			bindingService.setKeyFilterEnabled(enabled);
		}
	}
}
 
Example #8
Source File: JavaCamelJobScriptsExportWSWizardPage.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
@Override
public void handleEvent(Event e) {
    super.handleEvent(e);
    Widget source = e.widget;

    if (source == destinationBrowseButton) {
        handleDestinationBrowseButtonPressed();
    }

    if (source instanceof Combo) {
        String destination = ((Combo) source).getText();
        if (getDialogSettings() != null) {
            IDialogSettings section = getDialogSettings().getSection(DESTINATION_FILE);
            if (section == null) {
                section = getDialogSettings().addNewSection(DESTINATION_FILE);
            }
            section.put(DESTINATION_FILE, destination);
        }
    }
}
 
Example #9
Source File: ExportToDDLAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(Event event) {
	ERDiagram diagram = this.getDiagram();

	ExportToDDLDialog dialog = new ExportToDDLDialog(PlatformUI
			.getWorkbench().getActiveWorkbenchWindow().getShell(), diagram,
			this.getEditorPart(), this.getGraphicalViewer());

	dialog.open();

	this.refreshProject();

	if (dialog.getExportSetting() != null
			&& !diagram.getDiagramContents().getSettings()
					.getExportSetting().equals(dialog.getExportSetting())) {
		Settings newSettings = (Settings) diagram.getDiagramContents()
				.getSettings().clone();
		newSettings.setExportSetting(dialog.getExportSetting());

		ChangeSettingsCommand command = new ChangeSettingsCommand(diagram,
				newSettings);
		this.execute(command);
	}

}
 
Example #10
Source File: OpenUIDesignerCoolBarItemTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void call_open_ui_designer_command_on_selection() throws Exception {
    final OpenUIDesignerCoolBarItem openUIDesignerCoolBarItem = spy(new OpenUIDesignerCoolBarItem());
    doReturn(openDesignerHandler).when(openUIDesignerCoolBarItem).getHandler();
    doReturn(prefStore).when(openUIDesignerCoolBarItem).getPreferenceStore();
    doReturn(eclipsePref).when(openUIDesignerCoolBarItem).getEclipsePreferences();
    doReturn(true).when(eclipsePref).getBoolean(eq(OpenUIDesignerCoolBarItem.HIDE_UIDESIGNER_INFO_DIALOG), anyBoolean());
    final Shell shell = realmWithDisplay.getShell();
    doReturn(shell).when(openUIDesignerCoolBarItem).getShell();

    final ToolBar toolbar = new ToolBar(realmWithDisplay.createComposite(), SWT.NONE);
    openUIDesignerCoolBarItem.fill(toolbar, 0, -1);

    final ToolItem toolItem = toolbar.getItem(0);
    toolItem.notifyListeners(SWT.Selection, new Event());

    verify(openDesignerHandler).execute();
}
 
Example #11
Source File: VButton.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private Event createEvent(Event event) {
	Event e = new Event();
	e.type = SWT.Selection;
	e.data = VButton.this;
	e.button = event.button;
	e.detail = event.detail;
	e.display = event.display;
	e.gc = event.gc;
	e.height = event.height;
	e.stateMask = event.stateMask;
	e.time = event.time;
	e.width = event.width;
	e.x = event.x;
	e.y = event.y;
	return e;
}
 
Example #12
Source File: PGroupToolItem.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
void onMouseDown(Event e) {
	if ((getStyle() & SWT.DROP_DOWN) == 0) {
		setSelection(!getSelection());
		notifyListeners(SWT.Selection, new Event());
	} else {
		if ( ((getStyle() & SWT.PUSH) == SWT.PUSH) && ( dropdownArea == null || !dropdownArea.contains(e.x, e.y))) {
			notifyListeners(SWT.Selection, new Event());
		} else {
			Event event = new Event();
			event.detail = SWT.ARROW;
			event.x = bounds.x;
			event.y = bounds.y + bounds.height;
			notifyListeners(SWT.Selection, event);
		}
	}
}
 
Example #13
Source File: ToolItemMenuListener.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This function should only make the Menu visible if necessary. Nothing
 * inside the Menu will be changed.
 */
@Override
public void handleEvent(Event event) {
	// We want to align the menu with the bottom-left corner of the ToolItem
	// arrow.

	// event.detail == SWT.ARROW means the arrow has been clicked.
	// event.detail == SWT.NONE means the button has been clicked.
	if (event.detail == SWT.ARROW || event.detail == SWT.NONE) {
		Rectangle r = toolItem.getBounds();
		Point p = new Point(r.x, r.y + r.height);
		p = toolItem.getParent().toDisplay(p.x, p.y);
		menu.setLocation(p.x, p.y);
		menu.setVisible(true);
	}

	return;
}
 
Example #14
Source File: MoveScrollBarEffect.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void applyEffect(final long currentTime) {
	current = (int) (start + step
			* easingFunction.getValue((int) currentTime));

	if (!scrollBar.isDisposed()) {
		scrollBar.setSelection(current);
		Event event = new Event();
		event.detail = step < 0 ? SWT.PAGE_UP : SWT.PAGE_DOWN;
		event.data = this;
		event.display = scrollBar.getDisplay();
		event.widget = scrollBar;
		event.doit = true;

		scrollBar.notifyListeners(SWT.Selection, event);
	}
}
 
Example #15
Source File: VButtonImageBak.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
public void handleEvent(Event e) {
	GC gc = new GC(b);
	Image image = new Image(b.getDisplay(), e.width, e.height);
	gc.copyArea(image, 0, 0);
	ImageData data = image.getImageData();
	gc.dispose();
	image.dispose();
	images.put(key, data);
	keys.put(data, key);
	if(requests.containsKey(key)) {
		for(Iterator<VButton> iter = requests.get(key).iterator(); iter.hasNext();) {
			iter.next().redraw();
			iter.remove();
		}
		requests.remove(key);
	}
	Display.getDefault().asyncExec(new Runnable() {
		public void run() {
			if(!b.isDisposed() && b == b.getDisplay().getFocusControl()) {
				b.getParent().forceFocus();
			}
			b.dispose();
		}
	});
}
 
Example #16
Source File: Breadcrumb.java    From SWET with MIT License 6 votes vote down vote up
private void addMouseDownListener() {
	addListener(SWT.MouseDown, new Listener() {
		@Override
		public void handleEvent(final Event event) {
			for (final BreadcrumbItem item : Breadcrumb.this.items) {
				if (item.getBounds().contains(event.x, event.y)) {
					final boolean isToggle = (item.getStyle() & SWT.TOGGLE) != 0;
					final boolean isPush = (item.getStyle() & SWT.PUSH) != 0;
					if (isToggle || isPush) {
						item.setSelection(!item.getSelection());
						redraw();
						update();
					}
					item.setData(IS_BUTTON_PRESSED, "*");
					return;
				}
			}
		}
	});
}
 
Example #17
Source File: MetaDataSection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
@Override
public void handleEvent(Event event) {
  valueChanged = false;

  dmd.setName(setValueChanged(nameText.getText(), dmd.getName()));
  dmd.setVersion(setValueChanged(versionText.getText(), dmd.getVersion()));
  dmd.setVendor(setValueChanged(vendorText.getText(), dmd.getVendor()));
  dmd.setDescription(setValueChanged(multiLineFix(descriptionText.getText()), dmd
          .getDescription()));

  if (valueChanged)
    setFileDirty();
}
 
Example #18
Source File: LevelPropertyDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private IDialogHelper createHyperLinkPart( Composite parent )
{
	Object[] helperProviders = ElementAdapterManager.getAdapters( input,
			IDialogHelperProvider.class );
	if ( helperProviders != null )
	{
		for ( int i = 0; i < helperProviders.length; i++ )
		{
			IDialogHelperProvider helperProvider = (IDialogHelperProvider) helperProviders[i];
			if ( helperProvider != null )
			{
				final IDialogHelper hyperLinkHelper = helperProvider.createHelper( this,
						BuilderConstants.HYPERLINK_HELPER_KEY );
				if ( hyperLinkHelper != null )
				{
					hyperLinkHelper.setProperty( BuilderConstants.HYPERLINK_LABEL,
							Messages.getString( "LevelPropertyDialog.Label.LinkTo" ) ); //$NON-NLS-1$
					hyperLinkHelper.setProperty( BuilderConstants.HYPERLINK_BUTTON_TEXT,
							Messages.getString( "LevelPropertyDialog.Button.Text.Edit" ) ); //$NON-NLS-1$
					hyperLinkHelper.setProperty( BuilderConstants.HYPERLINK_REPORT_ITEM_HANDLE,
							input );
					hyperLinkHelper.setProperty( BuilderConstants.HYPERLINK_REPORT_ITEM_PROVIDER,
							new LinkToCubeExpressionProvider( input ) );
					hyperLinkHelper.createContent( parent );
					hyperLinkHelper.addListener( SWT.Modify,
							new Listener( ) {

								public void handleEvent( Event event )
								{
									hyperLinkHelper.update( false );
								}
							} );
					hyperLinkHelper.update( true );
					return hyperLinkHelper;
				}
			}
		}
	}
	return null;
}
 
Example #19
Source File: ScriptValuesModDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void addRenameTowTreeScriptItems() {
  lastItem = new TreeItem[1];
  editor = new TreeEditor( wTree );
  wTree.addListener( SWT.Selection, new Listener() {
    public void handleEvent( Event event ) {
      final TreeItem item = (TreeItem) event.item;
      renameFunction( item );
    }
  } );
}
 
Example #20
Source File: AbstractLinkedEditingIntegrationTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void pressKey(XtextEditor editor, char c) throws Exception {
	StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
	Event e = new Event();
	e.character = c;
	e.type = SWT.KeyDown;
	e.doit = true;
	//XXX Hack!
	if (c == SWT.ESC) {
		e.keyCode = 27;
	}
	textWidget.notifyListeners(SWT.KeyDown, e);
}
 
Example #21
Source File: PatternImageEditorDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void notifyListeners( )
{
	Event event = new Event( );
	event.type = SWT.Modify;

	for ( Listener listener : listeners )
	{
		listener.handleEvent( event );
	}
}
 
Example #22
Source File: XLIFFEditorActionHandler.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public void runWithEvent(Event event) {
	if (viewer != null && !viewer.getTextWidget().isDisposed()) {
		StyledTextCellEditor editor = HsMultiActiveCellEditor.getFocusCellEditor();
		boolean isSrc = false;
		if (editor != null && editor.getCellType().equals(NatTableConstant.SOURCE)) {
			isSrc = true;
		}
		StyledText styledText = viewer.getTextWidget();
		String text = styledText.getText();
		String selectionText = styledText.getSelectionText();
		// 当选择源文时,要判断是否是删除所有源文
		if (isSrc) {
			if (selectionText != null && text != null && text.equals(selectionText)) {
				MessageDialog.openInformation(viewer.getTextWidget().getShell(),
						Messages.getString("editor.XLIFFEditorActionHandler.msgTitle"),
						Messages.getString("editor.XLIFFEditorActionHandler.msg"));
				return;
			}
		}
		viewer.doOperation(ITextOperationTarget.DELETE);
		updateActionsEnableState();
		return;
	}
	if (deleteAction != null) {
		deleteAction.runWithEvent(event);
		return;
	}
}
 
Example #23
Source File: ChangeFreeLayoutAction.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(Event event) {
    final ERDiagram diagram = getDiagram();
    final ChangeFreeLayoutCommand command = new ChangeFreeLayoutCommand(diagram, isChecked());

    execute(command);
}
 
Example #24
Source File: ScriptDialog.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
private void addRenameTowTreeScriptItems() {
  lastItem = new TreeItem[1];
  editor = new TreeEditor( wTree );
  wTree.addListener( SWT.Selection, new Listener() {
    public void handleEvent( Event event ) {
      final TreeItem item = (TreeItem) event.item;
      renameFunction( item );
    }
  } );
}
 
Example #25
Source File: MessageArea.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create a text box
 */
private void createTextBox() {
	final Text textbox = new Text(composite, SWT.BORDER | SWT.WRAP);
	textbox.setText(textBoxValue);
	final GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true, 1, 1);
	textbox.setLayoutData(gd);
	textbox.addListener(SWT.Modify, e -> {
		textBoxValue = textbox.getText();
	});

	textbox.addListener(SWT.KeyUp, e -> {
		if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
			MessageArea.this.parent.shell.dispose();
			MessageArea.this.parent.getFooterArea().selectedButtonIndex = 0;
		}
	});

	textbox.getShell().addListener(SWT.Activate, new Listener() {

		@Override
		public void handleEvent(final Event arg0) {
			textbox.forceFocus();
			textbox.setSelection(textbox.getText().length());
			textbox.getShell().removeListener(SWT.Activate, this);
		}
	});

}
 
Example #26
Source File: MenuPage.java    From EasyShell with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Control createContents(Composite parent) {
    // main page composite
    Composite pageComponent = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(3, false);
    pageComponent.setLayout(layout);
    //parent.setLayout(layout);

    // search
    createSearchField(pageComponent);

    // get the native commands list
    commandList = CommandDataDefaultCollection.getCommandsNativeAll(new CommandDataList(CommandDataStore.instance().getDataList()));

    // table viewer
    createTableViewer(pageComponent);

    // buttons
    createButtons(pageComponent);

    // refresh the viewer
    refreshTableViewer();

    // send event to refresh tableViewer selection
    Event event = new Event();
    event.item = null;
    tableViewer.getTable().notifyListeners(SWT.Selection, event);

    return pageComponent;
}
 
Example #27
Source File: GridColumn.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Fires resized event.
 */
void fireResized() {
	Event e = new Event();
	e.display = this.getDisplay();
	e.item = this;
	e.widget = parent;

	this.notifyListeners(SWT.Resize, e);
}
 
Example #28
Source File: TableCombo.java    From Pydev with 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 #29
Source File: FileCoverMsgDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public void handleEvent(Event event) {
	Widget resource = event.widget;
	if (resource == cancelBtn) {
		cancelPressed();
	}else if (resource == skipBtn) {
		setReturnCode(SKIP);
		ALWAYS = alwaysBtn.getSelection();
		close();
	}else if (resource == overBtn) {
		setReturnCode(OVER);
		ALWAYS = alwaysBtn.getSelection();
		close();
	}
}
 
Example #30
Source File: TransferStatsView.java    From BiglyBT with GNU General Public License v2.0 5 votes vote down vote up
protected
zoneView(
 SpeedManagerPingMapper		_mapper,
 Canvas 						_canvas,
 String[]						_labels,
 ValueFormater[]				_formatters )
{
 mapper		= _mapper;
 canvas		= _canvas;
 labels		= _labels;
 formatters	= _formatters;

 canvas.addPaintListener(new PaintListener() {
	@Override
	public void paintControl(PaintEvent e) {
		if (buffer_image != null && !buffer_image.isDisposed()) {
			Rectangle bounds = buffer_image.getBounds();
			if (bounds.width >= ( e.width + e.x ) && bounds.height >= ( e.height + e.y )) {

				e.gc.drawImage(buffer_image, e.x, e.y, e.width, e.height, e.x, e.y,
						e.width, e.height);
			}
		}
	}
});

 canvas.addListener(SWT.Resize, new Listener() {
	@Override
	public void handleEvent(Event event) {
		refresh(true);
	}
});
 COConfigurationManager.addAndFireParameterListener( "Graphics Update", this );
}