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: AgentWorkbench   File: ProjectNewOpen.java   Source Code and License 7 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 2
Project: Hydrograph   File: ComponentSearchUtility.java   Source Code and License 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 3
Project: n4js   File: TestResultsView.java   Source Code and License 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 4
Project: ide-plugins   File: PluginsSWT.java   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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);
		}
	};
}
 
Example 41
Project: RxSWT   File: WidgetObservable.java   Source Code and License 5 votes vote down vote up
@Override
protected void subscribeActual(Observer<? super Event> observer) {
	if (!Preconditions.checkWidget(observer, widget)) {
		return;
	}
	WidgetListener listener = new WidgetListener(widget, eventType, observer);
	observer.onSubscribe(listener);
	widget.addDisposeListener(e -> listener.dispose());
	widget.addListener(eventType, listener);
}
 
Example 42
Project: xcalendar   File: AbstractXCalendarEventHandler.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
@Override
public final boolean handle(Context ctx, Event event) {
	final XCalendarEventHandler focus = ctx.getFocus();
	if (focus != null && focus != this) return false;
	return !accepts(ctx, event) ? false : process(ctx, event);
}
 
Example 43
Project: Hydrograph   File: ELTMouseDoubleClickListener.java   Source Code and License 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) {
			mouseDoubleClickAction(propertyDialogButtonBar,helpers, widgets);
		}
		};
return listener;
}
 
Example 44
Project: AppleCommander   File: DiskExplorerTab.java   Source Code and License 5 votes vote down vote up
/**
 * Create the keyboard handler for the file pane.
 * These are keys that are <em>only</em> active in the file
 * viewer.  See createToolbarCommandHandler for the general application
 * keyboard handler.  
 * @see #createToolbarCommandHandler
 */
private Listener createFileKeyboardHandler() {
	return new Listener() {
		public void handleEvent(Event event) {
			FileEntry fileEntry = getSelectedFileEntry();
			if (fileEntry != null && event.type == SWT.KeyUp && (event.stateMask & SWT.CTRL) != 0) {
				switch (event.character) {
					case CTRL_C:	// Compile Wizard
						if (getCompileToolItem().isEnabled()) {
							compileFileWizard();
						}
						break;
					case CTRL_D:	// Delete file
						if (getDeleteToolItem().isEnabled()) {
							deleteFile();
						}
						break;
					case CTRL_E:	// Export Wizard
						exportFileWizard();
						break;
					case CTRL_V:	// View file
						viewFile(null);
						break;
				}		
			}
		}
	};
}
 
Example 45
Project: BiglyBT   File: ListenerNeedingCoreRunning.java   Source Code and License 5 votes vote down vote up
@Override
public final void handleEvent(final Event event) {
	CoreWaiterSWT.waitForCoreRunning(new CoreRunningListener() {
		@Override
		public void coreRunning(Core core) {
			handleEvent(core, event);
		}
	});
}
 
Example 46
Project: gw4e.project   File: GeneratorChoiceComposite.java   Source Code and License 5 votes vote down vote up
private void createAppendMode() {
	btnAppendRadioButton = new Button(this, SWT.RADIO);
	btnAppendRadioButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 12, 1));
	btnAppendRadioButton.setText(MessageUtil.getString("append_mode"));
	btnAppendRadioButton.setSelection(true);
	btnAppendRadioButton.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event e) {
			switch (e.type) {
			case SWT.Selection:
				updateUI();
				break;
			}
		}
	});
	btnAppendRadioButton.setData(GW4E_CONVERSION_WIDGET_ID, GW4E_APPEND_CHECKBOX);

	Composite composite = new Composite(this, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 12, 1));
	composite.setLayout(new GridLayout(12, false));

	lblAppendClassNameLabel = new Label(composite, SWT.NONE);
	lblAppendClassNameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 4, 1));
	lblAppendClassNameLabel.setText("Class name");

	comboAppendClassnameViewer = new AncestorViewer(composite);
	comboAppendClassnameViewer.initialize(GW4E_CONVERSION_COMBO_ANCESTOR_EXTEND_TEST, false);
	comboAppendClassnameViewer.getCombo().setData(GW4E_CONVERSION_WIDGET_ID, GW4E_CONVERSION_COMBO_ANCESTOR_APPEND_TEST);
	Combo combo = comboAppendClassnameViewer.getCombo();
	combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 8, 1));
	combo.setEnabled(true);
}
 
Example 47
Project: avro-schema-editor   File: AvroSchemaViewerDropPolicy.java   Source Code and License 5 votes vote down vote up
protected void openPopupMenu(List<DragAndDropPolicy.Action> availableActions,
		final AvroNode sourceNode, final AvroNode targetNode, final TargetPosition position) {
	
	Shell shell = Display.getCurrent().getActiveShell();
	final Menu menu = new Menu(shell, SWT.POP_UP);
	
	for (DragAndDropPolicy.Action availableAction : availableActions) {
		final DragAndDropPolicy.Action action = availableAction;
		MenuItem item = new MenuItem(menu, SWT.PUSH);
		item.setText(action.getLabel());
		item.addListener(SWT.Selection, new Listener() {
			public void handleEvent(Event e) {
				menu.dispose();
				IEditCommand cmd = context.getService(IEditCommandFactory.class)
						.createDnDElementCommand(action, sourceNode, targetNode, position, Notifications.NOT_REF);					
				if (cmd != null) {	
					context.getService(ICommandExecutor.class).execute(cmd);
				}
			}
		});
	}
       
	java.awt.Point location = MouseInfo.getPointerInfo().getLocation();
	int x = location.x;
	int y = location.y;
       menu.setLocation(x, y);
       menu.setVisible(true);
       
}
 
Example 48
Project: Hydrograph   File: DelimiterModifyListener.java   Source Code and License 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);
	}
	Listener listener=new Listener() {

		@Override
		public void handleEvent(Event event) {
			
			String string=((Text)widgetList[0]).getText();
			if(event.type==SWT.Modify){ 
				if(StringUtils.isEmpty(string)){
					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));
				}

			}else{
				txtDecorator.hide();
				((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 255));
			}
		}		
	};

	return listener;
}
 
Example 49
Project: BiglyBT   File: SpeedGraphic.java   Source Code and License 5 votes vote down vote up
@Override
 protected void
 addMenuItems(
Menu	menu )
 {
  new MenuItem( menu, SWT.SEPARATOR );
  
  MenuItem mi_reset = new MenuItem( menu, SWT.PUSH );

  mi_reset.setText(  MessageText.getString( "label.clear.history" ));

  mi_reset.addListener(SWT.Selection, new Listener() {
	  @Override
	  public void handleEvent(Event e) {
		  try{
		   	this_mon.enter();
		   	
		   	nbValues		= 0;
		   	currentPosition	= 0;
	 		
		   	for ( int i=0;i<all_values.length;i++ ){
		   		all_values[i] = new int[all_values[i].length];
		   	}	
		  }finally{
			  
			this_mon.exit();
		  }
		  
		  refresh( true );
	  }
  });
 }
 
Example 50
Project: gw4e.project   File: EdgeDefaultSection.java   Source Code and License 5 votes vote down vote up
public void handleEvent(Event e) {
	txtNameDecorator.hide();
	if (!notification)
		return;
	EdgeGW4EEditPartProperties properties = (EdgeGW4EEditPartProperties) node
			.getAdapter(IPropertySource.class);
	String value = textName.getText();
	if (!JDTManager.validateClassName(value.trim())) {
		txtNameDecorator.show();
		return;
	}
	properties.setPropertyValue(ModelProperties.PROPERTY_NAME, value);
}
 
Example 51
Project: BiglyBT   File: PingGraphic.java   Source Code and License 5 votes vote down vote up
@Override
 protected void
 addMenuItems(
Menu	menu )
 {
  new MenuItem( menu, SWT.SEPARATOR );
  
  MenuItem mi_reset = new MenuItem( menu, SWT.PUSH );

  mi_reset.setText(  MessageText.getString( "label.clear.history" ));

  mi_reset.addListener(SWT.Selection, new Listener() {
	  @Override
	  public void handleEvent(Event e) {
		  try{
		   	this_mon.enter();
		   	
		   	nbValues		= 0;
		   	currentPosition	= 0;
		   		
		   	for ( int i=0;i<all_values.length;i++ ){
		   		all_values[i] = new int[all_values[i].length];
		   	}
		  }finally{
			  
			this_mon.exit();
		  }
		  
		  refresh( true );
	  }
  });
 }
 
Example 52
Project: gw4e.project   File: VertexDefaultSection.java   Source Code and License 5 votes vote down vote up
public void handleEvent(Event e) {
	if (!notification)
		return;
	switch (e.type) {
	case SWT.Selection:
		GW4EVertexEditPartProperties properties = (GW4EVertexEditPartProperties) sectionProvider
				.getAdapter(IPropertySource.class);
		properties.setPropertyValue(ModelProperties.PROPERTY_VERTEX_SHARED, btnCheckShrd.getSelection());
		break;
	}
}
 
Example 53
Project: Hydrograph   File: ModifyAlphaNumbericTextListener.java   Source Code and License 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 (StringUtils.isNotBlank(string)) {
				Matcher matchs=Pattern.compile(Constants.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.setDescriptionText(Messages.FIELDNAME_NOT_ALPHANUMERIC_ERROR);
				((Text) widgetList[0]).setToolTipText(txtDecorator.getDescriptionText());
				txtDecorator.show();
			}
		}else{
			((Text) widgetList[0]).setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry( 255, 255, 204));
			txtDecorator.setDescriptionText(Messages.FIELDNAME_NOT_ALPHANUMERIC_ERROR);
			((Text) widgetList[0]).setToolTipText(txtDecorator.getDescriptionText());
			txtDecorator.show();
		}
	}
	};
return listener;
}
 
Example 54
Project: gw4e.project   File: GraphElementProperties.java   Source Code and License 5 votes vote down vote up
protected void selectTab(SWTBotGefEditPart part, String label) {
	selectPart(part);
	Matcher<TabbedPropertyList> matcher = new BaseMatcher<TabbedPropertyList>() {
		@Override
		public boolean matches(Object item) {
			if (item instanceof TabbedPropertyList) {
				return true;
			}
			return false;
		}
		@Override
		public void describeTo(Description description) {
		}
	};
	List<TabbedPropertyList> allWidgets = widget(matcher);
	UIThreadRunnable.syncExec(Display.getDefault(), new VoidResult() {
		@Override
		public void run() {
			for (final TabbedPropertyList tabbedProperty : allWidgets) {
				final ListElement tabItem = getTabItem(label, tabbedProperty);
				if (tabItem != null) {
					final Event mouseEvent = createEvent(tabItem);
					tabItem.notifyListeners(SWT.MouseUp, mouseEvent);
					tabItem.setFocus();
					return;
				}
			}
			throw new IllegalStateException("Unable to select the tab " + label);
		}
	});
}
 
Example 55
Project: gw4e.project   File: GraphElementProperties.java   Source Code and License 5 votes vote down vote up
protected Event createEvent(Control control) {
	Event evt = new Event();
	evt.widget = control;
	evt.x = control.getBounds().x;
	evt.y = control.getBounds().y;
	evt.display = bot.getDisplay();
	evt.count = 1;
	evt.button = 1;
	evt.stateMask = SWT.BUTTON1;
	evt.time = (int) System.currentTimeMillis();
	return evt;
}
 
Example 56
Project: gw4e.project   File: GraphElementProperties.java   Source Code and License 5 votes vote down vote up
protected Event createFocusEvent(Control control) {
	Event evt = new Event();
	evt.widget = control;
	evt.x = control.getBounds().x;
	evt.y = control.getBounds().y;
	evt.display = bot.getDisplay();
	 
	evt.time = (int) System.currentTimeMillis();
	return evt;
}
 
Example 57
Project: gw4e.project   File: OutLineView.java   Source Code and License 5 votes vote down vote up
private Event createEvent(Control control) {
	Event evt = new Event();
	evt.widget = control;
	evt.x = control.getBounds().x;
	evt.y = control.getBounds().y;
	evt.display = bot.getDisplay();
	evt.count = 1;
	evt.button = 1;
	evt.stateMask = SWT.BUTTON1;
	evt.time = (int) System.currentTimeMillis();
	return evt;
}
 
Example 58
Project: BiglyBT   File: DirectoryParameter.java   Source Code and License 5 votes vote down vote up
public
DirectoryParameter(
	final Composite pluginGroup,
	String			name,
	String			defaultValue )
{
 	super(name);
  	controls = new Control[2];

    sp = new StringParameter(pluginGroup, name, defaultValue);

    controls[0] = sp.getControl();
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    controls[0].setLayoutData(gridData);

    Button browse = new Button(pluginGroup, SWT.PUSH);
    ImageLoader.getInstance().setButtonImage(browse, getBrowseImageResource());
    browse.setToolTipText(MessageText.getString("ConfigView.button.browse"));

    browse.addListener(SWT.Selection, new Listener() {
      @Override
      public void handleEvent(Event event) {
    	  String path = DirectoryParameter.this.openDialog(pluginGroup.getShell(), sp.getValue());
    	  if (path != null) {
    		  sp.setValue(path);
    	  }
      }
    });
    controls[1] = browse;
  }
 
Example 59
Project: applecommander   File: FileViewerWindow.java   Source Code and License 5 votes vote down vote up
/**
 * The toolbar command handler contains the global toolbar
 * actions. The intent is that the listener is then added to 
 * multiple visual components.
 */
public Listener createToolbarCommandHandler() {
	return new Listener() {
		public void handleEvent(Event event) {
			if (event.type == SWT.KeyUp) {
				if ((event.stateMask & SWT.CTRL) != 0) {	// CTRL+key
					switch (event.character) {
						case CTRL_C:
							getContentTypeAdapter().copy();
							break;
						case CTRL_A:
							getContentTypeAdapter().selectAll();
							break;
						case CTRL_P:
							getContentTypeAdapter().print();
							break;
					}
				} else if ((event.stateMask & SWT.ALT) == 0) { // key alone
					switch (event.keyCode) {
						case SWT.F2:	// the "native" file format (image, text, etc)
							getNativeFilterAdapter().display();
							setFilterToolItemSelection(true, false, false);
							break;
						case SWT.F3:	// Hex format
							getHexFilterAdapter().display();
							setFilterToolItemSelection(false, true, false);
							break;
						case SWT.F4:	// "Raw" hex format
							getRawDumpFilterAdapter().display();
							setFilterToolItemSelection(false, false, true);
							break;
					}
				}
			}
		}
	};
}
 
Example 60
Project: applecommander   File: DiskExplorerTab.java   Source Code and License 5 votes vote down vote up
/**
 * Create the keyboard handler for the file pane.
 * These are keys that are <em>only</em> active in the file
 * viewer.  See createToolbarCommandHandler for the general application
 * keyboard handler.  
 * @see #createToolbarCommandHandler
 */
private Listener createFileKeyboardHandler() {
	return new Listener() {
		public void handleEvent(Event event) {
			FileEntry fileEntry = getSelectedFileEntry();
			if (fileEntry != null && event.type == SWT.KeyUp && (event.stateMask & SWT.CTRL) != 0) {
				switch (event.character) {
					case CTRL_C:	// Compile Wizard
						if (getCompileToolItem().isEnabled()) {
							compileFileWizard();
						}
						break;
					case CTRL_D:	// Delete file
						if (getDeleteToolItem().isEnabled()) {
							deleteFile();
						}
						break;
					case CTRL_E:	// Export Wizard
						exportFileWizard();
						break;
					case CTRL_V:	// View file
						viewFile(null);
						break;
				}		
			}
		}
	};
}