Java Code Examples for org.eclipse.swt.widgets.Event

The following are top voted examples for showing how to use org.eclipse.swt.widgets.Event. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Hydrograph   File: ComponentSearchUtility.java   View source code 6 votes vote down vote up
/**
 * Check the coordinates for Component creation
 * @param event
 * @param container
 */
private void checkComponentCoordinates(Event event, Container container) {
	boolean isCordinateChanged = false;
	for (Object component : container.getChildren()) {
		if (component instanceof hydrograph.ui.graph.model.Component) {
			if (((hydrograph.ui.graph.model.Component) component).getLocation().x == event.x
					&& ((hydrograph.ui.graph.model.Component) component).getLocation().y == event.y) {
				event.x = event.x + 20;
				event.y = event.y + 20;
				isCordinateChanged = true;
			}
		} else if (component instanceof hydrograph.ui.graph.model.CommentBox) {
			if (((hydrograph.ui.graph.model.CommentBox) component).getLocation().x == event.x
					&& ((hydrograph.ui.graph.model.CommentBox) component).getLocation().y == event.y) {
				event.x = event.x + 20;
				event.y = event.y + 20;
				isCordinateChanged = true;
			}
		}
	}
	if (!isCordinateChanged) {
		return;
	} else {
		checkComponentCoordinates(event, container);
	}
}
 
Example 2
Project: n4js   File: TestResultsView.java   View source code 6 votes vote down vote up
@Override
protected boolean shouldCreateToolTip(final Event e) {
	this.lastDescriptor = null;
	if (e.widget instanceof Tree) {
		final Tree tree = (Tree) e.widget;
		final TreeItem item = tree.getItem(new Point(e.x, e.y));

		if (null != item && item.getData() instanceof ResultNode) {
			final ResultNode node = (ResultNode) item.getData();
			if (node.getElement() instanceof TestCase) {
				final URI uri = ((TestCase) node.getElement()).getURI();
				if (null != uri) {
					final StyledTextDescriptor descriptor = getDescriptor(uri);
					if (null != descriptor) {
						this.lastDescriptor = descriptor;
					}
				}
			}
		}
	}

	return null != this.lastDescriptor;
}
 
Example 3
Project: AgentWorkbench   File: ProjectNewOpen.java   View source code 6 votes vote down vote up
@Override
  protected void configureShell(Shell newShell) {
      super.configureShell(newShell);
      this.currentShell = newShell;
      this.currentShell.setText(this.title);
      this.currentShell.getDisplay().addFilter(SWT.Traverse, new Listener() {
	@Override
	public void handleEvent(Event event) {
		switch (event.detail) {
		case SWT.TRAVERSE_ESCAPE:
			event.doit = false;
			cancelPressed();
			break;

		default:
			break;
		}
	}
});
  }
 
Example 4
Project: ide-plugins   File: PluginsSWT.java   View source code 6 votes vote down vote up
@Override
protected Composite createViewerToolTipContentArea(Event event, ViewerCell cell, Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setBackground(rowColorBack);
    Plugin plugin = (Plugin) cell.getElement();

    Hyperlink button = new Hyperlink(composite, SWT.FLAT);
    button.setText("\uf05A");
    button.setFont(fontAwesome);
    button.setBackground(composite.getBackground());
    button.setForeground(rowColorTitle);
    button.setUnderlined(false);
    button.addListener (SWT.MouseDown, e -> Program.launch(GLUON_PLUGIN_URL + plugin.getUrl()));
    button.setToolTipText("Click to access the service's JavaDoc");

    Label text = new Label(composite, SWT.LEFT);
    final String description = plugin.getDescription();
    text.setText(description.contains(".") ? description.substring(0, description.indexOf(".")) : description);
    text.setBackground(composite.getBackground());
    text.setForeground(rowColorTitle);
    composite.pack();
    return composite;
}
 
Example 5
Project: bdf2   File: PropEditor.java   View source code 6 votes vote down vote up
@Override
public void handleEvent(Event e) {
	if (e.widget == toolItemAdd) {
		doAdd();
	} else if (e.widget == toolItemDel) {
		doDel();
	} else if (e.widget == toolItemProperty) {
		if (propertyBrowser == null) {
			if (!checkXmlExist()) {
				try {
					updatePropertyBrowser();
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
			propertyBrowser = new PropertyBrowser(getContainer().getShell(), me, getXmlFilePath());
		}
		propertyBrowser.open();
	}

}
 
Example 6
Project: pmTrans   File: BarManager.java   View source code 6 votes vote down vote up
public void createToolBar() {
	bar = new CoolBar(shell, SWT.FLAT | SWT.TOP);
	// bars
	bar.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

	createFileSection();
	createEditBar();
	createFontSection();
	createSettingsBar();

	bar.pack();
	bar.addListener(SWT.Resize, new Listener() {

		@Override
		public void handleEvent(Event arg0) {
			pmTrans.adjustLayout();
		}
	});
}
 
Example 7
Project: network-device-panel   File: DevicePanelSvg.java   View source code 6 votes vote down vote up
@Override
protected void handleCallNotify(String eventName, JsonObject parameters) {
	if ("Selection".equals(eventName)) {
		Event event = new Event();
		event.text = parameters.get("index").asString();
		event.data =  parameters.get("data").asString();

		if(event.text.toLowerCase().equals("svgtxtchanged")){
			event.data = this.svgTxtPrefix + parameters.get("data").asString();
		}
		if(event.text.toLowerCase().equals("portmenu") || event.text.toLowerCase().equals("portport")){
			event.x =  parameters.get("x").asInt();
			event.y =  parameters.get("y").asInt();
		}
		notifyListeners(SWT.Selection, event);
	}
}
 
Example 8
Project: BiglyBT   File: IntListParameter.java   View source code 6 votes vote down vote up
public IntListParameter(Composite composite, final String name,
	int defaultValue, final String labels[], final int values[]) {
super(name);
this.name = name;
this.values = values;

    if(labels.length != values.length)
      return;
    int value = COConfigurationManager.getIntParameter(name,defaultValue);
    int index = findIndex(value,values);
    list = new Combo(composite,SWT.SINGLE | SWT.READ_ONLY);
    for(int i = 0 ; i < labels.length  ;i++) {
      list.add(labels[i]);
    }

    setIndex(index);

    list.addListener(SWT.Selection, new Listener() {
         @Override
         public void handleEvent(Event e) {
        	 setIndex(list.getSelectionIndex());
         }
       });

  }
 
Example 9
Project: Hydrograph   File: ELTVerifySequenceFieldName.java   View source code 6 votes vote down vote up
@Override
public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper,
		Widget... widgets) {
	if (helper != null) {
		txtDecorator = (ControlDecoration) helper.get(HelperType.CONTROL_DECORATION);
	}
	Listener listener = new Listener() {

		@Override
		public void handleEvent(Event event) {
			String string = event.text;
			Matcher matchs = Pattern.compile(Constants.REGEX).matcher(string);
			LOGGER.debug("Verifying text format");
			if (!matchs.matches()) {
				txtDecorator.setDescriptionText(Messages.CHARACTERSET);
				txtDecorator.show();
				event.doit = false;

			} else
				txtDecorator.hide();

		}
	};
	return listener;
}
 
Example 10
Project: BiglyBT   File: DelayedListenerMultiCombiner.java   View source code 6 votes vote down vote up
@Override
public final void handleEvent(final Event event) {
	synchronized (lock) {
		if (pending) {
			return;
		}

		pending = true;
	}

	Utils.execSWTThreadLater(0, new SWTRunnable() {
		@Override
		public void runWithDisplay(Display display) {
			synchronized( lock ){
 					pending = false;
 				}
			handleDelayedEvent(event);
		}
	});
}
 
Example 11
Project: AppleCommander   File: SwtAppleCommander.java   View source code 6 votes vote down vote up
public void handleEvent(Event event) {
	if (event.type == SWT.KeyUp && (event.stateMask & SWT.CTRL) != 0) {
		switch (event.character) {
			case 0x01:		// CTRL+A
				showAboutAppleCommander();
				break;
			case 0x03:		// CTRL+C
				createDiskImage();
				break;
			case 0x0f:		// CTRL+O
				openFile();
				break;
			case 0x05:		// CTRL+E
				compareDiskImages();
				break;
		}
	}		
}
 
Example 12
Project: Hydrograph   File: ComponentSearchUtility.java   View source code 6 votes vote down vote up
private Object createCommentBox(Event event) {
	CommentBox commentBox = null;
	editor = (ELTGraphicalEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
			.getActiveEditor();
	if (editor != null) {
		Container container = editor.getContainer();
		checkComponentCoordinates(event, container);
		org.eclipse.draw2d.geometry.Point point = new org.eclipse.draw2d.geometry.Point(event.x, event.y);
		commentBox = new CommentBox(LABEL);
		commentBox.setSize(new Dimension(300, 60));
		commentBox.setLocation(point);
		CommentBoxCommand command = new CommentBoxCommand(commentBox, LABEL, container);
		command.execute();
	}
	return commentBox;
}
 
Example 13
Project: BiglyBT   File: SpeedTestPanel.java   View source code 6 votes vote down vote up
@Override
public void handleEvent(Event event) {
    //same action as "cancel" button.
    cancel();
    test.setEnabled(true);
    abort.setEnabled(false);
    encryptToggle.setEnabled(true);
    wizard.setNextEnabled(false);
    uploadTest=0;
    downloadTest=0;

    String testAbortedManually = MessageText.getString("SpeedTestWizard.test.panel.aborted");
    wizard.setErrorMessage(testAbortedManually);
    reportStage("\n"+testAbortedManually);

}
 
Example 14
Project: Hydrograph   File: ELTCheckFileExtensionListener.java   View source code 6 votes vote down vote up
@Override
public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar,ListenerHelper helpers, Widget... widgets) {
	final Widget[] widgetList = widgets;
			
	Listener listener=new Listener() { 
		@Override
		public void handleEvent(Event event) {
			if(!((Button)widgetList[1]).getSelection()){
			ControlDecoration	fieldNameMustJava = WidgetUtility.addDecorator((Text)widgetList[0],Messages.INVALID_FILE);
			if(!WidgetUtility.isFileExtention((((Text)widgetList[0]).getText()).trim(), ".java") && !(((Text)widgetList[0]).getText().trim().isEmpty())){
				fieldNameMustJava.show();
			((Text)widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255,
					255, 204));
			}
				else  
				{   
					((Text)widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255,
						255, 255));
				fieldNameMustJava.hide(); 
				}
			}
		} 
	};
	return listener;
}
 
Example 15
Project: Hydrograph   File: ELTCreateNewClassListener.java   View source code 6 votes vote down vote up
@Override
public Listener getListener(final PropertyDialogButtonBar propertyDialogButtonBar, final ListenerHelper helpers, Widget... widgets) {
	final Widget[] widgetList = widgets;
	
	if (helpers != null) {
		widgetConfig = (WidgetConfig) helpers.get(HelperType.WIDGET_CONFIG);
	}
	
	 Listener listener=new Listener() {
		@Override
		public void handleEvent(Event event) {
			String comboValue = ((Combo) widgetList[0]).getText();
			if (comboValue.equals(Messages.CUSTOM)) {
				FilterOperationClassUtility.INSTANCE.createNewClassWizard((Text) widgetList[1], widgetConfig);
				if(helpers.get(HelperType.OPERATION_CLASS_DIALOG_OK_CONTROL) instanceof OperationClassDialog)
				{
					OperationClassDialog operationClassDialog=(OperationClassDialog)helpers.get(HelperType.OPERATION_CLASS_DIALOG_OK_CONTROL);
					operationClassDialog.getShell().setFocus();
				}
					
				propertyDialogButtonBar.enableApplyButton(true);
			}
		}
	};
	return listener;
}
 
Example 16
Project: gw4e.project   File: EdgeDefaultSection.java   View source code 6 votes vote down vote up
public void handleEvent(Event e) {
	if (!notification)
		return;
	EdgeGW4EEditPartProperties properties = (EdgeGW4EEditPartProperties) node
			.getAdapter(IPropertySource.class);
	textDependencyDecorator.hide();
	String value = textDependency.getText();
	if (value != null && value.trim().length() > 0) {
		try {
			Integer d = Integer.parseInt(value.trim());
			if (d<0 || d>100) {
				throw new NumberFormatException();
			}
			properties.setPropertyValue(ModelProperties.PROPERTY_EDGE_DEPENDENCY, value.trim());
		} catch (NumberFormatException ex) {
			textDependencyDecorator.show();
		}
	}
}
 
Example 17
Project: Hydrograph   File: FocusInListener.java   View source code 6 votes vote down vote up
@Override
public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper, Widget... widgets) {
	final Widget[] widgetList = widgets;
	if (helper != null){
		txtDecorator = (ControlDecoration) helper.get(HelperType.CONTROL_DECORATION);
	}
	
	Listener listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			String charSet = ((Text) widgetList[0]).getText().trim();
			if(SWT.FocusIn == event.type) {
				if (StringUtils.isBlank(charSet)) {
					txtDecorator.show();
					((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255));
					((Text) widgetList[0]).setToolTipText(txtDecorator.getDescriptionText());
				} else {
					txtDecorator.hide();
				}
			}
		}
	};
	return listener;
}
 
Example 18
Project: BiglyBT   File: UISWTStatusEntryImpl.java   View source code 6 votes vote down vote up
@Override
public void created(final MainStatusBar.CLabelPadding label) {
	final Listener click_listener = new Listener() {
		@Override
		public void handleEvent(Event e) {
			onClick();
		}
	};

	Utils.execSWTThread(new AERunnable() {
		@Override
		public void runSupport() {
			label.addListener(SWT.MouseDoubleClick, click_listener);
		}
	}, true);
}
 
Example 19
Project: Hydrograph   File: ELTSchemaDialogSelectionListener.java   View source code 6 votes vote down vote up
@Override
public Listener getListener(final PropertyDialogButtonBar propertyDialogButtonBar,
		ListenerHelper helpers, final Widget... widgets) {
	final Button button = ((Button)widgets[0]);
	button.getShell();
	if(helpers != null){
		txtDecorator = (ControlDecoration) helpers.get(HelperType.CONTROL_DECORATION);
		file_extension=(String)helpers.get(HelperType.FILE_EXTENSION);
	}
	
	Listener listener=new Listener() {
		@Override
		public void handleEvent(Event event) {
			if(event.type==SWT.Selection){
				FilterOperationClassUtility.INSTANCE.browseFile(file_extension,((Text) widgets[0]));
					propertyDialogButtonBar.enableApplyButton(true);
					txtDecorator.hide();
			}
		}
	};
	return listener;
}
 
Example 20
Project: SWET   File: TipDayEx.java   View source code 6 votes vote down vote up
private void buildLeftColumn() {
	final Composite composite = new Composite(this.shell, SWT.NONE);
	final GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, false,
			true, 1, 1);
	composite.setLayoutData(gd);
	final FillLayout compositeLayout = new FillLayout();
	compositeLayout.marginWidth = 2;
	composite.setLayout(compositeLayout);
	final Label label = new Label(composite, SWT.NONE);
	if (this.image == null) {
		this.image = new Image(display, this.getClass().getClassLoader()
				.getResourceAsStream("images/document_wrench_color.png"));
		shell.addListener(SWT.Close, new Listener() {
			@Override
			public void handleEvent(Event event) {
				image.dispose();
			}
		});

	}
	label.setImage(this.image);
}
 
Example 21
Project: SWET   File: TipDayEx.java   View source code 6 votes vote down vote up
private void buildLeftColumn() {
	final Composite composite = new Composite(this.shell, SWT.NONE);
	final GridData gd = new GridData(GridData.FILL, GridData.BEGINNING, false,
			true, 1, 1);
	composite.setLayoutData(gd);
	final FillLayout compositeLayout = new FillLayout();
	compositeLayout.marginWidth = 2;
	composite.setLayout(compositeLayout);
	final Label label = new Label(composite, SWT.NONE);
	if (this.image == null) {
		this.image = new Image(display, this.getClass().getClassLoader()
				.getResourceAsStream("images/light1.png"));
		shell.addListener(SWT.Close, new Listener() {
			@Override
			public void handleEvent(Event event) {
				image.dispose();
			}
		});

	}
	label.setImage(this.image);
}
 
Example 22
Project: Hydrograph   File: PropertyDialogBuilder.java   View source code 6 votes vote down vote up
private void attachMouseScrollButtonListener(final ScrolledComposite scrolledComposite){
	scrolledComposite.addListener(SWT.MouseWheel, new Listener() {
		@Override
		public void handleEvent(Event event) {
			int wheelCount = event.count;
			wheelCount = (int) Math.ceil(wheelCount / 3.0f);
			while (wheelCount < 0) {
				scrolledComposite.getVerticalBar().setIncrement(4);
				wheelCount++;
			}

			while (wheelCount > 0) {
				scrolledComposite.getVerticalBar().setIncrement(-4);
				wheelCount--;
			}
		}
	});
}
 
Example 23
Project: Hydrograph   File: MouseActionListener.java   View source code 5 votes vote down vote up
@Override
public Listener getListener(
		final PropertyDialogButtonBar propertyDialogButtonBar,
		final ListenerHelper helpers, final Widget... widgets) {
	Listener listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			mouseAction(propertyDialogButtonBar,helpers,event,widgets);
		}
	};
	return listener;
}
 
Example 24
Project: Hydrograph   File: ELTSelectionTaskListener.java   View source code 5 votes vote down vote up
@Override
public Listener getListener(
		final PropertyDialogButtonBar propertyDialogButtonBar,
		final ListenerHelper helper, final Widget... widgets) {

	Listener listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			selectionListenerAction(propertyDialogButtonBar,helper, widgets);
		}
	};
	return listener;
}
 
Example 25
Project: Hydrograph   File: MouseDownSchemaGridListener.java   View source code 5 votes vote down vote up
@Override
public void mouseAction(PropertyDialogButtonBar propertyDialogButtonBar,
		ListenerHelper helpers, Event event, Widget... widgets) {
	 Table table=(Table)widgets[0];
	 Label label=(Label)event.widget;
	 Event e = new Event();
        e.item = (TableItem) label.getData("_TABLEITEM");
        table.setSelection(new TableItem[] { (TableItem) e.item });
        table.notifyListeners(SWT.Selection, e);
}
 
Example 26
Project: n4js   File: TestResultsView.java   View source code 5 votes vote down vote up
@Override
protected Composite createToolTipContentArea(final Event event, final Composite parent) {
	final Object layoutData = parent.getLayoutData();
	final StyledText text = lastDescriptor.toStyledText(parent, NONE);
	if (layoutData instanceof GridData) {
		((GridData) layoutData).heightHint = text.getBounds().height;
		((GridData) layoutData).widthHint = text.getBounds().width;
	}
	return parent;
}
 
Example 27
Project: n4js   File: SpecConfigAdocPage.java   View source code 5 votes vote down vote up
private void selectDocRoot(Event e) {
	switch (e.type) {
	case SWT.Selection:
		DirectoryDialog dialog = new DirectoryDialog(Display.getCurrent().getActiveShell(), SWT.OPEN | SWT.MULTI);
		dialog.setText("Select the documentation root directory");
		String result = dialog.open();
		if (result != null && !result.isEmpty()) {
			txtDocRootDirName.setText(result);
			saveProperty(result);
			checkPageComplete();
		}
		break;
	}
}
 
Example 28
Project: Hydrograph   File: JoinInputCountFocusOutListener.java   View source code 5 votes vote down vote up
@Override
public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers,
		Widget... widgets) {
	final Widget[] widgetList = widgets;
	if (helpers != null) {
		if (helpers.get(HelperType.MINIMUM_PORT_COUNT) != null){
			minimunPortCount = Integer.valueOf((String) helpers.get(HelperType.MINIMUM_PORT_COUNT));
		}
		currentComponent = (Component) helpers.get(HelperType.CURRENT_COMPONENT);
	}
	Listener listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			if (event.type == SWT.FocusOut) {
				Text textBox = (Text) widgetList[0];
				String textBoxValue = ((Text) event.widget).getText();
				if(StringUtils.isNotBlank(textBoxValue) && StringUtils.isNumeric(textBoxValue)){
					if ((Integer.parseInt(textBoxValue) < minimunPortCount || Integer.parseInt(textBoxValue) > 25)
							&& currentComponent.getProperties().get(Constants.UNUSED_AND_INPUT_PORT_COUNT_PROPERTY) != null){
							textBox.setText((String) currentComponent.getProperties().get(
									Constants.UNUSED_AND_INPUT_PORT_COUNT_PROPERTY));
					}
				}
			}
		}
	};
	return listener;
}
 
Example 29
Project: Hydrograph   File: OperationClassComboChangeListener.java   View source code 5 votes vote down vote up
@Override
public Listener getListener(final PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers,
		Widget... widgets) {
	final Widget[] widgetList = widgets;

	Listener listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			String comboValue = ((Combo) widgetList[0]).getText();
			propertyDialogButtonBar.enableApplyButton(true);
			if (Messages.CUSTOM.equalsIgnoreCase(comboValue) && !FilterOperationClassUtility.INSTANCE.isCheckBoxSelected()) {
				((Text) widgetList[1]).setText("");
				((Text) widgetList[1]).setEnabled(true);
				FilterOperationClassUtility.INSTANCE.enableAndDisableButtons(true, false);
			} else {
				if(FilterOperationClassUtility.INSTANCE.isCheckBoxSelected())
				{
					MessageBox messageBox = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK);
					messageBox.setText(Messages.ERROR);
					messageBox.setMessage(Messages.CHECKBOX_DISABLE_MESSAGE);
					if (messageBox.open() == SWT.OK) {
						((Combo) widgetList[0]).setText(Messages.CUSTOM);
					} 
				}
				else
				{
					FilterOperationClassUtility.INSTANCE.setOperationClassNameInTextBox(comboValue, (Text)widgetList[1]);
					((Text) widgetList[1]).setEnabled(false);
					FilterOperationClassUtility.INSTANCE.enableAndDisableButtons(false, false);
					((Button) widgetList[2]).setEnabled(false);
				}
			}
		} 
	};
	return listener;
}
 
Example 30
Project: pandionj   File: InvocationWidget.java   View source code 5 votes vote down vote up
public void handleEvent(Event event) {
	switch (event.detail) {
	case SWT.TRAVERSE_ESCAPE:
		shell.setVisible(false);
		event.detail = SWT.TRAVERSE_NONE;
		event.doit = false;
		break;
	}
}
 
Example 31
Project: Hydrograph   File: DelimiterFocusOutListener.java   View source code 5 votes vote down vote up
@Override
public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper,
		Widget... widgets) {
	final Widget[] widgetList = widgets;
	if (helper != null) {
		txtDecorator = (ControlDecoration) helper.get(HelperType.CONTROL_DECORATION);
		txtDecorator.hide();
	}

	Listener listener = new Listener() {

		@Override
		public void handleEvent(Event event) {
			String charSet = ((Text) widgetList[0]).getText();
			if (SWT.FocusOut == event.type) {
				if (StringUtils.isEmpty(charSet)){
					txtDecorator.show();
					((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204));
					((Text) widgetList[0]).setToolTipText(txtDecorator.getDescriptionText());
				} else {
					txtDecorator.hide();
				}
			} 
		}
	};
	return listener;
}
 
Example 32
Project: Hydrograph   File: VerifyNumbericOrParameterFocusInListener.java   View source code 5 votes vote down vote up
@Override
public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helper,  Widget... widgets) {
	final Widget[] widgetList = widgets;
		Listener listener=new Listener() {
			@Override
			public void handleEvent(Event event) {
				String string=((Text) widgetList[0]).getText().trim();
				Matcher matchs=Pattern.compile("[\\d]*").matcher(string);
				if(!matchs.matches() && StringUtils.isNotBlank(string)){
					((Text) widgetList[0]).setText(string.replace("@{", "").replace("}", ""));
				}
			}
		};
	return listener;
}
 
Example 33
Project: Hydrograph   File: ComponentSearchUtility.java   View source code 5 votes vote down vote up
/**
 * @param triggerChar
 */
private void activateAssist(char triggerChar) {
	assistText.setText(triggerChar + "");
	assistText.setSelection(assistText.getText().length());

	Event event = new Event();
	event.character = triggerChar;
	assistText.notifyListeners(SWT.KeyDown, event);
	assistText.notifyListeners(SWT.Modify, event);
}
 
Example 34
Project: Hydrograph   File: KeyDownSchemaGridListener.java   View source code 5 votes vote down vote up
@Override
public void mouseAction(PropertyDialogButtonBar propertyDialogButtonBar,
		ListenerHelper helpers, Event event, Widget... widgets) {
	Table table=(Table)event.widget;
	   Shell tip=(Shell) table.getData("tip");
	   Label label=(Label) table.getData("label");
	if(tip!=null) 
	{
	 tip.dispose();
        tip = null;
        label = null;
	}
}
 
Example 35
Project: BiglyBT   File: ExclusiveSelectionActionPerformer.java   View source code 5 votes vote down vote up
@Override
public void performAction() {
  if(buttons == null)
    return;
  if(!selected)
    return;
  for(int i = 0 ; i < buttons.length ; i++) {
    buttons[i].setSelection(false);
    buttons[i].notifyListeners(SWT.Selection,new Event());
  }
}
 
Example 36
Project: BiglyBT   File: PeersViewBase.java   View source code 5 votes vote down vote up
@Override
public void
handleEvent(
		Event e)
{
	if ( !run( peers )){

		for ( PEPeer peer: peers ){

			run( peer );
		}
	}
}
 
Example 37
Project: convertigo-eclipse   File: ProjectSchemaWizardPage.java   View source code 5 votes vote down vote up
public void createControl(Composite parent) {
	Composite container = new Composite(parent, SWT.NULL);
	GridLayout layout = new GridLayout();
	container.setLayout(layout);
	layout.numColumns = 2;
	layout.verticalSpacing = 9;

	Label label = new Label(container, SWT.NULL);
	label.setText("&Project:");
	
	tree = new Tree(container, SWT.SINGLE | SWT.BORDER);
	tree.setHeaderVisible(false);
	GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
	gridData.verticalSpan = 20;
	gridData.horizontalSpan = 2;
	tree.setLayoutData(gridData);		
	tree.addListener(SWT.Selection, new Listener() {
		public void handleEvent(final Event event) {
			TreeItem item = (TreeItem) event.item;
			projectName = item.getText();
			dialogChanged();
		}
	});
	tree.setVisible(false);
	
	initialize();
	setControl(container);
	dialogChanged();
}
 
Example 38
Project: BiglyBT   File: ShellManager.java   View source code 5 votes vote down vote up
/**
 * <p>Invokes the handleEvent method specified by the SWT listener for each managed shell</p>
 * <p>The event's widget is set to the reference of the shell invoking it</p>
 * @param command A command implemented as a SWT Listener
 */
public final void performForShells(final Listener command)
{
    Iterator iter = shells.iterator();
    for(int i = 0; i < shells.size(); i++)
    {
        Shell aShell = (Shell)iter.next();
        Event evt = new Event();
        evt.widget = aShell;
        evt.data = this;
        command.handleEvent(evt);
    }
}
 
Example 39
Project: Hydrograph   File: VerifyNumericAndParameterListener.java   View source code 5 votes vote down vote up
@Override
public Listener getListener(PropertyDialogButtonBar propertyDialogButtonBar, ListenerHelper helpers,
		Widget... widgets) {
	final Widget[] widgetList = widgets;
	if (helpers != null) {
		txtDecorator = (ControlDecoration) helpers.get(HelperType.CONTROL_DECORATION);
	}

	Listener listener = new Listener() {
		@Override
		public void handleEvent(Event event) {
			String string = ((Text) widgetList[0]).getText();
			if (event.type == SWT.Modify) {
				if (StringUtils.isNotBlank(string)) {
					Matcher matchs = Pattern.compile(Constants.PORT_VALIDATION_REGEX).matcher(string);
					if (matchs.matches()|| ParameterUtil.isParameter(string)) {
						txtDecorator.hide();
						((Text) widgetList[0]).setToolTipText("");
						((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255));
					} else {
						txtDecorator.show();
						txtDecorator.setDescriptionText(Messages.PORT_VALIDATION_ERROR);
						((Text) widgetList[0]).setToolTipText(txtDecorator.getDescriptionText());
						((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255));
					}
				} else {
					txtDecorator.show();
					((Text) widgetList[0]).setToolTipText(txtDecorator.getDescriptionText());
					((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204));

				}
			}else{
				txtDecorator.hide();
				((Text) widgetList[0]).setToolTipText("");
				((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255));
			}
		}
	};
	return listener;
}
 
Example 40
Project: RxSWT   File: SwtObservables.java   View source code 5 votes vote down vote up
public static Observable<Event> displayFilter(Display display, int eventType) {
	checkNotNull(display, "display == null");
	return new DisplayObservable(display, eventType) {

		@Override
		protected void addlistener(Listener listener) {
			display.addFilter(eventType, listener);
		}
	};
}