use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.
the class RunConfigurationPopupMenuExtension method createItemPopupMenu.
private Menu createItemPopupMenu(Tree tree) {
if (itemMenu == null) {
itemMenu = new Menu(tree);
MenuItem editMenuItem = new MenuItem(itemMenu, SWT.NONE);
editMenuItem.setText(BaseMessages.getString(PKG, "RunConfigurationPopupMenuExtension.MenuItem.Edit"));
editMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
runConfigurationDelegate.edit(runConfiguration);
}
});
MenuItem deleteMenuItem = new MenuItem(itemMenu, SWT.NONE);
deleteMenuItem.setText(BaseMessages.getString(PKG, "RunConfigurationPopupMenuExtension.MenuItem.Delete"));
deleteMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
runConfigurationDelegate.delete(runConfiguration);
}
});
}
return itemMenu;
}
use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.
the class Spoon method addTabs.
private void addTabs() {
if (tabComp != null) {
tabComp.dispose();
}
tabComp = new Composite(sashform, SWT.BORDER);
props.setLook(tabComp);
tabComp.setLayout(new FillLayout());
tabfolder = new TabSet(tabComp);
tabfolder.setChangedFont(GUIResource.getInstance().getFontBold());
final CTabFolder cTabFolder = tabfolder.getSwtTabset();
props.setLook(cTabFolder, Props.WIDGET_STYLE_TAB);
cTabFolder.addMenuDetectListener(new MenuDetectListener() {
@Override
public void menuDetected(MenuDetectEvent event) {
org.eclipse.swt.graphics.Point real = new org.eclipse.swt.graphics.Point(event.x, event.y);
org.eclipse.swt.graphics.Point point = display.map(null, cTabFolder, real);
final CTabItem item = cTabFolder.getItem(point);
if (item != null) {
Menu menu = new Menu(cTabFolder);
MenuItem closeItem = new MenuItem(menu, SWT.NONE);
closeItem.setText(BaseMessages.getString(PKG, "Spoon.Tab.Close"));
closeItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int index = tabfolder.getSwtTabset().indexOf(item);
if (index >= 0) {
TabMapEntry entry = delegates.tabs.getTabs().get(index);
tabClose(entry.getTabItem());
}
}
});
MenuItem closeAllItems = new MenuItem(menu, SWT.NONE);
closeAllItems.setText(BaseMessages.getString(PKG, "Spoon.Tab.CloseAll"));
closeAllItems.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
for (TabMapEntry entry : delegates.tabs.getTabs()) {
tabClose(entry.getTabItem());
}
}
});
MenuItem closeOtherItems = new MenuItem(menu, SWT.NONE);
closeOtherItems.setText(BaseMessages.getString(PKG, "Spoon.Tab.CloseOthers"));
closeOtherItems.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int index = tabfolder.getSwtTabset().indexOf(item);
if (index >= 0) {
TabMapEntry entry = delegates.tabs.getTabs().get(index);
for (TabMapEntry closeEntry : delegates.tabs.getTabs()) {
if (!closeEntry.equals(entry)) {
tabClose(closeEntry.getTabItem());
}
}
}
}
});
menu.setLocation(real);
menu.setVisible(true);
}
}
});
int[] weights = props.getSashWeights();
sashform.setWeights(weights);
sashform.setVisible(true);
// Set a minimum width on the sash so that the view and design buttons
// on the left panel are always visible.
//
Control[] comps = sashform.getChildren();
for (Control comp : comps) {
if (comp instanceof Sash) {
int limit = 10;
final int SASH_LIMIT = Const.isOSX() ? 150 : limit;
final Sash sash = (Sash) comp;
sash.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
Rectangle rect = sash.getParent().getClientArea();
event.x = Math.min(Math.max(event.x, SASH_LIMIT), rect.width - SASH_LIMIT);
if (event.detail != SWT.DRAG) {
sash.setBounds(event.x, event.y, event.width, event.height);
sashform.layout();
}
}
});
}
}
// methods: tabDeselected, tabClose,
tabfolder.addListener(this);
// tabSelected
}
use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.
the class SpoonPerspectiveManager method initialize.
public void initialize() {
XulToolbar mainToolbar = (XulToolbar) domContainer.getDocumentRoot().getElementById("main-toolbar");
SwtDeck deck = (SwtDeck) domContainer.getDocumentRoot().getElementById("canvas-deck");
int y = 0;
int perspectiveIdx = 0;
Class<? extends SpoonPerspective> perClass = null;
List<SpoonPerspective> perspectives = getPerspectives();
if (this.startupPerspective != null) {
for (int i = 0; i < perspectives.size(); i++) {
if (perspectives.get(i).getId().equals(this.startupPerspective)) {
perspectiveIdx = i;
break;
}
}
}
final List<PerspectiveData> perspectiveList = new ArrayList<>();
final ToolBar swtToolbar = (ToolBar) mainToolbar.getManagedObject();
final Shell shell = swtToolbar.getShell();
final ToolItem perspectiveButton = new ToolItem(swtToolbar, SWT.DROP_DOWN, 7);
perspectiveButton.setImage(GUIResource.getInstance().getImage("ui/images/perspective_changer.svg"));
perspectiveButton.setToolTipText(BaseMessages.getString(PKG, "Spoon.Menu.View.Perspectives"));
perspectiveButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Menu menu = new Menu(shell);
for (final PerspectiveData perspectiveData : perspectiveList) {
MenuItem item = new MenuItem(menu, SWT.CHECK);
if (perspectiveData.isHidden()) {
item.setEnabled(false);
}
if (activePerspective.getId().equals(perspectiveData.getId())) {
item.setSelection(true);
}
item.setText(perspectiveData.getName());
item.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent selectionEvent) {
Spoon.getInstance().loadPerspective(perspectiveData.getId());
swtToolbar.forceFocus();
}
});
}
ToolItem item = (ToolItem) e.widget;
Rectangle rect = item.getBounds();
Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y + rect.height));
menu.setLocation(pt.x, pt.y);
menu.setVisible(true);
}
});
for (final SpoonPerspective per : getPerspectives()) {
if (installedPerspectives.contains(per)) {
y++;
continue;
}
String name = per.getDisplayName(LanguageChoice.getInstance().getDefaultLocale());
PerspectiveData perspectiveData = new PerspectiveData(name, per.getId());
if (Arrays.asList(defaultDisabled).contains(per.getId())) {
perspectiveData.setHidden(true);
}
perspectiveList.add(perspectiveData);
XulVbox box = deck.createVBoxCard();
box.setId("perspective-" + per.getId());
box.setFlex(1);
deck.addChild(box);
PerspectiveManager perspectiveManager = new PerspectiveManager(per, box, mainToolbar, perspectiveList, name);
perspectiveManagerMap.put(per, perspectiveManager);
// Need to force init for main perspective even if it won't be shown
if (perspectiveIdx == y || y == 0) {
if (perspectiveIdx == y) {
// we have a startup perspective. Hold onto the class
perClass = per.getClass();
}
// force init
perspectiveManager.initializeIfNeeded();
}
y++;
installedPerspectives.add(per);
}
deck.setSelectedIndex(perspectiveIdx);
if (perClass != null) {
// activate the startup perspective
try {
activatePerspective(perClass);
// stop other perspectives from opening
SpoonPerspectiveManager.getInstance().setForcePerspective(true);
} catch (KettleException e) {
// TODO Auto-generated catch block
}
}
}
use of org.eclipse.swt.widgets.MenuItem in project archi by archimatetool.
the class HintsView method selectionChanged.
public void selectionChanged(Object source, Object selected) {
if (fActionPinContent.isChecked()) {
return;
}
Object object = null;
String key = null;
// EClass (selected from Diagram Palette) so get Java class
if (selected instanceof EClass) {
EClass eClass = (EClass) selected;
object = eClass.getInstanceClass();
} else // Adaptable, dig in to get to get Element...
if (selected instanceof IAdaptable) {
// This first
object = ((IAdaptable) selected).getAdapter(IHelpHintProvider.class);
if (object == null) {
object = ((IAdaptable) selected).getAdapter(IArchimateConcept.class);
}
if (object == null) {
object = ((IAdaptable) selected).getAdapter(IDiagramModelObject.class);
}
if (object == null) {
object = ((IAdaptable) selected).getAdapter(IDiagramModelConnection.class);
}
if (object == null) {
object = ((IAdaptable) selected).getAdapter(IDiagramModel.class);
}
} else // Default
{
object = selected;
}
// Hint Provider, if set
if (object instanceof IHelpHintProvider) {
String title = ((IHelpHintProvider) object).getHelpHintTitle();
String text = ((IHelpHintProvider) object).getHelpHintContent();
if (StringUtils.isSet(title) || StringUtils.isSet(text)) {
fTitleLabel.setText(title);
Color color = getTitleColor(object);
fTitleLabel.setBackground(new Color[] { color, ColorConstants.white }, new int[] { 80 }, false);
text = makeHTMLEntry(text);
fBrowser.setText(text);
// $NON-NLS-1$
fLastPath = "";
return;
}
}
// Archimate Diagram Model use Viewpoint as key
if (object instanceof IArchimateDiagramModel) {
key = ((IArchimateDiagramModel) object).getViewpoint();
}
Hint hint = getHintFromObject(object, key);
if (hint != null) {
if (fLastPath != hint.path) {
// Title and Color
Color color = getTitleColor(object);
fTitleLabel.setBackground(new Color[] { color, ColorConstants.white }, new int[] { 80 }, false);
fTitleLabel.setText(hint.title);
// Load page
fPageLoaded = false;
fBrowser.setUrl(hint.path);
fLastPath = hint.path;
// Kludge for Mac/Safari when displaying hint on mouse rollover menu item in MagicConnectionCreationTool
if (PlatformUtils.isMac() && source instanceof MenuItem) {
_doMacWaitKludge();
}
}
} else {
// $NON-NLS-1$
fBrowser.setText("");
// $NON-NLS-1$
fLastPath = "";
// $NON-NLS-1$
fTitleLabel.setText("");
fTitleLabel.setBackground(ColorConstants.white);
}
}
use of org.eclipse.swt.widgets.MenuItem in project archi by archimatetool.
the class MagicConnectionCreationTool method addConnectionActions.
/**
* Add Connection Actions going in both directions
*/
private void addConnectionActions(Menu menu, IArchimateConcept sourceConcept, IArchimateConcept targetConcept) {
EClass[] forwardConnections = ArchimateModelUtils.getValidRelationships(sourceConcept, targetConcept);
EClass[] reverseConnections = ArchimateModelUtils.getValidRelationships(targetConcept, sourceConcept);
// Add forward direction connections
for (EClass type : forwardConnections) {
addConnectionAction(menu, type, false);
}
// Add reverse direction connections
for (EClass type : reverseConnections) {
addConnectionAction(menu, type, true);
}
// Add a separator only if we have both sets of items on the menu
if (forwardConnections.length > 0 && reverseConnections.length > 0) {
new MenuItem(menu, SWT.SEPARATOR, forwardConnections.length);
}
}
Aggregations