List of usage examples for org.eclipse.jface.action Action Action
protected Action(String text)
From source file:ac.soton.xeventb.ui.AbstractXEventBActionProvider.java
License:Open Source License
/** * Provides an open action for IXEventBNavigatorObject * //from ww w .ja v a2s.c om * @param site * The information for the action provider * @return An open action */ public Action getOpenAction(final ICommonActionExtensionSite site) { final Action doubleClickAction = new Action("Open") { @Override public void run() { final ISelection selection = site.getStructuredViewer().getSelection(); final Object obj = ((IStructuredSelection) selection).getFirstElement(); if ((obj instanceof IXEventBNavigatorObject)) { final IFile resource = ((IXEventBNavigatorObject) obj).getResource(); final IEditorDescriptor desc = IDE.getDefaultEditor(resource); try { final IWorkbenchPage activePage = XEventBUIPlugin.getDefault().getWorkbench() .getActiveWorkbenchWindow().getActivePage(); FileEditorInput _fileEditorInput = new FileEditorInput(resource); final IEditorPart editor = activePage.openEditor(_fileEditorInput, desc.getId()); if ((editor == null)) { return; } } catch (final Throwable _t) { if (_t instanceof PartInitException) { final String errorMsg = "Error opening Editor"; MessageDialog.openError(null, null, errorMsg); } else { throw Exceptions.sneakyThrow(_t); } } } } }; return doubleClickAction; }
From source file:ac.soton.xeventb.ui.AbstractXEventBActionProvider.java
License:Open Source License
/** * Provides a delete action for IXEventBNavigatorObject * Deletes the xtext as well as the corresponding Event-B files * //from w w w . ja v a 2 s. c o m * @param site * The information for the action provider * @return A delete action */ public Action getDeleteAction(final ICommonActionExtensionSite site) { final Action doubleClickAction = new Action("Delete") { @Override public void run() { try { final ISelection selection = site.getStructuredViewer().getSelection(); final Object obj = ((IStructuredSelection) selection).getFirstElement(); if ((obj instanceof IXEventBNavigatorObject)) { final IFile resource = ((IXEventBNavigatorObject) obj).getResource(); String name = resource.getName(); int _length = name.length(); int _minus = (_length - 1); name = name.substring(0, _minus); IPath path = resource.getLocation(); path = path.removeLastSegments(1); path = path.addTrailingSeparator().append(name); final IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IFile ifile = workspace.getRoot().getFileForLocation(path); final Shell shell = site.getViewSite().getShell(); String _name = resource.getName(); String _plus = ("Are you sure you want to delete \"" + _name); final String msg = (_plus + "\" and its corresponding Event-B files?"); final String[] options = { "Yes to All", "Yes", "No" }; final MessageDialog dialog = new MessageDialog(shell, "Confirm Delete", null, msg, MessageDialog.CONFIRM, options, 0); final int result = dialog.open(); if ((result == 0)) { resource.delete(true, null); ifile.delete(true, null); } else { if ((result == 1)) { resource.delete(true, null); } } } } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } } }; return doubleClickAction; }
From source file:ar.com.tadp.xml.rinzo.core.views.XPathView.java
License:Open Source License
public void createPartControl(Composite parent) { parent.setLayout(new GridLayout(1, false)); parent.setLayoutData(new GridData(GridData.FILL_BOTH)); Composite expresionComposite = new Composite(parent, SWT.NONE); expresionComposite.setLayout(new GridLayout(3, false)); expresionComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite expresionContainer = new Composite(expresionComposite, SWT.NONE); expresionContainer.setLayout(new GridLayout(3, false)); expresionContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Label label = new Label(expresionContainer, SWT.NONE); label.setText("Expression:"); this.expressionsCombo = new Combo(expresionContainer, SWT.DROP_DOWN | SWT.SINGLE | SWT.LEAD); this.expressionsCombo.setLayout(new GridLayout(1, false)); this.expressionsCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); this.expressionsCombo.setFocus(); this.expressionsCombo.setVisibleItemCount(8); this.expressionsCombo.setToolTipText("Enter XPath for Source XML"); this.autoEvaluationListener = new AutoEvaluationKeyListener(); this.enterEvaluationListener = new EnterEvaluationKeyListener(); this.expressionsCombo.addKeyListener(this.enterEvaluationListener); this.selectionListener = new SelectionListenerImplementation(); this.evaluateButton = new Button(expresionComposite, SWT.PUSH); this.evaluateButton.setText("evaluate"); this.evaluateButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); evaluateExpression();/*from ww w .j av a 2s . co m*/ } }); Composite resultComposite = new Composite(parent, SWT.NONE); resultComposite.setLayout(new FillLayout()); resultComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); this.resultViewer = new SourceViewer(resultComposite, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); this.resultViewer.setInput(this); this.resultViewer.configure(new XMLEditorConfiguration()); this.resultViewer.setDocument(new Document("")); this.clearAllAction = new Action("Clear All") { public void run() { resultViewer.getDocument().set(""); resultViewer.refresh(); expressionsCombo.removeAll(); } }; this.clearAllAction .setImageDescriptor(ImageDescriptor.createFromImage(PluginImages.get(PluginImages.IMG_CLEAR))); this.autoEvaluateAction = new Action("Auto Evaluate XPath", IAction.AS_CHECK_BOX) { public void run() { setAutoEvaluation(!autoEvaluation); } }; this.autoEvaluateAction.setImageDescriptor( ImageDescriptor.createFromImage(PluginImages.get(PluginImages.IMG_XPATH_AUTO_EVALUATE))); this.setAutoEvaluation( XMLEditorPlugin.getDefault().getPreferenceStore().getBoolean(XPATH_VIEW_AUTO_EVALUATION)); this.autoEvaluateAction.setChecked(this.autoEvaluation); IToolBarManager toolbarManager = getViewSite().getActionBars().getToolBarManager(); toolbarManager.add(this.autoEvaluateAction); toolbarManager.add(this.clearAllAction); }
From source file:aspectminingtool.views.FanIn.ViewPartFanIn.java
License:Open Source License
/** * Create the actions.//from w w w. j a v a 2 s .co m */ public void createActions() { selectAllActionMethodsTable = new Action("Select All") { public void run() { selectAll(tableViewerLeft); } }; selectAllActionCallsTable = new Action("Select All") { public void run() { selectAll(tableViewerRight); } }; // Add selection listener. tableViewerLeft.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) tableViewerLeft.getSelection(); openActionTableLeft.setEnabled(sel.size() > 0); selectAllActionMethodsTable.setEnabled(sel.size() > 0); selectAsSeedOperation.setEnabled(sel.size() > 0); } }); tableViewerRight.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) tableViewerRight.getSelection(); selectAllActionCallsTable.setEnabled(sel.size() > 0); openActionTableRight.setEnabled(sel.size() > 0); } }); }
From source file:aspectminingtool.views.FanInSeeds.ViewPartFanInSeeds.java
License:Open Source License
/** * Create the actions./* w w w. j av a 2s.c om*/ */ public void createActions() { openItemActionMethodsTable = new Action("Open") { public void run() { IStructuredSelection sel = (IStructuredSelection) tableViewerLeft.getSelection(); Iterator iter = sel.iterator(); while (iter.hasNext()) { MethodDescription methodDescription = (MethodDescription) iter.next(); if (methodDescription != null) { String id = methodDescription.getMethod().getClass_id(); openResource(id); } } } }; deleteAction = new Action("Delete") { public void run() { IStructuredSelection sel = (IStructuredSelection) tableViewerLeft.getSelection(); Iterator iter = sel.iterator(); while (iter.hasNext()) { MethodDescription methodDescription = (MethodDescription) iter.next(); if (methodDescription != null) { ((SeedsModel) model).removeMethodDescription(methodDescription); } } } }; selectAllActionMethodsTable = new Action("Select All") { public void run() { selectAll(tableViewerLeft); } }; openItemActionCallsTable = new Action("Open") { public void run() { IStructuredSelection sel = (IStructuredSelection) tableViewerRight.getSelection(); Iterator iter = sel.iterator(); while (iter.hasNext()) { Call_Counted callCounted = (Call_Counted) iter.next(); String name = callCounted.getCaller_id(); int index = name.indexOf("//"); name = name.substring(0, index); openResource(name); } } }; selectAllActionCallsTable = new Action("Select All") { public void run() { selectAll(tableViewerRight); } }; // Add selection listener. tableViewerLeft.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) tableViewerLeft.getSelection(); openItemActionMethodsTable.setEnabled(sel.size() > 0); selectAllActionMethodsTable.setEnabled(sel.size() > 0); deleteAction.setEnabled(sel.size() > 0); } }); tableViewerRight.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) tableViewerLeft.getSelection(); selectAllActionCallsTable.setEnabled(sel.size() > 0); openItemActionCallsTable.setEnabled(sel.size() > 0); } }); }
From source file:aspectminingtool.views.RedirectorFinder.ViewPartRedirectorFinder.java
License:Open Source License
/** * Create the actions.// w ww . j a va 2 s .co m */ public void createActions() { // selectAsSeedAction = new Action("Select As a Seed") { // public void run() { // IStructuredSelection sel = (IStructuredSelection)tableViewerLeft.getSelection(); // Iterator iter = sel.iterator(); // while (iter.hasNext()) { // RedirectorFinderResults redirFinderResul = (RedirectorFinderResults) iter.next(); // Method method = redirFinderResul.getMetodo(); // ViewPartUtil.selectAsSeed(method, ViewPartFanInSeeds.ID_VIEW, ((FanInModel)model).getCalls(method.getId()), ((FanInModel)model).getProjectModel()); // //selectAsSeedOperation(method.getMetodo()); // // } selectAllActionMethodsTable = new Action("Select All") { public void run() { selectAll(tableViewerLeft); } }; selectAllActionCallsTable = new Action("Select All") { public void run() { selectAll(tableViewerRight); } }; // Add selection listener. tableViewerLeft.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) tableViewerLeft.getSelection(); openActionTableLeft.setEnabled(sel.size() > 0); selectAllActionMethodsTable.setEnabled(sel.size() > 0); selectAsSeedOperation.setEnabled(sel.size() > 0); } }); tableViewerRight.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) tableViewerRight.getSelection(); selectAllActionCallsTable.setEnabled(sel.size() > 0); openActionTableRight.setEnabled(sel.size() > 0); } }); }
From source file:aspectminingtool.views.RedirectorFinderSeeds.ViewPartClassesSeeds.java
License:Open Source License
/** * Create the actions.// w w w . ja v a2 s . com */ public void createActionsTableLeft() { selectAllActionsLeft = new SelectAllAction(tableViewerLeft); deleteAction = new Action("Delete") { public void run() { IStructuredSelection sel = (IStructuredSelection) tableViewerLeft.getSelection(); Iterator iter = sel.iterator(); while (iter.hasNext()) { SeedClassDescription classDescription = (SeedClassDescription) iter.next(); if (classDescription != null) { ((SeedsClassGeneralModel) model).removeMethodDescription(classDescription); } } } }; selectAllActionsRight = new SelectAllAction(tableViewerRight); // Add selection listener. tableViewerLeft.addSelectionChangedListener(new MenuLeftChangeListener(tableViewerLeft, selectAllActionsLeft, openClassActionTableL, deleteAction)); }
From source file:aspectminingtool.views.SeedsGeneral.ViewPartSeeds.java
License:Open Source License
/** * Create the actions./* w w w . jav a 2 s . co m*/ */ public void createActionsTableLeft() { selectAllActionsLeft = new SelectAllAction(tableViewerLeft); deleteAction = new Action("Delete") { public void run() { IStructuredSelection sel = (IStructuredSelection) tableViewerLeft.getSelection(); Iterator iter = sel.iterator(); while (iter.hasNext()) { SeedDescription methodDescription = (SeedDescription) iter.next(); if (methodDescription != null) { ((SeedsGeneralModel) model).removeMethodDescription(methodDescription); } } } }; selectAllActionsRight = new SelectAllAction(tableViewerRight); // Add selection listener. tableViewerLeft.addSelectionChangedListener(new MenuLeftChangeListener(tableViewerLeft, selectAllActionsLeft, openClassActionTableL, deleteAction)); }
From source file:aspectminingtool.views.Sinergia.Seeds.ViewPartSinergiaSeedsDesc.java
License:Open Source License
/** * Create the actions.//from w w w .ja va2s . c o m */ public void createActions() { selectAllTableLeft = new Action("Select All") { public void run() { selectAll(tableViewerLeft); } }; // Add selection listener. tableViewerLeft.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) tableViewerLeft.getSelection(); openActionTableLeft.setEnabled(sel.size() > 0); selectAllTableLeft.setEnabled(sel.size() > 0); } }); }
From source file:aspectminingtool.views.Sinergia.Seeds.ViewPartSinergiaSeedsDesc.java
License:Open Source License
/** * Create the actions./*from w w w. jav a2 s.c o m*/ */ public void createActionsTableLeft() { selectAllTableLeft = new SelectAllAction(tableViewerLeft); deleteAction = new Action("Delete") { public void run() { IStructuredSelection sel = (IStructuredSelection) tableViewerLeft.getSelection(); Iterator iter = sel.iterator(); while (iter.hasNext()) { SeedDescription methodDescription = (SeedDescription) iter.next(); if (methodDescription != null) { ((SinergiaDescriptionResultsModel) model).removeMethodDescription(methodDescription); } } } }; // Add selection listener. tableViewerLeft.addSelectionChangedListener( new MenuLeftChangeListener(tableViewerLeft, selectAllTableLeft, openActionTableLeft, deleteAction)); }