private void createUICategoryCombo(Composite parent) { int style = SWT.READ_ONLY | SWT.BORDER; fCategoryCombo = new Combo(parent, style); GridData data = new GridData(GridData.FILL_HORIZONTAL); fCategoryCombo.setLayoutData(data); fCategoryCombo.add(CSWizardMessages.RegisterCSWizardPage_none); fCategoryCombo.setText(CSWizardMessages.RegisterCSWizardPage_none); }
private void handleWidgetSelectedCategoryButton() { // Create a dialog allowing the user to input the category name NewCategoryNameDialog dialog = new NewCategoryNameDialog(PDEUserAssistanceUIPlugin.getActiveWorkbenchShell()); dialog.create(); dialog.getShell().setText(CSWizardMessages.RegisterCSWizardPage_descTooltip); if (dialog.open() == Window.OK) { String newCategoryName = dialog.getNameText(); if (PDETextHelper.isDefinedAfterTrim(newCategoryName)) { String trimmedText = newCategoryName.trim(); fCategoryCombo.add(trimmedText); fCategoryCombo.setText(trimmedText); fCategoryCombo.setFocus(); String id = generateCategoryID(trimmedText); fCategoryTrackerUtil.associate(id, trimmedText, CSCategoryTrackerUtil.F_TYPE_NEW_CATEGORY); } } }
/** * Process cheatsheet elements with a category attribute * * @param parentElement */ private void updateUICategoryComboAttribute(IPluginElement element) { // Get the category attribute IPluginAttribute categoryAttribute = element.getAttribute(F_CS_ELEMENT_CATEGORY); // Process the category attribute if ((categoryAttribute != null) && PDETextHelper.isDefined(categoryAttribute.getValue())) { String id = categoryAttribute.getValue(); // Check to see if the category ID has been defined if (fCategoryTrackerUtil.containsCategoryID(id)) { // Update the category combo selection String name = fCategoryTrackerUtil.getCategoryName(id); fCategoryCombo.setText(name); } else { // Add the category ID to the combo box (no assoicated name) // This can only happen if the category is defined outside of // the plug-in the cheat sheet is stored in fCategoryCombo.add(id); fCategoryCombo.setText(id); fCategoryTrackerUtil.associate(id, id, CSCategoryTrackerUtil.F_TYPE_OLD_CATEGORY); } } }
/** * Process category elements * * @param parentElement */ private void updateUICategoryComboElement(IPluginElement parentElement) { // Get the id attribute IPluginAttribute idAttribute = parentElement.getAttribute(ICompCSConstants.ATTRIBUTE_ID); // Get the name attribute IPluginAttribute nameAttribute = parentElement.getAttribute(ICompCSConstants.ATTRIBUTE_NAME); // Add the category to the combo box only if // (1) the category name is defined // (2) the category has not already been added to the combo box if ((nameAttribute != null) && PDETextHelper.isDefined(nameAttribute.getValue()) && (idAttribute != null) && PDETextHelper.isDefined(idAttribute.getValue()) && (fCategoryTrackerUtil.containsCategoryName(nameAttribute.getValue()) == false)) { // TODO: MP: LOW: CompCS: Reference translated value fCategoryCombo.add(nameAttribute.getValue()); // Assocate the category ID with the category name fCategoryTrackerUtil.associate( idAttribute.getValue(), nameAttribute.getValue(), CSCategoryTrackerUtil.F_TYPE_OLD_CATEGORY); } }