List of usage examples for java.awt List contains
public boolean contains(Point p)
From source file:lu.lippmann.cdb.ext.hydviga.ui.SimilarCasesFrame.java
private JXTable buidJXTable(final Instances cases) { final InstanceTableModel outputCasesTableModel = new InstanceTableModel(); outputCasesTableModel.setDataset(cases); final JXTable outputCasesTable = new JXTable(outputCasesTableModel); outputCasesTable.setEditable(false); outputCasesTable.setShowHorizontalLines(false); outputCasesTable.setShowVerticalLines(false); outputCasesTable.setVisibleRowCount(Math.min(10, cases.numInstances())); // FIXME: hardcoded trick outputCasesTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); final HighlightPredicate myPredicate = new HighlightPredicate() { @Override//from w w w . j av a 2 s . c om public boolean isHighlighted(final Component arg0, final ComponentAdapter arg1) { final String trueColumnName = (arg1.column > 0) ? cases.attribute(arg1.column - 1).name() : "id"; final java.util.List<String> inputFieldsList = Arrays.asList(GapFillingKnowledgeDB.INPUT_FIELDS); return (inputFieldsList.contains(trueColumnName)); } }; outputCasesTable.addHighlighter(new ColorHighlighter(myPredicate, null, Color.BLUE)); outputCasesTable.packAll(); return outputCasesTable; }
From source file:dbseer.gui.panel.DBSeerSelectableChartPanel.java
@Override public void chartMouseClicked(ChartMouseEvent chartMouseEvent) { ChartEntity entity = chartMouseEvent.getEntity(); MouseEvent mouseEvent = chartMouseEvent.getTrigger(); if (SwingUtilities.isLeftMouseButton(mouseEvent) && entity != null && entity instanceof PieSectionEntity) { java.util.List<String> names = dataset.getTransactionTypeNames(); PieSectionEntity pieSectionEntity = (PieSectionEntity) entity; int idx = pieSectionEntity.getSectionIndex(); String name = (String) JOptionPane.showInputDialog(null, "Enter the name for this transaction type", "Transaction Type", JOptionPane.PLAIN_MESSAGE, null, null, ""); if (name != null) { if (names.contains(name) && !names.get(idx).equals(name) && !name.isEmpty()) { JOptionPane.showMessageDialog(null, "Please enter a different name for the transaction type.\nEach name has to be unique.", "Warning", JOptionPane.WARNING_MESSAGE); } else { PieDataset oldDataset = pieSectionEntity.getDataset(); DefaultPieDataset newDataset = new DefaultPieDataset(); PiePlot plot = (PiePlot) chart.getPlot(); String oldName = (String) oldDataset.getKey(idx); names.set(idx, name);//from ww w . ja va 2 s. co m dataset.setTransactionTypeName(idx, name); for (int i = 0; i < oldDataset.getItemCount(); ++i) { String key = (String) oldDataset.getKey(i); Number number = oldDataset.getValue(i); if (key.equals(oldName)) { if (name.isEmpty()) newDataset.setValue("Transaction Type " + (i + 1), number); else newDataset.setValue(name, number); } else { newDataset.setValue(key, number); } } Paint[] tempPaint = new Paint[oldDataset.getItemCount()]; for (int i = 0; i < oldDataset.getItemCount(); ++i) { String key = (String) oldDataset.getKey(i); tempPaint[i] = plot.getSectionPaint(key); } ((DefaultPieDataset) oldDataset).clear(); plot.setDataset(newDataset); for (int i = 0; i < newDataset.getItemCount(); ++i) { String key = (String) newDataset.getKey(i); plot.setSectionPaint(key, tempPaint[i]); } } } } }
From source file:op.care.values.PnlValues.java
private JPanel createContentPanel4Year(final ResValueTypes vtype, final int year) { final String keyYears = vtype.getID() + ".xtypes." + Integer.toString(year) + ".year"; java.util.List<ResValue> myValues; synchronized (mapType2Values) { if (!mapType2Values.containsKey(keyYears)) { mapType2Values.put(keyYears, ResValueTools.getResValues(resident, vtype, year)); }/*from w ww.java 2 s . c om*/ if (mapType2Values.get(keyYears).isEmpty()) { JLabel lbl = new JLabel(SYSTools.xx("misc.msg.novalue")); JPanel pnl = new JPanel(); pnl.add(lbl); return pnl; } myValues = mapType2Values.get(keyYears); } JPanel pnlYear = new JPanel(new VerticalLayout()); pnlYear.setOpaque(false); for (final ResValue resValue : myValues) { String title = "<html><table border=\"0\">" + "<tr>" + "<td width=\"200\" align=\"left\">" + DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT).format(resValue.getPit()) + " [" + resValue.getID() + "]</td>" + "<td width=\"340\" align=\"left\">" + ResValueTools.getValueAsHTML(resValue) + "</td>" + "<td width=\"200\" align=\"left\">" + resValue.getUser().getFullname() + "</td>" + "</tr>" + "</table>" + "</html>"; final DefaultCPTitle pnlTitle = new DefaultCPTitle(title, null); pnlTitle.getMain().setBackground(GUITools.blend(vtype.getColor(), Color.WHITE, 0.1f)); pnlTitle.getMain().setOpaque(true); if (resValue.isObsolete()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22eraser)); } if (resValue.isReplacement()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22edited)); } if (!resValue.getText().trim().isEmpty()) { pnlTitle.getAdditionalIconPanel().add(new JLabel(SYSConst.icon22info)); } if (pnlTitle.getAdditionalIconPanel().getComponentCount() > 0) { pnlTitle.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { GUITools.showPopup( GUITools.getHTMLPopup(pnlTitle.getButton(), ResValueTools.getInfoAsHTML(resValue)), SwingConstants.NORTH); } }); } if (!resValue.getAttachedFilesConnections().isEmpty()) { /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = new JButton( Integer.toString(resValue.getAttachedFilesConnections().size()), SYSConst.icon22greenStar); btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip")); btnFiles.setForeground(Color.BLUE); btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER); btnFiles.setFont(SYSConst.ARIAL18BOLD); btnFiles.setPressedIcon(SYSConst.icon22Pressed); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.setAlignmentY(Component.TOP_ALIGNMENT); btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnFiles.setContentAreaFilled(false); btnFiles.setBorder(null); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgFiles(resValue, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final ResValue myValue = em.find(ResValue.class, resValue.getID()); em.close(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } }); } }); btnFiles.setEnabled(OPDE.isFTPworking()); pnlTitle.getRight().add(btnFiles); } if (!resValue.getAttachedProcessConnections().isEmpty()) { /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = new JButton( Integer.toString(resValue.getAttachedProcessConnections().size()), SYSConst.icon22redStar); btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip")); btnProcess.setForeground(Color.YELLOW); btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER); btnProcess.setFont(SYSConst.ARIAL18BOLD); btnProcess.setPressedIcon(SYSConst.icon22Pressed); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.setAlignmentY(Component.TOP_ALIGNMENT); btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnProcess.setContentAreaFilled(false); btnProcess.setBorder(null); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(resValue, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); ResValue myValue = em.merge(resValue); em.lock(myValue, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSVAL2PROCESS> attached = new ArrayList<SYSVAL2PROCESS>( resValue.getAttachedProcessConnections()); for (SYSVAL2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections() .remove(linkObject); linkObject.getResValue().getAttachedProcessConnections() .remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myValue)) { QProcess myQProcess = em.merge(qProcess); SYSVAL2PROCESS myLinkObject = em .merge(new SYSVAL2PROCESS(myQProcess, myValue)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedResValueConnections().add(myLinkObject); myValue.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); synchronized (mapType2Values) { mapType2Values.get(keyYears).remove(resValue); mapType2Values.get(keyYears).add(myValue); Collections.sort(mapType2Values.get(keyYears)); } createCP4Year(vtype, year); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled(OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)); pnlTitle.getRight().add(btnProcess); } /*** * __ __ * | \/ | ___ _ __ _ _ * | |\/| |/ _ \ '_ \| | | | * | | | | __/ | | | |_| | * |_| |_|\___|_| |_|\__,_| * */ final JButton btnMenu = new JButton(SYSConst.icon22menu); btnMenu.setPressedIcon(SYSConst.icon22Pressed); btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT); btnMenu.setAlignmentY(Component.TOP_ALIGNMENT); btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btnMenu.setContentAreaFilled(false); btnMenu.setBorder(null); btnMenu.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JidePopup popup = new JidePopup(); popup.setMovable(false); popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS)); popup.setOwner(btnMenu); popup.removeExcludedComponent(btnMenu); JPanel pnl = getMenu(resValue); popup.getContentPane().add(pnl); popup.setDefaultFocusComponent(pnl); GUITools.showPopup(popup, SwingConstants.WEST); } }); btnMenu.setEnabled(!resValue.isObsolete()); pnlTitle.getRight().add(btnMenu); pnlYear.add(pnlTitle.getMain()); synchronized (linemap) { linemap.put(resValue, pnlTitle.getMain()); } } return pnlYear; }
From source file:op.care.values.PnlValues.java
private JPanel getMenu(final ResValue resValue) { final ResValueTypes vtype = resValue.getType(); JPanel pnlMenu = new JPanel(new VerticalLayout()); boolean doesNotBelongToResInfos = ResInfoTools.getInfosFor(resValue).isEmpty(); if (doesNotBelongToResInfos && OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) { /***/*from www . j a v a2s. c o m*/ * _____ _ _ _ * | ____|__| (_) |_ * | _| / _` | | __| * | |__| (_| | | |_ * |_____\__,_|_|\__| * */ final JButton btnEdit = GUITools.createHyperlinkButton("nursingrecords.vitalparameters.btnEdit.tooltip", SYSConst.icon22edit3, null); btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT); btnEdit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgValue(resValue.clone(), DlgValue.MODE_EDIT, new Closure() { @Override public void execute(Object o) { if (o != null) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); final ResValue newValue = em.merge((ResValue) o); ResValue oldValue = em.merge(resValue); em.lock(oldValue, LockModeType.OPTIMISTIC); newValue.setReplacementFor(oldValue); for (SYSVAL2FILE oldAssignment : oldValue.getAttachedFilesConnections()) { em.remove(oldAssignment); } oldValue.getAttachedFilesConnections().clear(); for (SYSVAL2PROCESS oldAssignment : oldValue.getAttachedProcessConnections()) { em.remove(oldAssignment); } oldValue.getAttachedProcessConnections().clear(); oldValue.setEditedBy(em.merge(OPDE.getLogin().getUser())); oldValue.setEditDate(new Date()); oldValue.setReplacedBy(newValue); em.getTransaction().commit(); DateTime dt = new DateTime(newValue.getPit()); final String keyType = vtype.getID() + ".xtypes"; final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(oldValue); mapType2Values.get(key).add(newValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); try { synchronized (cpMap) { cpMap.get(keyType).setCollapsed(false); cpMap.get(key).setCollapsed(false); } } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnEdit.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnEdit); /*** * ____ _ _ * | _ \ ___| | ___| |_ ___ * | | | |/ _ \ |/ _ \ __/ _ \ * | |_| | __/ | __/ || __/ * |____/ \___|_|\___|\__\___| * */ final JButton btnDelete = GUITools.createHyperlinkButton( "nursingrecords.vitalparameters.btnDelete.tooltip", SYSConst.icon22delete, null); btnDelete.setAlignmentX(Component.RIGHT_ALIGNMENT); btnDelete.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/><i>" + DateFormat.getDateTimeInstance().format(resValue.getPit()) + "</i><br/>" + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() { @Override public void execute(Object o) { if (o.equals(JOptionPane.YES_OPTION)) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); ResValue myValue = em.merge(resValue); myValue.setDeletedBy(em.merge(OPDE.getLogin().getUser())); for (SYSVAL2FILE file : myValue.getAttachedFilesConnections()) { em.remove(file); } myValue.getAttachedFilesConnections().clear(); // Vorgangszuordnungen entfernen for (SYSVAL2PROCESS connObj : myValue.getAttachedProcessConnections()) { em.remove(connObj); } myValue.getAttachedProcessConnections().clear(); myValue.getAttachedProcesses().clear(); em.getTransaction().commit(); DateTime dt = new DateTime(myValue.getPit()); final String keyType = vtype.getID() + ".xtypes"; final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); try { synchronized (cpMap) { cpMap.get(keyType).setCollapsed(false); cpMap.get(key).setCollapsed(false); } } catch (PropertyVetoException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } } }); } }); btnDelete.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnDelete); pnlMenu.add(new JSeparator()); /*** * _ _ _____ _ _ * | |__ | |_ _ __ | ___(_) | ___ ___ * | '_ \| __| '_ \| |_ | | |/ _ \/ __| * | |_) | |_| | | | _| | | | __/\__ \ * |_.__/ \__|_| |_|_| |_|_|\___||___/ * */ final JButton btnFiles = GUITools.createHyperlinkButton("misc.btnfiles.tooltip", SYSConst.icon22attach, null); btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT); btnFiles.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgFiles(resValue, new Closure() { @Override public void execute(Object o) { EntityManager em = OPDE.createEM(); final ResValue myValue = em.find(ResValue.class, resValue.getID()); em.close(); DateTime dt = new DateTime(myValue.getPit()); final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } buildPanel(); } }); } }); btnFiles.setEnabled(!resValue.isObsolete() && OPDE.isFTPworking()); pnlMenu.add(btnFiles); /*** * _ _ ____ * | |__ | |_ _ __ | _ \ _ __ ___ ___ ___ ___ ___ * | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __| * | |_) | |_| | | | __/| | | (_) | (_| __/\__ \__ \ * |_.__/ \__|_| |_|_| |_| \___/ \___\___||___/___/ * */ final JButton btnProcess = GUITools.createHyperlinkButton("misc.btnprocess.tooltip", SYSConst.icon22link, null); btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT); btnProcess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { new DlgProcessAssign(resValue, new Closure() { @Override public void execute(Object o) { if (o == null) { return; } Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o; ArrayList<QProcess> assigned = result.getFirst(); ArrayList<QProcess> unassigned = result.getSecond(); EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); em.lock(em.merge(resident), LockModeType.OPTIMISTIC); ResValue myValue = em.merge(resValue); em.lock(myValue, LockModeType.OPTIMISTIC_FORCE_INCREMENT); ArrayList<SYSVAL2PROCESS> attached = new ArrayList<SYSVAL2PROCESS>( resValue.getAttachedProcessConnections()); for (SYSVAL2PROCESS linkObject : attached) { if (unassigned.contains(linkObject.getQProcess())) { linkObject.getQProcess().getAttachedNReportConnections().remove(linkObject); linkObject.getResValue().getAttachedProcessConnections().remove(linkObject); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_REMOVE_ELEMENT, linkObject.getQProcess())); em.remove(linkObject); } } attached.clear(); for (QProcess qProcess : assigned) { java.util.List<QProcessElement> listElements = qProcess.getElements(); if (!listElements.contains(myValue)) { QProcess myQProcess = em.merge(qProcess); SYSVAL2PROCESS myLinkObject = em .merge(new SYSVAL2PROCESS(myQProcess, myValue)); em.merge(new PReport( SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": " + myValue.getTitle() + " ID: " + myValue.getID(), PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess)); qProcess.getAttachedResValueConnections().add(myLinkObject); myValue.getAttachedProcessConnections().add(myLinkObject); } } em.getTransaction().commit(); DateTime dt = new DateTime(myValue.getPit()); final String key = vtype.getID() + ".xtypes." + Integer.toString(dt.getYear()) + ".year"; synchronized (mapType2Values) { mapType2Values.get(key).remove(resValue); mapType2Values.get(key).add(myValue); Collections.sort(mapType2Values.get(key)); } createCP4Year(vtype, dt.getYear()); buildPanel(); //GUITools.flashBackground(contentmap.get(keyMonth), Color.YELLOW, 2); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (RollbackException ole) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); } }); btnProcess.setEnabled(!resValue.isObsolete()); pnlMenu.add(btnProcess); } return pnlMenu; }
From source file:org.yccheok.jstock.gui.JStock.java
private boolean initCSVWatchlist() { java.util.List<String> availableWatchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames(); // Do we have any watchlist for this country? if (availableWatchlistNames.size() <= 0) { // If not, create an empty watchlist. org.yccheok.jstock.watchlist.Utils .createEmptyWatchlist(org.yccheok.jstock.watchlist.Utils.getDefaultWatchlistName()); availableWatchlistNames = org.yccheok.jstock.watchlist.Utils.getWatchlistNames(); }// w w w. j a va 2s . c o m assert (availableWatchlistNames.isEmpty() == false); // Is user selected watchlist name within current available watchlist names? if (false == availableWatchlistNames.contains(jStockOptions.getWatchlistName())) { // Nope. Reset user selected watchlist name to the first available name. jStockOptions.setWatchlistName(availableWatchlistNames.get(0)); } // openAsCSVFile will "append" stocks. We need to clear previous stocks // explicitly. // Clear the previous data structures. clearAllStocks(); File realTimeStockFile = org.yccheok.jstock.watchlist.Utils .getWatchlistFile(org.yccheok.jstock.watchlist.Utils.getWatchlistDirectory()); return this.openAsCSVFile(realTimeStockFile); }
From source file:uk.ac.ucl.cs.cmic.giftcloud.uploadapp.GiftCloudDialogs.java
public String showInputDialogToSelectProject(final java.util.List<String> projectMap, final Component component, final Optional<String> lastProject) throws IOException { final String lastProjectName = lastProject.isPresent() ? lastProject.get() : ""; if (projectMap.size() < 1) { return null; }//from www . j ava 2 s . c o m String[] projectStringArray = projectMap.toArray(new String[0]); final String defaultSelection = projectMap.contains(lastProjectName) ? lastProjectName : null; final Object returnValue = JOptionPane.showInputDialog(component, "Please select a project to which data will be uploaded.", applicationName, JOptionPane.QUESTION_MESSAGE, null, projectStringArray, defaultSelection); if (returnValue == null) { throw new CancellationException("User cancelled project selection during upload"); } if (!(returnValue instanceof String)) { throw new RuntimeException("Bad return type"); } return (String) returnValue; }