use of org.eclipse.jface.viewers.SelectionChangedEvent in project azure-tools-for-java by Microsoft.
the class BlobExplorerFileEditor method createTable.
private Table createTable(Composite parent) {
blobListTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION);
blobListTable.setHeaderVisible(true);
blobListTable.setLinesVisible(true);
GridData gridData = new GridData();
// gridData.heightHint = 75;
gridData.horizontalAlignment = SWT.FILL;
gridData.verticalAlignment = SWT.FILL;
gridData.grabExcessVerticalSpace = true;
gridData.grabExcessHorizontalSpace = true;
GridLayout gridLayoutTable = new GridLayout();
gridLayoutTable.numColumns = 6;
gridLayoutTable.marginRight = 0;
blobListTable.setLayout(gridLayoutTable);
blobListTable.setLayoutData(gridData);
for (int i = 0; i < 6; i++) {
new TableColumn(blobListTable, SWT.FILL);
}
blobListTable.getColumn(0).setText("");
blobListTable.getColumn(1).setText("Name");
blobListTable.getColumn(2).setText("Size");
blobListTable.getColumn(3).setText("Last Modified (UTC)");
blobListTable.getColumn(4).setText("Content Type");
blobListTable.getColumn(5).setText("URL");
blobListTable.getColumn(0).setWidth(25);
blobListTable.getColumn(1).setWidth(280);
blobListTable.getColumn(2).setWidth(60);
blobListTable.getColumn(3).setWidth(110);
blobListTable.getColumn(4).setWidth(140);
blobListTable.getColumn(5).setWidth(250);
tableViewer = new TableViewer(blobListTable);
tableViewer.setUseHashlookup(true);
tableViewer.setContentProvider(new BlobListContentProvider());
tableViewer.setLabelProvider(new BlobListLabelProvider());
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
boolean directorySelected = tableViewer.getTable().getSelectionIndex() > -1 && isDirectorySelected();
deleteButton.setEnabled(!directorySelected);
// openButton.setEnabled(!directorySelected);
saveAsButton.setEnabled(!directorySelected);
}
});
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
tableSelection();
}
});
fillGrid();
return blobListTable;
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project cubrid-manager by CUBRID.
the class RecentlyUsedSQLComposite method createHistoryTable.
/**
* createHistoryTable
* @param bottomSash
*/
public void createHistoryTable(SashForm bottomSash) {
sqlHistoryTable = new TableViewer(bottomSash, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
sqlHistoryTable.getTable().setHeaderVisible(true);
sqlHistoryTable.getTable().setLinesVisible(true);
// final TableViewerColumn columnNO = new TableViewerColumn(
// sqlHistoryTable, SWT.CENTER);
// columnNO.getColumn().setWidth(40);
// columnNO.getColumn().setText("NO");
final TableViewerColumn columnRunTime = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnRunTime.getColumn().setWidth(155);
columnRunTime.getColumn().setText(Messages.recentlyUsedSQLColumnRunTime);
columnRunTime.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.EXECUTETIME_ASC : Sorter.EXECUTETIME_DESC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
final TableViewerColumn columnSQL = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnSQL.getColumn().setWidth(250);
columnSQL.getColumn().setText(Messages.recentlyUsedSQLColumn);
columnSQL.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.SQL_ASC : Sorter.SQL_DEC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
final TableViewerColumn columnElapseTime = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnElapseTime.getColumn().setWidth(100);
columnElapseTime.getColumn().setText(Messages.recentlyUsedSQLColumnElapseTime);
columnElapseTime.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.ELAPSETIME_ASC : Sorter.ELAPSETIME_DESC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
final TableViewerColumn columnInfo = new TableViewerColumn(sqlHistoryTable, SWT.LEFT);
columnInfo.getColumn().setWidth(300);
columnInfo.getColumn().setText(Messages.recentlyUsedSQLColumnLOG);
columnInfo.getColumn().addSelectionListener(new SelectionAdapter() {
boolean asc = true;
@Override
public void widgetSelected(SelectionEvent e) {
sqlHistoryTable.setSorter(asc ? Sorter.LOG_ASC : Sorter.LOG_DESC);
sqlHistoryTable.getTable().setSortDirection(asc ? SWT.DOWN : SWT.UP);
asc = !asc;
}
});
sqlHistoryTable.setContentProvider(new HistorySQLContentProvider());
provider = new HistorySQLLabelProvider();
sqlHistoryTable.setLabelProvider(provider);
sqlHistoryTable.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(final SelectionChangedEvent event) {
SQLHistoryDetail history = (SQLHistoryDetail) sqlHistoryTable.getElementAt(sqlHistoryTable.getTable().getSelectionIndex());
if (history != null) {
logMessageArea.setText(history.getExecuteInfo() + StringUtil.NEWLINE + history.getSql());
}
}
});
sqlHistoryTable.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
SQLHistoryDetail history = (SQLHistoryDetail) selection.getFirstElement();
logMessageArea.setText(history.getExecuteInfo() + StringUtil.NEWLINE + StringUtil.NEWLINE + history.getSql());
int start = editor.getAllQueries().length();
editor.setQuery(StringUtil.NEWLINE + history.getSql(), true, false, false);
int end = start + history.getSql().length();
// "/n" take a postion ,so both start and end should + 1
editor.setSelection(start + 1, end + 1);
}
});
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project cubrid-manager by CUBRID.
the class LayoutManager method fireSelectionChanged.
/**
*
* Fire selection change event
*
* @param selection the ISelection object
*/
public void fireSelectionChanged(ISelection selection) {
SelectionChangedEvent event = new SelectionChangedEvent(getSelectionProvider(), selection);
selectionChanged(event);
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project cubrid-manager by CUBRID.
the class ShardKeysPanel method initial.
private void initial() {
insertKeyItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
addNewKey();
}
});
deletekeyItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
keyListTable.forceFocus();
deleteKey();
}
});
keyListTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@SuppressWarnings("unchecked")
public void selectionChanged(SelectionChangedEvent arg0) {
int selectedItemCount = keyListTable.getSelectionCount();
if (selectedItemCount > 0) {
deletekeyItem.setEnabled(true);
} else {
deletekeyItem.setEnabled(false);
}
if (selectedItemCount == 1) {
String keyName = ((Map<String, String>) keyListTable.getSelection()[0].getData()).get("0");
keyInfoGroup.setText("Key Info: " + keyName);
insertKeyInfoItem.setEnabled(true);
saveShardKey();
currentShardKey = module.getShardKeysFile().getKey(keyName);
initKeyInfoList();
keyInfoTableViewer.refresh();
setKeyInfoColor();
} else {
insertKeyInfoItem.setEnabled(false);
}
}
});
setKeyListColor();
linkEditorForKeyListTable();
insertKeyInfoItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
addNewKeyInfo();
}
});
deletekeyInfoItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
keyInfoTable.forceFocus();
deleteKeyInfo();
}
});
keyInfoTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent arg0) {
int selectedItemCount = keyInfoTable.getSelectionCount();
if (selectedItemCount > 0) {
deletekeyInfoItem.setEnabled(true);
} else {
deletekeyInfoItem.setEnabled(false);
}
}
});
setKeyInfoColor();
linkEditorForKeyInfoTable();
}
use of org.eclipse.jface.viewers.SelectionChangedEvent in project bndtools by bndtools.
the class TestSuiteLabelProvider method createSection.
private void createSection(Section section, FormToolkit toolkit) {
section.setText(Messages.TestSuitesPart_section_junit_tests);
Composite composite = toolkit.createComposite(section);
section.setClient(composite);
// Section toolbar buttons
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(Messages.TestSuitesPart_add);
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(Messages.TestSuitesPart_remove);
removeItem.setEnabled(false);
Table table = toolkit.createTable(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
viewer = new TableViewer(table);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new TestSuiteLabelProvider());
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
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
boolean enabled = selection != null && !selection.isEmpty();
removeItem.setEnabled(enabled);
btnMoveUp.setEnabled(enabled);
btnMoveDown.setEnabled(enabled);
getManagedForm().fireSelectionChanged(TestSuitesPart.this, selection);
}
});
viewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
String name = (String) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (name != null)
doOpenSource(name);
}
});
viewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { ResourceTransfer.getInstance() }, new TestSuiteListDropAdapter());
addItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doAdd();
}
});
removeItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doRemove();
}
});
table.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
if (e.character == SWT.DEL) {
doRemove();
} else if (e.character == '+') {
doAdd();
}
}
});
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