Java tutorial
/******************************************************************************* * Copyright (c) 2013, 2014 ETAS GmbH. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Dennis Eder (ETAS GmbH) - initial API and implementation and/or initial documentation *******************************************************************************/ package mbtarranger.explorer; import java.io.File; import java.net.URL; import java.util.List; import mbtarranger.BadBank; import mbtarranger.explorer.Functions.SyntaxCheckOptions; import mbtarranger.explorer.jobs.GenerateTests_PARAM_DiagramDetailsJob.Job_generateTests_PARAM_DiagramDetails; import mbtarranger.explorer.jobs.RenderSpinAutomataJob.OutputFormat; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IActionBars; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.progress.IProgressConstants; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; //import org.eclipse.ui.part.FileEditorInput; public class XplrView extends ViewPart { public class ArrExplorerActions { public ArrExplorerActions(XplrJobs jobFactory, InteractionModel interactionModel) { this.jobFactory = jobFactory; this.interactionModel = interactionModel; } private InteractionModel interactionModel; protected XplrJobs jobFactory; public Action action_syncToEditorFile; public Action action_refresh; public Action action_resetProblemReporting; public Action action_renderAutomata; public Action action_renderAutomataNormalized; public Action action_renderAutomataAsTextualARR; public Action action_syntaxCheck_a_v; public Action action_syntaxCheck_a; public Action action_syntaxCheck_A_v; public Action action_syntaxCheck_A; public Action action_verify; public Action action_findPath; public Action action_generateTestCommons; public Action action_generateTests; public Action action_generateTests_summarized; public Action action_generateTests_detailed; public Action action_generateTestsuite_definitionOnly; public Action doubleClickAction; public Action action_renderTrail_onlyIfComplete; public Action action_renderTrail_alsoUncomplete; public void action_syncToEditor() { viewer.setInput(getViewSite()); viewer.expandToLevel(c_REFRESH_EXPAND_LEVEL); } private void action_refresh() { viewer.refresh(); viewer.expandToLevel(c_REFRESH_EXPAND_LEVEL); } private void action_doubleClickAction() { ISelection selection = viewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); showMessage("Double-click detected on " + obj.toString()); } private void action_resetProblemReporting() { try { BadBank.reset4resource(getActiveInputFileResource()); } catch (CoreException e2) { e2.printStackTrace(); } } private void action_renderAutomata() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { @SuppressWarnings("rawtypes") final List selectedItems = sele.toList(); Job job = jobFactory.job_renderSpinAutomata(OutputFormat.unnormalizedGraph, selectedItems, getActiveInputFile(), this.interactionModel); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_renderAutomataAsTextualARR() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { @SuppressWarnings("rawtypes") final List selectedItems = sele.toList(); Job job = jobFactory.job_renderSpinAutomata(OutputFormat.textualArrangeScenario, selectedItems, getActiveInputFile(), this.interactionModel); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_renderAutomataNormalized() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { @SuppressWarnings("rawtypes") final List selectedItems = sele.toList(); Job job = jobFactory.job_renderSpinAutomata(OutputFormat.normalizedGraph, selectedItems, getActiveInputFile(), this.interactionModel); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_syntaxCheck_a_v() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if ((!sele.isEmpty())) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); final ViewContent_TreeNodeV2 selNode = (ViewContent_TreeNodeV2) selectedItems.get(0); Job job = jobFactory.job_syntaxCheck(selNode, SyntaxCheckOptions._a_v, viewer.getControl().getShell().getDisplay(), getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_syntaxCheck_a() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if ((!sele.isEmpty())) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); final ViewContent_TreeNodeV2 selNode = (ViewContent_TreeNodeV2) selectedItems.get(0); Job job = jobFactory.job_syntaxCheck(selNode, SyntaxCheckOptions._a, viewer.getControl().getShell().getDisplay(), getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_syntaxCheck_A_v() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if ((!sele.isEmpty())) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); final ViewContent_TreeNodeV2 selNode = (ViewContent_TreeNodeV2) selectedItems.get(0); Job job = jobFactory.job_syntaxCheck(selNode, SyntaxCheckOptions._A_v, viewer.getControl().getShell().getDisplay(), getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_findPath() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if ((!sele.isEmpty())) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); final ViewContent_TreeNodeV2 selNode = (ViewContent_TreeNodeV2) selectedItems.get(0); Job job = jobFactory.job_findPath(selNode, viewer.getControl().getShell().getDisplay(), getActiveInputFileResource()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_syntaxCheck_A() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if ((!sele.isEmpty())) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); final ViewContent_TreeNodeV2 selNode = (ViewContent_TreeNodeV2) selectedItems.get(0); Job job = jobFactory.job_syntaxCheck(selNode, SyntaxCheckOptions._A, viewer.getControl().getShell().getDisplay(), getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_verify() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if ((!sele.isEmpty())) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); Job job = jobFactory.job_verify(selectedItems, viewer.getControl().getShell().getDisplay(), getActiveInputFileResource()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_generateTestsuite_definitionOnly() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); Job job = jobFactory.job_generateTestsuite_defOnly(selectedItems, getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_generateTestCommons() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); Job job = jobFactory.job_generateTestCommons(selectedItems, Job_generateTests_PARAM_DiagramDetails.None, getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_generateTests() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); Job job = jobFactory.job_generateTests(selectedItems, Job_generateTests_PARAM_DiagramDetails.None, getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_generateTests_detailed() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); Job job = jobFactory.job_generateTests(selectedItems, Job_generateTests_PARAM_DiagramDetails.Detailed, getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_generateTests_summarized() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); Job job = jobFactory.job_generateTests(selectedItems, Job_generateTests_PARAM_DiagramDetails.Summarized, getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_renderTrail_onlyIfComplete() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); Job job = jobFactory.job_renderTrailInteraction(selectedItems, true, getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } private void action_renderTrail_alsoUncomplete() { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { @SuppressWarnings("rawtypes") List selectedItems = sele.toList(); Job job = jobFactory.job_renderTrailInteraction(selectedItems, false, getActiveInputFile()); job.setProperty(IProgressConstants.KEEP_PROPERTY, true); job.schedule(); } } public void makeActions() { // --------------------------- action_renderAutomata = new Action() { public void run() { action_renderAutomata(); } }; action_renderAutomata.setText("Render Automata (compact)..."); action_renderAutomata.setToolTipText("Render Automata..."); // --------------------------- action_renderAutomataNormalized = new Action() { public void run() { action_renderAutomataNormalized(); } }; action_renderAutomataNormalized.setText("Render Automata (normalized)..."); action_renderAutomataNormalized.setToolTipText( "renders with one start state and one end state, there is no incoming (resp. outgoing) transitions " + "to (resp. from) the start (resp. end) state, inaccessible states are removed"); // --------------------------- action_renderAutomataAsTextualARR = new Action() { public void run() { action_renderAutomataAsTextualARR(); } }; action_renderAutomataAsTextualARR.setText("Render Automata (textual)..."); action_renderAutomataAsTextualARR.setToolTipText( "renders with one start state and one end state, there is no incoming (resp. outgoing) transitions " + "to (resp. from) the start (resp. end) state, inaccessible states are removed"); // --------------------------- action_syntaxCheck_a_v = new Action() { public void run() { action_syntaxCheck_a_v(); } }; action_syntaxCheck_a_v.setText("Syntax Check (SPIN -a -v)..."); action_syntaxCheck_a_v.setToolTipText(null); // --------------------------- action_syntaxCheck_a = new Action() { public void run() { action_syntaxCheck_a(); } }; action_syntaxCheck_a.setText("Syntax Check (SPIN -a)..."); action_syntaxCheck_a.setToolTipText(null); // --------------------------- action_syntaxCheck_A_v = new Action() { public void run() { action_syntaxCheck_A_v(); } }; action_syntaxCheck_A_v.setText("Syntax Check (SPIN -A -v)..."); action_syntaxCheck_A_v.setToolTipText(null); // --------------------------- action_syntaxCheck_A = new Action() { public void run() { action_syntaxCheck_A(); } }; action_syntaxCheck_A.setText("Syntax Check (SPIN -A)..."); action_syntaxCheck_A.setToolTipText(null); // --------------------------- action_findPath = new Action() { public void run() { action_findPath(); } }; action_findPath.setText("Find Path..."); action_findPath.setToolTipText("open PathFinder with selected input"); // --------------------------- action_verify = new Action() { public void run() { action_verify(); } }; action_verify.setText("Verification..."); action_verify.setToolTipText("if too large, prune / point and shoot"); // --------------------------- action_generateTestCommons = new Action() { public void run() { action_generateTestCommons(); } }; action_generateTestCommons.setText("Generate Tests Commons ..."); action_generateTestCommons.setToolTipText("to be specified"); // --------------------------- action_generateTests = new Action() { public void run() { action_generateTests(); } }; action_generateTests.setText("Generate Tests ..."); action_generateTests.setToolTipText("to be specified"); // --------------------------- action_generateTests_summarized = new Action() { public void run() { action_generateTests_summarized(); } }; action_generateTests_summarized.setText("Generate Tests (summarized diagram)..."); action_generateTests_summarized.setToolTipText("to be specified"); // --------------------------- action_generateTests_detailed = new Action() { public void run() { action_generateTests_detailed(); } }; action_generateTests_detailed.setText("Generate Tests (detailed diagrams)..."); action_generateTests_detailed.setToolTipText("to be specified"); // --------------------------- action_generateTestsuite_definitionOnly = new Action() { public void run() { action_generateTestsuite_definitionOnly(); } }; action_generateTestsuite_definitionOnly.setText("Generate Testsuite (definition only)..."); action_generateTestsuite_definitionOnly.setToolTipText( "the testcases themselves are not generated, only the BOOST test suite which references the testcases"); // --------------------------- action_resetProblemReporting = new Action() { public void run() { action_resetProblemReporting(); } }; action_resetProblemReporting.setText("Reset Problem Markers"); action_resetProblemReporting.setToolTipText("resets Problem Markers for current file"); // --------------------------- action_syncToEditorFile = new Action() { public void run() { action_syncToEditor(); } }; action_syncToEditorFile.setText("Sync<<Editor"); action_syncToEditorFile.setToolTipText("synchronizes from currently active file in editor"); // --------------------------- action_refresh = new Action() { public void run() { action_refresh(); } }; action_refresh.setText("Refresh"); action_refresh.setToolTipText("synchronizes to updates on active file in this window"); // --------------------------- action_renderTrail_onlyIfComplete = new Action() { public void run() { action_renderTrail_onlyIfComplete(); } }; action_renderTrail_onlyIfComplete.setText("Render Trail (only if counterproof hit)..."); action_renderTrail_onlyIfComplete .setToolTipText("e.g. uses counterproof trail from prior verification"); // --------------------------- action_renderTrail_alsoUncomplete = new Action() { public void run() { action_renderTrail_alsoUncomplete(); } }; action_renderTrail_alsoUncomplete.setText("Render Trail (also uncomplete verifications)..."); action_renderTrail_alsoUncomplete .setToolTipText("e.g. uses counterproof trail from prior verification"); // --------------------------- doubleClickAction = new Action() { public void run() { action_doubleClickAction(); } }; } } /** * The name of the view as specified by the extension. */ public static final String ID = "PLUGIN_ArrExplorer.views.View"; protected InteractionModel interactionModel = new InteractionModel(); protected static final int c_REFRESH_EXPAND_LEVEL = 2; protected TreeViewer viewer; protected ArrExplorerActions actions; protected IFile m_activeInputFile = null; protected Image image_icon4file16px; protected Image image_icon4tx16px; protected Image image_icon4fsm16px; protected Image image_icon4arrange16px; protected Image image_icon4cov16px; protected Image image_icon4cfg16px; protected Image image_icon4input16px; protected Image image_icon4output16px; protected Image image_icon4internal16px; protected Image image_icon4labels16px; protected Image image_icon4compose16px; protected Image image_icon4express16px; protected Image image_icon4scenarios16px; protected Image image_icon4labeldef16px; protected Image image_icon4never16px; protected Image image_icon4trace16px; protected Image image_icon4notrace16px; protected Image image_icon4testsetslisting16px; protected Image image_icon4testslisting16px; protected Image image_icon4testset16px; protected Image image_icon4ltl16px; protected Image image_icon4adapter16px; protected Image image_icon4autoconstruct16px; protected Image image_icon4cfgslisting16px; protected Image image_icon4enum16px; protected Image image_icon4channel16px; protected Image image_icon4typedef16px; protected Image image_icon4define16px; protected Image image_icon4inline16px; protected Image image_icon4array16px; protected Image image_icon4flatCommaList16px; protected Image image_icon4databind16px; protected Image image_icon4databindings16px; protected Image image_icon4variant16px; protected Image image_icon4combinatorics16px; protected Image image_icon4alternative16px; protected Image image_icon4alternatives16px; protected Image image_icon4fileImport16px; protected Image image_icon4package16px; public synchronized InteractionModel getInteractionModel() { return interactionModel; } class NameSorter extends ViewerSorter { } public XplrView() { this(new XplrJobs()); } public XplrView(XplrJobs jobFactory) { actions = new ArrExplorerActions(jobFactory, this.interactionModel); setupIcons(); } protected void setupIcons() { // setup icons Bundle bundle = FrameworkUtil.getBundle(this.getClass()); URL url = FileLocator.find(bundle, new Path("icons/tx16.gif"), null); ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4tx16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/fsm16px.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4fsm16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/arrange16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4arrange16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/cov16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4cov16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/cfg16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4cfg16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/cfgslisting16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4cfgslisting16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/input16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4input16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/output16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4output16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/internal16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4internal16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/labels16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4labels16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/compose16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4compose16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/express16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4express16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/scenarios16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4scenarios16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/file16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4file16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/labeldef16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4labeldef16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/never16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4never16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/trace16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4trace16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/notrace16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4notrace16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/testslisting16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4testslisting16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/testsetslisting16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4testsetslisting16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/testset16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4testset16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/ltl16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4ltl16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/adapter16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4adapter16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/channel16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4channel16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/enum16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4enum16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/array16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4array16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/typedef16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4typedef16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/flatCommaList16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4flatCommaList16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/autoconstruct16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4autoconstruct16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/define16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4define16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/inline16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4inline16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/databind16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4databind16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/databindings16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4databindings16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/variant16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4variant16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/combinatorics16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4combinatorics16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/alternative16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4alternative16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/alternatives16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4alternatives16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/fileImport16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4fileImport16px = imageDescriptor.createImage(); // url = FileLocator.find(bundle, new Path("icons/package16.gif"), null); imageDescriptor = ImageDescriptor.createFromURL(url); image_icon4package16px = imageDescriptor.createImage(); } /** * This is a callback that will allow us to create the viewer and initialize * it. */ public void setContentProvider() { viewer.setContentProvider(new XplrContentProvider(this)); } @Override public void createPartControl(Composite parent) { parent.setLayoutData(new FillLayout()); viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); /* * ------------ ... */ setContentProvider(); /* * ... ------------ */ viewer.setLabelProvider(new XplrLabelProvider(this)); viewer.setSorter(new NameSorter()); // Create the help context name for the viewer's control PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "TodoMock.viewer"); actions.makeActions(); hookContextMenu(); hookDoubleClickAction(); contributeToActionBars(); getSite().setSelectionProvider(viewer); viewer.setInput(getViewSite()); viewer.expandToLevel(c_REFRESH_EXPAND_LEVEL); } public File getActiveInputFile() { return m_activeInputFile.getRawLocation().toFile(); } public void setActiveInputFile(IFile activeInputFile) { this.m_activeInputFile = activeInputFile; } protected void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(manager -> XplrView.this.fillContextMenu(manager)); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, viewer); } protected void contributeToActionBars() { IActionBars bars = getViewSite().getActionBars(); fillLocalPullDown(bars.getMenuManager()); fillLocalToolBar(bars.getToolBarManager()); } private void fillLocalPullDown(IMenuManager manager) { manager.add(actions.action_refresh); manager.add(actions.action_syncToEditorFile); manager.add(new Separator()); } protected void fillContextMenu(IMenuManager manager) { IStructuredSelection sele = (IStructuredSelection) viewer.getSelection(); if (!sele.isEmpty()) { ViewContent_TreeNodeV2 selNode = (ViewContent_TreeNodeV2) sele.toList().get(0); switch (selNode.contentType) { case Alternative: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case AlternativesListing: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case Scenario: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case ComposeTermNonterminal: case ComposeTermTerminal: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case SmvFile: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_syntaxCheck_a_v); manager.add(actions.action_syntaxCheck_a); manager.add(actions.action_syntaxCheck_A_v); manager.add(actions.action_syntaxCheck_A); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case PromelaProcessBehaviour: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case NeverSpec: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case LtlSpec: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case NotraceSpec: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case TraceSpec: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case Config: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_generateTestCommons); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case Test: case AutoconstructedTest: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_findPath); manager.add(actions.action_verify); manager.add(actions.action_renderTrail_alsoUncomplete); manager.add(actions.action_renderTrail_onlyIfComplete); manager.add(actions.action_generateTestCommons); manager.add(actions.action_generateTests); manager.add(actions.action_generateTests_summarized); manager.add(actions.action_generateTests_detailed); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case Testset: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_generateTestsuite_definitionOnly); manager.add(actions.action_generateTestCommons); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case Variant: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; case VariantsListing: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(actions.action_renderAutomataAsTextualARR); manager.add(actions.action_renderAutomata); manager.add(actions.action_renderAutomataNormalized); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); break; default: manager.add(actions.action_resetProblemReporting); manager.add(new Separator()); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } } } private void fillLocalToolBar(IToolBarManager manager) { manager.add(actions.action_refresh); manager.add(actions.action_syncToEditorFile); } public static class MarkerLineAndFileTuple { public int line; public File file; public MarkerLineAndFileTuple(int line, File file) { this.line = line; this.file = file; } } public IFile getActiveInputFileResource() { return m_activeInputFile; } protected void hookDoubleClickAction() { viewer.addDoubleClickListener(event -> actions.doubleClickAction.run()); } private void showMessage(String message) { MessageDialog.openInformation(viewer.getControl().getShell(), "PML Explorer (DeSpIDE)", message); } /** * Passing the focus request to the viewer's control. */ public void setFocus() { viewer.getControl().setFocus(); } }