List of usage examples for javax.swing JOptionPane OK_OPTION
int OK_OPTION
To view the source code for javax.swing JOptionPane OK_OPTION.
Click Source Link
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Displays a dialog that allows the user to edit the properties for the * current chart.// w ww. jav a 2 s . co m */ private void attemptEditChartProperties() { ChartPropertyEditPanel panel = new ChartPropertyEditPanel(chart); int result = JOptionPane.showConfirmDialog(this, panel, localizationResources.getString("Chart_Properties"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (result == JOptionPane.OK_OPTION) { panel.updateChartProperties(chart); } }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_link.java
private List<JComponent> getExtraOptions(final int row, final Object itemId) { List<JComponent> options = new LinkedList<JComponent>(); final List<Link> rowVisibleLinks = getVisibleElementsInTable(); final NetPlan netPlan = callback.getDesign(); if (itemId != null) { final long linkId = (long) itemId; JMenuItem lengthToEuclidean_thisLink = new JMenuItem("Set link length to node-pair Euclidean distance"); lengthToEuclidean_thisLink.addActionListener(new ActionListener() { @Override/*www . j a va2 s . co m*/ public void actionPerformed(ActionEvent e) { Link link = netPlan.getLinkFromId(linkId); Node originNode = link.getOriginNode(); Node destinationNode = link.getDestinationNode(); double euclideanDistance = netPlan.getNodePairEuclideanDistance(originNode, destinationNode); link.setLengthInKm(euclideanDistance); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(lengthToEuclidean_thisLink); JMenuItem lengthToHaversine_allNodes = new JMenuItem( "Set link length to node-pair Haversine distance (longitude-latitude) in km"); lengthToHaversine_allNodes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Link link = netPlan.getLinkFromId(linkId); Node originNode = link.getOriginNode(); Node destinationNode = link.getDestinationNode(); double haversineDistanceInKm = netPlan.getNodePairHaversineDistanceInKm(originNode, destinationNode); link.setLengthInKm(haversineDistanceInKm); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(lengthToHaversine_allNodes); JMenuItem scaleLinkLength_thisLink = new JMenuItem("Scale link length"); scaleLinkLength_thisLink.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double scaleFactor; while (true) { String str = JOptionPane.showInputDialog(null, "(Multiplicative) Scale factor", "Scale link length", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { scaleFactor = Double.parseDouble(str); if (scaleFactor < 0) throw new RuntimeException(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog( "Non-valid scale value. Please, introduce a non-negative number", "Error setting scale factor"); } } netPlan.getLinkFromId(linkId) .setLengthInKm(netPlan.getLinkFromId(linkId).getLengthInKm() * scaleFactor); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(scaleLinkLength_thisLink); if (netPlan.isMultilayer()) { Link link = netPlan.getLinkFromId(linkId); if (link.getCoupledDemand() != null) { JMenuItem decoupleLinkItem = new JMenuItem("Decouple link (if coupled to unicast demand)"); decoupleLinkItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { netPlan.getLinkFromId(linkId).getCoupledDemand().decouple(); model.setValueAt("", row, 20); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.LINK, NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(decoupleLinkItem); } else { JMenuItem createLowerLayerDemandFromLinkItem = new JMenuItem( "Create lower layer demand from link"); createLowerLayerDemandFromLinkItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection<Long> layerIds = netPlan.getNetworkLayerIds(); final JComboBox layerSelector = new WiderJComboBox(); for (long layerId : layerIds) { if (layerId == netPlan.getNetworkLayerDefault().getId()) continue; final String layerName = netPlan.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; layerSelector.addItem(StringLabeller.of(layerId, layerLabel)); } layerSelector.setSelectedIndex(0); JPanel pane = new JPanel(); pane.add(new JLabel("Select layer: ")); pane.add(layerSelector); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the lower layer to create the demand", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long layerId = (long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); Link link = netPlan.getLinkFromId(linkId); netPlan.addDemand(link.getOriginNode(), link.getDestinationNode(), link.getCapacity(), link.getAttributes(), netPlan.getNetworkLayerFromId(layerId)); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error creating lower layer demand from link"); } } } }); options.add(createLowerLayerDemandFromLinkItem); JMenuItem coupleLinkToDemand = new JMenuItem("Couple link to lower layer demand"); coupleLinkToDemand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection<Long> layerIds = netPlan.getNetworkLayerIds(); final JComboBox layerSelector = new WiderJComboBox(); final JComboBox demandSelector = new WiderJComboBox(); for (long layerId : layerIds) { if (layerId == netPlan.getNetworkLayerDefault().getId()) continue; final String layerName = netPlan.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; layerSelector.addItem(StringLabeller.of(layerId, layerLabel)); } layerSelector.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (layerSelector.getSelectedIndex() >= 0) { long selectedLayerId = (Long) ((StringLabeller) layerSelector .getSelectedItem()).getObject(); demandSelector.removeAllItems(); for (Demand demand : netPlan .getDemands(netPlan.getNetworkLayerFromId(selectedLayerId))) { if (demand.isCoupled()) continue; long ingressNodeId = demand.getIngressNode().getId(); long egressNodeId = demand.getEgressNode().getId(); String ingressNodeName = demand.getIngressNode().getName(); String egressNodeName = demand.getEgressNode().getName(); demandSelector.addItem(StringLabeller.unmodifiableOf(demand.getId(), "d" + demand.getId() + " [n" + ingressNodeId + " (" + ingressNodeName + ") -> n" + egressNodeId + " (" + egressNodeName + ")]")); } } if (demandSelector.getItemCount() == 0) { demandSelector.setEnabled(false); } else { demandSelector.setSelectedIndex(0); demandSelector.setEnabled(true); } } }); layerSelector.setSelectedIndex(-1); layerSelector.setSelectedIndex(0); JPanel pane = new JPanel(new MigLayout("", "[][grow]", "[][]")); pane.add(new JLabel("Select layer: ")); pane.add(layerSelector, "growx, wrap"); pane.add(new JLabel("Select demand: ")); pane.add(demandSelector, "growx, wrap"); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the lower layer demand", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long demandId; try { demandId = (long) ((StringLabeller) demandSelector.getSelectedItem()) .getObject(); } catch (Throwable ex) { throw new RuntimeException("No demand was selected"); } netPlan.getDemandFromId(demandId) .coupleToUpperLayerLink(netPlan.getLinkFromId(linkId)); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.LINK, NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error coupling lower layer demand to link"); } } } }); options.add(coupleLinkToDemand); } } } if (rowVisibleLinks.size() > 1) { if (!options.isEmpty()) options.add(new JPopupMenu.Separator()); JMenuItem caFixValue = new JMenuItem("Set capacity to all"); caFixValue.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double u_e; while (true) { String str = JOptionPane.showInputDialog(null, "Capacity value", "Set capacity to all table links", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { u_e = Double.parseDouble(str); if (u_e < 0) throw new NumberFormatException(); break; } catch (NumberFormatException ex) { ErrorHandling.showErrorDialog( "Non-valid capacity value. Please, introduce a non-negative number", "Error setting capacity value"); } } try { for (Link link : rowVisibleLinks) link.setCapacity(u_e); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set capacity to all links"); } } }); options.add(caFixValue); JMenuItem caFixValueUtilization = new JMenuItem("Set capacity to match a given utilization"); caFixValueUtilization.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double utilization; while (true) { String str = JOptionPane.showInputDialog(null, "Link utilization value", "Set capacity to all table links to match a given utilization", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { utilization = Double.parseDouble(str); if (utilization <= 0) throw new NumberFormatException(); break; } catch (NumberFormatException ex) { ErrorHandling.showErrorDialog( "Non-valid link utilization value. Please, introduce a strictly positive number", "Error setting link utilization value"); } } try { for (Link link : rowVisibleLinks) link.setCapacity(link.getOccupiedCapacity() / utilization); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set capacity to all links according to a given link utilization"); } } }); options.add(caFixValueUtilization); JMenuItem lengthToAll = new JMenuItem("Set link length to all"); lengthToAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double l_e; while (true) { String str = JOptionPane.showInputDialog(null, "Link length value (in km)", "Set link length to all table links", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { l_e = Double.parseDouble(str); if (l_e < 0) throw new RuntimeException(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog( "Non-valid link length value. Please, introduce a non-negative number", "Error setting link length"); } } NetPlan netPlan = callback.getDesign(); try { for (Link link : rowVisibleLinks) link.setLengthInKm(l_e); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set link length to all links"); } } }); options.add(lengthToAll); JMenuItem lengthToEuclidean_allLinks = new JMenuItem( "Set all table link lengths to node-pair Euclidean distance"); lengthToEuclidean_allLinks.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { for (Link link : rowVisibleLinks) link.setLengthInKm(netPlan.getNodePairEuclideanDistance(link.getOriginNode(), link.getDestinationNode())); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set link length value to all links"); } } }); options.add(lengthToEuclidean_allLinks); JMenuItem lengthToHaversine_allLinks = new JMenuItem( "Set all table link lengths to node-pair Haversine distance (longitude-latitude) in km"); lengthToHaversine_allLinks.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { for (Link link : rowVisibleLinks) { link.setLengthInKm(netPlan.getNodePairHaversineDistanceInKm(link.getOriginNode(), link.getDestinationNode())); } callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set link length value to all links"); } } }); options.add(lengthToHaversine_allLinks); JMenuItem scaleLinkLength_allLinks = new JMenuItem("Scale all table link lengths"); scaleLinkLength_allLinks.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double scaleFactor; while (true) { String str = JOptionPane.showInputDialog(null, "(Multiplicative) Scale factor", "Scale (all) link length", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { scaleFactor = Double.parseDouble(str); if (scaleFactor < 0) throw new RuntimeException(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog( "Non-valid scale value. Please, introduce a non-negative number", "Error setting scale factor"); } } NetPlan netPlan = callback.getDesign(); try { for (Link link : rowVisibleLinks) link.setLengthInKm(link.getLengthInKm() * scaleFactor); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to scale link length"); } } }); options.add(scaleLinkLength_allLinks); if (netPlan.isMultilayer()) { final Set<Link> coupledLinks = rowVisibleLinks.stream().filter(e -> e.isCoupled()) .collect(Collectors.toSet()); if (!coupledLinks.isEmpty()) { JMenuItem decoupleAllLinksItem = new JMenuItem("Decouple all table links"); decoupleAllLinksItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (Link link : coupledLinks) if (link.getCoupledDemand() == null) link.getCoupledMulticastDemand().decouple(); else link.getCoupledDemand().decouple(); int numRows = model.getRowCount(); for (int i = 0; i < numRows; i++) model.setValueAt("", i, 20); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.LINK, NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(decoupleAllLinksItem); } if (coupledLinks.size() < rowVisibleLinks.size()) { JMenuItem createLowerLayerDemandsFromLinksItem = new JMenuItem( "Create lower layer unicast demands from uncoupled links"); createLowerLayerDemandsFromLinksItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JComboBox layerSelector = new WiderJComboBox(); for (NetworkLayer layer : netPlan.getNetworkLayers()) { if (layer.getId() == netPlan.getNetworkLayerDefault().getId()) continue; final String layerName = layer.getName(); String layerLabel = "Layer " + layer.getId(); if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; layerSelector.addItem(StringLabeller.of(layer.getId(), layerLabel)); } layerSelector.setSelectedIndex(0); JPanel pane = new JPanel(); pane.add(new JLabel("Select layer: ")); pane.add(layerSelector); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the lower layer to create demands", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long layerId = (long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); NetworkLayer layer = netPlan.getNetworkLayerFromId(layerId); for (Link link : rowVisibleLinks) if (!link.isCoupled()) link.coupleToNewDemandCreated(layer); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.LINK, NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error creating lower layer demands"); } } } }); options.add(createLowerLayerDemandsFromLinksItem); } } } return options; }
From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java
/** * @return//from w w w .ja va2 s.c o m */ public CollectionResultType initialize() { collectionInfoList = CollectionInfo.getCollectionInfoList(oldDBConn, false); //fixIdaho(); if (collectionInfoList == null) { if (CollectionInfo.isAskForFix()) { if (ConvertTaxonHelper.fixTaxonomicUnitType(oldDBConn)) { collectionInfoList = CollectionInfo.getCollectionInfoList(oldDBConn, true); } else { try { oldDBConn.close(); } catch (SQLException e) { } System.exit(0); } } else { try { oldDBConn.close(); } catch (SQLException e) { } System.exit(0); } } collectionInfoShortList = CollectionInfo.getFilteredCollectionInfoList(); if (collectionInfoList != null && collectionInfoList.size() > 0) { int paleoCnt = 0; // This is a Hash of TaxonObjectType to see how many collections use the same TaxonObjectType HashMap<Integer, HashSet<CollectionInfo>> taxonomyTypeHash = new HashMap<Integer, HashSet<CollectionInfo>>(); // Get a List for each type of Paleo Collection, hashed by the Root Id HashMap<Integer, Vector<CollectionInfo>> paleoColInfoHash = new HashMap<Integer, Vector<CollectionInfo>>(); HashMap<Integer, HashSet<DisciplineType.STD_DISCIPLINES>> paleoDispTypeHash = new HashMap<Integer, HashSet<DisciplineType.STD_DISCIPLINES>>(); for (CollectionInfo colInfo : collectionInfoShortList) { // Tracks a 'set' of CollectionInfo objects for each TaxonomyTypeId HashSet<CollectionInfo> taxonomyTypeSet = taxonomyTypeHash.get(colInfo.getTaxonomyTypeId()); if (taxonomyTypeSet == null) { System.out.println("Creating TxTypeID: " + colInfo.getTaxonomyTypeId() + " From " + colInfo.getCatSeriesName()); taxonomyTypeSet = new HashSet<CollectionInfo>(); taxonomyTypeHash.put(colInfo.getTaxonomyTypeId(), taxonomyTypeSet); } else { System.out.println("Adding TxTypeID: " + colInfo.getTaxonomyTypeId() + " From " + colInfo.getCatSeriesName() + " " + taxonomyTypeSet.size()); } taxonomyTypeSet.add(colInfo); //--- DisciplineType dType = getStandardDisciplineName(colInfo.getTaxonomyTypeName(), colInfo.getColObjTypeName(), colInfo.getCatSeriesName()); colInfo.setDisciplineTypeObj(dType); if (dType != null && dType.isPaleo()) { Vector<CollectionInfo> ciList = paleoColInfoHash.get(colInfo.getTaxonNameId()); if (ciList == null) { ciList = new Vector<CollectionInfo>(); paleoColInfoHash.put(colInfo.getTaxonNameId(), ciList); } ciList.add(colInfo); HashSet<DisciplineType.STD_DISCIPLINES> typeDispSet = paleoDispTypeHash .get(colInfo.getTaxonNameId()); if (typeDispSet == null) { typeDispSet = new HashSet<DisciplineType.STD_DISCIPLINES>(); paleoDispTypeHash.put(colInfo.getTaxonNameId(), typeDispSet); } typeDispSet.add(colInfo.getDisciplineTypeObj().getDisciplineType()); paleoCnt++; } System.out.println("--------------------------------------"); //System.out.println(colInfo.toString()+"\n"); } // for loop int cnt = 0; StringBuilder msg = new StringBuilder(); for (Integer taxonomyTypId : taxonomyTypeHash.keySet()) { HashSet<CollectionInfo> taxonomyTypeSet = taxonomyTypeHash.get(taxonomyTypId); if (taxonomyTypeSet.size() > 1) { msg.append( String.format("<html>TaxonomyTypeId %d has more than one Discpline/Collection:<br><OL>", taxonomyTypId)); for (CollectionInfo ci : taxonomyTypeSet) { msg.append(String.format("<LI>%s - %s - %s</LI>", ci.getCatSeriesName(), ci.getColObjTypeName(), ci.getTaxonomyTypeName())); } msg.append("</OL>"); cnt++; } } if (cnt > 0) { JOptionPane.showConfirmDialog(null, msg.toString(), "Taxomony Type Issues", JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE); } // Will be zero for no Paleo collections if (paleoCnt > 1) { // Check to see if they all use the same tree if (paleoColInfoHash.size() > 1) { msg.setLength(0); // We get here when there is more than one Taxon Tree for the Paleo Collections for (Integer treeId : paleoColInfoHash.keySet()) { Vector<CollectionInfo> ciList = paleoColInfoHash.get(treeId); CollectionInfo colInfo = ciList.get(0); msg.append(String.format("The following collections use Taxon Tree '%s':\n", colInfo.getTaxonomyTypeName())); for (CollectionInfo ci : paleoColInfoHash.get(treeId)) { DisciplineType dType = getStandardDisciplineName(ci.getTaxonomyTypeName(), ci.getColObjTypeName(), ci.getCatSeriesName()); String name = String.format("%s / %s / %s / %s / %s", ci.getCatSeriesPrefix(), ci.getCatSeriesName(), ci.getColObjTypeName(), ci.getTaxonomyTypeName(), dType.toString()); msg.append(name); msg.append("\n"); } msg.append("\n"); } JOptionPane.showConfirmDialog(null, msg.toString(), "Paleo Taxon Tree Issues", JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE); } else { StringBuilder colNames = new StringBuilder(); for (Integer treeId : paleoColInfoHash.keySet()) { for (CollectionInfo ci : paleoColInfoHash.get(treeId)) { colNames.append("<LI>"); colNames.append(ci.getCatSeriesName()); colNames.append("</LI>"); } } // You get here when all the Paleo Disciplines use the same tree String msgStr = "<html>All the Paleo Collections need to use the same Taxon Tree and<br>therefore needs to be in the same discipline:<br><ol>"; JOptionPane.showConfirmDialog(null, msgStr + colNames.toString(), "Paleo Taxon Tree Issues", JOptionPane.CLOSED_OPTION, JOptionPane.QUESTION_MESSAGE); for (Integer treeId : paleoColInfoHash.keySet()) { Vector<CollectionInfo> ciList = paleoColInfoHash.get(treeId); CollectionInfo colInfo = ciList.get(0); for (CollectionInfo ci : paleoColInfoHash.get(treeId)) { ci.setDisciplineTypeObj(colInfo.getDisciplineTypeObj()); } } } // } DefaultTableModel model = CollectionInfo.getCollectionInfoTableModel(false); if (model.getRowCount() > 1) { TableWriter colInfoTblWriter = convLogger.getWriter("colinfo.html", "Collection Info"); colInfoTblWriter.startTable(); colInfoTblWriter.logHdr(CollectionInfoModel.getHeaders()); Object[] row = new Object[model.getColumnCount()]; for (int r = 0; r < model.getRowCount(); r++) { for (int i = 0; i < model.getColumnCount(); i++) { row[i] = model.getValueAt(r, i); } colInfoTblWriter.logObjRow(row); } colInfoTblWriter.endTable(); colInfoTblWriter.println("<BR><h3>Collections to be Created.</h3>"); colInfoTblWriter.startTable(); colInfoTblWriter.logHdr(CollectionInfoModel.getHeaders()); model = CollectionInfo.getCollectionInfoTableModel(true); row = new Object[model.getColumnCount()]; for (int r = 0; r < model.getRowCount(); r++) { for (int i = 0; i < model.getColumnCount(); i++) { row[i] = model.getValueAt(r, i); } colInfoTblWriter.logObjRow(row); } colInfoTblWriter.endTable(); colInfoTblWriter.close(); File file = new File(colInfoTblWriter.getFileName()); if (file != null && file.exists()) { try { AttachmentUtils.openURI(file.toURI()); } catch (Exception ex) { ex.printStackTrace(); } } } for (CollectionInfo ci : CollectionInfo.getFilteredCollectionInfoList()) { String sql = "select preparationmethod, ct.* from usyscollobjprepmeth pt inner join usysmetafieldsetsubtype st on st.fieldsetsubtypeid = pt.fieldsetsubtypeid " + "inner join collectionobjecttype ct1 on ct1.collectionobjecttypeid = st.fieldvalue " + "inner join collectionobjecttype ct on ct.collectionobjecttypename = replace(ct1.collectionobjecttypename, ' Preparation', '') " + "inner join catalogseriesdefinition csd on csd.objecttypeid = ct.collectionobjecttypeid " + "inner join catalogseries cs on cs.catalogseriesid = csd.catalogseriesid " + "WHERE csd.catalogseriesid = " + ci.getCatSeriesId(); System.out.println("\n------------------"); System.out.println(ci.getCatSeriesName()); System.out.println(sql); System.out.println("------------------"); int i = 0; Vector<Object[]> list = BasicSQLUtils.query(oldDBConn, sql); if (list.size() > 0) { for (Object[] row : list) { System.out.print(i + " - "); for (Object col : row) { System.out.print(col != null ? col.toString() : "null"); System.out.print(", "); } System.out.println(); i++; } } else { System.out.println("No Results"); } sql = "select ct.*, (select relatedsubtypevalues from usysmetacontrol c " + "left join usysmetafieldsetsubtype fst on fst.fieldsetsubtypeid = c.fieldsetsubtypeid " + "where objectid = 10290 and ct.taxonomytypeid = c.relatedsubtypevalues) as DeterminationTaxonType " + "from collectiontaxonomytypes ct where ct.biologicalobjecttypeid = " + ci.getColObjTypeId(); sql = String.format( "SELECT CollectionTaxonomyTypesID, BiologicalObjectTypeID, CollectionObjectTypeName FROM (select ct.*, " + "(SELECT distinct relatedsubtypevalues FROM usysmetacontrol c " + "LEFT JOIN usysmetafieldsetsubtype fst ON fst.fieldsetsubtypeid = c.fieldsetsubtypeid " + "WHERE objectid = 10290 AND ct.taxonomytypeid = c.relatedsubtypevalues) AS DeterminationTaxonType " + "FROM collectiontaxonomytypes ct WHERE ct.biologicalobjecttypeid = %d) T1 " + "INNER JOIN collectionobjecttype cot ON T1.biologicalobjecttypeid = cot.CollectionObjectTypeID", ci.getColObjTypeId()); System.out.println("\n------------------"); System.out.println(ci.getColObjTypeName()); System.out.println(sql); System.out.println("------------------"); i = 0; list = BasicSQLUtils.query(oldDBConn, sql); if (list.size() > 0) { for (Object[] row : list) { System.out.print(i + " - "); for (Object col : row) { System.out.print(col != null ? col.toString() : "null"); System.out.print(", "); } System.out.println(); i++; } } else { System.out.println("No Results"); } } /* String sql = " select ct.*, (select relatedsubtypevalues from usysmetacontrol c " + "left join usysmetafieldsetsubtype fst on fst.fieldsetsubtypeid = c.fieldsetsubtypeid " + "where objectid = 10290 and ct.taxonomytypeid = c.relatedsubtypevalues) as DeterminationTaxonType " + "from collectiontaxonomytypes ct where ct.biologicalobjecttypeid = 13"; System.out.println("\n------------------"); System.out.println("List of the taxonomytypes associated with a CollectionObjectTypeID"); System.out.println(sql); System.out.println("------------------"); int i = 0; Vector<Object[]> list = BasicSQLUtils.query(oldDBConn, sql); if (list.size() > 0) { for (Object[] row : list) { System.out.print(i+" - "); for (Object col: row) { System.out.print(col != null ? col.toString() : "null"); System.out.print(", "); } System.out.println(); } } else { System.out.println("No Results"); }*/ CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,2px,f:p:g,10px,p,2px,p:g,8px")); JTable tableTop = new JTable(CollectionInfo.getCollectionInfoTableModel(false)); JTable tableBot = new JTable( CollectionInfo.getCollectionInfoTableModel(!CollectionInfo.DOING_ACCESSSION)); int rows = 10; tableTop.setPreferredScrollableViewportSize(new Dimension( tableTop.getPreferredScrollableViewportSize().width, rows * tableTop.getRowHeight())); tableBot.setPreferredScrollableViewportSize(new Dimension( tableBot.getPreferredScrollableViewportSize().width, rows * tableBot.getRowHeight())); pb.add(UIHelper.createLabel("Available Specify 5 Taxononmic Types", SwingConstants.CENTER), cc.xy(1, 1)); pb.add(UIHelper.createScrollPane(tableTop), cc.xy(1, 3)); pb.add(UIHelper.createLabel("Specify 5 Collections to be Created", SwingConstants.CENTER), cc.xy(1, 5)); pb.add(UIHelper.createScrollPane(tableBot), cc.xy(1, 7)); pb.setDefaultDialogBorder(); CustomDialog dlg = new CustomDialog(null, "Taxononic Types", true, pb.getPanel()); dlg.createUI(); dlg.setSize(1024, 500); UIHelper.centerWindow(dlg); dlg.setAlwaysOnTop(true); dlg.setVisible(true); if (dlg.isCancelled()) { return CollectionResultType.eCancel; } Pair<CollectionInfo, DisciplineType> pair = CollectionInfo.getDisciplineType(oldDBConn); if (pair == null || pair.second == null) { CollectionInfo colInfo = pair.first; disciplineType = getStandardDisciplineName(colInfo.getTaxonomyTypeName(), colInfo.getColObjTypeName(), colInfo.getCatSeriesName()); } else { disciplineType = pair.second; } return disciplineType != null ? CollectionResultType.eOK : CollectionResultType.eError; } return CollectionResultType.eError; }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
protected void chooseCourses() { try {/*from w w w .j a v a2s . c o m*/ if (login()) { CourseChooserContr courseChooserContr = new CourseChooserContr(iliasProperties.isSyncAll(), iliasProperties.getActiveCourses(), syncService.getIliasSoapService()); if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, courseChooserContr.getView(), "Kurse auswhlen", JOptionPane.OK_CANCEL_OPTION)) { iliasProperties.setActiveCourses(courseChooserContr.getActiveCourses()); iliasProperties.setSyncAll(courseChooserContr.isSyncAll()); saveProperties(iliasProperties); } } } catch (Exception e) { showError("Fehler beim ndern der Kursinformationen", e); } }
From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_demand.java
private List<JComponent> getExtraOptions(final int row, final Object itemId) { List<JComponent> options = new LinkedList<JComponent>(); final int numRows = model.getRowCount(); final NetPlan netPlan = callback.getDesign(); final List<Demand> tableVisibleDemands = getVisibleElementsInTable(); JMenuItem offeredTrafficToAll = new JMenuItem("Set offered traffic to all"); offeredTrafficToAll.addActionListener(new ActionListener() { @Override/* w w w. j a v a 2 s . com*/ public void actionPerformed(ActionEvent e) { double h_d; while (true) { String str = JOptionPane.showInputDialog(null, "Offered traffic volume", "Set traffic value to all demands in the table", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { h_d = Double.parseDouble(str); if (h_d < 0) throw new RuntimeException(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog("Please, introduce a non-negative number", "Error setting offered traffic"); } } NetPlan netPlan = callback.getDesign(); try { for (Demand d : tableVisibleDemands) d.setOfferedTraffic(h_d); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set offered traffic to all demands in the table"); } } }); options.add(offeredTrafficToAll); JMenuItem scaleOfferedTrafficToAll = new JMenuItem("Scale offered traffic all demands in the table"); scaleOfferedTrafficToAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { double scalingFactor; while (true) { String str = JOptionPane.showInputDialog(null, "Scaling factor to multiply to all offered traffics", "Scale offered traffic", JOptionPane.QUESTION_MESSAGE); if (str == null) return; try { scalingFactor = Double.parseDouble(str); if (scalingFactor < 0) throw new RuntimeException(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog("Please, introduce a non-negative number", "Error setting offered traffic"); } } try { for (Demand d : tableVisibleDemands) d.setOfferedTraffic(d.getOfferedTraffic() * scalingFactor); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to scale demand offered traffics"); } } }); options.add(scaleOfferedTrafficToAll); JMenuItem setServiceTypes = new JMenuItem( "Set traversed resource types (to one or all demands in the table)"); setServiceTypes.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetPlan netPlan = callback.getDesign(); try { Demand d = netPlan.getDemandFromId((Long) itemId); String[] headers = StringUtils.arrayOf("Order", "Type"); Object[][] data = { null, null }; DefaultTableModel model = new ClassAwareTableModelImpl(data, headers); AdvancedJTable table = new AdvancedJTable(model); JButton addRow = new JButton("Add new traversed resource type"); addRow.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object[] newRow = { table.getRowCount(), "" }; ((DefaultTableModel) table.getModel()).addRow(newRow); } }); JButton removeRow = new JButton("Remove selected"); removeRow.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ((DefaultTableModel) table.getModel()).removeRow(table.getSelectedRow()); for (int t = 0; t < table.getRowCount(); t++) table.getModel().setValueAt(t, t, 0); } }); JButton removeAllRows = new JButton("Remove all"); removeAllRows.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { while (table.getRowCount() > 0) ((DefaultTableModel) table.getModel()).removeRow(0); } }); List<String> oldTraversedResourceTypes = d.getServiceChainSequenceOfTraversedResourceTypes(); Object[][] newData = new Object[oldTraversedResourceTypes.size()][headers.length]; for (int i = 0; i < oldTraversedResourceTypes.size(); i++) { newData[i][0] = i; newData[i][1] = oldTraversedResourceTypes.get(i); } ((DefaultTableModel) table.getModel()).setDataVector(newData, headers); JPanel pane = new JPanel(); JPanel pane2 = new JPanel(); pane.setLayout(new BorderLayout()); pane2.setLayout(new BorderLayout()); pane.add(new JScrollPane(table), BorderLayout.CENTER); pane2.add(addRow, BorderLayout.WEST); pane2.add(removeRow, BorderLayout.EAST); pane2.add(removeAllRows, BorderLayout.SOUTH); pane.add(pane2, BorderLayout.SOUTH); final String[] optionsArray = new String[] { "Set to selected demand", "Set to all demands", "Cancel" }; int result = JOptionPane.showOptionDialog(null, pane, "Set traversed resource types", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, optionsArray, optionsArray[0]); if ((result != 0) && (result != 1)) return; final boolean setToAllDemands = (result == 1); List<String> newTraversedResourcesTypes = new LinkedList<>(); for (int j = 0; j < table.getRowCount(); j++) { String travResourceType = table.getModel().getValueAt(j, 1).toString(); newTraversedResourcesTypes.add(travResourceType); } if (setToAllDemands) { for (Demand dd : tableVisibleDemands) if (!dd.getRoutes().isEmpty()) throw new Net2PlanException( "It is not possible to set the resource types traversed to demands with routes"); for (Demand dd : tableVisibleDemands) dd.setServiceChainSequenceOfTraversedResourceTypes(newTraversedResourcesTypes); } else { if (!d.getRoutes().isEmpty()) throw new Net2PlanException( "It is not possible to set the resource types traversed to demands with routes"); d.setServiceChainSequenceOfTraversedResourceTypes(newTraversedResourcesTypes); } callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Unable to set traversed resource types"); } } }); options.add(setServiceTypes); if (itemId != null && netPlan.isMultilayer()) { final long demandId = (long) itemId; if (netPlan.getDemandFromId(demandId).isCoupled()) { JMenuItem decoupleDemandItem = new JMenuItem("Decouple demand"); decoupleDemandItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { netPlan.getDemandFromId(demandId).decouple(); model.setValueAt("", row, 3); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges(Collections.singleton(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); options.add(decoupleDemandItem); } else { JMenuItem createUpperLayerLinkFromDemandItem = new JMenuItem("Create upper layer link from demand"); createUpperLayerLinkFromDemandItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection<Long> layerIds = netPlan.getNetworkLayerIds(); final JComboBox layerSelector = new WiderJComboBox(); for (long layerId : layerIds) { if (layerId == netPlan.getNetworkLayerDefault().getId()) continue; final String layerName = netPlan.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; layerSelector.addItem(StringLabeller.of(layerId, layerLabel)); } layerSelector.setSelectedIndex(0); JPanel pane = new JPanel(); pane.add(new JLabel("Select layer: ")); pane.add(layerSelector); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the upper layer to create the link", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long layerId = (long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); netPlan.getDemandFromId(demandId) .coupleToNewLinkCreated(netPlan.getNetworkLayerFromId(layerId)); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.DEMAND, NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error creating upper layer link from demand"); } } } }); options.add(createUpperLayerLinkFromDemandItem); JMenuItem coupleDemandToLink = new JMenuItem("Couple demand to upper layer link"); coupleDemandToLink.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection<Long> layerIds = netPlan.getNetworkLayerIds(); final JComboBox layerSelector = new WiderJComboBox(); final JComboBox linkSelector = new WiderJComboBox(); for (long layerId : layerIds) { if (layerId == netPlan.getNetworkLayerDefault().getId()) continue; final String layerName = netPlan.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; layerSelector.addItem(StringLabeller.of(layerId, layerLabel)); } layerSelector.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (layerSelector.getSelectedIndex() >= 0) { long selectedLayerId = (Long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); NetworkLayer selectedLayer = netPlan.getNetworkLayerFromId(selectedLayerId); linkSelector.removeAllItems(); Collection<Link> links_thisLayer = netPlan.getLinks(selectedLayer); for (Link link : links_thisLayer) { if (link.isCoupled()) continue; String originNodeName = link.getOriginNode().getName(); String destinationNodeName = link.getDestinationNode().getName(); linkSelector.addItem(StringLabeller.unmodifiableOf(link.getId(), "e" + link.getIndex() + " [n" + link.getOriginNode().getIndex() + " (" + originNodeName + ") -> n" + link.getDestinationNode().getIndex() + " (" + destinationNodeName + ")]")); } } if (linkSelector.getItemCount() == 0) { linkSelector.setEnabled(false); } else { linkSelector.setSelectedIndex(0); linkSelector.setEnabled(true); } } }); layerSelector.setSelectedIndex(-1); layerSelector.setSelectedIndex(0); JPanel pane = new JPanel(new MigLayout("", "[][grow]", "[][]")); pane.add(new JLabel("Select layer: ")); pane.add(layerSelector, "growx, wrap"); pane.add(new JLabel("Select link: ")); pane.add(linkSelector, "growx, wrap"); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the upper layer link", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long layerId = (long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); long linkId; try { linkId = (long) ((StringLabeller) linkSelector.getSelectedItem()).getObject(); } catch (Throwable ex) { throw new RuntimeException("No link was selected"); } netPlan.getDemandFromId(demandId) .coupleToUpperLayerLink(netPlan.getLinkFromId(linkId)); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.DEMAND, NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error coupling upper layer link to demand"); } } } }); options.add(coupleDemandToLink); } if (numRows > 1) { JMenuItem decoupleAllDemandsItem = null; JMenuItem createUpperLayerLinksFromDemandsItem = null; final Set<Demand> coupledDemands = tableVisibleDemands.stream().filter(d -> d.isCoupled()) .collect(Collectors.toSet()); if (!coupledDemands.isEmpty()) { decoupleAllDemandsItem = new JMenuItem("Decouple all demands"); decoupleAllDemandsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (Demand d : new LinkedHashSet<Demand>(coupledDemands)) d.decouple(); int numRows = model.getRowCount(); for (int i = 0; i < numRows; i++) model.setValueAt("", i, 3); callback.getVisualizationState().resetPickedState(); callback.updateVisualizationAfterChanges(Sets.newHashSet(NetworkElementType.DEMAND)); callback.getUndoRedoNavigationManager().addNetPlanChange(); } }); } if (coupledDemands.size() < tableVisibleDemands.size()) { createUpperLayerLinksFromDemandsItem = new JMenuItem( "Create upper layer links from uncoupled demands"); createUpperLayerLinksFromDemandsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Collection<Long> layerIds = netPlan.getNetworkLayerIds(); final JComboBox layerSelector = new WiderJComboBox(); for (long layerId : layerIds) { if (layerId == netPlan.getNetworkLayerDefault().getId()) continue; final String layerName = netPlan.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; layerSelector.addItem(StringLabeller.of(layerId, layerLabel)); } layerSelector.setSelectedIndex(0); JPanel pane = new JPanel(); pane.add(new JLabel("Select layer: ")); pane.add(layerSelector); while (true) { int result = JOptionPane.showConfirmDialog(null, pane, "Please select the upper layer to create links", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result != JOptionPane.OK_OPTION) return; try { long layerId = (long) ((StringLabeller) layerSelector.getSelectedItem()) .getObject(); NetworkLayer layer = netPlan.getNetworkLayerFromId(layerId); for (Demand demand : tableVisibleDemands) if (!demand.isCoupled()) demand.coupleToNewLinkCreated(layer); callback.getVisualizationState() .recomputeCanvasTopologyBecauseOfLinkOrNodeAdditionsOrRemovals(); callback.updateVisualizationAfterChanges( Sets.newHashSet(NetworkElementType.DEMAND, NetworkElementType.LINK)); callback.getUndoRedoNavigationManager().addNetPlanChange(); break; } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error creating upper layer links"); } } } }); } if (!options.isEmpty() && (decoupleAllDemandsItem != null || createUpperLayerLinksFromDemandsItem != null)) { options.add(new JPopupMenu.Separator()); if (decoupleAllDemandsItem != null) options.add(decoupleAllDemandsItem); if (createUpperLayerLinksFromDemandsItem != null) options.add(createUpperLayerLinksFromDemandsItem); } } } return options; }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
protected void changeMaxFileSize() { final JPanel panel = new JPanel(); boolean keineLimitierung = iliasProperties.getMaxFileSize() == Long.MAX_VALUE; panel.setLayout(new GridLayout(1, 0)); panel.add(new JLabel("Maximale Dateigre in MB")); final JCheckBox cb = new JCheckBox("Keine Limitierung"); cb.setSelected(keineLimitierung);//from ww w . java 2 s .c om panel.add(cb); final JTextField fieldFileSize = new JTextField( String.valueOf(iliasProperties.getMaxFileSize() / (1024 * 1024))); panel.add(fieldFileSize); fieldFileSize.setVisible(!cb.isSelected()); cb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { fieldFileSize.setVisible(!cb.isSelected()); } }); if (JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(mainFrame, panel, "Maximale Dateigre ndern", JOptionPane.OK_CANCEL_OPTION)) { if (cb.isSelected()) { iliasProperties.setMaxFileSize(Long.MAX_VALUE); } else { iliasProperties.setMaxFileSize(Long.parseLong(fieldFileSize.getText()) * 1024 * 1024); } saveProperties(iliasProperties); } }
From source file:Installer.java
public void run() { JOptionPane optionPane = new JOptionPane(this, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, new String[] { "Install", "Cancel" }); emptyFrame = new Frame("Vivecraft Installer"); emptyFrame.setUndecorated(true);/*www . ja v a 2 s . co m*/ emptyFrame.setVisible(true); emptyFrame.setLocationRelativeTo(null); dialog = optionPane.createDialog(emptyFrame, "Vivecraft Installer"); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); String str = ((String) optionPane.getValue()); if (str != null && ((String) optionPane.getValue()).equalsIgnoreCase("Install")) { int option = JOptionPane.showOptionDialog(null, "Please ensure you have closed the Minecraft launcher before proceeding.\n" //"Also, if installing with Forge please ensure you have installed Forge " + FORGE_VERSION + " first.", , "Important!", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, null, null); if (option == JOptionPane.OK_OPTION) { monitor = new ProgressMonitor(null, "Installing Vivecraft...", "", 0, 100); monitor.setMillisToDecideToPopup(0); monitor.setMillisToPopup(0); task = new InstallTask(); task.addPropertyChangeListener(this); task.execute(); } else { dialog.dispose(); emptyFrame.dispose(); } } else { dialog.dispose(); emptyFrame.dispose(); } }
From source file:com.sshtools.sshterm.SshTerminalPanel.java
public void authenticationComplete(boolean newProfile) throws SshException, IOException { try {//from w w w . j ava2s . c o m SshToolsConnectionProfile profile = getCurrentConnectionProfile(); // We are now connected setContainerTitle(getCurrentConnectionProfile().getHost()); statusBar.setStatusText("Connected"); statusBar.setConnected(true); // Set the connection status setAvailableActions(); // Make sure the terminal has focus terminal.requestFocus(); //If the eol setting is EOL_DEFAULT, then use the // value guessed by j2ssh if (eol == TerminalEmulation.EOL_DEFAULT) { if (ssh.getRemoteEOL() == TransportProtocolCommon.EOL_CRLF) { emulation.setEOL(TerminalEmulation.EOL_CR_LF); } else { emulation.setEOL(TerminalEmulation.EOL_CR); } } if (profile.getOnceAuthenticatedCommand() != SshToolsConnectionProfile.DO_NOTHING) { if (profile.getOnceAuthenticatedCommand() == SshToolsConnectionProfile.EXECUTE_COMMANDS) { BufferedReader reader = new BufferedReader( new StringReader(profile.getCommandsToExecute() + "\n")); String cmd; while ((cmd = reader.readLine()) != null) { if (cmd.trim().length() > 0) { log.info("Executing " + cmd); session = createNewSession(false); if (session.executeCommand(cmd)) { session.bindInputStream(/*new InputStreamMonitor(*/ emulation.getTerminalInputStream()/*)*/); session.bindOutputStream(/*new OutputStreamMonitor(*/ emulation.getTerminalOutputStream()/*)*/); try { session.getState().waitForState(ChannelState.CHANNEL_CLOSED); } catch (InterruptedException ex) { JOptionPane.showMessageDialog(this, "The command was interrupted!", "Interrupted Exception", JOptionPane.OK_OPTION); } } } } if (profile.disconnectOnSessionClose()) { ssh.disconnect(); } } else { // Start the users shell session = createNewSession(true); if (session.startShell()) { session.bindInputStream(/*new InputStreamMonitor(*/ emulation.getTerminalInputStream()/*)*/); session.bindOutputStream(/*new OutputStreamMonitor(*/ emulation.getTerminalOutputStream()/*)*/); } } } log.info("Authentication complete and startup actions performed."); } catch (SshException se) { log.error("authenticationComplete passing on error: " + se); throw se; } catch (IOException ioe) { log.error("authenticationComplete passing on error: " + ioe); throw ioe; } catch (Throwable t) { log.error("authenticationComplete passing on error: " + t); throw new RuntimeException(t); } }
From source file:org.adamkrajcik.gui.MainForm.java
private void deleteCellarMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteCellarMenuItemActionPerformed DeleteCellarSwingWorker deleteCellarSW; if (CellarTable.getSelectedRow() == -1) { JOptionPane.showConfirmDialog(null, langResource.getString("notSelectedCellarMessage"), langResource.getString("error"), JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); return;//from w w w . j a v a2s . c om } Cellar cellar = cellarTableModel.getCellarAtRow(CellarTable.getSelectedRow()); Object[] message = { langResource.getString("deleteCellarMessage"), cellar.toString() }; int option = JOptionPane.showConfirmDialog(null, message, langResource.getString("deleteCellarTitle"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (option == JOptionPane.OK_OPTION) { deleteCellarMenuItem.setEnabled(false); deleteCellarSW = new DeleteCellarSwingWorker(cellar); deleteCellarSW.execute(); } }