use of org.eclipse.swt.events.ControlEvent in project tdi-studio-se by Talend.
the class VersionManagementPage method createItemTableColumns.
@Override
protected void createItemTableColumns() {
TableColumn itemColumn = new TableColumn(itemTable, SWT.CENTER);
//$NON-NLS-1$
itemColumn.setText(Messages.getString("VersionManagementDialog.Items"));
itemColumn.setWidth(110);
TableColumn oldVersionColumn = new TableColumn(itemTable, SWT.CENTER);
//$NON-NLS-1$
oldVersionColumn.setText(Messages.getString("VersionManagementDialog.Version"));
oldVersionColumn.setWidth(60);
TableColumn versionColumn = new TableColumn(itemTable, SWT.CENTER);
//$NON-NLS-1$
versionColumn.setText(Messages.getString("VersionManagementDialog.NewVersion"));
versionColumn.setWidth(82);
final TableColumn delColumn = new TableColumn(itemTable, SWT.CENTER);
//$NON-NLS-1$
delColumn.setText("");
delColumn.setWidth(26);
delColumn.setResizable(false);
versionColumn.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
if (!isFixedVersion()) {
refreshTableItems();
}
}
});
itemTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
checkButtonsState();
}
});
}
use of org.eclipse.swt.events.ControlEvent in project tdi-studio-se by Talend.
the class DataMapTableView method createExpressionCellEditor.
protected TextCellEditor createExpressionCellEditor(final TableViewerCreator tableViewerCreator, TableViewerCreatorColumn column, final Zone[] zones, boolean isConstraintExpressionCellEditor) {
final TextCellEditorWithProposal cellEditor = new TextCellEditorWithProposal(tableViewerCreator.getTable(), SWT.MULTI | SWT.BORDER, column);
final Text expressionTextEditor = (Text) cellEditor.getControl();
if (isConstraintExpressionCellEditor) {
// moved to it's caller to execute
// constraintExpressionTextEditor = expressionTextEditor;
} else {
columnExpressionTextEditor = expressionTextEditor;
}
cellEditor.addListener(new ICellEditorListener() {
Text text = (Text) cellEditor.getControl();
@Override
public void applyEditorValue() {
ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
mapperManager.getUiManager().parseNewExpression(text.getText(), (ITableEntry) modifiedObjectInfo.getCurrentModifiedBean(), true);
}
@Override
public void cancelEditor() {
ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
text.setText((String) modifiedObjectInfo.getOriginalPropertyBeanValue());
ITableEntry tableEntry = (ITableEntry) (modifiedObjectInfo.getCurrentModifiedBean() != null ? modifiedObjectInfo.getCurrentModifiedBean() : modifiedObjectInfo.getPreviousModifiedBean());
String originalExpression = (String) modifiedObjectInfo.getOriginalPropertyBeanValue();
mapperManager.getUiManager().parseNewExpression(originalExpression, tableEntry, true);
}
@Override
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
if (expressionTextEditor.isFocusControl() || lastExpressionEditorTextWhichLostFocus == expressionTextEditor) {
ModifiedObjectInfo modifiedObjectInfo = tableViewerCreator.getModifiedObjectInfo();
ITableEntry tableEntry = (ITableEntry) (modifiedObjectInfo.getCurrentModifiedBean() != null ? modifiedObjectInfo.getCurrentModifiedBean() : modifiedObjectInfo.getPreviousModifiedBean());
mapperManager.getUiManager().parseNewExpression(text.getText(), tableEntry, false);
resizeTextEditor(text, tableViewerCreator);
}
}
});
expressionTextEditor.addControlListener(new ControlListener() {
ExecutionLimiter executionLimiter = null;
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (executionLimiter == null) {
executionLimiter = new ExecutionLimiter(50, true) {
@Override
public void execute(boolean isFinalExecution, Object data) {
if (isFinalExecution && !expressionTextEditor.isDisposed()) {
expressionTextEditor.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
if (expressionTextEditor.isDisposed()) {
return;
}
resizeTextEditor(expressionTextEditor, tableViewerCreator);
}
});
}
}
};
}
executionLimiter.startIfExecutable();
}
});
expressionTextEditor.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
ITableEntry currentModifiedEntry = (ITableEntry) tableViewerCreator.getModifiedObjectInfo().getCurrentModifiedBean();
initExpressionProposals(cellEditor, zones, tableViewerCreator, currentModifiedEntry);
resizeTextEditor(expressionTextEditor, tableViewerCreator);
StyledTextHandler styledTextHandler = mapperManager.getUiManager().getTabFolderEditors().getStyledTextHandler();
styledTextHandler.setCurrentEntry(currentModifiedEntry);
//$NON-NLS-1$
styledTextHandler.setTextWithoutNotifyListeners(currentModifiedEntry.getExpression() == null ? "" : currentModifiedEntry.getExpression());
}
@Override
public void focusLost(FocusEvent e) {
expressionEditorTextSelectionBeforeFocusLost = expressionTextEditor.getSelection();
lastExpressionEditorTextWhichLostFocus = expressionTextEditor;
}
});
column.setCellEditor(cellEditor, new CellEditorValueAdapter() {
@Override
public Object getCellEditorTypedValue(CellEditor cellEditor, Object originalTypedValue) {
return super.getCellEditorTypedValue(cellEditor, originalTypedValue);
}
@Override
public String getColumnText(CellEditor cellEditor, Object bean, Object cellEditorTypedValue) {
//$NON-NLS-1$ //$NON-NLS-2$
return super.getColumnText(cellEditor, bean, cellEditorTypedValue).replaceAll("[\r\n\t]+", " ... ");
}
@Override
public Object getOriginalTypedValue(CellEditor cellEditor, Object cellEditorTypedValue) {
return super.getOriginalTypedValue(cellEditor, cellEditorTypedValue);
}
});
return cellEditor;
}
use of org.eclipse.swt.events.ControlEvent in project tdi-studio-se by Talend.
the class RowGeneratorUI method addParentListeners.
/**
* qzhang Comment method "addParentListeners".
*
* @param uiManager
* @param uiProperties
*/
private void addParentListeners(final UIManager uiManager, final ExternalRowGeneratorUiProperties uiProperties) {
rowGenUIParent.addListener(SWT.Close, new Listener() {
@Override
public void handleEvent(Event event) {
if (uiManager.getRowGenResponse() == SWT.NONE) {
uiManager.closeRowGenerator(SWT.CANCEL, false);
}
}
});
rowGenUIParent.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
updateBackground(false, true);
}
@Override
public void focusLost(FocusEvent e) {
}
});
// store size if not maximized
if (rowGenUIParent instanceof Shell) {
((Shell) rowGenUIParent).addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (!((Shell) e.getSource()).getMaximized()) {
ExternalRowGeneratorUiProperties.setBoundsRowGen(((Shell) e.getSource()).getBounds());
}
}
});
}
}
use of org.eclipse.swt.events.ControlEvent in project cubrid-manager by CUBRID.
the class BrokerDashboardViewPart method createPartControl.
/**
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*
* @param parent the parent composite
*/
public void createPartControl(Composite parent) {
final ScrolledComposite scrolledComp = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
composite = new Composite(scrolledComp, SWT.NONE);
composite.setLayout(new GridLayout());
BrokerTblColumnSetHelp bcsh = BrokerTblColumnSetHelp.getInstance();
bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusBasicColumn, BrokerStatusBasicColumn.values());
bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusAsColumn, BrokerStatusAsColumn.values());
bcsh.loadSetting(BrokerTblColumnSetHelp.StatusColumn.BrokerStatusJqColumn, BrokerStatusJqColumn.values());
brokerTablePart.setServerInfo(serverInfo);
brokerTablePart.setAppendDiag(true);
basicTableViewer = brokerTablePart.createBasicTable(composite);
asTableViewer = brokerTablePart.createAsTable(composite);
jqTableViewer = brokerTablePart.createJobTable(composite);
makeActions();
composite.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent event) {
updateTableLayout();
}
});
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) asTableViewer.getSelection();
ApplyServerInfo as = (ApplyServerInfo) (selection.toArray()[0]);
RestartAction restartAcion = new RestartAction(as.getAs_id());
manager.add(restartAcion);
}
});
Menu contextMenu = menuManager.createContextMenu(asTableViewer.getControl());
asTableViewer.getControl().setMenu(contextMenu);
scrolledComp.setContent(composite);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
scrolledComp.setMinHeight(300);
scrolledComp.setMinWidth(800);
}
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();
}
Aggregations