List of usage examples for java.lang InternalError InternalError
public InternalError(Throwable cause)
From source file:org.apache.tajo.master.exec.DDLExecutor.java
public boolean execute(QueryContext queryContext, LogicalPlan plan) throws IOException, TajoException { LogicalNode root = ((LogicalRootNode) plan.getRootBlock().getRoot()).getChild(); switch (root.getType()) { case ALTER_TABLESPACE: AlterTablespaceNode alterTablespace = (AlterTablespaceNode) root; alterTablespace(context, queryContext, alterTablespace); return true; case CREATE_DATABASE: CreateDatabaseNode createDatabase = (CreateDatabaseNode) root; createDatabase(queryContext, createDatabase.getDatabaseName(), null, createDatabase.isIfNotExists()); return true; case DROP_DATABASE: DropDatabaseNode dropDatabaseNode = (DropDatabaseNode) root; dropDatabase(queryContext, dropDatabaseNode.getDatabaseName(), dropDatabaseNode.isIfExists()); return true; case CREATE_TABLE: CreateTableNode createTable = (CreateTableNode) root; createTableExecutor.create(queryContext, createTable, createTable.isIfNotExists()); return true; case DROP_TABLE: DropTableNode dropTable = (DropTableNode) root; dropTable(queryContext, dropTable.getTableName(), dropTable.isIfExists(), dropTable.isPurge()); return true; case TRUNCATE_TABLE: TruncateTableNode truncateTable = (TruncateTableNode) root; truncateTable(queryContext, truncateTable); return true; case ALTER_TABLE: AlterTableNode alterTable = (AlterTableNode) root; alterTable(context, queryContext, alterTable); return true; case CREATE_INDEX: CreateIndexNode createIndex = (CreateIndexNode) root; createIndex(queryContext, createIndex); return true; case DROP_INDEX: DropIndexNode dropIndexNode = (DropIndexNode) root; dropIndex(queryContext, dropIndexNode); return true; default:// w ww . ja v a2 s . c o m throw new InternalError("updateQuery cannot handle such query: \n" + root.toJson()); } }
From source file:com.clustercontrol.infra.view.action.CopyInfraModuleAction.java
@Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; }/*from w ww . j a va 2s . co m*/ // ??? this.viewPart = HandlerUtil.getActivePart(event); if (!(viewPart instanceof InfraModuleView)) { return null; } InfraModuleView infraModuleView = null; try { infraModuleView = (InfraModuleView) viewPart.getAdapter(InfraModuleView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (infraModuleView == null) { m_log.info("execute: infra module view is null"); return null; } StructuredSelection selection = null; if (infraModuleView.getComposite().getTableViewer().getSelection() instanceof StructuredSelection) { selection = (StructuredSelection) infraModuleView.getComposite().getTableViewer().getSelection(); } String moduleId = null; if (selection != null) { moduleId = (String) ((ArrayList<?>) selection.getFirstElement()) .get(GetInfraModuleTableDefine.MODULE_ID); } InfraManagementInfo info = null; String managerName = infraModuleView.getComposite().getManagerName(); String managementId = infraModuleView.getComposite().getManagementId(); try { InfraEndpointWrapper wrapper = InfraEndpointWrapper.getWrapper(managerName); info = wrapper.getInfraManagement(managementId); } catch (InvalidRole_Exception e) { // ??? MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.accesscontrol.16")); return null; } catch (HinemosUnknown_Exception | InvalidUserPass_Exception | NotifyNotFound_Exception | InfraManagementNotFound_Exception e) { m_log.debug("execute getInfraManagement, " + e.getMessage()); MessageDialog.openError(null, Messages.getString("failed"), HinemosMessage.replace(e.getMessage())); return null; } InfraModuleInfo module = null; if (info != null && info.getModuleList() != null) { for (InfraModuleInfo tmpModule : info.getModuleList()) { if (tmpModule.getModuleId().equals(moduleId)) { module = tmpModule; break; } } CommonDialog dialog = null; if (module != null) { if (module instanceof CommandModuleInfo) { dialog = new CommandModuleDialog(infraModuleView.getSite().getShell(), managerName, managementId, moduleId, PropertyDefineConstant.MODE_COPY); } else if (module instanceof FileTransferModuleInfo) { dialog = new FileTransferModuleDialog(infraModuleView.getSite().getShell(), managerName, managementId, moduleId, PropertyDefineConstant.MODE_COPY); } else { throw new InternalError("dialog is null"); } } if (dialog != null) dialog.open(); infraModuleView.update(managerName, managementId); } return null; }
From source file:com.commsen.apropos.core.PropertiesManager.java
/** * Adds new {@link PropertyPackage}. NOTE: The object passed is cloned internally. * //from w w w . j a v a 2s .co m * @param propertyPackage the {@link PropertyPackage} to be added. Can not be null. * @throws PropertiesException if package with that name already exists or if circular * parent/child relation is detected. * @throws IllegalArgumentException if <code>propertyPackage</code> is null */ public static synchronized void addPropertyPackage(PropertyPackage propertyPackage) throws PropertiesException { if (propertyPackage == null) throw new IllegalArgumentException("propertySet can not be null"); String key = propertyPackage.getName(); if (allPackages.containsKey(key)) throw new PropertiesException("Configuration called " + key + " already exists"); String parentPackageName = null; if (propertyPackage.getParent() != null) { parentPackageName = propertyPackage.getParent().getName(); propertyPackage.setParent(null); } PropertyPackage clonedPackage = null; try { clonedPackage = (PropertyPackage) propertyPackage.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.toString()); } clonedPackage.setParent(allPackages.get(parentPackageName)); allPackages.put(key, clonedPackage); if (clonedPackage.getParent() == null) { instance.rootPackages.add(clonedPackage); } // packages.add(propertyPackage); save(); }
From source file:com.clustercontrol.infra.view.action.ModifyInfraModuleAction.java
@Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; }//from w w w . ja va2 s. co m // ??? this.viewPart = HandlerUtil.getActivePart(event); if (!(viewPart instanceof InfraModuleView)) { return null; } InfraModuleView infraModuleView = null; try { infraModuleView = (InfraModuleView) viewPart.getAdapter(InfraModuleView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (infraModuleView == null) { m_log.info("execute: view is null"); return null; } StructuredSelection selection = null; String managerName = null; if (infraModuleView.getComposite().getTableViewer().getSelection() instanceof StructuredSelection) { selection = (StructuredSelection) infraModuleView.getComposite().getTableViewer().getSelection(); managerName = infraModuleView.getComposite().getManagerName(); } String moduleId = null; if (selection != null) { moduleId = (String) ((ArrayList<?>) selection.getFirstElement()) .get(GetInfraModuleTableDefine.MODULE_ID); } String managementId = infraModuleView.getComposite().getManagementId(); InfraManagementInfo info = null; try { InfraEndpointWrapper wrapper = InfraEndpointWrapper .getWrapper(infraModuleView.getComposite().getManagerName()); info = wrapper.getInfraManagement(infraModuleView.getComposite().getManagementId()); } catch (InvalidRole_Exception e) { // ??? MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.accesscontrol.16")); return null; } catch (HinemosUnknown_Exception | InvalidUserPass_Exception | NotifyNotFound_Exception | InfraManagementNotFound_Exception e) { m_log.debug("execute getInfraManagement, " + e.getMessage()); MessageDialog.openError(null, Messages.getString("failed"), HinemosMessage.replace(e.getMessage())); return null; } InfraModuleInfo module = null; if (info != null && info.getModuleList() != null) { for (InfraModuleInfo tmpModule : info.getModuleList()) { if (tmpModule.getModuleId().equals(moduleId)) { module = tmpModule; break; } } CommonDialog dialog = null; if (moduleId != null) { if (module instanceof CommandModuleInfo) { dialog = new CommandModuleDialog(infraModuleView.getSite().getShell(), managerName, managementId, moduleId, PropertyDefineConstant.MODE_MODIFY); } else if (module instanceof FileTransferModuleInfo) { dialog = new FileTransferModuleDialog(infraModuleView.getSite().getShell(), managerName, managementId, moduleId, PropertyDefineConstant.MODE_MODIFY); } else { throw new InternalError("dialog is null"); } } if (dialog != null) dialog.open(); infraModuleView.update(managerName, managementId); } return null; }
From source file:net.sf.firemox.xml.tbs.Tbs.java
/** * Converts the given tbs XML node to its binary form writing in the given * OutputStream./* ww w.java2 s. c o m*/ * * @see net.sf.firemox.token.IdTokens#PLAYER_REGISTER_SIZE * @see net.sf.firemox.stack.phasetype.PhaseType * @see net.sf.firemox.clickable.ability.SystemAbility * @see net.sf.firemox.tools.StatePicture * @param node * the XML card structure * @param out * output stream where the card structure will be saved * @return the amount of written action in the output. * @throws IOException * error during the writing. * @see net.sf.firemox.deckbuilder.MdbLoader#loadMDB(String, int) */ public final int buildMdb(Node node, OutputStream out) throws IOException { final FileOutputStream fileOut = (FileOutputStream) out; referencedTest = new HashMap<String, Node>(); referencedAbilities = new HashMap<String, Node>(); referencedActions = new HashMap<String, List<Node>>(); referencedAttachments = new HashMap<String, Node>(); referencedNonMacroActions = new HashSet<String>(); referencedNonMacroAttachments = new HashSet<String>(); macroActions = new Stack<List<Node>>(); resolveReferences = false; MToolKit.writeString(out, node.getAttribute("name")); System.out.println("Building " + node.getAttribute("name") + " rules..."); MToolKit.writeString(out, node.getAttribute("version")); MToolKit.writeString(out, node.getAttribute("author")); MToolKit.writeString(out, node.getAttribute("comment")); // Write database configuration final Node database = node.get("database-properties"); Map<String, IdPropertyType> properties = new HashMap<String, IdPropertyType>(); for (java.lang.Object obj : database) { if (obj instanceof Node) { Node nodePriv = (Node) obj; String propertyType = nodePriv.getAttribute("type"); IdPropertyType propertyId; if (propertyType == null || propertyType.equals(String.class.getName())) { if ("true".equalsIgnoreCase(nodePriv.getAttribute("translate"))) { propertyId = IdPropertyType.SIMPLE_TRANSLATABLE_PROPERTY; } else { propertyId = IdPropertyType.SIMPLE_PROPERTY; } } else if ("java.util.List".equals(propertyType)) { if ("true".equalsIgnoreCase(nodePriv.getAttribute("translate"))) { propertyId = IdPropertyType.COLLECTION_TRANSLATABLE_PROPERTY; } else { propertyId = IdPropertyType.COLLECTION_PROPERTY; } } else { throw new InternalError("Unknow property type '" + propertyType + "'"); } properties.put(nodePriv.getAttribute("name"), propertyId); } } out.write(properties.size()); for (Map.Entry<String, IdPropertyType> entry : properties.entrySet()) { entry.getValue().serialize(out); MToolKit.writeString(out, entry.getKey()); } MToolKit.writeString(out, node.getAttribute("art-url")); MToolKit.writeString(out, node.getAttribute("back-picture")); MToolKit.writeString(out, node.getAttribute("damage-picture")); MToolKit.writeString(out, (String) node.get("licence").get(0)); // Manas final Node manas = node.get("mana-symbols"); // Colored manas final Node colored = manas.get("colored"); MToolKit.writeString(out, colored.getAttribute("url")); MToolKit.writeString(out, colored.getAttribute("big-url")); for (java.lang.Object obj : colored) { if (obj instanceof Node) { Node nodePriv = (Node) obj; out.write(XmlTools.getValue(nodePriv.getAttribute("name"))); MToolKit.writeString(out, nodePriv.getAttribute("picture")); MToolKit.writeString(out, nodePriv.getAttribute("big-picture")); } } // Colorless manas final Node colorless = manas.get("colorless"); MToolKit.writeString(out, colorless.getAttribute("url")); MToolKit.writeString(out, colorless.getAttribute("big-url")); MToolKit.writeString(out, colorless.getAttribute("unknown")); out.write(colorless.getNbNodes()); for (java.lang.Object obj : colorless) { if (obj instanceof Node) { final Node nodePriv = (Node) obj; out.write(Integer.parseInt(nodePriv.getAttribute("amount"))); MToolKit.writeString(out, nodePriv.getAttribute("picture")); } } // Hybrid manas final Node hybrid = manas.get("hybrid"); MToolKit.writeString(out, hybrid.getAttribute("url")); for (Object obj : hybrid) { if (obj instanceof Node) { final Node nodePriv = (Node) obj; out.write(XmlTools.getValue(nodePriv.getAttribute("name"))); MToolKit.writeString(out, nodePriv.getAttribute("picture")); } } // phyrexian manas final Node phyrexian = manas.get("phyrexian"); MToolKit.writeString(out, phyrexian.getAttribute("url")); for (Object obj : phyrexian) { if (obj instanceof Node) { final Node nodePriv = (Node) obj; out.write(XmlTools.getValue(nodePriv.getAttribute("name"))); MToolKit.writeString(out, nodePriv.getAttribute("picture")); } } // Prepare the shortcut to card's bytes offset final long shortcutCardBytes = fileOut.getChannel().position(); MToolKit.writeInt24(out, 0); // Write the user defined deck constraints final Set<String> definedConstraints = new HashSet<String>(); final Node deckConstraintRoot = XmlTools.getExternalizableNode(node, "deck-constraints"); final List<Node> deckConstraints = deckConstraintRoot.getNodes("deck-constraint"); XmlTools.writeAttrOptions(deckConstraintRoot, "deckbuilder-min-property", out); XmlTools.writeAttrOptions(deckConstraintRoot, "deckbuilder-max-property", out); XmlTools.writeAttrOptions(deckConstraintRoot, "master", out); out.write(deckConstraints.size()); for (Node deckConstraint : deckConstraints) { // Write the constraint key name String deckName = deckConstraint.getAttribute("name"); MToolKit.writeString(out, deckName); // Write extend String extend = deckConstraint.getAttribute("extends"); MToolKit.writeString(out, extend); if (extend != null && extend.length() > 0 && !definedConstraints.contains(extend)) { throw new RuntimeException("'" + deckName + "' is supposed extending '" + extend + "' but has not been found. Note that declaration order is important."); } // Write the constraint XmlTools.defaultOnMeTag = false; XmlTest.getTest("test").buildMdb(deckConstraint, out); definedConstraints.add(deckName); } // END OF HEADER // additional zones final List<XmlParser.Node> additionalZones = node.get("layouts").get("zones").get("additional-zones") .getNodes("additional-zone"); out.write(additionalZones.size()); int zoneId = IdZones.FIRST_ADDITIONAL_ZONE; for (XmlParser.Node additionalZone : additionalZones) { final String zoneName = additionalZone.getAttribute("name"); if (zoneId > IdZones.LAST_ADDITIONAL_ZONE) { throw new RuntimeException( "Cannot add more additional-zone (" + zoneName + "), increase core limitation"); } XmlTools.zones.put(zoneName, zoneId++); MToolKit.writeString(out, zoneName); MToolKit.writeString(out, additionalZone.getAttribute("layout-class")); MToolKit.writeString(out, additionalZone.getAttribute("constraint-you")); MToolKit.writeString(out, additionalZone.getAttribute("constraint-opponent")); } // Initial zone id out.write(XmlTools.getZone(node.get("layouts").get("zones").getAttribute("default-zone"))); // the references final Node references = XmlTools.getExternalizableNode(node, "references"); // the tests references System.out.println("\tshared tests..."); XmlTools.defaultOnMeTag = true; final Node tests = references.get("tests"); if (tests == null) { out.write(0); } else { out.write(tests.getNbNodes()); for (java.lang.Object obj : tests) { if (obj instanceof Node) { String ref = ((Node) obj).getAttribute("reference-name").toString(); referencedTest.put(ref, (Node) obj); MToolKit.writeString(out, ref); for (java.lang.Object objTest : (Node) obj) { if (objTest instanceof Node) { final Node node1 = (Node) objTest; try { XmlTest.getTest(node1.getTag()).buildMdb(node1, out); } catch (Throwable ie) { XmlConfiguration.error("In referenced test '" + ref + "' : " + ie.getMessage() + ". Context=" + objTest); } break; } } } } } // the action references (not included into MDB) final Node actions = references.get("actions"); System.out.print("\tactions : references (inlined in MDB)"); if (actions != null) { for (java.lang.Object obj : actions) { if (obj instanceof Node) { final String ref = ((Node) obj).getAttribute("reference-name"); final String globalName = ((Node) obj).getAttribute("name"); // do not accept macro? if ("false".equals(((Node) obj).getAttribute("macro"))) { referencedNonMacroActions.add(ref); } final List<Node> actionList = new ArrayList<Node>(); boolean firstIsDone = false; for (java.lang.Object actionI : (Node) obj) { if (actionI instanceof Node) { final Node action = (Node) actionI; // add action to the action list and replace the name of // sub-actions if (action.getAttribute("name") == null) { if (globalName != null) { if (firstIsDone) { action.addAttribute(new XmlParser.Attribute("name", "%" + globalName)); } else { action.addAttribute(new XmlParser.Attribute("name", globalName)); firstIsDone = true; } } else if (firstIsDone) { action.addAttribute(new XmlParser.Attribute("name", "%" + ref)); } else { action.addAttribute(new XmlParser.Attribute("name", ref)); firstIsDone = true; } } else if (!firstIsDone) { firstIsDone = true; } actionList.add((Node) actionI); } } // add this reference referencedActions.put(ref, actionList); } } } // the attachment references (not included into MDB) final Node attachments = references.get("attachments"); System.out.print(", attachments"); if (attachments != null) { for (java.lang.Object obj : attachments) { if (obj instanceof Node) { final String ref = ((Node) obj).getAttribute("reference-name"); // do not accept macro? if ("false".equals(((Node) obj).getAttribute("macro"))) { referencedNonMacroAttachments.add(ref); } // add this reference referencedAttachments.put(ref, (Node) obj); } } } // action pictures final Node actionsPictures = node.get("action-pictures"); System.out.print(", pictures"); if (actionsPictures == null) { out.write(0); out.write('\0'); } else { MToolKit.writeString(out, actionsPictures.getAttribute("url")); out.write(actionsPictures.getNbNodes()); for (java.lang.Object obj : actionsPictures) { if (obj instanceof Node) { final Node actionPicture = (Node) obj; MToolKit.writeString(out, actionPicture.getAttribute("name")); MToolKit.writeString(out, actionPicture.getAttribute("picture")); } } } // constraints on abilities linked to action final Node constraints = node.get("action-constraints"); System.out.println(", constraints"); if (constraints == null) { out.write(0); } else { out.write(constraints.getNbNodes()); for (java.lang.Object obj : constraints) { if (obj instanceof Node) { final Node constraint = (Node) obj; for (java.lang.Object objA : constraint.get("actions")) { if (objA instanceof Node) { XmlAction.getAction(((Node) objA).getTag()).buildMdb((Node) objA, out); break; } } if ("or".equals(constraint.getAttribute("operation"))) { IdOperation.OR.serialize(out); } else { IdOperation.AND.serialize(out); } XmlTest.getTest("test").buildMdb(constraint.get("test"), out); } } } // objects defined in this TBS System.out.println("\tobjects..."); final List<Node> objects = node.get("objects").getNodes("object"); out.write(objects.size()); for (Node object : objects) { // write object final XmlParser.Attribute objectName = new XmlParser.Attribute("name", object.getAttribute("name")); boolean onePresent = false; for (java.lang.Object modifierTmp : object) { if (modifierTmp instanceof Node) { // write the 'has-next' flag if (onePresent) { out.write(1); } // write the object-modifier final Node modifier = (Node) modifierTmp; modifier.addAttribute(objectName); XmlModifier.getModifier(modifier.getTag()).buildMdb(modifier, out); // Write the 'paint' flag if (onePresent) { out.write(0); } else { out.write(1); } onePresent = true; } } if (!onePresent) { // no modifier associated to this object, we write a virtual ONE ModifierType.REGISTER_MODIFIER.serialize(out); XmlModifier.buildMdbModifier(object, out); // Write the modified register index && value XmlTools.writeConstant(out, 0); XmlTools.writeConstant(out, 0); IdOperation.ADD.serialize(out); // Write the 'paint' flag out.write(1); } // Write the 'has-next' flag out.write(0); } // the abilities references System.out.println("\tshared abilities..."); Node abilities = references.get("abilities"); out.write(abilities.getNbNodes()); macroActions.push(null); for (Node ability : abilities.getNodes("ability")) { String ref = ability.getAttribute("reference-name").toString(); referencedAbilities.put(ref, ability); MToolKit.writeString(out, ref); try { Node node1 = (Node) ability.get(1); XmlTbs.getTbsComponent(node1.getTag()).buildMdb(node1, out); } catch (Throwable ie) { XmlConfiguration.error("Error In referenced ability '" + ref + "' : " + ie.getMessage() + "," + ie + ". Context=" + ability); } } macroActions.pop(); // damage types name System.out.println("\tdamage types..."); Collections.sort(XmlConfiguration.EXPORTED_DAMAGE_TYPES); int count = XmlConfiguration.EXPORTED_DAMAGE_TYPES.size(); out.write(count); for (int i = 0; i < count; i++) { final PairStringInt pair = XmlConfiguration.EXPORTED_DAMAGE_TYPES.get(i); MToolKit.writeString(out, pair.text); MToolKit.writeInt16(out, pair.value); } /** * <ul> * CARD'S PART : * <li>state pictures * <li>tooltip filters * <li>exported types name * <li>exported sorted properties name * <li>implemented cards * </ul> */ // state pictures System.out.println("\tstates"); final Node states = node.get("state-pictures"); if (states == null) { out.write(0); } else { out.write(states.getNbNodes()); for (java.lang.Object obj : states) { if (obj instanceof Node) { final Node ns = (Node) obj; MToolKit.writeString(out, ns.getAttribute("picture")); MToolKit.writeString(out, ns.getAttribute("name")); MToolKit.writeInt16(out, XmlTools.getInt(ns.getAttribute("state"))); out.write(XmlTools.getInt(ns.getAttribute("index"))); final int x = XmlTools.getInt(ns.getAttribute("x")); final int y = XmlTools.getInt(ns.getAttribute("y")); if (MToolKit.getConstant(x) == -1 && MToolKit.getConstant(y) != -1 || MToolKit.getConstant(x) != -1 && MToolKit.getConstant(y) == -1) { XmlConfiguration.error( "In state-picture '-1' value is allowed if and only if x AND y have this value."); } MToolKit.writeInt16(out, XmlTools.getInt(ns.getAttribute("x"))); MToolKit.writeInt16(out, XmlTools.getInt(ns.getAttribute("y"))); MToolKit.writeInt16(out, XmlTools.getInt(ns.getAttribute("width"))); MToolKit.writeInt16(out, XmlTools.getInt(ns.getAttribute("height"))); XmlTest.getTest("test").buildMdb(node.get("display-test"), out); } } } // tooltip filters System.out.println("\ttooltip filters..."); final Node ttFilters = node.get("tooltip-filters"); XmlTools.defaultOnMeTag = false; if (ttFilters == null) { out.write(0); } else { out.write(ttFilters.getNbNodes()); for (java.lang.Object obj : ttFilters) { if (obj instanceof Node) { buildMdbTooltipFilter((Node) obj, out); } } } // exported types name System.out.println("\texported type..."); Collections.sort(XmlConfiguration.EXPORTED_TYPES); int nbTypes = XmlConfiguration.EXPORTED_TYPES.size(); out.write(nbTypes); for (int i = 0; i < nbTypes; i++) { final PairStringInt pair = XmlConfiguration.EXPORTED_TYPES.get(i); MToolKit.writeString(out, pair.text); MToolKit.writeInt16(out, pair.value); } // exported sorted properties name and associated pictures System.out.println("\tproperties..."); Collections.sort(XmlConfiguration.EXPORTED_PROPERTIES); final int nbProperties = XmlConfiguration.EXPORTED_PROPERTIES.size(); MToolKit.writeInt16(out, nbProperties); for (int i = 0; i < nbProperties; i++) { final PairStringInt pair = XmlConfiguration.EXPORTED_PROPERTIES.get(i); MToolKit.writeInt16(out, pair.value); MToolKit.writeString(out, pair.text); } MToolKit.writeInt16(out, XmlConfiguration.PROPERTY_PICTURES.size()); for (Map.Entry<Integer, String> entry : XmlConfiguration.PROPERTY_PICTURES.entrySet()) { MToolKit.writeInt16(out, entry.getKey()); MToolKit.writeString(out, entry.getValue()); } /** * <ul> * STACK MANAGER'S PART : * <li>first player registers * <li>second player registers * <li>abortion zone * </ul> */ // player registers System.out.println("\tinitial registers..."); Node registers = node.get("registers-first-player"); final byte[] registersBytes = new byte[IdTokens.PLAYER_REGISTER_SIZE]; if (registers != null) { final List<Node> list = registers.getNodes("register"); for (Node register : list) { registersBytes[XmlTools.getInt(register.getAttribute("index"))] = (byte) XmlTools .getInt(register.getAttribute("value")); } } out.write(registersBytes); registers = node.get("registers-second-player"); final byte[] registersBytes2 = new byte[IdTokens.PLAYER_REGISTER_SIZE]; if (registers != null) { final List<Node> list = registers.getNodes("register"); for (Node register : list) { registersBytes2[XmlTools.getInt(register.getAttribute("index"))] = (byte) XmlTools .getInt(register.getAttribute("value")); } } out.write(registersBytes2); /* * TODO abortion zone */ final Node refAbilities = node.get("abilities"); out.write(XmlTools.getZone(refAbilities.getAttribute("abortionzone"))); // additional costs System.out.println("\tadditional-costs..."); final List<Node> additionalCosts = node.get("additional-costs").getNodes("additional-cost"); out.write(additionalCosts.size()); for (Node additionalCost : additionalCosts) { XmlTest.getTest("test").buildMdb(additionalCost.get("test"), out); XmlTbs.writeActionList(additionalCost.get("cost"), out); } /** * <ul> * EVENT MANAGER'S PART : * <li>phases * <li>turn-structure * <li>first phase index * </ul> */ // phases System.out.println("\tphases..."); final Node phases = node.get("phases"); out.write(phases.getNbNodes()); for (java.lang.Object obj : phases) { if (obj instanceof Node) { buildMdbPhaseType((Node) obj, out); } } // turn structure final String list = phases.getAttribute("turn-structure"); System.out.println("\tturn structure..."); final String[] arrayid = list.split(" "); out.write(arrayid.length); for (String id : arrayid) { out.write(XmlTools.getAliasValue(id)); } // first phase index for first turn out.write(Integer.parseInt(phases.getAttribute("start"))); // state based abilities System.out.println("\trule abilities..."); out.write(refAbilities.getNbNodes()); for (java.lang.Object obj : refAbilities) { if (obj instanceof Node) { try { XmlTbs.getTbsComponent(((Node) obj).getTag()).buildMdb((Node) obj, out); } catch (Throwable ie) { XmlConfiguration.error("Error in system ability '" + ((Node) obj).getAttribute("name") + "' : " + ie.getMessage() + ". Context=" + obj); break; } } } // static-modifiers System.out.println("\tstatic-modifiers..."); final Node modifiers = node.get("static-modifiers"); if (modifiers == null) { out.write(0); } else { out.write(modifiers.getNbNodes()); for (java.lang.Object obj : modifiers) { if (obj instanceof Node) { XmlModifier.getModifier("static-modifier").buildMdb((Node) obj, out); } } } // layouts System.out.println("\tlayouts..."); final Node layouts = node.get("layouts"); // initialize task pane layout writeTaskPaneElement(layouts.get("common-panel").get("card-details").get("properties"), out); // Sector of play zone for layouts List<Node> sectors = layouts.get("zones").get("play").getNodes("sector"); out.write(sectors.size()); for (XmlParser.Node sector : sectors) { XmlTest.getTest("test").buildMdb(sector, out); MToolKit.writeString(out, sector.getAttribute("constraint")); } // Update the shortcut to the first bytes of cards final long cardBytesPosition = fileOut.getChannel().position(); fileOut.getChannel().position(shortcutCardBytes); MToolKit.writeInt24(out, (int) cardBytesPosition); fileOut.getChannel().position(cardBytesPosition); // cards bytes + names resolveReferences = true; System.out.println("Processing cards..."); String xmlFile = node.getAttribute("xmlFile"); try { final String baseName = FilenameUtils.getBaseName(xmlFile); XmlTbs.updateMdb(baseName, out); } catch (Throwable e2) { XmlConfiguration.error("Error found in cards parsing of rule '" + xmlFile + "' : " + e2.getMessage()); } System.out.println(node.getAttribute("name") + " rules finished"); return 0; }
From source file:com.clustercontrol.monitor.view.action.StatusOpenJobHistoryAction.java
@Override /*/*from www . j av a 2s .c o m*/ * (non-Javadoc) * * @see org.eclipse.core.commands.IHandler#execute */ public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; } IPerspectiveRegistry reg = PlatformUI.getWorkbench().getPerspectiveRegistry(); PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IPerspectiveDescriptor desc = reg .findPerspectiveWithId("com.clustercontrol.jobmanagement.ui.JobHistoryPerspective"); if (desc == null) { return null; } // ??? IWorkbenchPart viewPart = HandlerUtil.getActivePart(event); ScopeListBaseView statusView = null; try { statusView = (StatusView) viewPart.getAdapter(StatusView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (statusView == null) { m_log.info("execute: view is null"); return null; } StatusListComposite composite = (StatusListComposite) statusView.getListComposite(); StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection(); List<?> list = (ArrayList<?>) selection.getFirstElement(); if (list == null) { return null; } JobTreeItem item; //IDID? String monitorId = (String) list.get(GetStatusListTableDefine.MONITOR_ID); String managerName = (String) list.get(GetStatusListTableDefine.MANAGER_NAME); try { JobEndpointWrapper wrapper = JobEndpointWrapper.getWrapper(managerName); item = wrapper.getJobDetailList(monitorId); } catch (JobInfoNotFound_Exception e) { ClientSession.occupyDialog(); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.job.122")); ClientSession.freeDialog(); return null; } catch (Exception e) { m_log.warn("run() getJobDetailList, " + e.getMessage(), e); if (ClientSession.isDialogFree()) { ClientSession.occupyDialog(); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); ClientSession.freeDialog(); } return null; } IWorkbenchPage page = window.getActivePage(); //?? page.setPerspective(desc); //view?composite? JobHistoryView historyView = (JobHistoryView) page.findView(JobHistoryView.ID); if (historyView == null) throw new InternalError("historyView is null."); JobDetailView detailView = (JobDetailView) page.findView(JobDetailView.ID); if (detailView == null) throw new InternalError("detailView is null."); HistoryComposite historyCmp = historyView.getComposite(); //ID?ID? ArrayList<?> objList = (ArrayList<?>) historyCmp.getTableViewer().getInput(); if (objList == null || objList.size() == 0) { return null; } //ID?ID historyCmp.setSessionId(monitorId); DetailComposite detailCmp = detailView.getComposite(); JobTreeItem child = getChild(item); String jobId = child.getData().getId(); String jobunitId = child.getData().getJobunitId(); //?? detailCmp.setJobId(jobId); detailCmp.setSessionId(monitorId); //?? historyView.update(false); detailCmp.setItem(managerName, monitorId, jobunitId, item); return null; }
From source file:com.clustercontrol.winservice.dialog.WinServiceCreateDialog.java
/** * ????// w ww . ja v a 2 s .c om * * @param parent * ? */ @Override protected void customizeDialog(Composite parent) { super.customizeDialog(parent); // shell.setText(Messages.getString("dialog.winservice.create.modify")); // ???? Label label = null; // ???? GridData gridData = null; /* * ???? */ Group groupCheckRule = new Group(groupRule, SWT.NONE); WidgetTestUtil.setTestId(this, null, groupCheckRule); GridLayout layout = new GridLayout(1, true); layout.marginWidth = HALF_MARGIN; layout.marginHeight = HALF_MARGIN; layout.numColumns = BASIC_UNIT; groupCheckRule.setLayout(layout); gridData = new GridData(); gridData.horizontalSpan = BASIC_UNIT; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; groupCheckRule.setLayoutData(gridData); groupCheckRule.setText(Messages.getString("check.rule")); /* * */ // label = new Label(groupCheckRule, SWT.NONE); WidgetTestUtil.setTestId(this, "winservicename", label); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TITLE_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; label.setLayoutData(gridData); label.setText(Messages.getString("winservice.name") + " : "); // this.m_serviceName = new Text(groupCheckRule, SWT.BORDER | SWT.LEFT); WidgetTestUtil.setTestId(this, null, m_serviceName); gridData = new GridData(); gridData.horizontalSpan = WIDTH_TEXT_LONG; gridData.horizontalAlignment = GridData.FILL; gridData.grabExcessHorizontalSpace = true; this.m_serviceName.setLayoutData(gridData); this.m_serviceName.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent arg0) { update(); } }); // this.adjustDialog(); // ? MonitorInfo info = null; if (this.monitorId == null) { // ??? info = new MonitorInfo(); this.setInfoInitialValue(info); } else { // ???? try { MonitorSettingEndpointWrapper wrapper = MonitorSettingEndpointWrapper.getWrapper(getManagerName()); info = wrapper.getMonitor(this.monitorId); } catch (InvalidRole_Exception e) { // ?????? MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.accesscontrol.16")); throw new InternalError(e.getMessage()); } catch (Exception e) { // ? m_log.warn("customizeDialog(), " + HinemosMessage.replace(e.getMessage()), e); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); throw new InternalError(e.getMessage()); } } this.setInputData(info); }
From source file:net.sf.firemox.xml.XmlConfiguration.java
/** * Return the method name corresponding to the specified TAG. * //w w w.j a va 2s . c o m * @param tagName * @return the method name corresponding to the specified TAG. */ static XmlToMDB getXmlClass(String tagName, Map<String, XmlToMDB> instances, Class<?> nameSpaceCall) { if (!nameSpaceCall.getSimpleName().startsWith("Xml")) throw new InternalError("Caller should be an Xml class : " + nameSpaceCall); XmlToMDB nodeClass = instances.get(tagName); if (nodeClass != null) { return nodeClass; } String simpleClassName = StringUtils.capitalize(tagName.replaceAll("-", "")); String packageName = nameSpaceCall.getPackage().getName(); String namespace = nameSpaceCall.getSimpleName().substring(3).toLowerCase(); String className = packageName + "." + namespace + "." + simpleClassName; XmlToMDB result; try { result = (XmlToMDB) Class.forName(className).newInstance(); } catch (Throwable e) { Class<?> mdbClass = null; simpleClassName = WordUtils.capitalize(tagName.replaceAll("-", " ")).replaceAll(" ", ""); try { result = (XmlToMDB) Class.forName(packageName + "." + namespace + "." + simpleClassName) .newInstance(); } catch (Throwable e1) { try { className = StringUtils.chomp(packageName, ".xml") + "." + namespace + "." + simpleClassName; mdbClass = Class.forName(className); if (!mdbClass.isAnnotationPresent(XmlTestElement.class)) { result = (XmlToMDB) mdbClass.newInstance(); } else { result = getAnnotedBuilder(mdbClass, tagName, packageName, namespace); } } catch (Throwable ei2) { error("Unsupported " + namespace + " '" + tagName + "'"); result = DummyBuilder.instance(); } } } instances.put(tagName, result); return result; }
From source file:com.clustercontrol.monitor.view.action.EventOpenJobHistoryAction.java
@Override public Object execute(ExecutionEvent event) throws ExecutionException { this.window = HandlerUtil.getActiveWorkbenchWindow(event); // In case this action has been disposed if (null == this.window || !isEnabled()) { return null; }//from w w w . j av a 2 s . co m IPerspectiveRegistry reg = PlatformUI.getWorkbench().getPerspectiveRegistry(); PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IPerspectiveDescriptor desc = reg .findPerspectiveWithId("com.clustercontrol.jobmanagement.ui.JobHistoryPerspective"); if (desc == null) { return null; } // ??? this.viewPart = HandlerUtil.getActivePart(event); ScopeListBaseView eventView = null; try { eventView = (EventView) this.viewPart.getAdapter(EventView.class); } catch (Exception e) { m_log.info("execute " + e.getMessage()); return null; } if (eventView == null) { m_log.info("execute: view is null"); return null; } EventListComposite composite = (EventListComposite) eventView.getListComposite(); StructuredSelection selection = (StructuredSelection) composite.getTableViewer().getSelection(); List<?> list = (ArrayList<?>) selection.getFirstElement(); if (list == null) { return null; } JobTreeItem item; //IDID? String monitorId = (String) list.get(GetEventListTableDefine.MONITOR_ID); String managerName = (String) list.get(GetEventListTableDefine.MANAGER_NAME); try { JobEndpointWrapper wrapper = JobEndpointWrapper.getWrapper(managerName); item = wrapper.getJobDetailList(monitorId); } catch (JobInfoNotFound_Exception e) { ClientSession.occupyDialog(); MessageDialog.openInformation(null, Messages.getString("message"), Messages.getString("message.job.122")); ClientSession.freeDialog(); return null; } catch (Exception e) { m_log.warn("run() getJobDetailList, " + e.getMessage(), e); if (ClientSession.isDialogFree()) { ClientSession.occupyDialog(); MessageDialog.openError(null, Messages.getString("failed"), Messages.getString("message.hinemos.failure.unexpected") + ", " + HinemosMessage.replace(e.getMessage())); ClientSession.freeDialog(); } return null; } IWorkbenchPage page = window.getActivePage(); //?? page.setPerspective(desc); //view?composite? JobHistoryView historyView = (JobHistoryView) page.findView(JobHistoryView.ID); if (historyView == null) throw new InternalError("historyView is null."); JobDetailView detailView = (JobDetailView) page.findView(JobDetailView.ID); if (detailView == null) throw new InternalError("detailView is null."); HistoryComposite historyCmp = historyView.getComposite(); //ID?ID? ArrayList<?> objList = (ArrayList<?>) historyCmp.getTableViewer().getInput(); if (objList == null || objList.size() == 0) { return null; } //ID?ID historyCmp.setSessionId(monitorId); DetailComposite detailCmp = detailView.getComposite(); JobTreeItem child = getChild(item); child.getData().getType().equals(JobConstant.TYPE_JOB); String jobId = child.getData().getId(); String jobunitId = child.getData().getJobunitId(); detailCmp.setJobId(jobId); detailCmp.setSessionId(monitorId); //?? historyView.update(false); detailCmp.setItem(managerName, monitorId, jobunitId, item); return null; }
From source file:org.apache.hama.bsp.JobStatus.java
@Override public Object clone() { try {//www . ja va 2 s . c om return super.clone(); } catch (CloneNotSupportedException cnse) { throw new InternalError(cnse.toString()); } }