public static void performTransition( ActivityInstanceBean activityInstance, TransitionTarget transitionTarget, boolean complete) { ExecutionPlan plan = new ExecutionPlan(transitionTarget); plan.assertNoOtherActiveActivities(); ModelManager mm = ModelManagerFactory.getCurrent(); IActivity target = mm.findActivity(transitionTarget.getModelOid(), transitionTarget.getActivityRuntimeOid()); if (target == null) { throw new ObjectNotFoundException( BpmRuntimeError.MDL_UNKNOWN_ACTIVITY_IN_MODEL.raise( transitionTarget.getActivityRuntimeOid(), transitionTarget.getModelOid())); } BpmRuntimeEnvironment rtEnv = PropertyLayerProviderInterceptor.getCurrent(); ExecutionPlan oldPlan = rtEnv.getExecutionPlan(); try { rtEnv.setExecutionPlan(plan); if (complete) { ActivityInstanceUtils.complete(activityInstance, null, null, true); } else { long rootOid = plan.getRootActivityInstanceOid(); if (rootOid != activityInstance.getOID()) { activityInstance = ActivityInstanceUtils.lock(rootOid); } ActivityInstanceUtils.abortActivityInstance(activityInstance); } } finally { rtEnv.setExecutionPlan(oldPlan); } }
void delete(AnnotationSet annotationSet) { if (annotationSets.remove(annotationSet)) { // if the active set was deleted then we need to unselect it if (activeSet.isPresent() && activeSet.get().equals(annotationSet)) { activeSet = Optional.empty(); parent.postEvent(new ModelEvents.AnnotationSetSelected(this, Optional.empty())); } parent.postEvent(new ModelEvents.AnnotationSetDeleted(annotationSet)); } }
public synchronized void cleanUp(IProgressMonitor monitor) throws CoreException { DeltaProcessingState state = ModelManager.getModelManager().deltaState; HashMap roots = state.roots; // HashMap sourceAttachments = state.sourceAttachments; if (roots == null /* && sourceAttachments == null */) return; HashMap knownFolders = getFolders(); Iterator iterator = knownFolders.keySet().iterator(); while (iterator.hasNext()) { IPath path = (IPath) iterator.next(); if ((roots != null && !roots.containsKey(path)) /* * & (sourceAttachments != null && !sourceAttachments * .containsKey(path)) */ ) { IFolder folder = (IFolder) knownFolders.get(path); if (folder != null) folder.delete(true, monitor); } } IProject project = getExternalFoldersProject(); if (project.isAccessible() && project.members().length == 1 /* * remaining * member is * .project */) project.delete(true, monitor); }
/** * If modified, also modify the method {@link ModelManager#getDefaultOptionsNoInitialization()} */ @Override public void initializeDefaultPreferences() { // Get options names set HashSet<String> optionNames = ModelManager.getModelManager().optionNames; Map<String, String> defaultOptionsMap = new HashMap<String, String>(); // DLTKCore settings defaultOptionsMap.put(DLTKCore.CORE_INCOMPLETE_BUILDPATH, DLTKCore.ERROR); defaultOptionsMap.put(DLTKCore.CORE_CIRCULAR_BUILDPATH, DLTKCore.ERROR); defaultOptionsMap.put(DLTKCore.CORE_ENABLE_BUILDPATH_EXCLUSION_PATTERNS, DLTKCore.ENABLED); defaultOptionsMap.put(DLTKCore.INDEXER_ENABLED, DLTKCore.ENABLED); defaultOptionsMap.put(DLTKCore.BUILDER_ENABLED, DLTKCore.ENABLED); defaultOptionsMap.put(DLTKCore.CODEASSIST_CAMEL_CASE_MATCH, DLTKCore.ENABLED); // encoding setting comes from resource plug-in optionNames.add(DLTKCore.CORE_ENCODING); // project-specific options optionNames.add(DLTKCore.PROJECT_SOURCE_PARSER_ID); // Store default values to default preferences IEclipsePreferences defaultPreferences = new DefaultScope().getNode(DLTKCore.PLUGIN_ID); for (Map.Entry<String, String> entry : defaultOptionsMap.entrySet()) { String optionName = entry.getKey(); defaultPreferences.put(optionName, entry.getValue()); optionNames.add(optionName); } }
/** Creates a SearchableEnvironment on the given project */ public SearchableEnvironment(ScriptProject project, WorkingCopyOwner owner) throws ModelException { this( project, owner == null ? null : ModelManager.getModelManager().getWorkingCopies(owner, true)); // add primary WCs }
@Override public <E> E get(Class<E> type, String attrName, E defaultValue) { JsonNode json = data.get(attrName); if (json == null) { return defaultValue; } return model.readObject(type, json.traverse()); }
@Override public <E> E get(Class<E> type, String attrName) { JsonNode json = data.get(attrName); if (json == null) { throw new ConfigException("Attribute " + attrName + " is required but not set"); } return model.readObject(type, json.traverse()); }
@Override public DataSourceImpl set(String attrName, Object v) { if (v == null) { data.remove(attrName); } else { data.put(attrName, model.writeObjectAsJsonNode(v)); } return this; }
/** * Swaps the order of the two annotation sets. The two annotation sets must be distinct and must * be contained in this network view set, otherwise this method does nothing. */ public void swap(AnnotationSet first, AnnotationSet second) { int i1 = annotationSets.indexOf(first); int i2 = annotationSets.indexOf(second); if (i1 < 0 || i2 < 0 || i1 == i2) return; Collections.swap(annotationSets, i1, i2); parent.postEvent(new ModelEvents.NetworkViewSetChanged(this, Type.ANNOTATION_SET_ORDER)); }
/** * Get topics the user has subscribed to * * @return */ public ArrayList<EventTopic> getTopics() { ArrayList<EventTopic> result = new ArrayList<EventTopic>(); for (String sid : eventTopicIds) { EventTopic es = ModelManager.get().getTopicById(sid); if (es != null) { result.add(es); } } return result; }
AnnotationSet build(AnnotationSetBuilder builder) { AnnotationSet as = new AnnotationSet(this, builder); annotationSets.add(as); try { builder.getCallback().ifPresent(callback -> callback.accept(as)); } catch (Exception e) { e.printStackTrace(); } parent.postEvent(new ModelEvents.AnnotationSetAdded(as)); return as; }
public boolean refreshSourceFields() throws ModelException { if (jstType == null || !jstType.hasMixins()) { // only refresh types // with mixins return false; } ModelManager manager = ModelManager.getModelManager(); // mixin types maybe changed, refresh the member fields try { final String natureId = getNatureId(); final VjoSourceElementParser parser = (VjoSourceElementParser) getSourceElementParser(natureId); HashMap newElements = new HashMap(); JSSourceModuleElementInfo info = (JSSourceModuleElementInfo) createElementInfo(); final VjoSourceModuleStructureRequestor requestor = new VjoSourceModuleStructureRequestor(this, info, newElements); if (!isReadOnly()) { ((ISourceElementParserExtension) parser).setScriptProject(this.getScriptProject()); } parser.setRequestor(requestor); final AccumulatingProblemReporter problemReporter = getAccumulatingProblemReporter(); parser.setReporter(problemReporter); SourceParserUtil.parseSourceModule(this, parser); manager.putInfos(this, newElements); return true; } catch (CoreException e) { throw new ModelException(e); } }
public void factoryUnit(Unit u) { Graphics2D g2 = (Graphics2D) this.getGraphics(); g2.setColor(Color.BLACK); g2.fillRect(0, 0, getWidth(), getHeight()); if (u == null) return; g2.drawImage( ModelManager.getModel(u.getModelName()).getImage(u.getTeam()), 30, 15, 50, 50, this); g2.setColor(Color.LIGHT_GRAY); g2.setFont(new Font("Consolas", 0, 16)); g2.drawString(u.getName(), 100, 39); g2.drawString("Land Attack: " + (u.getLandAttack()), 170, 25); g2.drawString("Air Attack: " + (u.getAirAttack()), 170, 50); g2.drawString("Defense: " + u.getDefense(), 350, 25); g2.drawString("Speed: " + u.getShift(), 350, 50); }
/** * Sets the given AnnotationSet as the "selected" one. If null is passed then all AnnotationSets * will be unselected. * * <p>Note: Currently switching selection is not supported when the currently selected * AnnotationSet has collapsed clusters. It is the responsibility of the UI to expand all the * clusters before switching the AnnotationSet. * * <p>MKTODO: It would be better for the model to handle expanding the clusters, but for now we * will force the UI to do it. * * @throws IllegalStateException If the currently active AnnotationSet has collapsed clusters. */ public void select(AnnotationSet annotationSet) { if (annotationSet == null || annotationSets.contains(annotationSet)) { if (Optional.ofNullable(annotationSet).equals(activeSet)) { return; } if (activeSet.map(AnnotationSet::hasCollapsedCluster).orElse(false)) { throw new IllegalStateException("Current AnnotationSet has collapsed clusters"); } CyNetwork network = networkView.getModel(); activeSet = Optional.ofNullable(annotationSet); // ModelManager.handle(AboutToRemoveNodesEvent) only removes nodes from the active annotation // set. // When switching to a new annotation set we need to "fix" the clusters to remove any nodes // that // were deleted previously. // MKTODO: probably need to test for deleted nodes when serializing the model if (annotationSet != null) { Set<Cluster> clusters = annotationSet.getClusters(); for (Cluster cluster : new HashSet<>( clusters)) { // avoid ConcurrentModificationException because removeNodes() can call // delete() Set<CyNode> nodesToRemove = cluster .getNodes() .stream() .filter(node -> !network.containsNode(node)) .collect(Collectors.toSet()); // Fires ClusterChangedEvent, UI listeners should test if the cluster is part of the // active annotation set. if (!nodesToRemove.isEmpty()) { cluster.removeNodes(nodesToRemove); } } } parent.postEvent(new ModelEvents.AnnotationSetSelected(this, activeSet)); } }
public ISourceModule[] getSourceModules(WorkingCopyOwner owner) { ISourceModule[] workingCopies = ModelManager.getModelManager().getWorkingCopies(owner, false /* don't add primary */); if (workingCopies == null) return ModelManager.NO_WORKING_COPY; int length = workingCopies.length; ISourceModule[] result = new ISourceModule[length]; int index = 0; for (int i = 0; i < length; i++) { ISourceModule wc = workingCopies[i]; IResource res = wc.getResource(); boolean valid; if (res != null) valid = Util.isValidSourceModule(this, res); else valid = Util.isValidSourceModule(this, wc.getPath()); if (equals(wc.getParent()) && !Util.isExcluded(wc) && valid) { result[index++] = wc; } } if (index != length) { System.arraycopy(result, 0, result = new ISourceModule[index], 0, index); } return result; }
public void paintComponent(Graphics g) { super.paintComponent(g); this.setBackground(Color.black); Graphics2D g2 = (Graphics2D) g; g2.setFont(new Font("Consolas", 0, 24)); g2.setColor(Color.LIGHT_GRAY); Location loc = LocationManager.getLoc(cursor); if (!loc.isEmpty()) { g2.drawImage( ModelManager.getModel(loc.getUnit().getModelName()).getImage(loc.getUnit().getTeam()), 30, 15, 50, 50, this); g2.drawString(loc.getUnit().getName() + " x" + loc.getUnit().getHealth(), 90, 50); g2.drawString("Exp: " + loc.getUnit().getExp(), 250, 50); } if (loc.getTerrain() != -1) { g2.drawString("Terrain: " + loc.getTerrain() + "%", 500, 50); } }
public AnnotationSet createAnnotationSet(String name, String labelColumn) { AnnotationSet as = new AnnotationSet(this, name, labelColumn); annotationSets.add(as); parent.postEvent(new ModelEvents.AnnotationSetAdded(as)); return as; }
@Override public <T> T loadTask(Class<T> taskType) { return model.readObject(taskType, data.traverse()); }
@Override public <T> T loadConfig(Class<T> taskType) { return model.readObjectWithConfigSerDe(taskType, data.traverse()); }
public boolean isSelected() { return parent.isNetworkViewSetSelected(this); }