void release() { if (childRowToIdMap != null) { Collection delegates = childRowToIdMap.values(); Iterator iter = delegates.iterator(); while (iter.hasNext()) { SWTAccessibleDelegate childDelegate = ((Accessible) iter.next()).delegate; if (childDelegate != null) { childDelegate.internal_dispose_SWTAccessibleDelegate(); childDelegate.release(); } } childRowToIdMap.clear(); childRowToIdMap = null; } if (childColumnToIdMap != null) { Collection delegates = childColumnToIdMap.values(); Iterator iter = delegates.iterator(); while (iter.hasNext()) { SWTAccessibleDelegate childDelegate = ((Accessible) iter.next()).delegate; if (childDelegate != null) { childDelegate.internal_dispose_SWTAccessibleDelegate(); childDelegate.release(); } } childColumnToIdMap.clear(); childColumnToIdMap = null; } }
/** Set the focus to the editor containing {@link AttributeNames#QUERY}, if possible. */ @Override public boolean setFocus() { if (editors.containsKey(AttributeNames.QUERY)) { editors.get(AttributeNames.QUERY).setFocus(); return true; } else return false; }
void onValueChanged(String ov, String nv) { String[] vs = (String[]) propertiesHash.get(nv); if (vs == null) vs = new String[0]; String[] ovs = getSelectedProperties(); if (ov != null && ovs != null) propertiesHash.put(ov, ovs); setSelectedProperties(vs); propertyListEditor.updateBar(); }
void createCommand(String commandId, Map parameters) { if (commandId == null) { WorkbenchPlugin.log( "Unable to create menu item \"" + getId() //$NON-NLS-1$ + "\", no command id"); //$NON-NLS-1$ return; } Command cmd = commandService.getCommand(commandId); if (!cmd.isDefined()) { WorkbenchPlugin.log( "Unable to create menu item \"" + getId() //$NON-NLS-1$ + "\", command \"" + commandId + "\" not defined"); //$NON-NLS-1$ //$NON-NLS-2$ return; } if (parameters == null || parameters.size() == 0) { command = new ParameterizedCommand(cmd, null); return; } try { ArrayList parmList = new ArrayList(); Iterator i = parameters.entrySet().iterator(); while (i.hasNext()) { Map.Entry entry = (Map.Entry) i.next(); String parmName = (String) entry.getKey(); IParameter parm; parm = cmd.getParameter(parmName); if (parm == null) { WorkbenchPlugin.log( "Unable to create menu item \"" + getId() //$NON-NLS-1$ + "\", parameter \"" + parmName + "\" for command \"" //$NON-NLS-1$ //$NON-NLS-2$ + commandId + "\" is not defined"); //$NON-NLS-1$ return; } parmList.add(new Parameterization(parm, (String) entry.getValue())); } command = new ParameterizedCommand( cmd, (Parameterization[]) parmList.toArray(new Parameterization[parmList.size()])); } catch (NotDefinedException e) { // this shouldn't happen as we checked for !defined, but we // won't take the chance WorkbenchPlugin.log( "Failed to create menu item " //$NON-NLS-1$ + getId(), e); } }
protected void setComboBoxes() { // Something was changed in the row. // final Map<String, Integer> fields = new HashMap<String, Integer>(); // Add the currentMeta fields... fields.putAll(inputFields); Set<String> keySet = fields.keySet(); java.util.List<String> entries = new ArrayList<String>(keySet); String[] fieldNames = entries.toArray(new String[entries.size()]); Const.sortStrings(fieldNames); colinf[0].setComboValues(fieldNames); }
Accessible childRowToOs(int childID) { if (childID == ACC.CHILDID_SELF) { return tableAccessible; } /* Check cache for childID, if found, return corresponding osChildID. */ AccessibleTableRow childRef = (AccessibleTableRow) childRowToIdMap.get(Integer.valueOf(childID)); if (childRef == null) { childRef = new AccessibleTableRow(tableAccessible, childID); childRowToIdMap.put(Integer.valueOf(childID), childRef); } return childRef; }
/** @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object) */ public void applyData(Object data) { if (data instanceof Map) { fPageData = (Map) data; if (link != null && fPageData.containsKey(NO_LINK)) { link.setVisible(!Boolean.TRUE.equals(((Map) data).get(NO_LINK))); } } }
private void setButtonEnabled(String configKey, Button b, boolean enabled) { Boolean previousValue = oldBulkAPIDependencies.put(b, b.getSelection()); b.setSelection( enabled ? (previousValue != null ? previousValue : this.controller.getConfig().getBoolean(configKey)) : false); b.setEnabled(enabled); }
/** @return a map connecting IPath to the resolved bundles in that path */ private Map getFileBundleMapping() { if (fFileBundleMapping != null) { return fFileBundleMapping; } // Map the bundles into their file locations fFileBundleMapping = new HashMap(); for (Iterator iterator = fAllBundles.iterator(); iterator.hasNext(); ) { IResolvedBundle currentBundle = (IResolvedBundle) iterator.next(); IPath parentPath = getParentPath(currentBundle); List bundles = (List) fFileBundleMapping.get(parentPath); if (bundles == null) { bundles = new ArrayList(); bundles.add(currentBundle); fFileBundleMapping.put(parentPath, bundles); } else { bundles.add(currentBundle); } } return fFileBundleMapping; }
public AuthenticatorWindow() { SESecurityManager.addPasswordListener(this); // System.out.println( "AuthenticatorWindow"); Map cache = COConfigurationManager.getMapParameter(CONFIG_PARAM, new HashMap()); try { Iterator it = cache.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String key = (String) entry.getKey(); Map value = (Map) entry.getValue(); String user = new String((byte[]) value.get("user"), "UTF-8"); char[] pw = new String((byte[]) value.get("pw"), "UTF-8").toCharArray(); auth_cache.put(key, new authCache(key, new PasswordAuthentication(user, pw), true)); } } catch (Throwable e) { COConfigurationManager.setParameter(CONFIG_PARAM, new HashMap()); Debug.printStackTrace(e); } }
public void setAuthenticationOutcome( String realm, String protocol, String host, int port, boolean success) { try { this_mon.enter(); String tracker = protocol + "://" + host + ":" + port + "/"; String auth_key = realm + ":" + tracker; authCache cache = (authCache) auth_cache.get(auth_key); if (cache != null) { cache.setOutcome(success); } } finally { this_mon.exit(); } }
protected void saveAuthCache() { try { this_mon.enter(); HashMap map = new HashMap(); Iterator it = auth_cache.values().iterator(); while (it.hasNext()) { authCache value = (authCache) it.next(); if (value.isPersistent()) { try { HashMap entry_map = new HashMap(); entry_map.put("user", value.getAuth().getUserName().getBytes("UTF-8")); entry_map.put("pw", new String(value.getAuth().getPassword()).getBytes("UTF-8")); map.put(value.getKey(), entry_map); } catch (Throwable e) { Debug.printStackTrace(e); } } } COConfigurationManager.setParameter(CONFIG_PARAM, map); } finally { this_mon.exit(); } }
/** Sets the <code>key</code> editor's current value to <code>value</code>. */ public void setAttribute(String key, Object value) { final IAttributeEditor editor = editors.get(key); if (editor != null) { editor.setValue(value); } }
/** Create internal GUI. */ private void createComponents(Map<String, Object> currentValues) { /* * Sort alphabetically by label. */ final Locale locale = Locale.getDefault(); final Map<String, String> labels = Maps.newHashMap(); for (Map.Entry<String, AttributeDescriptor> entry : attributeDescriptors.entrySet()) { labels.put(entry.getKey(), getLabel(entry.getValue()).toLowerCase(locale)); } final Collator collator = Collator.getInstance(locale); final List<String> sortedKeys = Lists.newArrayList(labels.keySet()); Collections.sort( sortedKeys, new Comparator<String>() { public int compare(String a, String b) { return collator.compare(labels.get(a), labels.get(b)); } }); /* * Create editors and inquire about their layout needs. */ editors = Maps.newHashMap(); final Map<String, AttributeEditorInfo> editorInfos = Maps.newHashMap(); int maxColumns = 1; for (String key : sortedKeys) { final AttributeDescriptor descriptor = attributeDescriptors.get(key); IAttributeEditor editor = null; try { editor = EditorFactory.getEditorFor(this.componentClazz, descriptor); final AttributeEditorInfo info = editor.init(bindable, descriptor, globalEventsProvider, currentValues); editorInfos.put(key, info); maxColumns = Math.max(maxColumns, info.columns); } catch (EditorNotFoundException ex) { Utils.logError( "No editor for attribute: " + descriptor.key + " (class: " + descriptor.type + ")", false); /* * Skip editor. */ editor = null; } editors.put(key, editor); } /* * Prepare the layout for this editor. */ final GridLayout layout = GUIFactory.zeroMarginGridLayout(); layout.makeColumnsEqualWidth = false; layout.numColumns = maxColumns; this.setLayout(layout); /* * Create visual components for editors. */ final GridDataFactory labelFactory = GridDataFactory.fillDefaults().span(maxColumns, 1); boolean firstEditor = true; for (String key : sortedKeys) { final AttributeDescriptor descriptor = attributeDescriptors.get(key); final IAttributeEditor editor = editors.get(key); final AttributeEditorInfo editorInfo = editorInfos.get(key); if (editor == null) { // Skip attributes without the editor. continue; } final Object defaultValue; if (currentValues != null && currentValues.get(key) != null) { defaultValue = currentValues.get(key); } else { defaultValue = attributeDescriptors.get(key).defaultValue; } // Add label to editors that do not have it. if (!editorInfo.displaysOwnLabel) { final Label label = new Label(this, SWT.LEAD); final GridData gd = labelFactory.create(); if (!firstEditor) { gd.verticalIndent = SPACE_BEFORE_LABEL; } label.setLayoutData(gd); label.setText(getLabel(descriptor) + (descriptor.requiredAttribute ? " (required)" : "")); /* * Add validation overlay. */ addValidationOverlay(descriptor, editor, defaultValue, label); AttributeInfoTooltip.attach(label, descriptor); } // Add the editor, if available. editor.createEditor(this, maxColumns); // Set the default value for the editor. editor.setValue(defaultValue); editors.put(editor.getAttributeKey(), editor); /* * Forward events from this editor to all our listeners. */ editor.addAttributeListener(forwardListener); firstEditor = false; } }
public PasswordAuthentication getAuthentication( String realm, String protocol, String host, int port) { try { this_mon.enter(); String tracker = protocol + "://" + host + ":" + port + "/"; InetAddress bind_ip = NetworkAdmin.getSingleton().getSingleHomedServiceBindAddress(); String self_addr; // System.out.println( "auth req for " + realm + " - " + tracker ); if (bind_ip == null || bind_ip.isAnyLocalAddress()) { self_addr = "127.0.0.1"; } else { self_addr = bind_ip.getHostAddress(); } // when the tracker is connected to internally we don't want to prompt // for the password. Here we return a special user and the password hash // which is picked up in the tracker auth code - search for "<internal>"! // also include the tracker IP as well as for scrapes these can occur on // a raw torrent which hasn't been modified to point to localhost if (host.equals(self_addr) || host.equals(COConfigurationManager.getStringParameter("Tracker IP", ""))) { try { byte[] pw = COConfigurationManager.getByteParameter("Tracker Password", new byte[0]); String str_pw = new String(Base64.encode(pw)); return (new PasswordAuthentication("<internal>", str_pw.toCharArray())); } catch (Throwable e) { Debug.printStackTrace(e); } } String auth_key = realm + ":" + tracker; authCache cache = (authCache) auth_cache.get(auth_key); if (cache != null) { PasswordAuthentication auth = cache.getAuth(); if (auth != null) { return (auth); } } String[] res = getAuthenticationDialog(realm, tracker); if (res == null) { return (null); } else { PasswordAuthentication auth = new PasswordAuthentication(res[0], res[1].toCharArray()); boolean save_pw = res[2].equals("true"); boolean old_entry_existed = auth_cache.put(auth_key, new authCache(auth_key, auth, save_pw)) != null; if (save_pw || old_entry_existed) { saveAuthCache(); } return (auth); } } finally { this_mon.exit(); } }