use of org.eclipse.jface.viewers.ViewerCell 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.jface.viewers.ViewerCell in project bndtools by bndtools.
the class IndexerWizardPage method createControl.
@Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
setControl(composite);
// Create controls
new Label(composite, SWT.NONE).setText(Messages.IndexerWizardPage_baseDir);
txtBaseDir = new Text(composite, SWT.BORDER);
newSpacer(composite);
Composite cmpButtonBar = new Composite(composite, SWT.NONE);
Button btnBrowseWorkspace = new Button(cmpButtonBar, SWT.PUSH);
btnBrowseWorkspace.setText(Messages.IndexerWizardPage_browse);
Button btnBrowseExternal = new Button(cmpButtonBar, SWT.PUSH);
btnBrowseExternal.setText(Messages.IndexerWizardPage_browseExternal);
new Label(composite, SWT.NONE).setText(Messages.IndexerWizardPage_resourcePattern);
txtResourcePattern = new Text(composite, SWT.BORDER);
ControlDecoration decorResourcePattern = new ControlDecoration(txtResourcePattern, SWT.LEFT | SWT.TOP, composite);
decorResourcePattern.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
decorResourcePattern.setMarginWidth(3);
decorResourcePattern.setDescriptionText(Messages.IndexerWizardPage_resourcePatternHelp);
decorResourcePattern.setShowHover(true);
decorResourcePattern.setShowOnlyOnFocus(false);
Label lblInputs = new Label(composite, SWT.NONE);
lblInputs.setText(Messages.IndexerWizardPage_inputs);
Table tblInputs = new Table(composite, SWT.MULTI | SWT.BORDER);
vwrInputs = new TableViewer(tblInputs);
vwrInputs.setContentProvider(ArrayContentProvider.getInstance());
vwrInputs.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Object elem = cell.getElement();
if (elem instanceof Path) {
cell.setText(elem.toString());
cell.setImage(imgFile);
} else if (elem instanceof IStatus) {
IStatus status = (IStatus) elem;
cell.setText(status.getMessage());
if (status.getSeverity() == IStatus.ERROR)
cell.setImage(imgError);
else if (status.getSeverity() == IStatus.WARNING)
cell.setImage(imgWarning);
}
}
});
newSpacer(composite);
lblInputCount = new Label(composite, SWT.NONE);
Label lblOutputs = new Label(composite, SWT.NONE);
lblOutputs.setText(Messages.IndexerWizardPage_output);
Group grpOutput = new Group(composite, SWT.NONE);
new Label(grpOutput, SWT.NONE).setText(Messages.IndexerWizardPage_prefix);
txtOutputPrefix = new Text(grpOutput, SWT.BORDER);
newSpacer(grpOutput);
btnOutputPretty = new Button(grpOutput, SWT.RADIO);
btnOutputPretty.setText(Messages.IndexerWizardPage_prettyPrint);
newSpacer(grpOutput);
btnOutputCompressed = new Button(grpOutput, SWT.RADIO);
btnOutputCompressed.setText(Messages.IndexerWizardPage_compressed);
newSpacer(grpOutput);
lblOutputName = new Label(grpOutput, SWT.NONE);
// LAYOUT
GridLayout gl;
GridData gd;
gl = new GridLayout(2, false);
gl.horizontalSpacing = 10;
composite.setLayout(gl);
txtBaseDir.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
cmpButtonBar.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, false));
gl = new GridLayout(2, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
cmpButtonBar.setLayout(gl);
btnBrowseWorkspace.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
btnBrowseExternal.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
txtResourcePattern.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
lblInputs.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = 120;
gd.widthHint = 100;
tblInputs.setLayoutData(gd);
lblInputCount.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false));
lblOutputs.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
grpOutput.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
grpOutput.setLayout(new GridLayout(2, false));
txtOutputPrefix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
btnOutputCompressed.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
btnOutputPretty.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
lblOutputName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
// LOAD DATA
if (baseDir != null)
txtBaseDir.setText(baseDir.getAbsolutePath());
if (resourcePattern != null)
txtResourcePattern.setText(resourcePattern);
// $NON-NLS-1$
txtOutputPrefix.setText("index");
btnOutputCompressed.setSelection(outputStyle == IndexFormatStyle.COMPRESSED);
btnOutputPretty.setSelection(outputStyle == IndexFormatStyle.PRETTY_UNCOMPRESSED);
updateOutputFileName();
updateInputs();
// LISTENERS
txtBaseDir.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent me) {
String baseDirStr = txtBaseDir.getText();
baseDir = baseDirStr.isEmpty() ? null : new File(baseDirStr);
validate();
updateInputs();
}
});
txtResourcePattern.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent me) {
resourcePattern = txtResourcePattern.getText();
updateInputs();
}
});
btnBrowseWorkspace.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
ContainerSelectionDialog containerDlg = new ContainerSelectionDialog(getShell(), root, false, Messages.IndexerWizardPage_selectBaseDir);
containerDlg.showClosedProjects(false);
if (containerDlg.open() == Window.OK) {
Object[] selection = containerDlg.getResult();
if (selection != null && selection.length > 0) {
IPath workspacePath = (IPath) selection[0];
IResource resource = root.findMember(workspacePath);
if (resource == null)
MessageDialog.openError(getShell(), "Error", "Could not find resource for path " + workspacePath);
else
txtBaseDir.setText(resource.getLocation().toString());
}
}
}
});
btnBrowseExternal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dirDialog = new DirectoryDialog(getShell());
dirDialog.setMessage(Messages.IndexerWizardPage_selectBaseDir);
String selectedPath = dirDialog.open();
if (selectedPath != null)
txtBaseDir.setText(selectedPath);
}
});
txtOutputPrefix.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent me) {
updateOutputFileName();
validate();
}
});
Listener outputRadioListener = new Listener() {
@Override
public void handleEvent(Event ev) {
outputStyle = btnOutputCompressed.getSelection() ? IndexFormatStyle.COMPRESSED : IndexFormatStyle.PRETTY_UNCOMPRESSED;
updateOutputFileName();
validate();
}
};
btnOutputCompressed.addListener(SWT.Selection, outputRadioListener);
btnOutputPretty.addListener(SWT.Selection, outputRadioListener);
validate();
}
use of org.eclipse.jface.viewers.ViewerCell in project bndtools by bndtools.
the class AddFilesToRepositoryWizardPage method createControl.
@Override
@SuppressWarnings("unused")
public void createControl(Composite parent) {
setTitle("Add Files to Repository");
Composite composite = new Composite(parent, SWT.NONE);
new Label(composite, SWT.NONE).setText("Selected files:");
// Spacer;
new Label(composite, SWT.NONE);
Table table = new Table(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumn col;
col = new TableColumn(table, SWT.NONE);
col.setText("Path");
col.setWidth(300);
col = new TableColumn(table, SWT.NONE);
col.setText("Bundle Name/Version");
col.setWidth(300);
viewer = new TableViewer(table);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new StyledCellLabelProvider() {
@Override
public void update(ViewerCell cell) {
File file = (File) cell.getElement();
Pair<String, String> bundleId = bsnMap.get(file);
int index = cell.getColumnIndex();
if (index == 0) {
if (bundleId == null) {
cell.setImage(errorImg);
} else {
cell.setImage(jarImg);
}
StyledString label = new StyledString(file.getName());
String parentPath = file.getParent();
if (parentPath != null) {
label.append(" (" + parentPath + ")", StyledString.QUALIFIER_STYLER);
}
cell.setText(label.getString());
cell.setStyleRanges(label.getStyleRanges());
} else if (index == 1) {
if (bundleId == null) {
cell.setImage(errorImg);
cell.setText("Not a JAR file");
} else {
String bsn = bundleId.getFirst();
String version = bundleId.getSecond();
if (bsn == null) {
cell.setImage(warnImg);
cell.setText("Not a Bundle JAR");
} else {
cell.setImage(okayImg);
StyledString styledString = new StyledString(bsn);
if (version != null) {
styledString.append(" [" + version + "]", StyledString.COUNTER_STYLER);
cell.setText(styledString.getString());
cell.setStyleRanges(styledString.getStyleRanges());
}
}
}
}
}
});
viewer.setInput(files);
validate();
final Button btnAdd = new Button(composite, SWT.PUSH);
btnAdd.setText("Add JARs...");
final Button btnAddExternal = new Button(composite, SWT.PUSH);
btnAddExternal.setText("Add External JARs...");
final Button btnRemove = new Button(composite, SWT.NONE);
btnRemove.setText("Remove");
btnRemove.setEnabled(false);
// LISTENERS
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
btnRemove.setEnabled(!viewer.getSelection().isEmpty());
}
});
btnAdd.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doAdd();
}
});
btnAddExternal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doAddExternal();
}
});
btnRemove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doRemove();
}
});
// LAYOUT
composite.setLayout(new GridLayout(2, false));
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
btnAdd.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
setControl(composite);
}
use of org.eclipse.jface.viewers.ViewerCell in project dbeaver by serge-rider.
the class OracleCompilerDialog method createDialogArea.
@Override
protected Composite createDialogArea(Composite parent) {
GridData gd;
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
{
Composite unitsGroup = new Composite(composite, SWT.NONE);
gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 250;
gd.heightHint = 200;
gd.verticalIndent = 0;
gd.horizontalIndent = 0;
unitsGroup.setLayoutData(gd);
unitsGroup.setLayout(new GridLayout(1, false));
unitTable = new TableViewer(unitsGroup, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
{
final Table table = unitTable.getTable();
table.setLayoutData(new GridData(GridData.FILL_BOTH));
table.setLinesVisible(true);
table.setHeaderVisible(true);
}
ViewerColumnController columnController = new ViewerColumnController("OracleCompilerDialog", unitTable);
columnController.addColumn(OracleUIMessages.views_oracle_compiler_dialog_column_name, null, SWT.NONE, true, true, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
DBSObject unit = (DBSObject) cell.getElement();
final DBNDatabaseNode node = DBNUtils.getNodeByObject(unit);
if (node != null) {
cell.setText(node.getNodeName());
cell.setImage(DBeaverIcons.getImage(node.getNodeIconDefault()));
} else {
cell.setText(unit.toString());
}
}
});
columnController.addColumn(OracleUIMessages.views_oracle_compiler_dialog_column_type, null, SWT.NONE, true, true, new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
DBSObject unit = (DBSObject) cell.getElement();
final DBNDatabaseNode node = DBNUtils.getNodeByObject(unit);
if (node != null) {
cell.setText(node.getNodeType());
} else {
// $NON-NLS-1$
cell.setText("???");
}
}
});
columnController.createColumns();
unitTable.addSelectionChangedListener(event -> {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
getButton(COMPILE_ID).setEnabled(!selection.isEmpty());
});
unitTable.addDoubleClickListener(event -> {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (!selection.isEmpty()) {
OracleSourceObject unit = (OracleSourceObject) selection.getFirstElement();
NavigatorHandlerObjectOpen.openEntityEditor(unit);
}
});
unitTable.setContentProvider(new ListContentProvider());
unitTable.setInput(compileUnits);
}
{
Composite infoGroup = new Composite(composite, SWT.NONE);
gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 400;
gd.heightHint = 200;
gd.verticalIndent = 0;
gd.horizontalIndent = 0;
infoGroup.setLayoutData(gd);
infoGroup.setLayout(new GridLayout(1, false));
compileLog = new ObjectCompilerLogViewer(infoGroup, null, true);
}
return composite;
}
Aggregations