/** * 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(); }
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); }
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); } } } }
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 String[] getAvailableProfiles() { String generator = config.getGenerator(); // case generator was initial set in properties page if (generator.equals("")) { generator = generatorText.getText(); } String[] profiles = util.getProfileNames(agx.getConfiguredProfiles(generator)); String[] usedProfiles = profilesList.getItems(); ArrayList<String> availableProfiles = new ArrayList<String>(0); for (int i = 0; i < profiles.length; i++) { String profile = profiles[i]; boolean skip = false; for (int j = 0; j < usedProfiles.length; j++) { if (profile.equals(usedProfiles[j])) { skip = true; } } if (!skip) { availableProfiles.add(profile); } } return availableProfiles.toArray(new String[] {}); }
/* * (non-) Method declared on FieldEditor. */ @Override protected void doStore() { String s = createList(list.getItems()); if (s != null) { getPreferenceStore().setValue(getPreferenceName(), s); } }
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); }
@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); }
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; }
private void guess() { // Guess the target for all the sources... for (int i = 0; i < sourceList.length; i++) { int idx = Const.indexOfString(sourceList[i], wSource.getItems()); if (idx >= 0) { wSource.select(idx); if (findTarget()) { add(); } } } }
@Override public boolean isValid(ILaunchConfiguration launchConfig) { if (selectedConfigsList.getItemCount() == 0) { setErrorMessage("At least one configuration should be selected"); return false; } for (String item : selectedConfigsList.getItems()) { if (!allConfigNames.contains((String) item)) { setErrorMessage("Configuration [" + item + "] is undefined"); return false; } } setErrorMessage(null); return super.isValid(launchConfig); }
public boolean performOk() { try { config.setTarget(targetText.getText()); config.setGenerator(generatorText.getText()); config.setProfiles(profilesList.getItems()); config.update(); agxInfoLabel.setText(agx.getInfo(generatorText.getText())); // URI modelUri = URI.createURI(resource.getLocation().toString()); // org.eclipse.uml2.uml.Package model = util.loadModel(modelUri); } catch (Exception e) { return false; } return true; }
private void updateFilteringKeysFromControls() { String[] theFilterStrings = filters.getItems(); if (theFilterStrings.length == 0) { _filtering = Filtering.NONE_LITERAL; _filteringKeys = Collections.EMPTY_LIST; } else { _filtering = Filtering.AUTOMATIC_LITERAL; if (_filteringKeys != null) { _filteringKeys = new ArrayList(); } for (int i = 0; i < theFilterStrings.length; i++) { _filteringKeys.add(theFilterStrings[i]); } } }
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_LEAKCHECK, leakCheckButton.getSelection()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_LEAKRES, leakResCombo.getText()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_SHOWREACH, showReachableButton.getSelection()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_FREELIST, freelistSpinner.getSelection()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_PARTIAL, partialLoadsButton.getSelection()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_UNDEF, undefValueButton.getSelection()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_GCCWORK, gccWorkaroundButton.getSelection()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_ALIGNMENT_BOOL, alignmentButton.getSelection()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_ALIGNMENT_VAL, alignmentSpinner.getSelection()); // VG >= 3.4.0 if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_4_0) >= 0) { configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_TRACKORIGINS, trackOriginsButton.getSelection()); } // VG >= 3.6.0 if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_6_0) >= 0) { configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_POSSIBLY_LOST_BOOL, showPossiblyLostButton.getSelection()); } configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_MALLOCFILL_BOOL, mallocFillButton.getSelection()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_MALLOCFILL_VAL, mallocFillText.getText()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_FREEFILL_BOOL, freeFillButton.getSelection()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_FREEFILL_VAL, freeFillText.getText()); configuration.setAttribute( MemcheckLaunchConstants.ATTR_MEMCHECK_IGNORE_RANGES, Arrays.asList(ignoreRangesList.getItems())); }
public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(LaunchConfigurationConstants.ATTR_TOOL, tool); configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, traceChildrenButton.getSelection()); configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_FREERES, runFreeresButton.getSelection()); configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_DEMANGLE, demangleButton.getSelection()); configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_NUMCALLERS, numCallersSpinner.getSelection()); configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_ERRLIMIT, errorLimitButton.getSelection()); configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_BELOWMAIN, showBelowMainButton.getSelection()); configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_MAXFRAME, maxStackFrameSpinner.getSelection()); configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_SUPPFILES, Arrays.asList(suppFileList.getItems())); // 3.4.0 specific if (valgrindVersion == null || valgrindVersion.compareTo(ValgrindLaunchPlugin.VER_3_4_0) >= 0) { configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_MAINSTACK_BOOL, mainStackSizeButton.getSelection()); configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_MAINSTACK, mainStackSizeSpinner.getSelection()); } // 3.6.0 specific if (valgrindVersion == null || valgrindVersion.compareTo(ValgrindLaunchPlugin.VER_3_6_0) >= 0) { configuration.setAttribute( LaunchConfigurationConstants.ATTR_GENERAL_DSYMUTIL, dSymUtilButton.getSelection()); } if (dynamicTab != null) { dynamicTab.performApply(configuration); } }
/** Check for updates and perform them */ public void run() { // Bandwidth bandwidth.setText("Bytes: " + bytesWritten + "/" + bytesRead); // Player list if (players != null) { if (!Arrays.equals(players, playerList.getItems())) playerList.setItems(players); } // Chat log String msg; while ((msg = messages.poll()) != null) { log.append(msg); } // Status bar if (status) statusBar.setText("Server started"); else statusBar.setText("Server stopped"); stopButton.setEnabled(status); startButton.setEnabled(!status); }
private boolean isGeneralValid() { String[] suppFiles = suppFileList.getItems(); boolean result = true; for (int i = 0; i < suppFiles.length && result; i++) { try { IPath suppfile = getPlugin().parseWSPath(suppFiles[i]); if (!suppfile.toFile().exists()) { setErrorMessage( NLS.bind( Messages.getString("ValgrindOptionsTab.suppressions_file_doesnt_exist"), suppFiles[i])); // $NON-NLS-1$ result = false; } } catch (CoreException e) { // should only occur if there's a cycle in variable substitution e.printStackTrace(); } } return result; }
/** * set a model to apply content to user interface. * * @param p a dynabeanfunction */ public void setModel(Object p) { dynaBeanFunction = ((DynaBeanFunction) ((TreeObject) p).getUserObject()); treeObject = (TreeObject) p; textName.setText(dynaBeanFunction.getName() == null ? "" : dynaBeanFunction.getName()); textProperty.setText(dynaBeanFunction == null ? "" : dynaBeanFunction.getPropertyName()); listMethods.removeAll(); listParameter.removeAll(); textClass.setData(dynaBeanFunction.getMethod().getDeclaringClass()); textClass.setText(dynaBeanFunction.getMethod().getDeclaringClass().toString()); setList(dynaBeanFunction.getMethod().getDeclaringClass()); String[] items = listMethods.getItems(); for (int i = 0; i < items.length; i++) { if (items[i].equals(dynaBeanFunction.getMethod().toString())) { listMethods.select(i); displayMethodDetails(dynaBeanFunction.getMethod()); break; } } }
void listEvent(Event event) { switch (event.type) { case SWT.Dispose: if (getShell() != popup.getParent()) { String[] items = list.getItems(); int selectionIndex = list.getSelectionIndex(); popup = null; list = null; createPopup(items, selectionIndex); } break; case SWT.FocusIn: { handleFocus(SWT.FocusIn); break; } case SWT.MouseUp: { if (event.button != 1) return; dropDown(false); break; } case SWT.Selection: { int index = list.getSelectionIndex(); if (index == -1) return; text.setText(list.getItem(index)); // text.selectAll (); list.setSelection(index); // list.forceFocus(); Event e = new Event(); e.time = event.time; e.stateMask = event.stateMask; e.doit = event.doit; notifyListeners(SWT.Selection, e); event.doit = e.doit; break; } case SWT.Traverse: { switch (event.detail) { case SWT.TRAVERSE_RETURN: case SWT.TRAVERSE_ESCAPE: case SWT.TRAVERSE_ARROW_PREVIOUS: case SWT.TRAVERSE_ARROW_NEXT: event.doit = false; break; } Event e = new Event(); e.time = event.time; e.detail = event.detail; e.doit = event.doit; e.character = event.character; e.keyCode = event.keyCode; notifyListeners(SWT.Traverse, e); event.doit = e.doit; event.detail = e.detail; break; } case SWT.KeyUp: { Event e = new Event(); e.time = event.time; e.character = event.character; e.keyCode = event.keyCode; e.stateMask = event.stateMask; notifyListeners(SWT.KeyUp, e); break; } case SWT.KeyDown: { if (event.character == SWT.ESC) { // Escape key cancels popup list dropDown(false); } if ((event.stateMask & SWT.ALT) != 0 && (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN)) { dropDown(false); } if (event.character == SWT.CR) { // Enter causes default selection dropDown(false); Event e = new Event(); e.time = event.time; e.stateMask = event.stateMask; notifyListeners(SWT.DefaultSelection, e); } // At this point the widget may have been disposed. // If so, do not continue. if (isDisposed()) break; Event e = new Event(); e.time = event.time; e.character = event.character; e.keyCode = event.keyCode; e.stateMask = event.stateMask; notifyListeners(SWT.KeyDown, e); break; } } }
public String[] getItems() { checkWidget(); return list.getItems(); }
/** * Checks whether this page is filtering it's contents. * * @return <code>true</code> if this page is filtering it's contents. */ boolean isFiltering() { return filterStrings == null ? false : (filters.getItems().length != 0); }
@Override protected void doStore() { // super.doStore(); storeDefault(); LocalizedPropertiesPlugin.setWildcardPaths(listControl.getItems()); }