use of org.eclipse.jface.action.MenuManager in project tdi-studio-se by Talend.
the class MultiSchemasUI method createMenuBar.
private void createMenuBar(final ToolBar menuBar) {
ToolItem pullDownButton = new ToolItem(menuBar, SWT.PUSH);
// Image hoverImage = WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_RENDERED_VIEW_MENU);
//$NON-NLS-1$
Image hoverImage = PlatformUI.getWorkbench().getSharedImages().getImage("IMG_LCL_RENDERED_VIEW_MENU");
pullDownButton.setDisabledImage(hoverImage);
pullDownButton.setImage(hoverImage);
pullDownButton.setToolTipText("Menu");
pullDownButton.setWidth(5);
//$NON-NLS-1$
MenuManager menuManager = new MenuManager("MultiSchema");
columnAction = new SchameDetailsColumnAction(schemaDetailsViewer);
columnAction.setChecked(!ExternalMultiSchemasUIProperties.isSchemaDetailsModel());
menuManager.add(columnAction);
propertyAction = new SchameDetailsPropertyAction(schemaDetailsViewer);
propertyAction.setChecked(ExternalMultiSchemasUIProperties.isSchemaDetailsModel());
menuManager.add(propertyAction);
final Menu aMenu = menuManager.createContextMenu(menuBar.getParent());
pullDownButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Point toolbarSize = menuBar.getSize();
toolbarSize = menuBar.toDisplay(0, toolbarSize.y);
aMenu.setLocation(toolbarSize);
aMenu.setVisible(true);
}
});
}
use of org.eclipse.jface.action.MenuManager in project tdi-studio-se by Talend.
the class AbstractVersionManagementProjectSettingPage method addMenuAction.
protected void addMenuAction(Tree tree) {
MenuManager manager = new MenuManager();
manager.add(new SelectAllAction());
Menu menu = manager.createContextMenu(tree);
tree.setMenu(menu);
}
use of org.eclipse.jface.action.MenuManager in project tdi-studio-se by Talend.
the class ProcessVersionComposite method addPopUpMenu.
/**
* DOC Administrator Comment method "addPoppuMenu".
*/
private void addPopUpMenu() {
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager mgr) {
if (getParentWizard() == null) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action instanceof OpenExistVersionProcessAction) {
continue;
}
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
Object o = structuredSelection.getFirstElement();
if (o instanceof RepositoryNode) {
((AContextualAction) action).setAvoidUnloadResources(true);
}
if (action.isVisible()) {
mgr.add(action);
}
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
}
use of org.eclipse.jface.action.MenuManager in project tdi-studio-se by Talend.
the class SWTResourceFilteredTree method createContextMenu.
/**
* Creates the context menu.
*/
private void createContextMenu() {
final CopyAction copyAction = CopyAction.createCopyAction(actionBars);
getViewer().getControl().addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
getViewer().removeSelectionChangedListener(copyAction);
}
@Override
public void focusGained(FocusEvent e) {
getViewer().addSelectionChangedListener(copyAction);
}
});
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopupMenu");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
manager.add(copyAction);
}
});
Menu menu = menuMgr.createContextMenu(getViewer().getControl());
getViewer().getControl().setMenu(menu);
}
use of org.eclipse.jface.action.MenuManager in project tdi-studio-se by Talend.
the class VersionSection method createControls.
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
composite = getWidgetFactory().createFlatFormComposite(parent);
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
table.setLinesVisible(true);
final String[] columnProperties = new String[] { //$NON-NLS-1$
Messages.getString("VersionSection.Version"), //$NON-NLS-1$
Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$
Messages.getString("VersionSection.Status") };
final TableColumn column1 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column1.setText(columnProperties[0]);
final TableColumn column2 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column2.setText(columnProperties[1]);
final TableColumn column3 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnPixelData(125, true));
column3.setText(columnProperties[2]);
final TableColumn column4 = new TableColumn(table, SWT.NONE);
tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
column4.setText(columnProperties[3]);
tableViewer.setColumnProperties(columnProperties);
Object layoutData = parent.getLayoutData();
if (layoutData instanceof GridData) {
GridData gridData = (GridData) layoutData;
gridData.grabExcessVerticalSpace = true;
gridData.verticalAlignment = SWT.FILL;
}
FormData formData = new FormData();
formData.left = new FormAttachment(0);
formData.top = new FormAttachment(0);
formData.right = new FormAttachment(100);
formData.bottom = new FormAttachment(100);
table.setLayoutData(formData);
tableViewer.setContentProvider(new IStructuredContentProvider() {
public Object[] getElements(Object inputElement) {
IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
if (repositoryObject.getProperty() == null) {
return null;
}
RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
try {
List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
Collections.sort(allVersion, new IRepositoryObjectComparator());
Object[] objects = new Object[allVersion.size()];
for (int i = 0; i < objects.length; i++) {
IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
objects[i] = repositoryNode;
}
return objects;
} catch (PersistenceException e) {
return null;
}
}
private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
return repositoryNode;
}
public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
tableViewer.setLabelProvider(new ITableLabelProvider() {
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
public String getColumnText(Object element, int columnIndex) {
RepositoryNode repositoryNode = (RepositoryNode) element;
switch(columnIndex) {
case 0:
return repositoryNode.getObject().getVersion();
case 1:
if (repositoryNode.getObject().getCreationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getCreationDate());
} else {
return null;
}
case 2:
if (repositoryNode.getObject().getModificationDate() != null) {
return FORMATTER.format(repositoryNode.getObject().getModificationDate());
} else {
return null;
}
case 3:
if (repositoryNode.getObject().getStatusCode() != null) {
return repositoryNode.getObject().getStatusCode();
} else {
return null;
}
default:
return null;
}
}
public void addListener(ILabelProviderListener listener) {
}
public void dispose() {
}
public boolean isLabelProperty(Object element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
});
//$NON-NLS-1$
MenuManager menuMgr = new MenuManager("#PopUp");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
ISelection selection = tableViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
for (ITreeContextualAction action : contextualsActions) {
if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
action.init(null, structuredSelection);
if (action.isVisible()) {
mgr.add(action);
}
}
}
}
}
});
Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
tableViewer.getControl().setMenu(menu);
Listener sortListener = new Listener() {
private int direction = 1;
public void handleEvent(Event e) {
final TableColumn column = (TableColumn) e.widget;
if (column == table.getSortColumn()) {
direction = -direction;
}
if (direction == 1) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
table.setSortColumn(column);
tableViewer.setSorter(new ViewerSorter() {
int index = 0;
@Override
public void sort(Viewer viewer, Object[] elements) {
while (index < table.getColumns().length && table.getColumn(index) != column) {
index++;
}
super.sort(viewer, elements);
}
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
"";
String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
"";
return getComparator().compare(columnText, columnText2) * direction;
}
});
}
};
column1.addListener(SWT.Selection, sortListener);
column2.addListener(SWT.Selection, sortListener);
column3.addListener(SWT.Selection, sortListener);
column4.addListener(SWT.Selection, sortListener);
table.setSortColumn(column1);
table.setSortDirection(SWT.DOWN);
aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
Aggregations