Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
Uploader
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Uploader
Commits
dfe849ef
Commit
dfe849ef
authored
Feb 22, 2019
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Pause/Resume button
parent
85ab4a9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
10 deletions
+52
-10
anno-gui/src/main/java/org/eclipse/wb/swt/SWTResourceManager.java
.../src/main/java/org/eclipse/wb/swt/SWTResourceManager.java
+10
-10
anno-gui/src/main/java/org/genesys2/anno/gui/PushDialog.java
anno-gui/src/main/java/org/genesys2/anno/gui/PushDialog.java
+42
-0
No files found.
anno-gui/src/main/java/org/eclipse/wb/swt/SWTResourceManager.java
View file @
dfe849ef
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Google, Inc. - initial API and implementation
*******************************************************************************/
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Google, Inc. - initial API and implementation
*******************************************************************************/
package
org.eclipse.wb.swt
;
import
java.io.FileInputStream
;
...
...
anno-gui/src/main/java/org/genesys2/anno/gui/PushDialog.java
View file @
dfe849ef
...
...
@@ -29,6 +29,7 @@ import java.util.concurrent.Future;
import
java.util.concurrent.LinkedBlockingDeque
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.function.Consumer
;
import
java.util.stream.Collectors
;
...
...
@@ -109,6 +110,7 @@ public class PushDialog extends Dialog {
private
IDataSource
dataSource
;
private
List
<
Future
<?>>
futures
=
new
ArrayList
<
Future
<?>>();
private
ToolBar
toolBar
;
private
AtomicBoolean
doPushPaused
=
new
AtomicBoolean
(
true
);
// paused by default
static
{
deleteDataIcon
=
ImageDescriptor
.
createFromURL
(
PushDialog
.
class
.
getResource
(
"/icon/delete.png"
)).
createImage
();
...
...
@@ -238,6 +240,17 @@ public class PushDialog extends Dialog {
});
tltmRemove
.
setText
(
"Remove"
);
tltmRemove
.
setImage
(
PushDialog
.
deleteDataIcon
);
ToolItem
tltmPause
=
new
ToolItem
(
toolBar
,
SWT
.
NONE
);
tltmPause
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
doPushPaused
.
set
(!
doPushPaused
.
get
());
_log
.
warn
(
"Reading data source is "
+
(
doPushPaused
.
get
()
?
"paused"
:
"resumed"
));
tltmPause
.
setText
(
doPushPaused
.
get
()
?
"Resume"
:
"Pause"
);
}
});
tltmPause
.
setText
(
"Pause"
);
ToolItem
tltmRadioItemDebug
=
new
ToolItem
(
toolBar
,
SWT
.
RADIO
);
tltmRadioItemDebug
.
addSelectionListener
(
new
SelectionAdapter
()
{
...
...
@@ -348,6 +361,9 @@ public class PushDialog extends Dialog {
_log
.
info
(
"Starting push to "
+
oauthSettings
.
getServerUrl
());
final
GenesysClient
genesysClient
=
SpringConfig
.
createGenesysClient
(
oauthSettings
);
// Manages pause/resume
doPushPaused
.
set
(
false
);
Future
<?>
future
=
executorService
.
submit
(()
->
{
try
{
List
<
String
>
instCodesOrder
=
new
ArrayList
<>();
...
...
@@ -360,6 +376,10 @@ public class PushDialog extends Dialog {
List
<
Object
[]>
rows
=
null
;
int
count
=
0
;
do
{
while
(
doPushPaused
.
get
())
{
// Pause reading
Thread
.
sleep
(
500
);
}
rows
=
rowReader1
.
readRows
(
1000
);
for
(
Object
[]
row
:
rows
)
{
count
++;
...
...
@@ -400,6 +420,25 @@ public class PushDialog extends Dialog {
try
{
do
{
if
(
doPushPaused
.
get
())
{
while
(
doPushPaused
.
get
())
{
// Pause reading
Thread
.
sleep
(
500
);
}
try
{
genesysClient
.
me
();
}
catch
(
OAuthAuthenticationException
e
)
{
_log
.
error
(
"Trying reauthentication using refresh token."
);
try
{
genesysClient
.
refreshAccessToken
();
}
catch
(
OAuthAuthenticationException
e1
)
{
_log
.
error
(
"Trying Oauth client authentication."
);
genesysClient
.
authenticate
();
}
}
}
List
<
Object
[]>
rows
=
rowReader
.
readRows
(
100
);
if
(
rows
.
size
()
==
0
)
{
...
...
@@ -509,6 +548,9 @@ public class PushDialog extends Dialog {
_log
.
warn
(
"PUSH FINISHED."
);
_log
.
warn
(
"Really."
);
// Interrupt the thread so it stops logging
uploadMonitor
.
interrupt
();
}
catch
(
OAuthAuthenticationException
e
)
{
_log
.
error
(
e
.
getMessage
(),
e
);
}
catch
(
PleaseRetryException
e
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment