From 22df771422d7c2c642cd09864b3b574b507fa102 Mon Sep 17 00:00:00 2001 From: satr Date: Sun, 22 Jul 2018 22:05:31 +0200 Subject: [PATCH] Fixed button layout for the version IDEA 2018.2.RC. The list of AWS streams has been ordered by event time, descendant. Added a button to load next list of AWS stream set (split by 50 items). --- sources/.idea/workspace.xml | 491 +++++++++++------- sources/resources/META-INF/plugin.xml | 6 +- sources/resources/icons/iconNextAwsLogSet.png | Bin 0 -> 1387 bytes .../resources/icons/iconNextAwsLogSet@2x.png | Bin 0 -> 1479 bytes .../icons/iconNextAwsLogSet@2x_dark.png | Bin 0 -> 1479 bytes .../icons/iconNextAwsLogSet_dark.png | Bin 0 -> 1383 bytes .../la/entities/AwsLogStreamEntity.java | 14 +- .../la/models/FunctionConnectorModel.java | 71 ++- .../connector/la/ui/ConnectorPresenter.java | 1 + .../la/ui/ConnectorPresenterImpl.java | 16 +- .../plugin/connector/la/ui/ConnectorView.form | 61 ++- .../connector/la/ui/ConnectorViewFactory.java | 15 +- 12 files changed, 456 insertions(+), 219 deletions(-) create mode 100644 sources/resources/icons/iconNextAwsLogSet.png create mode 100644 sources/resources/icons/iconNextAwsLogSet@2x.png create mode 100644 sources/resources/icons/iconNextAwsLogSet@2x_dark.png create mode 100644 sources/resources/icons/iconNextAwsLogSet_dark.png diff --git a/sources/.idea/workspace.xml b/sources/.idea/workspace.xml index e88aaee..dd4e0a5 100644 --- a/sources/.idea/workspace.xml +++ b/sources/.idea/workspace.xml @@ -2,9 +2,18 @@ - + + + + - + + + + + + + @@ -30,31 +39,66 @@ + @@ -312,17 +378,19 @@ - - + + + + - + @@ -348,9 +416,15 @@ + + @@ -401,6 +481,9 @@ @@ -457,6 +540,13 @@ + + + + + + + 1520437214334 @@ -570,11 +660,18 @@ - - @@ -587,36 +684,37 @@ + - + - - - - + + + + - + + - + - - + + - + - @@ -678,7 +776,8 @@ - @@ -688,97 +787,66 @@ 58 + + file://$PROJECT_DIR$/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorPresenterImpl.java + 333 + + - - e.getClickCount() + updateProxySettingsButton JAVA EXPRESSION - ((JList)e.getSource()).getSelectedIndex() + updateProxySettingsButton.getBackground() JAVA EXPRESSION - ((JList)e.getSource()) + e.getClickCount() JAVA EXPRESSION - e.source + ((JList)e.getSource()).getSelectedIndex() JAVA EXPRESSION - e + ((JList)e.getSource()) JAVA EXPRESSION - e.getSource() + e.source JAVA EXPRESSION - e.getFirstIndex() + e JAVA EXPRESSION - e.getLastIndex() + e.getSource() JAVA EXPRESSION - reformattedJsonText.replaceAll("\\n", "\n") + e.getFirstIndex() JAVA EXPRESSION - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -812,13 +880,6 @@ - - - - - - - @@ -903,22 +964,41 @@ - + + - - + + - + - - + + - - + + + + + + + + + + + + + + + + + + + + @@ -927,84 +1007,133 @@ - + - - + + - - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + + + + + - - + + - + - - + + - + - - + + + + + + - + - - + + + + + + + + + + + + + + + + diff --git a/sources/resources/META-INF/plugin.xml b/sources/resources/META-INF/plugin.xml index 3d01550..6b41b04 100644 --- a/sources/resources/META-INF/plugin.xml +++ b/sources/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ io.github.satr.idea.plugin.connector.la Connector for AWS Lambda - 1.6 + 1.7.RC1 github.com/satr +
  • 1.7.RC1
  • +
  • Fixed button layout for the version IDEA 2018.2.RC
  • +
  • The list of AWS streams has been ordered by event time, descendant.
  • +
  • Added a button to load next list of AWS stream set (split by 50 items).
  • 1.6
  • Save and restore selected jar artifact per function - implemented by DragoX.
  • Fix last selected function restore after relaunch - implemented by DragoX.
  • diff --git a/sources/resources/icons/iconNextAwsLogSet.png b/sources/resources/icons/iconNextAwsLogSet.png new file mode 100644 index 0000000000000000000000000000000000000000..e526a2c3cf28cc9061213eef3bece708c5573039 GIT binary patch literal 1387 zcmV-x1(f=UP)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|uwRK0yDg0B4PV z0id6JRRdfL?*IS+4M{{nR5%gskg-YwK@f)jnLVTAWS7gOP#?fXun-iV#Lh|(3|y`W z_zJdym2V(cmV!@UW#bE2Scn=Vh4El_+`T}!TSQWeQ!MlU^UXi7z<;SlzCahf{mx#p zTHRN#G0(B_lNQDnsij9f>|Ld0w%ufA0f$J_LAur)w0i5_2*gBmpoAWDncwJA?*@j# zV~Xq)%x8dn2=ENS*uztSeED91sPDm@z&6XzZ}+6>D+&v?+xVne!D^@-+Mt9Pxj zIWd`KwLuC-oLym79TGSTs}(2L^Hq_Fa~Mr7-Y;7Lb0BUCEE~?JwJma2ksN)VkDp@f tSFMNni!QT)hZZ{;r*)6J>#_Go^f&&TLSx@=I5_|S002ovPDHLkV1iFKs3iaZ literal 0 HcmV?d00001 diff --git a/sources/resources/icons/iconNextAwsLogSet@2x.png b/sources/resources/icons/iconNextAwsLogSet@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..dac58aaa0dd0d3e184cf502c36fa05648045b89d GIT binary patch literal 1479 zcmV;&1vvVNP)Hg1+lHrgWSWcKdPn90sKGrRqvPeo9CG3uKX#J{(IASm?@+di}}l?o-=)F3E6 zwD^Ni=!>T7nL9I?X}YoAW$t|Qo$sD|?zw001?ah|SeB6#0T!CBEf+H4bBB+JJu8re zhoBb*p;u8ID_yBf0ya+zcePvJL&AGs+11_tpRKn>9TgyPA7ZoSs0)aX0r00)%XR^J z`jH<$>RKN5V(7OqK*TS4xZz{h!*f1C3ECFkK$#7nA@pGN!$;%jYv zwjAKwmYb0gKL(K8-kPtb5${A?tlI~wzMrJ6wTdBr=Y%%%EaEMQ&o}4FQ^DA)s*}Z> z!FI&AHCpoWI|RUqx?7s@$8!5^Q=anY%X@i5{QA6kNcMelpE>R6eCYFpmMsVT zrI(b06~u#xf1yS}_UGdMvD``!0~u->P=lA4?YN`hilQ z|3tHka)7T{2CGqwjZfMwx$5irQN_*|e4l)UHmiYuz74Yp1t^#>hrJ3-SOXDcC_o0^ z7T9R1gAN8V6s;5)ieI5-7aQlmJn}lUna#nz!j%5V$X|o`xX!dHWQRV27P1=rj;t2b zW$~+pTw@bIek?ZvKPDL<64`^#UNTAck#RBsB6*5DP4<%UA_FqU$I>2EH_cM;u)Q~SI+rg`Rn{L z_AC5qq~L$#SMj%U$6Cz0vP{G5Y*=%5RT^yu;}-DInZ=349rJPVM6C3K^oO)8y(fJr{l>k`ead~!ea?NsT>_Ci%bnxC;Vy6= zb6>{xYV#Ue-+LB$7`JEXmTRm^AtP)R9u{)KHsMiWGV&)32xCG~*nyU<>-!d;FP=Re z4r3qYr~6#KE>;1F`>_J_P5xC?ROxV(DIHdCO*p$HRQI@7^PwV@Pvuf+ z5K}u-6REM(K@W$srgorh0{i?O)v0c>QtHxU-hBdD(>iYJ4b2sIOVX2K8m~4gmYVA5 zh^QEb$V`rCQ-|7ZS{nuL-t>?3n=-o(6I(7vocj#GzCZEo`!3>+v;dYIfPu#&ZWzzX z2i^rZ^Mu;6+rb@?NPG+6)c5T6zxpzGe*M(x+{AON=PiJ>H#?ob-|uwRK0yDg0B4PV z0id6JRRdfL?*IS+X-PyuR9Fe^Q$0%qK@fd27a>JJk-Nr9u(I+eSXr+q9B>@yUyA<+MrXx1XDr4_lD zYG9$C9=2yo;0uWeizVhO+vi5*1kRrmhyjU+_1Y+x`OfyZ3J((|BDpA#1kxlXHI-wV z`Nr|Fl&r<))D$>POTIT`eHXzwdQr8riT1w`h(Sf3% zrv=Jv!EbSG&srr$bJ%-wfb)f2S5qqDC+z4o3rDyCk4AtJt z7J?LN;*tvi?ek?%sqH5h*9k1+FgC=imlD hMXFGsP+$xd_yFd{X)`F|4cPzy002ovPDHLkV1l}W$SeQ= literal 0 HcmV?d00001 diff --git a/sources/resources/icons/iconNextAwsLogSet@2x_dark.png b/sources/resources/icons/iconNextAwsLogSet@2x_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..dac58aaa0dd0d3e184cf502c36fa05648045b89d GIT binary patch literal 1479 zcmV;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J>H#?ob-|uwRK0yDg0B4PV z0id6JRRdfL?*IS+X-PyuR9Fe^Q$0%qK@fd27a>JJk-Nr9u(I+eSXr+q9B>@yUyA<+MrXx1XDr4_lD zYG9$C9=2yo;0uWeizVhO+vi5*1kRrmhyjU+_1Y+x`OfyZ3J((|BDpA#1kxlXHI-wV z`Nr|Fl&r<))D$>POTIT`eHXzwdQr8riT1w`h(Sf3% zrv=Jv!EbSG&srr$bJ%-wfb)f2S5qqDC+z4o3rDyCk4AtJt z7J?LN;*tvi?ek?%sqH5h*9k1+FgC=imlD hMXFGsP+$xd_yFd{X)`F|4cPzy002ovPDHLkV1l}W$SeQ= literal 0 HcmV?d00001 diff --git a/sources/resources/icons/iconNextAwsLogSet_dark.png b/sources/resources/icons/iconNextAwsLogSet_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..01415b3fdfe13bf15a49e5782561f4be88fe0f16 GIT binary patch literal 1383 zcmV-t1(^DYP)Hg1+lHrgWSWcKdPn90sKGrRqvPeo9CG3uKX#J{(IASm?@+di}}l?o-=)F3E6 zwD^Ni=!>T7nL9I?X}YoAW$t|Qo$sD|?zw001?ah|SeB6#0T!CBEf+H4bBB+JJu8re zhoBb*p;u8ID_yBf0ya+zcePvJL&AGs+11_tpRKn>9TgyPA7ZoSs0)aX0r00)%XR^J z`jH<$>RKN5V(7OqK*TS4xZz{h!*f1C3ECFkK$#7nA@pGN!$;%jYv zwjAKwmYb0gKL(K8-kPtb5${A?tlI~wzMrJ6wTdBr=Y%%%EaEMQ&o}4FQ^DA)s*}Z> z!FI&AHCpoWI|RUqx?7s@$8!5^Q=anY%X@i5{QA6kNcMelpE>R6eCYFpmMsVT zrI(b06~u#xf1yS}_UGdMvD``!0~u->P=lA4?YN`hilQ z|3tHka)7T{2CGqwjZfMwx$5irQN_*|e4l)UHmiYuz74Yp1t^#>hrJ3-SOXDcC_o0^ z7T9R1gAN8V6s;5)ieI5-7aQlmJn}lUna#nz!j%5V$X|o`xX!dHWQRV27P1=rj;t2b zW$~+pTw@bIek?ZvKPDL<64`^#UNTAck#RBsB6*5DP4<%UA_FqU$I>2EH_cM;u)Q~SI+rg`Rn{L z_AC5qq~L$#SMj%U$6Cz0vP{G5Y*=%5RT^yu;}-DInZ=349rJPVM6C3K^oO)8y(fJr{l>k`ead~!ea?NsT>_Ci%bnxC;Vy6= zb6>{xYV#Ue-+LB$7`JEXmTRm^AtP)R9u{)KHsMiWGV&)32xCG~*nyU<>-!d;FP=Re z4r3qYr~6#KE>;1F`>_J_P5xC?ROxV(DIHdCO*p$HRQI@7^PwV@Pvuf+ z5K}u-6REM(K@W$srgorh0{i?O)v0c>QtHxU-hBdD(>iYJ4b2sIOVX2K8m~4gmYVA5 zh^QEb$V`rCQ-|7ZS{nuL-t>?3n=-o(6I(7vocj#GzCZEo`!3>+v;dYIfPu#&ZWzzX z2i^rZ^Mu;6+rb@?NPG+6)c5T6zxpzGe*M(x+{AON=PiJ>H#?ob-|uwRK0yDg0B4PV z0id6JRRdfL?*IS+2}wjjR5%f1U>F6=!~_9fu8;+r84J&^Q@`Gzt0&3;HcL)-P8*h8 z%u<|MEEXKMexLmD5@rw+m=Vjs&7H+90TaZa|NeUm663ID4CA(9y2zI=ypb=T&lDua z2qO4%11otQ1cO7Ox8cJ3t-~>nf!u(nV6**nHl*1|NG0q#Kg?T_@Ck5UxvSYTsADL zVd_Bi_rw3wKTml#3&j9r1t{!X26izU;U6HepGW`i`NjA@`TNB8k5JSQ;)tyj{?C^$ pm<3cvoTcana;0%eqKgd^J^%=RLqbPi$G89h002ovPDHLkV1jGjq-y{G literal 0 HcmV?d00001 diff --git a/sources/src/io/github/satr/idea/plugin/connector/la/entities/AwsLogStreamEntity.java b/sources/src/io/github/satr/idea/plugin/connector/la/entities/AwsLogStreamEntity.java index 7d849b1..d1a2375 100644 --- a/sources/src/io/github/satr/idea/plugin/connector/la/entities/AwsLogStreamEntity.java +++ b/sources/src/io/github/satr/idea/plugin/connector/la/entities/AwsLogStreamEntity.java @@ -4,23 +4,19 @@ import io.github.satr.common.DateTimeHelper; import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.time.format.FormatStyle; -import java.util.Date; public class AwsLogStreamEntity { private String logGroupName; private final String logStreamName; private final LocalDateTime lastEventTimestamp; - private final LocalDateTime creationTime; + private final LocalDateTime lastEventTime; public AwsLogStreamEntity(String logGroupName, LogStream logStream) { this.logGroupName = logGroupName; logStreamName = logStream.getLogStreamName(); lastEventTimestamp = DateTimeHelper.toLocalDateTime(logStream.getLastEventTimestamp()); - creationTime = DateTimeHelper.toLocalDateTime(logStream.getCreationTime()); + lastEventTime = DateTimeHelper.toLocalDateTime(logStream.getLastEventTimestamp()); } public String getLogStreamName() { @@ -31,13 +27,13 @@ public String getLogGroupName() { return logGroupName; } - public LocalDateTime getCreationTime() { - return creationTime; + public LocalDateTime getLastEventTime() { + return lastEventTime; } @Override public String toString() { - return String.format("%s - %s : \"%s\"", DateTimeHelper.toFormattedString(creationTime), + return String.format("%s - %s : \"%s\"", DateTimeHelper.toFormattedString(lastEventTime), DateTimeHelper.toFormattedString(lastEventTimestamp), logStreamName); } diff --git a/sources/src/io/github/satr/idea/plugin/connector/la/models/FunctionConnectorModel.java b/sources/src/io/github/satr/idea/plugin/connector/la/models/FunctionConnectorModel.java index a87a579..13db2a7 100644 --- a/sources/src/io/github/satr/idea/plugin/connector/la/models/FunctionConnectorModel.java +++ b/sources/src/io/github/satr/idea/plugin/connector/la/models/FunctionConnectorModel.java @@ -33,6 +33,7 @@ public class FunctionConnectorModel extends AbstractConnectorModel { private final AWSLogs awsLogClient; + private final int awsLogStreamItemsLimit = 50; private AWSLambda awsLambdaClient; private static final Map regionDescriptions; @@ -40,6 +41,34 @@ public class FunctionConnectorModel extends AbstractConnectorModel { regionDescriptions = createRegionDescriptionsMap(); } + private LastLogStreamState lastLogStreamState; + + private class LastLogStreamState { + private String nextToken; + private String functionName; + + private LastLogStreamState(String functionName) { + this.functionName = functionName; + } + + public String getNextToken() { + return nextToken; + } + + public LastLogStreamState setNextToken(String token) { + this.nextToken = token; + return this; + } + + public boolean hasNextToken() { + return !isEmpty(nextToken); + } + + public boolean isForFunction(String functionName) { + return this.functionName.equals(functionName); + } + } + private static Map createRegionDescriptionsMap() { HashMap map = new LinkedHashMap<>(); map.put("us-east-2", "US East (Ohio)"); @@ -111,6 +140,7 @@ public OperationValueResult updateWithJar(final FunctionEntity f } public OperationValueResult updateWithJar(final FunctionEntity functionEntity, final File file) { + resetLastLogStreamNextToken(); final OperationValueResultImpl operationResult = new OperationValueResultImpl<>(); validateLambdaFunctionJarFile(file, operationResult); if (operationResult.failed()) @@ -134,6 +164,7 @@ public OperationValueResult updateWithJar(final FunctionEntity f } private OperationValueResult updateFunctionCode(final FunctionEntity functionEntity, final FileChannel fileChannel) throws IOException { + resetLastLogStreamNextToken(); final OperationValueResultImpl valueResult = new OperationValueResultImpl<>(); try { final MappedByteBuffer buffer = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileChannel.size()); @@ -153,6 +184,7 @@ private OperationValueResult updateFunctionCode(final FunctionEn public OperationValueResult invokeFunction(final String functionName, final String inputText) { OperationValueResult operationResult = new OperationValueResultImpl<>(); try { + resetLastLogStreamNextToken(); InvokeRequest invokeRequest = new InvokeRequest(); invokeRequest.setFunctionName(functionName); invokeRequest.setPayload(inputText); @@ -176,6 +208,10 @@ public OperationValueResult invokeFunction(final String functionName, fi return operationResult; } + public void resetLastLogStreamNextToken() { + lastLogStreamState = null; + } + private void validateLambdaFunctionJarFile(File file, OperationResult operationResult) { if (!file.exists()) { operationResult.addError("JAR-file does not exist."); @@ -236,6 +272,7 @@ public OperationValueResult getFunctionBy(String name) { } public OperationResult updateConfiguration(FunctionEntity functionEntity) { + resetLastLogStreamNextToken(); OperationResultImpl operationResult = new OperationResultImpl(); UpdateFunctionConfigurationRequest request = new UpdateFunctionConfigurationRequest() .withFunctionName(functionEntity.getFunctionName()) @@ -254,7 +291,9 @@ public OperationResult updateConfiguration(FunctionEntity functionEntity) { return operationResult; } - public OperationValueResult> getAwsLogStreamsFor(String functionName) { + @NotNull + public OperationValueResult> getAwsLogStreamsFor(String functionName, + AwsLogRequestMode awsLogRequestMode) { List awsLogStreamEntities = new ArrayList<>(); OperationValueResult> operationResult = new OperationValueResultImpl<>(); operationResult.setValue(awsLogStreamEntities); @@ -263,17 +302,39 @@ public OperationValueResult> getAwsLogStreamsFor(String operationResult.addInfo("Not found log group for the function \"%s\"", functionName); return operationResult; } - DescribeLogStreamsRequest describeLogStreamsRequest = new DescribeLogStreamsRequest().withLogGroupName(logGroup.getLogGroupName()); + DescribeLogStreamsRequest describeLogStreamsRequest = new DescribeLogStreamsRequest() + .withLogGroupName(logGroup.getLogGroupName()) + .withOrderBy(OrderBy.LastEventTime) + .withDescending(true) + .withLimit(awsLogStreamItemsLimit); + if (awsLogRequestMode == AwsLogRequestMode.RequestNextSet + && lastLogStreamState != null + && lastLogStreamState.isForFunction(functionName) + && lastLogStreamState.hasNextToken() ) { + describeLogStreamsRequest.withNextToken(lastLogStreamState.getNextToken()); + } else { + lastLogStreamState = null; + } + //TODO move backward? DescribeLogStreamsResult describeLogStreamsResult = awsLogClient.describeLogStreams(describeLogStreamsRequest); + String nextToken = describeLogStreamsResult.getNextToken(); + lastLogStreamState = getLastLogStreamStateFor(functionName).setNextToken(nextToken); List logStreams = describeLogStreamsResult.getLogStreams(); for(LogStream logStream : logStreams) { awsLogStreamEntities.add(new AwsLogStreamEntity(logGroup.getLogGroupName(), logStream)); } - awsLogStreamEntities.sort(Comparator.comparing(AwsLogStreamEntity::getCreationTime)); + awsLogStreamEntities.sort(Comparator.comparing(AwsLogStreamEntity::getLastEventTime).reversed()); return operationResult; } + public LastLogStreamState getLastLogStreamStateFor(String functionName) { + return lastLogStreamState != null && lastLogStreamState.isForFunction(functionName) + ? lastLogStreamState + : new LastLogStreamState(functionName); + } + public OperationValueResult deleteAwsLogStreamsFor(String functionName) { + resetLastLogStreamNextToken(); OperationValueResult operationResult = new OperationValueResultImpl(); LogGroup logGroup = getLogGroupForAwsLambdaFunction(functionName); if(logGroup == null) { @@ -324,4 +385,8 @@ public void shutdown() { } } + public enum AwsLogRequestMode { + NewRequest, RequestNextSet + + } } diff --git a/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorPresenter.java b/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorPresenter.java index b62ac95..4a8ebb4 100644 --- a/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorPresenter.java +++ b/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorPresenter.java @@ -34,6 +34,7 @@ public interface ConnectorPresenter { void setAwsLogStreamEventList(AwsLogStreamEntity entity); void setAutoRefreshAwsLog(boolean autoRefresh); void refreshAwsLogStreams(); + void runGetNextAwsLogStreamSet(); boolean roleListLoaded(); boolean initializeFunctionRoleList(); void deleteAwsLogStreams(); diff --git a/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorPresenterImpl.java b/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorPresenterImpl.java index e27f41c..d293063 100644 --- a/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorPresenterImpl.java +++ b/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorPresenterImpl.java @@ -218,7 +218,7 @@ public void refreshAll() { FunctionEntity functionEntity = view.getSelectedFunctionEntity(); refreshFunctionConfiguration(functionEntity); if(autoRefreshAwsLog) { - refreshAwsLogStreamList(functionEntity); + refreshAwsLogStreamList(functionEntity, FunctionConnectorModel.AwsLogRequestMode.NewRequest); } else { view.clearAwsLogStreamList(); } @@ -253,7 +253,12 @@ public void setAutoRefreshAwsLog(boolean autoRefresh) { @Override public void refreshAwsLogStreams() { - refreshAwsLogStreamList(view.getSelectedFunctionEntity()); + refreshAwsLogStreamList(view.getSelectedFunctionEntity(), FunctionConnectorModel.AwsLogRequestMode.NewRequest); + } + + @Override + public void runGetNextAwsLogStreamSet() { + refreshAwsLogStreamList(view.getSelectedFunctionEntity(), FunctionConnectorModel.AwsLogRequestMode.RequestNextSet); } @Override @@ -311,7 +316,7 @@ public void setAwsLogStreamEvent(AwsLogStreamEventEntity entity) { view.setAwsLogStreamEvent(DateTimeHelper.toFormattedString(entity.getTimeStamp()), entity.getMessage()); } - private void refreshAwsLogStreamList(FunctionEntity functionEntity) { + private void refreshAwsLogStreamList(FunctionEntity functionEntity, FunctionConnectorModel.AwsLogRequestMode awsLogRequestMode) { if(functionEntity == null) { getLogger().logDebug("Clear AWS Log Stream list for not selected function."); view.clearAwsLogStreamList(); @@ -320,7 +325,8 @@ private void refreshAwsLogStreamList(FunctionEntity functionEntity) { getLogger().logDebug("Refresh AWS Log Stream list."); view.clearAwsLogStreamEventList(); OperationValueResult> getAwsLogEventsResult = getFunctionConnectorModel() - .getAwsLogStreamsFor(functionEntity.getFunctionName()); + .getAwsLogStreamsFor(functionEntity.getFunctionName(), + awsLogRequestMode); if(getAwsLogEventsResult.failed()) { getLogger().logOperationResult(getAwsLogEventsResult); return; @@ -471,7 +477,7 @@ public void setFunction(FunctionEntity functionEntity) { } view.setFunctionConfiguration(functionEntity); if(autoRefreshAwsLog) { - refreshAwsLogStreamList(functionEntity); + refreshAwsLogStreamList(functionEntity, FunctionConnectorModel.AwsLogRequestMode.NewRequest); } else { view.clearAwsLogStreamList(); } diff --git a/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorView.form b/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorView.form index 34edc63..9e43fc2 100644 --- a/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorView.form +++ b/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorView.form @@ -3,7 +3,7 @@ - + @@ -30,8 +30,9 @@ - - + + + @@ -39,7 +40,8 @@ - + + @@ -64,14 +66,16 @@ - - + + + - + + @@ -81,12 +85,13 @@ + - + - + @@ -94,15 +99,21 @@ - - + + + + + - + + + - + + @@ -118,12 +129,13 @@ + - + - + @@ -795,7 +807,7 @@ - + @@ -805,7 +817,7 @@ - + @@ -978,7 +990,7 @@
    - + @@ -996,13 +1008,24 @@ - + + + + + + + + + + + + diff --git a/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorViewFactory.java b/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorViewFactory.java index 6dbcff9..9b0785f 100644 --- a/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorViewFactory.java +++ b/sources/src/io/github/satr/idea/plugin/connector/la/ui/ConnectorViewFactory.java @@ -130,6 +130,7 @@ public class ConnectorViewFactory implements ToolWindowFactory, ConnectorView, i private JLabel awsLogStreamEventTimestamp; private JCheckBox awsLogStreamEventMessageWrapCheckBox; private JScrollPane awsLogStreamEventMessageScroll; + private JButton getNextAwsLogStreamListSet; private JTextField textProxyHost; private JTextField textProxyPort; private JCheckBox cbUseProxy; @@ -232,6 +233,10 @@ public ConnectorViewFactory(final ConnectorPresenter presenter) { runRefreshAwsLogStreams(); }); + getNextAwsLogStreamListSet.addActionListener(e -> { + runGetNextAwsLogStreamSet(); + }); + this.presenter.refreshTracingModeList(); this.presenter.refreshJarArtifactList(); runRefreshAll(); @@ -405,6 +410,7 @@ private void prepareButtons() { setupButton(reformatJsonFunctionTestInputButton, IconLoader.getIcon("/icons/iconReformatJson.png")); setupButton(reformatJsonFunctionTestOutputButton, IconLoader.getIcon("/icons/iconReformatJson.png")); setupButton(functionConfigurationCollapseExpandButton, IconLoader.getIcon("/icons/iconExpand.png")); + setupButton(getNextAwsLogStreamListSet, IconLoader.getIcon("/icons/iconNextAwsLogSet.png")); } private void performAfterBuildActivity() { @@ -427,10 +433,10 @@ private void setupButton(JButton button, Icon icon) { } private static void removeButtonBorder(JButton button) { + button.setBorder(BorderFactory.createEmptyBorder()); button.setOpaque(false); button.setContentAreaFilled(false); button.setBorderPainted(false); - button.setBorder(null); } private void openFunctionTestInputFile() { @@ -508,6 +514,13 @@ private void runRefreshAwsLogStreams() { runOperation(() -> presenter.refreshAwsLogStreams(), "Refresh AWS Log Streams"); } + private void runGetNextAwsLogStreamSet() { + if(operationInProgress || setRegionOperationInProgress) { + return; + } + runOperation(() -> presenter.runGetNextAwsLogStreamSet(), "Get next AWS Log Streams"); + } + private void refreshAwsLogStreamEvents(JList source) { if(operationInProgress || setRegionOperationInProgress) { return;