List of usage examples for java.awt.event WindowEvent WindowEvent
public WindowEvent(Window source, int id)
From source file:net.lmxm.ute.gui.MainFrame.java
/** * Action exit.//w w w . ja va 2 s . c o m */ private void actionExit() { final WindowEvent wev = new WindowEvent(this, WindowEvent.WINDOW_CLOSING); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev); }
From source file:com.digitalgeneralists.assurance.ui.MainWindow.java
public void actionPerformed(ActionEvent e) { if (AssuranceActions.viewScanAction.equals(e.getActionCommand())) { this.topArea.setSelectedIndex(0); this.setMenuState(this.resultsMenuIndex, false); }//from w w w . ja v a 2 s . c o m if (AssuranceActions.viewHistoryAction.equals(e.getActionCommand())) { this.topArea.setSelectedIndex(1); this.setMenuState(this.scanMenuIndex, false); } if (AssuranceActions.quitApplicationAction.equals(e.getActionCommand())) { this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); } if (AssuranceActions.aboutApplicationAction.equals(e.getActionCommand())) { this.displayAboutDialog(); } if (AssuranceActions.displaySettingsAction.equals(e.getActionCommand())) { this.displayPreferencesDialog(); } }
From source file:com.sldeditor.test.unit.tool.vector.VectorToolTest.java
@Test public void testVectorToolDBDataSource() { TestMissingSLDAttributes testAttribute = new TestMissingSLDAttributes(); List<CheckAttributeInterface> checkList = new ArrayList<CheckAttributeInterface>(); checkList.add(testAttribute);/*from w w w . ja v a 2s. c o m*/ CheckAttributeFactory.setOverideCheckList(checkList); String testsldfile = "/polygon/sld/polygon_polygonwithdefaultlabel.sld"; TestSLDEditor testSLDEditor = null; try { testSLDEditor = TestSLDEditor.createAndShowGUI2(null, null, true, null); } catch (Exception e) { e.printStackTrace(); } RenderPanelImpl.setUnderTest(true); InputStream inputStream = VectorToolTest.class.getResourceAsStream(testsldfile); if (inputStream == null) { Assert.assertNotNull("Failed to find sld test file : " + testsldfile, inputStream); } else { File f = null; try { f = stream2file(inputStream); try { testSLDEditor.openFile(f.toURI().toURL()); } catch (NullPointerException nullException) { nullException.printStackTrace(); StackTraceElement[] stackTraceElements = nullException.getStackTrace(); System.out.println(stackTraceElements[0].getMethodName()); } f.delete(); } catch (IOException e1) { e1.printStackTrace(); } } // Fields extracted from the SLD file DataSourceInterface dataSource = DataSourceFactory.createDataSource(null); Collection<PropertyDescriptor> propertyList = dataSource.getPropertyDescriptorList(); assertEquals(2, propertyList.size()); Map<String, PropertyDescriptor> map = new HashMap<String, PropertyDescriptor>(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } AttributeDescriptor name = (AttributeDescriptor) map.get("name"); assertNotNull(name); GeometryDescriptor geometry = (GeometryDescriptor) map.get("geom"); assertNotNull(geometry); File tempFolder = Files.createTempDir(); TestVectorTool vectorTool = new TestVectorTool(testSLDEditor); try { InputStream gpkgInputStream = VectorToolTest.class .getResourceAsStream("/test/sld_cookbook_polygon.gpkg"); final File gpkgFile = new File(tempFolder, "sld_cookbook_polygon.gpkg"); try (FileOutputStream out = new FileOutputStream(gpkgFile)) { IOUtils.copy(gpkgInputStream, out); } DatabaseConnection databaseConnection = DatabaseConnectionFactory .getConnection(gpkgFile.getAbsolutePath()); DatabaseFeatureClassNode dbFCTreeNode = new DatabaseFeatureClassNode(null, databaseConnection, "sld_cookbook_polygon"); DatabaseConnectionManager.getInstance().addNewConnection(null, databaseConnection); vectorTool.testSetDataSource(dbFCTreeNode); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(3, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNotNull(name); geometry = (GeometryDescriptor) map.get("geometry"); assertNotNull(geometry); AttributeDescriptor pop = (AttributeDescriptor) map.get("pop"); assertNotNull(pop); // Create SLD from geopackage layer vectorTool.testImportFeatureClass(dbFCTreeNode); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(3, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNotNull(name); geometry = (GeometryDescriptor) map.get("geometry"); assertNotNull(geometry); pop = (AttributeDescriptor) map.get("pop"); assertNotNull(pop); // Release locks dataSource.reset(); } catch (IOException e) { e.printStackTrace(); fail(); } // Tidy up so the remaining unit tests are ok JFrame frame = testSLDEditor.getApplicationFrame(); frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); testSLDEditor = null; clearDown(); // Delete the shape files we extracted purgeDirectory(tempFolder); }
From source file:com.headswilllol.basiclauncher.Launcher.java
private static void pullThePlug() { WindowEvent wev = new WindowEvent(f, WindowEvent.WINDOW_CLOSING); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev); f.setVisible(false);// w w w .j a v a2 s . c o m f.dispose(); System.exit(0); }
From source file:com.sldeditor.test.SLDTestRunner.java
/** * Run the test/*from w w w .ja v a 2s . co m*/ * * @param folder the folder * @param testConfig the test config */ public void runTest(String folder, String testConfig) { // read JSON file data as String String fullPath = "/" + folder + "/test/" + testConfig; SldEditorTest testSuite = (SldEditorTest) ParseXML.parseFile("", fullPath, SCHEMA_RESOURCE, SldEditorTest.class); Assert.assertNotNull("Failed to read test config file : " + fullPath, testSuite); String testsldfile = testSuite.getTestsldfile(); if (!testsldfile.startsWith("/")) { testsldfile = "/" + testsldfile; } System.out.println("Opening : " + testsldfile); List<XMLVendorOption> xmlVendorOptionList = testSuite.getVendorOption(); if ((xmlVendorOptionList != null) && !xmlVendorOptionList.isEmpty()) { List<VersionData> versionDataList = new ArrayList<VersionData>(); for (XMLVendorOption vo : xmlVendorOptionList) { try { String vendorOptionClassName = vo.getClassType().trim(); Class<?> vendorOptionClass = Class.forName(vendorOptionClassName); VersionData versionData = VersionData.decode(vendorOptionClass, vo.getVersion()); versionDataList.add(versionData); } catch (ClassNotFoundException e) { e.printStackTrace(); } } if (!versionDataList.contains(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData())) { versionDataList.add(VendorOptionManager.getInstance().getDefaultVendorOptionVersionData()); } sldEditor.setVendorOptions(versionDataList); } InputStream inputStream = SLDTestRunner.class.getResourceAsStream(testsldfile); if (inputStream == null) { Assert.assertNotNull("Failed to find sld test file : " + testsldfile, inputStream); } else { File f = null; try { f = stream2file(inputStream); sldEditor.openFile(f.toURI().toURL()); } catch (IOException e1) { e1.printStackTrace(); } GraphicPanelFieldManager mgr = sldEditor.getFieldDataManager(); for (XMLPanelTest test : testSuite.getPanelTests()) { XMLSetup selectedItem = test.getSetup(); TreeSelectionData selectionData = new TreeSelectionData(); selectionData.setLayerIndex(getXMLValue(selectedItem.getLayer())); selectionData.setStyleIndex(getXMLValue(selectedItem.getStyle())); selectionData.setFeatureTypeStyleIndex(getXMLValue(selectedItem.getFeatureTypeStyle())); selectionData.setRuleIndex(getXMLValue(selectedItem.getRule())); selectionData.setSymbolizerIndex(getXMLValue(selectedItem.getSymbolizer())); selectionData.setSymbolizerDetailIndex(getXMLValue(selectedItem.getSymbolizerDetail())); try { selectionData.setSelectedPanel(Class.forName(selectedItem.getExpectedPanel())); } catch (ClassNotFoundException e1) { Assert.fail("Unknown class : " + selectedItem.getExpectedPanel()); } boolean result = sldEditor.selectTreeItem(selectionData); Assert.assertTrue("Failed to select tree item", result); PopulateDetailsInterface panel = sldEditor.getSymbolPanel(); String panelClassName = panel.getClass().getName(); Assert.assertEquals(panelClassName, selectedItem.getExpectedPanel()); Assert.assertEquals("Check panel data present", panel.isDataPresent(), selectedItem.isEnabled()); Class<?> panelId = null; try { panelId = Class.forName(selectedItem.getExpectedPanel()); } catch (ClassNotFoundException e) { e.printStackTrace(); } if (test.getFieldTests() != null) { for (XMLFieldTest testItem : test.getFieldTests()) { if (testItem != null) { if (testItem.getDisabledOrLiteralStringOrLiteralInt() != null) { for (Object xmlTestValueObj : testItem.getDisabledOrLiteralStringOrLiteralInt()) { if (xmlTestValueObj instanceof XMLSetMultiOptionGroup) { XMLSetMultiOptionGroup testValue = (XMLSetMultiOptionGroup) xmlTestValueObj; GroupIdEnum groupId = testValue.getMultiOptionGroupId(); String outputText = "Checking multioption group : " + groupId; System.out.println(outputText); Assert.assertNotNull(outputText, groupId); MultiOptionGroup multiOptionGroup = mgr.getMultiOptionGroup(panelId, groupId); Assert.assertNotNull(panelId.getName() + "/" + groupId + " multi option group should exist", multiOptionGroup); multiOptionGroup.setOption(testValue.getOption()); OptionGroup optionGroupSelected = multiOptionGroup.getSelectedOptionGroup(); Assert.assertTrue(groupId + " should be set", optionGroupSelected.getId() == testValue.getOption()); } else if (xmlTestValueObj instanceof XMLSetGroup) { XMLSetGroup testValue = (XMLSetGroup) xmlTestValueObj; GroupIdEnum groupId = testValue.getGroupId(); String outputText = "Checking group : " + groupId; System.out.println(outputText); Assert.assertNotNull(outputText, groupId); GroupConfig groupConfig = mgr.getGroup(panelId, groupId); Assert.assertNotNull( panelId.getName() + "/" + groupId + " group should exist", groupConfig); groupConfig.enable(testValue.isEnable()); Assert.assertTrue(groupId + " should be set", groupConfig.isPanelEnabled() == testValue.isEnable()); } else { XMLFieldBase testValue = (XMLFieldBase) xmlTestValueObj; FieldId fieldId = new FieldId(testValue.getField()); String outputText = "Checking : " + fieldId; System.out.println(outputText); Assert.assertNotNull(outputText, fieldId); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } FieldConfigBase fieldConfig = mgr.getData(panelId, fieldId); Assert.assertNotNull(String.format("Failed to field panel %s field %s", selectedItem.getExpectedPanel(), fieldId), fieldConfig); if (testValue instanceof XMLSetFieldLiteralBase) { XMLSetFieldLiteralInterface testInterface = (XMLSetFieldLiteralInterface) testValue; testInterface.accept(fieldConfig, fieldId); if (!((XMLSetFieldLiteralBase) testValue).isIgnoreCheck()) { String sldContentString = sldEditor.getSLDString(); boolean actualResult = testOutput.testValue(sldContentString, selectionData, testValue.getField(), testValue); Assert.assertTrue(fieldId + " should be set", actualResult); } } else if (testValue instanceof XMLSetFieldAttribute) { XMLSetFieldLiteralInterface testInterface = (XMLSetFieldLiteralInterface) testValue; testInterface.accept(fieldConfig, fieldId); String sldContentString = sldEditor.getSLDString(); boolean actualResult = testOutput.testAttribute(sldContentString, selectionData, testValue.getField(), (XMLSetFieldAttribute) testValue); Assert.assertTrue(fieldId + " should be set", actualResult); } else if (testValue instanceof XMLFieldDisabled) { Assert.assertFalse(fieldId + " should be disabled", fieldConfig.isEnabled()); } else { Assert.assertTrue(fieldId + " should be enabled", fieldConfig.isEnabled()); Expression expression = null; if (fieldConfig.isValueOnly()) { String expectedValue = ""; if (testValue instanceof XMLFieldLiteralBase) { Object literalValue = getLiteralValue( (XMLFieldLiteralBase) testValue); expectedValue = String.valueOf(literalValue); } else if (testValue instanceof XMLFieldAttribute) { expectedValue = ((XMLFieldAttribute) testValue).getAttribute(); } else if (testValue instanceof XMLFieldExpression) { expectedValue = ((XMLFieldExpression) testValue) .getExpression(); } else { Assert.fail(fieldId + " has unsupported type " + testValue.getClass().getName()); } String actualValue = fieldConfig.getStringValue(); String msg = String.format("%s Expected : '%s' Actual : '%s'", outputText, expectedValue, actualValue); boolean condition; if (comparingFilename(fieldId)) { condition = actualValue.endsWith(expectedValue); } else { condition = (expectedValue.compareTo(actualValue) == 0); } Assert.assertTrue(msg, condition); } else { if (colourFieldsList.contains(fieldId.getFieldId())) { FieldConfigColour fieldColour = (FieldConfigColour) fieldConfig; expression = fieldColour.getColourExpression(); } else { expression = fieldConfig.getExpression(); if (fieldId.getFieldId() == FieldIdEnum.SYMBOL_TYPE) { String string = expression.toString(); expression = ff .literal(string.replace(File.separatorChar, '/')); } else if (fieldId.getFieldId() == FieldIdEnum.FONT_FAMILY) { // Handle the case where a font is not available on all operating systems String string = expression.toString(); if (string.compareToIgnoreCase(DEFAULT_FONT) != 0) { expression = ff.literal(getFontForOS()); System.out.println("Updated font family to test for : " + expression.toString()); } } } if (expression != null) { if (testValue instanceof XMLFieldLiteralBase) { Object literalValue = getLiteralValue( (XMLFieldLiteralBase) testValue); if (literalValue.getClass() == Double.class) { checkLiteralValue(outputText, expression, (Double) literalValue); } else if (literalValue.getClass() == Integer.class) { checkLiteralValue(outputText, expression, (Integer) literalValue); } else if (literalValue.getClass() == String.class) { if (fieldId.getFieldId() == FieldIdEnum.FONT_FAMILY) { // Handle the case where a font is not available on all operating systems checkLiteralValue(outputText, expression, getFontForOS()); } else { checkLiteralValue(outputText, expression, (String) literalValue); } } } } else { String actualValue; String expectedValue = fieldConfig.getStringValue(); Object literalValue = getLiteralValue( (XMLFieldLiteralBase) testValue); if (literalValue.getClass() == Double.class) { actualValue = String.valueOf((Double) literalValue); } else if (literalValue.getClass() == Integer.class) { actualValue = String.valueOf((Integer) literalValue); } else if (literalValue.getClass() == String.class) { actualValue = (String) literalValue; } else { actualValue = ""; } String msg = String.format("%s Expected : '%s' Actual : '%s'", outputText, expectedValue, actualValue); boolean condition = (expectedValue.compareTo(actualValue) == 0); Assert.assertTrue(msg, condition); } } } } } } } } } } } JFrame frame = sldEditor.getApplicationFrame(); frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); }
From source file:au.com.jwatmuff.eventmanager.gui.main.MainWindow.java
private void fileExitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileExitMenuItemActionPerformed this.processWindowEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); }
From source file:gui.DownloadManagerGUI.java
@Override public void actionPerformed(ActionEvent e) { JMenuItem clicked = (JMenuItem) e.getSource(); if (clicked == exportDataItem) { // addNewDownloadDialog.setVisible(true); } else if (clicked == importDataItem) { // addNewDownloadDialog.setVisible(true); } else if (clicked == exitItem) { WindowListener[] listeners = getWindowListeners(); for (WindowListener listener : listeners) listener.windowClosing(new WindowEvent(DownloadManagerGUI.this, 0)); } else if (clicked == prefsItem) { preferenceDialog.setVisible(true); } else if (clicked == newDownloadItem) { addNewDownloadDialog.setVisible(true); addNewDownloadDialog.onPaste();//w w w . j a va2s . c o m } else if (clicked == openItem) { downloadPanel.actionOpenFile(); } else if (clicked == openFolderItem) { downloadPanel.actionOpenFolder(); } else if (clicked == resumeItem) { downloadPanel.actionResume(); } else if (clicked == pauseItem) { downloadPanel.actionPause(); mainToolbar.setStateOfButtonsControl(false, false, false, false, false, true); // canceled } else if (clicked == pauseAllItem) { int action = JOptionPane.showConfirmDialog(DownloadManagerGUI.this, "Do you realy want to pause all downloads?", "Confirm pause all", JOptionPane.OK_CANCEL_OPTION); ////*********** if (action == JOptionPane.OK_OPTION) { downloadPanel.actionPauseAll(); } } else if (clicked == clearItem) { downloadPanel.actionClear(); } else if (clicked == clearAllCompletedItem) { downloadPanel.actionClearAllCompleted(); } else if (clicked == reJoinItem) { downloadPanel.actionReJoinFileParts(); } else if (clicked == reDownloadItem) { downloadPanel.actionReDownload(); } else if (clicked == moveToQueueItem) { // mainToolbarListener.preferencesEventOccured(); } else if (clicked == removeFromQueueItem) { // mainToolbarListener.preferencesEventOccured(); } else if (clicked == propertiesItem) { downloadPanel.actionProperties(); } else if (clicked == aboutItem) { if (!aboutDialog.isVisible()) aboutDialog.setVisible(true); } }
From source file:paintbasico2d.VentanaPrincipal.java
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed JOptionPane.showMessageDialog(jMenuImagen, "Gracias por utilizar nuestro programa."); this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); }
From source file:course_generator.frmMain.java
/** * Called by the quit application menu/*from ww w . ja va 2s . c o m*/ * * @param evt */ private void mnuQuitActionPerformed(java.awt.event.ActionEvent evt) { this.processWindowEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); }