use of org.eclipse.swt.widgets.MenuItem in project translationstudio8 by heartsome.
the class MenuItemProviders method autoResizeRowMenuItemProvider.
public static IMenuItemProvider autoResizeRowMenuItemProvider() {
return new IMenuItemProvider() {
public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
MenuItem autoResizeRows = new MenuItem(popupMenu, SWT.PUSH);
autoResizeRows.setText("Auto resize row");
autoResizeRows.setEnabled(true);
autoResizeRows.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int rowPosition = getNatEventData(event).getRowPosition();
natTable.doCommand(new InitializeAutoResizeRowsCommand(natTable, rowPosition, natTable.getConfigRegistry(), new GC(natTable)));
}
});
}
};
}
use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.
the class ScriptValuesModDialog method buildingFolderMenu.
private void buildingFolderMenu() {
// styledTextPopupmenu = new Menu(, SWT.POP_UP);
MenuItem addNewItem = new MenuItem(cMenu, SWT.PUSH);
addNewItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.AddNewTab"));
addNewItem.setImage(imageAddScript);
addNewItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
addCtab("", "", ADD_BLANK);
}
});
MenuItem copyItem = new MenuItem(cMenu, SWT.PUSH);
copyItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.AddCopy"));
copyItem.setImage(imageDuplicateScript);
copyItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
CTabItem item = folder.getSelection();
StyledTextComp st = (StyledTextComp) item.getControl();
addCtab(item.getText(), st.getText(), ADD_COPY);
}
});
new MenuItem(cMenu, SWT.SEPARATOR);
MenuItem setActiveScriptItem = new MenuItem(cMenu, SWT.PUSH);
setActiveScriptItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.SetTransformScript"));
setActiveScriptItem.setImage(imageActiveScript);
setActiveScriptItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
CTabItem item = folder.getSelection();
for (int i = 0; i < folder.getItemCount(); i++) {
if (folder.getItem(i).equals(item)) {
if (item.getImage().equals(imageActiveScript)) {
strActiveScript = "";
} else if (item.getImage().equals(imageActiveStartScript)) {
strActiveStartScript = "";
} else if (item.getImage().equals(imageActiveEndScript)) {
strActiveEndScript = "";
}
item.setImage(imageActiveScript);
strActiveScript = item.getText();
} else if (folder.getItem(i).getImage().equals(imageActiveScript)) {
folder.getItem(i).setImage(imageInactiveScript);
}
}
modifyScriptTree(item, SET_ACTIVE_ITEM);
}
});
MenuItem setStartScriptItem = new MenuItem(cMenu, SWT.PUSH);
setStartScriptItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.SetStartScript"));
setStartScriptItem.setImage(imageActiveStartScript);
setStartScriptItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
CTabItem item = folder.getSelection();
for (int i = 0; i < folder.getItemCount(); i++) {
if (folder.getItem(i).equals(item)) {
if (item.getImage().equals(imageActiveScript)) {
strActiveScript = "";
} else if (item.getImage().equals(imageActiveStartScript)) {
strActiveStartScript = "";
} else if (item.getImage().equals(imageActiveEndScript)) {
strActiveEndScript = "";
}
item.setImage(imageActiveStartScript);
strActiveStartScript = item.getText();
} else if (folder.getItem(i).getImage().equals(imageActiveStartScript)) {
folder.getItem(i).setImage(imageInactiveScript);
}
}
modifyScriptTree(item, SET_ACTIVE_ITEM);
}
});
MenuItem setEndScriptItem = new MenuItem(cMenu, SWT.PUSH);
setEndScriptItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.SetEndScript"));
setEndScriptItem.setImage(imageActiveEndScript);
setEndScriptItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
CTabItem item = folder.getSelection();
for (int i = 0; i < folder.getItemCount(); i++) {
if (folder.getItem(i).equals(item)) {
if (item.getImage().equals(imageActiveScript)) {
strActiveScript = "";
} else if (item.getImage().equals(imageActiveStartScript)) {
strActiveStartScript = "";
} else if (item.getImage().equals(imageActiveEndScript)) {
strActiveEndScript = "";
}
item.setImage(imageActiveEndScript);
strActiveEndScript = item.getText();
} else if (folder.getItem(i).getImage().equals(imageActiveEndScript)) {
folder.getItem(i).setImage(imageInactiveScript);
}
}
modifyScriptTree(item, SET_ACTIVE_ITEM);
}
});
new MenuItem(cMenu, SWT.SEPARATOR);
MenuItem setRemoveScriptItem = new MenuItem(cMenu, SWT.PUSH);
setRemoveScriptItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.RemoveScriptType"));
setRemoveScriptItem.setImage(imageInactiveScript);
setRemoveScriptItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
CTabItem item = folder.getSelection();
input.setChanged(true);
if (item.getImage().equals(imageActiveScript)) {
strActiveScript = "";
} else if (item.getImage().equals(imageActiveStartScript)) {
strActiveStartScript = "";
} else if (item.getImage().equals(imageActiveEndScript)) {
strActiveEndScript = "";
}
item.setImage(imageInactiveScript);
}
});
folder.setMenu(cMenu);
}
use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.
the class ScriptValuesModDialog method buildingTreeMenu.
private void buildingTreeMenu() {
// styledTextPopupmenu = new Menu(, SWT.POP_UP);
MenuItem addDeleteItem = new MenuItem(tMenu, SWT.PUSH);
addDeleteItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Delete.Label"));
addDeleteItem.setImage(imageDeleteScript);
addDeleteItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
if (wTree.getSelectionCount() <= 0) {
return;
}
TreeItem tItem = wTree.getSelection()[0];
if (tItem != null) {
MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES);
messageBox.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.DeleteItem.Label"));
messageBox.setMessage(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ConfirmDeleteItem.Label", tItem.getText()));
switch(messageBox.open()) {
case SWT.YES:
modifyCTabItem(tItem, DELETE_ITEM, "");
tItem.dispose();
input.setChanged();
break;
default:
break;
}
}
}
});
MenuItem renItem = new MenuItem(tMenu, SWT.PUSH);
renItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Rename.Label"));
renItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
renameFunction(wTree.getSelection()[0]);
}
});
new MenuItem(tMenu, SWT.SEPARATOR);
MenuItem helpItem = new MenuItem(tMenu, SWT.PUSH);
helpItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Sample.Label"));
helpItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
String strFunctionName = wTree.getSelection()[0].getText();
String strFunctionNameWithArgs = strFunctionName;
strFunctionName = strFunctionName.substring(0, strFunctionName.indexOf('('));
String strHelpTabName = strFunctionName + "_Sample";
if (getCTabPosition(strHelpTabName) == -1) {
addCtab(strHelpTabName, scVHelp.getSample(strFunctionName, strFunctionNameWithArgs), 0);
}
if (getCTabPosition(strHelpTabName) != -1) {
setActiveCtab(strHelpTabName);
}
}
});
wTree.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event e) {
if (wTree.getSelectionCount() <= 0) {
return;
}
TreeItem tItem = wTree.getSelection()[0];
if (tItem != null) {
TreeItem pItem = tItem.getParentItem();
if (pItem != null && pItem.equals(wTreeScriptsItem)) {
if (folder.getItemCount() > 1) {
tMenu.getItem(0).setEnabled(true);
} else {
tMenu.getItem(0).setEnabled(false);
}
tMenu.getItem(1).setEnabled(true);
tMenu.getItem(3).setEnabled(false);
} else if (tItem.equals(wTreeClassesitem)) {
tMenu.getItem(0).setEnabled(false);
tMenu.getItem(1).setEnabled(false);
tMenu.getItem(3).setEnabled(false);
} else if (tItem.getData() != null && tItem.getData().equals("jsFunction")) {
tMenu.getItem(0).setEnabled(false);
tMenu.getItem(1).setEnabled(false);
tMenu.getItem(3).setEnabled(true);
} else {
tMenu.getItem(0).setEnabled(false);
tMenu.getItem(1).setEnabled(false);
tMenu.getItem(3).setEnabled(false);
}
}
}
});
wTree.setMenu(tMenu);
}
use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.
the class UserDefinedJavaClassDialog method buildingTreeMenu.
private void buildingTreeMenu() {
// styledTextPopupmenu = new Menu(, SWT.POP_UP);
MenuItem addDeleteItem = new MenuItem(tMenu, SWT.PUSH);
addDeleteItem.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Delete.Label"));
addDeleteItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
if (wTree.getSelectionCount() <= 0) {
return;
}
TreeItem tItem = wTree.getSelection()[0];
if (tItem != null) {
MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES);
messageBox.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.DeleteItem.Label"));
messageBox.setMessage(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.ConfirmDeleteItem.Label", tItem.getText()));
switch(messageBox.open()) {
case SWT.YES:
modifyCTabItem(tItem, TabActions.DELETE_ITEM, "");
tItem.dispose();
input.setChanged();
break;
default:
break;
}
}
}
});
MenuItem renItem = new MenuItem(tMenu, SWT.PUSH);
renItem.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Rename.Label"));
renItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
renameFunction(wTree.getSelection()[0]);
}
});
new MenuItem(tMenu, SWT.SEPARATOR);
MenuItem helpItem = new MenuItem(tMenu, SWT.PUSH);
helpItem.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Sample.Label"));
helpItem.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
String snippitFullName = wTree.getSelection()[0].getText();
String sampleTabName = snippitFullName.replace("Implement ", "").replace(' ', '_') + "_Sample";
if (getCTabPosition(sampleTabName) == -1) {
addCtab(sampleTabName, snippitsHelper.getSample(snippitFullName), TabAddActions.ADD_DEFAULT);
}
if (getCTabPosition(sampleTabName) != -1) {
setActiveCtab(sampleTabName);
}
}
});
wTree.addListener(SWT.MouseDown, new Listener() {
public void handleEvent(Event e) {
if (wTree.getSelectionCount() <= 0) {
return;
}
TreeItem tItem = wTree.getSelection()[0];
if (tItem != null) {
TreeItem pItem = tItem.getParentItem();
if (pItem != null && pItem.equals(wTreeClassesItem)) {
if (folder.getItemCount() > 1) {
tMenu.getItem(0).setEnabled(true);
} else {
tMenu.getItem(0).setEnabled(false);
}
tMenu.getItem(1).setEnabled(true);
tMenu.getItem(3).setEnabled(false);
} else if (tItem.equals(wTreeClassesItem)) {
tMenu.getItem(0).setEnabled(false);
tMenu.getItem(1).setEnabled(false);
tMenu.getItem(3).setEnabled(false);
} else if (pItem != null && pItem.getData() != null && pItem.getData().equals("Snippits Category")) {
tMenu.getItem(0).setEnabled(false);
tMenu.getItem(1).setEnabled(false);
tMenu.getItem(3).setEnabled(true);
} else {
tMenu.getItem(0).setEnabled(false);
tMenu.getItem(1).setEnabled(false);
tMenu.getItem(3).setEnabled(false);
}
}
}
});
wTree.setMenu(tMenu);
}
use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.
the class JobGraph method addToolBar.
private void addToolBar() {
try {
toolbar = (XulToolbar) getXulDomContainer().getDocumentRoot().getElementById("nav-toolbar");
ToolBar swtToolbar = (ToolBar) toolbar.getManagedObject();
swtToolbar.setBackground(GUIResource.getInstance().getColorDemoGray());
swtToolbar.pack();
// Added 1/11/2016 to implement dropdown option for "Run"
ToolItem runItem = new ToolItem(swtToolbar, SWT.DROP_DOWN, 0);
runItem.setImage(GUIResource.getInstance().getImage("ui/images/run.svg"));
runItem.setToolTipText(BaseMessages.getString(PKG, "Spoon.Tooltip.RunTranformation"));
runItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (e.detail == SWT.DROP_DOWN) {
Menu menu = new Menu(shell, SWT.POP_UP);
MenuItem item1 = new MenuItem(menu, SWT.PUSH);
item1.setText(BaseMessages.getString(PKG, "Spoon.Run.Run"));
item1.setAccelerator(SWT.F9);
item1.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e1) {
runJob();
}
});
MenuItem item2 = new MenuItem(menu, SWT.PUSH);
item2.setText(BaseMessages.getString(PKG, "Spoon.Run.RunOptions"));
item2.setAccelerator(SWT.F8);
item2.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e2) {
runOptionsJob();
}
});
menu.setLocation(shell.getDisplay().map(mainComposite.getParent(), null, mainComposite.getLocation()));
menu.setVisible(true);
} else {
runJob();
}
}
});
// Hack alert : more XUL limitations...
//
ToolItem sep = new ToolItem(swtToolbar, SWT.SEPARATOR);
zoomLabel = new Combo(swtToolbar, SWT.DROP_DOWN);
zoomLabel.setItems(TransPainter.magnificationDescriptions);
zoomLabel.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
readMagnification();
}
});
zoomLabel.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
if (event.character == SWT.CR) {
readMagnification();
}
}
});
setZoomLabel();
zoomLabel.pack();
sep.setWidth(80);
sep.setControl(zoomLabel);
swtToolbar.pack();
} catch (Throwable t) {
log.logError(Const.getStackTracker(t));
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingXULFile.Title"), BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_JOB_GRAPH), new Exception(t));
}
}
Aggregations