private boolean findTarget() { // Guess, user selects an entry in the list on the left. // Find a comparable entry in the target list... boolean found = false; int sourceIndex = wSource.getSelectionIndex(); // Skip eventhing after the bracket... String sourceStr = wSource.getItem(sourceIndex).toUpperCase(); int indexOfBracket = sourceStr.indexOf(EnterMappingDialog.STRING_ORIGIN_SEPARATOR); String sourceString = sourceStr; if (indexOfBracket >= 0) { sourceString = sourceStr.substring(0, indexOfBracket); } int length = sourceString.length(); boolean first = true; while (!found && (length >= 2 || first)) { first = false; for (int i = 0; i < wTarget.getItemCount() && !found; i++) { if (wTarget.getItem(i).toUpperCase().indexOf(sourceString.substring(0, length)) >= 0) { wTarget.setSelection(i); found = true; } } length--; } return found; }
private void populateList(List list, IStatus status, int nesting) { if (!status.matches(MASK)) { return; } StringBuffer buffer = new StringBuffer(); for (int i = 0; i < nesting; i++) { buffer.append(NESTING_INDENT); } buffer.append(status.getMessage()); list.add(buffer.toString()); // Look for a nested core exception Throwable t = status.getException(); if (t instanceof CoreException) { CoreException ce = (CoreException) t; populateList(list, ce.getStatus(), nesting + 1); } else if (t != null) { // Include low-level exception message buffer = new StringBuffer(); for (int i = 0; i < nesting; i++) { buffer.append(NESTING_INDENT); } String message = t.getLocalizedMessage(); if (message == null) { message = t.toString(); } buffer.append(message); list.add(buffer.toString()); } IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { populateList(list, children[i], nesting + 1); } }
@Override protected void setSelectionToWidget(List in, boolean reveal) { if (reveal) { super.setSelectionToWidget(in, reveal); } else { if (in == null || in.size() == 0) { // clear selection list.deselectAll(); } else { int n = in.size(); int[] ixs = new int[n]; int count = 0; for (int i = 0; i < n; ++i) { Object el = in.get(i); int ix = getElementIndex(el); if (ix >= 0) { ixs[count++] = ix; } } if (count < n) { System.arraycopy(ixs, 0, ixs = new int[count], 0, count); } list.deselectAll(); list.select(ixs); } } }
public void widgetSelected(SelectionEvent e) { traceList.remove(traceList.getItemCount() - 1); for (IUndoListener listener : observer) { listener.notifyUndo(); } }
public Point computeSize(int wHint, int hHint, boolean changed) { checkWidget(); int width = 0, height = 0; String[] items = list.getItems(); int textWidth = 0; GC gc = new GC(text); int spacer = gc.stringExtent(" ").x; // $NON-NLS-1$ for (int i = 0; i < items.length; i++) { textWidth = Math.max(gc.stringExtent(items[i]).x, textWidth); } gc.dispose(); Point textSize = text.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed); Point arrowSize = arrow.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed); Point listSize = list.computeSize(wHint, SWT.DEFAULT, changed); int borderWidth = getBorderWidth(); if (icon == null) { height = Math.max(hHint, Math.max(textSize.y, arrowSize.y) + 2 * borderWidth); width = Math.max( wHint, Math.max(textWidth + 2 * spacer + arrowSize.x + 2 * borderWidth, listSize.x)); } else { Point iconSize = icon.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed); height = Math.max(hHint, Math.max(textSize.y, arrowSize.y) + 2 * borderWidth); width = Math.max( wHint, Math.max( textWidth + 2 * spacer + arrowSize.x + iconSize.x + 2 * borderWidth, listSize.x)); } return new Point(width, height); }
private void dropDown(boolean drop) { if (drop == isDropped()) return; if (!drop) { popup.setVisible(false); if (!isDisposed() && arrow.isFocusControl()) { text.setFocus(); } return; } if (getShell() != popup.getParent()) { String[] items = list.getItems(); int selectionIndex = list.getSelectionIndex(); list.removeListener(SWT.Dispose, listener); popup.dispose(); popup = null; list = null; createPopup(items, selectionIndex); } computeShowArea(); popup.setAlpha(popup.getFinalAlpha()); popup.setVisible(true); }
private void updateSelectionDependentActions() { int index = list.getSelectionIndex(); int size = list.getItemCount(); buttons[REMOVE].setEnabled(index >= 0); buttons[UP].setEnabled(size > 1 && index > 0); buttons[DOWN].setEnabled(size > 1 && index >= 0 && index < size - 1); }
public DatabaseMeta getTargetDatabase() { if (wTargetDB.getSelection().length == 1) { String targetDbName = wTargetDB.getSelection()[0]; return DatabaseMeta.findDatabase(databases, targetDbName); } return null; }
public DatabaseMeta getSourceDatabase() { if (wSourceDB.getSelection().length == 1) { String sourceDbName = wSourceDB.getSelection()[0]; return DatabaseMeta.findDatabase(databases, sourceDbName); } 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 List getListControl(Composite parent) { listControl = super.getListControl(parent); listControl.addMouseListener( new MouseListener() { public void mouseUp(MouseEvent arg0) { selectionChanged1(); } public void mouseDown(MouseEvent arg0) {} public void mouseDoubleClick(MouseEvent arg0) {} }); listControl.addKeyListener( new KeyListener() { public void keyReleased(KeyEvent event) { if (event.keyCode == 32) { storeDefault(); } selectionChanged1(); } public void keyPressed(KeyEvent arg0) {} }); return listControl; }
public void buildView(List<String> files) { this.files = files; display = new Display(); shell = new Shell(display); shell.setText("Ebook converter"); shell.setSize(300, 400); list = new org.eclipse.swt.widgets.List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); list.setBounds(40, 20, 220, 100); label = new Label(shell, SWT.BORDER); label.setBounds(60, 130, 160, 25); label.setText("Converted:"); listConverted = new org.eclipse.swt.widgets.List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); listConverted.setBounds(40, 170, 220, 100); updateList(); list.addListener(SWT.DefaultSelection, this); listConverted.addListener( SWT.DefaultSelection, new Listener() { public void handleEvent(Event event) { try { int i = listConverted.getSelectionIndices()[0]; System.err.println(i); Runtime.getRuntime().exec(pdfViewer + " " + listConverted.getItem(i)); } catch (IOException e) { e.printStackTrace(); } } }); }
void layout() { Rectangle rect = shell.getClientArea(); // String[] strings = new String[objects.length]; int width = 0; String[] items = list.getItems(); GC gc = new GC(list); for (int i = 0; i < objects.length; i++) { width = Math.max(width, gc.stringExtent(items[i]).x); } gc.dispose(); Point size1 = start.computeSize(SWT.DEFAULT, SWT.DEFAULT); Point size2 = stop.computeSize(SWT.DEFAULT, SWT.DEFAULT); Point size3 = check.computeSize(SWT.DEFAULT, SWT.DEFAULT); Point size4 = label.computeSize(SWT.DEFAULT, SWT.DEFAULT); width = Math.max(size1.x, Math.max(size2.x, Math.max(size3.x, width))); width = Math.max(64, Math.max(size4.x, list.computeSize(width, SWT.DEFAULT).x)); start.setBounds(0, 0, width, size1.y); stop.setBounds(0, size1.y, width, size2.y); check.setBounds(0, size1.y + size2.y, width, size3.y); label.setBounds(0, rect.height - size4.y, width, size4.y); int height = size1.y + size2.y + size3.y; list.setBounds(0, height, width, rect.height - height - size4.y); text.setBounds(width, 0, rect.width - width, rect.height); canvas.setBounds(width, 0, rect.width - width, rect.height); }
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 boolean findSource() { // Guess, user selects an entry in the list on the right. // Find a comparable entry in the source list... boolean found = false; int targetIndex = wTarget.getSelectionIndex(); // Skip eventhing after the bracket... String targetString = wTarget.getItem(targetIndex).toUpperCase(); int length = targetString.length(); boolean first = true; while (!found && (length >= 2 || first)) { first = false; for (int i = 0; i < wSource.getItemCount() && !found; i++) { if (wSource.getItem(i).toUpperCase().indexOf(targetString.substring(0, length)) >= 0) { wSource.setSelection(i); found = true; } } length--; } return found; }
public void addSelectedFilesToTargetList() { ISelection selection = sourceFileViewer.getSelection(); if (isValidSourceFileViewerSelection(selection)) { java.util.List list = null; if (selection instanceof IStructuredSelection) { list = ((IStructuredSelection) selection).toList(); if (list != null) { list = ((IStructuredSelection) selection).toList(); for (Iterator i = list.iterator(); i.hasNext(); ) { IResource resource = (IResource) i.next(); if (resource instanceof IFile) { // Check if its in the list. Don't add it if it is. String resourceName = resource.getFullPath().toString(); if (selectedListBox.indexOf(resourceName) == -1) selectedListBox.add(resourceName); } } setFiles(selectedListBox.getItems()); } setAddButtonEnabled(false); if (selectedListBox.getItemCount() > 0) { removeAllButton.setEnabled(true); if (isFileMandatory) setPageComplete(true); if (selectedListBox.getSelectionCount() > 0) setRemoveButtonEnabled(true); else setRemoveButtonEnabled(false); } } } }
private void populateVersions() { versions.add("v20080424"); // $NON-NLS-1$ versions.add("v20080516"); // $NON-NLS-1$ versions.add("v20080522"); // $NON-NLS-1$ versions.add("v20080705"); // $NON-NLS-1$ versions.setSelection(0); }
@Override protected Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(2, false); container.setLayout(gridLayout); // Initialize and populate list final List list = new List(container, SWT.NONE); list.setLayoutData(new GridData(SWT.FILL)); populateList(list); list.setSelection(0); list.setSize(10, 20); list.addSelectionListener(new SomeSelectionListener(list)); Composite selectorContainer = new Composite(container, SWT.NONE); selectorContainer.setLayout(new GridLayout(1, false)); // Add color editor Composite colorContainer = new Composite(selectorContainer, SWT.NONE); color = new ColorFieldEditor(SYNTAXCOLOR_COLOR + SYNTAXCOLOR_KEYWORD, "Color", colorContainer); // Create and add style group Group styleContainer = new Group(selectorContainer, SWT.NONE); styleContainer.setText("Style"); GridLayout gridLayout2 = new GridLayout(1, false); styleContainer.setLayout(gridLayout2); Composite styleBoldContainer = new Composite(styleContainer, SWT.NONE); Composite styleItalicContainer = new Composite(styleContainer, SWT.NONE); Composite styleUnderlineContainer = new Composite(styleContainer, SWT.NONE); Composite styleStrikethroughContainer = new Composite(styleContainer, SWT.NONE); styleBold = new BooleanFieldEditor(SYNTAXCOLOR_BOLD + SYNTAXCOLOR_KEYWORD, "Bold", styleBoldContainer); styleItalic = new BooleanFieldEditor( SYNTAXCOLOR_ITALIC + SYNTAXCOLOR_KEYWORD, "Italic", styleItalicContainer); styleUnderline = new BooleanFieldEditor( SYNTAXCOLOR_UNDERLINE + SYNTAXCOLOR_KEYWORD, "Underline", styleUnderlineContainer); styleStrikethrough = new BooleanFieldEditor( SYNTAXCOLOR_STRIKETHROUGH + SYNTAXCOLOR_KEYWORD, "Strike through", styleStrikethroughContainer); // Link editors with the default preferenceStore color.setPreferenceStore(getDefaultPreferenceStore()); styleBold.setPreferenceStore(getDefaultPreferenceStore()); styleItalic.setPreferenceStore(getDefaultPreferenceStore()); styleUnderline.setPreferenceStore(getDefaultPreferenceStore()); styleStrikethrough.setPreferenceStore(getDefaultPreferenceStore()); // Load values for keyword updateEditors(SYNTAXCOLOR_KEYWORD); return container; }
/** Populates the filter lists based on the _filteringKeys and the filter criteria. */ private void populateFilterLists() { if (filterMap != null && !filterMap.isEmpty() && filterList != null && filters != null) { filterList.removeAll(); filters.removeAll(); Set keySet = filterMap.keySet(); Iterator i = keySet.iterator(); if (_filtering == Filtering.AUTOMATIC_LITERAL) { // Set the values of the filtered and unfiltered string while (i.hasNext()) { String filterString = (String) i.next(); if (_filteringKeys.contains(filterString)) { filters.add(filterString); } else { filterList.add(filterString); } } } else { // Add all filter strings to the possible filter list while (i.hasNext()) { String filterString = (String) i.next(); filterList.add(filterString); } } } }
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 1; composite.setLayout(layout); setControl(composite); final List lst = new List(composite, SWT.BORDER); lst.setItems(names); lst.setLayoutData(new GridData(GridData.FILL_BOTH)); lst.addSelectionListener( new SelectionListener() { public void widgetSelected(SelectionEvent e) { int sel = lst.getSelectionIndex(); // recall that we are using TRANSLATED names! calculation = (CalculationEnum) EnumHelper.getEnumByTranslatedName(CalculationEnum.values(), names[sel]); } public void widgetDefaultSelected(SelectionEvent e) {} }); lst.setSelection(0); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(getControl(), "Jaspersoft.wizard"); // $NON-NLS-1$ }
public boolean checkIfFileInTarget(IFile fileToCheck) { String[] strings = selectedListBox.getItems(); int size = selectedListBox.getItemCount(); for (int i = 0; i < size; i++) { if (strings[i].compareTo(fileToCheck.getFullPath().toString()) == 0) return true; } return false; }
public void handleEvent(Event event) { String input; for (int i : list.getSelectionIndices()) { input = list.getItem(i).split(" ")[0]; getController().notifyEbookChanged(input); } }
public void addCurrentCourse(List list, String course) { if (list.getItem(0).equals("No Courses Selected")) { list.remove(0); list.add(course); } else { list.add(course); } }
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { List<String> selectedList = new ArrayList<String>(selectedConfigsList.getItemCount()); for (String item : selectedConfigsList.getItems()) { selectedList.add(item); } configuration.setAttribute(SELECTED_CONFIGURATION_LIST, selectedList); }
/** Notifies that the Remove button has been pressed. */ private void removePressed() { setPresentsDefaultValue(false); int index = list.getSelectionIndex(); if (index >= 0) { list.remove(index); selectionChanged(); } }
/** * 为List组件设置数据 * * @param list * @param data */ private void setListData(List list, Map<String, String> data) { list.removeAll(); if (data == null) { return; } for (Entry<String, String> entry : data.entrySet()) { list.add(entry.getKey()); } }
public void refreshLiteratureView() { LiteratureReviewController literatureReviewController = new LiteratureReviewController(); literatureReviews = literatureReviewController.findAllLiteratureReview(); list.removeAll(); for (LiteratureReview literatureReview : literatureReviews) { list.add(literatureReview.getTitle()); } }
public void UpdateExchangeList(java.util.List<Queue> QueueList) { queueList.removeAll(); for (int idx = 0; idx < QueueList.size(); ++idx) { String exchName = QueueList.get(idx).toString(); queueList.add(exchName); } }
@Override public void setPackageProductType(ProductType packageProductType) { this.packageProductType = packageProductType; this.packageProductTypeItem = null; productTypeItemList.clear(); productTypeGUIList.removeAll(); if (packageProductType != null) { String languageID = NLLocale.getDefault().getLanguage(); if (packageProductType.getInnerPriceConfig() != null) { productTypeItemList.add(new Item(false, true, packageProductType)); productTypeGUIList.add( packageProductType.getName().getText(languageID) + Messages.getString( "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.ProductTypeSelectorListImpl.packageProductType_base")); //$NON-NLS-1$ } // EventInnerProductInfo assemblyInnerProductInfo = // assemblyPackageProductInfo.getEventInnerProductInfo(); // if (!(assemblyInnerProductInfo.getPriceConfig() instanceof FormulaPriceConfig)) // throw new IllegalArgumentException("The PriceConfig of assemblyInnerProductInfo is not // an instance of FormulaPriceConfig!"); // // productTypeItemList.add(assemblyInnerProductInfo); // productTypeGUIList.add(assemblyInnerProductInfo.getPrimaryKey()); // TO DO i18n for (NestedProductTypeLocal nestedProductTypeLocal : packageProductType.getProductTypeLocal().getNestedProductTypeLocals()) { ProductType productType = nestedProductTypeLocal.getInnerProductTypeLocal().getProductType(); // if (assemblyInnerProductInfo == productInfo) // continue; productTypeItemList.add(new Item(false, false, productType)); productTypeGUIList.add( productType.getName().getText(languageID) + " [" + nestedProductTypeLocal.getQuantity() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } if (packageProductType.getPackagePriceConfig() != null) { packageProductTypeItem = new Item(true, false, packageProductType); productTypeItemList.add(packageProductTypeItem); productTypeGUIList.add( packageProductType.getName().getText(languageID) + Messages.getString( "org.nightlabs.jfire.trade.admin.ui.gridpriceconfig.ProductTypeSelectorListImpl.packageProductType_total")); //$NON-NLS-1$ } productTypeGUIList.select(0); } // if (assemblyPackageProductInfo != null) { fireSelectionChangedEvent(); }
protected void refreshValidState() { super.refreshValidState(); int defaultIndex = LocalizedPropertiesPlugin.getDefault() .getPreferenceStore() .getInt(PreferenceConstants.WILDCARD_PATH_DEFAULT_INDEX_PREFERENCES); listControl.setSelection(defaultIndex); listControl.showSelection(); defaultButton.setEnabled(false); }