@FXML void loadSelectedPlaylist() { Playlist p = (Playlist) playlistsView.getSelectionModel().getSelectedItem(); if (p == null) return; tracksView.setPlaceholder(offlinePlaceHolder); Platform.runLater( () -> { List<Track> tracks = p.getTracks(); tracksView.getItems().clear(); for (int i = tracks.size() - 1; i >= 0; i--) { tracksView.getItems().add(tracks.get(i)); } if (findTrack) { Platform.runLater( () -> { tracksView.getSelectionModel().select(currentTrack); tracksView.scrollTo(currentTrack); tracksView.requestFocus(); findTrack = false; }); } else { if (tracksView.getItems().size() > 0) { tracksView.scrollTo(0); } } }); }
public static EventHandler<ActionEvent> getBrowseHandler( FXController controller, TextField filePath) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select a file to upload..."); return e -> { if (AESCTR.secretKey == null) { new Alert(Alert.AlertType.INFORMATION, "Please generate or choose a key", ButtonType.OK) .showAndWait(); return; } selectedFiles = fileChooser.showOpenMultipleDialog(null); if (selectedFiles != null) { controller.writeLog("Selected files: "); StringBuilder sb = new StringBuilder(1024); for (int i = 0; i < selectedFiles.size(); i++) { if (i == selectedFiles.size() - 1) { sb.append(selectedFiles.get(i).getAbsolutePath()); } else { sb.append(selectedFiles.get(i).getAbsolutePath() + ", "); } controller.writeLog(selectedFiles.get(i).getName()); } filePath.setText(sb.toString()); } }; }
// masuda$ // ChartEventListener @Override public void propertyChange(PropertyChangeEvent pce) { if (tableModel == null) { return; } ChartEventModel evt = (ChartEventModel) pce.getNewValue(); int sRow = -1; long ptPk = evt.getPtPk(); List<PatientModel> list = tableModel.getDataProvider(); // minagawa^ // ChartEventModel.EVENT eventType = evt.getEventType(); int eventType = evt.getEventType(); // minagawa$ switch (eventType) { case ChartEventModel.PVT_STATE: for (int row = 0; row < list.size(); ++row) { PatientModel pm = list.get(row); if (ptPk == pm.getId()) { sRow = row; pm.setOwnerUUID(evt.getOwnerUUID()); break; } } break; case ChartEventModel.PM_MERGE: for (int row = 0; row < list.size(); ++row) { PatientModel pm = list.get(row); if (ptPk == pm.getId()) { sRow = row; // pm = msg.getPatientModel(); list.set(row, evt.getPatientModel()); break; } } break; case ChartEventModel.PVT_MERGE: for (int row = 0; row < list.size(); ++row) { PatientModel pm = list.get(row); if (ptPk == pm.getId()) { sRow = row; // pm = msg.getPatientVisitModel().getPatientModel(); list.set(row, evt.getPatientVisitModel().getPatientModel()); break; } } break; default: break; } if (sRow != -1) { tableModel.fireTableRowsUpdated(sRow, sRow); } }
@Override public Object getValueAt(int row, int col) { if (col == 0) { return journals.get(row).name; } else { return journals.get(row).abbreviation; } }
public int compareTo(VersionNumber oth) { for (int i = 0; i < Math.min(digits.size(), oth.digits.size()); i++) { if (!digits.get(i).equals(oth.digits.get(i))) return oth.digits.get(i) - digits.get(i); } // All digits equal so far, and only one of the numbers has more digits. // The one with digits remaining is the newest one: return oth.digits.size() - digits.size(); }
@Override public void writeExternal(Element parentNode) throws WriteExternalException { for (int i = 0; i < myPatterns.size(); i++) { String pattern = myPatterns.get(i); String name = myNames.get(i); @NonNls Element element = new Element("pair"); parentNode.addContent(element); element.setAttribute("type", pattern); element.setAttribute("name", name); } }
public static String getInheritedAttribute( String name, DOMInput in, List<Map<String, String>> styles) { List<String> values = in.getInheritedAttribute(name); for (int i = values.size() - 1; i >= 0; i--) { if (values.get(i) != null) { return values.get(i); } if (styles.get(i) != null && styles.get(i).containsKey(name)) { return styles.get(i).get(name); } } return null; }
public Iterable<SearchPopupPane.SearchPopupItem> filter(String text) { List<String> commands = getCommandNameAndArguments(text); char[] nameChars = commands.get(0).toCharArray(); BitSet sets = getCharContainingIndexSet(nameChars); List<SearchPopupPane.SearchPopupItem> items = new ArrayList<>(sets.cardinality()); for (int i = sets.nextSetBit(0); i >= 0; i = sets.nextSetBit(i + 1)) { JavaCommandLineSource source = sources.get(i); if (match(source, nameChars)) { items.add(new JavaCommandLineSourceItem(source, commands, getIcon(source))); } } return items; }
public String nameByType(String type) { for (int i = 0; i < myPatterns.size(); i++) { String pattern = myPatterns.get(i); if (StringUtil.startsWithChar(pattern, '*')) { if (type.endsWith(pattern.substring(1))) { return myNames.get(i); } } else { if (type.equals(pattern)) { return myNames.get(i); } } } return null; }
/** * Read stream into array of strings. * * @param inputStream The InputStream for the file. */ protected void openInputStream(InputStream inputStream) { String textLine; // Collect input lines in an array list. List<String> lines = ListFactory.createNewList(); BufferedReader bufferedReader = null; try { bufferedReader = new BufferedReader(new UnicodeReader(inputStream, textFileEncoding)); while ((textLine = bufferedReader.readLine()) != null) { lines.add(textLine); } textFileLoaded = true; } catch (IOException e) { } finally { try { if (bufferedReader != null) bufferedReader.close(); } catch (Exception e) { } } // Convert array list to array of strings. textFileLines = new String[lines.size()]; for (int i = 0; i < lines.size(); i++) { textFileLines[i] = lines.get(i); } }
private void hideNestedTable(int level) { int n = nestedTableList.size(); for (int i = n - 1; i >= level; i--) { NestedTable ntable = nestedTableList.get(i); ntable.hide(); } }
public void ConnectToSmartCard() { try { TerminalFactory factory = TerminalFactory.getDefault(); List<CardTerminal> terminals = factory.terminals().list(); System.out.println("Terminals: " + terminals); // get the first terminal // CardTerminals.State. CardTerminal terminal = terminals.get(0); if (terminal.isCardPresent()) { JOptionPane.showMessageDialog(null, "Card is Present"); this.terminal = terminal; } else { JOptionPane.showMessageDialog(null, "Card is absent.Connnect it in 5 secs\nWaiting..."); terminal.waitForCardPresent(5000); JOptionPane.showMessageDialog(null, "Time is Up!\nBye!!!"); return; } // establish a connection with the card Card card = terminal.connect("*"); this.card1 = card; } catch (CardException ce) { } }
private static AttachingConnector getAttachingConnectorFor(String transport) { List acs = Bootstrap.virtualMachineManager().attachingConnectors(); AttachingConnector ac; int i, k = acs.size(); for (i = 0; i < k; i++) if ((ac = (AttachingConnector) acs.get(i)).transport().name().equals(transport)) return ac; return null; }
public Object getElementAt(int index) { TileScript event = data.get(index); String s = event.getClass().getSimpleName() + " [" + V1TileScript.toString(event) + "]"; if (s.length() > 75) { s = s.substring(0, 73) + "..."; } return s; }
public void setDataset(NetcdfFile ds) { this.ds = ds; NestedTable nt = nestedTableList.get(0); nt.table.setBeans(getVariableBeans(ds)); hideNestedTable(1); datasetTree.setFile(ds); }
/** Gets the GUI component for this pane. */ public JComponent getGUI() { if (cwp == null) { Object object = mWhiteBoard.get("device_definition"); Object ctx_obj = mWhiteBoard.get("context"); if (null != object && object instanceof ConfigDefinition && null != ctx_obj && ctx_obj instanceof ConfigContext) { mConfigContext = (ConfigContext) ctx_obj; ConfigDefinition def = (ConfigDefinition) object; String token = def.getToken(); // Create a temporary list of ConfigDefinitions to pass to factory. java.util.List def_list = new ArrayList(); def_list.add(def); // Initialize a ConfigElementFactory with the needed // ConfigDefinition. And create a new ConfigElement. ConfigElementFactory temp_factory = new ConfigElementFactory(def_list); mConfigElement = temp_factory.create("New " + token, def); List list = CustomEditorRegistry.findEditors(token); Color start_color = new Color(160, 160, 180); Object color = UIManager.get("window"); if (null != color && color instanceof Color) { start_color = (Color) color; } else { System.out.println("Could not get the desktop color from the UIManager."); } // XXX:This will be used after making findEditors -> findEditor // if(null != editor) if (null == list || list.size() == 0) { System.out.println("No CustomEditors registered for token: " + token); JScrollPane scroll_pane = new JScrollPane(); PropertySheet element_prop_sheet = PropertySheetFactory.instance() .makeSheet(mConfigContext, mConfigElement, start_color); scroll_pane.getViewport().removeAll(); scroll_pane.getViewport().add(element_prop_sheet, null); cwp = scroll_pane; } else if (null != list && list.size() > 0) { CustomEditor editor = (CustomEditor) list.get(0); cwp = (JComponent) editor.getPanel(); editor.setConfig(mConfigContext, mConfigElement); } } } // cwp.init(mWhiteBoard); return cwp; }
public void setUpList() { List substances = system.getSubstances(); int nSubs = substances.size(); // substances.length; Substance s; for (int i = 0; i < nSubs; i++) { s = (Substance) (substances.get(i)); substanceNames.addElement(s.getName()); } }
@Override public void setValueAt(Object object, int row, int col) { JournalEntry entry = journals.get(row); if (col == 0) { entry.name = (String) object; } else { entry.abbreviation = (String) object; } }
private static int getItemToSelect( LookupImpl lookup, List<LookupElement> items, boolean onExplicitAction, @Nullable LookupElement mostRelevant) { if (items.isEmpty() || lookup.getFocusDegree() == LookupImpl.FocusDegree.UNFOCUSED) { return 0; } if (lookup.isSelectionTouched() || !onExplicitAction) { final LookupElement lastSelection = lookup.getCurrentItem(); int old = ContainerUtil.indexOfIdentity(items, lastSelection); if (old >= 0) { return old; } Object selectedValue = ((LookupImpl) lookup).getList().getSelectedValue(); if (selectedValue instanceof EmptyLookupItem && ((EmptyLookupItem) selectedValue).isLoading()) { int index = ((LookupImpl) lookup).getList().getSelectedIndex(); if (index >= 0 && index < items.size()) { return index; } } for (int i = 0; i < items.size(); i++) { String invariant = PRESENTATION_INVARIANT.get(items.get(i)); if (invariant != null && invariant.equals(PRESENTATION_INVARIANT.get(lastSelection))) { return i; } } } String selectedText = lookup.getEditor().getSelectionModel().getSelectedText(); for (int i = 0; i < items.size(); i++) { LookupElement item = items.get(i); if (isPrefixItem(lookup, item, true) && !isLiveTemplate(item) || item.getLookupString().equals(selectedText)) { return i; } } return Math.max(0, ContainerUtil.indexOfIdentity(items, mostRelevant)); }
public Point getHighestLocation(int row, int col) { List<Point> neighbors = getNeighbors(row, col); Collections.shuffle(neighbors); Point highest = neighbors.get(0); for (Point p : neighbors) { if (tile[p.x][p.y].getPheromone() > tile[highest.x][highest.y].getPheromone()) { highest = p; } } return highest; }
@Nullable public String getHint(final QuickFix fix) { if (myQuickFixes != null) { final List<String> list = myQuickFixes.getKeysByValue(fix); if (list != null) { LOG.assertTrue(list.size() == 1); return list.get(0); } } return null; }
/** Get iterator over one image */ public LineIterator getLineIterator( ProgressHandle progh, EvStack stack, EvImage im, final String channel, final EvDecimal frame, final double z) { List<ROI> subRoi = getSubRoi(); if (imageInRange(channel, frame, z) && !subRoi.isEmpty()) { LineIterator li = subRoi.get(0).getLineIterator(progh, stack, im, channel, frame, z); for (int i = 1; i < subRoi.size(); i++) li = new ThisLineIterator( im, subRoi.get(i).getLineIterator(progh, stack, im, channel, frame, z), li, channel, frame, z); return li; } else return new EmptyLineIterator(); }
public String getPrefixByNamespace(String namespace) { final PsiElement parent = getParent(); BidirectionalMap<String, String> map = initNamespaceMaps(parent); if (map != null) { List<String> keysByValue = map.getKeysByValue(namespace); final String ns = keysByValue == null || keysByValue.isEmpty() ? null : keysByValue.get(0); if (ns != null) return ns; } if (parent instanceof XmlTag) return ((XmlTag) parent).getPrefixByNamespace(namespace); // The prefix 'xml' is by definition bound to the namespace name // http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared if (XmlUtil.XML_NAMESPACE_URI.equals(namespace)) return XML_NS_PREFIX; return null; }
@Nullable private String extractReturnType() { final String ARROW = "->"; final StructuredDocString structuredDocString = getStructuredDocString(); if (structuredDocString != null) { return structuredDocString.getReturnType(); } final String docString = getDocStringValue(); if (docString != null && docString.contains(ARROW)) { final List<String> lines = StringUtil.split(docString, "\n"); while (lines.size() > 0 && lines.get(0).trim().length() == 0) { lines.remove(0); } if (lines.size() > 1 && lines.get(1).trim().length() == 0) { String firstLine = lines.get(0); int pos = firstLine.lastIndexOf(ARROW); if (pos >= 0) { return firstLine.substring(pos + 2).trim(); } } } return null; }
private NestedTable setNestedTable(int level, Structure s) { NestedTable ntable; if (nestedTableList.size() < level + 1) { ntable = new NestedTable(level); nestedTableList.add(ntable); } else { ntable = nestedTableList.get(level); } if (s != null) // variables inside of records ntable.table.setBeans(getStructureVariables(s)); ntable.show(); return ntable; }
public void actionPerformed(ActionEvent e) { List<Resource> loadedDocuments; try { // get all the documents loaded in the system loadedDocuments = Gate.getCreoleRegister().getAllInstances("gate.Document"); } catch (GateException ge) { // gate.Document is not registered in creole.xml....what is!? throw new GateRuntimeException( "gate.Document is not registered in the creole register!\n" + "Something must be terribly wrong...take a vacation!"); } Vector<String> docNames = new Vector<String>(); for (Resource loadedDocument : new ArrayList<Resource>(loadedDocuments)) { if (corpus.contains(loadedDocument)) { loadedDocuments.remove(loadedDocument); } else { docNames.add(loadedDocument.getName()); } } JList docList = new JList(docNames); docList.getSelectionModel().setSelectionInterval(0, docNames.size() - 1); docList.setCellRenderer(renderer); final JOptionPane optionPane = new JOptionPane( new JScrollPane(docList), JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); final JDialog dialog = optionPane.createDialog(CorpusEditor.this, "Add document(s) to this corpus"); docList.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { optionPane.setValue(JOptionPane.OK_OPTION); dialog.dispose(); } } }); dialog.setVisible(true); if (optionPane.getValue().equals(JOptionPane.OK_OPTION)) { int[] selectedIndices = docList.getSelectedIndices(); for (int selectedIndice : selectedIndices) { corpus.add((Document) loadedDocuments.get(selectedIndice)); } } changeMessage(); }
private void okActionPerformed(java.awt.event.ActionEvent evt) { if (smtp.getText().trim().isEmpty()) { CommonFunctions.showErrorMessage(this, "You must enter a SMTP server."); return; } else if (smtpUsername.getText().trim().isEmpty()) { CommonFunctions.showErrorMessage(this, "You must enter the SMTP username."); return; } else { try { int port = Integer.parseInt(smtpPort.getText()); if (port <= 0) throw new NumberFormatException(); new InternetAddress(email.getText()).validate(); } catch (NumberFormatException e) { CommonFunctions.showErrorMessage(this, "You must enter a valid SMTP port."); return; } catch (AddressException e) { CommonFunctions.showErrorMessage(this, "You must enter a valid source email address."); return; } } retval = 0; List<Student> selectedStudents = new ArrayList(); for (int i = 0; i < studentsTbl.getRowCount(); i++) { if ((boolean) studentsTbl.getValueAt(i, 0)) { selectedStudents.add(students.get(studentsTbl.convertRowIndexToModel(i))); } } output = new Object[] { email.getText(), smtp.getText(), smtpPort.getText(), smtpUsername.getText(), new String(smtpPassword.getPassword()), selectedStudents }; setVisible(false); }
public void showColorButtons() { Color colors[] = {Color.RED, Color.BLACK, Color.WHITE, Color.GREEN, Color.YELLOW, Color.BLUE}; Insets in = this.getInsets(); this.input = new JTextField(); this.add(this.input); this.input.setBounds(100 + in.left, 36 + in.top, 200, 30); int arrayAmount = numberOfPlayersButtons.size(); for (int i = 0; i < numberOfPlayersButtons.size(); i++) { this.remove(numberOfPlayersButtons.get(i)); } numberOfPlayersButtons = null; arrayAmount = this.maxPlayersAmount; for (int i = 0; i < arrayAmount; i++) { JButton tempButton = new JButton(); colorButtons.add(tempButton); tempButton.setBackground(colors[i]); tempButton.setBorderPainted(false); tempButton.setOpaque(true); tempButton.setBounds(65 + i * 45 + in.left, 81 + in.top, 25, 25); tempButton.addActionListener(this.listener); this.add(tempButton); } Dimension size; size = label.getPreferredSize(); label.setBounds(65, 5 + in.top, size.width + 48, size.height); label.setText("Jogador 1, informe a sua cor e o seu nome:"); this.repaint(); }
private void setSelected(Variable v) { eventsOK = false; List<Variable> vchain = new ArrayList<Variable>(); vchain.add(v); Variable vp = v; while (vp.isMemberOfStructure()) { vp = vp.getParentStructure(); vchain.add(0, vp); // reverse } for (int i = 0; i < vchain.size(); i++) { vp = vchain.get(i); NestedTable ntable = setNestedTable(i, vp.getParentStructure()); ntable.setSelected(vp); } eventsOK = true; }
/** Fetches any styles that match the passed into arguments into <code>matches</code>. */ private void getMatchingStyles(java.util.List matches, JComponent c, Region id) { String idName = id.getLowerCaseName(); String cName = c.getName(); if (cName == null) { cName = ""; } for (int counter = _styles.size() - 1; counter >= 0; counter--) { StyleAssociation sa = _styles.get(counter); String path; if (sa.getID() == NAME) { path = cName; } else { path = idName; } if (sa.matches(path) && matches.indexOf(sa.getStyle()) == -1) { matches.add(sa.getStyle()); } } }