use of org.eclipse.swt.events.ControlEvent in project pmd-eclipse-plugin by pmd.
the class ViolationOutlinePage method createColumnAdapters.
/**
* Creates Adapter for sorting and resizing the Columns
*
* @param table
*/
private void createColumnAdapters(Table table) {
TableColumn[] columns = table.getColumns();
for (int k = 0; k < columns.length; k++) {
columnWidths[k] = Integer.valueOf(columns[k].getWidth());
final int i = k;
// the Sorter
columns[k].addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
currentSortedColumn = i;
columnSortOrder[currentSortedColumn] *= -1;
tableViewer.setSorter(getViewerSorter(currentSortedColumn));
}
});
// the Resizing
columns[k].addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
columnWidths[i] = Integer.valueOf(tableViewer.getTable().getColumn(i).getWidth());
}
});
}
}
use of org.eclipse.swt.events.ControlEvent in project pmd-eclipse-plugin by pmd.
the class ViolationOutlinePageBR method createControl.
public void createControl(Composite parent) {
tableManager = new BasicTableManager<IMarker>("rscViolations", PMDPlugin.getDefault().loadPreferences(), initialColumns);
tableViewer = tableManager.buildTableViewer(parent);
tableManager.setupColumns(initialColumns);
tableManager.setTableMenu(violationOutline.createContextMenu(tableViewer));
columnWidths = new Integer[initialColumns.length];
for (int i = 0; i < initialColumns.length; i++) {
columnWidths[i] = initialColumns[i].defaultWidth();
final int columnIndex = i;
tableViewer.getTable().getColumn(i).addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
columnWidths[columnIndex] = tableViewer.getTable().getColumn(columnIndex).getWidth();
}
});
tableViewer.getTable().getColumn(i).addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sorterProperties[0] = columnIndex;
sorterProperties[1] = tableManager.getSortDirection();
}
});
}
sorterProperties = new Integer[2];
sorterProperties[0] = null;
sorterProperties[1] = SWT.NONE;
// create the Table
createActionBars();
// set the Input
tableViewer.setContentProvider(new ViolationOutlineContentProvider(this));
tableViewer.setInput(resource);
// add the Filter and Listener
tableViewer.addFilter(viewerFilter);
tableViewer.addSelectionChangedListener(this);
}
use of org.eclipse.swt.events.ControlEvent in project MonjaDB by Kanatoko.
the class MActionView method init2.
// --------------------------------------------------------------------------------
public void init2() {
parent.setLayout(new FormLayout());
sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
FormData fd_sashForm1 = new FormData();
fd_sashForm1.top = new FormAttachment(0, 1);
fd_sashForm1.left = new FormAttachment(0, 1);
fd_sashForm1.right = new FormAttachment(100, -1);
fd_sashForm1.bottom = new FormAttachment(100, -1);
sashForm.setLayoutData(fd_sashForm1);
table = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
table.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
onTableStateChange();
}
});
table.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.keyCode == 13) {
e.doit = false;
if (// Shift + Enter
(e.stateMask & SWT.SHIFT) != 0) {
repeatActionsOnTable();
} else {
editActions();
}
}
}
});
FormData fd_table = new FormData();
fd_table.top = new FormAttachment(0, 0);
fd_table.bottom = new FormAttachment(100, 0);
fd_table.left = new FormAttachment(0, 0);
fd_table.right = new FormAttachment(100, 0);
table.setLayoutData(fd_table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn actionColumn = new TableColumn(table, SWT.NONE);
actionColumn.setWidth(100);
actionColumn.setText("Action");
TableColumn dateColumn = new TableColumn(table, SWT.NONE);
dateColumn.setWidth(100);
dateColumn.setText("Date");
editorComposite = new Composite(sashForm, SWT.BORDER);
editorComposite.setLayout(new FormLayout());
text = new Text(editorComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
onTextStateChange();
}
});
FormData fd_text = new FormData();
fd_text.bottom = new FormAttachment(100, -40);
fd_text.right = new FormAttachment(100);
fd_text.top = new FormAttachment(0);
fd_text.left = new FormAttachment(0);
text.setLayoutData(fd_text);
executeButton = new Button(editorComposite, SWT.NONE);
executeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
executeActionsOnText();
}
});
executeButton.setEnabled(false);
FormData fd_executeButton = new FormData();
fd_executeButton.top = new FormAttachment(text, 6);
fd_executeButton.left = new FormAttachment(text, -120, SWT.RIGHT);
fd_executeButton.right = new FormAttachment(100, -10);
executeButton.setLayoutData(fd_executeButton);
executeButton.setText("Execute");
editorComposite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
onSashResize();
}
});
MSwtUtil.getTableColumnWidthFromProperties("actionListTable", table, prop, new int[] { 200, 100 });
MSwtUtil.addListenerToTableColumns2(table, this);
// table.addListener( SWT.KeyDown, this );
table.addListener(SWT.MouseDoubleClick, this);
menuManager = new MenuManager();
Menu contextMenu = menuManager.createContextMenu(table);
table.setMenu(contextMenu);
// executeTableAction
{
redoAction = new Action() {
public void run() {
// ------------
repeatActionsOnTable();
}
};
// ------------
redoAction.setToolTipText("Redo Selected Actions");
redoAction.setText("Redo\tShift+Enter");
initAction(redoAction, "table_go.png", menuManager);
redoAction.setEnabled(false);
}
// editAction
{
editAction = new Action() {
public void run() {
// ------------
editActions();
}
};
// ------------
editAction.setToolTipText("Edit Actions on The Text Editor");
editAction.setText("Edit\tEnter");
initAction(editAction, "pencil.png", menuManager);
editAction.setEnabled(false);
}
dropDownMenu.add(new Separator());
menuManager.add(new Separator());
// executeAction
{
executeAction = new Action() {
public void run() {
// ------------
executeActionsOnText();
}
};
// ------------
executeAction.setToolTipText("Execute Actions on the Textarea");
executeAction.setText("Execute");
setActionImage(executeAction, "bullet_go.png");
addActionToToolBar(executeAction);
executeAction.setEnabled(false);
dropDownMenu.add(executeAction);
}
dropDownMenu.add(new Separator());
menuManager.add(new Separator());
// copyAction
{
copyAction = new Action() {
public void run() {
// ------------
copyActions();
}
};
// ------------
copyAction.setToolTipText("Copy Actions to Clipboard");
copyAction.setText("Copy");
setActionImage(copyAction, "page_copy.png");
addActionToToolBar(copyAction);
copyAction.setEnabled(false);
dropDownMenu.add(copyAction);
menuManager.add(copyAction);
}
dropDownMenu.add(new Separator());
menuManager.add(new Separator());
// clearAction
{
clearAction = new Action() {
public void run() {
// ------------
clearActions();
}
};
// ------------
clearAction.setToolTipText("Clear All");
clearAction.setText("Clear All");
initAction(clearAction, "table_delete.png", menuManager);
clearAction.setEnabled(false);
}
// saveAction
{
saveAction = new Action() {
public void run() {
// ------------
saveActions();
}
};
// ------------
saveAction.setToolTipText("Save Action");
saveAction.setText("Save");
initAction(saveAction, "cog_add.png", menuManager);
saveAction.setEnabled(false);
}
// load actionLogList
if (prop.containsKey(ACTION_LOG_LIST)) {
String savedStr = prop.getProperty(ACTION_LOG_LIST);
actionLogList = (java.util.List) JSON.parse(savedStr);
for (int i = 0; i < actionLogList.size(); ++i) {
Map actionLog = (Map) actionLogList.get(i);
addActionToTable(actionLog);
}
} else {
actionLogList = new LinkedList();
}
if (prop.containsKey(ACTIONLOG_COMPOSITE_WEIGHT)) {
(new Thread() {
public void run() {
MSystemUtil.sleep(0);
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
// ----
sashForm.setWeights(prop.getIntArrayProperty(ACTIONLOG_COMPOSITE_WEIGHT));
}
});
// ----
}
}).start();
} else {
sashForm.setWeights(new int[] { 70, 30 });
}
initializedTime = System.currentTimeMillis();
}
use of org.eclipse.swt.events.ControlEvent in project bndtools by bndtools.
the class RunPropertiesPart method createSection.
private void createSection(Section section, FormToolkit toolkit) {
section.setText("Runtime Properties");
final Composite composite = toolkit.createComposite(section);
section.setClient(composite);
// Create controls: Run Properties
Label lblRunProperties = toolkit.createLabel(composite, "OSGi Framework properties:");
tblRunProperties = toolkit.createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
viewRunProperties = new TableViewer(tblRunProperties);
runPropertiesModifier = new MapEntryCellModifier<>(viewRunProperties);
tblRunProperties.setHeaderVisible(true);
final TableColumn tblRunPropsCol1 = new TableColumn(tblRunProperties, SWT.NONE);
tblRunPropsCol1.setText("Name");
tblRunPropsCol1.setWidth(100);
final TableColumn tblRunPropsCol2 = new TableColumn(tblRunProperties, SWT.NONE);
tblRunPropsCol1.setText("Value");
tblRunPropsCol1.setWidth(100);
viewRunProperties.setUseHashlookup(true);
viewRunProperties.setColumnProperties(MapEntryCellModifier.getColumnProperties());
runPropertiesModifier.addCellEditorsToViewer();
viewRunProperties.setCellModifier(runPropertiesModifier);
viewRunProperties.setContentProvider(new MapContentProvider());
viewRunProperties.setLabelProvider(new PropertiesTableLabelProvider());
Control createRemovePropsToolBar = createRemovePropsPart.createControl(composite, SWT.FLAT | SWT.VERTICAL);
// Create controls: program args
Label lblProgramArgs = toolkit.createLabel(composite, "Launcher Arguments:");
txtProgramArgs = toolkit.createText(composite, "", SWT.MULTI | SWT.BORDER);
ToolTips.setupMessageAndToolTipFromSyntax(txtProgramArgs, Constants.RUNPROGRAMARGS);
// Create controls: vm args
Label lblVmArgs = toolkit.createLabel(composite, "JVM Arguments:");
txtVmArgs = toolkit.createText(composite, "", SWT.MULTI | SWT.BORDER);
ToolTips.setupMessageAndToolTipFromSyntax(txtVmArgs, Constants.RUNVM);
// Layout
GridLayout gl;
GridData gd;
gl = new GridLayout(2, false);
gl.marginWidth = 0;
gl.marginHeight = 0;
composite.setLayout(gl);
lblRunProperties.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
gd = new GridData(SWT.FILL, SWT.FILL, true, false);
gd.heightHint = 50;
gd.widthHint = 50;
tblRunProperties.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.TOP, false, true);
createRemovePropsToolBar.setLayoutData(gd);
lblProgramArgs.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gd.heightHint = 40;
gd.widthHint = 50;
txtProgramArgs.setLayoutData(gd);
lblVmArgs.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
gd.heightHint = 40;
gd.widthHint = 50;
txtVmArgs.setLayoutData(gd);
// Listeners
viewRunProperties.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
createRemovePropsPart.setRemoveEnabled(!viewRunProperties.getSelection().isEmpty());
}
});
createRemovePropsPart.addListener(new AddRemoveListener() {
@Override
public void addSelected() {
runProperties.put("name", "");
viewRunProperties.add("name");
markDirty();
viewRunProperties.editElement("name", 0);
}
@Override
public void removeSelected() {
@SuppressWarnings("rawtypes") Iterator iter = ((IStructuredSelection) viewRunProperties.getSelection()).iterator();
while (iter.hasNext()) {
Object item = iter.next();
runProperties.remove(item);
viewRunProperties.remove(item);
}
markDirty();
}
});
runPropertiesModifier.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
markDirty();
}
});
txtProgramArgs.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent ev) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
markDirty();
programArgs = txtProgramArgs.getText();
if (programArgs.length() == 0)
programArgs = null;
}
});
}
});
txtVmArgs.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent ev) {
lock.ifNotModifying(new Runnable() {
@Override
public void run() {
markDirty();
vmArgs = txtVmArgs.getText();
if (vmArgs.length() == 0)
vmArgs = null;
}
});
}
});
composite.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle area = composite.getClientArea();
Point preferredSize = tblRunProperties.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int width = area.width - 2 * tblRunProperties.getBorderWidth();
if (preferredSize.y > area.height + tblRunProperties.getHeaderHeight()) {
// Subtract the scrollbar width from the total column width
// if a vertical scrollbar will be required
Point vBarSize = tblRunProperties.getVerticalBar().getSize();
width -= vBarSize.x;
}
Point oldSize = tblRunProperties.getSize();
if (oldSize.x > area.width) {
// table is getting smaller so make the columns
// smaller first and then resize the table to
// match the client area width
tblRunPropsCol1.setWidth(width / 3);
tblRunPropsCol2.setWidth(width - tblRunPropsCol1.getWidth());
tblRunProperties.setSize(area.width, area.height);
} else {
// table is getting bigger so make the table
// bigger first and then make the columns wider
// to match the client area width
tblRunProperties.setSize(area.width, area.height);
tblRunPropsCol1.setWidth(width / 3);
tblRunPropsCol2.setWidth(width - tblRunPropsCol1.getWidth());
}
}
});
}
use of org.eclipse.swt.events.ControlEvent in project tesb-studio-se by Talend.
the class XmlTableForm method addFieldsListeners.
private void addFieldsListeners() {
nameFilter.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String pattern = nameFilter.getText();
SearchPattern matcher = new SearchPattern();
matcher.setPattern(pattern);
final List<Item> newList = new ArrayList<Item>();
for (Item item : items) {
if (matcher.matches(item.getLabel())) {
newList.add(item);
}
}
reftesTableContent(newList);
completeListener.setComplete(!getSelectionItems().isEmpty());
}
});
// Event checkBox action
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (e.detail == SWT.CHECK) {
((Item) e.item.getData()).setCheck(((TableItem) e.item).getChecked());
if (null != completeListener) {
completeListener.setComplete(!getSelectionItems().isEmpty());
}
}
}
});
table.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
table.getColumns()[0].setWidth(table.getClientArea().width - 2 * table.getBorderWidth());
}
});
selectAllTablesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
setChecked(true);
}
});
selectNoneTablesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
setChecked(false);
}
});
}
Aggregations