use of org.eclipse.swt.widgets.List in project tdi-studio-se by Talend.
the class ColorCombo method createPopup.
void createPopup(String[] items, int selectionIndex) {
// create shell and list
popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
int style = getStyle();
int listStyle = SWT.SINGLE | SWT.V_SCROLL;
if ((style & SWT.FLAT) != 0) {
listStyle |= SWT.FLAT;
}
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
listStyle |= SWT.RIGHT_TO_LEFT;
}
if ((style & SWT.LEFT_TO_RIGHT) != 0) {
listStyle |= SWT.LEFT_TO_RIGHT;
}
list = new List(popup, listStyle);
if (font != null) {
list.setFont(font);
}
if (foreground != null) {
list.setForeground(foreground);
}
if (background != null) {
list.setBackground(background);
}
int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate };
for (int i = 0; i < popupEvents.length; i++) {
popup.addListener(popupEvents[i], listener);
}
int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose };
for (int i = 0; i < listEvents.length; i++) {
list.addListener(listEvents[i], listener);
}
if (items != null) {
list.setItems(items);
}
if (selectionIndex != -1) {
list.setSelection(selectionIndex);
}
}
use of org.eclipse.swt.widgets.List in project tdi-studio-se by Talend.
the class AllTypeDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite createDialogArea = (Composite) super.createDialogArea(parent);
createDialogArea.setLayout(new FillLayout());
SashForm baseCom = new SashForm(createDialogArea, SWT.VERTICAL | SWT.BORDER);
baseCom.setLayout(new GridLayout(1, true));
Group group1 = new Group(baseCom, SWT.None);
group1.setText(Messages.getString("AllTypeDialog.Group1Text"));
group1.setLayoutData(new GridData(GridData.FILL_BOTH));
group1.setLayout(new FillLayout());
Font font = new Font(Display.getCurrent(), "Arial", 43, 3);
group1.setFont(font);
font.dispose();
Group group2 = new Group(baseCom, SWT.None);
group2.setText(Messages.getString("AllTypeDialog.Group2Text"));
group2.setLayoutData(new GridData(GridData.FILL_BOTH));
font = new Font(Display.getCurrent(), "Arial", 43, 3);
group2.setFont(font);
group2.setLayout(new FillLayout());
font.dispose();
list = new List(group1, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
list.setItems(allXMLSchemaTypeName);
treeViewer = new TreeViewer(group2, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
tree = treeViewer.getTree();
tree.setHeaderVisible(false);
tree.setLinesVisible(true);
treeViewer.setContentProvider(new WebServiceTreeContentProvider());
treeViewer.setLabelProvider(new AllTypeLabelProvider());
treeViewer.setInput(null);
treeViewer.refresh();
list.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
String selection = list.getSelection()[0];
if (selection.contains(COMPLEXTYPE)) {
String[] split = selection.split(":");
String complexTypeName = split[1];
for (XmlSchemaType xmlSchemaType : allXmlSchemaType) {
if (xmlSchemaType.getName().equals(complexTypeName)) {
ParameterInfo parameterRoot = new ParameterInfo();
parameterRoot.setName("parameters");
ParameterInfo parameterSon = new ParameterInfo();
parameterSon.setName(complexTypeName);
parameterSon.setParent(parameterRoot);
parameterRoot.getParameterInfos().add(parameterSon);
XmlSchemaComplexType xmlElementComplexType = (XmlSchemaComplexType) xmlSchemaType;
XmlSchemaParticle xmlSchemaParticle = xmlElementComplexType.getParticle();
if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
XmlSchemaObjectCollection childCollection = xmlSchemaGroupBase.getItems();
if (childCollection != null) {
buildParameterFromCollection(childCollection, parameterSon);
}
}
treeViewer.setInput(parameterRoot);
treeViewer.refresh();
selectedParaInfo = parameterSon;
}
}
} else {
treeViewer.setInput(null);
treeViewer.refresh();
selectedParaInfo = null;
}
}
});
return baseCom;
}
use of org.eclipse.swt.widgets.List in project tdi-studio-se by Talend.
the class ImportComponentDialog method createDialogArea.
/*
* (non-Javadoc) Method declared on Dialog.
*/
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
GridLayout gl = new GridLayout(5, true);
composite.setLayout(gl);
if (message != null) {
Label label = new Label(composite, SWT.WRAP);
label.setText(message);
GridData data = new GridData(GridData.GRAB_HORIZONTAL);
data.horizontalSpan = 5;
label.setLayoutData(data);
label.setFont(parent.getFont());
}
Label label1 = new Label(composite, SWT.NONE);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
gd.horizontalSpan = 2;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.SelectDirectoryLabel"));
text = new Text(composite, SWT.BORDER);
text.setEditable(false);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
text.setLayoutData(gd);
if (paletteComponentsPath == null) {
//$NON-NLS-1$
paletteComponentsPath = "";
}
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput(true);
}
});
Button button = new Button(composite, SWT.NONE);
//$NON-NLS-1$
button.setText(Messages.getString("ImportComponentDialog.Browser"));
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 1;
button.setLayoutData(gd);
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dd = new DirectoryDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
String path = dd.open();
if (path != null) {
text.setText(path);
}
}
});
Button showPaletteComponents = new Button(composite, SWT.NONE);
gd = new GridData();
gd.horizontalSpan = 2;
showPaletteComponents.setLayoutData(gd);
//$NON-NLS-1$
showPaletteComponents.setText(Messages.getString("ImportComponentDialog.ShowPaletteComponents"));
showPaletteComponents.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
text.setText(paletteComponentsPath);
}
});
label1 = new Label(composite, SWT.LEFT);
gd = new GridData();
gd.horizontalSpan = 1;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.Filter"));
filterText = new Text(composite, SWT.BORDER);
filterText.setEditable(true);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 2;
filterText.setLayoutData(gd);
filterText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
validateInput(false);
}
});
label1 = new Label(composite, SWT.LEFT);
gd = new GridData();
gd.horizontalSpan = 5;
label1.setLayoutData(gd);
//$NON-NLS-1$
label1.setText(Messages.getString("ImportComponentDialog.ChooseComponentsLabel"));
componentList = new List(composite, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 5;
componentList.setLayoutData(gd);
componentList.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent e) {
}
public void mouseDown(MouseEvent e) {
validateSelected();
}
public void mouseUp(MouseEvent e) {
validateSelected();
}
});
errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.CENTER);
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan = 5;
label1.setLayoutData(gd);
errorMessageText.setLayoutData(gd);
errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
applyDialogFont(composite);
//$NON-NLS-1$
text.setText("");
return composite;
}
use of org.eclipse.swt.widgets.List in project ACS by ACS-Community.
the class SourcesView method createViewWidgets.
private void createViewWidgets(final Composite parent) {
_sash = new SashForm(parent, SWT.HORIZONTAL);
_sash.setLayout(new FillLayout());
/* Left pane */
_sourcesComp = new Composite(_sash, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
_sourcesComp.setLayout(layout);
_listGroup = new Group(_sourcesComp, SWT.SHADOW_ETCHED_IN);
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
_listGroup.setLayoutData(gd);
GridLayout gl = new GridLayout();
gl.numColumns = 1;
_listGroup.setLayout(gl);
_listGroup.setText("Sources List");
_sourcesList = new List(_listGroup, SWT.BORDER);
gd = new GridData();
gd.verticalAlignment = SWT.FILL;
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessVerticalSpace = true;
gd.grabExcessHorizontalSpace = true;
_sourcesList.setLayoutData(gd);
_sourcesButtonsComp = new Composite(_sourcesComp, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
_sourcesButtonsComp.setLayout(layout);
_addSourceButton = new Button(_sourcesButtonsComp, SWT.None);
_addSourceButton.setText("Add");
_addSourceButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
_deleteSourceButton = new Button(_sourcesButtonsComp, SWT.None);
_deleteSourceButton.setText("Delete");
_deleteSourceButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_DELETE));
/* Please change this in the future when more SOURCES will be available */
_addSourceButton.setEnabled(false);
_deleteSourceButton.setEnabled(false);
_sourcesList.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
String source = _sourcesList.getSelection()[0];
Control c = _compInitial.getChildren()[0];
if (c instanceof Label) {
c.dispose();
_group.setVisible(true);
_group.layout();
}
fillSource(source);
_compInitial.layout();
}
});
_addSourceButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
InputDialog dialog = new InputDialog(SourcesView.this.getViewSite().getShell(), "New source", "Enter the source name", null, new IInputValidator() {
public String isValid(String newText) {
if (newText.trim().compareTo("") == 0)
return "The name is empty";
return null;
}
});
dialog.setBlockOnOpen(true);
dialog.open();
int returnCode = dialog.getReturnCode();
if (returnCode == InputDialog.OK) {
Source newSource = new Source();
newSource.setSourceId(dialog.getValue());
try {
_sourceManager.addSource(newSource);
} catch (IllegalOperationException e) {
ErrorDialog error = new ErrorDialog(SourcesView.this.getViewSite().getShell(), "Source already exist", "The source " + dialog.getValue() + " already exists in the current configuration", new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
return;
}
refreshContents();
if (_sourcesList.getItems().length != 0) {
int lenght = _sourcesList.getItems().length;
lenght -= 1;
_sourcesList.select(lenght);
_descriptionText.setText(_sourcesList.getItem(lenght).toString());
}
}
}
});
_deleteSourceButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
boolean choice = MessageDialog.openQuestion(SourcesView.this.getViewSite().getShell(), "Confirmation", "Are you sure you want to delete this Source");
if (choice == true) {
String[] tmp = _sourcesList.getSelection();
if (tmp.length == 0) {
MessageBox box = new MessageBox(getViewSite().getShell(), SWT.OK | SWT.ICON_ERROR | SWT.APPLICATION_MODAL);
box.setText("Empty selection");
box.setMessage("There are no sources selected to be deleted");
box.open();
return;
}
String source = tmp[0];
try {
_sourceManager.deleteSource(_sourceManager.getSource(source));
} catch (IllegalOperationException e) {
ErrorDialog error = new ErrorDialog(SourcesView.this.getViewSite().getShell(), "Cannot delete source", "The source cannot be deleted", new Status(IStatus.ERROR, "cl.utfsm.acs.acg", e.getMessage()), IStatus.ERROR);
error.setBlockOnOpen(true);
error.open();
}
refreshContents();
if (_sourcesList.getItems().length != 0) {
int lenght = _sourcesList.getItems().length;
lenght -= 1;
_sourcesList.select(lenght);
_sourceNameText.setText(_sourcesList.getItem(lenght).toString());
}
}
}
});
/* Right pane */
_compInitial = new Composite(_sash, SWT.NONE);
_compInitial.setLayout(new GridLayout());
new Label(_compInitial, SWT.NONE).setText("Select a source");
layout = new GridLayout();
layout.numColumns = 2;
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.verticalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
gd.grabExcessVerticalSpace = true;
_group = new Group(_compInitial, SWT.SHADOW_ETCHED_IN);
_group.setText("Source information");
_group.setLayout(layout);
_group.setLayoutData(gd);
_sourceNameLabel = new Label(_group, SWT.NONE);
_sourceNameLabel.setText("Source name");
_sourceNameText = new Text(_group, SWT.BORDER);
_descriptionLabel = new Label(_group, SWT.NONE);
_descriptionLabel.setText("Description");
_descriptionText = new Text(_group, SWT.BORDER);
gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
gd.grabExcessHorizontalSpace = true;
_sourceNameText.setLayoutData(gd);
_descriptionText.setLayoutData(gd);
_group.setVisible(false);
_sash.setWeights(new int[] { 3, 5 });
/* TODO: This is temporal, since there is currently only
* one source defined in the AS, and it's hardcoded */
//setEnabled(false);
_descriptionText.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event e) {
updateSource();
}
});
_errorMessageLabel = new Label(_group, SWT.NONE);
_errorMessageLabel.setText("");
_errorMessageLabel.setForeground(getViewSite().getShell().getDisplay().getSystemColor(SWT.COLOR_RED));
gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
gd.horizontalSpan = 2;
_errorMessageLabel.setLayoutData(gd);
/* Please change this in the future when more SOURCES will be available */
_sourceNameText.setEnabled(false);
_descriptionText.setEnabled(false);
}
use of org.eclipse.swt.widgets.List in project cubrid-manager by CUBRID.
the class GroupSettingDialog method createGroupList.
/**
* Create group list.
*
* @param parentComp parent composite.
*/
private void createGroupList(Composite parentComp) {
Composite groupLabel = new Composite(parentComp, SWT.NONE);
{
groupLabel.setLayout(new GridLayout());
groupLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label label = new Label(groupLabel, SWT.LEFT);
label.setText(Messages.labelManagerGroups);
}
Composite group1 = new Composite(parentComp, SWT.NONE);
{
group1.setLayout(new GridLayout(2, false));
group1.setLayoutData(new GridData(GridData.FILL_BOTH));
groupList = new List(group1, SWT.BORDER | SWT.V_SCROLL);
{
groupList.setLayoutData(new GridData(GridData.FILL_BOTH));
groupList.addSelectionListener(new SelectionAdapter() {
/**
* selection change event
*
* @param event SelectionEvent
*/
public void widgetSelected(SelectionEvent event) {
setButtonStatus();
}
});
}
Composite btnCom = new Composite(group1, SWT.NONE);
{
btnCom.setLayout(new GridLayout());
btnCom.setLayoutData(new GridData(GridData.FILL_VERTICAL));
}
btnTop = new Button(btnCom, SWT.NONE);
btnTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnTop.setText(Messages.btnTop);
btnTop.addSelectionListener(new SelectionAdapter() {
/**
* push button event
*
* @param event SelectionEvent
*/
public void widgetSelected(SelectionEvent event) {
String current = groupList.getSelection()[0];
int index = groupList.getSelectionIndex();
groupList.remove(index);
groupList.add(current, 0);
groupList.setSelection(0);
setButtonStatus();
}
});
btnUp = new Button(btnCom, SWT.NONE);
btnUp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnUp.setText(Messages.btnUp);
btnUp.addSelectionListener(new SelectionAdapter() {
/**
* push button event
*
* @param event SelectionEvent
*/
public void widgetSelected(SelectionEvent event) {
String current = groupList.getSelection()[0];
int index = groupList.getSelectionIndex();
groupList.remove(index);
groupList.add(current, index - 1);
groupList.setSelection(index - 1);
setButtonStatus();
}
});
btnDown = new Button(btnCom, SWT.NONE);
btnDown.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnDown.setText(Messages.btnDown);
btnDown.addSelectionListener(new SelectionAdapter() {
/**
* push button event
*
* @param event SelectionEvent
*/
public void widgetSelected(SelectionEvent event) {
String current = groupList.getSelection()[0];
int index = groupList.getSelectionIndex();
groupList.remove(index);
groupList.add(current, index + 1);
groupList.setSelection(index + 1);
setButtonStatus();
}
});
btnBottom = new Button(btnCom, SWT.NONE);
btnBottom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
btnBottom.setText(Messages.btnBottom);
btnBottom.addSelectionListener(new SelectionAdapter() {
/**
* push button event
*
* @param event SelectionEvent
*/
public void widgetSelected(SelectionEvent event) {
String current = groupList.getSelection()[0];
int index = groupList.getSelectionIndex();
groupList.remove(index);
groupList.add(current);
groupList.setSelection(groupList.getItemCount() - 1);
setButtonStatus();
}
});
}
}
Aggregations