use of org.eclipse.swt.widgets.ToolItem in project tdi-studio-se by Talend.
the class ToolbarInputZone method addPreviewToolItems.
private void addPreviewToolItems() {
if (PluginChecker.isTraceDebugPluginLoaded() && getMapperManager().isTracesActive()) {
final RunProcessContext activeContext = RunProcessPlugin.getDefault().getRunProcessContextManager().getActiveContext();
if (activeContext == null) {
return;
}
new ToolItem(getToolBarActions(), SWT.SEPARATOR);
previousRow = new ToolItem(getToolBarActions(), SWT.PUSH);
previousRow.setEnabled(activeContext.isRunning());
previousRow.setToolTipText("Previous Row");
previousRow.setImage(ImageProvider.getImage(EImage.LEFT_ICON));
currentRowLabel = new ToolItem(getToolBarActions(), SWT.PUSH | SWT.BORDER);
currentRowLabel.setEnabled(false);
currentRowLabel.setText(getCurrentRowString());
currentRowLabel.setToolTipText("Current Row");
currentRowLabel.setWidth(50);
nextRow = new ToolItem(getToolBarActions(), SWT.PUSH);
nextRow.setEnabled(!getMapperManager().componentIsReadOnly());
nextRow.setToolTipText("Next Row");
nextRow.setImage(ImageProvider.getImage(EImage.RIGHT_ICON));
nextBreakpoint = new ToolItem(getToolBarActions(), SWT.PUSH);
nextBreakpoint.setToolTipText("Next Breakpoint");
nextBreakpoint.setImage(ImageProvider.getImage(EImage.RIGHTX_ICON));
Boolean bc = activeContext.checkBreakpoint();
if (!bc) {
nextBreakpoint.setEnabled(bc);
} else {
nextBreakpoint.setEnabled(activeContext.isRunning());
}
killBtn = new ToolItem(getToolBarActions(), SWT.PUSH);
killBtn.setToolTipText("Kill");
killBtn.setImage(ImageProvider.getImage(ERunprocessImages.KILL_PROCESS_ACTION));
killBtn.setEnabled(activeContext.isRunning());
previousRow.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeContext.setPreviousRow(true);
}
});
nextRow.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (!activeContext.isRunning()) {
for (DataMapTableView dataMapTableView : getMapperManager().getUiManager().getOutputsTablesView()) {
dataMapTableView.notifyFocusLost();
}
if (getMapperManager().isDataChanged()) {
boolean closeWindow = MessageDialog.openConfirm(getComposite().getShell(), //$NON-NLS-1$
"tMap configuration modified", //$NON-NLS-1$
"Do you want to apply the modification of the tMap now ?");
// save change and regenerate code
if (closeWindow) {
IExternalNode externalNode = getMapperManager().getAbstractMapComponent().getExternalNode();
IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (externalNode != null && (part instanceof AbstractMultiPageTalendEditor)) {
INode node = externalNode.getOriginalNode();
if (node != null && node instanceof Node) {
Command cmd = new ExternalNodeChangeCommand((Node) node, externalNode);
CommandStack cmdStack = (CommandStack) part.getAdapter(CommandStack.class);
cmdStack.execute(cmd);
}
}
}
}
activeContext.setLastIsRow(true);
IDebugProcessService service = (IDebugProcessService) GlobalServiceRegister.getDefault().getService(IDebugProcessService.class);
service.debugProcess();
} else {
activeContext.setNextRow(true);
}
}
});
nextBreakpoint.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
activeContext.setNextBreakPoint(true);
}
});
killBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IDebugProcessService service = (IDebugProcessService) GlobalServiceRegister.getDefault().getService(IDebugProcessService.class);
service.debugKill();
killBtn.setEnabled(false);
previousRow.setEnabled(false);
nextBreakpoint.setEnabled(false);
}
});
propertyListener = new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent evt) {
final String propName = evt.getPropertyName();
ProcessManager.getInstance().getProcessShell().getDisplay().syncExec(new Runnable() {
public void run() {
if (RunProcessContext.PREVIOUS_ROW.equals(propName)) {
boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
if (!previousRow.isDisposed() && enabled != previousRow.isEnabled()) {
previousRow.setEnabled(enabled);
}
} else if (RunProcessContext.PROP_RUNNING.equals(propName)) {
boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
if (!previousRow.isDisposed() && enabled != previousRow.isEnabled()) {
previousRow.setEnabled(enabled);
}
if (!nextBreakpoint.isDisposed() && enabled != nextBreakpoint.isEnabled()) {
Boolean bc = activeContext.checkBreakpoint();
if (!bc) {
nextBreakpoint.setEnabled(bc);
} else {
nextBreakpoint.setEnabled(enabled);
}
}
if (!killBtn.isDisposed() && enabled != killBtn.isEnabled()) {
killBtn.setEnabled(enabled);
}
if (!nextRow.isDisposed()) {
nextRow.setEnabled(true);
}
} else if (RunProcessContext.NEXTBREAKPOINT.equals(propName)) {
boolean running = ((Boolean) evt.getNewValue()).booleanValue();
if (!nextBreakpoint.isDisposed()) {
nextBreakpoint.setEnabled(running);
}
if (!nextRow.isDisposed()) {
nextRow.setEnabled(true);
}
} else if (RunProcessContext.BREAKPOINT_BAR.equals(propName)) {
boolean enable = ((Boolean) evt.getNewValue()).booleanValue();
if (!enable) {
if (!previousRow.isDisposed()) {
previousRow.setEnabled(false);
}
if (!nextRow.isDisposed()) {
nextRow.setEnabled(false);
}
if (!nextBreakpoint.isDisposed()) {
nextBreakpoint.setEnabled(false);
}
}
}
}
});
}
};
activeContext.addPropertyChangeListener(propertyListener);
}
}
use of org.eclipse.swt.widgets.ToolItem in project tdi-studio-se by Talend.
the class ToolbarOutputZone method createComponents.
/**
* DOC amaumont Comment method "createComponents".
*/
private void createComponents() {
addOutputItem = new ToolItem(getToolBarActions(), SWT.PUSH);
addOutputItem.setEnabled(!getMapperManager().componentIsReadOnly());
//$NON-NLS-1$
addOutputItem.setToolTipText(Messages.getString("ToolbarOutputZone.widgetTooltip.addOutputTable"));
addOutputItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.ADD_ICON)));
removeOutputItem = new ToolItem(getToolBarActions(), SWT.PUSH);
removeOutputItem.setEnabled(false);
removeOutputItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.MINUS_ICON)));
//$NON-NLS-1$
removeOutputItem.setToolTipText(Messages.getString("ToolbarOutputZone.widgetTooltip.removeOutputTable"));
addCommonsComponents();
new ToolItem(getToolBarActions(), SWT.SEPARATOR);
guessItem = new ToolItem(getToolBarActions(), SWT.PUSH);
guessItem.setEnabled(!getMapperManager().componentIsReadOnly());
//$NON-NLS-1$
guessItem.setToolTipText(Messages.getString("ToolbarOutputZone.widgetTooltip.mapInputAndOutput"));
//$NON-NLS-1$
guessItem.setText(Messages.getString("ToolbarOutputZone.widgetText.autoMap"));
// dieOnError = new ToolItem(getToolBarActions(), SWT.CHECK);
// dieOnError.setEnabled(!getMapperManager().componentIsReadOnly());
// dieOnError.setToolTipText("tmap die on error");
// AbstractMapComponent component = getMapperManager().getAbstractMapComponent();
// IElementParameter elementParameter = component.getElementParameter("DIE_ON_ERROR");
// boolean isDieOnError = false;
// if (elementParameter != null && elementParameter.getValue() != null) {
// isDieOnError = Boolean.valueOf(elementParameter.getValue().toString());
// }
// dieOnError.setSelection(isDieOnError);
// Image image = ImageProviderMapper.getImage(isDieOnError ? ImageInfo.CHECKED_ICON : ImageInfo.UNCHECKED_ICON);
// dieOnError.setImage(image);
// dieOnError.setText("Die on error");
}
use of org.eclipse.swt.widgets.ToolItem in project tdi-studio-se by Talend.
the class ScdSection method createToolbar.
/**
* DOC chuang Comment method "createToolbar".
*
* @param headerComposite
*/
protected void createToolbar(Composite headerComposite) {
toolBar = new ToolBar(headerComposite, SWT.FLAT | SWT.RIGHT | SWT.NONE);
addEntryItem = new ToolItem(toolBar, SWT.PUSH);
addEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.ADD_ICON)));
toolBar.setBackground(SWTResourceManager.getColor(IColorConstants.YELLOW));
removeEntryItem = new ToolItem(toolBar, SWT.PUSH);
removeEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.MINUS_ICON)));
// removeEntryItem.setBackground(SWTResourceManager.getColor(IColorConstants.YELLOW));
moveUpEntryItem = new ToolItem(toolBar, SWT.PUSH);
moveUpEntryItem.setImage(ImageProvider.getImage(EImage.UP_ICON));
moveDownEntryItem = new ToolItem(toolBar, SWT.PUSH);
moveDownEntryItem.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
addToolbarListener();
}
use of org.eclipse.swt.widgets.ToolItem in project tdi-studio-se by Talend.
the class VarsDataMapTableView method createToolItems.
@Override
protected void createToolItems() {
// /////////////////////////////////////////////////////////////////
ToolItem addEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
addEntryItem.setEnabled(!getMapperManager().componentIsReadOnly());
//$NON-NLS-1$
addEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.addVariable"));
addEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.ADD_ICON)));
addEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
TableViewerCreator<IColumnEntry> tableViewerCreator = getExtendedTableViewerForColumns().getTableViewerCreator();
tableViewerCreator.applyActivatedCellEditor();
Table table = getExtendedTableViewerForColumns().getTable();
int[] indices = table.getSelectionIndices();
int indexInsert = table.getItemCount();
if (indices.length > 0) {
indexInsert = indices[indices.length - 1] + 1;
}
IDataMapTable dataMapTable = VarsDataMapTableView.this.getDataMapTable();
String varName = null;
if (dataMapTable instanceof VarsTable) {
//$NON-NLS-1$
varName = ((VarsTable) dataMapTable).findUniqueColumnName("var");
} else {
throw new UnsupportedOperationException(Messages.getString(//$NON-NLS-1$
"VarsDataMapTableView.exceptionMessage.caseNotFound"));
}
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
String type = null;
if (currentLanguage.getCodeLanguage() == ECodeLanguage.JAVA) {
type = JavaTypesManager.STRING.getId();
} else {
// fix bug 0018996 ,when add a var row,there is no default type,this bug exsit for long time
type = PerlTypesManager.STRING;
}
mapperManager.addNewVarEntry(VarsDataMapTableView.this, varName, indexInsert, type);
tableViewerCreatorForColumns.getTableViewer().refresh();
if (canBeResizedAtPreferedSize()) {
VarsDataMapTableView.this.changeSize(VarsDataMapTableView.this.getPreferredSize(true, true, false), true, true);
changeMinimizeState(false);
}
mapperManager.getUiManager().refreshBackground(true, false);
table.setSelection(indexInsert);
removeEntryItem.setEnabled(true);
moveUpEntryItem.setEnabled(true);
moveDownEntryItem.setEnabled(true);
}
});
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
removeEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
removeEntryItem.setEnabled(false);
removeEntryItem.setImage(org.talend.commons.ui.runtime.image.ImageProvider.getImage(org.talend.commons.ui.runtime.image.ImageProvider.getImageDesc(EImage.MINUS_ICON)));
//$NON-NLS-1$
removeEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.removeVariable"));
removeEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
IStructuredSelection selection = (IStructuredSelection) tableViewerCreatorForColumns.getTableViewer().getSelection();
List<ITableEntry> selectedBeans = selection.toList();
for (ITableEntry entry : selectedBeans) {
mapperManager.removeTableEntry(entry);
}
if (selectedBeans.size() > 0) {
tableViewerCreatorForColumns.getTableViewer().refresh();
mapperManager.getUiManager().refreshBackground(true, false);
if (canBeResizedAtPreferedSize()) {
resizeAtExpandedSize();
}
}
removeEntryItem.setEnabled(false);
}
});
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
moveUpEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
moveUpEntryItem.setEnabled(false);
moveUpEntryItem.setImage(ImageProvider.getImage(EImage.UP_ICON));
//$NON-NLS-1$
moveUpEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.moveUpVariable"));
moveUpEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
AbstractExtendedTableViewer viewer = getExtendedTableViewerForColumns();
ExtendedTableMoveCommand moveCommand = new ExtendedTableMoveCommand(viewer.getExtendedTableModel(), true, viewer.getTableViewerCreator().getTable().getSelectionIndices());
viewer.getTableViewerCreator().applyActivatedCellEditor();
viewer.executeCommand(moveCommand);
}
});
// /////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////
moveDownEntryItem = new ToolItem(toolBarActions, SWT.PUSH);
moveDownEntryItem.setEnabled(false);
moveDownEntryItem.setImage(ImageProvider.getImage(EImage.DOWN_ICON));
//$NON-NLS-1$
moveDownEntryItem.setToolTipText(Messages.getString("VarsDataMapTableView.entryItemTooltip.movedownVariable"));
moveDownEntryItem.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
AbstractExtendedTableViewer viewer = getExtendedTableViewerForColumns();
ExtendedTableMoveCommand moveCommand = new ExtendedTableMoveCommand(viewer.getExtendedTableModel(), false, viewer.getTableViewerCreator().getTable().getSelectionIndices());
viewer.getTableViewerCreator().applyActivatedCellEditor();
viewer.executeCommand(moveCommand);
}
});
// /////////////////////////////////////////////////////////////////
}
use of org.eclipse.swt.widgets.ToolItem in project cubrid-manager by CUBRID.
the class BrokerConfigEditorPart method createToolBarComp.
/**
* Create the toolbar composition.
*
* @param parent
*/
public void createToolBarComp(Composite parent) {
final Composite comp = new Composite(parent, SWT.NONE);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
comp.setLayoutData(gridData);
final GridLayout layout = new GridLayout(1, false);
layout.marginHeight = -1;
comp.setLayout(layout);
final ToolBar toolbar = new ToolBar(comp, SWT.LEFT_TO_RIGHT | SWT.FLAT);
toolbar.setLayoutData(createGridData(HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
// Show/hide of the history pane
saveConfItem = new ToolItem(toolbar, SWT.PUSH);
saveConfItem.setImage(getImage("icons/queryeditor/file_save.png"));
saveConfItem.setToolTipText(Messages.cubridBrokerConfEditorSaveItemLabel);
saveConfItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// check whether contains duplicate property name
String errMsg = editorComp.validate();
if (isNotBlank(errMsg)) {
openErrorBox(errMsg);
return;
}
if (!openConfirmBox(Messages.cubridBrokerConfEditorSaveConfirm)) {
return;
}
saveData();
}
});
// Show/hide of the history pane
saveAsConfItem = new ToolItem(toolbar, SWT.PUSH);
saveAsConfItem.setImage(getImage("icons/queryeditor/file_saveas.png"));
saveAsConfItem.setToolTipText(Messages.cubridBrokerConfEditorSaveAsItemLabel);
saveAsConfItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
// Check whether contains duplicate property or broker name
String errMsg = editorComp.validate();
if (isNotBlank(errMsg)) {
openErrorBox(errMsg);
return;
}
if (!openConfirmBox(Messages.cubridBrokerConfEditorSaveAsConfirm)) {
return;
}
final FileDialog dialog = new FileDialog(getSite().getShell(), SWT.OPEN | SWT.MULTI);
dialog.setFilterPath(PersistUtils.getPreferenceValue(PLUGIN_ID, BrokerConfOpenFileDialog.CUBRIDBROKERCONFPATH));
dialog.setText(Messages.cubridBrokerConfEditorSaveAsDialogTitle);
dialog.setFilterExtensions(new String[] { "*.conf" });
dialog.setOverwrite(false);
String path = dialog.open();
File saveAsFile = null;
if (path == null) {
return;
}
if (!path.endsWith(".conf")) {
path += ".conf";
}
saveAsFile = new File(path);
BrokerConfig brokerConf = editorComp.getBrokerConfig();
String contents = persistUtil.readBrokerConfig(brokerConf);
try {
persistUtil.writeBrokerConfig(saveAsFile, charset, contents);
openInformationBox(Messages.titleSuccess, Messages.cubridBrokerConfEditorSaveSucessMsg);
setDirty(false);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
openErrorBox(e.getMessage());
}
}
});
new ToolItem(toolbar, SWT.SEPARATOR);
addPropItem = new ToolItem(toolbar, SWT.PUSH);
addPropItem.setImage(getImage("icons/queryeditor/table_record_insert.png"));
addPropItem.setToolTipText(Messages.cubridBrokerConfEditorAddPropItemLabel);
addPropItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
editorComp.addPropData();
}
});
deletePropItem = new ToolItem(toolbar, SWT.PUSH);
deletePropItem.setImage(getImage("icons/queryeditor/table_record_delete.png"));
deletePropItem.setToolTipText(Messages.cubridBrokerConfEditorDeletePropItemLabel);
deletePropItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
editorComp.deletePropData();
}
});
}
Aggregations