use of org.eclipse.swt.widgets.ToolBar in project tdi-studio-se by Talend.
the class MetadataToolbarEditorViewExt method createColumns.
/**
* qzhang Comment method "createColumns".
*/
private void createColumns() {
columnSelector = new ToolBar(toolbar, SWT.HORIZONTAL);
final ToolItem columns = new ToolItem(columnSelector, SWT.DROP_DOWN);
//$NON-NLS-1$
columns.setText(Messages.getString("MetadataToolbarEditorViewExt.Columns.Text"));
createMenu(columns);
columns.addSelectionListener(new SelectionAdapter() {
/*
* (non-Java)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent event) {
// If they clicked the arrow, we show the list
// if (event.detail == SWT.ARROW) {
// Determine where to put the dropdown list
ToolItem item = (ToolItem) event.widget;
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
columnsListmenu.setLocation(pt.x, pt.y + rect.height);
columnsListmenu.setVisible(true);
// }
}
});
}
use of org.eclipse.swt.widgets.ToolBar in project bndtools by bndtools.
the class EditableParametersPart method createControl.
public Control createControl(Composite parent) {
this.parent = parent;
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
composite.setLayout(layout);
Label titleLabel = new Label(composite, SWT.NONE);
titleLabel.setText(title);
titleLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 2, 1));
Table table = new Table(composite, SWT.BORDER | SWT.MULTI);
viewer = new TableViewer(table);
viewer.setContentProvider(ArrayContentProvider.getInstance());
final Image iconImg = imageDescriptor.createImage(parent.getDisplay());
viewer.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
@SuppressWarnings("unchecked") Pair<String, Attrs> entry = (Pair<String, Attrs>) cell.getElement();
StyledString label = new StyledString(entry.getFirst(), BoldStyler.INSTANCE_DEFAULT);
for (Entry<String, String> attribEntry : entry.getSecond().entrySet()) {
label.append("; " + attribEntry.getKey() + "=", StyledString.QUALIFIER_STYLER);
label.append(attribEntry.getValue());
}
cell.setText(label.toString());
cell.setStyleRanges(label.getStyleRanges());
cell.setImage(iconImg);
}
});
viewer.setInput(entries);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gd.widthHint = 280;
gd.heightHint = 80;
table.setLayoutData(gd);
final AddRemoveButtonBarPart buttonBarPart = new AddRemoveButtonBarPart();
ToolBar buttonBar = buttonBarPart.createControl(composite, SWT.FLAT | SWT.VERTICAL);
buttonBar.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
final Image imgEdit = ImageDescriptor.createFromURL(BUNDLE.getEntry("icons/edit.gif")).createImage(parent.getDisplay());
final Image imgEditDisabled = ImageDescriptor.createFromURL(BUNDLE.getEntry("icons/edit-disabled.gif")).createImage(parent.getDisplay());
final ToolItem btnEdit = new ToolItem(buttonBar, SWT.PUSH);
btnEdit.setImage(imgEdit);
btnEdit.setDisabledImage(imgEditDisabled);
buttonBarPart.setRemoveEnabled(false);
btnEdit.setEnabled(false);
buttonBarPart.addListener(new AddRemoveListener() {
@Override
public void addSelected() {
doAdd();
}
@Override
public void removeSelected() {
doRemove();
}
});
btnEdit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doEdit();
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
boolean enabled = !viewer.getSelection().isEmpty();
buttonBarPart.setRemoveEnabled(enabled);
btnEdit.setEnabled(enabled);
}
});
viewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
doEdit();
}
});
table.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.DEL && e.stateMask == 0)
doRemove();
}
});
composite.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent ev) {
iconImg.dispose();
imgEdit.dispose();
imgEditDisabled.dispose();
}
});
return composite;
}
use of org.eclipse.swt.widgets.ToolBar in project bndtools by bndtools.
the class ProjectListControl method createFilter.
private void createFilter(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout gridLayout = new GridLayout(2, false);
gridLayout.marginHeight = gridLayout.marginWidth = 0;
gridLayout.horizontalSpacing = 0;
gridLayout.verticalSpacing = 0;
composite.setLayout(gridLayout);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.grabExcessHorizontalSpace = true;
composite.setLayoutData(gridData);
FilterPanelPart filterPart = new FilterPanelPart(Activator.getDefault().getScheduler());
filterPart.createControl(composite, 0, 0);
filterPart.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
String filter = (String) event.getNewValue();
updatedFilter(filter);
}
});
ToolBar toolbar = new ToolBar(composite, SWT.FLAT);
ToolItem tiCheckAll = new ToolItem(toolbar, SWT.FLAT);
tiCheckAll.setImage(Activator.getImageDescriptor("icons/check_all.gif").createImage());
tiCheckAll.setToolTipText(Messages.checkAll);
tiCheckAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Object[] objs = contentProvider.getElements(null);
for (Object obj : objs) {
ProjectDiff diff = (ProjectDiff) obj;
diff.setRelease(true);
}
tableViewer.refresh();
}
});
ToolItem tiUncheckAll = new ToolItem(toolbar, SWT.FLAT);
tiUncheckAll.setImage(Activator.getImageDescriptor("icons/uncheck_all.gif").createImage());
tiUncheckAll.setToolTipText(Messages.uncheckAll);
tiUncheckAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Object[] objs = contentProvider.getElements(null);
for (Object obj : objs) {
ProjectDiff diff = (ProjectDiff) obj;
diff.setRelease(false);
}
tableViewer.refresh();
}
});
}
use of org.eclipse.swt.widgets.ToolBar in project bndtools by bndtools.
the class UpDownButtonBarPart method createControl.
public Control createControl(Composite parent, int style) {
toolbar = new ToolBar(parent, style);
btnUp = new ToolItem(toolbar, SWT.PUSH);
btnUp.setImage(imgUp);
btnUp.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doMoveUp();
}
});
btnDown = new ToolItem(toolbar, SWT.PUSH);
btnDown.setImage(imgDown);
btnDown.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doMoveDown();
}
});
toolbar.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent de) {
if (!imgUp.isDisposed())
imgUp.dispose();
if (!imgDown.isDisposed())
imgDown.dispose();
}
});
return toolbar;
}
use of org.eclipse.swt.widgets.ToolBar in project bndtools by bndtools.
the class PkgPatternsListPart method createSection.
protected void createSection(Section section, FormToolkit toolkit) {
Composite composite = toolkit.createComposite(section);
section.setClient(composite);
ToolBar toolbar = new ToolBar(section, SWT.FLAT);
section.setTextClient(toolbar);
final ToolItem addItem = new ToolItem(toolbar, SWT.PUSH);
addItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ADD));
addItem.setToolTipText("Add");
final ToolItem insertItem = new ToolItem(toolbar, SWT.PUSH);
insertItem.setImage(imgInsert);
insertItem.setToolTipText("Insert");
insertItem.setEnabled(false);
final ToolItem removeItem = new ToolItem(toolbar, SWT.PUSH);
removeItem.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE));
removeItem.setDisabledImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE_DISABLED));
removeItem.setToolTipText("Remove");
removeItem.setEnabled(false);
Table table = toolkit.createTable(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
viewer = new TableViewer(table);
viewer.setUseHashlookup(false);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(labelProvider);
toolbar = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
final ToolItem btnMoveUp = new ToolItem(toolbar, SWT.PUSH);
btnMoveUp.setText("Up");
btnMoveUp.setImage(imgUp);
btnMoveUp.setEnabled(false);
final ToolItem btnMoveDown = new ToolItem(toolbar, SWT.PUSH);
btnMoveDown.setText("Down");
btnMoveDown.setImage(imgDown);
btnMoveDown.setEnabled(false);
// Listeners
table.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
ISelection selection = viewer.getSelection();
if (!selection.isEmpty())
managedForm.fireSelectionChanged(PkgPatternsListPart.this, selection);
}
});
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
List<C> oldSelection = selection;
IStructuredSelection structSel = (IStructuredSelection) event.getSelection();
@SuppressWarnings("unchecked") List<C> newSelection = structSel.toList();
selection = newSelection;
propChangeSupport.firePropertyChange(PROP_SELECTION, oldSelection, selection);
managedForm.fireSelectionChanged(PkgPatternsListPart.this, event.getSelection());
boolean enabled = !viewer.getSelection().isEmpty();
insertItem.setEnabled(enabled);
removeItem.setEnabled(enabled);
btnMoveUp.setEnabled(enabled);
btnMoveDown.setEnabled(enabled);
}
});
viewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { LocalSelectionTransfer.getTransfer(), ResourceTransfer.getInstance(), TextTransfer.getInstance() }, new PackageDropAdapter<C>(viewer) {
@Override
protected C createNewEntry(String packageName) {
return newHeaderClause(packageName);
}
@Override
protected void addRows(int index, Collection<C> rows) {
doAddClauses(rows, index, true);
}
@Override
protected int indexOf(Object object) {
return clauses.indexOf(object);
}
});
table.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.character == SWT.DEL) {
doRemoveSelectedClauses();
} else if (e.character == '+') {
doAddClausesAfterSelection(generateClauses());
}
}
});
addItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doAddClausesAfterSelection(generateClauses());
}
});
insertItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doInsertClausesAtSelection(generateClauses());
}
});
removeItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doRemoveSelectedClauses();
}
});
btnMoveUp.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doMoveUp();
}
});
btnMoveDown.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doMoveDown();
}
});
// Layout
GridLayout layout;
layout = new GridLayout(1, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
composite.setLayout(layout);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 75;
gd.heightHint = 75;
table.setLayoutData(gd);
toolbar.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
}
Aggregations