/** Return configured image if none exists for the element type */ public Image getImage(Object element) { Image image = CorePlugin.getImageFor(element, false); if (image != null) { return image; } return CorePlugin.getImageFor("ImportedFunctionPackage.gif"); }
/** Return configured image if none exists for the element type */ public Image getImage(Object element) { Image image = CorePlugin.getImageFor(element, false); if (image != null) { return image; } return CorePlugin.getImageFor("RequiredSignal.gif"); }
private void COMM_COMM_NewClassParticipant(IStructuredSelection selection) { // Assign the context selection variables with the action context // Assign the context selection variable with the action context Object context = selection.iterator().next(); Communication_c v_comm = (Communication_c) context; PersistableModelComponent.ensureCoreDataTypesAvailable(v_comm.getModelRoot()); TransactionUtil.TransactionGroup transactionGroup = TransactionUtil.startTransactionsOnSelectedModelRoots("New Class Participant"); try { // Ensure that actions take place between Verifier Activity executions Ooaofooa.beginSaveOperation(); if (((v_comm != null))) { if (v_comm != null) { v_comm.Newclassparticipant(); } else { Throwable t = new Throwable(); t.fillInStackTrace(); CorePlugin.logError("Attempted to call an operation on a null instance.", t); } } // end critical section Ooaofooa.endSaveOperation(); // catch all exceptions and cancel the transactions } catch (Exception e) { Ooaofooa.endSaveOperation(); TransactionUtil.cancelTransactions(transactionGroup, e); CorePlugin.logError("Transaction: New Class Participant failed", e); // $NON-NLS-1$ } TransactionUtil.endTransactions(transactionGroup); }
/** * Copies the domain file of the given name from the development workspace project of the given * name into the given test workspace project. */ public static IFile copyTestDomainIntoProject( String domainName, String copyFromProjectName, IProject toProject) { // locate the test domain's file in the development workspace File workspaceSource = TestingUtilities.getSourceDirectory().toFile().getParentFile(); File file = new File( workspaceSource, copyFromProjectName + "/" + Ooaofooa.MODELS_DIRNAME + "/" + domainName + "." + Ooaofooa.MODELS_EXT); // if a file of the same name already exists in the given project IFile resource = toProject.getFile(Ooaofooa.MODELS_DIRNAME + "/" + file.getName()); File copyFile = resource.getLocation().toFile(); if (resource.exists()) { // copy the test domain's file over the existing file at the // Java-file level, as Eclipse won't let us overwrite // it at the IFile level (due to a bug in IFile.create()) copyFile(file, copyFile.getAbsolutePath()); // get Eclipse to notice the changed file (and wait // until the resulting model-events have been dispatched, // before proceeding) try { DispatchOnDoneProgressMonitor monitor = new DispatchOnDoneProgressMonitor(); resource.refreshLocal(0, monitor); while (!monitor.done) TestUtil.sleep(10); } catch (CoreException e) { CorePlugin.logError( "Could not get Eclipse to recognize new copy of test domain in project", e); } } // otherwise else { // copy the test domain's file into the given project (and wait // until the resulting model-events have been dispatched, // before proceeding) copyFile(file, copyFile.getAbsolutePath()); try { FileInputStream stream = new FileInputStream(file); DispatchOnDoneProgressMonitor monitor = new DispatchOnDoneProgressMonitor(); resource.create(stream, true, monitor); while (!monitor.done) TestUtil.sleep(10); stream.close(); } catch (Exception e) { CorePlugin.logError("Could not copy test domain into project", e); } } return resource; }
// declare transform functions public void Dispose() { Ooaofgraphics.log.println( ILogger.OPERATION, "GraphNode", " Operation entered: Graphnode::Dispose"); final ModelRoot modelRoot = getModelRoot(); Graphelement_c v_element = Graphelement_c.getOneDIM_GEOnR301(this); if (((v_element != null))) { if (v_element != null) { v_element.Dispose(); } else { Throwable t = new Throwable(); t.fillInStackTrace(); CorePlugin.logError("Attempted to call an operation on a null instance.", t); } } else { Shape_c v_shape = Shape_c.getOneGD_SHPOnR19(this); if (((v_shape != null))) { this.unrelateAcrossR19From(v_shape); if (v_shape != null) { v_shape.Dispose(); } else { Throwable t = new Throwable(); t.fillInStackTrace(); CorePlugin.logError("Attempted to call an operation on a null instance.", t); } } FloatingText_c v_ctxt = FloatingText_c.getOneGD_CTXTOnR19(this); if (((v_ctxt != null))) { this.unrelateAcrossR19From(v_ctxt); if (v_ctxt != null) { v_ctxt.Dispose(); } else { Throwable t = new Throwable(); t.fillInStackTrace(); CorePlugin.logError("Attempted to call an operation on a null instance.", t); } } if (delete()) { Ooaofgraphics.getDefaultInstance() .fireModelElementDeleted( new BaseModelDelta(Modeleventnotification_c.DELTA_DELETE, this)); } } } // End dispose
// public for unit test public WizardDialog MSG_SM_CommunicationClassOperationFormalize(IStructuredSelection selection) { CommunicationClassOperationFormalizeOnMSG_SMWizard wizard = new CommunicationClassOperationFormalizeOnMSG_SMWizard(); wizard.init(CorePlugin.getDefault().getWorkbench(), selection, null); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog(m_part.getSite().getShell(), wizard); dialog.create(); ImageDescriptor descr = CorePlugin.getImageDescriptor("green-bp.gif"); dialog.getShell().setImage(descr.createImage()); return dialog; }
// public for unit test public WizardDialog SQ_CP_SpecializedPackageClassFormalize(IStructuredSelection selection) { SpecializedPackageClassFormalizeOnSQ_CPWizard wizard = new SpecializedPackageClassFormalizeOnSQ_CPWizard(); wizard.init(CorePlugin.getDefault().getWorkbench(), selection, null); // Instantiates the wizard container with the wizard and opens it WizardDialog dialog = new WizardDialog(m_part.getSite().getShell(), wizard); dialog.create(); ImageDescriptor descr = CorePlugin.getImageDescriptor("green-bp.gif"); dialog.getShell().setImage(descr.createImage()); return dialog; }
/** A convenience method for opening the given project. */ public static void openProject(IProject project) { try { project.open(new NullProgressMonitor()); } catch (CoreException e) { CorePlugin.logError("Could not open project", e); } }
/** A convenience method for closing the given project. */ public static void closeProject(IProject project) { try { project.close(new NullProgressMonitor()); } catch (CoreException e) { CorePlugin.logError("Could not close project", e); } }
/** A convenience method for closing the given project. */ public static void deleteProject(IProject project) { try { project.delete(false, true, new NullProgressMonitor()); } catch (CoreException e) { CorePlugin.logError("Could not delete project", e); } }
/** * Changes the given file's readonly status * * @param readonly - A boolean used to determine what status to set the file to * @param modelFile - The file in which the status should be altered */ public static void changeFileReadonlyStatus(boolean readonly, IFile modelFile) { ResourceAttributes resourceAttributes = modelFile.getResourceAttributes(); if (resourceAttributes != null) { resourceAttributes.setReadOnly(readonly); try { modelFile.setResourceAttributes(resourceAttributes); } catch (CoreException e) { CorePlugin.logError("Core Exception", e); } } }
protected void setUp() throws Exception { super.setUp(); if (!initialized) { m_sys = getSystemModel("Models"); ensureAvailableAndLoaded( "Models", "Imported Component IF Scope Testing", false, true, "Component Package"); Ooaofooa componentRoot = modelRoot; ensureAvailableAndLoaded("Models", "sdt_test", false, false, "Domain"); testDomain = Domain_c.DomainInstance(modelRoot); modelRoot = componentRoot; initialized = true; } CorePlugin.disableParseAllOnResourceChange(); }
/** * Writes the given array of strings out to a text file of the given name (including path), one * string per line. * * <p>Note that any line-feed characters within the strings will be stripped out before writing, * as they tend to complicate comparisons of the contents of the file after they are read back in. * * @return Whether the write was successful. */ public static boolean writeToFile(String[] strings, String pathName) { try { // get the current file contents for comparison // if there is no difference then we don't need // to update the result File resultFile = new File(pathName); if (resultFile.exists()) { byte[] fileBytes = new byte[(int) resultFile.length()]; FileInputStream fis = new FileInputStream(resultFile); fis.read(fileBytes); fis.close(); String fileContents = new String(fileBytes); String[] currentContents = null; if (fileContents.indexOf("\r") != -1) { currentContents = fileContents.split("\r\n"); } else { currentContents = fileContents.split("\n"); } if (stringArraysAreEqual(currentContents, strings)) { return false; } } // create the file of the given path and name FileWriter writer = new FileWriter(pathName); // for each element in the given strings array String lineSeparator = System.getProperty("line.separator"); for (int i = 0; i < strings.length; i++) { // strip out any line-feeds from this string, as they // will cause it to be treated as two or more separate // strings when it is read back in, which screws up // comparisons String string = strings[i].replaceAll("\n", ""); // write this string out to a new line in the text file if (i > 0) writer.write(lineSeparator); writer.write(string); } writer.flush(); } catch (Exception e) { CorePlugin.logError("Could not write strings to text file", e); return false; } return true; }
protected boolean includeMoveDownOperation() { if ((getMergeViewer().getLeftViewer() == this && !getMergeViewer().isLeftEditable()) || (getMergeViewer().getRightViewer() == this && !getMergeViewer().isRightEditable())) { return false; } IStructuredSelection selection = (IStructuredSelection) getSelection(); if (selection.size() == 1) { Object element = selection.getFirstElement(); Object realElement = ((ComparableTreeObject) element).getRealElement(); if (MetadataSortingManager.isOrderedElement(realElement)) { try { Method method = realElement .getClass() .getMethod( "Actionfilter", new Class[] {String.class, String.class}); // $NON-NLS-1$ Boolean bool = (Boolean) method.invoke( realElement, new Object[] {"can", "move down"}); // $NON-NLS-1$ $NON-NLS-2$ return bool; } catch (SecurityException e) { CorePlugin.logError("Unable to test for ordering ability.", e); } catch (NoSuchMethodException e) { CorePlugin.logError("Unable to test for ordering ability.", e); } catch (IllegalArgumentException e) { CorePlugin.logError("Unable to test for ordering ability.", e); } catch (IllegalAccessException e) { CorePlugin.logError("Unable to test for ordering ability.", e); } catch (InvocationTargetException e) { CorePlugin.logError("Unable to test for ordering ability.", e); } } } return false; }
/** * Copies the given file to a new one at the given destination path. If a file is already at that * location, it will be overwritten. * * <p>For copying an Eclipse IFile, IFile.create() should be used instead of this. */ public static void copyFile(File file, String destPath) { try { // open streams on the file and the // destination location File copy = new File(destPath); FileInputStream in = new FileInputStream(file); FileOutputStream out = new FileOutputStream(copy); // transfer the bytes from the file to the copy int c; while ((c = in.read()) != -1) out.write(c); // close the streams in.close(); out.close(); } catch (IOException e) { CorePlugin.logError("Could not copy file", e); } }
/** * Copies a class file of the given name from the development workspace project of the given name * into the given test workspace project. */ public static IFile copyClassFileIntoProject( String className, String copyFromProjectName, IProject toProject) { // locate the required file in the development workspace File workspaceSource = TestingUtilities.getSourceDirectory().toFile().getParentFile(); File file = new File(workspaceSource, copyFromProjectName + "/bin/lib/" + className + ".class"); IFile resource = toProject.getFile("/bin/lib/" + file.getName()); File copyFile = resource.getLocation().toFile(); // copy the test file into the given project (and wait // until the resulting model-events have been dispatched, // before proceeding) copyFile(file, copyFile.getAbsolutePath()); try { FileInputStream stream = new FileInputStream(file); DispatchOnDoneProgressMonitor monitor = new DispatchOnDoneProgressMonitor(); resource.create(stream, true, monitor); while (!monitor.done) TestUtil.sleep(10); stream.close(); } catch (Exception e) { CorePlugin.logError("Could not copy test class into project. reason: ", e); } return resource; }
/* (non-Javadoc) * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object) */ public void setPropertyValue(Object id, Object value) { boolean value_changed = false; String trans_name = ""; Transaction tr = null; Ooaofooa modelRoot = (Ooaofooa) m_inst.getModelRoot(); TransactionManager tm = TransactionManager.getSingleton(); try { if (id.equals("Descrip")) { if (!value.toString().equals(m_inst.getDescrip())) { trans_name = "Change in property: 'Descrip' of Fork Join Node"; // $NON-NLS-1$ tr = tm.startTransaction(trans_name, Ooaofooa.getDefaultInstance()); value_changed = true; m_inst.setDescrip(value.toString()); } } else if (id.equals("GuardCondition")) { if (!value.toString().equals(m_inst.getGuardcondition())) { trans_name = "Change in property: 'GuardCondition' of Fork Join Node"; // $NON-NLS-1$ tr = tm.startTransaction(trans_name, Ooaofooa.getDefaultInstance()); value_changed = true; m_inst.setGuardcondition(value.toString()); } } // catch all exceptions and cancel the transaction } catch (Exception e) { // this can be null if there was // an exception starting the // transaction if (tr != null) { tm.cancelTransaction(tr, e); tr = null; } CorePlugin.logError("Transaction: " + trans_name + " could not complete", e); } if (tr != null) { if (value_changed) tm.endTransaction(tr); else tm.cancelTransaction(tr); } }
/** * Creates (and returns) a test project of the name of the given test class, copies into it the * model of the given name found in the project of the given name, and (also) returns the root of * the model imported from that copy. */ public static Result1 createTestProjectAndImportModel( Class testClass, String testModelName, String testModelProjectName) { Result1 result = new Result1(); // create the test project String className = testClass.getName(); IProject project = null; try { project = result.project = TestingUtilities.createProject(className.substring(className.lastIndexOf(".") + 1)); } catch (CoreException e) { CorePlugin.logError("Core Exception", e); } // copy the test domain into our test project IFile file = copyTestDomainIntoProject(testModelName, testModelProjectName, project); result.file = file; // import the test domain from the copy in the test project result.modelRoot = Ooaofooa.getInstance(Ooaofooa.createModelRootId(project, testModelName, true), true); return result; }
public boolean performFinish() { TransactionUtil.TransactionGroup transactionGroup = null; ModelRoot modelRoot = v_asyncMessage.getModelRoot(); try { transactionGroup = TransactionUtil.startTransactionsOnSelectedModelRoots( "Instance Event Formalize"); //$NON-NLS-1$ Message_c v_message = Message_c.getOneMSG_MOnR1018(v_asyncMessage); InteractionParticipant_c v_participant = InteractionParticipant_c.getOneSQ_POnR1007(v_message); Lifespan_c v_ls = Lifespan_c.getOneSQ_LSOnR930(v_participant); ClassInstanceParticipant_c v_cip = ClassInstanceParticipant_c.getOneSQ_CIPOnR930( InteractionParticipant_c.getOneSQ_POnR940(v_ls)); ModelClass_c v_cipclass = (ModelClass_c) modelRoot.getInstanceList(ModelClass_c.class).getGlobal(null, Gd_c.Null_unique_id()); if (((v_cip != null))) { v_cipclass = ModelClass_c.getOneO_OBJOnR934(v_cip); } else { v_cip = ClassInstanceParticipant_c.getOneSQ_CIPOnR930( InteractionParticipant_c.getOneSQ_POnR1007(v_message)); if (((v_cip != null))) { Communication_c v_communication = Communication_c.getOneCOMM_COMMOnR1126( ParticipantInCommunication_c.getOneCOMM_PICOnR1126( InteractionParticipant_c.getOneSQ_POnR930(v_cip))); if (((v_communication != null))) { v_cipclass = ModelClass_c.getOneO_OBJOnR934(v_cip); } } } if (((v_cipclass != null))) { StateMachineEvent_c v_evt = StateMachineEvent_c.getOneSM_EVTOnR1009( EventMessage_c.getOneMSG_EOnR1019(v_asyncMessage)); java.util.UUID v_existingId = Gd_c.Null_unique_id(); if (((v_evt != null))) { v_existingId = v_evt.getSmevt_id(); } StateMachine_c v_stateMachine = StateMachine_c.getOneSM_SMOnR517(InstanceStateMachine_c.getOneSM_ISMOnR518(v_cipclass)); StateMachine_c[] v_machines = StateMachine_c.getManySM_SMsOnR517( InstanceStateMachine_c.getManySM_ISMsOnR518( ModelClass_c.getManyO_OBJsOnR8001( PackageableElement_c.getManyPE_PEsOnR8000( Package_c.getManyEP_PKGsOnR1405( SystemModel_c.getManyS_SYSsOnR1405( Package_c.getManyEP_PKGsOnR8000( PackageableElement_c.getManyPE_PEsOnR8001( v_cipclass)))))))); if (((v_machines.length == 0))) { v_machines = StateMachine_c.getManySM_SMsOnR517( InstanceStateMachine_c.getManySM_ISMsOnR518( ModelClass_c.getManyO_OBJsOnR2( Subsystem_c.getManyS_SSsOnR1( Domain_c.getManyS_DOMsOnR1( Subsystem_c.getManyS_SSsOnR2(v_cipclass)))))); } if (((v_Message != null))) { if (v_asyncMessage != null) { v_asyncMessage.Formalizewithevent(v_Message.getSmevt_id()); } else { Throwable t = new Throwable(); t.fillInStackTrace(); CorePlugin.logError("Attempted to call an operation on a null instance.", t); } } } // catch all exceptions and cancel the transaction } catch (Exception e) { if (transactionGroup != null) TransactionUtil.cancelTransactions(transactionGroup, e); CorePlugin.logError("Transaction: Instance Event Formalize failed", e); // $NON-NLS-1$ // return true so that the wizard will // close return true; } if (transactionGroup != null) TransactionUtil.endTransactions(transactionGroup); if (m_viewer != null) { if (m_viewer instanceof StructuredViewer) { ((StructuredViewer) m_viewer).refresh(v_asyncMessage); } else { m_viewer.refresh(); } } return true; }
public boolean performFinish() { TransactionUtil.TransactionGroup transactionGroup = null; ModelRoot modelRoot = v_syncMessage.getModelRoot(); try { transactionGroup = TransactionUtil.startTransactionsOnSelectedModelRoots( "Interface Operation Formalize"); //$NON-NLS-1$ Message_c v_message = Message_c.getOneMSG_MOnR1018(v_syncMessage); InteractionParticipant_c v_participant = InteractionParticipant_c.getOneSQ_POnR1007(v_message); ComponentParticipant_c v_cop = ComponentParticipant_c.getOneSQ_COPOnR930(v_participant); if (((v_cop == null))) { v_cop = ComponentParticipant_c.getOneSQ_COPOnR930( InteractionParticipant_c.getOneSQ_POnR940( Lifespan_c.getOneSQ_LSOnR930(v_participant))); } Component_c v_component = (Component_c) modelRoot.getInstanceList(Component_c.class).getGlobal(null, Gd_c.Null_unique_id()); if (((v_cop != null))) { v_component = Component_c.getOneC_COnR955(v_cop); } if (((v_component != null))) { if (((v_Operation != null))) { if (v_syncMessage != null) { v_syncMessage.Formalizewithinterfaceoperation(v_Operation.getId()); } else { Throwable t = new Throwable(); t.fillInStackTrace(); CorePlugin.logError("Attempted to call an operation on a null instance.", t); } } } // catch all exceptions and cancel the transaction } catch (Exception e) { if (transactionGroup != null) TransactionUtil.cancelTransactions(transactionGroup, e); CorePlugin.logError("Transaction: Interface Operation Formalize failed", e); // $NON-NLS-1$ // return true so that the wizard will // close return true; } if (transactionGroup != null) TransactionUtil.endTransactions(transactionGroup); if (m_viewer != null) { if (m_viewer instanceof StructuredViewer) { ((StructuredViewer) m_viewer).refresh(v_syncMessage); } else { m_viewer.refresh(); } } return true; }
/** @see IActionDelegate#selectionChanged(IAction, ISelection) */ public void selectionChanged(IAction action, ISelection selection) { action.setImageDescriptor(CorePlugin.getImageDescriptorFor("ClassParticipant_c", false)); }
/** @see IActionDelegate#selectionChanged(IAction, ISelection) */ public void selectionChanged(IAction action, ISelection selection) { action.setImageDescriptor(CorePlugin.getImageDescriptorFor("LiteralSymbolicConstant_c", false)); }
@Override public void buildContextMenu(IMenuManager menu) { final MenuManager createMenuManager = new MenuManager("New", "com.mentor.nucleus.bp.ui.newroot"); // $NON-NLS-2$ final MenuManager openMenuManager = new MenuManager("Open With", "com.mentor.nucleus.bp.ui.openroot"); // $NON-NLS-2$ final MenuManager classesMenu = new MenuManager("Classes", "com.mentor.nucleus.bp.ui.classroot"); // $NON-NLS-2$ final MenuManager componentsMenu = new MenuManager("Components", "com.mentor.nucleus.bp.ui.componentroot"); // $NON-NLS-2$ final MenuManager externalMenu = new MenuManager("External", "com.mentor.nucleus.bp.ui.externalroot"); // $NON-NLS-2$ final MenuManager interactionMenu = new MenuManager("Interaction", "com.mentor.nucleus.bp.ui.interactionroot"); // $NON-NLS-2$ final MenuManager activityMenu = new MenuManager("Activity", "com.mentor.nucleus.bp.ui.activityroot"); // $NON-NLS-2$ final MenuManager typesMenu = new MenuManager("Types", "com.mentor.nucleus.bp.ui.typeroot"); // $NON-NLS-2$ final MenuManager useCaseMenu = new MenuManager("Usecase", "com.mentor.nucleus.bp.ui.usecaseroot"); // $NON-NLS-2$ menu.add(createMenuManager); createMenuManager.removeAll(); createMenuManager.add(new GroupMarker("com.mentor.nucleus.bp.ui.newmenu")); // $NON-NLS-1$ createMenuManager.add(activityMenu); activityMenu.removeAll(); activityMenu.add(new GroupMarker("com.mentor.nucleus.bp.ui.newactivitymenu")); createMenuManager.add(classesMenu); classesMenu.removeAll(); classesMenu.add(new GroupMarker("com.mentor.nucleus.bp.ui.newclassmenu")); createMenuManager.add(componentsMenu); componentsMenu.removeAll(); componentsMenu.add(new GroupMarker("com.mentor.nucleus.bp.ui.newcomponentmenu")); createMenuManager.add(externalMenu); externalMenu.removeAll(); externalMenu.add(new GroupMarker("com.mentor.nucleus.bp.ui.newexternalmenu")); createMenuManager.add(interactionMenu); interactionMenu.removeAll(); interactionMenu.add(new GroupMarker("com.mentor.nucleus.bp.ui.newinteractionmenu")); createMenuManager.add(typesMenu); typesMenu.removeAll(); typesMenu.add(new GroupMarker("com.mentor.nucleus.bp.ui.newtypemenu")); createMenuManager.add(useCaseMenu); useCaseMenu.removeAll(); useCaseMenu.add(new GroupMarker("com.mentor.nucleus.bp.ui.newusecasemenu")); menu.add(fEditor.getOpenAction()); menu.add(openMenuManager); openMenuManager.removeAll(); openMenuManager.add(new GroupMarker("com.mentor.nucleus.bp.ui.openmenu")); // $NON-NLS-1$ menu.add(new Separator("com.mentor.nucleus.bp.ui.context-internal")); // $NON-NLS-1$ menu.add(new Separator("com.mentor.nucleus.bp.ui.context-internal-end")); // $NON-NLS-1$ menu.add(new Separator()); menu.add(fEditor.getUndoAction()); menu.add(fEditor.getRedoAction()); menu.add(new Separator()); menu.add(fEditor.getCutAction()); // for some reason we must specifically set enabled here fEditor.getCutAction().setEnabled(fEditor.getCutAction().isEnabled()); menu.add(fEditor.getCopyAction()); fEditor.getCopyAction().setEnabled(fEditor.getCopyAction().isEnabled()); menu.add(fEditor.getPasteAction()); fEditor.getPasteAction().setEnabled(fEditor.getPasteAction().isEnabled()); menu.add(new Separator()); menu.add(fEditor.getSelectAllAction()); fEditor .getDeleteAction() .setEnabled( enableDelete( (IStructuredSelection) fEditor.getSite().getSelectionProvider().getSelection())); menu.add(fEditor.getDeleteAction()); fEditor.getRenameAction().setEnabled(RenameAction.canRenameAction()); menu.add(fEditor.getRenameAction()); menu.add(new Separator()); menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); menu.add(new Separator()); menu.add(CorePlugin.getResourceImportAction()); menu.add(CorePlugin.getResourceExportAction()); }
private void CNST_CSP_NewConstant(IStructuredSelection selection) { // Assign the context selection variables with the action context // Assign the context selection variable with the action context Object context = selection.iterator().next(); ConstantSpecification_c v_csp = (ConstantSpecification_c) context; PersistableModelComponent.ensureCoreDataTypesAvailable(v_csp.getModelRoot()); TransactionUtil.TransactionGroup transactionGroup = TransactionUtil.startTransactionsOnSelectedModelRoots("New Constant"); boolean abortTransaction = false; try { // Ensure that actions take place between Verifier Activity executions Ooaofooa.beginSaveOperation(); if (v_csp != null) { v_csp.Newliteralsymbolicconstant(); } else { Throwable t = new Throwable(); t.fillInStackTrace(); CorePlugin.logError("Attempted to call an operation on a null instance.", t); } NonRootModelElement[] children = LiteralSymbolicConstant_c.getManyCNST_LSCsOnR1503( LeafSymbolicConstant_c.getManyCNST_LFSCsOnR1502( SymbolicConstant_c.getManyCNST_SYCsOnR1504(v_csp))); NonRootModelElement newElement = children[children.length - 1]; IPreferenceStore store = CorePlugin.getDefault().getPreferenceStore(); boolean option = store.getBoolean(BridgePointPreferencesStore.USE_DEFAULT_NAME_FOR_CREATION); if (!option) { String oldName = RenameActionUtil.getElementName(newElement); boolean performRename = UIUtil.inputDialog( null, "Element Creation", "Enter the name:", oldName, UIUtil.newRenameValidator(newElement)); if (performRename) { String proposedName = UIUtil.inputDialogResult; RenameActionUtil.setElementName(newElement, proposedName); newElement.setComponent(null); } else { abortTransaction = true; } } // end critical section Ooaofooa.endSaveOperation(); // catch all exceptions and cancel the transactions } catch (Exception e) { Ooaofooa.endSaveOperation(); TransactionUtil.cancelTransactions(transactionGroup, e); CorePlugin.logError("Transaction: New Constant failed", e); // $NON-NLS-1$ } if ((!CorePlugin.getDefault() .getPreferenceStore() .getBoolean(BridgePointPreferencesStore.USE_DEFAULT_NAME_FOR_CREATION)) && abortTransaction) { TransactionUtil.cancelTransactions(transactionGroup); } else { TransactionUtil.endTransactions(transactionGroup); } }
@Override protected void setUp() throws Exception { if (!initialized) delayGlobalUpgrade = true; super.setUp(); if (!initialized) { CorePlugin.disableParseAllOnResourceChange(); // set perspective switch dialog on launch DebugUIPlugin.getDefault() .getPluginPreferences() .setValue(IDebugUIConstants.PLUGIN_ID + ".switch_to_perspective", "always"); CorePlugin.getDefault() .getPluginPreferences() .setDefault(BridgePointPreferencesStore.ALLOW_IMPLICIT_COMPONENT_ADDRESSING, true); CorePlugin.getDefault() .getPluginPreferences() .setValue(BridgePointPreferencesStore.SHOW_EVENT_PARAMETERS, true); // initialize test model final IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); File sourceProject = new File(m_workspace_path + "../" + projectName); TestingUtilities.copyProjectContents(sourceProject, project); TestingUtilities.allowJobCompletion(); TestingUtilities.allowJobCompletion(); m_sys = SystemModel_c.SystemModelInstance( Ooaofooa.getDefaultInstance(), new ClassQueryInterface_c() { public boolean evaluate(Object candidate) { return ((SystemModel_c) candidate).getName().equals(project.getName()); } }); PersistableModelComponent sys_comp = m_sys.getPersistableComponent(); sys_comp.loadComponentAndChildren(new NullProgressMonitor()); CorePlugin.enableParseAllOnResourceChange(); TestingUtilities.allowJobCompletion(); while (!ResourcesPlugin.getWorkspace().getRoot().isSynchronized(IProject.DEPTH_INFINITE)) { ResourcesPlugin.getWorkspace() .getRoot() .refreshLocal(IProject.DEPTH_INFINITE, new NullProgressMonitor()); while (PlatformUI.getWorkbench().getDisplay().readAndDispatch()) ; } Ooaofooa.setPersistEnabled(true); delayGlobalUpgrade = false; initialized = true; } }
private void createActions() { expandAll = new ExpandAllAction(this); expandAll.setText("Expand All"); // $NON-NLS-1$ collapseAll = new CollapseAllAction(this); collapseAll.setText("Collapse All"); // $NON-NLS-1$ open = new Action(OPEN) { public void run() { handleOpen(); } }; open.setText("Open"); open.setToolTipText("Open this model Element"); cut = new ExplorerCutAction(this); copy = new ExplorerCopyAction(this); paste = new ExplorerPasteAction(); moveUp = new MoveUpAction(this); moveUp.setText("Move Up"); moveDown = new MoveDownAction(this); moveDown.setText("Move Down"); // Delete and Rename are retargetable actions defined by core. // // delete = new DeleteAction(CorePlugin.getImageDescriptor("delete_edit.gif")) { //$NON-NLS-1$ // // @Override // public void run() { // Transaction transaction = mergeViewer // .getCompareTransactionManager() // .startCompareTransaction(); // super.run(); // mergeViewer.getCompareTransactionManager().endTransaction( // transaction); // mergeViewer // .markLeftDirty(SynchronizedTreeViewer.this == mergeViewer // .getLeftViewer()); // mergeViewer // .markRightDirty(SynchronizedTreeViewer.this == mergeViewer // .getRightViewer()); // } // // }; // ((DeleteAction) delete).setStartTransaction(false); // rename = new RenameAction(this) { // // @Override // public void saveChangesAndDispose(Object selection) { // final Transaction transaction = mergeViewer // .getCompareTransactionManager() // .startCompareTransaction(); // super.saveChangesAndDispose(selection); // // need to wait on rename as it is asynchronously called // PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { // // @Override // public void run() { // mergeViewer.getCompareTransactionManager().endTransaction( // transaction); // mergeViewer // .markLeftDirty(SynchronizedTreeViewer.this == mergeViewer // .getLeftViewer()); // mergeViewer // .markRightDirty(SynchronizedTreeViewer.this == mergeViewer // .getRightViewer()); // } // }); // } // // }; // fileImport = CorePlugin.getResourceImportAction(); fileExport = CorePlugin.getResourceExportAction(); }