Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bonita
bonita-studio
Commits
8fa5a940
Commit
8fa5a940
authored
Jul 29, 2014
by
Aurelien Pupier
Browse files
BS-9384: the name of the repository is Studio and not Portal
parent
5da1fe3a
Changes
2
Hide whitespace changes
Inline
Side-by-side
bundles/plugins/org.bonitasoft.studio.properties/src/org/bonitasoft/studio/properties/sections/document/FileStoreSelectDialog.java
View file @
8fa5a940
/**
* Copyright (C) 2012 BonitaSoft S.A.
* Copyright (C) 2012
-2014
BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
org.bonitasoft.studio.properties.sections.document
;
import
static
org
.
bonitasoft
.
studio
.
common
.
Messages
.
bonitaPortalModuleName
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
...
...
@@ -69,32 +64,32 @@ public abstract class FileStoreSelectDialog extends Dialog {
private
Button
removeButton
;
private
AbstractFileStore
selected
;
public
FileStoreSelectDialog
(
Shell
parentShell
)
{
public
FileStoreSelectDialog
(
final
Shell
parentShell
)
{
super
(
parentShell
);
}
public
FileStoreSelectDialog
(
IShellProvider
parentShell
)
{
public
FileStoreSelectDialog
(
final
IShellProvider
parentShell
)
{
super
(
parentShell
);
}
@Override
protected
void
configureShell
(
Shell
newShell
)
{
protected
void
configureShell
(
final
Shell
newShell
)
{
super
.
configureShell
(
newShell
);
newShell
.
setText
(
getDialogTitle
());
}
@Override
protected
Control
createContents
(
Composite
parent
)
{
protected
Control
createContents
(
final
Composite
parent
)
{
final
Control
createContents
=
super
.
createContents
(
parent
);
fileStoreListViewer
.
setSelection
(
new
StructuredSelection
());
return
createContents
;
}
@Override
protected
Control
createDialogArea
(
Composite
parent
)
{
protected
Control
createDialogArea
(
final
Composite
parent
)
{
final
Control
dialogArea
=
super
.
createDialogArea
(
parent
);
Composite
mainComposite
=
new
Composite
((
Composite
)
dialogArea
,
SWT
.
NONE
);
final
Composite
mainComposite
=
new
Composite
((
Composite
)
dialogArea
,
SWT
.
NONE
);
mainComposite
.
setLayout
(
GridLayoutFactory
.
fillDefaults
().
numColumns
(
2
).
create
());
mainComposite
.
setLayoutData
(
GridDataFactory
.
fillDefaults
().
grab
(
true
,
true
).
create
());
createDescription
(
mainComposite
);
...
...
@@ -104,14 +99,16 @@ public abstract class FileStoreSelectDialog extends Dialog {
return
dialogArea
;
}
private
void
createDescription
(
Composite
mainComposite
)
{
Label
descriptionLabel
=
new
Label
(
mainComposite
,
SWT
.
NONE
);
private
void
createDescription
(
final
Composite
mainComposite
)
{
final
Label
descriptionLabel
=
new
Label
(
mainComposite
,
SWT
.
NONE
);
descriptionLabel
.
setLayoutData
(
GridDataFactory
.
fillDefaults
().
grab
(
true
,
false
).
span
(
2
,
1
).
create
());
descriptionLabel
.
setText
(
Messages
.
bind
(
Messages
.
selectDocumentDescription
,
new
Object
[]{
bonitaPortalModuleName
}
));
descriptionLabel
.
setText
(
getDialogDescription
(
));
}
private
void
createList
(
Composite
mainComposite
)
{
Composite
listComposite
=
new
Composite
(
mainComposite
,
SWT
.
NONE
);
protected
abstract
String
getDialogDescription
();
private
void
createList
(
final
Composite
mainComposite
)
{
final
Composite
listComposite
=
new
Composite
(
mainComposite
,
SWT
.
NONE
);
listComposite
.
setLayout
(
GridLayoutFactory
.
fillDefaults
().
create
());
listComposite
.
setLayoutData
(
GridDataFactory
.
fillDefaults
().
grab
(
true
,
true
).
create
());
final
Text
fileStoreListFilter
=
new
Text
(
listComposite
,
SWT
.
BORDER
|
SWT
.
SEARCH
|
SWT
.
ICON_SEARCH
|
SWT
.
ICON_CANCEL
);
...
...
@@ -122,7 +119,7 @@ public abstract class FileStoreSelectDialog extends Dialog {
private
ViewerFilter
filter
;
@Override
public
void
modifyText
(
ModifyEvent
e
)
{
public
void
modifyText
(
final
ModifyEvent
e
)
{
final
String
textForFiltering
=
fileStoreListFilter
.
getText
();
if
(
filter
!=
null
){
fileStoreListViewer
.
removeFilter
(
filter
);
...
...
@@ -132,7 +129,7 @@ public abstract class FileStoreSelectDialog extends Dialog {
filter
=
new
ViewerFilter
()
{
@Override
public
boolean
select
(
Viewer
viewer
,
Object
parentElement
,
Object
element
)
{
public
boolean
select
(
final
Viewer
viewer
,
final
Object
parentElement
,
final
Object
element
)
{
return
((
AbstractFileStore
)
element
).
getName
().
contains
(
textForFiltering
);
}
};
...
...
@@ -145,12 +142,12 @@ public abstract class FileStoreSelectDialog extends Dialog {
fileStoreListViewer
.
getList
().
setLayoutData
(
GridDataFactory
.
fillDefaults
().
grab
(
true
,
true
).
hint
(
SWT
.
DEFAULT
,
300
).
create
());
fileStoreListViewer
.
setContentProvider
(
new
ArrayContentProvider
());
fileStoreListViewer
.
setLabelProvider
(
new
FileStoreLabelProvider
());
IRepositoryStore
<?>
ars
=
(
IRepositoryStore
<?>)
RepositoryManager
.
getInstance
().
getRepositoryStore
(
getRepositoryStoreClass
());
final
IRepositoryStore
<?>
ars
=
(
IRepositoryStore
<?>)
RepositoryManager
.
getInstance
().
getRepositoryStore
(
getRepositoryStoreClass
());
fileStoreListViewer
.
setInput
(
ars
.
getChildren
());
fileStoreListViewer
.
addSelectionChangedListener
(
new
ISelectionChangedListener
()
{
@Override
public
void
selectionChanged
(
SelectionChangedEvent
event
)
{
public
void
selectionChanged
(
final
SelectionChangedEvent
event
)
{
final
boolean
empty
=
event
.
getSelection
().
isEmpty
();
getButton
(
IDialogConstants
.
OK_ID
).
setEnabled
(!
empty
);
removeButton
.
setEnabled
(!
empty
);
...
...
@@ -160,9 +157,9 @@ public abstract class FileStoreSelectDialog extends Dialog {
fileStoreListViewer
.
getList
().
setFocus
();
}
private
void
createButtons
(
Composite
mainComposite
)
{
Composite
buttonComposite
=
new
Composite
(
mainComposite
,
SWT
.
NONE
);
RowLayout
rowLayout
=
new
RowLayout
(
SWT
.
VERTICAL
);
private
void
createButtons
(
final
Composite
mainComposite
)
{
final
Composite
buttonComposite
=
new
Composite
(
mainComposite
,
SWT
.
NONE
);
final
RowLayout
rowLayout
=
new
RowLayout
(
SWT
.
VERTICAL
);
rowLayout
.
fill
=
true
;
buttonComposite
.
setLayout
(
rowLayout
);
createAddButton
(
buttonComposite
);
...
...
@@ -170,32 +167,32 @@ public abstract class FileStoreSelectDialog extends Dialog {
}
private
void
createAddButton
(
Composite
buttonComposite
)
{
Button
addButton
=
new
Button
(
buttonComposite
,
SWT
.
FLAT
);
private
void
createAddButton
(
final
Composite
buttonComposite
)
{
final
Button
addButton
=
new
Button
(
buttonComposite
,
SWT
.
FLAT
);
addButton
.
setText
(
Messages
.
importEtc
);
addButton
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
FileDialog
fileDialog
=
new
FileDialog
(
getShell
());
String
fileDialogResult
=
fileDialog
.
open
();
public
void
widgetSelected
(
final
SelectionEvent
e
)
{
final
FileDialog
fileDialog
=
new
FileDialog
(
getShell
());
final
String
fileDialogResult
=
fileDialog
.
open
();
if
(
fileDialogResult
!=
null
){
AbstractRepositoryStore
<
IRepositoryFileStore
>
ars
=
(
AbstractRepositoryStore
<
IRepositoryFileStore
>)
RepositoryManager
.
getInstance
().
getRepositoryStore
(
getRepositoryStoreClass
());
File
newFile
=
new
File
(
fileDialogResult
);
final
AbstractRepositoryStore
<
IRepositoryFileStore
>
ars
=
(
AbstractRepositoryStore
<
IRepositoryFileStore
>)
RepositoryManager
.
getInstance
().
getRepositoryStore
(
getRepositoryStoreClass
());
final
File
newFile
=
new
File
(
fileDialogResult
);
FileInputStream
inputStream
=
null
;
try
{
inputStream
=
new
FileInputStream
(
newFile
);
IRepositoryFileStore
fileStoreCreated
=
ars
.
importInputStream
(
newFile
.
getName
(),
inputStream
);
final
IRepositoryFileStore
fileStoreCreated
=
ars
.
importInputStream
(
newFile
.
getName
(),
inputStream
);
fileStoreListViewer
.
setInput
(
ars
.
getChildren
());
fileStoreListViewer
.
setSelection
(
new
StructuredSelection
(
fileStoreCreated
));
fileStoreListViewer
.
refresh
();
}
catch
(
FileNotFoundException
e1
)
{
}
catch
(
final
FileNotFoundException
e1
)
{
BonitaStudioLog
.
error
(
e1
);
}
finally
{
if
(
inputStream
!=
null
){
try
{
inputStream
.
close
();
}
catch
(
IOException
e1
)
{
}
catch
(
final
IOException
e1
)
{
BonitaStudioLog
.
error
(
e1
);
}
}
...
...
@@ -206,15 +203,15 @@ public abstract class FileStoreSelectDialog extends Dialog {
});
}
private
void
createRemoveButton
(
Composite
buttonComposite
)
{
private
void
createRemoveButton
(
final
Composite
buttonComposite
)
{
removeButton
=
new
Button
(
buttonComposite
,
SWT
.
FLAT
);
removeButton
.
setText
(
Messages
.
remove
);
removeButton
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
public
void
widgetSelected
(
final
SelectionEvent
e
)
{
super
.
widgetSelected
(
e
);
((
IRepositoryFileStore
)
((
StructuredSelection
)
fileStoreListViewer
.
getSelection
()).
getFirstElement
()).
delete
();
AbstractRepositoryStore
<
IRepositoryFileStore
>
ars
=
(
AbstractRepositoryStore
<
IRepositoryFileStore
>)
RepositoryManager
.
getInstance
().
getRepositoryStore
(
getRepositoryStoreClass
());
final
AbstractRepositoryStore
<
IRepositoryFileStore
>
ars
=
(
AbstractRepositoryStore
<
IRepositoryFileStore
>)
RepositoryManager
.
getInstance
().
getRepositoryStore
(
getRepositoryStoreClass
());
fileStoreListViewer
.
setInput
(
ars
.
getChildren
());
}
});
...
...
bundles/plugins/org.bonitasoft.studio.properties/src/org/bonitasoft/studio/properties/sections/document/SelectDocumentInBonitaStudioRepository.java
View file @
8fa5a940
/**
* Copyright (C) 2012 BonitaSoft S.A.
* Copyright (C) 2012
-2014
BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.
If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
org.bonitasoft.studio.properties.sections.document
;
...
...
@@ -31,11 +28,11 @@ import org.eclipse.swt.widgets.Shell;
*/
public
class
SelectDocumentInBonitaStudioRepository
extends
FileStoreSelectDialog
{
public
SelectDocumentInBonitaStudioRepository
(
IShellProvider
parentShell
)
{
public
SelectDocumentInBonitaStudioRepository
(
final
IShellProvider
parentShell
)
{
super
(
parentShell
);
}
public
SelectDocumentInBonitaStudioRepository
(
Shell
parentShell
){
public
SelectDocumentInBonitaStudioRepository
(
final
Shell
parentShell
){
super
(
parentShell
);
}
...
...
@@ -52,4 +49,10 @@ public class SelectDocumentInBonitaStudioRepository extends FileStoreSelectDialo
protected
String
getDialogTitle
()
{
return
Messages
.
bind
(
Messages
.
selectDocumentDialogTitle
,
new
Object
[]{
bonitaStudioModuleName
});
}
@Override
protected
String
getDialogDescription
()
{
return
Messages
.
bind
(
Messages
.
selectDocumentDescription
,
new
Object
[]
{
bonitaStudioModuleName
});
}
}
Write
Preview
Supports
Markdown
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