类org.eclipse.swt.widgets.Listener源码实例Demo

下面列出了怎么用org.eclipse.swt.widgets.Listener的API类实例代码及写法,或者点击链接到github查看源代码。


private CursorLinePainter getCursorLinePainterInstalled(TextViewer viewer)
{
	Listener[] listeners = viewer.getTextWidget().getListeners(3001/* StyledText.LineGetBackground */);
	for (Listener listener : listeners)
	{
		if (listener instanceof TypedListener)
		{
			TypedListener typedListener = (TypedListener) listener;
			if (typedListener.getEventListener() instanceof CursorLinePainter)
			{
				return (CursorLinePainter) typedListener.getEventListener();
			}
		}
	}
	return null;
}
 
源代码2 项目: birt   文件: HyperlinkBuilder.java

private void createExpressionButton( Composite parent, final Text text )
{
	Listener listener = new Listener( ) {

		public void handleEvent( Event event )
		{
			updateButtons( );
		}

	};
	ExpressionButtonUtil.createExpressionButton( parent,
			text,
			getExpressionProvider( ),
			inputHandle.getElementHandle( ),
			listener );
}
 
源代码3 项目: SWET   文件: Breadcrumb.java

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;
				}
			}
		}
	});
}
 
源代码4 项目: pmTrans   文件: FindReplaceDialog.java

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);
		}
	});
}
 

private CCombo createSubprocessSourceCombo(final Composite outputMappingControl, final OutputMapping mapping) {
    final CCombo subprocessSourceCombo = getWidgetFactory().createCCombo(outputMappingControl, SWT.BORDER);
    for (final Data subprocessData : callActivityHelper.getCallActivityData()) {
        subprocessSourceCombo.add(subprocessData.getName());
    }
    subprocessSourceCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(15, 0).create());
    subprocessSourceCombo.addListener(SWT.Modify, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            getEditingDomain().getCommandStack()
                    .execute(
                            new SetCommand(getEditingDomain(), mapping,
                                    ProcessPackage.Literals.OUTPUT_MAPPING__SUBPROCESS_SOURCE, subprocessSourceCombo
                                            .getText()));
        }
    });
    if (mapping.getSubprocessSource() != null) {
        subprocessSourceCombo.setText(mapping.getSubprocessSource());
    }
    return subprocessSourceCombo;
}
 
源代码6 项目: nebula   文件: GridToolTip.java

/**
   * Creates an inplace tooltip.
   *
   * @param parent parent control.
   */
  public GridToolTip(final Control parent)
  {
      super(parent, SWT.NONE);

      shell = new Shell(parent.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
      shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
      shell.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));

      parent.addListener(SWT.Dispose, new Listener()
      {
	public void handleEvent(Event arg0)
	{
		shell.dispose();
		dispose();
	}
});

      shell.addListener(SWT.Paint, new Listener()
      {
          public void handleEvent(Event e)
          {
              onPaint(e.gc);
          }
      });
  }
 
源代码7 项目: slr-toolkit   文件: ObservableCombo.java

public ObservableCombo(Composite parent, GridData gridData) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new GridLayout(2, false));
    
	combo = new Combo(container, SWT.READ_ONLY);
	combo.setLayoutData(gridData);
	combo.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			notifyObservers();
		}
	});
	Button refresh = new Button(container, SWT.PUSH);
	refresh.setText("Refresh");
	refresh.addListener(SWT.Selection, new Listener() {
		@Override
		public void handleEvent(Event event) {
	        updateOptionsDisplay();
	    }
	});
}
 
源代码8 项目: nebula   文件: TextAssist.java

/**
 * @return a listener for the FocusOut event
 */
private Listener createFocusOutListener() {
	return new Listener() {
		@Override
		public void handleEvent(final Event event) {
			/*
			 * Async is needed to wait until focus reaches its new Control
			 */
			TextAssist.this.getDisplay().asyncExec(() -> {
				if (TextAssist.this.isDisposed() || TextAssist.this.getDisplay().isDisposed()) {
					return;
				}
				final Control control = TextAssist.this.getDisplay().getFocusControl();
				if (control == null || control != text && control != table) {
					popup.setVisible(false);
				}
			});
		}
	};
}
 

public void createContent( Composite parent )
{
	controlTypeChooser = new Combo( parent, SWT.READ_ONLY | SWT.DROP_DOWN );
	controlTypeChooser.setVisibleItemCount( 30 );
	controlTypeChooser.addListener( SWT.Selection, new Listener( ) {

		public void handleEvent( Event e )
		{
			List<Listener> listeners = DefaultParameterDialogControlTypeHelper.this.listeners.get( SWT.Selection );
			if ( listeners == null )
				return;
			for ( int i = 0; i < listeners.size( ); i++ )
				listeners.get( i ).handleEvent( e );
		}
	} );
}
 
源代码10 项目: Pydev   文件: PyConfigureExceptionDialog.java

/**
 * Initialises this dialog's viewer after it has been laid out.
 */
private void initContent() {
    listViewer.setInput(inputElement);
    Listener listener = new Listener() {
        @Override
        public void handleEvent(Event e) {
            if (updateInThread) {
                if (filterJob != null) {
                    // cancel it if it was already in progress
                    filterJob.cancel();
                }
                filterJob = new FilterJob();
                filterJob.start();
            } else {
                doFilterUpdate(new NullProgressMonitor());
            }
        }
    };

    filterPatternField.setText(filterPattern != null ? filterPattern : "");
    filterPatternField.addListener(SWT.Modify, listener);
}
 

@Override
protected List<Control> renderControls() {
    List<Control> controls = new LinkedList<>();
    for (String choice : question.getChoices()) {
        Button btn = new Button(root, SWT.RADIO);
        btn.setText(choice);
        btn.setSelection(choice.equals(question.getAnswer(document)));
        btn.addListener(SWT.Selection, new Listener() {
			@Override
			public void handleEvent(Event event) {
                question.addAnswer(document, choice);
                onQuestionChanged.accept(question);
            }
        });
        controls.add(btn);
    }
    return controls;
}
 
源代码12 项目: nebula   文件: BidiLayout.java

public void addAndReorderListener(int eventType, Listener listener){
	//have to 'reorder' listeners in eventTable. BidiLayout's listener should come first (before StyledText's one)
	Listener[] listeners = styledText.getListeners(eventType);
	Listener styledTextListener = null;
	for (Listener listener2 : listeners) {
		if (listener2.getClass().getSimpleName().startsWith("StyledText")){
			styledTextListener = listener2;
			break;
		}
	}
	if (styledTextListener != null){
		styledText.removeListener(eventType, styledTextListener);
	}
	styledText.addListener(eventType, listener);
	if (styledTextListener != null){
		styledText.addListener(eventType, styledTextListener);
	}
}
 
源代码13 项目: arx   文件: Resources.java

/**
 * Loads an image. Adds a dispose listener that disposes the image when the display is disposed
 * @param display
 * @param resource
 * @return
 */
private static final Image getImage(Display display, String resource) {
    InputStream stream = Resources.class.getResourceAsStream(resource);
    try {
        final Image image = new Image(display, stream);
        display.addListener(SWT.Dispose, new Listener() {
            public void handleEvent(Event arg0) {
                if (image != null && !image.isDisposed()) {
                    image.dispose();
                }
            }
        });
        return image;
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
                // Ignore silently
            }
        }
    }
}
 
源代码14 项目: swt-bling   文件: Bubble.java

private void attachListeners() {
  listener = new Listener() {
    public void handleEvent(Event event) {
      switch (event.type) {
        case SWT.Paint:
          onPaint(event);
          break;
        case SWT.MouseDown:
          onMouseDown(event);
          break;
        case SWT.MouseEnter:
          BubbleRegistrant registrant = BubbleRegistry.getInstance().findRegistrant(getPoppedOverItem().getControlOrCustomElement());
          registrant.dismissBubble();
          registrant.bubble.setDisableAutoHide(false);
          break;
        default:
          break;
      }
    }
  };
  popOverShell.addListener(SWT.Paint, listener);
  popOverShell.addListener(SWT.MouseDown, listener);
  popOverShell.addListener(SWT.MouseEnter, listener);

  addAccessibilityHooks(parentControl);
}
 
源代码15 项目: tmxeditor8   文件: GridToolTip.java

/**
   * Creates an inplace tooltip.
   *
   * @param parent parent control.
   */
  public GridToolTip(final Control parent)
  {
      super(parent, SWT.NONE);

      shell = new Shell(parent.getShell(), SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
      shell.setBackground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
      shell.setForeground(shell.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));

      parent.addListener(SWT.Dispose, new Listener()
      {
	public void handleEvent(Event arg0)
	{
		shell.dispose();
		dispose();
	}
});

      shell.addListener(SWT.Paint, new Listener()
      {
          public void handleEvent(Event e)
          {
              onPaint(e.gc);
          }
      });
  }
 
源代码16 项目: nebula   文件: DisposalTests.java

public void testDisposeWithListeners() throws Exception {
	asyncExec(new Runnable() {
		public void run() {
			comp.addListener(SWT.Dispose, new Listener() {
				public void handleEvent(Event event) {
					assertFalse(comp.isDisposed());
				}
			});
		}
	});
	
	asyncExec(new Runnable() {
		public void run() {
			getShell().dispose();
		}
	});
	
	while(getDisplay() != null && !getDisplay().isDisposed()) {
		Thread.sleep(100);
	}
}
 
源代码17 项目: tuxguitar   文件: SWTTabItem.java

@SuppressWarnings("unchecked")
public void addChild(UIControl control) {
	Control handle = ((SWTControl<? extends Control>) control).getControl();
	
	this.control = control;
	this.item.setControl(handle);
	
	handle.addListener(SWT.Resize, new Listener() {
		public void handleEvent(Event event) {
			onResize();
		}
	});
	handle.getDisplay().asyncExec(new Runnable() {
		public void run() {
			onResize();
		}
	});
}
 

public MatchViewerBodyMenu(MatchViewPart view) {
	this.view = view;
	createMenu();
	bodyMenu.addListener(SWT.Show, new Listener() {

		public void handleEvent(Event event) {
			updateActionState();
		}
	});
}
 
源代码19 项目: gef   文件: GraphvizConfigurationDialog.java

@Override
protected Control createMessageArea(Composite composite) {
	// prevent creation of messageLabel by super implementation
	String linkText = message;
	message = null;
	super.createMessageArea(composite);
	message = linkText;

	Link messageLink = new Link(composite, SWT.WRAP);
	messageLink.setText(message);
	GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
			.grab(true, false).applyTo(messageLink);
	messageLink.addListener(SWT.Selection, new Listener() {
		@Override
		public void handleEvent(Event event) {
			Shell shell = PlatformUI.getWorkbench()
					.getActiveWorkbenchWindow().getShell();
			PreferenceDialog pref = PreferencesUtil
					.createPreferenceDialogOn(shell,
							"org.eclipse.gef.dot.internal.ui.GraphvizPreferencePage", //$NON-NLS-1$
							null, null);
			if (pref != null) {
				close();
				pref.open();
			}
		}
	});
	return composite;
}
 
源代码20 项目: tracecompass   文件: TmfRawEventViewer.java

/**
 * Remove selection listener
 * @param listener A listener to remove
 */
public void removeSelectionListener(Listener listener) {
    checkWidget();
    if (listener == null) {
        SWT.error (SWT.ERROR_NULL_ARGUMENT);
    }
    removeListener(SWT.Selection, listener);
}
 
源代码21 项目: bonita-studio   文件: ConnectorSection.java

private Button createUpdateConnectorButton(final Composite parent) {
    final Button updateButton = getWidgetFactory().createButton(parent,
            Messages.update, SWT.FLAT);
    updateButton.setLayoutData(GridDataFactory.fillDefaults()
            .minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create());
    updateButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            updateConnectorAction();
        }
    });
    return updateButton;
}
 
源代码22 项目: thym   文件: MissingRequirementsDialog.java

@Override
protected Control createDialogArea(Composite parent) {
	Composite composite = (Composite) super.createDialogArea(parent);
	Link messageLnk = new Link(composite,SWT.NONE);
	messageLnk.setText(this.message);
	messageLnk.addListener(SWT.Selection, new Listener() {
		
		@Override
		public void handleEvent(Event event) {
			OpenCheatSheetAction ch = new OpenCheatSheetAction("org.eclipse.thym.ui.requirements.cordova");
			ch.run();
		}
	});
	return composite;
}
 
源代码23 项目: lwjgl3-swt   文件: SimpleDemo.java

public static void main(String[] args) {
    // Create the Vulkan instance
    VkInstance instance = createInstance();

    // Create SWT Display, Shell and VKCanvas
    final Display display = new Display();
    final Shell shell = new Shell(display, SWT.SHELL_TRIM | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE);
    shell.setLayout(new FillLayout());
    shell.addListener(SWT.Traverse, new Listener() {
        public void handleEvent(Event event) {
            switch (event.detail) {
            case SWT.TRAVERSE_ESCAPE:
                shell.close();
                event.detail = SWT.TRAVERSE_NONE;
                event.doit = false;
                break;
            }
        }
    });
    VKData data = new VKData();
    data.instance = instance; // <- set Vulkan instance
    final VKCanvas canvas = new VKCanvas(shell, SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE, data);
    shell.setSize(800, 600);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    canvas.dispose();
    display.dispose();
}
 
源代码24 项目: birt   文件: GanttLineAttributesComposite.java

/**
 * 
 */
private void init( )
{
	this.setSize( getParent( ).getClientArea( ).width,
			getParent( ).getClientArea( ).height );
	vListeners = new Vector<Listener>( );
}
 
源代码25 项目: birt   文件: DateTimeDataElementComposite.java

public DateTimeDataElementComposite( Composite parent, int style,
		DateTimeDataElement data, boolean isNullAllowed )
{
	super( parent, SWT.NONE );
	this.isNullAllowed = isNullAllowed;

	placeComponents( style );

	vListeners = new Vector<Listener>( );

	setDataElement( data );
}
 
源代码26 项目: SWET   文件: Breadcrumb.java

private void addMouseUpListener() {
	addListener(SWT.MouseUp, new Listener() {
		@Override
		public void handleEvent(final Event event) {
			for (final BreadcrumbItem item : Breadcrumb.this.items) {
				if (item.getBounds().contains(event.x, event.y)) {
					if (item.getData(IS_BUTTON_PRESSED) == null) {
						// The button was not pressed
						return;
					}
					item.setData(IS_BUTTON_PRESSED, null);

					if ((item.getStyle() & SWT.PUSH) != 0) {
						item.setSelection(false);
					}

					if ((item.getStyle() & (SWT.TOGGLE | SWT.PUSH)) != 0) {
						item.fireSelectionEvent();
						redraw();
						update();
					}
					return;
				}
			}
		}
	});
}
 

private void createRow(final Composite parent, Composite panel,
    final Text text) {
  text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  Button button = new Button(panel, SWT.BORDER);
  button.setText("Browse...");
  button.addListener(SWT.Selection, new Listener() {
    public void handleEvent(Event arg0) {
      try {
        AST ast = AST.newAST(3);

        SelectionDialog dialog = JavaUI.createTypeDialog(parent.getShell(),
            new ProgressMonitorDialog(parent.getShell()), SearchEngine
                .createWorkspaceScope(),
            IJavaElementSearchConstants.CONSIDER_CLASSES, false);
        dialog.setMessage("Select Mapper type (implementing )");
        dialog.setBlockOnOpen(true);
        dialog.setTitle("Select Mapper Type");
        dialog.open();

        if ((dialog.getReturnCode() == Window.OK)
            && (dialog.getResult().length > 0)) {
          IType type = (IType) dialog.getResult()[0];
          text.setText(type.getFullyQualifiedName());
          setDirty(true);
        }
      } catch (JavaModelException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  });
}
 
源代码28 项目: nebula   文件: GridViewerColumn.java

/** {@inheritDoc} */
public void setEditingSupport(EditingSupport editingSupport)
{
	currentEditingSupport = editingSupport;
	if (!getColumn().isVisible()) {
		return;
	}

    if (editingSupport instanceof CheckEditingSupport)
    {
        if (checkEditingSupport == null)
        {
            final int colIndex = getColumn().getParent().indexOf(getColumn());

            getColumn().getParent().addListener(SWT.Selection, new Listener()
            {
                public void handleEvent(Event event)
                {
                    if (event.detail == SWT.CHECK && event.index == colIndex)
                    {
                        GridItem item = (GridItem)event.item;
                        Object element = item.getData();
                        checkEditingSupport.setValue(element, new Boolean(item.getChecked(colIndex)));
                    }
                }
            });
        }
        checkEditingSupport = (CheckEditingSupport)editingSupport;
    }
    else
    {
        super.setEditingSupport(editingSupport);
    }
}
 
源代码29 项目: pentaho-kettle   文件: WidgetUtils.java

/**
 * creates a ComboVar populated with fields from the previous step.
 * @param parentComposite - the composite in which the widget will be placed
 * @param props - PropsUI props for L&F
 * @param stepMeta - stepMeta of the current step
 * @param formData - FormData to use for placement
 */
public static ComboVar createFieldDropDown(
  Composite parentComposite, PropsUI props, BaseStepMeta stepMeta, FormData formData ) {
  TransMeta transMeta = stepMeta.getParentStepMeta().getParentTransMeta();
  ComboVar fieldDropDownCombo = new ComboVar( transMeta, parentComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER );
  props.setLook( fieldDropDownCombo );
  fieldDropDownCombo.addModifyListener( e -> stepMeta.setChanged() );

  fieldDropDownCombo.setLayoutData( formData );
  Listener focusListener = e -> {
    String current = fieldDropDownCombo.getText();
    fieldDropDownCombo.getCComboWidget().removeAll();
    fieldDropDownCombo.setText( current );

    try {
      RowMetaInterface rmi = transMeta.getPrevStepFields( stepMeta.getParentStepMeta().getName() );
      List ls = rmi.getValueMetaList();
      for ( Object l : ls ) {
        ValueMetaBase vmb = (ValueMetaBase) l;
        fieldDropDownCombo.add( vmb.getName() );
      }
    } catch ( KettleStepException ex ) {
      // can be ignored, since previous step may not be set yet.
      stepMeta.logDebug( ex.getMessage(), ex );
    }
  };
  fieldDropDownCombo.getCComboWidget().addListener( SWT.FocusIn, focusListener );
  return fieldDropDownCombo;
}
 
源代码30 项目: birt   文件: TreeValueDialog.java

/**
 * Creates and initializes the tree viewer.
 * 
 * @param parent
 *            the parent composite
 * @return the tree viewer
 * @see #doCreateTreeViewer(Composite, int)
 */
protected TreeViewer createTreeViewer( Composite parent )
{
	TreeViewer treeViewer = super.createTreeViewer( parent );
	Tree tree = treeViewer.getTree( );
	assert ( tree != null );
	for ( int i = 0; i < listeners.size( ); i++ )
	{
		int type = listeners.get( i ).type;
		Listener listener = listeners.get( i ).listener;
		tree.addListener( type, listener );
	}
	return treeViewer;
}
 
 类所在包
 类方法
 同包方法