public DatabaseMeta getTargetDatabase() { if (wTargetDB.getSelection().length == 1) { String targetDbName = wTargetDB.getSelection()[0]; return DatabaseMeta.findDatabase(databases, targetDbName); } return null; }
/* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ protected void okPressed() { okPressed = true; if (type == TYPE_SAVE) { if (nameText.getText() == null || nameText.getText().trim().length() == 0) { messageLabel.setText( Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text7")); // $NON-NLS-1$ messageLabel.redraw(); return; } else { this.nameToSave = nameText.getText(); } } else if (type == TYPE_LOAD) { if (this.selectedPath != null) { try { this.selectedText = getFileContents(this.selectedPath); } catch (Exception e) { messageLabel.setText(e.getMessage()); messageLabel.redraw(); return; } } else if (nameList.getSelection() == null || nameList.getSelection().length == 0) { messageLabel.setText( Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text8")); // $NON-NLS-1$ messageLabel.redraw(); return; } else { this.selectedText = QuickRExPlugin.getDefault().getTestTextByName(nameList.getSelection()[0]); } } this.close(); }
public DatabaseMeta getSourceDatabase() { if (wSourceDB.getSelection().length == 1) { String sourceDbName = wSourceDB.getSelection()[0]; return DatabaseMeta.findDatabase(databases, sourceDbName); } return null; }
/** * Handles the button pressed event on the filter criteria. Move the items between the lists based * on the selection and but button pressed. */ private void buttonPressed(int buttonId) { String[] items = {}; switch (buttonId) { case ADD_TO_ID: items = filterList.getSelection(); for (int i = 0; i < items.length; i++) { filters.add(items[i]); filterList.remove(items[i]); } addTo.setEnabled(false); break; case REMOVE_FROM_ID: items = filters.getSelection(); for (int i = 0; i < items.length; i++) { filterList.add(items[i]); filters.remove(items[i]); } removeFrom.setEnabled(false); break; case ADD_ALL_TO_ID: items = filterList.getItems(); for (int i = 0; i < items.length; i++) { filters.add(items[i]); filterList.remove(items[i]); } break; case REMOVE_ALL_FROM_ID: items = filters.getItems(); for (int i = 0; i < items.length; i++) { filters.remove(items[i]); filterList.add(items[i]); } break; } updateFilteringKeysFromControls(); if (pageType == CHILD_PAGE) { refreshList(); } else if (pageType == ROOT_PAGE) { PreferenceManager preferenceManager = ((SortFilterDialog) getContainer()).getPreferenceManager(); Iterator nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER).iterator(); while (nodes.hasNext()) { PreferenceNode node = (PreferenceNode) nodes.next(); SortFilterPage page = (SortFilterPage) node.getPage(); if (page == this) { continue; } if (Arrays.equals(filterStrings, page.getFilterList())) { page._filteringKeys = new ArrayList(_filteringKeys.size()); page._filteringKeys.addAll(_filteringKeys); page._filtering = _filtering; page.populateFilterLists(); page.refreshList(); page.updateApplyButton(); } } } updateApplyButton(); }
private void updateModel() { GuvWizardModel model = ((IGuvnorWizard) super.getWizard()).getModel(); String selected = null; if (repLocations.getSelection().length > 0) { selected = repLocations.getSelection()[0]; } if (selected != null) { model.setRepLocation(repLocations.getSelection()[0]); } }
private void deletePressed() { if (nameList.getSelection() == null || nameList.getSelection().length == 0) { messageLabel.setText( Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text5")); // $NON-NLS-1$ messageLabel.redraw(); return; } else { QuickRExPlugin.getDefault().deleteTestTextByName(nameList.getSelection()[0]); testTextField.setText(""); // $NON-NLS-1$ nameList.setItems(QuickRExPlugin.getDefault().getTestTextNames()); messageLabel.setText( Messages.getString("dialogs.OrganizeTestTextDialog.messageLabel.text6")); // $NON-NLS-1$ messageLabel.redraw(); } }
protected void onDeleteClicked() { if (selectedConfigsList.getSelectionCount() == 0) { return; } String[] selection = selectedConfigsList.getSelection(); StringBuilder b = new StringBuilder(); for (String item : selection) { if (b.length() > 0) { b.append(", "); } b.append(item); } int response = ask( "Are you shure you want to remove [" + b.toString() + "]?", "Removing launch configuration"); if (response != SWT.YES) { return; } selectedConfigsList.remove(selectedConfigsList.getSelectionIndices()); for (String item : selection) { if (allConfigNames.contains((String) item)) { availableConfigsCombo.add(item); } } updateButtonsState(); updateLaunchConfigurationDialog(); }
private void add() { if (wSource.getSelectionCount() == 1 && wTarget.getSelectionCount() == 1) { String sourceString = wSource.getSelection()[0]; String targetString = wTarget.getSelection()[0]; int srcIndex = Const.indexOfString(sourceString, sourceList); int tgtIndex = Const.indexOfString(targetString, targetList); if (srcIndex >= 0 && tgtIndex >= 0) { // New mapping: add it to the list... SourceToTargetMapping mapping = new SourceToTargetMapping(srcIndex, tgtIndex); mappings.add(mapping); refreshMappings(); } } }
/** @return the data for the selected template or null if not available. */ public TemplatePersistenceData getSelectedTemplate() { if (templateList != null && nameToTemplateData != null) { String[] sel = templateList.getSelection(); if (sel != null && sel.length > 0) { return nameToTemplateData.get(sel[0]); } } return null; }
private void delete() { String[] result = wResult.getSelection(); for (int i = 0; i < result.length; i++) { int idx = wResult.indexOf(result[i]); if (idx >= 0 && idx < mappings.size()) { mappings.remove(idx); } } refreshMappings(); }
/** * Moves the currently selected item up or down. * * @param up <code>true</code> if the item should move up, and <code>false</code> if it should * move down */ private void swap(boolean up) { setPresentsDefaultValue(false); int index = list.getSelectionIndex(); int target = up ? index - 1 : index + 1; if (index >= 0) { String[] selection = list.getSelection(); Assert.isTrue(selection.length == 1); list.remove(index); list.add(selection[0], target); list.setSelection(target); } selectionChanged(); }
private void ok() { if (wSelection.getSelectionCount() > 0) { selection = wSelection.getSelection()[0]; selectionNr = wSelection.getSelectionIndices()[0]; if (quickSearch) { for (int i = 0; i < choices.length; i++) { if (choices[i].equals(selection)) { selectionNr = i; } } } // We need to handle the indices properly. If a filter is applied, the wSelection will differ // from choices // So we have to get the current index from choices and store it in the indices String[] selections = wSelection.getSelection(); boolean found = false; indices = new int[selections.length]; for (int i = 0; i < selections.length; i++) { found = false; for (int j = 0; j < choices.length; j++) { if (selections[i].equals(choices[j])) { indices[i] = j; found = true; break; } } } if (!found) { indices = wSelection.getSelectionIndices(); } } else { selection = null; selectionNr = -1; indices = new int[0]; } dispose(); }
/** 编辑 */ private void edit() { String[] filters = customFilterList.getSelection(); if (filters.length > 0) { if (isChange()) { if (!MessageDialog.openConfirm(getShell(), "", "不保存当前内容吗?")) { return; } } String key = filters[0]; filterNameTxt.setText(key); String[] tempArray = XLFHandler.getCustomMatchFilterAdditionMap().get(key).get(0); if (tempArray[0].indexOf("and") != -1) { andBtn.setSelection(true); orBtn.setSelection(false); } else { andBtn.setSelection(false); orBtn.setSelection(true); } int check = Integer.parseInt(tempArray[1]); if (btnIsTagged != null) { if ((check & btnIsTaggedCheck) != 0) { btnIsTagged.setSelection(true); } else { btnIsTagged.setSelection(false); } } if (btnQT != null) { if ((check & btnQTCheck) != 0) { btnQT.setSelection(true); } else { btnQT.setSelection(false); } } if (btnPT != null) { if ((check & btnPTCheck) != 0) { btnPT.setSelection(true); } else { btnPT.setSelection(false); } } if (btnIsRemoveFromSrc != null) { if ((check & btnIsRemoveFromSrcCheck) != 0) { btnIsRemoveFromSrc.setSelection(true); } else { btnIsRemoveFromSrc.setSelection(false); } } for (Control ctl : conditionList) { if (!ctl.isDisposed()) { ctl.dispose(); } } conditionList.clear(); ArrayList<String[]> tmpList = XLFHandler.getCustomMatchFilterIndexMap().get(key); for (String[] tempIndex : tmpList) { String filterIndex = tempIndex[0]; DynaComposite dyna = new DynaComposite(dynaComp, SWT.NONE); dyna.getFilterName().select(Integer.parseInt(filterIndex)); dyna.getFilterName().notifyListeners(SWT.Selection, null); if ("0".equals(filterIndex)) { // 匹配率 dyna.getConditions().select(Integer.parseInt(tempIndex[1])); dyna.getValue().setText(tempIndex[2]); } else if ("1".equals(filterIndex)) { // 关键字 dyna.getConditions().select(Integer.parseInt(tempIndex[1])); dyna.getValue().setText(tempIndex[2]); } else if ("2".equals(filterIndex)) { // 来源 dyna.getValue().setText(tempIndex[1]); } dyna.getValue().setForeground(black); } scroll.setMinSize(dynaComp.computeSize(SWT.DEFAULT, SWT.DEFAULT)); dynaComp.layout(); } else { MessageDialog.openInformation(getShell(), "", "请选择一个自定义过滤器。"); } }
/** @return the key for the hashmap that is selected in the list */ private String getCurrentKey() throws Exception { return dataList.getSelection()[0].split(";")[0]; }