Java Code Examples for org.eclipse.swt.widgets.Label#addListener()

The following examples show how to use org.eclipse.swt.widgets.Label#addListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XViewerCustomizeDialog.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void createColumnFilterTextBlock(final Composite composite) {
   // Filter text block
   final Composite composite_8 = new Composite(composite, SWT.NONE);
   composite_8.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
   final GridLayout gridLayout_14 = new GridLayout();
   gridLayout_14.numColumns = 3;
   composite_8.setLayout(gridLayout_14);

   final Label columnFilterLabel = new Label(composite_8, SWT.NONE);
   columnFilterLabel.setText(XViewerText.get("XViewerCustomizeDialog.filter.column")); //$NON-NLS-1$

   columnFilterText = new Text(composite_8, SWT.BORDER);
   columnFilterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

   final Label clearColumnFilterLabel = new Label(composite_8, SWT.PUSH);
   clearColumnFilterLabel.setImage(XViewerLib.getImage("clear.gif")); //$NON-NLS-1$
   clearColumnFilterLabel.addListener(SWT.MouseUp, e -> columnFilterText.setText("")); //$NON-NLS-1$
}
 
Example 2
Source File: XViewerCustomizeDialog.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void createFilterTextBlock(final Composite composite) {
   // Filter text block
   final Composite composite_7 = new Composite(composite, SWT.NONE);
   composite_7.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
   final GridLayout gridLayout_13 = new GridLayout();
   gridLayout_13.numColumns = 5;
   composite_7.setLayout(gridLayout_13);

   final Label filterLabel = new Label(composite_7, SWT.NONE);
   filterLabel.setText(XViewerText.get("XViewerCustomizeDialog.filter.text")); //$NON-NLS-1$

   filterText = new Text(composite_7, SWT.BORDER);
   filterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

   Label filterLabel2 = new Label(composite_7, SWT.NONE);
   filterLabel2.setText(XViewerText.get("XViewerCustomizeDialog.filter.expression")); //$NON-NLS-1$

   filterRegExCheckBox = new Button(composite_7, SWT.CHECK);
   filterRegExCheckBox.setLayoutData(new GridData(SWT.RIGHT, SWT.NONE, false, false));

   final Label clearFilterLabel = new Label(composite_7, SWT.PUSH);
   clearFilterLabel.setImage(XViewerLib.getImage("clear.gif")); //$NON-NLS-1$
   clearFilterLabel.addListener(SWT.MouseUp, e -> filterText.setText("")); //$NON-NLS-1$

}
 
Example 3
Source File: DateChooser.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates the grid of labels displaying the days numbers. The grid is composed
 * of a header row, displaying days initials, and 6 row for the days numbers.
 * All labels are empty (no text displayed), the content depending of both the
 * locale (for first day of week) and the current displayed month.
 */
private void createGrid() {
	// Master grid panel
	gridPanel = new Composite(this, SWT.NONE);
	gridLayout = new DateChooserLayout();
	gridPanel.setLayout(gridLayout);
	gridPanel.addListener(SWT.Paint, listener);

	// Weeks numbers panel
	weeksPanel = new Composite(gridPanel, SWT.NONE);
	weeks = new Cell[6];
	for (int i = 0; i < 6; i++) {
		weeks[i] = new Cell(weeksPanel, i);
	}

	// Grid header panel
	headersPanel = new Composite(gridPanel, SWT.NONE);
	headers = new Label[8];
	for (int i = 0; i < 8; i++) {
		headers[i] = new Label(headersPanel, SWT.CENTER);
		headers[i].addListener(SWT.MouseDown, listener);
	}

	// Grid panel
	daysPanel = new Composite(gridPanel, SWT.NONE);
	days = new Cell[42];
	for (int i = 0; i < 42; i++) {
		days[i] = new Cell(daysPanel, i);
		days[i].label.addListener(SWT.MouseUp, listener);
	}
	daysPanel.addListener(SWT.Paint, listener);

	// Footer panel
	todayLabel = new Label(gridPanel, SWT.CENTER);
	todayLabel.addListener(SWT.MouseDoubleClick, listener);
	todayLabel.addListener(SWT.MouseDown, listener);
}
 
Example 4
Source File: DateChooser.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates the header of the calendar. The header contains the label
 * displaying the current month and year, and the two buttons for navigation :
 * previous and next month.
 */
private void createHeader() {
	monthPanel = new Composite(this, SWT.NONE);
	GridLayoutFactory.fillDefaults().numColumns(3).spacing(HEADER_SPACING, 0).margins(HEADER_SPACING, 2).applyTo(monthPanel);
	GridDataFactory.fillDefaults().applyTo(monthPanel);
	monthPanel.addListener(SWT.MouseDown, listener);

	prevMonth = new Button(monthPanel, SWT.ARROW | SWT.LEFT | SWT.FLAT);
	prevMonth.addListener(SWT.MouseUp, listener);
	prevMonth.addListener(SWT.FocusIn, listener);

	currentMonth = new Label(monthPanel, SWT.CENTER);
	currentMonth.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
	currentMonth.addListener(SWT.MouseDown, listener);

	nextMonth = new Button(monthPanel, SWT.ARROW | SWT.RIGHT | SWT.FLAT);
	nextMonth.addListener(SWT.MouseUp, listener);
	nextMonth.addListener(SWT.FocusIn, listener);

	monthsMenu = new Menu(getShell(), SWT.POP_UP);
	currentMonth.setMenu(monthsMenu);
	for (int i = 0; i < 12; i++) {
		final MenuItem item = new MenuItem(monthsMenu, SWT.PUSH);
		item.addListener(SWT.Selection, listener);
		item.setData(new Integer(i));
	}
	monthsMenu.addListener(SWT.Show, listener);
}
 
Example 5
Source File: XViewerCustomizeDialog.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void createSorterTextBlock(final Composite composite) {
   final Label sorterLabel = new Label(composite, SWT.NONE);
   sorterLabel.setText(XViewerText.get("XViewerCustomizeDialog.sorter")); //$NON-NLS-1$

   sorterText = new Text(composite, SWT.BORDER);
   sorterText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

   final Label clearSorterLabel = new Label(composite, SWT.PUSH);
   clearSorterLabel.setImage(XViewerLib.getImage("clear.gif")); //$NON-NLS-1$
   clearSorterLabel.addListener(SWT.MouseUp, e -> sorterText.setText("")); //$NON-NLS-1$
}
 
Example 6
Source File: Sorter.java    From Rel with Apache License 2.0 5 votes vote down vote up
public Sorter(FilterSorter filterSorter, Composite contentPanel) {
	super(contentPanel, SWT.NONE);
	
	this.filterSorter = filterSorter;
	
	GridLayout layout = new GridLayout(2, false);
	layout.horizontalSpacing = 0;
	layout.verticalSpacing = 0;
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	setLayout(layout);		

	sortSpec = new Label(this, SWT.NONE);
	sortSpec.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
	
	sortSpec.addListener(SWT.MouseUp, e -> popup());
	sortSpec.setText(emptySortPrompt);
	
	ToolBar toolBar = new ToolBar(this, SWT.NONE);
	
	ToolItem clear = new ToolItem(toolBar, SWT.PUSH);
	clear.addListener(SWT.Selection, e -> {
		sortSpec.setText(emptySortPrompt);
		filterSorter.refresh();
	});
	clear.setText("Clear");
	
	toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	
	this.addListener(SWT.Show, e -> {
		if (sortSpec.getText().equals(emptySortPrompt))
			popup();
	});
	
	createPopup();
}
 
Example 7
Source File: SearchAdvanced.java    From Rel with Apache License 2.0 5 votes vote down vote up
public SearchAdvanced(FilterSorter filterSorter, Composite contentPanel) {
	super(contentPanel, SWT.NONE);
	
	this.filterSorter = filterSorter;
	
	GridLayout layout = new GridLayout(2, false);
	layout.horizontalSpacing = 0;
	layout.verticalSpacing = 0;
	layout.marginWidth = 0;
	layout.marginHeight = 0;
	setLayout(layout);

	filterSpec = new Label(this, SWT.NONE);
	filterSpec.setText(emptyFilterPrompt);
	filterSpec.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1));
	
	filterSpec.addListener(SWT.MouseUp, e -> popup());		
	
	ToolBar toolBar = new ToolBar(this, SWT.NONE);
	
	ToolItem clear = new ToolItem(toolBar, SWT.PUSH);
	clear.addListener(SWT.Selection, e -> {
		filterSpec.setText(emptyFilterPrompt);
		filterSorter.refresh();
	});
	clear.setText("Clear");
	
	toolBar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	
	this.addListener(SWT.Show, e -> {
		if (filterSpec.getText().equals(emptyFilterPrompt))
			popup();
	});
	
	constructPopup();
}
 
Example 8
Source File: RecentPanel.java    From Rel with Apache License 2.0 5 votes vote down vote up
private void createItem(Composite parent, String prompt, String iconName, String dbURL, Listener action) {
	boolean enabled = true;
	if (dbURL != null)
		enabled = Core.databaseMayExist(dbURL);

	Composite panel = new Composite(parent, SWT.TRANSPARENT);		
	panel.setLayout(new RowLayout(SWT.VERTICAL));
	
	Composite topPanel = new Composite(panel, SWT.TRANSPARENT);		
	topPanel.setLayout(new RowLayout(SWT.HORIZONTAL));
	
	Button icon = new Button(topPanel, SWT.FLAT);
	icon.setImage(IconLoader.loadIcon(iconName));
	icon.addListener(SWT.Selection, action);
	icon.setEnabled(enabled);
	
	if (dbURL != null) {
		Button removeButton = new Button(topPanel, SWT.NONE);
		removeButton.setText("X");
		removeButton.setToolTipText("Remove this entry from this list of recently-used databases." + ((enabled) ? " The database will not be deleted." : ""));
		removeButton.addListener(SWT.Selection, e -> {
			Core.removeFromRecentlyUsedDatabaseList(dbURL);
			((DbTabContentRecent)getParent()).redisplayed();
		});
	}

	Label urlButton = new Label(panel, SWT.NONE);
	urlButton.setText(prompt);
	urlButton.addListener(SWT.MouseUp, action);
	if (!enabled)
		urlButton.setForeground(getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
}
 
Example 9
Source File: DateChooser.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
Cell(Composite parent, int idx) {
	label = new Label(parent, SWT.CENTER);
	index = idx;
	label.addListener(SWT.MouseDown, listener);
	label.setData(this);
}
 
Example 10
Source File: LinkSwtParameter.java    From BiglyBT with GNU General Public License v2.0 4 votes vote down vote up
public LinkSwtParameter(Composite composite, String name_resource,
		String labelKey, String url) {
	super(name_resource);

	if (labelKey != null) {
		Label label = new Label(composite, SWT.NONE);
		Messages.setLanguageText(label, labelKey);
		setRelatedControl(label);
	}

	link_label = new Label(composite, SWT.WRAP);
	setMainControl(link_label);
	this.url = url;
	Messages.setLanguageText(link_label, name_resource);
	Display display = link_label.getDisplay();
	link_label.setCursor(display.getSystemCursor(SWT.CURSOR_HAND));
	link_label.setForeground(display.getSystemColor(SWT.COLOR_LINK_FOREGROUND));
	link_label.addListener(SWT.MouseUp, e -> {
		if (e.button == 1) {
			triggerChangeListeners(false);
		} else {
			e.doit = true;
		}
	});
	link_label.addListener(SWT.MouseDoubleClick,
			e -> triggerChangeListeners(false));
	link_label.setData(url);
	ClipboardCopy.addCopyToClipMenu(link_label);

	if (doGridData(composite) && labelKey == null) {
		GridLayout parentLayout = (GridLayout) composite.getLayout();
		if (parentLayout.numColumns >= 2) {
			GridData gridData = Utils.getWrappableLabelGridData(2,
					GridData.FILL_HORIZONTAL);
			link_label.setLayoutData(gridData);
		} else {
			link_label.setLayoutData(new GridData());
		}
	}

	if (url != null) {
		Utils.setTT(link_label, url);
	}
}