Skip to content

#67 - Use smart time (configurable) #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions sqldev/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version>
<jdk.version.test>1.8</jdk.version.test>
<xtend.version>2.15.0</xtend.version>
<xtend.version>2.18.0</xtend.version>
<!-- requires SQL Developer 4.1.0 or higher (first version based on JDK 1.8) -->
<sqldev.basedir>/Applications/SQLDeveloper19.1.0.app/Contents/Resources/sqldeveloper</sqldev.basedir>
<final.name>utplsql_for_SQLDev_${project.version}</final.name>
Expand Down Expand Up @@ -170,17 +170,17 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.1.0.RELEASE</version>
<version>5.1.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.0.RELEASE</version>
<version>5.1.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.oddgen</groupId>
<artifactId>org.oddgen.sqldev</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -264,7 +264,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<version>2.22.2</version>
<configuration>
<!-- -noverify is required in some environments to avoid java.lang.VerifyError -->
<argLine>-noverify
Expand Down Expand Up @@ -296,7 +296,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<version>1.8</version><!--$NO-MVN-MAN-VER$-->
<executions>
<execution>
<phase>prepare-package</phase>
Expand Down Expand Up @@ -400,7 +400,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.0.0</version>
<version>4.2.0</version>
<extensions>true</extensions>
<configuration>
<finalName>${project.name}</finalName>
Expand Down Expand Up @@ -450,7 +450,7 @@
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.1</version><!--$NO-MVN-MAN-VER$-->
<configuration>
<finalName>${final.name}</finalName>
<appendAssemblyId>false</appendAssemblyId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class PreferenceModel extends HashStructureAdapter {
static final String KEY_CLEAR_SCREEN = "clearScreen"
static final String KEY_AUTO_EXECUTE = "autoExecute"
static final String KEY_CHECK_RUN_UTPLSQL_TEST = "checkRunUtplsqlTest"
static final String KEY_USE_SMART_TIMES = "useSmartTimes"
static final String KEY_NUMBER_OF_RUNS_IN_HISTORY = "numberOfRunsInHistory"
static final String KEY_SHOW_DISABLED_COUNTER = "showDisabledCounter"
static final String KEY_SHOW_WARNINGS_COUNTER = "showWarningsCounter"
Expand Down Expand Up @@ -110,6 +111,14 @@ class PreferenceModel extends HashStructureAdapter {
getHashStructure.putBoolean(PreferenceModel.KEY_CHECK_RUN_UTPLSQL_TEST, checkRunUtplsqlTest)
}

def isUseSmartTimes() {
return getHashStructure.getBoolean(PreferenceModel.KEY_USE_SMART_TIMES, false)
}

def setUseSmartTimes(boolean useSmartTimes) {
getHashStructure.putBoolean(PreferenceModel.KEY_USE_SMART_TIMES, useSmartTimes)
}

def getNumberOfRunsInHistory() {
return getHashStructure.getInt(PreferenceModel.KEY_NUMBER_OF_RUNS_IN_HISTORY, 10)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class UtplsqlRunner implements RealtimeReporterEventConsumer {

private def initGUI() {
var RunnerView dockable = null
if (runningInSqlDeveloper && (dockable = RunnerFactory.dockable as RunnerView) === null) {
if (runningInSqlDeveloper && (dockable = RunnerFactory.dockable) === null) {
logger.severe('''Error getting utPLSQL dockable. Cannot run utPLSQL test.''')
return false
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ import javax.swing.JButton
import javax.swing.JCheckBox
import javax.swing.JOptionPane
import javax.swing.JPanel
import javax.swing.JSeparator
import javax.swing.JSpinner
import javax.swing.JTabbedPane
import javax.swing.JTextField
import javax.swing.SpinnerNumberModel
import javax.swing.SwingConstants
import javax.swing.table.DefaultTableModel
import oracle.dbtools.raptor.templates.CodeTemplateUtil
import oracle.ide.panels.DefaultTraversablePanel
Expand All @@ -45,6 +47,7 @@ class PreferencePanel extends DefaultTraversablePanel {
val JCheckBox clearScreenCheckBox = new JCheckBox
val JCheckBox autoExecuteCheckBox = new JCheckBox
val JCheckBox checkRunUtplsqlTestCheckBox = new JCheckBox
val JCheckBox useSmartTimesCheckBox = new JCheckBox
val JButton importSnippetsButton = new JButton(UtplsqlResources.getString("PREF_IMPORT_SNIPPETS_BUTTON_LABEL"))
val JPanel realtimeReporterPanel = new JPanel
val SpinnerNumberModel numberOfRunsInHistoryModel = new SpinnerNumberModel(1, 1, 100, 1);
Expand Down Expand Up @@ -104,6 +107,10 @@ class PreferencePanel extends DefaultTraversablePanel {
runTab.add(
runTab.field.label.withText(UtplsqlResources.getString("PREF_CHECK_RUN_UTPLSQL_TEST_LABEL")).component(
checkRunUtplsqlTestCheckBox))
runTab.add(
runTab.field.label.withText(UtplsqlResources.getString("PREF_USE_SMART_TIMES_LABEL")).component(
useSmartTimesCheckBox))
runTab.addRow(new JSeparator(SwingConstants.HORIZONTAL))
runTab.addRow(importSnippetsButton)
runTab.addVerticalSpring

Expand Down Expand Up @@ -336,6 +343,7 @@ class PreferencePanel extends DefaultTraversablePanel {
clearScreenCheckBox.selected = info.clearScreen
autoExecuteCheckBox.selected = info.autoExecute
checkRunUtplsqlTestCheckBox.selected = info.checkRunUtplsqlTest
useSmartTimesCheckBox.selected = info.useSmartTimes
numberOfRunsInHistorySpinner.value = info.numberOfRunsInHistory
showDisabledCounterCheckBox.selected = info.showDisabledCounter
showWarningsCounterCheckBox.selected = info.showWarningsCounter
Expand Down Expand Up @@ -371,6 +379,7 @@ class PreferencePanel extends DefaultTraversablePanel {
info.autoExecute = autoExecuteCheckBox.selected
info.numberOfRunsInHistory = numberOfRunsInHistorySpinner.value as Integer
info.checkRunUtplsqlTest = checkRunUtplsqlTestCheckBox.selected
info.useSmartTimes = useSmartTimesCheckBox.selected
info.showDisabledCounter = showDisabledCounterCheckBox.selected
info.showWarningsCounter = showWarningsCounterCheckBox.selected
info.showInfoCounter = showInfoCounterCheckBox.selected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class GradientToolbar extends JToolBar {
val g2d = g as Graphics2D
val w = width
val h = height - 1
val h2 = height / 2 as int
val int h2 = height / 2
val colorTop = new Color(237, 237, 237)
val colorMiddle = new Color(244, 244, 244)
val colorBottom = new Color(254, 254, 254)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import java.awt.event.MouseEvent
import java.awt.event.MouseListener
import java.text.DecimalFormat
import java.util.ArrayList
import java.util.regex.Pattern
import javax.swing.BorderFactory
Expand Down Expand Up @@ -75,6 +74,7 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
static val INDICATOR_WIDTH = 20
static val OVERVIEW_TABLE_ROW_HEIGHT = 20
static val TEXTPANE_DIM = new Dimension(100, 100)
static var boolean useSmartTimes
LimitedLinkedHashMap<String, Run> runs = new LimitedLinkedHashMap<String, Run>(10)
Run currentRun
JPanel basePanel
Expand Down Expand Up @@ -338,6 +338,7 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
fixCheckBoxMenuItem(showInfoIndicatorCheckBoxMenuItem)
syncDetailTabCheckBoxMenuItem.selected = preferences.syncDetailTab
fixCheckBoxMenuItem(syncDetailTabCheckBoxMenuItem)
useSmartTimes = preferences.useSmartTimes
}

def setModel(Run run) {
Expand All @@ -349,7 +350,13 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
private def setCurrentRun(Run run) {
if (run !== currentRun) {
currentRun = run
testOverviewTableModel.setModel(run.tests, showTestDescriptionCheckBoxMenuItem.selected)
testOverviewTableModel.setModel(run.tests, showTestDescriptionCheckBoxMenuItem.selected, useSmartTimes)
val header = testOverviewTableModel.timeColumnName
val timeColumn = testOverviewTable.columnModel.getColumn(4)
if (timeColumn.headerValue != header) {
timeColumn.headerValue = header
testOverviewTable.tableHeader.repaint
}
resetDerived
val item = new ComboBoxItem<String, String>(currentRun.reporterId, currentRun.name)
runComboBox.selectedItem = item
Expand Down Expand Up @@ -640,12 +647,10 @@ class RunnerPanel implements ActionListener, MouseListener, HyperlinkListener {
}

static class TimeFormatRenderer extends DefaultTableCellRenderer {
static val DecimalFormat formatter = new DecimalFormat("#,##0.000")

override getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
int row, int col) {
val renderedValue = if (value === null) {null} else {formatter.format(value as Number)}
return super.getTableCellRendererComponent(table, renderedValue, isSelected, hasFocus, row, col)
val smartTime = new SmartTime(value as Double, useSmartTimes)
return super.getTableCellRendererComponent(table, smartTime.toString, isSelected, hasFocus, row, col)
}
}

Expand Down
72 changes: 72 additions & 0 deletions sqldev/src/main/java/org/utplsql/sqldev/ui/runner/SmartTime.xtend
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright 2019 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.utplsql.sqldev.ui.runner

import java.text.DecimalFormat

class SmartTime {
var Double seconds
var boolean smart = false

new() {
super()
}

new(Double seconds, boolean smart) {
super()
this.seconds = seconds
this.smart = smart
}

def setMillis(Double seconds) {
this.seconds = seconds
}

def setSmart(boolean smart) {
this.smart = smart
}

def getSeconds() {
return seconds
}

override toString() {
var String ret;
if (seconds === null) {
ret = null
} else if (smart) {
if (seconds >= 60*60) {
val DecimalFormat formatter = new DecimalFormat("#0.00")
ret = formatter.format(seconds / 60 / 60) + " h"
} else if (seconds >= 60) {
val DecimalFormat formatter = new DecimalFormat("#0.00")
ret = formatter.format(seconds / 60) + " min"
} else if (seconds >= 1) {
val DecimalFormat formatter = new DecimalFormat("#0.000")
ret = formatter.format(seconds) + " s"
} else {
val DecimalFormat formatter = new DecimalFormat("##0")
ret = formatter.format(seconds * 1000) + " ms"
}

} else {
val DecimalFormat formatter = new DecimalFormat("##,##0.000")
ret = formatter.format(seconds)
}
return ret
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class TestOverviewTableModel extends DefaultTableModel {
String commonPrefix
boolean commonPrefixCalculated
boolean showDescription
boolean useSmartTimes

new() {
super()
Expand All @@ -40,10 +41,11 @@ class TestOverviewTableModel extends DefaultTableModel {
}
}

def setModel(LinkedHashMap<String, Test> tests, boolean showDescription) {
def setModel(LinkedHashMap<String, Test> tests, boolean showDescription, boolean useSmartTimes) {
commonPrefixCalculated = false
this.tests = tests
this.showDescription = showDescription
this.useSmartTimes = useSmartTimes
calcCommonPrefix
fireTableDataChanged()
}
Expand All @@ -70,6 +72,11 @@ class TestOverviewTableModel extends DefaultTableModel {
}
}

def getTimeColumnName() {
val timeColumnName = '''«UtplsqlResources.getString("RUNNER_TEST_EXECUTION_TIME_COLUMN")»«IF !useSmartTimes» [s]«ENDIF»'''
return timeColumnName
}

def getTest(int row) {
val entry = tests.entrySet.get(row)
val test = tests.get(entry.key)
Expand Down Expand Up @@ -120,7 +127,7 @@ class TestOverviewTableModel extends DefaultTableModel {

override getColumnName(int col) {
return #["", "", "", UtplsqlResources.getString(if (showDescription) {"RUNNER_DESCRIPTION_LABEL"} else {"RUNNER_TEST_ID_COLUMN"}),
UtplsqlResources.getString("RUNNER_TEST_EXECUTION_TIME_COLUMN")].get(col)
timeColumnName].get(col)
}

override isCellEditable(int row, int column) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ PREF_RESET_PACKAGE_LABEL=Reset package before running utPLSQL?
PREF_CLEAR_SCREEN_LABEL=Clear script output panel before running utPLSQL?
PREF_AUTO_EXECUTE_LABEL=Execute unit test automatically?
PREF_CHECK_RUN_UTPLSQL_TEST_LABEL=Check availability of menu option?
PREF_USE_SMART_TIMES_LABEL=Use smart times?
PREF_IMPORT_SNIPPETS_BUTTON_LABEL=Import Snippets
MENU_REALTIME_REPORTER_LABEL=Realtime Reporter
PREF_NUMBER_OF_RUNS_IN_HISTORY_LABEL=Number of runs in history
Expand Down Expand Up @@ -89,7 +90,7 @@ RUNNER_NO_TESTS_FOUND_TEXT=No tests found.
RUNNER_RUN_MENUITEM=Run test
RUNNER_RUN_WORKSHEET_MENUITEM=Run test in new worksheet
RUNNER_TEST_ID_COLUMN=Suitepath
RUNNER_TEST_EXECUTION_TIME_COLUMN=Time [s]
RUNNER_TEST_EXECUTION_TIME_COLUMN=Time
RUNNER_OWNER_LABEL=Owner
RUNNER_PACKAGE_LABEL=Package
RUNNER_PROCEDURE_LABEL=Procedure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PREF_RESET_PACKAGE_LABEL=Package vor der Ausf
PREF_CLEAR_SCREEN_LABEL=Skriptausgabe-Fenster vor der Ausf�hrung von utPLSQL leeren?
PREF_AUTO_EXECUTE_LABEL=Unit Test automatisch ausf�hren?
PREF_CHECK_RUN_UTPLSQL_TEST_LABEL=Verf�gbarkeit der Men�option pr�fen?
PREF_USE_SMART_TIMES_LABEL=Smarte Zeitangaben verwenden?
PREF_IMPORT_SNIPPETS_BUTTON_LABEL=Code-Schnipsel importieren
MENU_REALTIME_REPORTER_LABEL=Realtime Reporter
PREF_NUMBER_OF_RUNS_IN_HISTORY_LABEL=Anzahl Ausf�hrungen in der Historie
Expand Down Expand Up @@ -66,7 +67,7 @@ RUNNER_NO_TESTS_FOUND_TEXT=Keine Tests gefunden.
RUNNER_RUN_MENUITEM=Run testTest ausf�hren
RUNNER_RUN_WORKSHEET_MENUITEM=Test in neuem Arbeitsblatt ausf�hruen
RUNNER_TEST_ID_COLUMN_NAME=Suitepath
RUNNER_TEST_EXECUTION_TIME_COLUMN_NAME=Zeit [s]
RUNNER_TEST_EXECUTION_TIME_COLUMN_NAME=Zeit
RUNNER_OWNER_LABEL=Besitzer
RUNNER_PACKAGE_LABEL=Paket
RUNNER_PROCEDURE_LABEL=Prozedur
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CodeCoverageReporterDialogTest extends AbstractJdbcTest{
val reporter = new CodeCoverageReporter(#["SCOTT"], #['a', 'b', 'c'], dataSource.connection)
reporter.showParameterWindow
Thread.sleep(4 * 1000)
reporter.frame.exit
reporter.frame?.exit
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class RealtimeReporterFetchSizeTest extends AbstractJdbcTest {

@Test
def void delayFreeStreamingConsumtion() {
val long TOLERANCE_MS = 400
val long TOLERANCE_MS = 600
var ds = new SingleConnectionDataSource()
ds.driverClassName = "oracle.jdbc.OracleDriver"
ds.url = dataSource.url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class PreferenceModelTest {
Assert.assertFalse(model.clearScreen)
Assert.assertTrue(model.autoExecute)
Assert.assertFalse(model.checkRunUtplsqlTest)
Assert.assertFalse(model.useSmartTimes)
Assert.assertEquals(model.numberOfRunsInHistory, 10)
Assert.assertFalse(model.showDisabledCounter)
Assert.assertFalse(model.showWarningsCounter)
Expand Down
Loading