use of org.eclipse.swt.events.ControlEvent in project BiglyBT by BiglySoftware.
the class GeneralView method initialize.
public void initialize(Composite composite) {
parent = composite;
scrolled_comp = new ScrolledComposite(composite, SWT.V_SCROLL);
scrolled_comp.setExpandHorizontal(true);
scrolled_comp.setExpandVertical(true);
GridLayout layout = new GridLayout();
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
scrolled_comp.setLayout(layout);
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1);
Utils.setLayoutData(scrolled_comp, gridData);
genComposite = new Canvas(scrolled_comp, SWT.NULL);
GridLayout genLayout = new GridLayout();
genLayout.marginHeight = 0;
try {
genLayout.marginTop = 5;
} catch (NoSuchFieldError e) {
// pre 3.1
}
genLayout.marginWidth = 2;
genLayout.numColumns = 1;
genComposite.setLayout(genLayout);
scrolled_comp.setContent(genComposite);
scrolled_comp.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
piecesImageRefreshNeeded = true;
Utils.updateScrolledComposite(scrolled_comp);
}
});
Utils.execSWTThreadLater(0, new AERunnable() {
@Override
public void runSupport() {
swt_refreshInfo();
}
});
COConfigurationManager.addParameterListener("Graphics Update", this);
}
use of org.eclipse.swt.events.ControlEvent in project epp.mpc by eclipse.
the class CatalogSwitcher method createContents.
private void createContents(final Composite parent) {
createHeader(parent);
final ScrolledComposite scrollArea = new ScrolledComposite(parent, SWT.V_SCROLL);
scrollArea.setLayout(new FillLayout());
marketplaceArea = new Composite(scrollArea, SWT.NONE);
RowLayout layout = new RowLayout(SWT.HORIZONTAL);
layout.marginLeft = layout.marginRight = layout.marginTop = layout.marginBottom = layout.marginHeight = layout.marginWidth = 0;
marketplaceArea.setLayout(layout);
Color listBackground = getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
setBackground(listBackground);
marketplaceArea.setBackground(listBackground);
scrollArea.setBackground(listBackground);
List<CatalogDescriptor> catalogDescriptors = configuration.getCatalogDescriptors();
for (CatalogDescriptor catalogDescriptor : catalogDescriptors) {
createMarketplace(marketplaceArea, catalogDescriptor);
}
scrollArea.setContent(marketplaceArea);
scrollArea.setExpandVertical(true);
scrollArea.setExpandHorizontal(true);
scrollArea.setMinHeight(MIN_SCROLL_HEIGHT);
scrollArea.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle r = parent.getClientArea();
int scrollBarWidth = scrollArea.getVerticalBar().getSize().x;
scrollArea.setMinSize(marketplaceArea.computeSize(r.width - scrollBarWidth, SWT.DEFAULT));
}
});
}
use of org.eclipse.swt.events.ControlEvent in project vsDiaryWriter by shilongdai.
the class JournalWindow method open.
/**
* Open the window.
*
* @wbp.parser.entryPoint
*/
public void open() {
display = Display.getDefault();
shell = new Shell();
shell.setImage(SWTResourceManager.getImage(JournalWindow.class, "/logo.ico"));
shell.setSize(495, 480);
shell.setText("vsDiary - 6.0.0");
shell.setLayout(new GridLayout(8, false));
errorReporter = new ExceptionDisplayer(shell);
e.addObserver(errorReporter);
searchText = new Text(shell, SWT.BORDER);
searchText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 8, 1));
operationBar = new ToolBar(shell, SWT.FLAT | SWT.RIGHT);
operationBar.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 8, 1));
newJournal = new ToolItem(operationBar, SWT.NONE);
newJournal.setText(messages.getString("action.add"));
deleteJournal = new ToolItem(operationBar, SWT.NONE);
deleteJournal.setText(messages.getString("action.delete"));
recentLabel = new Label(shell, SWT.NONE);
recentLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
recentLabel.setText(messages.getString("label.dateRange"));
lowerBound = new DateTime(shell, SWT.DROP_DOWN);
Label lblTo = new Label(shell, SWT.NONE);
lblTo.setText(messages.getString("label.dateRangeTo"));
upperBoound = new DateTime(shell, SWT.DROP_DOWN);
search = new SearchJournal();
lowerBound.addSelectionListener(search.createSelectAdapter());
upperBoound.addSelectionListener(search.createSelectAdapter());
searchText.addModifyListener(search.createModifyAdapter());
newJournal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
newJournal();
}
});
deleteJournal.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
deleteJournal();
}
});
Menu mainMenu = new Menu(shell, SWT.BAR);
shell.setMenuBar(mainMenu);
MenuItem fileMenu = new MenuItem(mainMenu, SWT.CASCADE);
fileMenu.setText(messages.getString("menu.file"));
Menu menu = new Menu(fileMenu);
fileMenu.setMenu(menu);
MenuItem newEntryMenu = new MenuItem(menu, SWT.NONE);
newEntryMenu.setText(messages.getString("menu.new"));
newEntryMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
newJournal();
}
});
MenuItem exportMenu = new MenuItem(menu, SWT.NONE);
exportMenu.setText(messages.getString("menu.export"));
exportMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
FileDialog exportSelector = new FileDialog(shell);
exportSelector.setOverwrite(true);
exportSelector.setText("Enter a location to export");
exportSelector.open();
if (exportSelector.getFileName() == null || exportSelector.getFileName().length() == 0) {
return;
}
String toExport = new File(exportSelector.getFilterPath(), exportSelector.getFileName()).getAbsolutePath();
if (toExport != null) {
JournalWindow.this.e.submit(f.getExportEntriesOperation(toExport));
}
}
});
MenuItem mntmImport = new MenuItem(menu, SWT.NONE);
mntmImport.setText(messages.getString("menu.import"));
MenuItem exit = new MenuItem(menu, SWT.NONE);
exit.setText(messages.getString("menu.exit"));
exit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
shell.dispose();
}
});
mntmImport.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
FileDialog selecter = new FileDialog(shell);
selecter.setText("Select the file to import");
selecter.open();
if (selecter.getFileName() == null || selecter.getFileName().length() == 0) {
return;
}
String selected = new File(selecter.getFilterPath(), selecter.getFileName()).getAbsolutePath();
if (selected == null || selected.length() == 0) {
return;
}
JournalWindow.this.e.submit(f.getImportEntriesOperation(selected));
search.displayAll();
searchText.setText("");
}
});
MenuItem editMenu = new MenuItem(mainMenu, SWT.CASCADE);
editMenu.setText(messages.getString("menu.edit"));
Menu menu_1 = new Menu(editMenu);
editMenu.setMenu(menu_1);
MenuItem deleteEntryMenu = new MenuItem(menu_1, SWT.NONE);
deleteEntryMenu.setText(messages.getString("menu.delete"));
deleteEntryMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
deleteJournal();
}
});
MenuItem clearEntrieMenu = new MenuItem(menu_1, SWT.NONE);
clearEntrieMenu.setText(messages.getString("menu.clear"));
clearEntrieMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
boolean toClear = MessageDialog.openConfirm(shell, messages.getString("warning.confirm"), messages.getString("warning.clear"));
if (toClear) {
JournalWindow.this.e.submit(f.getClearEntriesOperation());
search.searchJournals();
}
}
});
MenuItem showAllMenu = new MenuItem(menu_1, SWT.NONE);
showAllMenu.setText(messages.getString("menu.showAll"));
showAllMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
search.displayAll();
}
});
MenuItem preferenceMenu = new MenuItem(mainMenu, SWT.CASCADE);
preferenceMenu.setText(messages.getString("menu.settings"));
Menu settingMenu = new Menu(preferenceMenu);
preferenceMenu.setMenu(settingMenu);
MenuItem changeConfigMenu = new MenuItem(settingMenu, SWT.NONE);
changeConfigMenu.setText(messages.getString("menu.config"));
changeConfigMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
super.widgetSelected(arg0);
PreferenceDialog pd = new PreferenceDialog(shell, PreferenceGUIManager.getMger());
int result = pd.open();
if (result == Window.OK) {
JournalWindow.this.e.submit(StoreConfigurationBufferOperation.applyOperation());
}
}
});
MenuItem passwordMenu = new MenuItem(settingMenu, SWT.NONE);
passwordMenu.setText(messages.getString("menu.passwd"));
passwordMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
super.widgetSelected(arg0);
ChangePasswordPrompt prompt = new ChangePasswordPrompt();
prompt.open();
}
});
MenuItem helpMenu = new MenuItem(mainMenu, SWT.CASCADE);
helpMenu.setText(messages.getString("menu.help"));
Menu menu_2 = new Menu(helpMenu);
helpMenu.setMenu(menu_2);
MenuItem aboutMenu = new MenuItem(menu_2, SWT.NONE);
aboutMenu.setText(messages.getString("menu.help"));
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
pgTable = new PageableTable(shell, SWT.NONE, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, 10, PageResultContentProvider.getInstance(), null, ResultAndNavigationPageLinksRendererFactory.getFactory());
GridData gd_pgTable = new GridData(SWT.FILL, SWT.FILL, true, true);
gd_pgTable.horizontalSpan = 8;
pgTable.setLayoutData(gd_pgTable);
tableViewer = pgTable.getViewer();
searchResults = tableViewer.getTable();
searchResults.setLayoutData(new GridData(GridData.FILL_BOTH));
tableViewer.setContentProvider(new ArrayContentProvider());
searchResults.setHeaderVisible(true);
searchResults.setLinesVisible(true);
final TableViewerColumn titles = new TableViewerColumn(tableViewer, SWT.NONE);
titles.getColumn().setWidth(200);
titles.getColumn().setText(messages.getString("table.title"));
titles.getColumn().setResizable(true);
titles.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
JournalPointer j = (JournalPointer) element;
return j.getTitle();
}
});
final TableViewerColumn dates = new TableViewerColumn(tableViewer, SWT.NONE);
dates.getColumn().setWidth(200);
dates.getColumn().setResizable(true);
dates.getColumn().setText(messages.getString("table.date"));
dates.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
JournalPointer j = (JournalPointer) element;
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM);
return df.format(j.getDate());
}
});
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent arg0) {
StructuredSelection selected = (StructuredSelection) arg0.getSelection();
if (selected.isEmpty()) {
return;
}
JournalPointer pointer = (JournalPointer) selected.getFirstElement();
OperationWithResult<Journal> get = f.getGetEntryOperation(pointer.getId());
e.submit(get);
Journal result = new JournalEditor().open(get.getResult());
if (result == null) {
return;
}
e.submit(f.getEditContentOperation(result.getId(), result.getContent()));
e.submit(f.getEditSubjectOperation(result.getId(), result.getSubject()));
search.searchJournals();
}
});
aboutMenu.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
MessageDialog.openInformation(shell, messages.getString("menu.about"), "This is an application to write secure and authenticated diary digitally. It is dedicated to Abigail Nunez.");
}
});
shell.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent arg0) {
// TODO Auto-generated method stub
super.controlResized(arg0);
Rectangle area = shell.getClientArea();
Point preferredSize = searchResults.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int width = area.width - searchResults.getBorderWidth() * 2;
if (preferredSize.y > area.height + searchResults.getHeaderHeight()) {
// Subtract the scrollbar width from the total column width
// if a vertical scrollbar will be required
Point vBarSize = searchResults.getVerticalBar().getSize();
width -= vBarSize.x;
}
Point oldSize = searchResults.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
titles.getColumn().setWidth(width / 2);
dates.getColumn().setWidth(width - titles.getColumn().getWidth() - 25);
} else {
// table is getting bigger so make the table
// bigger first and then make the columns wider
// to match the client area width
titles.getColumn().setWidth(width / 2);
dates.getColumn().setWidth(width - titles.getColumn().getWidth() - 25);
}
}
});
search.displayAll();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
use of org.eclipse.swt.events.ControlEvent in project mdw-designer by CenturyLinkCloud.
the class ListView method createTable.
private void createTable(Composite parent) {
int style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
table = new Table(parent, style);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 10;
table.setLayoutData(gridData);
table.setLinesVisible(true);
table.setHeaderVisible(true);
for (int i = 0; i < columnSpecs.size(); i++) {
ColumnSpec colSpec = columnSpecs.get(i);
int styles = SWT.LEFT;
if (colSpec.readOnly)
style = style | SWT.READ_ONLY;
TableColumn column = new TableColumn(table, styles, i);
column.setText(colSpec.label);
column.setWidth(colSpec.width);
column.setResizable(colSpec.resizable);
column.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
TableColumn sortColumn = tableViewer.getTable().getSortColumn();
TableColumn currentColumn = (TableColumn) e.widget;
int direction = tableViewer.getTable().getSortDirection();
if (sortColumn == currentColumn) {
direction = direction == SWT.UP ? SWT.DOWN : SWT.UP;
} else {
tableViewer.getTable().setSortColumn(currentColumn);
direction = SWT.UP;
}
tableViewer.getTable().setSortDirection(direction);
// TODO handle column sort
refreshTable();
}
});
}
// double-click
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
handleOpen(e.item.getData());
}
});
// right-click menu
table.addListener(SWT.MenuDetect, new Listener() {
public void handleEvent(Event event) {
table.setMenu(createContextMenu(table.getShell()));
}
});
// auto-adjust column width
table.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
int tableWidth = table.getBounds().width;
int cumulative = 0;
TableColumn[] tableColumns = table.getColumns();
for (int i = 0; i < tableColumns.length; i++) {
if (i == tableColumns.length - 1)
tableColumns[i].setWidth(tableWidth - cumulative - 25);
cumulative += tableColumns[i].getWidth();
}
}
});
}
use of org.eclipse.swt.events.ControlEvent in project mdw-designer by CenturyLinkCloud.
the class VariableValuesTableContainer method createTable.
private void createTable(Composite parent) {
int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
table = new Table(parent, style);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 2;
gridData.verticalIndent = 3;
gridData.verticalAlignment = SWT.FILL;
gridData.heightHint = 150;
table.setLayoutData(gridData);
table.setLinesVisible(true);
table.setHeaderVisible(true);
for (int i = 0; i < columnSpecs.size(); i++) {
ColumnSpec colSpec = columnSpecs.get(i);
int styles = SWT.LEFT;
if (colSpec.readOnly)
style = style | SWT.READ_ONLY;
TableColumn column = new TableColumn(table, styles, i);
column.setText(colSpec.label);
column.setWidth(colSpec.width);
column.setResizable(colSpec.resizable);
}
table.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
int tableWidth = table.getBounds().width;
int cumulative = 0;
TableColumn[] tableColumns = table.getColumns();
for (int i = 0; i < tableColumns.length; i++) {
if (i == tableColumns.length - 1)
tableColumns[i].setWidth(tableWidth - cumulative - 5);
cumulative += tableColumns[i].getWidth();
}
}
});
table.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
VariableValue varVal = (VariableValue) e.item.getData();
String originalValue = varVal.getValue();
VariableValueDialog varValDlg = new VariableValueDialog(getShell(), varVal);
varValDlg.setHelpAvailable(false);
if (varValDlg.open() == Dialog.OK && !originalValue.equals(varVal.getValue())) {
varVal.setValue(varValDlg.getVariableValue().getValue());
tableViewer.update(varVal, null);
fireDirtyStateChange(true);
} else {
varVal.setValue(originalValue);
}
}
});
}
Aggregations