List of usage examples for javax.swing.event ChangeListener ChangeListener
ChangeListener
From source file:gtu._work.ui.JarFinderUI.java
private void initGUI() { try {/*from w w w . j av a 2 s .c o m*/ BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setTitle("Jar finder"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("src dir", null, jPanel1, null); { openDir = new JButton(); jPanel1.add(openDir, BorderLayout.NORTH); openDir.setText("open dir"); openDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton1ActionPerformed(evt); } }); } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(406, 255)); { DefaultListModel jList1Model = new DefaultListModel(); try { prop.load(new FileInputStream(CONFIG_FILE)); for (Enumeration<?> enu = prop.keys(); enu.hasMoreElements();) { File val = new File((String) enu.nextElement()); jList1Model.addElement(val); } } catch (Exception ex) { JCommonUtil.handleException("??:" + CONFIG_FILE, ex); } jarFileDirs = new JList(); jScrollPane1.setViewportView(jarFileDirs); jarFileDirs.setModel(jList1Model); jarFileDirs.setPreferredSize(new java.awt.Dimension(406, 221)); jarFileDirs.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (!JListUtil.newInstance(jarFileDirs).isCorrectMouseClick(evt)) { return; } File file = (File) JListUtil.getLeadSelectionObject(jarFileDirs); try { Desktop.getDesktop().open(file); } catch (IOException e) { JCommonUtil.handleException(e); } } }); jarFileDirs.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(jarFileDirs).defaultJListKeyPressed(evt); } }); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("result", null, jPanel2, null); { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jPanel2.add(jPanel3, BorderLayout.NORTH); jPanel3.setPreferredSize(new java.awt.Dimension(406, 26)); { searchText = new JTextField(); jPanel3.add(searchText, BorderLayout.WEST); searchText.setPreferredSize(new java.awt.Dimension(326, 26)); } { search = new JButton(); jPanel3.add(search, BorderLayout.CENTER); search.setText("search"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton2ActionPerformed(evt); } }); } } { jScrollPane2 = new JScrollPane(); jPanel2.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(406, 231)); { ListModel searchResultModel = new DefaultListModel(); searchResult = new JList(); jScrollPane2.setViewportView(searchResult); searchResult.setModel(searchResultModel); searchResult.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { jList1MouseClicked(evt); } }); searchResult.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(searchResult).defaultJListKeyPressed(evt); } }); } } { resetFinder = new JButton(); jPanel2.add(resetFinder, BorderLayout.SOUTH); resetFinder.setText("reset finder"); resetFinder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jarfinder.clear(); } }); } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("copy to", null, jPanel4, null); { copyToBtn = new JButton(); jPanel4.add(copyToBtn, BorderLayout.NORTH); copyToBtn.setText("copy to"); copyToBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("copy to dir undefined!", getTitle()); return; } else { copyToFile = file; } } }); } { jScrollPane3 = new JScrollPane(); jPanel4.add(jScrollPane3, BorderLayout.CENTER); { DefaultListModel copyToListModel = new DefaultListModel(); copyToList = new JList(); jScrollPane3.setViewportView(copyToList); copyToList.setModel(copyToListModel); { panel = new JPanel(); jTabbedPane1.addTab("config", null, panel, null); panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); { lblNewLabel = new JLabel("JD Gui"); panel.add(lblNewLabel, "2, 2, right, default"); } { jdGuiText = new JTextField(); JCommonUtil.jTextFieldSetFilePathMouseEvent(jdGuiText, false); panel.add(jdGuiText, "4, 2, fill, default"); jdGuiText.setColumns(10); } { saveConfigBtn = new JButton(""); saveConfigBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { configBean.reflectSetConfig(JarFinderUI.this); configBean.store(); JCommonUtil._jOptionPane_showMessageDialog_info("?!"); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); panel.add(saveConfigBtn, "2, 24"); } } copyToList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { // copyToFile if (evt.getClickCount() != 2) { return; } if (copyToList.getLeadSelectionIndex() == -1) { return; } if (copyToFile == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("copy to dir undefined!", getTitle()); return; } DefaultListModel model = (DefaultListModel) copyToList.getModel(); Object val = model.getElementAt(copyToList.getLeadSelectionIndex()); StringBuilder sb = new StringBuilder(); sb.append("?\n"); sb.append("file : " + val + "\n"); sb.append("copy to dir : " + copyToFile + "\n"); ComfirmDialogResult result = JOptionPaneUtil.newInstance().confirmButtonYesNo() .showConfirmDialog(sb, getTitle()); File srcFile = new File((String) val); if (!srcFile.exists()) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog(srcFile + " not found!", getTitle()); return; } File copyDestFile = new File(copyToFile, srcFile.getName()); switch (result) { case YES_OK_OPTION: System.out.println("yes.."); try { FileUtil.copyFile(srcFile, copyDestFile); } catch (IOException e) { JCommonUtil.handleException(e.toString(), e); } if (srcFile != null && // copyDestFile != null && // srcFile.length() == copyDestFile.length()) { JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("success!\n" + copyDestFile, getTitle()); } else { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("failed!\n" + copyDestFile, getTitle()); } break; case NO_OPTION: System.out.println("no.."); break; } } }); } } } jTabbedPane1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { copyToList.setModel(searchResult.getModel()); } }); } this.setSize(562, 407); JCommonUtil.frameCloseDo(this, new WindowAdapter() { public void windowClosing(WindowEvent paramWindowEvent) { if (CONFIG_FILE.exists()) { DefaultListModel model = (DefaultListModel) jarFileDirs.getModel(); for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) { Object obj = enu.nextElement(); prop.setProperty(((File) obj).getAbsolutePath(), ""); } try { prop.store(new FileOutputStream(CONFIG_FILE), "testtesttesttest"); } catch (Exception e) { JCommonUtil.handleException("", e); } } setVisible(false); dispose(); } }); { configBean.reflectInit(this); } } catch (Exception e) { e.printStackTrace(); } }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeographyAssignISOs.java
/** * @return// w w w .j a v a 2 s . c o m */ @SuppressWarnings("rawtypes") public boolean buildAsyncOrig(final int earthId) { String sql = adjustSQL( "SELECT COUNT(*) FROM geography WHERE GeographyCode IS NOT NULL AND RankID = 100 AND GeographyTreeDefID = GEOTREEDEFID"); int numContinentsWithNames = BasicSQLUtils.getCountAsInt(sql); continentsCBX = createCheckBox("All Continents"); // I18N CellConstraints cc = new CellConstraints(); PanelBuilder pb1 = new PanelBuilder(new FormLayout("f:p:g", "p,4px,p,4px,p,8px")); countriesCBX = createCheckBox("All Countries"); stateCBX = createCheckBox("All States"); countiesCBX = createCheckBox("All Counties"); pb1.add(countriesCBX, cc.xy(1, 1)); pb1.add(stateCBX, cc.xy(1, 3)); //pb1.add(countiesCBX, cc.xy(1, 5)); allCountriesRB = new JRadioButton("Choose the Geography level to be processed"); //L18N singleCountryRB = new JRadioButton("Choose an individual Country"); btnGroup = new ButtonGroup(); btnGroup.add(this.allCountriesRB); btnGroup.add(this.singleCountryRB); if (numContinentsWithNames == 0) { continentsCBX.setEnabled(false); continentsCBX.setSelected(true); } countriesCBX.setEnabled(true); stateCBX.setEnabled(false); countiesCBX.setEnabled(false); countryIds.clear(); sql = "SELECT g.GeographyID, g.Name, g2.Name FROM geography g LEFT JOIN geography g2 ON g.ParentID = g2.GeographyID " + "WHERE g.Name IS NOT NULL && LENGTH(g.Name) > 0 AND g.RankID = 200 AND g.GeographyTreeDefID = GEOTREEDEFID ORDER BY g.Name"; sql = adjustSQL(sql); Vector<Object[]> rows = query(sql); Object[] titles = new Object[rows.size() + 1]; int i = 0; titles[i++] = "None"; // I18N countryIds.add(-1); for (Object[] r : rows) { countryIds.add((Integer) r[0]); String countryStr = (String) r[1]; String contStr = (String) r[2]; titles[i++] = countryStr != null ? (countryStr + " (" + contStr + ")") : countryStr; } PanelBuilder pb2 = new PanelBuilder(new FormLayout("8px,p,2px,f:p:g", "p,4px,p,8px")); spCountriesLbl = createFormLabel("Country"); // I18N spCountriesCmbx = createComboBox(titles); spStatesCBX = createCheckBox("States (Required)"); // I18N spCountiesCBX = createCheckBox("Counties"); // I18N pb2.add(spCountriesLbl, cc.xy(2, 1)); pb2.add(spCountriesCmbx, cc.xy(4, 1)); pb2.add(spStatesCBX, cc.xyw(1, 3, 4)); //pb2.add(spCountiesCBX, cc.xyw(1, 5, 4)); spCountriesCmbx.setSelectedIndex(0); spStatesCBX.setSelected(true); spStatesCBX.setEnabled(false); spCountiesCBX.setEnabled(false); String rowDef = createDuplicateJGoodiesDef("p", "4px", 8); PanelBuilder pb = new PanelBuilder(new FormLayout("16px,f:p:g", rowDef)); pb.addSeparator("Continents to be processed", cc.xyw(1, 1, 2)); pb.add(continentsCBX, cc.xyw(1, 3, 2)); pb.addSeparator("Countries to be processed", cc.xyw(1, 5, 2)); pb.add(allCountriesRB, cc.xyw(1, 7, 2)); pb.add(pb1.getPanel(), cc.xyw(2, 9, 1)); pb.add(singleCountryRB, cc.xyw(1, 11, 2)); pb.add(pb2.getPanel(), cc.xyw(2, 13, 1)); pb.add(createGeoStatsPanel(), cc.xyw(1, 15, 2)); pb.setDefaultDialogBorder(); final CustomDialog dlg = new CustomDialog((Frame) getTopWindow(), "ISO Code Processing", true, CustomDialog.OKCANCELHELP, pb.getPanel()); // I18N dlg.setHelpContext("GeoCleanUpLevelChooser"); // Setup actions ChangeListener rbChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { radioSelected(dlg); } }; allCountriesRB.addChangeListener(rbChangeListener); singleCountryRB.addChangeListener(null); countriesCBX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { boolean isSel = countriesCBX.isSelected(); stateCBX.setEnabled(isSel); countiesCBX.setEnabled(false); if (!isSel) { stateCBX.setSelected(false); countiesCBX.setSelected(false); } calcGeoStats(); dlg.getOkBtn().setEnabled(isSel || spCountriesCmbx.getSelectedIndex() > 0); } }); stateCBX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { countiesCBX.setEnabled(stateCBX.isSelected()); if (!stateCBX.isSelected()) { countiesCBX.setSelected(false); } calcGeoStats(); } }); // Special spCountriesCmbx.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isSel = spCountriesCmbx.getSelectedIndex() > 0; spStatesCBX.setSelected(isSel); spCountiesCBX.setEnabled(isSel); if (!isSel) { spStatesCBX.setSelected(false); spCountiesCBX.setSelected(false); } calcGeoStats(); dlg.getOkBtn().setEnabled(isSel || countriesCBX.isSelected()); } }); spStatesCBX.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { spCountiesCBX.setEnabled(stateCBX.isSelected()); calcGeoStats(); } }); allCountriesRB.setSelected(true); dlg.createUI(); dlg.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // Must be called after 'createUI' dlg.getOkBtn().setEnabled(false); // AUTO Don't show Dialog because it is automatically setting what to do centerAndShow(dlg); if (dlg.isCancelled()) { return false; } connectToDB(); if (true) // AUTO { doAllCountries = new boolean[] { countriesCBX.isSelected(), stateCBX.isSelected(), countiesCBX.isSelected(), false }; doInvCountry = new boolean[] { spCountriesCmbx.getSelectedIndex() > 0, spStatesCBX.isSelected(), spCountiesCBX.isSelected(), false }; doIndvCountryId = doInvCountry[0] ? countryIds.get(spCountriesCmbx.getSelectedIndex()) : null; } else { int indexOfUSA = getUnitedStatesIndex(titles); if (indexOfUSA == -1) { Vector<Object> nameList = new Vector<Object>(); Collections.addAll(nameList, titles); JList list = createList(nameList); JScrollPane sp = createScrollPane(list); pb = new PanelBuilder(new FormLayout("f:p:g", "p,8px,f:p:g")); pb.add(createLabel("Select the United States"), cc.xy(1, 1)); pb.add(sp, cc.xy(1, 3)); pb.setDefaultDialogBorder(); final CustomDialog askDlg = new CustomDialog((Frame) getTopWindow(), "Choose", true, CustomDialog.OKCANCELHELP, pb.getPanel()); // I18N dlg.setHelpContext("GeoCleanUpLevelChooser"); centerAndShow(askDlg); if (!askDlg.isCancelled()) { indexOfUSA = list.getSelectedIndex(); } } doAllCountries = new boolean[] { true, false, false, false }; doInvCountry = new boolean[] { indexOfUSA > -1, true, false, false }; doIndvCountryId = doInvCountry[0] ? countryIds.get(indexOfUSA) : null; } // Check to see if it needs indexing. boolean shouldIndex = luceneSearch.shouldIndex(); if (shouldIndex) { frame = new ProgressFrame("Building Geography Authority..."); // I18N frame.getCloseBtn().setVisible(false); frame.turnOffOverAll(); frame.setDesc("Loading Geonames data..."); // I18N frame.pack(); frame.setSize(450, frame.getBounds().height + 10); UIHelper.centerAndShow(frame, 450, frame.getBounds().height + 10); luceneSearch.startIndexingProcessAsync(earthId, frame, new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { frame.setVisible(false); frame = null; if (((Boolean) e.getSource())) { GeographyAssignISOs.this.startTraversal(); } } }); } else { sql = "SELECT Name, geonameId, iso_alpha2 FROM countryinfo"; for (Object[] row : query(sql)) { countryInfo.add(new GeoSearchResultsItem((String) row[0], (Integer) row[1], (String) row[2])); } startTraversal(); } return true; }
From source file:com.juanhg.pattern.PatternApplet.java
private void autogeneratedCode() { JPanel panel_control = new JPanel(); panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null), new BevelBorder(BevelBorder.RAISED, null, null, null, null))); JPanel panelInputs = new JPanel(); panelInputs.setToolTipText(""); panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelOutputs = new JPanel(); panelOutputs.setToolTipText(""); panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0))); JPanel panelTitleOutputs = new JPanel(); panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n"); labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitleOutputs.add(labelOutputData); lblO1 = new JLabel("O1:"); lblO1.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO1Value = new JLabel(); lblO1Value.setText("0"); lblO1Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel lblO2 = new JLabel("O2:"); lblO2.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO2Value = new JLabel(); lblO2Value.setText("0"); lblO2Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO3 = new JLabel("O3:"); lblO3.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblO3Value = new JLabel(); lblO3Value.setText("0"); lblO3Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs); gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE) .addGroup(gl_panelOutputs.createSequentialGroup().addGap(22).addGroup(gl_panelOutputs .createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblO3, GroupLayout.PREFERRED_SIZE, 84, GroupLayout.PREFERRED_SIZE) .addGap(26)//w w w . j a v a 2 s. c o m .addComponent(lblO3Value, GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)) .addGroup(gl_panelOutputs.createSequentialGroup() .addGroup(gl_panelOutputs.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblO1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(26)) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE) .addGap(29))) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false) .addComponent(lblO2Value, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblO1Value, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)))) .addGap(109))); gl_panelOutputs .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelOutputs.createSequentialGroup() .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblO1Value).addComponent(lblO1)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE) .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblO2Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING) .addComponent(lblO3, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblO3Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addGap(79))); panelOutputs.setLayout(gl_panelOutputs); JPanel panelLicense = new JPanel(); panelLicense.setBorder(new LineBorder(new Color(0, 0, 0))); JPanel panel_6 = new JPanel(); panel_6.setBorder(new LineBorder(new Color(0, 0, 0))); GroupLayout gl_panel_control = new GroupLayout(panel_control); gl_panel_control.setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap().addGroup(gl_panel_control .createParallelGroup(Alignment.LEADING) .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panelOutputs, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panel_6, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE) .addComponent(panelLicense, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)) .addContainerGap())); gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panel_control.createSequentialGroup().addContainerGap() .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 213, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 146, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED).addComponent(panelLicense, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(24))); btnLaunchSimulation = new JButton("Iniciar"); btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16)); btnLaunchSimulation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { btnLaunchSimulationEvent(event); } }); GroupLayout gl_panel_6 = new GroupLayout(panel_6); gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.TRAILING).addGroup(Alignment.LEADING, gl_panel_6.createSequentialGroup().addContainerGap() .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE) .addContainerGap())); gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.TRAILING).addGroup(Alignment.LEADING, gl_panel_6.createSequentialGroup().addGap(80) .addComponent(btnLaunchSimulation, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); panel_6.setLayout(gl_panel_6); JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE"); panelLicense.add(lblNewLabel); JLabel LabelI1 = new JLabel("I1"); LabelI1.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelI2 = new JLabel("I2"); labelI2.setFont(new Font("Tahoma", Font.PLAIN, 14)); JLabel labelI3 = new JLabel("I3"); labelI3.setFont(new Font("Tahoma", Font.PLAIN, 14)); JPanel panelTitle = new JPanel(); panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null)); lblI2Value = new JLabel("5"); lblI2Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblI3Value = new JLabel("5"); lblI3Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblI1Value = new JLabel("5"); lblI1Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderI1 = new JSlider(); sliderI1.setMaximum(10); sliderI1.setMinorTickSpacing(1); sliderI1.setValue(5); sliderI1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { sliderI1Event(); } }); sliderI2 = new JSlider(); sliderI2.setMaximum(10); sliderI2.setMinorTickSpacing(1); sliderI2.setValue(5); sliderI2.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI2Event(); } }); sliderI3 = new JSlider(); sliderI3.setMaximum(10); sliderI3.setValue(5); sliderI3.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI3Event(); } }); JLabel lblI4 = new JLabel("I4"); lblI4.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblI4Value = new JLabel("5"); lblI4Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderI4 = new JSlider(); sliderI4.setMaximum(10); sliderI4.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { sliderI4Event(); } }); sliderI4.setValue(5); sliderI4.setMinorTickSpacing(1); JLabel lblI5 = new JLabel("I5"); lblI5.setFont(new Font("Tahoma", Font.PLAIN, 14)); lblI5Value = new JLabel("5"); lblI5Value.setFont(new Font("Tahoma", Font.PLAIN, 14)); sliderI5 = new JSlider(); sliderI5.setMaximum(10); sliderI5.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { sliderI5Event(); } }); sliderI5.setValue(5); sliderI5.setMinorTickSpacing(1); GroupLayout gl_panelInputs = new GroupLayout(panelInputs); gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING) .addGroup(gl_panelInputs.createSequentialGroup().addGroup(gl_panelInputs .createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING, false) .addComponent(labelI3, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(LabelI1, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(labelI2, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblI1Value, GroupLayout.PREFERRED_SIZE, 42, GroupLayout.PREFERRED_SIZE) .addComponent(lblI2Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addComponent(lblI3Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false) .addComponent(sliderI1, 0, 0, Short.MAX_VALUE) .addComponent(sliderI2, 0, 0, Short.MAX_VALUE).addComponent( sliderI3, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(lblI4Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(sliderI4, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(lblI5, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE) .addGap(18) .addComponent(lblI5Value, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE) .addGap(18).addComponent(sliderI5, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))) .addGap(19)) .addComponent(panelTitle, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE)); gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createSequentialGroup() .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(LabelI1).addComponent(lblI1Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderI1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.RELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE) .addComponent(labelI2).addComponent(lblI2Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)) .addComponent(sliderI2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(11) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(labelI3) .addComponent(lblI3Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderI3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblI4Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderI4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addPreferredGap(ComponentPlacement.UNRELATED) .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING) .addComponent(lblI5, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(lblI5Value, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE) .addComponent(sliderI5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGap(429))); JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada"); lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14)); panelTitle.add(lblDatosDeEntrada); panelInputs.setLayout(gl_panelInputs); panel_control.setLayout(gl_panel_control); JPanel panel_visualizar = new JPanel(); panel_visualizar.setBackground(Color.WHITE); GroupLayout groupLayout = new GroupLayout(getContentPane()); groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap() .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap())); groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout .createSequentialGroup() .addGroup(groupLayout.createParallelGroup(Alignment.LEADING) .addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(panel_control, GroupLayout.PREFERRED_SIZE, 568, GroupLayout.PREFERRED_SIZE)) .addGroup(groupLayout.createSequentialGroup().addGap(12).addComponent(panel_visualizar, GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE))) .addContainerGap())); GroupLayout gl_panel_visualizar = new GroupLayout(panel_visualizar); gl_panel_visualizar.setHorizontalGroup( gl_panel_visualizar.createParallelGroup(Alignment.LEADING).addGap(0, 845, Short.MAX_VALUE)); gl_panel_visualizar.setVerticalGroup( gl_panel_visualizar.createParallelGroup(Alignment.LEADING).addGap(0, 567, Short.MAX_VALUE)); panel_visualizar.setLayout(gl_panel_visualizar); getContentPane().setLayout(groupLayout); }
From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java
/** * Starts the search of unlinked files according to the current dialog * state. <br>/*from w w w .ja v a 2 s .co m*/ * <br> * This state is made of: <br> * <li>The value of the "directory"-input-textfield and <li>The file type * selection. <br> * The search will process in a seperate thread and the progress bar behind * the "search" button will be displayed. <br> * <br> * When the search has completed, the * {@link #searchFinishedHandler(CheckableTreeNode)} handler method is * invoked. */ private void startSearch() { Path directory = Paths.get(textfieldDirectoryPath.getText()); if (Files.notExists(directory)) { directory = Paths.get(System.getProperty("user.dir")); } if (!Files.isDirectory(directory)) { directory = directory.getParent(); } //this addtional statement is needed because for the lamdba the variable must be effetively final Path dir = directory; storeLastSelectedDirectory(directory); progressBarSearching.setMinimumSize( new Dimension(buttonScan.getSize().width, progressBarSearching.getMinimumSize().height)); progressBarSearching.setVisible(true); progressBarSearching.setString(""); labelSearchingDirectoryInfo.setVisible(true); buttonScan.setVisible(false); disOrEnableDialog(false); labelSearchingDirectoryInfo.setEnabled(true); final FileFilter selectedFileFilter = (FileFilter) comboBoxFileTypeSelection.getSelectedItem(); threadState.set(true); JabRefExecutorService.INSTANCE.execute(() -> { UnlinkedPDFFileFilter unlinkedPDFFileFilter = new UnlinkedPDFFileFilter(selectedFileFilter, database); CheckableTreeNode rootNode = crawler.searchDirectory(dir.toFile(), unlinkedPDFFileFilter, threadState, new ChangeListener() { int counter; @Override public void stateChanged(ChangeEvent e) { counter++; progressBarSearching.setString(counter + " files found"); } }); searchFinishedHandler(rootNode); }); }
From source file:com.imag.nespros.gui.plugin.GraphEditor.java
/** * create an instance of a simple graph with popup controls to create a * graph.//from w w w . ja v a 2 s. c o m * */ private GraphEditor(Simulation s) { simu = s; try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception ex) { Logger.getLogger(GraphEditor.class.getName()).log(Level.SEVERE, null, ex); } // create a simple graph for the demo graph = Topology.getInstance().getGraph(); this.layout = new StaticLayout<Device, ComLink>(graph, new Transformer<Device, Point2D>() { @Override public Point2D transform(Device v) { Point2D p = new Point2D.Double(v.getX(), v.getY()); return p; } }, new Dimension(600, 600)); vv = new VisualizationViewer<Device, ComLink>(layout); vv.setBackground(Color.white); final Transformer<Device, String> vertexLabelTransformer = new Transformer<Device, String>() { @Override public String transform(Device d) { return d.getDeviceName(); } }; //vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<Device, String>getInstance( // LazyMap.<Device, String>decorate(new HashMap<Device, String>(), new ToStringLabeller<Device>()))); vv.getRenderContext().setVertexLabelTransformer(vertexLabelTransformer); vv.getRenderContext().setEdgeLabelTransformer(new Transformer<ComLink, String>() { @Override public String transform(ComLink link) { return (link.getID() + ", " + link.getLatency()); } }); //float dash[] = {0.1f}; //final Stroke edgeStroke = new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 1.0f); final Stroke edgeStroke = new BasicStroke(3.0f); final Transformer<ComLink, Stroke> edgeStrokeTransformer = new Transformer<ComLink, Stroke>() { @Override public Stroke transform(ComLink l) { return edgeStroke; } }; Transformer<ComLink, Paint> edgePaint = new Transformer<ComLink, Paint>() { public Paint transform(ComLink l) { if (l.isDown()) { return Color.RED; } else { return Color.BLACK; } } }; vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint); vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer); vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer()); vv.getRenderContext().setVertexIconTransformer(new CustomVertexIconTransformer()); vv.getRenderContext().setVertexShapeTransformer(new CustomVertexShapeTransformer()); vv.addPreRenderPaintable(new VisualizationViewer.Paintable() { @Override public void paint(Graphics grphcs) { for (Device d : Topology.getInstance().getGraph().getVertices()) { int size = d.getOperators().size(); MyLayeredIcon icon = d.getIcon(); //if(icon == null) continue; icon.removeAll(); if (size > 0) { // the vertex icon // Let's create the annotation image to be added to icon.. BufferedImage image = new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB); Graphics2D g = image.createGraphics(); g.setColor(Color.ORANGE); g.fillOval(0, 0, 20, 20); g.setColor(Color.BLACK); g.drawString(size + "", 5, 13); g.dispose(); ImageIcon img = new ImageIcon(image); //Dimension id = new Dimension(icon.getIconWidth(), icon.getIconHeight()); //double x = vv.getModel().getGraphLayout().transform(d).getX(); //x -= (icon.getIconWidth() / 2); //double y = vv.getModel().getGraphLayout().transform(d).getY(); //y -= (icon.getIconHeight() / 2); //grphcs.drawImage(image, (int) Math.round(x), (int) Math.round(y), null); icon.add(img); } } } @Override public boolean useTransform() { return false; } }); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); Factory<Device> vertexFactory = DeviceFactory.getInstance(); Factory<ComLink> edgeFactory = ComLinkFactory.getInstance(); final EditingModalGraphMouse<Device, ComLink> graphMouse = new EditingModalGraphMouse<>( vv.getRenderContext(), vertexFactory, edgeFactory); // Trying out our new popup menu mouse plugin... PopupVertexEdgeMenuMousePlugin myPlugin = new PopupVertexEdgeMenuMousePlugin(); // Add some popup menus for the edges and vertices to our mouse plugin. JPopupMenu edgeMenu = new MyMouseMenus.EdgeMenu(frame); JPopupMenu vertexMenu = new MyMouseMenus.VertexMenu(frame); myPlugin.setEdgePopup(edgeMenu); myPlugin.setVertexPopup(vertexMenu); graphMouse.remove(graphMouse.getPopupEditingPlugin()); // Removes the existing popup editing plugin graphMouse.add(myPlugin); // Add our new plugin to the mouse // AnnotatingGraphMousePlugin<Device,ComLink> annotatingPlugin = // new AnnotatingGraphMousePlugin<>(vv.getRenderContext()); //graphMouse.add(annotatingPlugin); // the EditingGraphMouse will pass mouse event coordinates to the // vertexLocations function to set the locations of the vertices as // they are created // graphMouse.setVertexLocations(vertexLocations); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); graphMouse.setMode(ModalGraphMouse.Mode.PICKING); //final ImageAtEdgePainter<String, String> imageAtEdgePainter = // new ImageAtEdgePainter<String, String>(vv, edge, image); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JButton help = new JButton("Help"); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(vv, instructions); } }); JButton deploy = new JButton("Deploy"); deploy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // OPMapping algo here if (simu == null) { return; } GraphUtil<Device, ComLink> util = new GraphUtil<>(); for (EventProducer p : simu.getProducers()) { if (!p.isMapped()) { JOptionPane.showMessageDialog(frame, "Cannot map operators. Please deploy the producer: " + p.getName()); return; } } for (EventConsumer c : simu.getConsumers()) { if (!c.isMapped()) { JOptionPane.showMessageDialog(frame, "Cannot map operators. Please deploy the consumer: " + c.getName()); return; } System.out.println("-- Operator placement algorithm Greedy: " + c.getName() + " --"); Solution init = util.initialMapping(c.getGraph()); System.out.println(c.getGraph() + "\nInitial Mapping: " + init); OperatorMapping mapper = new OperatorMapping(); long T1, T2; System.out.println("--- OpMapping Algo Greedy --- "); T1 = System.currentTimeMillis(); Solution solution = mapper.opMapping(c.getGraph(), Topology.getInstance().getGraph(), init); T2 = System.currentTimeMillis(); System.out.println(solution); System.out.println("Solution founded in: " + (T2 - T1) + " ms"); } // Solution init = util.initialMapping(EPGraph.getInstance().getGraph()); // System.out.println("Initial Mapping: " + init); // OperatorMapping mapper = new OperatorMapping(); // long T1, T2; // System.out.println("--- OpMapping Algo Greedy --- "); // T1 = System.currentTimeMillis(); // Solution solution = mapper.opMapping(EPGraph.getInstance().getGraph(), // Topology.getInstance().getGraph(), init); // T2 = System.currentTimeMillis(); // System.out.println(solution); // System.out.println("Solution founded in: " + (T2 - T1) + " ms"); vv.repaint(); } }); JButton run = new JButton("Run"); run.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // run the simulation here System.out.println("Setting the simulation..."); for (EventConsumer c : simu.getConsumers()) { for (EPUnit op : c.getGraph().getVertices()) { if (op.isMapped()) { op.openIOchannels(); } else { JOptionPane.showMessageDialog(frame, "Cannot run, undeployed operators founded."); return; } } } //ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); System.out.println("Running the simulation..."); //scheduledExecutorService.execute(runner); for (Device device : Topology.getInstance().getGraph().getVertices()) { if (!device.isAlive()) { device.start(); } } for (ComLink link : Topology.getInstance().getGraph().getEdges()) { if (!link.isAlive()) { link.start(); } } for (EventConsumer c : simu.getConsumers()) { for (EPUnit op : c.getGraph().getVertices()) { if (op.isMapped() && op.getDevice() != null && !op.isAlive()) { op.start(); } } } } }); AnnotationControls<Device, ComLink> annotationControls = new AnnotationControls<Device, ComLink>( graphMouse.getAnnotatingPlugin()); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 30, 0); slider.setMinorTickSpacing(5); slider.setMajorTickSpacing(30); slider.setPaintTicks(true); slider.setPaintLabels(true); slider.setLabelTable(slider.createStandardLabels(15)); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider slider = (JSlider) e.getSource(); if (!slider.getValueIsAdjusting()) { speedSimulation(slider.getValue()); } } }); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); JComboBox modeBox = graphMouse.getModeComboBox(); controls.add(modeBox); controls.add(annotationControls.getAnnotationsToolBar()); controls.add(slider); controls.add(deploy); controls.add(run); controls.add(help); content.add(controls, BorderLayout.SOUTH); /* Custom JPanels can be added here */ // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //final GraphEditor demo = new GraphEditor(); }
From source file:edu.ucla.stat.SOCR.chart.Chart.java
/**This method initializes the Gui, by setting up the basic tabbedPanes.*/ public void init() { depMax = 1;//w w w.j a v a2s. co m indMax = 1; chartTitle = this.getClass().getName(); chartTitle = chartTitle.substring(chartTitle.lastIndexOf(".") + 1); String fileName = "demo" + System.getProperty("file.separator") + chartTitle + ".html"; url = Chart.class.getResource(fileName); setName(chartTitle); //Get frame of the applet //frame = getFrame(this.getContentPane()); // Create the toolBar toolBar = new JToolBar(); createActionComponents(toolBar); this.getContentPane().add(toolBar, BorderLayout.NORTH); tabbedPanelContainer = new JTabbedPane(); dataObject = new Object[rowNumber][columnNumber]; columnNames = new String[columnNumber]; independentList = new ArrayList<Integer>(); dependentList = new ArrayList<Integer>(); for (int i = 0; i < columnNumber; i++) columnNames[i] = new String(DEFAULT_HEADER + (i + 1)); initTable(); initGraphPanel(); initMapPanel(); initMixPanel(); mixPanelContainer = new JScrollPane(mixPanel); mixPanelContainer.setPreferredSize(new Dimension(600, CHART_SIZE_Y + 100)); addTabbedPane(GRAPH, graphPanel); addTabbedPane(DATA, dataPanel); addTabbedPane(MAPPING, bPanel); addTabbedPane(ALL, mixPanelContainer); tabbedPanelContainer.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) { mixPanel.removeAll(); setMixPanel(); mixPanel.validate(); } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == GRAPH) { graphPanel.removeAll(); //setGraphPanel(); //graphPanel.validate(); setChart(); } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == DATA) { // setTablePane(); } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == MAPPING) { bPanel.removeAll(); mapPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y)); bPanel.add(mapPanel, BorderLayout.CENTER); bPanel.validate(); } } }); bPanel.addComponentListener(new ComponentListener() { public void componentResized(ComponentEvent e) { } public void componentMoved(ComponentEvent e) { } public void componentShown(ComponentEvent e) { // resultPanelTextArea.append("sucess"); // System.out.print("Success"); // Add code here for updating the Panel to show proper heading paintMappingLists(listIndex); } public void componentHidden(ComponentEvent e) { } }); // the right side (including top and bottom panels) statusTextArea = new JTextPane(); //right side lower statusTextArea.setEditable(false); JScrollPane statusContainer = new JScrollPane(statusTextArea); statusContainer.setPreferredSize(new Dimension(600, 140)); if (SHOW_STATUS_TEXTAREA) { JSplitPane container = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(tabbedPanelContainer), statusContainer); container.setContinuousLayout(true); container.setDividerLocation(0.6); this.getContentPane().add(container, BorderLayout.CENTER); } else { this.getContentPane().add(new JScrollPane(tabbedPanelContainer), BorderLayout.CENTER); } updateStatus(url); }
From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java
/** * This will start the import of all file of all selected nodes in this * dialogs tree view. <br>/*from w w w .j a v a 2s .com*/ * <br> * The import itself will run in a seperate thread, whilst this dialog will * be showing a progress bar, until the thread has finished its work. <br> * <br> * When the import has finished, the {@link #importFinishedHandler(java.util.List)} is * invoked. */ private void startImport() { if (treeModel == null) { return; } setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); CheckableTreeNode root = (CheckableTreeNode) treeModel.getRoot(); final List<File> fileList = getFileListFromNode(root); if ((fileList == null) || fileList.isEmpty()) { return; } progressBarImporting.setVisible(true); labelImportingInfo.setVisible(true); buttonApply.setVisible(false); buttonClose.setVisible(false); disOrEnableDialog(false); labelImportingInfo.setEnabled(true); progressBarImporting.setMinimum(0); progressBarImporting.setMaximum(fileList.size()); progressBarImporting.setValue(0); progressBarImporting.setString(""); final EntryType entryType = ((BibtexEntryTypeWrapper) comboBoxEntryTypeSelection.getSelectedItem()) .getEntryType(); threadState.set(true); JabRefExecutorService.INSTANCE.execute(() -> { List<String> errors = new LinkedList<>(); creatorManager.addEntriesFromFiles(fileList, database, frame.getCurrentBasePanel(), entryType, checkBoxWhyIsThereNoGetSelectedStupidSwing, new ChangeListener() { int counter; @Override public void stateChanged(ChangeEvent e) { counter++; progressBarImporting.setValue(counter); progressBarImporting.setString(counter + " of " + progressBarImporting.getMaximum()); } }, errors); importFinishedHandler(errors); }); }
From source file:com.diversityarrays.kdxplore.curate.fieldview.FieldLayoutViewPanel.java
@SuppressWarnings("unchecked") public FieldLayoutViewPanel(@SuppressWarnings("rawtypes") MutableComboBoxModel comboBoxModel, JCheckBox alwaysOnTopOption, CurationData cd, CurationTableModel ctm, SelectedValueStore svs, PlotCellChoicesPanel pccp, JPopupMenu popuMenu, Font fontForResizeControls, Action curationHelpAction, MessagePrinter mp, Closure<String> selectionClosure, CurationContext curationContext, CurationMenuProvider curationMenuProvider, FieldLayoutTableModel fieldLayoutTableModel, CellSelectableTable fieldLayoutTable, FieldViewSelectionModel fvsm,//from w w w .j av a 2s . c o m JButton undockButton) { super(new BorderLayout()); this.traitInstanceCombo.setModel(comboBoxModel); this.curationData = cd; this.messagePrinter = mp; this.selectionClosure = selectionClosure; this.curationTableModel = ctm; this.fieldLayoutTableModel = fieldLayoutTableModel; this.fieldLayoutTable = fieldLayoutTable; this.fieldViewSelectionModel = fvsm; traitInstanceCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object item = comboBoxModel.getSelectedItem(); if (item instanceof TraitInstance) { TraitInstance ti = (TraitInstance) item; plotCellRenderer.setActiveInstance(ti); } } }); rhtm = new RowHeaderTableModel(true, fieldLayoutTable, rowRemovable) { public String getRowLabel(int rowIndex) { int yCoord = FieldLayoutUtil.convertRowIndexToYCoord(rowIndex, trial, fieldLayoutTableModel.getFieldLayout()); return String.valueOf(yCoord); } }; rowHeaderTable = new RowHeaderTable(SwingConstants.CENTER, false, fieldLayoutTable, rowRemovable, rhtm, RowHeaderTable.createDefaultColumnModel("X/Y")) { public String getMarkerIndexName(int viewRow) { return "MIN-" + viewRow; //$NON-NLS-1$ } }; rhtTableRowResizer = new TableRowResizer(rowHeaderTable, true); curationData.addCurationDataChangeListener(plotActivationListener); curationTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { fieldLayoutTable.repaint(); } }); plotCellRenderer = new PlotCellRenderer(plotAttributeProvider, curationTableModel); TraitInstanceCellRenderer tiCellRenderer = new TraitInstanceCellRenderer( curationData.getTraitColorProvider(), instanceNameProvider); traitInstanceCombo.setRenderer(tiCellRenderer); traitInstanceCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateActiveTraitInstance(); } }); traitInstanceCombo.getModel().addListDataListener(new ListDataListener() { @Override public void intervalRemoved(ListDataEvent e) { updateActiveTraitInstance(); } @Override public void intervalAdded(ListDataEvent e) { updateActiveTraitInstance(); } @Override public void contentsChanged(ListDataEvent e) { updateActiveTraitInstance(); } }); this.trial = curationData.getTrial(); this.plotCellChoicesPanel = pccp; for (TraitInstance t : curationData.getTraitInstances()) { String id = InstanceIdentifierUtil.getInstanceIdentifier(t); traitById.put(id, t); } // fieldViewSelectionModel = new FieldViewSelectionModel( // fieldLayoutTable, // fieldLayoutTableModel, // svs); fieldLayoutTable.setSelectionModel(fieldViewSelectionModel); plotCellRenderer.setCurationData(curationData); plotCellRenderer.setSelectionModel(fieldViewSelectionModel); plotCellChoicesPanel.addPlotCellChoicesListener(plotCellChoicesListener); fieldLayoutTableModel.setTrial(trial); // IMPORTANT: DO NOT SORT THE FIELD LAYOUT TABLE fieldLayoutTable.setAutoCreateRowSorter(false); JScrollPane fieldTableScrollPane = new JScrollPane(fieldLayoutTable); if (undockButton != null) { fieldTableScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, undockButton); } fieldTableScrollPane.setRowHeaderView(rowHeaderTable); ChangeListener scrollBarChangeListener = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { fireRefreshRequired(); } }; fieldTableScrollPane.getVerticalScrollBar().getModel().addChangeListener(scrollBarChangeListener); fieldTableScrollPane.getHorizontalScrollBar().getModel().addChangeListener(scrollBarChangeListener); fieldLayoutTable.setRowHeaderTable(rowHeaderTable); // fieldLayoutTable.setComponentPopupMenu(popuMenu); initFieldLayoutTable(); Map<Integer, Plot> plotById = new HashMap<>(); FieldLayout<Integer> plotIdLayout = FieldLayoutUtil.createPlotIdLayout(trial.getTrialLayout(), trial.getPlotIdentSummary(), curationData.getPlots(), plotById); KdxploreFieldLayout<Plot> kdxFieldLayout = new KdxploreFieldLayout<Plot>(Plot.class, plotIdLayout.imageId, plotIdLayout.xsize, plotIdLayout.ysize); kdxFieldLayout.warning = plotIdLayout.warning; for (int y = 0; y < plotIdLayout.ysize; ++y) { for (int x = 0; x < plotIdLayout.xsize; ++x) { Integer id = plotIdLayout.cells[y][x]; if (id != null) { Plot plot = plotById.get(id); kdxFieldLayout.store_xy(plot, x, y); } } } fieldLayoutTableModel.setFieldLayout(kdxFieldLayout); if (kdxFieldLayout.warning != null && !kdxFieldLayout.warning.isEmpty()) { warningMessage.setText(kdxFieldLayout.warning); } else { warningMessage.setText(""); //$NON-NLS-1$ } changeVisitOrderAction.putValue(Action.SMALL_ICON, KDClientUtils.getIcon(kdxFieldLayout.imageId)); List<Component> components = new ArrayList<>(); components.add(alwaysOnTopOption); Collections.addAll(components, new JButton(changeVisitOrderAction), new JButton(curationHelpAction), traitInstanceCombo); Box resizeControls = KDClientUtils.createResizeControls(fieldLayoutTable, fontForResizeControls, components.toArray(new Component[components.size()])); resizeCombo = KDClientUtils.findResizeCombo(resizeControls); if (RunMode.getRunMode().isDeveloper()) { new FieldLayoutViewPanel.DebugSettings(resizeControls, messagePrinter); } JPanel fieldPanel = new JPanel(new BorderLayout()); // if (useSeparator) { // SeparatorPanel separator = GuiUtil.createLabelSeparator("Field Layout:", resizeControls); // fieldPanel.add(separator, BorderLayout.NORTH); // fieldPanel.add(fieldTableScrollPane, BorderLayout.CENTER); // } // else { fieldPanel.add(resizeControls, BorderLayout.NORTH); fieldPanel.add(fieldTableScrollPane, BorderLayout.CENTER); // } // splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, // plotCellChoicesPanel, // fieldPanel); // splitPane.setResizeWeight(0.0); // splitPane.setOneTouchExpandable(true); add(warningMessage, BorderLayout.NORTH); add(fieldPanel, BorderLayout.CENTER); // splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, // plotCellChoicesPanel, // fieldPanel); // splitPane.setResizeWeight(0.0); // splitPane.setOneTouchExpandable(true); // // add(warningMessage, BorderLayout.NORTH); // add(splitPane, BorderLayout.CENTER); fieldLayoutTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (SwingUtilities.isRightMouseButton(me) && 1 == me.getClickCount()) { me.consume(); List<Plot> plots = getSelectedPlots(); List<TraitInstance> checkedInstances = new ArrayList<>(); for (int index = traitInstanceCombo.getItemCount(); --index >= 1;) { Object item = traitInstanceCombo.getItemAt(index); if (item instanceof TraitInstance) { checkedInstances.add((TraitInstance) item); } } TraitInstance ti = fieldViewSelectionModel.getActiveTraitInstance(true); List<PlotOrSpecimen> plotSpecimens = new ArrayList<>(); plotSpecimens.addAll(plots); curationMenuProvider.showFieldViewToolMenu(me, plotSpecimens, ti, checkedInstances); } } }); }
From source file:edu.ku.brc.specify.tools.schemalocale.FieldItemPanel.java
/** * /*from w w w. ja v a 2 s.co m*/ */ public void buildUI() { setIgnoreChanges(true); fieldsList = createList(fieldsModel); fieldsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { getAllDataFromUI(); fieldSelected(); } } }); fieldsList.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { super.focusLost(e); //lastIndex = fieldsList.getSelectedIndex(); } }); fieldDescText.addKeyListener(new LengthWatcher(255)); // setting min and pref sizes to some bogus values so that textarea shrinks with dialog fieldNameText.addKeyListener(new LengthWatcher(64)); CellConstraints cc = new CellConstraints(); int y = 1; JScrollPane fldsp = UIHelper.createScrollPane(fieldsList); // LocalizableNameDescIFace PanelBuilder pb = new PanelBuilder(new FormLayout("max(200px;p),4px,p,2px,p,10px,p,2px,p,f:p:g", (includeHiddenUI ? "p,2px," : "") + (isDBSchema ? "p,2px,p,2px," : "") + (includeFormatAndAutoNumUI ? "p,2px,p,2px," : "") + "p,2px,p,2px,p,2px,p,2px,p,2px,p,2px,f:p:g"), this); pb.add(fldsp, cc.xywh(1, y, 1, 7 + (isDBSchema ? 4 : 0))); pb.add(fieldNameLbl = createI18NFormLabel("SL_LABEL", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldNameText, cc.xywh(5, y, 6, 1)); y += 2; if (includeHiddenUI) { pb.add(fieldHideChk, cc.xy(5, y)); y += 2; } pb.add(fieldDescLbl = createI18NFormLabel("SL_DESC", SwingConstants.RIGHT), cc.xy(3, y)); JScrollPane sp = new JScrollPane(fieldDescText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); pb.add(sp, cc.xywh(5, y, 6, 1)); y += 2; fieldDescText.setLineWrap(true); fieldDescText.setWrapStyleWord(true); if (isDBSchema) { fieldTypeTxt = createLabel(""); fieldLengthTxt = createLabel(""); pb.add(fieldTypeLbl = createI18NFormLabel("SL_TYPE", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldTypeTxt, cc.xy(5, y)); pb.add(fieldReqChk = createCheckBox(getResourceString("SL_REQ")), cc.xy(9, y)); y += 2; pb.add(fieldLengthLbl = createI18NFormLabel("SL_LENGTH", SwingConstants.RIGHT), cc.xy(3, y)); pb.add(fieldLengthTxt, cc.xy(5, y)); y += 2; fieldTypeTxt.setBackground(Color.WHITE); fieldLengthTxt.setBackground(Color.WHITE); fieldTypeTxt.setOpaque(true); fieldLengthTxt.setOpaque(true); } if (includeFormatAndAutoNumUI) { PanelBuilder inner = new PanelBuilder(new FormLayout("p,2px,p", "p")); formatSwitcherCombo = createComboBox(); fmtCardLayout = new CardLayout(); formatterPanel = new JPanel(fmtCardLayout); pb.add(formatLbl = createI18NFormLabel("SL_FMTTYPE", SwingConstants.RIGHT), cc.xy(3, y)); inner.add(formatSwitcherCombo, cc.xy(1, 1)); inner.add(formatterPanel, cc.xy(3, 1)); pb.add(inner.getPanel(), cc.xywh(5, y, 6, 1)); y += 2; ActionListener switchAL = new ActionListener() { public void actionPerformed(ActionEvent e) { String item = (String) formatSwitcherCombo.getSelectedItem(); if (item != null) { fmtCardLayout.show(formatterPanel, item); webLinkCombo.setEnabled(item.equals(SL_WEBLINK)); if (formatSwitcherCombo.getSelectedIndex() == 0) { if (webLinkCombo.getModel().getSize() > 0) { webLinkCombo.setSelectedIndex(0); } if (formatCombo.getModel().getSize() > 0) { formatCombo.setSelectedIndex(0); } if (pickListCBX.getModel().getSize() > 0) { pickListCBX.setSelectedIndex(0); } } } } }; formatSwitcherCombo.addActionListener(switchAL); formatterPanel.add(SL_NONE, new JPanel()); //-------------------------- // UIFieldFormatter //-------------------------- inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); formatCombo = createComboBox(new DefaultComboBoxModel()); formatMoreBtn = createButton(ELIPSES); inner.add(formatCombo, cc.xy(1, 1)); inner.add(formatMoreBtn, cc.xy(3, 1)); formatMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UIFormatterListEdtDlg dlg = new UIFormatterListEdtDlg((Frame) UIRegistry.getTopWindow(), fieldInfo, true, schemaPanel.getUiFieldFormatterMgrCache()); dlg.setVisible(true); if (!dlg.isCancelled() && dlg.hasChanged()) { //schemaPanel.setHasChanged(true); formHasChanged(); //fillFormatBox(dlg.getSelectedFormat()); setSelectedFieldFormatter(dlg.getSelectedFormat()); } } }); formatterPanel.add(SL_FORMAT, inner.getPanel()); ActionListener changed = new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); boolean hasFormat = formatCombo.getSelectedIndex() > 0; webLinkCombo.setEnabled(!hasFormat); if (hasFormat) { webLinkCombo.setSelectedIndex(webLinkCombo.getModel().getSize() > 0 ? 0 : -1); pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? 0 : -1); } } }; formatCombo.addActionListener(changed); //-------------------------- // WebLinks //-------------------------- webLinkMoreBtn = createButton(ELIPSES); webLinkMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { WebLinkDef selectedWL = (WebLinkDef) webLinkCombo.getSelectedItem(); WebLinkConfigDlg dlg = webLinkMgrCache.editWebLinks(tableInfo, false); if (dlg.getBtnPressed() == CustomDialog.OK_BTN) { fillWebLinkBox(); formHasChanged(); if (selectedWL != null && !selectedWL.getName().equals(SL_WEBLINK)) { dlg.setWebLink(selectedWL.getName()); } if (dlg.getBtnPressed() == CustomDialog.OK_BTN) { setSelectedWebLink(dlg.getSelectedItem()); } } } }); inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); webLinkCombo = createComboBox(); DefaultComboBoxModel model = (DefaultComboBoxModel) webLinkCombo.getModel(); model.addElement(webLinkDefNone); webLinkCombo.setSelectedIndex(0); inner.add(webLinkCombo, cc.xy(1, 1)); inner.add(webLinkMoreBtn, cc.xy(3, 1)); ActionListener wlchanged = new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); boolean hasWL = webLinkCombo.getSelectedIndex() > 0; webLinkCombo.setEnabled(hasWL); if (hasWL) { formatCombo.setSelectedIndex(formatCombo.getModel().getSize() > 0 ? 0 : -1); pickListCBX.setSelectedIndex(pickListCBX.getModel().getSize() > 0 ? 0 : -1); } } }; webLinkCombo.addActionListener(wlchanged); formatterPanel.add(SL_WEBLINK, inner.getPanel()); } //-------------------------- // PickList //-------------------------- pickListCBX = createComboBox(new DefaultComboBoxModel()); pickListCBX.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { formHasChanged(); if (formatCombo != null && pickListCBX.getSelectedIndex() > 0) { formatCombo.setSelectedIndex(formatCombo.getModel().getSize() > 0 ? 0 : -1); webLinkCombo.setSelectedIndex(webLinkCombo.getModel().getSize() > 0 ? 0 : -1); } } }); pickListMoreBtn = createButton(ELIPSES); pickListMoreBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LocalizableItemIFace currentField = prevField; prevField = getSelectedFieldItem(); PickList selectedItem = (PickList) pickListCBX.getSelectedItem(); PickListEditorDlg dlg = new PickListEditorDlg( localizableIO.hasUpdatablePickLists() ? null : localizableIO, true, true); dlg.setTableInfo(tableInfo); dlg.setFieldInfo(fieldInfo); dlg.createUI(); dlg.setSize(400, 500); dlg.setVisible(true); if (!dlg.isCancelled()) { if (dlg.hasChanged()) { hasChanged = true; Vector<PickList> list = dlg.getNewPickLists(); DefaultComboBoxModel plCbxModel = (DefaultComboBoxModel) pickListCBX.getModel(); for (int i = 0; i < plCbxModel.getSize(); i++) { list.add((PickList) plCbxModel.getElementAt(i)); } Collections.sort(list); plCbxModel.removeAllElements(); plCbxModel.addElement(pickListNone); int inx = -1; int i = 0; for (PickList pl : list) { plCbxModel.addElement(pl); if (inx == -1 && selectedItem != null && ((selectedItem.getId() != null && pl.getId() != null && selectedItem.getId().equals(pl.getId())) || (selectedItem.getName() != null && pl.getName() != null && selectedItem.getName().equals(pl.getName())))) { inx = i; } i++; } pickListCBX.setSelectedIndex(inx + 1); } } prevField = currentField; } }); if (includeFormatAndAutoNumUI) { PanelBuilder inner = new PanelBuilder(new FormLayout("max(p;150px),2px,min", "p")); inner.add(pickListCBX, cc.xy(1, 1)); inner.add(pickListMoreBtn, cc.xy(3, 1)); formatterPanel.add(SL_PICKLIST, inner.getPanel()); } else { pb.add(pickListLbl = createI18NFormLabel(SL_PICKLIST, SwingConstants.RIGHT), cc.xy(3, y)); pb.add(pickListCBX, cc.xy(5, y)); pb.add(pickListMoreBtn, cc.xy(7, y)); y += 2; } nxtBtn = createI18NButton("SL_NEXT"); nxtEmptyBtn = createI18NButton("SL_NEXT_EMPTY"); fldSpellChkBtn = createI18NButton("SL_SPELL_CHECK"); //JPanel bbp = ButtonBarFactory.buildCenteredBar(adjustButtonArray(new JButton[] {nxtEmptyBtn, nxtBtn, fldSpellChkBtn})); //bbp.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); //pb.add(bbp, cc.xywh(3, y, 8, 1)); nxtBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { next(); } }); nxtEmptyBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { nextEmpty(); } }); fldSpellChkBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (checker != null) { checker.spellCheck(fieldDescText); checker.spellCheck(fieldNameText); } } }); fieldHideChk.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { formHasChanged(); } }); fieldReqChk.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { formHasChanged(); } }); DocumentListener dl = new DocumentAdaptor() { @Override protected void changed(DocumentEvent e) { formHasChanged(); } }; fieldNameText.getDocument().addDocumentListener(dl); fieldDescText.getDocument().addDocumentListener(dl); /* if (formatTxt != null) { formatTxt.getDocument().addDocumentListener(dl); } */ SchemaI18NService.getInstance().checkCurrentLocaleMenu(); enableUIControls(false); setIgnoreChanges(false); }
From source file:org.ash.detail.DetailPanels.java
/** * Initialize DetailFrame/* w ww.j av a2s. c om*/ */ private void initialize() { this.setLayout(new BorderLayout()); this.setVisible(true); this.cpuSplitPaneMainDetail = new JSplitPane(); this.schedulerSplitPaneMainDetail = new JSplitPane(); this.userIOSplitPaneMainDetail = new JSplitPane(); this.systemIOSplitPaneMainDetail = new JSplitPane(); this.concurrencySplitPaneMainDetail = new JSplitPane(); this.applicationSplitPaneMainDetail = new JSplitPane(); this.commitSplitPaneMainDetail = new JSplitPane(); this.configurationSplitPaneMainDetail = new JSplitPane(); this.administrativeSplitPaneMainDetail = new JSplitPane(); this.networkSplitPaneMainDetail = new JSplitPane(); this.queuningSplitPaneMainDetail = new JSplitPane(); this.clusterSplitPaneMainDetail = new JSplitPane(); this.otherSplitPaneMainDetail = new JSplitPane(); this.cpuChartPanel = this.cpuStackedChartMainObjectDetail.createChartPanel(); this.schedulerChartPanel = this.schedulerStackedChartMainObjectDetail.createChartPanel(); this.userIOChartPanel = this.userIOStackedChartMainObjectDetail.createChartPanel(); this.systemIOChartPanel = this.systemIOStackedChartMainObjectDetail.createChartPanel(); this.concurrencyChartPanel = this.concurrencyStackedChartMainObjectDetail.createChartPanel(); this.applicationChartPanel = this.applicationStackedChartMainObjectDetail.createChartPanel(); this.commitChartPanel = this.commitStackedChartMainObjectDetail.createChartPanel(); this.configurationChartPanel = this.configurationStackedChartMainObjectDetail.createChartPanel(); this.administrativeChartPanel = this.administrativeStackedChartMainObjectDetail.createChartPanel(); this.networkChartPanel = this.networkStackedChartMainObjectDetail.createChartPanel(); this.queuningChartPanel = this.queuningStackedChartMainObjectDetail.createChartPanel(); this.clusterChartPanel = this.clusterStackedChartMainObjectDetail.createChartPanel(); this.otherChartPanel = this.otherStackedChartMainObjectDetail.createChartPanel(); /** Gantt graph */ this.cpuSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("cpuLabel.text")); this.schedulerSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("schedulerLabel.text")); this.userIOSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("userIOLabel.text")); this.systemIOSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("systemIOLabel.text")); this.concurrencySqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("concurrencyLabel.text")); this.applicationSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("applicationsLabel.text")); this.commitSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("commitLabel.text")); this.configurationSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("configurationLabel.text")); this.administrativeSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("administrativeLabel.text")); this.networkSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("networkLabel.text")); this.queuningSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("queueningLabel.text")); this.clusterSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("clusterLabel.text")); this.otherSqlsAndSessions = new GanttDetails(this.mainFrame, this.database, Options.getInstance().getResource("otherLabel.text")); this.cpuSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.cpuSplitPaneMainDetail.add(this.cpuChartPanel, "top"); this.cpuSplitPaneMainDetail.add(this.cpuSqlsAndSessions, "bottom"); this.cpuSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.cpuSplitPaneMainDetail.setOneTouchExpandable(true); this.schedulerSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.schedulerSplitPaneMainDetail.add(this.schedulerChartPanel, "top"); this.schedulerSplitPaneMainDetail.add(this.schedulerSqlsAndSessions, "bottom"); this.schedulerSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.schedulerSplitPaneMainDetail.setOneTouchExpandable(true); this.userIOSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.userIOSplitPaneMainDetail.add(this.userIOChartPanel, "top"); this.userIOSplitPaneMainDetail.add(this.userIOSqlsAndSessions, "bottom"); this.userIOSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.userIOSplitPaneMainDetail.setOneTouchExpandable(true); this.systemIOSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.systemIOSplitPaneMainDetail.add(this.systemIOChartPanel, "top"); this.systemIOSplitPaneMainDetail.add(this.systemIOSqlsAndSessions, "bottom"); this.systemIOSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.systemIOSplitPaneMainDetail.setOneTouchExpandable(true); this.concurrencySplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.concurrencySplitPaneMainDetail.add(this.concurrencyChartPanel, "top"); this.concurrencySplitPaneMainDetail.add(this.concurrencySqlsAndSessions, "bottom"); this.concurrencySplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.concurrencySplitPaneMainDetail.setOneTouchExpandable(true); this.applicationSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.applicationSplitPaneMainDetail.add(this.applicationChartPanel, "top"); this.applicationSplitPaneMainDetail.add(this.applicationSqlsAndSessions, "bottom"); this.applicationSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.applicationSplitPaneMainDetail.setOneTouchExpandable(true); this.commitSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.commitSplitPaneMainDetail.add(this.commitChartPanel, "top"); this.commitSplitPaneMainDetail.add(this.commitSqlsAndSessions, "bottom"); this.commitSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.commitSplitPaneMainDetail.setOneTouchExpandable(true); this.configurationSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.configurationSplitPaneMainDetail.add(this.configurationChartPanel, "top"); this.configurationSplitPaneMainDetail.add(this.configurationSqlsAndSessions, "bottom"); this.configurationSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.configurationSplitPaneMainDetail.setOneTouchExpandable(true); this.administrativeSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.administrativeSplitPaneMainDetail.add(this.administrativeChartPanel, "top"); this.administrativeSplitPaneMainDetail.add(this.administrativeSqlsAndSessions, "bottom"); this.administrativeSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.administrativeSplitPaneMainDetail.setOneTouchExpandable(true); this.networkSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.networkSplitPaneMainDetail.add(this.networkChartPanel, "top"); this.networkSplitPaneMainDetail.add(this.networkSqlsAndSessions, "bottom"); this.networkSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.networkSplitPaneMainDetail.setOneTouchExpandable(true); this.queuningSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.queuningSplitPaneMainDetail.add(this.queuningChartPanel, "top"); this.queuningSplitPaneMainDetail.add(this.queuningSqlsAndSessions, "bottom"); this.queuningSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.queuningSplitPaneMainDetail.setOneTouchExpandable(true); this.clusterSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.clusterSplitPaneMainDetail.add(this.clusterChartPanel, "top"); this.clusterSplitPaneMainDetail.add(this.clusterSqlsAndSessions, "bottom"); this.clusterSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.clusterSplitPaneMainDetail.setOneTouchExpandable(true); this.otherSplitPaneMainDetail.setOrientation(JSplitPane.VERTICAL_SPLIT); this.otherSplitPaneMainDetail.add(this.otherChartPanel, "top"); this.otherSplitPaneMainDetail.add(this.otherSqlsAndSessions, "bottom"); this.otherSplitPaneMainDetail.setDividerLocation(this.dividerLocation); this.otherSplitPaneMainDetail.setOneTouchExpandable(true); this.tabsDetail.add(this.cpuSplitPaneMainDetail, Options.getInstance().getResource("cpuLabel.text")); this.tabsDetail.add(this.schedulerSplitPaneMainDetail, Options.getInstance().getResource("schedulerLabel.text")); this.tabsDetail.add(this.userIOSplitPaneMainDetail, Options.getInstance().getResource("userIOLabel.text")); this.tabsDetail.add(this.systemIOSplitPaneMainDetail, Options.getInstance().getResource("systemIOLabel.text")); this.tabsDetail.add(this.concurrencySplitPaneMainDetail, Options.getInstance().getResource("concurrencyLabel.text")); this.tabsDetail.add(this.applicationSplitPaneMainDetail, Options.getInstance().getResource("applicationsLabel.text")); this.tabsDetail.add(this.commitSplitPaneMainDetail, Options.getInstance().getResource("commitLabel.text")); this.tabsDetail.add(this.configurationSplitPaneMainDetail, Options.getInstance().getResource("configurationLabel.text")); this.tabsDetail.add(this.administrativeSplitPaneMainDetail, Options.getInstance().getResource("administrativeLabel.text")); this.tabsDetail.add(this.networkSplitPaneMainDetail, Options.getInstance().getResource("networkLabel.text")); this.tabsDetail.add(this.queuningSplitPaneMainDetail, Options.getInstance().getResource("queueningLabel.text")); this.tabsDetail.add(this.clusterSplitPaneMainDetail, Options.getInstance().getResource("clusterLabel.text")); this.tabsDetail.add(this.otherSplitPaneMainDetail, Options.getInstance().getResource("otherLabel.text")); this.cpuChartPanel.addListenerReleaseMouse(this.cpuSqlsAndSessions); this.schedulerChartPanel.addListenerReleaseMouse(this.schedulerSqlsAndSessions); this.userIOChartPanel.addListenerReleaseMouse(this.userIOSqlsAndSessions); this.systemIOChartPanel.addListenerReleaseMouse(this.systemIOSqlsAndSessions); this.concurrencyChartPanel.addListenerReleaseMouse(this.concurrencySqlsAndSessions); this.applicationChartPanel.addListenerReleaseMouse(this.applicationSqlsAndSessions); this.commitChartPanel.addListenerReleaseMouse(this.commitSqlsAndSessions); this.configurationChartPanel.addListenerReleaseMouse(this.configurationSqlsAndSessions); this.administrativeChartPanel.addListenerReleaseMouse(this.administrativeSqlsAndSessions); this.networkChartPanel.addListenerReleaseMouse(this.networkSqlsAndSessions); this.queuningChartPanel.addListenerReleaseMouse(this.queuningSqlsAndSessions); this.clusterChartPanel.addListenerReleaseMouse(this.clusterSqlsAndSessions); this.otherChartPanel.addListenerReleaseMouse(this.otherSqlsAndSessions); this.cpuChartPanel.addListenerReleaseMouse(this.statusBar); this.schedulerChartPanel.addListenerReleaseMouse(this.statusBar); this.userIOChartPanel.addListenerReleaseMouse(this.statusBar); this.systemIOChartPanel.addListenerReleaseMouse(this.statusBar); this.concurrencyChartPanel.addListenerReleaseMouse(this.statusBar); this.applicationChartPanel.addListenerReleaseMouse(this.statusBar); this.commitChartPanel.addListenerReleaseMouse(this.statusBar); this.configurationChartPanel.addListenerReleaseMouse(this.statusBar); this.administrativeChartPanel.addListenerReleaseMouse(this.statusBar); this.networkChartPanel.addListenerReleaseMouse((Object) this.statusBar); this.queuningChartPanel.addListenerReleaseMouse((Object) this.statusBar); this.clusterChartPanel.addListenerReleaseMouse((Object) this.statusBar); this.otherChartPanel.addListenerReleaseMouse((Object) this.statusBar); ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource(); int index = sourceTabbedPane.getSelectedIndex(); statusBar.updateLabelStringDetail(sourceTabbedPane.getTitleAt(index)); } }; tabsDetail.addChangeListener(changeListener); this.add(tabsDetail, BorderLayout.CENTER); }