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
6cbf248b
Commit
6cbf248b
authored
Jul 09, 2018
by
Alexander Prendetskiy
Committed by
Matija Obreza
Jul 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Embed OAuth client id
parent
4ee8792a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
36 deletions
+103
-36
anno-gui/src/main/java/org/genesys2/anno/gui/SettingsDialog.java
...i/src/main/java/org/genesys2/anno/gui/SettingsDialog.java
+103
-36
No files found.
anno-gui/src/main/java/org/genesys2/anno/gui/SettingsDialog.java
View file @
6cbf248b
...
...
@@ -52,7 +52,16 @@ import org.springframework.beans.factory.annotation.Autowired;
import
swing2swt.layout.BorderLayout
;
import
java.util.Arrays
;
public
class
SettingsDialog
extends
Dialog
{
private
static
final
String
CUSTOM_SERVER_URL
=
"http://localhost:8080"
;
private
static
final
String
SANDBOX_SERVER_URL
=
"https://sandbox.genesys-pgr.org"
;
private
static
final
String
SANDBOX_CLIENT_ID
=
"Ap8Od.ydMSWlJ7qL9sJWtXXMCA@sandbox.genesys-pgr.org"
;
private
static
final
String
PRODUCTION_SERVER_URL
=
"https://www.genesys-pgr.org"
;
private
static
final
String
PRODUCTION_CLIENT_ID
=
"fTxcm.TrySiiiOLncyeWfmQKyp@www.genesys-pgr.org"
;
private
Binding
scope
;
private
static
final
Logger
_log
=
Logger
.
getLogger
(
SettingsDialog
.
class
);
private
DataBindingContext
m_bindingContext
;
...
...
@@ -106,7 +115,7 @@ public class SettingsDialog extends Dialog {
*/
private
void
createContents
()
{
shell
=
new
Shell
(
getParent
(),
SWT
.
SHELL_TRIM
);
shell
.
setSize
(
665
,
445
);
shell
.
setSize
(
665
,
530
);
shell
.
setText
(
getText
());
shell
.
setLayout
(
new
BorderLayout
(
0
,
0
));
...
...
@@ -125,7 +134,91 @@ public class SettingsDialog extends Dialog {
Composite
composite
=
new
Composite
(
scrolledComposite
,
SWT
.
NONE
);
composite
.
setLayout
(
new
GridLayout
(
1
,
false
));
Group
grpGenesysApiConfiguration
=
new
Group
(
composite
,
SWT
.
NONE
);
Group
genesysServer
=
new
Group
(
composite
,
SWT
.
NONE
);
Group
genesysApiConfiguration
=
new
Group
(
composite
,
SWT
.
NONE
);
Group
oauthTokens
=
new
Group
(
composite
,
SWT
.
NONE
);
renderServerSection
(
genesysServer
,
genesysApiConfiguration
);
renderApiConfigurationSection
(
genesysApiConfiguration
);
renderTokensSection
(
oauthTokens
);
Composite
composite_1
=
new
Composite
(
composite
,
SWT
.
NONE
);
GridData
gd_composite_1
=
new
GridData
(
SWT
.
LEFT
,
SWT
.
TOP
,
true
,
false
,
1
,
1
);
gd_composite_1
.
horizontalIndent
=
160
;
composite_1
.
setLayoutData
(
gd_composite_1
);
composite_1
.
setLayout
(
new
RowLayout
(
SWT
.
HORIZONTAL
));
Button
btnClearTokens
=
new
Button
(
composite_1
,
SWT
.
NONE
);
btnClearTokens
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
settings
.
getOauthSettings
().
clearTokens
();
}
});
btnClearTokens
.
setText
(
"Clear tokens"
);
Button
btnAuthenticate
=
new
Button
(
composite_1
,
SWT
.
NONE
);
btnAuthenticate
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
doAuthenticate
();
}
});
btnAuthenticate
.
setText
(
"Authenticate"
);
composite
.
pack
();
scrolledComposite
.
setContent
(
composite
);
scrolledComposite
.
setMinSize
(
composite
.
computeSize
(
SWT
.
DEFAULT
,
SWT
.
DEFAULT
));
// TabItem tbtmTodo = new TabItem(tabFolder, SWT.NONE);
// tbtmTodo.setText("TODO");
m_bindingContext
=
initDataBindings
();
}
private
void
renderServerSection
(
Group
grpGenesysServer
,
Group
grpGenesysApiConfiguration
)
{
OAuthSettings
oauthSettings
=
settings
.
getOauthSettings
();
grpGenesysServer
.
setLayout
(
new
GridLayout
(
3
,
false
));
grpGenesysServer
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
2
,
1
));
grpGenesysServer
.
setText
(
"Genesys server"
);
Button
btnSandbox
=
new
Button
(
grpGenesysServer
,
SWT
.
RADIO
);
btnSandbox
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
oauthSettings
.
setServerUrl
(
SANDBOX_SERVER_URL
);
oauthSettings
.
setClientKey
(
SANDBOX_CLIENT_ID
);
enableSection
(
grpGenesysApiConfiguration
,
false
);
}
});
btnSandbox
.
setText
(
"Sandbox"
);
Button
btnProduction
=
new
Button
(
grpGenesysServer
,
SWT
.
RADIO
);
btnProduction
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
oauthSettings
.
setServerUrl
(
PRODUCTION_SERVER_URL
);
oauthSettings
.
setClientKey
(
PRODUCTION_CLIENT_ID
);
enableSection
(
grpGenesysApiConfiguration
,
false
);
}
});
btnProduction
.
setText
(
"Production"
);
Button
btnCustom
=
new
Button
(
grpGenesysServer
,
SWT
.
RADIO
);
btnCustom
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
enableSection
(
grpGenesysApiConfiguration
,
true
);
}
});
btnCustom
.
setSelection
(
true
);
btnCustom
.
setText
(
"Custom"
);
}
private
void
renderApiConfigurationSection
(
Group
grpGenesysApiConfiguration
)
{
grpGenesysApiConfiguration
.
setLayout
(
new
GridLayout
(
2
,
false
));
grpGenesysApiConfiguration
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
2
,
1
));
grpGenesysApiConfiguration
.
setText
(
"Genesys API configuration"
);
...
...
@@ -197,16 +290,17 @@ public class SettingsDialog extends Dialog {
}
});
txtClientSecret
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
1
,
1
));
Label
tblScope
=
new
Label
(
grpGenesysApiConfiguration
,
SWT
.
NONE
);
tblScope
.
setLayoutData
(
new
GridData
(
SWT
.
RIGHT
,
SWT
.
CENTER
,
false
,
false
,
1
,
1
));
tblScope
.
setText
(
"Scope"
);
tblScope
.
setAlignment
(
SWT
.
RIGHT
);
txtScope
=
new
Text
(
grpGenesysApiConfiguration
,
SWT
.
BORDER
);
txtScope
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
1
,
1
));
}
Group
grpOauthTokens
=
new
Group
(
composite
,
SWT
.
NONE
);
private
void
renderTokensSection
(
Group
grpOauthTokens
)
{
grpOauthTokens
.
setLayout
(
new
GridLayout
(
2
,
false
));
grpOauthTokens
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
2
,
1
));
grpOauthTokens
.
setText
(
"OAuth Tokens"
);
...
...
@@ -227,39 +321,12 @@ public class SettingsDialog extends Dialog {
txtRefreshToken
=
new
Text
(
grpOauthTokens
,
SWT
.
BORDER
);
txtRefreshToken
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
1
,
1
));
}
Composite
composite_1
=
new
Composite
(
composite
,
SWT
.
NONE
);
GridData
gd_composite_1
=
new
GridData
(
SWT
.
LEFT
,
SWT
.
TOP
,
true
,
false
,
1
,
1
);
gd_composite_1
.
horizontalIndent
=
160
;
composite_1
.
setLayoutData
(
gd_composite_1
);
composite_1
.
setLayout
(
new
RowLayout
(
SWT
.
HORIZONTAL
));
Button
btnClearTokens
=
new
Button
(
composite_1
,
SWT
.
NONE
);
btnClearTokens
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
settings
.
getOauthSettings
().
clearTokens
();
}
});
btnClearTokens
.
setText
(
"Clear tokens"
);
Button
btnAuthenticate
=
new
Button
(
composite_1
,
SWT
.
NONE
);
btnAuthenticate
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
doAuthenticate
();
}
private
void
enableSection
(
Group
group
,
boolean
enable
)
{
Arrays
.
stream
(
group
.
getChildren
()).
forEach
(
control
->
{
control
.
setEnabled
(
enable
);
});
btnAuthenticate
.
setText
(
"Authenticate"
);
composite
.
pack
();
scrolledComposite
.
setContent
(
composite
);
scrolledComposite
.
setMinSize
(
composite
.
computeSize
(
SWT
.
DEFAULT
,
SWT
.
DEFAULT
));
// TabItem tbtmTodo = new TabItem(tabFolder, SWT.NONE);
// tbtmTodo.setText("TODO");
m_bindingContext
=
initDataBindings
();
}
protected
void
doAuthenticate
()
{
...
...
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