|
What this is
Other links
The source code/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Sebastian Davids <sdavids@gmx.de> - Fix for bug 19346 - Dialog
* font should be activated and used by other components.
*******************************************************************************/
package org.eclipse.ui.dialogs;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
/**
* An abstract class to select elements out of a list of elements.
*
* @since 2.0
*/
public abstract class AbstractElementListSelectionDialog extends
SelectionStatusDialog {
private ILabelProvider fRenderer;
private boolean fIgnoreCase = true;
private boolean fIsMultipleSelection = false;
private boolean fMatchEmptyString = true;
private boolean fAllowDuplicates = true;
private Label fMessage;
protected FilteredList fFilteredList;
private Text fFilterText;
private ISelectionStatusValidator fValidator;
private String fFilter = null;
private String fEmptyListMessage = ""; //$NON-NLS-1$
private String fEmptySelectionMessage = ""; //$NON-NLS-1$
private int fWidth = 60;
private int fHeight = 18;
private Object[] fSelection = new Object[0];
/**
* Constructs a list selection dialog.
* @param parent The parent for the list.
* @param renderer ILabelProvider for the list
*/
protected AbstractElementListSelectionDialog(Shell parent,
ILabelProvider renderer) {
super(parent);
fRenderer = renderer;
}
/**
* Handles default selection (double click).
* By default, the OK button is pressed.
*/
protected void handleDefaultSelected() {
if (validateCurrentSelection()) {
buttonPressed(IDialogConstants.OK_ID);
}
}
/**
* Specifies if sorting, filtering and folding is case sensitive.
* @param ignoreCase
*/
public void setIgnoreCase(boolean ignoreCase) {
fIgnoreCase = ignoreCase;
}
/**
* Returns if sorting, filtering and folding is case sensitive.
* @return boolean
*/
public boolean isCaseIgnored() {
return fIgnoreCase;
}
/**
* Specifies whether everything or nothing should be filtered on
* empty filter string.
* @param matchEmptyString boolean
*/
public void setMatchEmptyString(boolean matchEmptyString) {
fMatchEmptyString = matchEmptyString;
}
/**
* Specifies if multiple selection is allowed.
* @param multipleSelection
*/
public void setMultipleSelection(boolean multipleSelection) {
fIsMultipleSelection = multipleSelection;
}
/**
* Specifies whether duplicate entries are displayed or not.
* @param allowDuplicates
*/
public void setAllowDuplicates(boolean allowDuplicates) {
fAllowDuplicates = allowDuplicates;
}
/**
* Sets the list size in unit of characters.
* @param width the width of the list.
* @param height the height of the list.
*/
public void setSize(int width, int height) {
fWidth = width;
fHeight = height;
}
/**
* Sets the message to be displayed if the list is empty.
* @param message the message to be displayed.
*/
public void setEmptyListMessage(String message) {
fEmptyListMessage = message;
}
/**
* Sets the message to be displayed if the selection is empty.
* @param message the message to be displayed.
*/
public void setEmptySelectionMessage(String message) {
fEmptySelectionMessage = message;
}
/**
* Sets an optional validator to check if the selection is valid.
* The validator is invoked whenever the selection changes.
* @param validator the validator to validate the selection.
*/
public void setValidator(ISelectionStatusValidator validator) {
fValidator = validator;
}
/**
* Sets the elements of the list (widget).
* To be called within open().
* @param elements the elements of the list.
*/
protected void setListElements(Object[] elements) {
Assert.isNotNull(fFilteredList);
fFilteredList.setElements(elements);
}
/**
* Sets the filter pattern.
* @param filter the filter pattern.
*/
public void setFilter(String filter) {
if (fFilterText == null) {
fFilter = filter;
} else {
fFilterText.setText(filter);
}
}
/**
* Returns the current filter pattern.
* @return returns the current filter pattern or <code>null
|
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.