List of usage examples for javax.swing JDialog add
public Component add(String name, Component comp)
From source file:org.gofleet.module.routing.RoutingMap.java
private Map<String, String> getValues(LatLon from) { final Map<String, String> mapa = new HashMap<String, String>(); final JDialog frame = new JDialog(basicWindow.getFrame(), "Configuration"); JPanel panel = new JPanel(new GridLayout(0, 2)); int width = 10; final JTextField maxDistance = new JTextField(width); maxDistance.setText("10"); final JTextField maxTime = new JTextField(width); maxTime.setText("8"); final JTextField origin_x = new JTextField(width / 2); origin_x.setText((new Double(from.getX())).toString()); final JTextField origin_y = new JTextField(width / 2); origin_y.setText((new Double(from.getY())).toString()); final JTextField startTime = new JTextField(width); startTime.setText("7"); final JTextField timeSpentOnStop = new JTextField(width); timeSpentOnStop.setText("1"); JLabel lmaxDistance = new JLabel("Maximum Distance (km)"); lmaxDistance.setLabelFor(maxDistance); JLabel lmaxTime = new JLabel("Maximum Time (hours)"); lmaxTime.setLabelFor(maxTime);//from ww w.jav a 2s . com JLabel lorigin = new JLabel("Point of Origin"); lorigin.setLabelFor(origin_x); JLabel lstartTime = new JLabel("Start Time of Plan (0-24)"); lstartTime.setLabelFor(startTime); JLabel ltimeSpentOnStop = new JLabel("Time Spent on Stop (hours)"); ltimeSpentOnStop.setLabelFor(timeSpentOnStop); JButton close = new JButton("OK"); close.addActionListener(new AbstractAction() { private static final long serialVersionUID = -8912729211256933464L; @Override public void actionPerformed(ActionEvent arg0) { try { mapa.put("maxDistance", maxDistance.getText()); mapa.put("maxTime", maxTime.getText()); mapa.put("origin_x", origin_x.getText()); mapa.put("origin_y", origin_y.getText()); mapa.put("startTime", startTime.getText()); mapa.put("timeSpentOnStop", timeSpentOnStop.getText()); frame.dispose(); } catch (Throwable t) { log.error("Error configuring New Route Plan" + t); JOptionPane.showMessageDialog(RoutingMap.this, "Some values are wrong. Check them again."); } } }); panel.add(lmaxDistance); panel.add(maxDistance); panel.add(lmaxTime); panel.add(maxTime); panel.add(lorigin); JPanel panel_origin = new JPanel(); panel_origin.add(origin_x); panel_origin.add(origin_y); panel.add(panel_origin); panel.add(lstartTime); panel.add(startTime); panel.add(ltimeSpentOnStop); panel.add(timeSpentOnStop); panel.add(close); frame.add(panel, BorderLayout.CENTER); frame.pack(); frame.setModalityType(ModalityType.APPLICATION_MODAL); frame.setVisible(true); return mapa; }
From source file:org.interreg.docexplore.authoring.AuthoringMenu.java
public AuthoringMenu(final AuthoringToolFrame authoringTool) { this.tool = authoringTool; this.recent = new LinkedList<String>(); readRecent();// w ww .ja va2s . co m this.file = new JMenu(XMLResourceBundle.getBundledString("generalMenuFile")); add(file); newItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuNew")) { public void actionPerformed(ActionEvent arg0) { newFile(); } }); loadItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuLoad")) { public void actionPerformed(ActionEvent arg0) { load(); } }); saveItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSave")) { public void actionPerformed(ActionEvent arg0) { save(); } }); saveAsItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSaveAs")) { public void actionPerformed(ActionEvent arg0) { saveAs(); } }); exportItem = new JMenuItem( new AbstractAction(XMLResourceBundle.getBundledString("generalMenuExport") + "...") { public void actionPerformed(ActionEvent arg0) { GuiUtils.blockUntilComplete(new ProgressRunnable() { public void run() { try { authoringTool.readerExporter.doExport(authoringTool.editor.link); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } public float getProgress() { return (float) authoringTool.readerExporter.progress[0]; } }, authoringTool.editor); } }); webExportItem = new JMenuItem( new AbstractAction(XMLResourceBundle.getBundledString("generalMenuWebExport") + "...") { public void actionPerformed(ActionEvent arg0) { GuiUtils.blockUntilComplete(new ProgressRunnable() { public void run() { try { authoringTool.webExporter.doExport(authoringTool.editor.link); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } public float getProgress() { return (authoringTool.webExporter.copyComplete ? .5f : 0f) + (float) (.5 * authoringTool.webExporter.progress[0]); } }, authoringTool.editor); } }); // webExportItem = new JMenuItem(new AbstractAction("Web export") {public void actionPerformed(ActionEvent arg0) // { // GuiUtils.blockUntilComplete(new Runnable() {public void run() // { // try // { // new WebStaticExporter().doExport(authoringTool.editor.link.getBook(authoringTool.editor.link.getLink().getAllBookIds().get(0))); // } // catch (Exception ex) {ErrorHandler.defaultHandler.submit(ex);} // }}, authoringTool.editor); // }}); // webExportItem.setEnabled(false); quitItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuQuit")) { public void actionPerformed(ActionEvent arg0) { authoringTool.quit(); } }); buildFileMenu(); JMenu edit = new JMenu(XMLResourceBundle.getBundledString("generalMenuEdit")); this.undoItem = new JMenuItem(); undoItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { authoringTool.historyManager.undo(); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } }); edit.add(undoItem); this.redoItem = new JMenuItem(); redoItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { authoringTool.historyManager.redo(); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } }); edit.add(redoItem); JMenuItem viewHistory = new JMenuItem(XMLResourceBundle.getBundledString("generalMenuEditViewHistory")); viewHistory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { authoringTool.historyDialog.setVisible(true); } }); edit.add(viewHistory); edit.addSeparator(); edit.add(new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("fixChars")) { public void actionPerformed(ActionEvent arg0) { Object res = JOptionPane.showInputDialog(tool, XMLResourceBundle.getBundledString("fixCharsMsg"), XMLResourceBundle.getBundledString("fixChars"), JOptionPane.QUESTION_MESSAGE, null, new Object[] { XMLResourceBundle.getBundledString("fixCharsWin"), XMLResourceBundle.getBundledString("fixCharsMac") }, XMLResourceBundle.getBundledString("fixCharsWin")); if (res == null) return; try { convertPresentation(tool.defaultFile, res.equals(XMLResourceBundle.getBundledString("fixCharsWin")) ? "ISO-8859-1" : "x-MacRoman"); } catch (Exception e) { ErrorHandler.defaultHandler.submit(e); } try { tool.editor.reset(); } catch (Exception e) { e.printStackTrace(); } } })); //TODO: remove! // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // int lastPage = book.getLastPageNumber(); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // Set<Region> regions = page.getRegions(); // if (regions.size() > 2) // { // Region highest = null; // int max = -1; // for (Region region : regions) // for (Point point : region.getOutline()) // if (max < 0 || point.y < max) // {max = point.y; highest = region;} // Region middle = null; // max = -1; // for (Region region : regions) // if (region != highest) // for (Point point : region.getOutline()) // if (max < 0 || point.y < max) // {max = point.y; middle = region;} // if (regions.size() > 3) // { // max = -1; // Region newMiddle = null; // for (Region region : regions) // if (region != highest && region != middle) // for (Point point : region.getOutline()) // if (max < 0 || point.y < max) // {max = point.y; newMiddle = region;} // middle = newMiddle; // } // MetaDataKey display = book.getLink().getKey("display", ""); // for (Map.Entry<MetaDataKey, List<MetaData>> entry : highest.getMetaData().entrySet()) // for (MetaData md : entry.getValue()) // if (md.getType().equals(MetaData.textType)) // { // String val = "<b>"+md.getString()+"</b>\n"; // for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet()) // for (MetaData md2 : entry2.getValue()) // if (md2.getType().equals(MetaData.textType) && TextElement.getStyle(md, tool.styleManager) == TextElement.getStyle(md2, tool.styleManager)) // val = val+"\n"+md2.getString(); // md.setString(val); // } // boolean hasImage = false; // for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet()) // for (MetaData md2 : entry2.getValue()) // if (md2.getType().equals(MetaData.imageType)) // { // MetaData imageMd = new MetaData(book.getLink(), display, md2.getType(), md2.getValue()); // if (!hasImage) // BookImporter.insert(imageMd, highest, 0); // else BookImporter.insert(imageMd, highest, BookImporter.getHighestRank(highest)+1); // hasImage = true; // } // page.removeRegion(middle); // } // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // int lastPage = book.getLastPageNumber(); // MetaDataKey display = book.getLink().getKey("display", ""); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // Set<Region> regions = page.getRegions(); // for (Region region : regions) // { // List<MetaData> mds = region.getMetaDataListForKey(display); // for (MetaData md : mds) // if (md.getType().equals(MetaData.textType)) // { // String val = md.getString().trim(); // if (!val.startsWith("<i>") || !val.endsWith("</i>")) // continue; // TextElement.getStyleMD(md).setString("4"); // md.setString(val.substring(3, val.length()-4)); // System.out.println(md.getString()); // } // } // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // int lastPage = book.getLastPageNumber(); // MetaDataKey display = book.getLink().getKey("display", ""); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // Set<Region> regions = page.getRegions(); // for (Region region : regions) // { // int max = BookImporter.getHighestRank(region); // for (int i=0;i<max;i++) // { // MetaData md1 = BookImporter.getAtRank(region, i); // if (md1 == null || !md1.getType().equals(MetaData.textType)) // continue; // MetaData style1 = TextElement.getStyleMD(md1); // if (!style1.getString().equals("0")) // continue; // MetaData md2 = BookImporter.getAtRank(region, i+1); // if (md2 == null || !md2.getType().equals(MetaData.textType)) // continue; // MetaData style2 = TextElement.getStyleMD(md2); // if (!style2.getString().equals("1")) // continue; // BookImporter.setRank(md1, i+1); // BookImporter.setRank(md2, i); // i++; // } // } // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // MetaDataKey mini = book.getLink().getOrCreateKey("mini", ""); // MetaDataKey dim = book.getLink().getOrCreateKey("dimension", ""); // int lastPage = book.getLastPageNumber(); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // List<MetaData> mds = page.getMetaDataListForKey(mini); // if (mds != null) // for (MetaData md : mds) // page.removeMetaData(md); // mds = page.getMetaDataListForKey(dim); // if (mds != null) // for (MetaData md : mds) // page.removeMetaData(md); // DocExploreDataLink.getImageDimension(page, true); // DocExploreDataLink.getImageMini(page, false); // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); add(edit); JMenu view = new JMenu(XMLResourceBundle.getBundledString("generalMenuView")); add(view); JMenuItem styles = new JMenuItem(XMLResourceBundle.getBundledString("styleEdit") + "...", ImageUtils.getIcon("pencil-24x24.png")); styles.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { authoringTool.styleManager.styleDialog.setVisible(true); } }); view.add(styles); helpToggle = new JCheckBoxMenuItem( new AbstractAction(XMLResourceBundle.getBundledString("viewHelpToggle")) { public void actionPerformed(ActionEvent arg0) { authoringTool.displayHelp = helpToggle.isSelected(); authoringTool.repaint(); } }); helpToggle.setSelected(tool.startup.showHelp); view.add(helpToggle); JMenu helpMenu = new JMenu(XMLResourceBundle.getString("management-lrb", "generalMenuHelp")); if (Desktop.isDesktopSupported()) { final Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { helpMenu.add(new AbstractAction( XMLResourceBundle.getString("management-lrb", "generalMenuHelpContents")) { public void actionPerformed(ActionEvent e) { try { File doc = new File(DocExploreTool.getExecutableDir(), "MMT documentation.htm"); desktop.open(doc); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex, true); } } }); helpMenu.add(new AbstractAction( XMLResourceBundle.getString("management-lrb", "generalMenuHelpWebsite")) { public void actionPerformed(ActionEvent e) { try { File link = new File(DocExploreTool.getExecutableDir(), "website.url"); desktop.open(link); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex, true); } } }); } } helpMenu.add(new AbstractAction(XMLResourceBundle.getString("management-lrb", "generalMenuHelpAbout")) { public void actionPerformed(ActionEvent e) { final JDialog splash = new JDialog(tool, true); splash.setLayout(new BorderLayout()); SplashScreen screen = new SplashScreen("logoAT.png"); splash.add(screen, BorderLayout.NORTH); screen.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { splash.setVisible(false); } }); splash.setUndecorated(true); screen.setText( "<html>DocExplore 2009-2014" + "<br/>Released under the CeCILL v2.1 license" + "</html>"); splash.pack(); splash.setAlwaysOnTop(true); GuiUtils.centerOnScreen(splash); splash.setVisible(true); } }); add(helpMenu); historyChanged(authoringTool.historyManager); authoringTool.historyManager.addHistoryListener(this); }
From source file:org.nuclos.client.relation.EntityRelationshipModelEditPanel.java
private void editMasterdataRelation(mxCell cell) { EntityFieldMetaDataVO voField = null; RelationAttributePanel panel = new RelationAttributePanel(RelationAttributePanel.TYPE_ENTITY); String sSource = ""; String sTarget = ""; EntityMetaDataVO voSourceModify = null; if (cell.getValue() != null && cell.getValue() instanceof EntityFieldMetaDataVO) { voField = (EntityFieldMetaDataVO) cell.getValue(); EntityMetaDataVO voSource = (EntityMetaDataVO) cell.getSource().getValue(); voSourceModify = voSource;//from w ww . j a va 2s .co m EntityMetaDataVO voTarget = (EntityMetaDataVO) cell.getTarget().getValue(); sSource = voSource.getEntity(); sTarget = voTarget.getEntity(); EntityMetaDataVO voForeign = MetaDataClientProvider.getInstance().getEntity(voSource.getEntity()); EntityMetaDataVO voEntity = MetaDataClientProvider.getInstance().getEntity(voTarget.getEntity()); panel.setEntity(voEntity); panel.setEntitySource(voForeign); panel.setEntityFields( MetaDataDelegate.getInstance().getAllEntityFieldsByEntity(voForeign.getEntity()).values()); if (voField.getId() != null) { voField = MetaDataClientProvider.getInstance().getEntityField(voForeign.getEntity(), voField.getField()); List<TranslationVO> lstTranslation = new ArrayList<TranslationVO>(); for (LocaleInfo lInfo : LocaleDelegate.getInstance().getAllLocales(false)) { Map<String, String> mp = new HashMap<String, String>(); mp.put(TranslationVO.labelsField[0], LocaleDelegate.getInstance().getResourceByStringId(lInfo, voField.getLocaleResourceIdForLabel())); mp.put(TranslationVO.labelsField[1], LocaleDelegate.getInstance().getResourceByStringId(lInfo, voField.getLocaleResourceIdForDescription())); TranslationVO voTrans = new TranslationVO(lInfo.localeId, lInfo.title, lInfo.language, mp); lstTranslation.add(voTrans); } panel.setTranslation(lstTranslation); panel.setFieldValues(voField); } else { MyGraphModel model = (MyGraphModel) graphComponent.getGraph().getModel(); panel.setFieldValues(voField); panel.setTranslationAndMore(model.getTranslation().get(voField)); } } else if (cell.getValue() != null && cell.getValue() instanceof String) { EntityMetaDataVO voSource = (EntityMetaDataVO) cell.getSource().getValue(); EntityMetaDataVO voTarget = (EntityMetaDataVO) cell.getTarget().getValue(); sSource = voSource.getEntity(); sTarget = voTarget.getEntity(); EntityMetaDataVO voForeign = MetaDataClientProvider.getInstance().getEntity(voSource.getEntity()); EntityMetaDataVO voEntity = MetaDataClientProvider.getInstance().getEntity(voTarget.getEntity()); voSourceModify = voForeign; panel.setEntity(voEntity); panel.setEntitySource(voForeign); panel.setEntityFields( MetaDataDelegate.getInstance().getAllEntityFieldsByEntity(voSource.getEntity()).values()); } double cellsDialog[][] = { { 5, TableLayout.PREFERRED, 5 }, { 5, TableLayout.PREFERRED, 5 } }; JDialog dia = new JDialog(mf); dia.setLayout(new TableLayout(cellsDialog)); dia.setTitle("Verbindung von " + sSource + " zu " + sTarget + " bearbeiten"); dia.setLocationRelativeTo(EntityRelationshipModelEditPanel.this); dia.add(panel, "1,1"); dia.setModal(true); panel.setDialog(dia); dia.pack(); dia.setVisible(true); if (panel.getState() == 1) { EntityFieldMetaDataVO vo = panel.getField(); cell.setValue(vo); EntityRelationshipModelEditPanel.this.fireChangeListenEvent(); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(vo); toField.setTranslation(panel.getTranslation().getRows()); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(voSourceModify, toList); MyGraphModel model = (MyGraphModel) graphComponent.getGraph().getModel(); model.getTranslation().put(vo, panel.getTranslation().getRows()); getGraphComponent().refresh(); loadReferenz(); } else { if (cell.getValue() instanceof String) getGraphModel().remove(cell); } }
From source file:org.nuclos.client.relation.MyGraphModel.java
public JPopupMenu createRelationPopupMenu(final mxCell cell, boolean delete) { final JPopupMenu pop = new JPopupMenu(); JMenuItem i1 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.1", "Bezug zu Stammdaten")); i1.addActionListener(new ActionListener() { @Override/*ww w . ja v a 2 s .c o m*/ public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_OPEN); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); RelationAttributePanel panel = new RelationAttributePanel(RelationAttributePanel.TYPE_ENTITY); mxCell target = (mxCell) cell.getTarget(); mxCell source = (mxCell) cell.getSource(); panel.setEntity((EntityMetaDataVO) target.getValue()); panel.setEntitySource((EntityMetaDataVO) source.getValue()); EntityMetaDataVO voSource = (EntityMetaDataVO) source.getValue(); EntityMetaDataVO voTarget = (EntityMetaDataVO) target.getValue(); panel.setEntityFields( MetaDataDelegate.getInstance().getAllEntityFieldsByEntity(voSource.getEntity()).values()); double cellsDialog[][] = { { 5, TableLayout.PREFERRED, 5 }, { 5, TableLayout.PREFERRED, 5 } }; JDialog dia = new JDialog(mf); dia.setLayout(new TableLayout(cellsDialog)); dia.setTitle(getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.10", "Bezug zu Stammdaten bearbeiten")); dia.setLocationRelativeTo(editPanel); dia.add(panel, "1,1"); dia.setModal(true); panel.setDialog(dia); dia.pack(); dia.setVisible(true); if (panel.getState() == 1) { EntityFieldMetaDataVO vo = panel.getField(); cell.setValue(vo); mpTransation.put(vo, panel.getTranslation().getRows()); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(vo); toField.setTranslation(panel.getTranslation().getRows()); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(voSource, toList); editPanel.loadReferenz(); } else { remove(cell); } } }); final JMenuItem i2 = new JMenuItem(getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.3", "Bezug zu Vorg\u00e4ngen (Unterformularbezug)")); i2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_DIAMOND); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); mxCell target = (mxCell) cell.getTarget(); mxCell source = (mxCell) cell.getSource(); EntityMetaDataVO voSource = (EntityMetaDataVO) source.getValue(); EntityMetaDataVO voTarget = (EntityMetaDataVO) target.getValue(); String sFieldName = null; boolean blnNotSet = true; while (blnNotSet) { sFieldName = JOptionPane.showInputDialog(editPanel, getSpringLocaleDelegate().getMessage( "nuclos.entityrelation.editor.1", "Bitte geben Sie den Namen des Feldes an!")); if (sFieldName == null || sFieldName.length() < 1) { MyGraphModel.this.remove(cell); return; } else if (sFieldName != null) { blnNotSet = false; } } EntityFieldMetaDataVO vo = new EntityFieldMetaDataVO(); vo.setModifiable(true); vo.setLogBookTracking(false); vo.setReadonly(false); vo.setShowMnemonic(true); vo.setInsertable(true); vo.setSearchable(true); vo.setNullable(false); vo.setUnique(true); vo.setDataType("java.lang.String"); List<TranslationVO> lstTranslation = new ArrayList<TranslationVO>(); for (LocaleInfo voLocale : LocaleDelegate.getInstance().getAllLocales(false)) { String sLocaleLabel = voLocale.language; Integer iLocaleID = voLocale.localeId; String sCountry = voLocale.title; Map<String, String> map = new HashMap<String, String>(); TranslationVO translation = new TranslationVO(iLocaleID, sCountry, sLocaleLabel, map); for (String sLabel : labels) { translation.getLabels().put(sLabel, sFieldName); } lstTranslation.add(translation); } vo.setForeignEntity(voTarget.getEntity()); vo.setField(sFieldName); vo.setDbColumn("INTID_" + sFieldName); cell.setValue(vo); List<EntityFieldMetaDataTO> toList = new ArrayList<EntityFieldMetaDataTO>(); EntityFieldMetaDataTO toField = new EntityFieldMetaDataTO(); toField.setEntityFieldMeta(vo); toField.setTranslation(lstTranslation); toList.add(toField); MetaDataDelegate.getInstance().modifyEntityMetaData(voSource, toList); editPanel.loadReferenz(); } }); final JMenuItem i4 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.5", "Arbeitsschritt")); i4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editPanel.setIsPopupShown(false); if (cell.getTarget() == null || cell.getSource() == null) { remove(cell); return; } Object cells[] = { cell }; mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDARROW, mxConstants.ARROW_OVAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ENDSIZE, "12"); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL); mxUtils.setCellStyles(graphComponent.getGraph().getModel(), cells, EDGESTYLE, ELBOWCONNECTOR); try { mxCell cellSource = (mxCell) cell.getSource(); mxCell cellTarget = (mxCell) cell.getTarget(); EntityMetaDataVO sourceModule = (EntityMetaDataVO) cellSource.getValue(); EntityMetaDataVO targetModule = (EntityMetaDataVO) cellTarget.getValue(); String sSourceModule = sourceModule.getEntity(); String sTargetModule = targetModule.getEntity(); boolean blnFound = false; for (MasterDataVO voGeneration : MasterDataCache.getInstance() .get(NuclosEntity.GENERATION.getEntityName())) { String sSource = (String) voGeneration.getField("sourceModule"); String sTarget = (String) voGeneration.getField("targetModule"); if (org.apache.commons.lang.StringUtils.equals(sSource, sSourceModule) && org.apache.commons.lang.StringUtils.equals(sTarget, sTargetModule)) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); gcc.runViewSingleCollectableWithId(voGeneration.getId()); blnFound = true; break; } } if (!blnFound) { GenerationCollectController gcc = (GenerationCollectController) NuclosCollectControllerFactory .getInstance().newMasterDataCollectController( NuclosEntity.GENERATION.getEntityName(), null, null); Map<String, Object> mp = new HashMap<String, Object>(); mp.put("sourceModule", sSourceModule); mp.put("sourceModuleId", new Integer( MetaDataClientProvider.getInstance().getEntity(sSourceModule).getId().intValue())); mp.put("targetModule", sTargetModule); mp.put("targetModuleId", new Integer( MetaDataClientProvider.getInstance().getEntity(sTargetModule).getId().intValue())); MasterDataVO vo = new MasterDataVO(NuclosEntity.GENERATION.getEntityName(), null, null, null, null, null, null, mp); gcc.runWithNewCollectableWithSomeFields(vo); } } catch (NuclosBusinessException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonPermissionException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonFatalException e1) { LOG.warn("actionPerformed: " + e1); } catch (CommonBusinessException e1) { LOG.warn("actionPerformed: " + e1); } } }); JMenuItem i5 = new JMenuItem( getSpringLocaleDelegate().getMessage("nuclos.entityrelation.editor.12", "Verbindung l\u00f6sen")); i5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mxGraphModel model = (mxGraphModel) graphComponent.getGraph().getModel(); model.remove(cell); } }); pop.add(i1); pop.add(i2); //pop.add(i3); pop.add(i4); if (delete) { pop.addSeparator(); pop.add(i5); } return pop; }
From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java
/** * Singleton pattern : private constructor Use instead. *//*from ww w. j a v a 2 s . c om*/ private MMMainFrame() { super(NODE_NAME, false, true, false, true); instancing = true; // -------------- // INITIALIZATION // -------------- _sysConfigFile = ""; _isConfigLoaded = false; _root = PluginPreferences.getPreferences().node(NODE_NAME); final MainFrame mainFrame = Icy.getMainInterface().getMainFrame(); // -------------- // PROGRESS FRAME // -------------- ThreadUtil.invokeLater(new Runnable() { @Override public void run() { _progressFrame = new IcyFrame("", false, false, false, false); _progressBar = new JProgressBar(); _progressBar.setString("Please wait while loading..."); _progressBar.setStringPainted(true); _progressBar.setIndeterminate(true); _progressBar.setMinimum(0); _progressBar.setMaximum(1000); _progressBar.setBounds(50, 50, 100, 30); _progressFrame.setSize(300, 100); _progressFrame.setResizable(false); _progressFrame.add(_progressBar); _progressFrame.addToMainDesktopPane(); loadConfig(true); if (_sysConfigFile == "") { instancing = false; return; } ThreadUtil.bgRun(new Runnable() { @Override public void run() { while (!_isConfigLoaded) { if (!instancing) return; try { Thread.sleep(10); } catch (InterruptedException e) { } } ThreadUtil.invokeLater(new Runnable() { @Override public void run() { // -------------------- // START INITIALIZATION // -------------------- if (_progressBar != null) getContentPane().remove(_progressBar); if (mCore == null) { close(); return; } // ReportingUtils.setCore(mCore); _afMgr = new AutofocusManager(MMMainFrame.this); acqMgr = new AcquisitionManager(); PositionList posList = new PositionList(); _camera_label = MMCoreJ.getG_Keyword_CameraName(); if (_camera_label == null) _camera_label = ""; try { setPositionList(posList); } catch (MMScriptException e1) { e1.printStackTrace(); } posListDlg_ = new PositionListDlg(mCore, MMMainFrame.this, _posList, null, dlg); posListDlg_.setModalityType(ModalityType.APPLICATION_MODAL); callback = new EventCallBackManager(); mCore.registerCallback(callback); engine_ = new AcquisitionWrapperEngineIcy(); engine_.setParentGUI(MMMainFrame.this); engine_.setCore(mCore, getAutofocusManager()); engine_.setPositionList(getPositionList()); setSystemMenuCallback(new MenuCallback() { @Override public JMenu getMenu() { JMenu toReturn = MMMainFrame.this.getDefaultSystemMenu(); JMenuItem hconfig = new JMenuItem("Configuration Wizard"); hconfig.setIcon(new IcyIcon("cog", MENU_ICON_SIZE)); hconfig.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (!_pluginListEmpty && !ConfirmDialog.confirm("Are you sure ?", "<html>Loading the Configuration Wizard will unload all the devices and pause all running acquisitions.</br> Are you sure you want to continue ?</html>")) return; notifyConfigAboutToChange(null); try { mCore.unloadAllDevices(); } catch (Exception e1) { e1.printStackTrace(); } String previous_config = _sysConfigFile; ConfiguratorDlg2 configurator = new ConfiguratorDlg2(mCore, _sysConfigFile); configurator.setVisible(true); String res = configurator.getFileName(); if (_sysConfigFile == "" || _sysConfigFile == res || res == "") { _sysConfigFile = previous_config; loadConfig(); } refreshGUI(); notifyConfigChanged(null); } }); JMenuItem menuPxSizeConfigItem = new JMenuItem("Pixel Size Config"); menuPxSizeConfigItem.setIcon(new IcyIcon("link", MENU_ICON_SIZE)); menuPxSizeConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK)); menuPxSizeConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { CalibrationListDlg dlg = new CalibrationListDlg(mCore); dlg.setDefaultCloseOperation(2); dlg.setParentGUI(MMMainFrame.this); dlg.setVisible(true); dlg.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { super.windowClosed(e); notifyConfigChanged(null); } }); notifyConfigAboutToChange(null); } }); JMenuItem loadConfigItem = new JMenuItem("Load Configuration"); loadConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK)); loadConfigItem.setIcon(new IcyIcon("folder_open", MENU_ICON_SIZE)); loadConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loadConfig(); initializeGUI(); refreshGUI(); } }); JMenuItem saveConfigItem = new JMenuItem("Save Configuration"); saveConfigItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.SHIFT_DOWN_MASK | SHORTCUTKEY_MASK)); saveConfigItem.setIcon(new IcyIcon("save", MENU_ICON_SIZE)); saveConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveConfig(); } }); JMenuItem advancedConfigItem = new JMenuItem("Advanced Configuration"); advancedConfigItem.setIcon(new IcyIcon("wrench_plus", MENU_ICON_SIZE)); advancedConfigItem.addActionListener(new ActionListener() { /** */ @Override public void actionPerformed(ActionEvent e) { new ToolTipFrame( "<html><h3>About Advanced Config</h3><p>Advanced Configuration is a tool " + "in which you fill some data <br/>about your configuration that some " + "plugins may need to access to.<br/> Exemple: the real values of the magnification" + "of your objectives.</p></html>", "MM4IcyAdvancedConfig"); if (advancedDlg == null) advancedDlg = new AdvancedConfigurationDialog(); advancedDlg.setVisible(!advancedDlg.isVisible()); advancedDlg.setLocationRelativeTo(mainFrame); } }); JMenuItem loadPresetConfigItem = new JMenuItem( "Load Configuration Presets"); loadPresetConfigItem.setIcon(new IcyIcon("doc_import", MENU_ICON_SIZE)); loadPresetConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { notifyConfigAboutToChange(null); loadPresets(); notifyConfigChanged(null); } }); JMenuItem savePresetConfigItem = new JMenuItem( "Save Configuration Presets"); savePresetConfigItem.setIcon(new IcyIcon("doc_export", MENU_ICON_SIZE)); savePresetConfigItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { savePresets(); } }); JMenuItem aboutItem = new JMenuItem("About"); aboutItem.setIcon(new IcyIcon("info", MENU_ICON_SIZE)); aboutItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JDialog dialog = new JDialog(mainFrame, "About"); JPanel panel_container = new JPanel(); panel_container .setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); JPanel center = new JPanel(new BorderLayout()); final JLabel value = new JLabel("<html><body>" + "<h2>About</h2><p>Micro-Manager for Icy is being developed by Thomas Provoost." + "<br/>Copyright 2011, Institut Pasteur</p><br/>" + "<p>This plugin is based on Micro-Manager v1.4.6. which is developed under the following license:<br/>" + "<i>This software is distributed free of charge in the hope that it will be<br/>" + "useful, but WITHOUT ANY WARRANTY; without even the implied<br/>" + "warranty of merchantability or fitness for a particular purpose. In no<br/>" + "event shall the copyright owner or contributors be liable for any direct,<br/>" + "indirect, incidental spacial, examplary, or consequential damages.<br/>" + "Copyright University of California San Francisco, 2007, 2008, 2009,<br/>" + "2010. All rights reserved.</i>" + "</p>" + "</body></html>"); JLabel link = new JLabel( "<html><a href=\"\">For more information, please follow this link.</a></html>"); link.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseevent) { NetworkUtil.openBrowser( "http://valelab.ucsf.edu/~MM/MMwiki/index.php/Micro-Manager"); } }); value.setSize(new Dimension(50, 18)); value.setAlignmentX(SwingConstants.HORIZONTAL); value.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0)); center.add(value, BorderLayout.CENTER); center.add(link, BorderLayout.SOUTH); JPanel panel_south = new JPanel(); panel_south.setLayout(new BoxLayout(panel_south, BoxLayout.X_AXIS)); JButton btn = new JButton("OK"); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionevent) { dialog.dispose(); } }); panel_south.add(Box.createHorizontalGlue()); panel_south.add(btn); panel_south.add(Box.createHorizontalGlue()); dialog.setLayout(new BorderLayout()); panel_container.setLayout(new BorderLayout()); panel_container.add(center, BorderLayout.CENTER); panel_container.add(panel_south, BorderLayout.SOUTH); dialog.add(panel_container, BorderLayout.CENTER); dialog.setResizable(false); dialog.setVisible(true); dialog.pack(); dialog.setLocation( (int) mainFrame.getSize().getWidth() / 2 - dialog.getWidth() / 2, (int) mainFrame.getSize().getHeight() / 2 - dialog.getHeight() / 2); dialog.setLocationRelativeTo(mainFrame); } }); JMenuItem propertyBrowserItem = new JMenuItem("Property Browser"); propertyBrowserItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, SHORTCUTKEY_MASK)); propertyBrowserItem.setIcon(new IcyIcon("db", MENU_ICON_SIZE)); propertyBrowserItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editor.setVisible(!editor.isVisible()); } }); int idx = 0; toReturn.insert(hconfig, idx++); toReturn.insert(loadConfigItem, idx++); toReturn.insert(saveConfigItem, idx++); toReturn.insert(advancedConfigItem, idx++); toReturn.insertSeparator(idx++); toReturn.insert(loadPresetConfigItem, idx++); toReturn.insert(savePresetConfigItem, idx++); toReturn.insertSeparator(idx++); toReturn.insert(propertyBrowserItem, idx++); toReturn.insert(menuPxSizeConfigItem, idx++); toReturn.insertSeparator(idx++); toReturn.insert(aboutItem, idx++); return toReturn; } }); saveConfigButton_ = new JButton("Save Button"); // SETUP _groupPad = new ConfigGroupPad(); _groupPad.setParentGUI(MMMainFrame.this); _groupPad.setFont(new Font("", 0, 10)); _groupPad.setCore(mCore); _groupPad.setParentGUI(MMMainFrame.this); _groupButtonsPanel = new ConfigButtonsPanel(); _groupButtonsPanel.setCore(mCore); _groupButtonsPanel.setGUI(MMMainFrame.this); _groupButtonsPanel.setConfigPad(_groupPad); // LEFT PART OF INTERFACE _panelConfig = new JPanel(); _panelConfig.setLayout(new BoxLayout(_panelConfig, BoxLayout.Y_AXIS)); _panelConfig.add(_groupPad, BorderLayout.CENTER); _panelConfig.add(_groupButtonsPanel, BorderLayout.SOUTH); _panelConfig.setPreferredSize(new Dimension(300, 300)); // MIDDLE PART OF INTERFACE _panel_cameraSettings = new JPanel(); _panel_cameraSettings.setLayout(new GridLayout(5, 2)); _panel_cameraSettings.setMinimumSize(new Dimension(100, 200)); _txtExposure = new JTextField(); try { mCore.setExposure(90.0D); _txtExposure.setText(String.valueOf(mCore.getExposure())); } catch (Exception e2) { _txtExposure.setText("90"); } _txtExposure.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); _txtExposure.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent keyevent) { if (keyevent.getKeyCode() == KeyEvent.VK_ENTER) setExposure(); } }); _panel_cameraSettings.add(new JLabel("Exposure [ms]: ")); _panel_cameraSettings.add(_txtExposure); _combo_binning = new JComboBox(); _combo_binning.setMaximumRowCount(4); _combo_binning.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); _combo_binning.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { changeBinning(); } }); _panel_cameraSettings.add(new JLabel("Binning: ")); _panel_cameraSettings.add(_combo_binning); _combo_shutters = new JComboBox(); _combo_shutters.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { if (_combo_shutters.getSelectedItem() != null) { mCore.setShutterDevice((String) _combo_shutters.getSelectedItem()); _prefs.put(PREF_SHUTTER, (String) _combo_shutters .getItemAt(_combo_shutters.getSelectedIndex())); } } catch (Exception e) { e.printStackTrace(); } } }); _combo_shutters.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); _panel_cameraSettings.add(new JLabel("Shutter : ")); _panel_cameraSettings.add(_combo_shutters); ActionListener action_listener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateHistogram(); } }; _cbAbsoluteHisto = new JCheckBox(); _cbAbsoluteHisto.addActionListener(action_listener); _cbAbsoluteHisto.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionevent) { _comboBitDepth.setEnabled(_cbAbsoluteHisto.isSelected()); _prefs.putBoolean(PREF_ABS_HIST, _cbAbsoluteHisto.isSelected()); } }); _panel_cameraSettings.add(new JLabel("Display absolute histogram ?")); _panel_cameraSettings.add(_cbAbsoluteHisto); _comboBitDepth = new JComboBox(new String[] { "8-bit", "9-bit", "10-bit", "11-bit", "12-bit", "13-bit", "14-bit", "15-bit", "16-bit" }); _comboBitDepth.addActionListener(action_listener); _comboBitDepth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionevent) { _prefs.putInt(PREF_BITDEPTH, _comboBitDepth.getSelectedIndex()); } }); _comboBitDepth.setMaximumSize(new Dimension(Integer.MAX_VALUE, 20)); _comboBitDepth.setEnabled(false); _panel_cameraSettings.add(new JLabel("Select your bit depth for abs. hitogram: ")); _panel_cameraSettings.add(_comboBitDepth); // Acquisition _panelAcquisitions = new JPanel(); _panelAcquisitions.setLayout(new BoxLayout(_panelAcquisitions, BoxLayout.Y_AXIS)); // Color settings _panelColorChooser = new JPanel(); _panelColorChooser.setLayout(new BoxLayout(_panelColorChooser, BoxLayout.Y_AXIS)); painterPreferences = MicroscopePainterPreferences.getInstance(); painterPreferences.setPreferences(_prefs.node("paintersPreferences")); painterPreferences.loadColors(); HashMap<String, Color> allColors = painterPreferences.getColors(); String[] allKeys = (String[]) allColors.keySet().toArray(new String[0]); String[] columnNames = { "Painter", "Color", "Transparency" }; Object[][] data = new Object[allKeys.length][3]; for (int i = 0; i < allKeys.length; ++i) { final int actualRow = i; String actualKey = allKeys[i].toString(); data[i][0] = actualKey; data[i][1] = allColors.get(actualKey); final JSlider slider = new JSlider(0, 255, allColors.get(actualKey).getAlpha()); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent changeevent) { painterTable.setValueAt(slider, actualRow, 2); } }); data[i][2] = slider; } final AbstractTableModel tableModel = new JTableEvolvedModel(columnNames, data); painterTable = new JTable(tableModel); painterTable.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent tablemodelevent) { if (tablemodelevent.getType() == TableModelEvent.UPDATE) { int row = tablemodelevent.getFirstRow(); int col = tablemodelevent.getColumn(); String columnName = tableModel.getColumnName(col); String painterName = (String) tableModel.getValueAt(row, 0); if (columnName.contains("Color")) { // New color value int alpha = painterPreferences.getColor(painterName).getAlpha(); Color coloNew = (Color) tableModel.getValueAt(row, 1); painterPreferences.setColor(painterName, new Color(coloNew.getRed(), coloNew.getGreen(), coloNew.getBlue(), alpha)); } else if (columnName.contains("Transparency")) { // New alpha value Color c = painterPreferences.getColor(painterName); int alphaValue = ((JSlider) tableModel.getValueAt(row, 2)) .getValue(); painterPreferences.setColor(painterName, new Color(c.getRed(), c.getGreen(), c.getBlue(), alphaValue)); } /* * for (int i = 0; i < * tableModel.getRowCount(); ++i) { try { * String painterName = (String) * tableModel.getValueAt(i, 0); Color c = * (Color) tableModel.getValueAt(i, 1); int * alphaValue; if (ASpinnerChanged && * tablemodelevent.getFirstRow() == i) { * alphaValue = ((JSlider) * tableModel.getValueAt(i, 2)).getValue(); * } else { alphaValue = * painterPreferences.getColor * (painterPreferences * .getPainterName(i)).getAlpha(); } * painterPreferences.setColor(painterName, * new Color(c.getRed(), c.getGreen(), * c.getBlue(), alphaValue)); } catch * (Exception e) { System.out.println( * "error with painter table update"); } } */ } } }); painterTable.setPreferredScrollableViewportSize(new Dimension(500, 70)); painterTable.setFillsViewportHeight(true); // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(painterTable); // Set up renderer and editor for the Favorite Color // column. painterTable.setDefaultRenderer(Color.class, new ColorRenderer(true)); painterTable.setDefaultEditor(Color.class, new ColorEditor()); painterTable.setDefaultRenderer(JSlider.class, new SliderRenderer(0, 255)); painterTable.setDefaultEditor(JSlider.class, new SliderEditor()); _panelColorChooser.add(scrollPane); _panelColorChooser.add(Box.createVerticalGlue()); _mainPanel = new JPanel(); _mainPanel.setLayout(new BorderLayout()); // EDITOR // will refresh the data and verify if any change // occurs. // editor = new PropertyEditor(MMMainFrame.this); // editor.setCore(mCore); // editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); // editor.addToMainDesktopPane(); // editor.refresh(); // editor.start(); editor = new PropertyEditor(); editor.setGui(MMMainFrame.this); editor.setCore(mCore); editor.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); // editor.addToMainDesktopPane(); // editor.refresh(); // editor.start(); add(_mainPanel); initializeGUI(); loadPreferences(); refreshGUI(); setResizable(true); addToMainDesktopPane(); instanced = true; instancing = false; _singleton = MMMainFrame.this; setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addFrameListener(new IcyFrameAdapter() { @Override public void icyFrameClosing(IcyFrameEvent e) { customClose(); } }); acceptListener = new AcceptListener() { @Override public boolean accept(Object source) { close(); return _pluginListEmpty; } }; adapter = new MainAdapter() { @Override public void sequenceOpened(MainEvent event) { updateHistogram(); } }; Icy.getMainInterface().addCanExitListener(acceptListener); Icy.getMainInterface().addListener(adapter); } }); } }); } }); }
From source file:ro.nextreports.designer.action.chart.PreviewChartAction.java
public void actionPerformed(ActionEvent event) { executorThread = new Thread(new Runnable() { public void run() { if (ChartUtil.chartUndefined(chart)) { return; }//from w w w . j av a 2 s .c o m ParametersBean pBean = NextReportsUtil.selectParameters(chart.getReport(), null); if (pBean == null) { return; } UIActivator activator = new UIActivator(Globals.getMainFrame(), I18NSupport.getString("preview.chart.execute")); activator.start(new PreviewStopAction()); ChartWebServer webServer = ChartWebServer.getInstance(); String webRoot = webServer.getWebRoot(); ChartRunner runner = new ChartRunner(); runner.setFormat(chartRunnerType); runner.setGraphicType(chartGraphicType); runner.setChart(chart); runner.setQueryTimeout(Globals.getQueryTimeout()); runner.setParameterValues(pBean.getParamValues()); I18nLanguage language = I18nUtil.getDefaultLanguage(chart); if (language != null) { runner.setLanguage(language.getName()); } if (ChartRunner.IMAGE_FORMAT.equals(runner.getFormat())) { runner.setImagePath(Globals.USER_DATA_DIR + "/reports"); } Connection con = null; try { DataSource runDS = Globals.getChartLayoutPanel().getRunDataSource(); boolean csv = runDS.getDriver().equals(CSVDialect.DRIVER_CLASS); con = Globals.createTempConnection(runDS); runner.setConnection(con, csv); if (ChartRunner.IMAGE_FORMAT.equals(runner.getFormat())) { runner.run(); JDialog dialog = new JDialog(Globals.getMainFrame(), ""); dialog.setBackground(Color.WHITE); dialog.setLayout(new BorderLayout()); ShowImagePanel panel = new ShowImagePanel(runner.getChartImageAbsolutePath()); dialog.add(panel, BorderLayout.CENTER); dialog.pack(); dialog.setResizable(false); Show.centrateComponent(Globals.getMainFrame(), dialog); dialog.setVisible(true); } else { String jsonFile = "data.json"; if (ChartRunner.HTML5_TYPE == runner.getGraphicType()) { jsonFile = "data-html5.json"; } OutputStream outputStream = new FileOutputStream(webRoot + File.separatorChar + jsonFile); boolean result = runner.run(outputStream); outputStream.close(); if (result) { if (!webServer.isStarted()) { webServer.start(); } if (ChartRunner.HTML5_TYPE == runner.getGraphicType()) { FileUtil.openUrl( "http://localhost:" + Globals.getChartWebServerPort() + "/chart-html5.html", PreviewChartAction.class); } else { FileUtil.openUrl("http://localhost:" + Globals.getChartWebServerPort() + "/chart.html?ofc=data.json", PreviewChartAction.class); } } } } catch (NoDataFoundException e) { Show.info(I18NSupport.getString("run.nodata")); } catch (InterruptedException e) { Show.dispose(); // close a possible previous dialog message Show.info(I18NSupport.getString("preview.cancel")); } catch (Exception e) { e.printStackTrace(); Show.error(e); } finally { if (con != null) { try { con.close(); } catch (SQLException e) { e.printStackTrace(); LOG.error(e.getMessage(), e); } } stop = false; if (activator != null) { activator.stop(); activator = null; } // restore old parameters if chart was runned from tree if (oldParameters != null) { ParameterManager.getInstance().setParameters(oldParameters); } } } }, "NEXT : " + getClass().getSimpleName()); executorThread.setPriority(EngineProperties.getRunPriority()); executorThread.start(); }