@Override public void mouseClicked(MouseEvent e) { Component theChosenOne = e.getComponent(); System.out.println(theChosenOne.getName()); remove(portalPanel); GuideChangeSettings guidance = new GuideChangeSettings(theChosenOne.getName()); add(guidance); }
private void addComponentMsgContent(Component component, String prefix) { List<?> msgContentsNodes = getMsgContents(component.getMsgID()); System.out.println(prefix + " " + component.getName()); if (!component.getMsgContent().isEmpty()) { System.out.println(prefix + "\talready handled, return"); return; } for (Object o : msgContentsNodes) { Node node = (Node) o; String tagText = node.selectSingleNode("TagText").getText(); String reqd = node.selectSingleNode("Reqd").getText(); if (allFields.containsKey(tagText)) { ComponentField componentField = new ComponentField(allFields.get(tagText), reqd); component.addMsgContent(componentField); System.out.println(prefix + "\t " + allFields.get(tagText).getFieldName()); } else if (allComponents.containsKey(tagText)) { // Handle msgContents for the component in question first! addComponentMsgContent(allComponents.get(tagText), prefix + "\t"); ComponentComponent componentComponent = new ComponentComponent(allComponents.get(tagText), reqd); component.addMsgContent(componentComponent); System.out.println(prefix + "\t " + allComponents.get(tagText).getName()); } else { System.err.println("Could not find tagText: " + tagText); } } }
/** * Adds the platform to the folder on the given level. This method is recursive. If agent name is * not fitting the level, it will be added to the given composite. If it fitting for the level, * proper search will be done for sub-composite to insert the platform. * * @param folder Top composite. * @param level Wanted level. * @param platformIdent {@link PlatformIdent}. * @param agentStatusData {@link AgentStatusData}. * @param cmrRepositoryDefinition Repository agent is belonging to. */ private static void addToFolder( Composite folder, int level, PlatformIdent platformIdent, AgentStatusData agentStatusData, CmrRepositoryDefinition cmrRepositoryDefinition) { if (!accessibleForLevel(platformIdent.getAgentName(), level)) { // if name is not matching the level just add th leaf AgentLeaf agentLeaf = new AgentLeaf(platformIdent, agentStatusData, cmrRepositoryDefinition, level != 0); folder.addChild(agentLeaf); } else { // search for proper folder boolean folderExisting = false; String agentLevelName = getFolderNameFromAgent(platformIdent.getAgentName(), level); for (Component child : folder.getChildren()) { if (child instanceof Composite && ObjectUtils.equals(child.getName(), agentLevelName)) { addToFolder( (Composite) child, level + 1, platformIdent, agentStatusData, cmrRepositoryDefinition); folderExisting = true; } } // if not found create new one if (!folderExisting) { Composite newFolder = createFolder(agentLevelName); addToFolder(newFolder, level + 1, platformIdent, agentStatusData, cmrRepositoryDefinition); folder.addChild(newFolder); } } }
/** * method to negotiate draganddrop when mouse is pressed * * @param e */ public void mousePressed(MouseEvent e) { /** Set up click point and set ActivePanel */ Point p = e.getPoint(); System.out.println(p); if (!setActivePanel(p)) return; /** record where the initial click occurred */ OriP = activePanel; /** Check whether click was over an image label */ selectedComponent = getImageLabel(p); if (selectedComponent == null) return; /** Check whether click was over waste box */ if (selectedComponent.getName().equals("WasteBox")) return; /** * remove selected component from active panel add it to the glass panel set the offset and * original position */ Rectangle labelR = selectedComponent.getBounds(); Rectangle panelR = activePanel.getBounds(); // if(labelR.contains(p.x - panelR.x, p.y - panelR.y)) // { activePanel.remove(selectedComponent); selected = true; glassPanel.add(selectedComponent); offset.x = p.x - labelR.x - panelR.x; offset.y = p.y - labelR.y - panelR.y; dragging = true; Original = labelR.getLocation(); // } }
private Component buildComponentFromXml(MpiComponentType componentXml) { Component component = new Component(componentXml.getName()); if (componentXml.getDescription() != null) { component.setDescription(componentXml.getDescription()); } if (componentXml.getComponentType().intValue() == MpiComponentType.ComponentType.INT_BLOCKING) { component.setComponentType(ComponentType.BLOCKING); } else if (componentXml.getComponentType().intValue() == MpiComponentType.ComponentType.INT_MATCHING) { component.setComponentType(ComponentType.MATCHING); } else if (componentXml.getComponentType().intValue() == MpiComponentType.ComponentType.INT_FILELOADER) { component.setComponentType(ComponentType.FILELOADER); } log.debug( "Component configuration: " + component.getName() + " of type " + component.getComponentType()); for (int i = 0; i < componentXml.getExtensions().sizeOfExtensionArray(); i++) { ExtensionType extension = componentXml.getExtensions().getExtensionArray(i); log.debug("Extension definition is " + extension); component.addExtension( extension.getName(), extension.getImplementation(), getExtensionInterfaceTypeById(extension.getInterface())); } return component; }
/** * We generally draw lines to/from the <I>center</I> of components; this method finds the center * of the argument's enclosing rectangle * * @return Point at the center of <CODE>c</CODE> * @param c The component whose center point we wish to determine */ protected Point getCenterLocation(Component c) { Point p1 = new Point(); Point p2 = new Point(); // start with the relative location... c.getLocation(p1); // get to the middle of the fractionsLabel Dimension d = c.getSize(); p1.x += d.width / 2; p1.y += d.height / 2; Component parent = c.getParent(); // System.err.println("parent=" + parent); while (parent != null) { parent.getLocation(p2); p1.x += p2.x; p1.y += p2.y; if (STOP.equals(parent.getName())) break; parent = parent.getParent(); } return p1; }
public Component getComponent(String name) { for (Component component : listComponents()) { if (name.equals(component.getName())) { return component; } } return null; }
@Override public void actionPerformed(ActionEvent ev) { Component component = (Component) ev.getSource(); final String componentName = component.getName(); switch (componentName) { case SAVE_MENU_ITEM_NAME: case SAVE_AS_MENU_ITEM_NAME: boolean mustChooseFile = SAVE_AS_MENU_ITEM_NAME.equals(componentName); saveToDisk(mustChooseFile); break; case NEW_MENU_ITEM_NAME: case OPEN_MENU_ITEM_NAME: showSaveConfirmationIfNecessaryAndRun( "You have changes on your current document. Save before continuing?", componentName, new Runnable() { @Override public void run() { if (NEW_MENU_ITEM_NAME.equals(componentName)) { setSpreadsheet(new Spreadsheet()); setCurrentFile(null); } else { // open Path chosenFile = chooseFile(JFileChooser.OPEN_DIALOG); openSpreadsheet(chosenFile); } } }); break; case COPY_MENU_ITEM_NAME: Object displayValue = mCellDisplayValueManager.getDisplayValueOfCellAt(getSelectedCellLocation()); if (!"".equals(displayValue)) { Transferable contents = new StringSelection(displayValue.toString()); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, null); } break; case COPY_FORMULA_MENU_ITEM_NAME: String cellContent = mSpreadsheet.getCellContentAt(getSelectedCellLocation()); if (cellContent != null) { Transferable contents = new StringSelection(cellContent); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(contents, null); } break; case PASTE_MENU_ITEM_NAME: Transferable clipboard = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); CellLocation selectedLocation = getSelectedCellLocation(); try { Object transferData = clipboard.getTransferData(DataFlavor.stringFlavor); mTableModel.setValueAt( transferData.toString(), selectedLocation.getRow(), selectedLocation.getColumn()); } catch (UnsupportedFlavorException | IOException ex) { // we can only use the string flavor anyway, nothing we can do here } break; } }
private static void processElement( Object element, ClassLoader classLoader, Method putMethod, Object context, Method putByNameMethod) throws ClassNotFoundException, InstantiationException, InvocationTargetException, ConfigurationException, IllegalAccessException, IllegalArgumentException { if (element instanceof Component) { Component c = (Component) element; Class compClass = Class.forName(c.getClazz(), true, classLoader); String name = c.getName(); Object instance = compClass.newInstance(); for (Property p : c.getProperty()) { setPropertyOnComponent(instance, p.getName(), p.getValue()); log.log( Level.FINER, MessageNames.SET_PROPERTY_ON_COMPONENT, new Object[] {p.getName(), c.getClazz(), c.getName(), p.getValue()}); } if (name == null || name.trim().length() == 0) { putMethod.invoke(context, instance); } else { putByNameMethod.invoke(context, name, instance); } } else if (element instanceof Property) { Property p = (Property) element; putByNameMethod.invoke(context, p.getName(), p.getValue()); } else if (element instanceof DiscoveryContextType) { /* Just drop the element into the context under the appropriate name. */ DiscoveryContextType dct = (DiscoveryContextType) element; if (dct.getName() == null) { putByNameMethod.invoke(context, Strings.DEFAULT_DISCOVERY_CONTEXT, dct); } else { putByNameMethod.invoke(context, dct.getName(), dct); } } else { throw new ConfigurationException( MessageNames.UNSUPPORTED_ELEMENT, element.getClass().getName()); } }
public String getExtensionBeanNameFromComponent(Component component) { Component.Extension extension = component.getExtensionByExtensionInterface(ExtensionInterface.CONFIGURATION_LOADER); if (extension == null) { log.error( "Encountered a custom component with no configuration loader extension: " + component); throw new InitializationException( "Unable to load configuration for custom component " + component.getName()); } return extension.getImplementationKey(); }
private BlockingService processBlockingConfiguration(MpiConfigDocument configuration) { checkConfiguration(configuration); if (configuration.getMpiConfig().getBlockingConfigurationArray() == null) { return null; } int count = configuration.getMpiConfig().getBlockingConfigurationArray().length; BlockingService blockingService = null; for (int i = 0; i < count; i++) { BlockingConfigurationType obj = configuration.getMpiConfig().getBlockingConfigurationArray(i); if (obj == null) { log.warn("No blocking service configuration has been specified."); return null; } log.debug("Object is of type: " + obj.getDomNode().getNamespaceURI()); String namespaceUriStr = obj.getDomNode().getNamespaceURI(); URI namespaceURI = getNamespaceURI(namespaceUriStr); String resourcePath = generateComponentResourcePath(namespaceURI); Component component = loadAndRegisterComponentFromNamespaceUri(resourcePath); String configurationLoaderBean = getExtensionBeanNameFromComponent(component); ConfigurationLoader loader = (ConfigurationLoader) Context.getApplicationContext().getBean(configurationLoaderBean); loader.loadAndRegisterComponentConfiguration(this, obj); Component.Extension extension = component.getExtensionByExtensionInterface(ExtensionInterface.IMPLEMENTATION); if (extension == null) { log.error( "Encountered a custom blocking component with no implementation extension: " + component); throw new InitializationException( "Unable to locate an implementation component for custom blocking component " + component.getName()); } log.debug( "Registering implementation of blocking component named " + extension.getName() + " and implementation key " + extension.getImplementationKey()); blockingService = (BlockingService) Context.getApplicationContext().getBean(extension.getImplementationKey()); String entity = loader.getComponentEntity(); log.info("Registering blocking service " + blockingService + " for entity " + entity); Context.registerCustomBlockingService(entity, blockingService); } return blockingService; }
void canvasFocusLost(FocusEvent e) { if (isXEmbedActive() && !e.isTemporary()) { xembedLog.fine("Forwarding FOCUS_LOST"); int num = 0; if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.xembed.testing"))) { Component opp = e.getOppositeComponent(); try { num = Integer.parseInt(opp.getName()); } catch (NumberFormatException nfe) { } } xembed.sendMessage(xembed.handle, XEMBED_FOCUS_OUT, num, 0, 0); } }
/** * Using the name of a component in the format of a string returns the actual Component found in * the list of components of the Power Plant * * @param The name of a component. * @return The component specified by the given name. */ private Component getPowerPlantComponent(String currentCompName) { Component currentComponent = null; Iterator<Component> compIt; compIt = powrPlntComponents.iterator(); Component c = null; String cName = null; while (compIt.hasNext()) { c = compIt.next(); cName = c.getName(); if (cName.equals(currentCompName)) { currentComponent = c; } } return currentComponent; }
/** * @param request HTTP request * @param response HTTP response * @return rendered HTML output */ public String renderFragment(HttpRequest request, HttpResponse response) { String uriWithoutContextPath = request.getUriWithoutContextPath(); String uriPart = uriWithoutContextPath.substring(UriUtils.FRAGMENTS_URI_PREFIX.length()); String fragmentName = NameUtils.getFullyQualifiedName(rootComponent.getName(), uriPart); // When building the dependency tree, all fragments are accumulated into the rootComponent. Fragment fragment = lookup.getAllFragments().get(fragmentName); if (fragment == null) { throw new FragmentNotFoundException( "Requested fragment '" + fragmentName + "' does not exists."); } Model model = new MapModel(request.getQueryParams()); RequestLookup requestLookup = createRequestLookup(request, response); API api = new API(sessionRegistry, requestLookup); return fragment.render(model, lookup, requestLookup, api); }
/** * Calculate the temperature of the condenser, Temperature = old temp * ratio that pressure * increased or decreased by - the coolent flow rate * * @param oldPressure pressure before the last calculation of pressure. * @return The new temperature. */ protected double calculateTemp(double oldPressure) { // Temperature = old temp * pressure increase/decrease raito - coolent flow rate ArrayList<Component> inputs = super.getRecievesInputFrom(); Iterator<Component> it = inputs.iterator(); Component c = null; double totalCoolantFlowRate = 0; while (it.hasNext()) { c = it.next(); if (c.getName().contains("Coolant")) { totalCoolantFlowRate += c.getOutputFlowRate(); } } double ratio = pressure / oldPressure; return temperature * ratio - totalCoolantFlowRate; }
@Override protected double calculateOutputFlowRate() { // TODO Auto-generated method stub // Must distinguish between a pump that pumps steam in with a pump that pumps coolent round // (possibly by name of pump having collent or alike in) ArrayList<Component> outputs = super.getOutputsTo(); Iterator<Component> it = outputs.iterator(); Component c = null; double totalOPFL = 0; while (it.hasNext()) { c = it.next(); if (!c.getName().contains("Coolant")) { totalOPFL += c.getOutputFlowRate(); } } return totalOPFL; }
/** * Write the xml for a {@link Component}. * * @param component * @param contentHandler * @throws SAXException */ protected static void generateXML( final String namespace, final Component component, final ContentHandler contentHandler, final boolean isScrPrivateFile) throws SAXException { final AttributesImpl ai = new AttributesImpl(); IOUtils.addAttribute(ai, COMPONENT_ATTR_ENABLED, component.isEnabled()); IOUtils.addAttribute(ai, COMPONENT_ATTR_IMMEDIATE, component.isImmediate()); IOUtils.addAttribute(ai, COMPONENT_ATTR_NAME, component.getName()); IOUtils.addAttribute(ai, COMPONENT_ATTR_FACTORY, component.getFactory()); // attributes new in 1.1 if (NAMESPACE_URI_1_1.equals(namespace) || NAMESPACE_URI_1_1_FELIX.equals(namespace)) { IOUtils.addAttribute(ai, COMPONENT_ATTR_POLICY, component.getConfigurationPolicy()); IOUtils.addAttribute(ai, COMPONENT_ATTR_ACTIVATE, component.getActivate()); IOUtils.addAttribute(ai, COMPONENT_ATTR_DEACTIVATE, component.getDeactivate()); IOUtils.addAttribute(ai, COMPONENT_ATTR_MODIFIED, component.getModified()); } IOUtils.indent(contentHandler, 1); contentHandler.startElement( namespace, ComponentDescriptorIO.COMPONENT, ComponentDescriptorIO.COMPONENT_QNAME, ai); IOUtils.newline(contentHandler); generateXML(component.getImplementation(), contentHandler); if (component.getService() != null) { generateXML(component.getService(), contentHandler); } if (component.getProperties() != null) { for (final Property property : component.getProperties()) { generateXML(property, contentHandler, isScrPrivateFile); } } if (component.getReferences() != null) { for (final Reference reference : component.getReferences()) { generateXML(namespace, reference, contentHandler, isScrPrivateFile); } } IOUtils.indent(contentHandler, 1); contentHandler.endElement( namespace, ComponentDescriptorIO.COMPONENT, ComponentDescriptorIO.COMPONENT_QNAME); IOUtils.newline(contentHandler); }
/** * Calculates the pressure within the condenser Pressure = current pressure + input flow rate of * steam - output flow rate of water. * * @return The new pressure */ protected double calculatePressure() { // The pressure of the condenser is the current pressure + input flow of steam - output flow of // water. ArrayList<Component> inputs = super.getRecievesInputFrom(); Iterator<Component> it = inputs.iterator(); Component c = null; double totalInputFlowRate = 0; while (it.hasNext()) { c = it.next(); if (!(c.getName().contains("Coolant"))) { totalInputFlowRate += c.getOutputFlowRate(); } } if (temperature > 100) { return pressure + totalInputFlowRate - super.getOutputFlowRate(); } else { return (pressure - pressure / temperature) + totalInputFlowRate - super.getOutputFlowRate(); } }
private void processSingleBestRecordConfiguration(MpiConfigDocument configuration) { checkConfiguration(configuration); if (configuration.getMpiConfig().sizeOfSingleBestRecordArray() == 0) { log.warn("No single best record configuration has been specified."); return; } SingleBestRecordType obj = configuration.getMpiConfig().getSingleBestRecordArray(0); log.debug("Object is of type: " + obj.getDomNode().getNamespaceURI()); String namespaceUriStr = obj.getDomNode().getNamespaceURI(); URI namespaceURI = getNamespaceURI(namespaceUriStr); String resourcePath = generateComponentResourcePath(namespaceURI); Component component = loadAndRegisterComponentFromNamespaceUri(resourcePath); String configurationLoaderBean = getExtensionBeanNameFromComponent(component); ConfigurationLoader loader = (ConfigurationLoader) Context.getApplicationContext().getBean(configurationLoaderBean); loader.loadAndRegisterComponentConfiguration(this, obj); Component.Extension extension = component.getExtensionByExtensionInterface(ExtensionInterface.IMPLEMENTATION); if (extension == null) { log.error( "Encountered a custom single best record component with no implementation extension: " + component); throw new InitializationException( "Unable to locate an implementation component for custom single best record component " + component.getName()); } log.debug( "Registering implementation of single best record component named " + extension.getName() + " and implementation key " + extension.getImplementationKey()); SingleBestRecordService singleBestRecordService = (SingleBestRecordService) Context.getApplicationContext().getBean(extension.getImplementationKey()); Context.registerCustomSingleBestRecordService(singleBestRecordService); }
void createGraph(Component tier, InstanceGraph graph, Node root) { Node thisNode = null; if (root != null) { thisNode = graph.getNode(root.name); } else { thisNode = graph.addNode(tier.getName(), tier); } if (thisNode == null) return; if (root == null) root = thisNode; if (thisNode.mark) { return; } graph.mark(thisNode); for (Dependency rel : dependencies.get(tier)) { Node initiator = graph.addNode(rel.initiator); Node upstream = graph.addNode(rel.upstream); graph.addLink(initiator, upstream, rel); createGraph(rel.upstream, graph, upstream); } }
protected void handleComponentAction(Component c, ActionEvent event) { Container rootContainerAncestor = getRootAncestor(c); if (rootContainerAncestor == null) return; String rootContainerName = rootContainerAncestor.getName(); if (c.getParent().getLeadParent() != null) { c = c.getParent().getLeadParent(); } if (rootContainerName == null) return; if (rootContainerName.equals("Main")) { if ("TextArea".equals(c.getName())) { onMain_TextAreaAction(c, event); return; } if ("MultiButton".equals(c.getName())) { onMain_MultiButtonAction(c, event); return; } if ("Button".equals(c.getName())) { onMain_ButtonAction(c, event); return; } if ("MultiButton2".equals(c.getName())) { onMain_MultiButton2Action(c, event); return; } if ("MultiButton4".equals(c.getName())) { onMain_MultiButton4Action(c, event); return; } if ("MultiButton1".equals(c.getName())) { onMain_MultiButton1Action(c, event); return; } if ("MultiButton3".equals(c.getName())) { onMain_MultiButton3Action(c, event); return; } } }
/** * Returns the value to initialize the opacity property of the Component to. A Style should NOT * assume the opacity will remain this value, the developer may reset it or override it. * * @param context SynthContext identifying requestor * @return opaque Whether or not the JComponent is opaque. */ @Override public boolean isOpaque(SynthContext context) { Region region = context.getRegion(); if (region == Region.COMBO_BOX || region == Region.DESKTOP_PANE || region == Region.DESKTOP_ICON || region == Region.EDITOR_PANE || region == Region.FORMATTED_TEXT_FIELD || region == Region.INTERNAL_FRAME || region == Region.LIST || region == Region.MENU_BAR || region == Region.PANEL || region == Region.PASSWORD_FIELD || region == Region.POPUP_MENU || region == Region.PROGRESS_BAR || region == Region.ROOT_PANE || region == Region.SCROLL_PANE || region == Region.SPINNER || region == Region.SPLIT_PANE_DIVIDER || region == Region.TABLE || region == Region.TEXT_AREA || region == Region.TEXT_FIELD || region == Region.TEXT_PANE || region == Region.TOOL_BAR_DRAG_WINDOW || region == Region.TOOL_TIP || region == Region.TREE || region == Region.VIEWPORT) { return true; } Component c = context.getComponent(); String name = c.getName(); if (name == "ComboBox.renderer" || name == "ComboBox.listRenderer") { return true; } return false; }
@Override public String toString() { return component.getName() + "-" + name; }
// called by run and by adaptor after insertion of new components public void runComponent(Component c) { fMap.put(c.getName(), e.submit(c)); }
public Service add(Component component) { components.put(component.getName(), component); return this; }
public void addComponent(Component c) { pComps.put(c.getName(), c); }