/** * Draws the GUI that allows a user to select assets to be updated. * * @return true if the user made a valid choice of assets to replace. * @throws PipelineException */ private boolean buildUpdateGUI() throws PipelineException { Box finalBox = new Box(BoxLayout.Y_AXIS); top = new Box(BoxLayout.Y_AXIS); JScrollPane scroll; { scroll = new JScrollPane(finalBox); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); Dimension size = new Dimension(sVSize + sVSize + sTSize + 52, 500); scroll.setMinimumSize(size); scroll.setPreferredSize(size); scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); } /* query the user */ diag = new JToolDialog("Propagate Asset", scroll, "Continue"); areas = mclient.getWorkingAreas(); { Box hbox = new Box(BoxLayout.X_AXIS); Component comps[] = UIFactory.createTitledPanels(); JPanel tpanel = (JPanel) comps[0]; JPanel vpanel = (JPanel) comps[1]; { userField = UIFactory.createTitledCollectionField( tpanel, "User:"******"The user whose area the node is being created in."); userField.setActionCommand("user"); userField.setSelected(PackageInfo.sUser); userField.addActionListener(this); } UIFactory.addVerticalSpacer(tpanel, vpanel, 3); { viewField = UIFactory.createTitledCollectionField( tpanel, "View:", sTSize, vpanel, areas.get(PackageInfo.sUser), diag, sVSize, "The working area to create the nodes in."); viewField.setActionCommand("wrap"); viewField.addActionListener(this); } UIFactory.addVerticalSpacer(tpanel, vpanel, 3); { toolsetField = UIFactory.createTitledCollectionField( tpanel, "Toolset:", sTSize, vpanel, mclient.getActiveToolsetNames(), diag, sVSize, "The toolset to set on all the nodes."); toolsetField.setSelected(mclient.getDefaultToolsetName()); toolsetField.setActionCommand("wrap"); toolsetField.addActionListener(this); } UIFactory.addVerticalSpacer(tpanel, vpanel, 3); w = new Wrapper( userField.getSelected(), viewField.getSelected(), toolsetField.getSelected(), mclient); charList = SonyConstants.getAssetList(w, project, AssetType.CHARACTER); setsList = SonyConstants.getAssetList(w, project, AssetType.SET); propsList = SonyConstants.getAssetList(w, project, AssetType.PROP); { projectField = UIFactory.createTitledCollectionField( tpanel, "Project:", sTSize, vpanel, Globals.getChildrenDirs(w, "/projects"), diag, sVSize, "All the projects in pipeline."); projectField.setActionCommand("proj"); projectField.addActionListener(this); } hbox.add(comps[2]); top.add(hbox); } { Box vbox = new Box(BoxLayout.Y_AXIS); Box hbox = new Box(BoxLayout.X_AXIS); JButton button = new JButton("Propagate Additional Asset"); button.setName("ValuePanelButton"); button.setRolloverEnabled(false); button.setFocusable(false); Dimension d = new Dimension(sVSize, 25); button.setPreferredSize(d); button.setMinimumSize(d); button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); vbox.add(Box.createRigidArea(new Dimension(0, 5))); hbox.add(button); hbox.add(Box.createRigidArea(new Dimension(4, 0))); vbox.add(hbox); vbox.add(Box.createRigidArea(new Dimension(0, 5))); button.setActionCommand("add"); button.addActionListener(this); top.add(vbox); } list = new Box(BoxLayout.Y_AXIS); test = new JDrawer("Propagate Additional Asset", list, false); top.add(test); list.add(assetChoiceBox()); finalBox.add(top); { JPanel spanel = new JPanel(); spanel.setName("Spacer"); spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7)); spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7)); finalBox.add(spanel); } diag.setVisible(true); if (diag.wasConfirmed()) { // get list of things to change. for (Component comp : list.getComponents()) { if (comp instanceof Box) { Box can = (Box) comp; JCollectionField oldOne = (JCollectionField) can.getComponent(2); JCollectionField newOne = (JCollectionField) can.getComponent(4); TreeMap<String, String> assetList = new TreeMap<String, String>(); assetList.putAll(charList); assetList.putAll(propsList); assetList.putAll(setsList); String key = assetList.get(oldOne.getSelected()) + lr; String value = assetList.get(newOne.getSelected()) + lr; if (!key.equals(value)) { potentialUpdates.add(key); pAssetManager.put(key, new AssetInfo(key, value)); } // System.err.println("bUG: "+pAssetManager.get(key).getHiLoResShots()); } } if (!pAssetManager.isEmpty()) return true; } return false; } // end buildReplacementGUI
/** @param args */ public static void main(String[] args) { String user = "******"; String view = "build"; String toolset = "csg_rev18"; MasterMgrClient client = new MasterMgrClient(); Wrapper w = null; String project = "lr"; try { w = new Wrapper(user, view, toolset, client); PluginMgrClient.init(); } catch (PipelineException e1) { e1.printStackTrace(); } String baseModel = "/projects/lr/assets/prop/asylianHelmet/asylianHelmet"; String finalizeMel = "/projects/lr/assets/tools/mel/finalize-character"; int pass = 3; LinkedList<String> toAdd = new LinkedList<String>(); for (int i = 2; i <= 10; i++) { toAdd.add("asylianHelmet" + i); } if (pass == 1) { try { SonyAsset baseAsset = SonyConstants.stringToAsset(w, baseModel); Globals.getNewest( w, baseAsset.finalScene, CheckOutMode.OverwriteAll, CheckOutMethod.AllFrozen); Globals.getNewest( w, baseAsset.lr_finalScene, CheckOutMode.OverwriteAll, CheckOutMethod.AllFrozen); AssetType baseType = baseAsset.assetType; for (String name : toAdd) { TreeSet<String> addedNodes = new TreeSet<String>(); try { SonyAsset as = new SonyAsset(project, name, baseType); log(as.texGroup + " : "); if (!Globals.doesNodeExists(w, as.texGroup)) { logLine("Building"); NodeMod mod = Globals.registerNode(w, as.texGroup, null, Plugins.editorKWrite(w)); addedNodes.add(as.texGroup); BaseAction act = Plugins.actionListSources(w); mod.setAction(act); doReqs(mod); client.modifyProperties(user, view, mod); } else logLine("Already Exists"); log(as.matScene + " : "); if (!Globals.doesNodeExists(w, as.matScene)) { logLine("Building"); NodeMod mod = Globals.registerNode(w, as.matScene, "ma", Plugins.editorMaya(w)); addedNodes.add(as.matScene); BaseAction act = Plugins.actionMayaReference(w); Globals.referenceNode(w, as.matScene, baseAsset.rigScene, act, REF, "rig"); client.link(user, view, as.matScene, as.texGroup, REF, LINKALL, null); mod.setAction(act); doReqs(mod); client.modifyProperties(user, view, mod); } else logLine("Already Exists"); log(as.finalScene + " : "); if (!Globals.doesNodeExists(w, as.finalScene)) { logLine("Building"); NodeMod mod = Globals.registerNode(w, as.finalScene, "ma", Plugins.editorMaya(w)); addedNodes.add(as.finalScene); BaseAction act = Plugins.actionMayaImport(w); Globals.referenceNode(w, as.finalScene, as.matScene, act, DEP, "mat"); client.link(user, view, as.finalScene, finalizeMel, DEP, LINKALL, null); act.setSingleParamValue("ModelMEL", finalizeMel); mod.setAction(act); doReqs(mod); client.modifyProperties(user, view, mod); } else logLine("Already Exists"); log(as.lr_matScene + " : "); if (!Globals.doesNodeExists(w, as.lr_matScene)) { logLine("Building"); NodeMod mod = Globals.registerNode(w, as.lr_matScene, "ma", Plugins.editorMaya(w)); addedNodes.add(as.lr_matScene); BaseAction act = Plugins.actionMayaReference(w); Globals.referenceNode(w, as.lr_matScene, baseAsset.lr_rigScene, act, REF, "rig"); mod.setAction(act); doReqs(mod); client.modifyProperties(user, view, mod); } else logLine("Already Exists"); log(as.lr_finalScene + " : "); if (!Globals.doesNodeExists(w, as.lr_finalScene)) { logLine("Building"); NodeMod mod = Globals.registerNode(w, as.lr_finalScene, "ma", Plugins.editorMaya(w)); addedNodes.add(as.lr_finalScene); BaseAction act = Plugins.actionMayaImport(w); Globals.referenceNode(w, as.lr_finalScene, as.lr_matScene, act, DEP, "mat"); client.link(user, view, as.lr_finalScene, finalizeMel, DEP, LINKALL, null); act.setSingleParamValue("ModelMEL", finalizeMel); mod.setAction(act); doReqs(mod); client.modifyProperties(user, view, mod); } else logLine("Already Exists"); try { client.submitJobs(user, view, as.finalScene, null); client.submitJobs(user, view, as.lr_finalScene, null); } catch (PipelineException ex) { ex.printStackTrace(); } } catch (PipelineException ex) { try { Globals.releaseNodes(w, addedNodes); } catch (PipelineException e) { e.printStackTrace(); } ex.printStackTrace(); return; } } } catch (PipelineException e) { e.printStackTrace(); } } else if (pass == 2) { for (String name : toAdd) { try { logLine(name); SonyAsset baseAsset = SonyConstants.stringToAsset(w, baseModel); AssetType baseType = baseAsset.assetType; SonyAsset as = new SonyAsset(project, name, baseType); Globals.disableAction(w, as.matScene); Globals.disableAction(w, as.lr_matScene); } catch (PipelineException e) { e.printStackTrace(); } } } else if (pass == 3) { for (String name : toAdd) { try { logLine(name); SonyAsset baseAsset = SonyConstants.stringToAsset(w, baseModel); AssetType baseType = baseAsset.assetType; SonyAsset as = new SonyAsset(project, name, baseType); NodeID nodeID = new NodeID(user, view, as.finalScene); client.checkIn( nodeID, "Inital model tree built by the BuildDerivedModels tool. Built off the " + baseModel + " model", VersionID.Level.Minor); nodeID = new NodeID(user, view, as.lr_finalScene); client.checkIn( nodeID, "Inital model tree built by the BuildDerivedModels tool. Built off the " + baseModel + " model", VersionID.Level.Minor); } catch (PipelineException e) { e.printStackTrace(); } } } }