Skip to content

Commit

Permalink
Merge branch 'release/v1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
S.Homburg authored and S.Homburg committed Oct 10, 2022
2 parents d43690e + 586c9c4 commit 4b50dd0
Show file tree
Hide file tree
Showing 14 changed files with 382 additions and 87 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [1.2.0] - 2022-10-08

### Added

- queries and result displayed in tabs (tabbed pane)

### Changed

- stabilize plugin

### Fixed

- some minor bugs fixed

### Security

## [1.1.0] - 2022-10-04

### Added
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
pluginVersion = 1.1.0
pluginVersion = 1.2.0
ideaVersion = 221.6008.13
javaSourceVersion = 11
javaTargetVersion = 11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@

import com.ceyoniq.nscale.al.core.Session;
import com.ceyoniq.nscale.al.core.cfg.IndexingPropertyDefinition;
import com.google.common.eventbus.Subscribe;
import com.hsofttec.intellij.querytester.events.DocumentAreaChangedEvent;
import com.hsofttec.intellij.querytester.services.ConnectionService;
import com.hsofttec.intellij.querytester.ui.notifiers.DocumentAreaChangedNotifier;
import com.hsofttec.intellij.querytester.utils.NqlLiterals;
import com.intellij.codeInsight.completion.CompletionResultSet;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.util.TextFieldCompletionProviderDumbAware;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
Expand All @@ -42,16 +43,19 @@

public class NqlCompletionProvider extends TextFieldCompletionProviderDumbAware {
private static final ConnectionService CONNECTION_SERVICE = ConnectionService.getInstance( );
private final Project project;

private Pattern pattern = Pattern.compile( "([.!? ,])" );

private final List<IndexingPropertyDefinition> indexingPropertyDefinitions = new ArrayList<>( );

public NqlCompletionProvider( ) {
public NqlCompletionProvider( Project project ) {
super( true );
this.project = project;
MessageBusConnection connect = project.getMessageBus( ).connect( );
connect.subscribe( DocumentAreaChangedNotifier.DOCUMENT_AREA_CHANGED_TOPIC, this::dcumentAreaChanged );
}


@Override
protected void addCompletionVariants( @NotNull String text, int offset, @NotNull String prefix, @NotNull CompletionResultSet result ) {
CompletionResultSet myResult;
Expand Down Expand Up @@ -83,12 +87,11 @@ protected void addCompletionVariants( @NotNull String text, int offset, @NotNull
result.stopHere( );
}

@Subscribe
public void dcumentAreaChanged( DocumentAreaChangedEvent event ) {
public void dcumentAreaChanged( String selectedDocumentAreaName ) {
Session session = CONNECTION_SERVICE.getSession( );
indexingPropertyDefinitions.clear( );
if ( session != null ) {
List<IndexingPropertyDefinition> definitions = session.getConfigurationService( ).getIndexingPropertyDefinitions( event.getDocumentAreaName( ) );
List<IndexingPropertyDefinition> definitions = session.getConfigurationService( ).getIndexingPropertyDefinitions( selectedDocumentAreaName );
indexingPropertyDefinitions.addAll( definitions );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public int getColumnCount( ) {
return result.getPropertyNames( ).size( );
}


@Override
public Object getValueAt( int rowIndex, int columnIndex ) {
return result.getDynaBeans( ).get( rowIndex );
Expand Down
98 changes: 53 additions & 45 deletions src/main/java/com/hsofttec/intellij/querytester/ui/QueryTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.hsofttec.intellij.querytester.services.HistorySettingsService;
import com.hsofttec.intellij.querytester.ui.components.*;
import com.hsofttec.intellij.querytester.ui.notifiers.*;
import com.hsofttec.intellij.querytester.utils.QueryTab;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.options.ShowSettingsUtil;
Expand All @@ -44,10 +45,12 @@
import com.intellij.openapi.ui.SimpleToolWindowPanel;
import com.intellij.ui.JBSplitter;
import com.intellij.ui.OnePixelSplitter;
import com.intellij.ui.components.*;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBPanel;
import com.intellij.ui.components.JBTabbedPane;
import com.intellij.util.messages.MessageBus;
import com.intellij.util.messages.MessageBusConnection;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
Expand All @@ -70,8 +73,6 @@ public class QueryTester extends SimpleToolWindowPanel {

private JPanel mainPanel;
private ConnectionSelect inputSelectedConnection;
private NscaleTable queryResultTable;
private NqlQueryTextbox inputNqlQuery;
private JComboBox<String> inputHistory;
private RepositoryRootTextField inputRepositoryRoot;
private DocumentAreaSelect inputDocumentArea;
Expand All @@ -80,6 +81,7 @@ public class QueryTester extends SimpleToolWindowPanel {
private JCheckBox inputVersion;
private MasterdataScopeSelect inputMasterdataScope;
private ReconnectIcon iconReconnect;
private QueryTabbedPane queryTabbedPane;

public QueryTester( Project project ) {
super( false, true );
Expand All @@ -95,28 +97,37 @@ public QueryTester( Project project ) {
inputSelectedConnection.reloadItems( );

ResultTableContextMenu resultTableContextMenu = new ResultTableContextMenu( project );
queryResultTable.setComponentPopupMenu( resultTableContextMenu );
QueryTab activeQueryTab = queryTabbedPane.getActiveQueryTab( );
if ( activeQueryTab != null ) {
activeQueryTab.getQueryResultTable( ).setComponentPopupMenu( resultTableContextMenu );
}

resultTableContextMenu.setSelectParentFolderListener( new AbstractAction( ) {
@Override
public void actionPerformed( ActionEvent actionEvent ) {
BasicDynaBean basicDynaBean = ( BasicDynaBean ) queryResultTable.getValueAt( queryResultTable.getSelectedRow( ), queryResultTable.getSelectedColumn( ) );
String parentResourceId = ( String ) basicDynaBean.get( QueryTesterConstants.DBEAN_PROPERTY_NAME_KEY );
inputRepositoryRoot.setText( parentResourceId );
PrepareQueryExecutionNotifier notifier = messageBus.syncPublisher( PrepareQueryExecutionNotifier.PREPARE_QUERY_EXECUTION_TOPIC );
notifier.doAction( );
QueryTab activeQueryTab = queryTabbedPane.getActiveQueryTab( );
if ( activeQueryTab != null ) {
BasicDynaBean basicDynaBean = ( BasicDynaBean ) activeQueryTab.getQueryResultTable( ).getValueAt( activeQueryTab.getQueryResultTable( ).getSelectedRow( ), activeQueryTab.getQueryResultTable( ).getSelectedColumn( ) );
String parentResourceId = ( String ) basicDynaBean.get( QueryTesterConstants.DBEAN_PROPERTY_NAME_KEY );
inputRepositoryRoot.setText( parentResourceId );
PrepareQueryExecutionNotifier notifier = messageBus.syncPublisher( PrepareQueryExecutionNotifier.PREPARE_QUERY_EXECUTION_TOPIC );
notifier.doAction( );
}
}
} );

resultTableContextMenu.setSearchFromParentFolderListener( new AbstractAction( ) {
@Override
public void actionPerformed( ActionEvent actionEvent ) {
BasicDynaBean basicDynaBean = ( BasicDynaBean ) queryResultTable.getValueAt( queryResultTable.getSelectedRow( ), queryResultTable.getSelectedColumn( ) );
String resourceId = ( String ) basicDynaBean.get( QueryTesterConstants.DBEAN_PROPERTY_NAME_KEY );
BaseResource baseResource = CONNECTION_SERVICE.getBaseResource( resourceId );
inputRepositoryRoot.setText( baseResource.getParentresourceid( ) );
PrepareQueryExecutionNotifier notifier = messageBus.syncPublisher( PrepareQueryExecutionNotifier.PREPARE_QUERY_EXECUTION_TOPIC );
notifier.doAction( );
QueryTab activeQueryTab = queryTabbedPane.getActiveQueryTab( );
if ( activeQueryTab != null ) {
BasicDynaBean basicDynaBean = ( BasicDynaBean ) activeQueryTab.getQueryResultTable( ).getValueAt( activeQueryTab.getQueryResultTable( ).getSelectedRow( ), activeQueryTab.getQueryResultTable( ).getSelectedColumn( ) );
String resourceId = ( String ) basicDynaBean.get( QueryTesterConstants.DBEAN_PROPERTY_NAME_KEY );
BaseResource baseResource = CONNECTION_SERVICE.getBaseResource( resourceId );
inputRepositoryRoot.setText( baseResource.getParentresourceid( ) );
PrepareQueryExecutionNotifier notifier = messageBus.syncPublisher( PrepareQueryExecutionNotifier.PREPARE_QUERY_EXECUTION_TOPIC );
notifier.doAction( );
}
}
} );

Expand All @@ -125,7 +136,10 @@ public void actionPerformed( ActionEvent actionEvent ) {
inputHistory.addActionListener( actionEvent -> {
String selectedItem = ( String ) inputHistory.getSelectedItem( );
if ( StringUtils.isNotBlank( selectedItem ) ) {
inputNqlQuery.setText( selectedItem );
QueryTab activeQueryTab1 = queryTabbedPane.getActiveQueryTab( );
if ( activeQueryTab1 != null ) {
activeQueryTab1.getQueryTextbox( ).setText( selectedItem );
}
}
} );

Expand All @@ -151,8 +165,7 @@ private void subscribeNotifications( ) {
public void beforeAction( ConnectionSettings settings ) {
UIUtil.invokeLaterIfNeeded( ( ) -> {
inputSelectedConnection.setEnabled( false );
queryResultTable.setEnabled( false );
inputNqlQuery.setEnabled( false );
queryTabbedPane.setEnabled( false );
inputHistory.setEnabled( false );
inputDocumentArea.setEnabled( false );
iconReconnect.setEnabled( false );
Expand All @@ -166,8 +179,7 @@ public void beforeAction( ConnectionSettings settings ) {
public void afterAction( ConnectionSettings settings, boolean connectedSuccessful ) {
UIUtil.invokeLaterIfNeeded( ( ) -> {
inputSelectedConnection.setEnabled( true );
queryResultTable.setEnabled( true );
inputNqlQuery.setEnabled( true );
queryTabbedPane.setEnabled( true );
inputHistory.setEnabled( true );
inputDocumentArea.setEnabled( true );
iconReconnect.setEnabled( true );
Expand All @@ -193,7 +205,7 @@ public void afterAction( ConnectionSettings settings, boolean connectedSuccessfu
String documentAreaName = ( String ) inputDocumentArea.getSelectedItem( );
String masterdataScope = ( String ) inputMasterdataScope.getSelectedItem( );
String repositoryRoot = inputRepositoryRoot.getText( );
String nqlQuery = inputNqlQuery.getText( );
String nqlQuery = queryTabbedPane.getActiveQueryTab( ).getQueryTextbox( ).getText( );
QueryType queryType = QueryType.DEFAULT;
boolean aggregate = inputAggregate.isSelected( );
boolean version = inputVersion.isSelected( );
Expand Down Expand Up @@ -251,6 +263,7 @@ public void connectionRemoved( ConnectionSettings settings ) {
messageBusConnection.subscribe( StartQueryExecutionNotifier.START_QUERY_EXECUTION_TOPIC, new StartQueryExecutionNotifier( ) {
@Override
public void doAction( ConnectionSettings connectionSettings, QueryMode queryMode, String documentAreaName, String masterdataScope, String rootResourceId, String nqlQuery, QueryType queryType ) {
NscaleTable queryResultTable = queryTabbedPane.getActiveQueryTab( ).getQueryResultTable( );
queryResultTable.startQueryExecution( connectionSettings, queryMode, documentAreaName, masterdataScope, rootResourceId, nqlQuery, queryType );
}
} );
Expand All @@ -271,29 +284,39 @@ public void doAction( String rootResourceId ) {
messageBusConnection.subscribe( OptimizeTableHeaderWidthNotifier.OPTIMIZE_TABLE_HEADER_WIDTH_TOPIC, new OptimizeTableHeaderWidthNotifier( ) {
@Override
public void doAction( ) {
queryResultTable.calcHeaderWidth( );
QueryTab activeQueryTab = queryTabbedPane.getActiveQueryTab( );
activeQueryTab.getQueryResultTable( ).calcHeaderWidth( );
}
} );
messageBusConnection.subscribe( FontSettingsChangedNotifier.FONT_SETTINGS_CHANGED_TOPIC, new FontSettingsChangedNotifier( ) {
@Override
public void doAction( ) {
NscaleTable queryResultTable = queryTabbedPane.getActiveQueryTab( ).getQueryResultTable( );
NqlQueryTextbox queryTextbox = queryTabbedPane.getActiveQueryTab( ).getQueryTextbox( );
queryResultTable.fontSettingsChanged( );
inputNqlQuery.fontSettingsChanged( );
queryTextbox.fontSettingsChanged( );
}
} );
}

private JComponent createToolBar( ) {
DefaultActionGroup actionGroup = new DefaultActionGroup( );

actionGroup.add( new AnAction( "Execute Query", "Start query execution", AllIcons.RunConfigurations.TestState.Run ) {
actionGroup.add( new AnAction( "Execute Active Query", "The active query execution", AllIcons.RunConfigurations.TestState.Run ) {
@Override
public void actionPerformed( @NotNull AnActionEvent e ) {
PrepareQueryExecutionNotifier notifier = messageBus.syncPublisher( PrepareQueryExecutionNotifier.PREPARE_QUERY_EXECUTION_TOPIC );
notifier.doAction( );
}
} );

actionGroup.add( new AnAction( "Add Query Tab", "Open a new query tab", AllIcons.Ide.Rating ) {
@Override
public void actionPerformed( @NotNull AnActionEvent e ) {
queryTabbedPane.createQueryTab( ( String ) inputDocumentArea.getSelectedItem( ) );
}
} );

actionGroup.add( new AnAction( "Add Connection", "Show the connection settings dialog", AllIcons.General.Add ) {
@Override
public void actionPerformed( AnActionEvent actionEvent ) {
Expand Down Expand Up @@ -330,32 +353,16 @@ private JComponent createUIComponents( ) {
mainSplitter.setHonorComponentsMinimumSize( true );
mainSplitter.setSplitterProportionKey( "main.splitter.key" );

JBSplitter leftPaneSplitter = new OnePixelSplitter( true, 03f );
leftPaneSplitter.setHonorComponentsMinimumSize( true );
leftPaneSplitter.setSplitterProportionKey( "query.splitter.key" );

JPanel leftPanel = new JBPanel<>( new BorderLayout( 3, 3 ) );
JPanel rightPanel = new JBPanel<>( new BorderLayout( 3, 3 ) );
rightPanel.setBorder( BorderFactory.createEmptyBorder( 5, 5, 5, 5 ) );
leftPanel.setBorder( BorderFactory.createEmptyBorder( 5, 5, 5, 5 ) );
leftPanel.add( leftPaneSplitter );

mainSplitter.setFirstComponent( leftPanel );
mainSplitter.setSecondComponent( rightPanel );

inputNqlQuery = new NqlQueryTextbox( project );
queryResultTable = new NscaleTable( project );
queryTabbedPane = new QueryTabbedPane( project );
queryTabbedPane.createQueryTab( null );

JPanel firstPanel = JBUI.Panels.simplePanel( );
firstPanel.add( new JBScrollPane( inputNqlQuery ) );
firstPanel.setBorder( BorderFactory.createEtchedBorder( ) );

JPanel secondPanel = JBUI.Panels.simplePanel( );
secondPanel.add( new JBScrollPane( queryResultTable ) );
secondPanel.setBorder( BorderFactory.createEtchedBorder( ) );

leftPaneSplitter.setFirstComponent( firstPanel );
leftPaneSplitter.setSecondComponent( secondPanel );
mainSplitter.setFirstComponent( queryTabbedPane );
mainSplitter.setSecondComponent( rightPanel );

mainPanel.add( mainSplitter );

Expand All @@ -365,6 +372,7 @@ private JComponent createUIComponents( ) {
return mainPanel;
}


private JComponent createTabPanel( ) {
CellConstraints cc = new CellConstraints( );
FormLayout formLayout = new FormLayout(
Expand Down
Loading

0 comments on commit 4b50dd0

Please sign in to comment.