Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
ikus-soft
planimod
Compare revisions
master to Modification-for-NA-Parameter
Commits on Source (1)
Modification of the parameters to add non-availability reason section
· 9033dde6
karl
authored
Oct 14, 2013
and
Patrik Dufresne
committed
May 15, 2019
for the non availability view Closes
#193
9033dde6
Hide whitespace changes
Inline
Side-by-side
com.patrikdufresne.planimod/src/main/java/com/planimod/core/ApplicationSetting.java
View file @
9033dde6
...
...
@@ -19,13 +19,14 @@ package com.planimod.core;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Lob
;
import
com.patrikdufresne.managers.ManagedObject
;
/**
* This class represent one setting for the application.
*
* @author
p
at
apouf
* @author
P
at
rik Dufresne
*/
@Entity
public
class
ApplicationSetting
extends
ManagedObject
{
...
...
@@ -59,7 +60,9 @@ public class ApplicationSetting extends ManagedObject {
*
* @return the name of the setting.
*/
@Column
(
nullable
=
false
,
length
=
50
)
// Using Lob for a greater number of characters in the column.
@Lob
@Column
(
nullable
=
false
)
public
String
getName
()
{
return
this
.
name
;
}
...
...
@@ -69,7 +72,9 @@ public class ApplicationSetting extends ManagedObject {
*
* @return the value.
*/
@Column
(
nullable
=
false
,
length
=
50
)
// Using Lob for a greater number of characters in the column.
@Lob
@Column
(
nullable
=
false
)
public
String
getValue
()
{
return
this
.
value
;
}
...
...
com.patrikdufresne.planimod/src/main/java/com/planimod/core/PlanimodManagers.java
View file @
9033dde6
...
...
@@ -17,12 +17,15 @@
*/
package
com.planimod.core
;
import
java.sql.Clob
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
org.hibernate.HibernateException
;
import
org.hibernate.SessionFactory
;
import
org.hibernate.cfg.Configuration
;
import
org.hibernate.tool.hbm2ddl.TableMetadata
;
import
com.patrikdufresne.managers.DatabaseUpdateHelper
;
import
com.patrikdufresne.managers.IManager
;
...
...
@@ -368,8 +371,14 @@ public class PlanimodManagers extends Managers {
if
(
version
==
null
)
{
throw
new
HibernateException
(
"Database is invalid."
);
}
if
(
version
.
equals
(
VERSION_10
))
{
return
;
// Modification of the column to CLOB to accept a greater number of characters
String
catalog
=
DatabaseUpdateHelper
.
getCatalog
(
factory
);
String
schema
=
DatabaseUpdateHelper
.
getSchema
(
factory
);
TableMetadata
meta
=
DatabaseUpdateHelper
.
getTableMetadata
(
factory
,
"APPLICATIONSETTING"
,
schema
,
catalog
);
if
(
meta
!=
null
&&
meta
.
getColumnMetadata
(
"NAME"
).
getTypeName
()
!=
null
&&
meta
.
getColumnMetadata
(
"NAME"
).
getTypeName
()
!=
Clob
.
class
.
toString
())
{
List
<
String
>
script
=
new
ArrayList
<
String
>();
script
.
add
(
"ALTER TABLE APPLICATIONSETTING ALTER COLUMN VALUE CLOB"
);
DatabaseUpdateHelper
.
execute
(
factory
,
script
);
}
}
...
...
com.patrikdufresne.planimod/src/main/java/com/planimod/ui/databinding/MotifBean.java
0 → 100644
View file @
9033dde6
/**
* Copyright(C) 2019 Patrik Dufresne Service Logiciel <info@patrikdufresne.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 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 GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package
com.planimod.ui.databinding
;
import
java.beans.PropertyChangeListener
;
import
java.beans.PropertyChangeSupport
;
import
javax.persistence.Transient
;
/**
* Instance of this class are used to represent a bean object allowing modification of it's data and supporting property
* change event.
*
* @author Karl St-Cyr
*
*/
public
class
MotifBean
{
/**
* Min property name.
*/
public
static
final
String
NAME
=
"name"
;
@Transient
protected
PropertyChangeSupport
changeSupport
=
new
PropertyChangeSupport
(
this
);
/**
* Define the name of the motif.
*/
private
String
name
;
public
MotifBean
()
{
this
.
name
=
"Motif"
;
}
/**
* Java bean function.
*
* @param listener
* The PropertyChangeListener to be added
*/
public
void
addPropertyChangeListener
(
PropertyChangeListener
listener
)
{
this
.
changeSupport
.
addPropertyChangeListener
(
listener
);
}
/**
* Java bean function.
*
* @param propertyName
* The name of the property to listen on.
* @param listener
* The PropertyChangeListener to be added
*/
public
void
addPropertyChangeListener
(
String
propertyName
,
PropertyChangeListener
listener
)
{
this
.
changeSupport
.
addPropertyChangeListener
(
propertyName
,
listener
);
}
/**
* @return the name of the motif
*/
public
String
getName
()
{
return
this
.
name
;
}
/**
* Java bean function. To remove a Motif.
*
* @param listener
* The PropertyChangeListener to be removed
*/
public
void
removePropertyChangeListener
(
PropertyChangeListener
listener
)
{
this
.
changeSupport
.
removePropertyChangeListener
(
listener
);
}
/**
* Java bean function. To remove a Motif.
*
* @param propertyName
* The name of the property that was listened on.
* @param listener
* The PropertyChangeListener to be removed
*/
public
void
removePropertyChangeListener
(
String
propertyName
,
PropertyChangeListener
listener
)
{
this
.
changeSupport
.
removePropertyChangeListener
(
propertyName
,
listener
);
}
/**
* Sets the name
*/
public
void
setName
(
String
name
)
{
this
.
changeSupport
.
firePropertyChange
(
NAME
,
this
.
name
,
this
.
name
=
name
);
}
@Override
public
String
toString
()
{
return
this
.
name
;
}
}
\ No newline at end of file
com.patrikdufresne.planimod/src/main/java/com/planimod/ui/views/admin/AddMotifEntry.java
0 → 100644
View file @
9033dde6
/**
* Copyright(C) 2019 Patrik Dufresne Service Logiciel <info@patrikdufresne.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 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 GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package
com.planimod.ui.views.admin
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.eclipse.jface.action.Action
;
import
com.patrikdufresne.util.Localized
;
import
com.planimod.ui.databinding.MotifBean
;
import
com.planimod.ui.theme.Resources
;
/**
* This action is used to add a MotifBean to an PointChart. Notice: this action does not persist the modification.
*
* @author Karl St-Cyr
*
*/
public
class
AddMotifEntry
extends
Action
{
/**
* Motif property.
*/
public
static
final
String
MOTIFS
=
"motifs"
;
//$NON-NLS-1$
/**
* Used for localization.
*/
private
Localized
localized
=
Localized
.
load
(
AddMotifEntry
.
class
);
/**
* The current collection of motifs
*/
Set
<
MotifBean
>
motifs
;
/**
* Create a new action to add an entry to a motif chart.
*/
public
AddMotifEntry
()
{
setText
(
this
.
localized
.
get
(
"AddMotifEntry.text"
));
//$NON-NLS-1$
setImageDescriptor
(
Resources
.
getImageDescriptor
(
Resources
.
ICON_LIST_ADD_16
));
setEnabled
(
canRun
());
setToolTipText
(
this
.
localized
.
get
(
"AddMotifEntry.tooltip"
));
//$NON-NLS-1$
}
/**
* Check if this action can be run.
*
* @return True if the action can be run.
*/
protected
boolean
canRun
()
{
return
this
.
motifs
!=
null
;
}
/**
* Returns the set of MotifBean
*
* @return Set<MotifBean>
*/
public
Set
<
MotifBean
>
getMotifs
()
{
return
motifs
;
}
/**
* This implementation add a new entry to a MotifBean object
*/
@Override
public
void
run
()
{
if
(!
canRun
())
{
return
;
}
// Create a new instance of the Motifs
Set
<
MotifBean
>
newMotifs
=
new
HashSet
<
MotifBean
>(
this
.
motifs
);
// Add a new entry
MotifBean
r
=
new
MotifBean
();
r
.
setName
(
this
.
localized
.
get
(
"AddMotifEntry.newMotif"
));
//$NON-NLS-1$
newMotifs
.
add
(
r
);
// Fire a property change
firePropertyChange
(
MOTIFS
,
this
.
motifs
,
this
.
motifs
=
newMotifs
);
}
/**
* Sets the point chart object to be updated or null if not set.
*
* @param set
* <MotifBean>
*/
public
void
setMotifs
(
Set
<
MotifBean
>
motifs
)
{
if
(
this
.
motifs
!=
motifs
)
{
firePropertyChange
(
MOTIFS
,
this
.
motifs
,
this
.
motifs
=
motifs
);
setEnabled
(
canRun
());
}
}
}
com.patrikdufresne.planimod/src/main/java/com/planimod/ui/views/admin/AdminPageViewPart.java
View file @
9033dde6
...
...
@@ -132,6 +132,7 @@ public class AdminPageViewPart extends ViewPartPage {
PreferenceManager
mgr
=
new
PreferenceManager
();
mgr
.
addToRoot
(
new
GeneralPreferenceNode
(
getSite
().
getService
(
PlanimodManagers
.
class
)));
mgr
.
addToRoot
(
new
AppearancePreferenceNode
());
mgr
.
addToRoot
(
new
MotifPreferenceNode
(
getSite
().
getService
(
PlanimodManagers
.
class
)));
PreferenceDialog
dlg
=
new
PreferenceDialog
(
getSite
().
getShell
(),
mgr
);
dlg
.
setPreferenceStore
(
PlanimodPreferences
.
getPreferenceStore
());
dlg
.
open
();
...
...
com.patrikdufresne.planimod/src/main/java/com/planimod/ui/views/admin/AppearancePreferencePage.java
View file @
9033dde6
...
...
@@ -23,9 +23,9 @@ import org.eclipse.core.databinding.DataBindingContext;
import
org.eclipse.core.databinding.ObservablesManager
;
import
org.eclipse.core.databinding.observable.value.WritableValue
;
import
org.eclipse.jface.databinding.swt.WidgetProperties
;
import
org.eclipse.jface.preference.IPreferenceStore
;
import
org.eclipse.jface.preference.PreferencePage
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.custom.CLabel
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.layout.GridLayout
;
import
org.eclipse.swt.widgets.Button
;
...
...
@@ -113,7 +113,10 @@ public class AppearancePreferencePage extends PreferencePage {
@Override
public
boolean
performOk
()
{
Boolean
value
=
(
Boolean
)
(
this
.
showLines
.
getValue
()
instanceof
Boolean
?
this
.
showLines
.
getValue
()
:
Boolean
.
FALSE
);
getPreferenceStore
().
setValue
(
PlanimodPreferences
.
SHOW_LINES
,
value
.
booleanValue
());
IPreferenceStore
s
=
getPreferenceStore
();
if
(
s
!=
null
)
{
s
.
setValue
(
PlanimodPreferences
.
SHOW_LINES
,
value
.
booleanValue
());
}
return
true
;
}
...
...
com.patrikdufresne.planimod/src/main/java/com/planimod/ui/views/admin/MotifPreferenceNode.java
0 → 100644
View file @
9033dde6
/**
* Copyright(C) 2019 Patrik Dufresne Service Logiciel <info@patrikdufresne.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 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 GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package
com.planimod.ui.views.admin
;
import
org.eclipse.jface.preference.PreferenceNode
;
import
com.planimod.core.PlanimodManagers
;
/**
* Preference node for Planimod motif parameters
*
* @author Karl St-Cyr
*
*/
public
class
MotifPreferenceNode
extends
PreferenceNode
{
/**
* Node id.
*/
public
static
final
String
ID
=
"MotifPreferenceNode"
;
//$NON-NLS-1$
/**
* Create a preference node.
*
* @param managers
* The Planimod manager used to access the parameters
*/
public
MotifPreferenceNode
(
PlanimodManagers
manager
)
{
super
(
ID
,
new
MotifPreferencePage
(
manager
));
}
}
com.patrikdufresne.planimod/src/main/java/com/planimod/ui/views/admin/MotifPreferencePage.java
0 → 100644
View file @
9033dde6
/**
* Copyright(C) 2019 Patrik Dufresne Service Logiciel <info@patrikdufresne.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 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 GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package
com.planimod.ui.views.admin
;
import
java.util.Iterator
;
import
org.eclipse.core.databinding.DataBindingContext
;
import
org.eclipse.core.databinding.ObservablesManager
;
import
org.eclipse.core.databinding.UpdateValueStrategy
;
import
org.eclipse.core.databinding.beans.BeanProperties
;
import
org.eclipse.core.databinding.observable.set.WritableSet
;
import
org.eclipse.core.databinding.property.value.IValueProperty
;
import
org.eclipse.jface.databinding.viewers.ObservableSetContentProvider
;
import
org.eclipse.jface.databinding.viewers.ViewerProperties
;
import
org.eclipse.jface.layout.GridLayoutFactory
;
import
org.eclipse.jface.layout.RowLayoutFactory
;
import
org.eclipse.jface.preference.PreferencePage
;
import
org.eclipse.jface.viewers.ColumnViewerEditor
;
import
org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent
;
import
org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy
;
import
org.eclipse.jface.viewers.TableViewer
;
import
org.eclipse.jface.viewers.TableViewerEditor
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Control
;
import
com.patrikdufresne.jface.action.ActionContributionItem
;
import
com.patrikdufresne.jface.databinding.util.JFaceProperties
;
import
com.patrikdufresne.jface.databinding.viewers.ColumnSupport
;
import
com.patrikdufresne.managers.ManagerException
;
import
com.patrikdufresne.managers.databinding.ManagerUpdateValueStrategy
;
import
com.patrikdufresne.util.Localized
;
import
com.planimod.core.ApplicationSetting
;
import
com.planimod.core.PlanimodManagers
;
import
com.planimod.ui.PlanimodPolicy
;
import
com.planimod.ui.databinding.MotifBean
;
/**
* This dialog is used to change the Planimod Motif parameters.
*
* @author Karl St-Cyr
*
*/
public
class
MotifPreferencePage
extends
PreferencePage
{
private
AddMotifEntry
addMotifEntry
;
private
DataBindingContext
dbc
=
new
DataBindingContext
();
private
Localized
localized
=
Localized
.
load
(
AppearancePreferencePage
.
class
);
private
PlanimodManagers
managers
;
public
WritableSet
motifs
;
private
ObservablesManager
om
;
private
RemoveMotifEntry
removeMotifEntry
;
private
TableViewer
viewer
;
/**
* Key to acces the non availability motif. Used to filter the non availability.
*/
public
static
final
String
NONAVAILABILITY_REASON
=
"Nouveau motif,"
;
//$NON-NLS-1$
/**
* Create a new preference page.
*/
public
MotifPreferencePage
(
PlanimodManagers
manager
)
{
super
();
if
(
manager
==
null
)
{
throw
new
IllegalArgumentException
();
}
this
.
managers
=
manager
;
setTitle
(
this
.
localized
.
get
(
"MotifPreferencePage.title"
));
//$NON-NLS-1$
}
/**
* Sets the binding between the values and the page.
*/
private
void
bind
()
{
this
.
dbc
=
new
DataBindingContext
();
this
.
om
=
new
ObservablesManager
();
this
.
om
.
runAndCollect
(
new
Runnable
()
{
@Override
public
void
run
()
{
bindValues
();
}
});
this
.
om
.
addObservablesFromContext
(
this
.
dbc
,
true
,
true
);
}
/**
* Used to bind the widgets
*/
protected
void
bindValues
()
{
this
.
motifs
=
new
WritableSet
();
String
nAReason
=
null
;
try
{
nAReason
=
this
.
managers
.
getApplicationSettingManager
().
getByName
(
NONAVAILABILITY_REASON
);
}
catch
(
ManagerException
e
)
{
PlanimodPolicy
.
showException
(
e
);
}
if
(
nAReason
==
null
)
{
nAReason
=
this
.
localized
.
get
(
"AddMotifEntry.newMotif"
);
//$NON-NLS-1$
}
for
(
String
s
:
nAReason
.
split
(
","
))
{
//$NON-NLS-1$
MotifBean
r
=
new
MotifBean
();
r
.
setName
(
s
);
this
.
motifs
.
add
(
r
);
}
ObservableSetContentProvider
oscp
=
new
ObservableSetContentProvider
();
viewer
.
setContentProvider
(
oscp
);
IValueProperty
nameProperty
=
BeanProperties
.
value
(
MotifBean
.
class
,
MotifBean
.
NAME
);
ColumnSupport
.
create
(
viewer
,
this
.
localized
.
get
(
"MotifPreferencePage.title"
),
oscp
.
getKnownElements
(),
nameProperty
)
//$NON-NLS-1$
.
addTextEditingSupport
(
this
.
dbc
,
new
ManagerUpdateValueStrategy
(
this
.
managers
,
UpdateValueStrategy
.
POLICY_CONVERT
),
null
)
.
setWeightLayoutData
(
1
,
70
)
.
setResizable
(
false
)
.
setMoveable
(
false
);
viewer
.
setInput
(
this
.
motifs
);
/*
* Create the binding for the action
*/
// Bind add action
dbc
.
bindSet
(
JFaceProperties
.
set
(
AddMotifEntry
.
class
,
AddMotifEntry
.
MOTIFS
).
observe
(
this
.
addMotifEntry
),
this
.
motifs
);
// Bind remove action
dbc
.
bindSet
(
JFaceProperties
.
set
(
RemoveMotifEntry
.
class
,
RemoveMotifEntry
.
MOTIFS
).
observe
(
this
.
removeMotifEntry
),
this
.
motifs
);
dbc
.
bindValue
(
JFaceProperties
.
value
(
RemoveMotifEntry
.
class
,
RemoveMotifEntry
.
MOTIF
,
RemoveMotifEntry
.
MOTIF
).
observe
(
this
.
removeMotifEntry
),
ViewerProperties
.
singleSelection
().
observe
(
this
.
viewer
));
}
@Override
protected
Control
createContents
(
Composite
parent
)
{
// PlanimodManagers.updateDatabase(manager.getSessionFactory());
Composite
comp
=
new
Composite
(
parent
,
SWT
.
NONE
);
comp
.
setLayout
(
GridLayoutFactory
.
fillDefaults
().
create
());
comp
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
// TableViewer from Planimod
this
.
viewer
=
new
TableViewer
(
comp
,
SWT
.
BORDER
|
SWT
.
H_SCROLL
|
SWT
.
V_SCROLL
|
SWT
.
FULL_SELECTION
);
this
.
viewer
.
getTable
().
setHeaderVisible
(
false
);
// Change the editor strategy
ColumnViewerEditorActivationStrategy
actSupport
=
new
ColumnViewerEditorActivationStrategy
(
this
.
viewer
)
{
@Override
protected
boolean
isEditorActivationEvent
(
ColumnViewerEditorActivationEvent
event
)
{
return
event
.
eventType
==
ColumnViewerEditorActivationEvent
.
TRAVERSAL
||
event
.
eventType
==
ColumnViewerEditorActivationEvent
.
MOUSE_DOUBLE_CLICK_SELECTION
||
(
event
.
eventType
==
ColumnViewerEditorActivationEvent
.
KEY_PRESSED
&&
event
.
keyCode
==
SWT
.
CR
)
||
event
.
eventType
==
ColumnViewerEditorActivationEvent
.
PROGRAMMATIC
;
}
};
TableViewerEditor
.
create
(
this
.
viewer
,
actSupport
,
ColumnViewerEditor
.
TABBING_HORIZONTAL
|
ColumnViewerEditor
.
TABBING_CYCLE_IN_ROW
|
ColumnViewerEditor
.
TABBING_VERTICAL
|
ColumnViewerEditor
.
KEYBOARD_ACTIVATION
);
// Composite for the buttons (Add and Remove)
Composite
buttonsComp
=
new
Composite
(
parent
,
SWT
.
NONE
);
buttonsComp
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
));
buttonsComp
.
setLayout
(
RowLayoutFactory
.
fillDefaults
().
create
());
// Add button
(
new
ActionContributionItem
(
this
.
addMotifEntry
=
new
AddMotifEntry
(),
true
)).
fill
(
buttonsComp
);
// Remove button
(
new
ActionContributionItem
(
this
.
removeMotifEntry
=
new
RemoveMotifEntry
(),
true
)).
fill
(
buttonsComp
);
bind
();
return
comp
;
}
/**
* This implementation save the motif to the managers.
*/
@Override
public
boolean
performOk
()
{
StringBuilder
buf
=
new
StringBuilder
();
if
(
motifs
!=
null
)
{
@SuppressWarnings
(
"unchecked"
)
Iterator
<
MotifBean
>
iter
=
motifs
.
iterator
();
try
{
while
(
iter
.
hasNext
())
{
buf
.
append
(
iter
.
next
().
getName
());
if
(
iter
.
hasNext
())
{
buf
.
append
(
","
);
//$NON-NLS-1$
}
}
buf
.
append
(
","
);
//$NON-NLS-1$
this
.
managers
.
getApplicationSettingManager
().
setByName
(
NONAVAILABILITY_REASON
,
buf
.
toString
());
}
catch
(
ManagerException
e
)
{
PlanimodPolicy
.
showException
(
e
);
}
}
return
true
;
}
}
com.patrikdufresne.planimod/src/main/java/com/planimod/ui/views/admin/RemoveMotifEntry.java
0 → 100644
View file @
9033dde6
/**
* Copyright(C) 2019 Patrik Dufresne Service Logiciel <info@patrikdufresne.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 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 GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package
com.planimod.ui.views.admin
;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.eclipse.jface.action.Action
;
import
com.patrikdufresne.util.Localized
;
import
com.planimod.ui.databinding.MotifBean
;
import
com.planimod.ui.theme.Resources
;
/**
* This action is used to remove a chart from a set of charts. Notice: this action does not persists the modification.
*
* @author Karl St-Cyr
*
*/
public
class
RemoveMotifEntry
extends
Action
{
/**
* Selected Motif.
*/
public
static
final
String
MOTIF
=
"motif"
;
//$NON-NLS-1$
/**
* Motif property.
*/
public
static
final
String
MOTIFS
=
"motifs"
;
//$NON-NLS-1$
/**
* Used for localization.
*/
private
Localized
localized
=
Localized
.
load
(
AddMotifEntry
.
class
);
/**
* Point chart property name.
*/
private
MotifBean
motif
;
/**
* The current collection of charts
*/
private
Set
<
MotifBean
>
motifs
;
/**
* Create a new action.
*/
public
RemoveMotifEntry
()
{
setText
(
this
.
localized
.
get
(
"RemoveMotifEntry.text"
));
//$NON-NLS-1$
setImageDescriptor
(
Resources
.
getImageDescriptor
(
Resources
.
ICON_LIST_REMOVE_16
));
setEnabled
(
canRun
());
setToolTipText
(
this
.
localized
.
get
(
"RemoveMotifEntry.tooltip"
));
//$NON-NLS-1$
}
/**
* Check if this action can be run.
*
* @return True if the action can be run.
*/
protected
boolean
canRun
()
{
return
motif
!=
null
&&
motifs
!=
null
&&
motifs
.
contains
(
motif
);
}
/**
* Return the chart object to be deleted.
*
* @return the chart object or null if not set.
*/
public
MotifBean
getMotif
()
{
return
motif
;
}
/**
* Return the point chart to be updated or null if not set.
*
* @return Set<MotifBean>
*/
public
Set
<
MotifBean
>
getMotifs
()
{
return
motifs
;
}
/**
* This implementation remove the object from the list and fire a change property.
*/
@Override
public
void
run
()
{
if
(!
canRun
())
{
return
;
}
if
(
this
.
motifs
==
null
)
{
this
.
motifs
=
new
HashSet
<
MotifBean
>();
this
.
motifs
.
add
(
new
MotifBean
());
}
// Remove the object from the current list
Set
<
MotifBean
>
oldList
=
this
.
motifs
;
this
.
motifs
=
new
HashSet
<
MotifBean
>(
this
.
motifs
);
if
(
this
.
motifs
.
remove
(
this
.
motif
))
{
// Fire a property change
firePropertyChange
(
MOTIFS
,
oldList
,
this
.
motifs
);
}
}
/**
* Sets the chart to be deleted.
*
* @param motif
* the chart object
*/
public
void
setMotif
(
MotifBean
motif
)
{
if
(
this
.
motif
!=
motif
)
{
firePropertyChange
(
MOTIF
,
this
.
motif
,
this
.
motif
=
motif
);
setEnabled
(
canRun
());
}
}
/**
* Sets the point chart object to be updated or null if not set.
*
* @param set
* <MotifBean>
*/
public
void
setMotifs
(
Set
<
MotifBean
>
motifs
)
{
if
(
this
.
motifs
!=
motifs
)
{
firePropertyChange
(
MOTIF
,
this
.
motifs
,
this
.
motifs
=
motifs
);
setEnabled
(
canRun
());
}
}
}
com.patrikdufresne.planimod/src/main/java/com/planimod/ui/views/nonavailabilities/NonAvailabilityDialog.java
View file @
9033dde6
...
...
@@ -53,18 +53,19 @@ import org.eclipse.swt.widgets.Control;
import
org.eclipse.swt.widgets.DateTime
;
import
org.eclipse.swt.widgets.Label
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.swt.widgets.Text
;
import
com.patrikdufresne.jface.databinding.datetime.DateTimeSupport
;
import
com.patrikdufresne.jface.databinding.viewers.TextProposalViewerUpdater
;
import
com.patrikdufresne.jface.dialogs.DefaultValidationMessageProvider
;
import
com.patrikdufresne.jface.viewers.TextProposalViewer
;
import
com.patrikdufresne.managers.ManagerException
;
import
com.patrikdufresne.util.DateFormatRegistry
;
import
com.planimod.core.Employee
;
import
com.planimod.core.PlanimodManagers
;
import
com.planimod.ui.databinding.manager.PlanimodObservables
;
import
com.planimod.ui.theme.Resources
;
import
com.planimod.ui.viewers.EmployeeViewerUtils
;
import
com.planimod.ui.views.admin.MotifPreferencePage
;
/**
* Dialog to create or edit a non-availability.
...
...
@@ -146,7 +147,7 @@ public class NonAvailabilityDialog extends TitleAreaDialog {
/**
* Summary widget
*/
private
Text
summaryText
;
private
Combo
motifCombo
;
/**
* Button to set non-availability visibility.
...
...
@@ -158,6 +159,8 @@ public class NonAvailabilityDialog extends TitleAreaDialog {
*/
private
WritableValue
visible
;
private
String
motifs
;
public
NonAvailabilityDialog
(
IShellProvider
provider
,
PlanimodManagers
managers
,
int
style
)
{
this
(
provider
.
getShell
(),
managers
,
style
);
}
...
...
@@ -280,7 +283,7 @@ public class NonAvailabilityDialog extends TitleAreaDialog {
DataBindingContext
dbc
=
new
DataBindingContext
();
// Bind summary
dbc
.
bindValue
(
SWTObservables
.
observe
Text
(
this
.
summaryText
,
SWT
.
Modify
),
this
.
summary
);
dbc
.
bindValue
(
SWTObservables
.
observe
Selection
(
motifCombo
),
this
.
summary
);
// Bind employee viewer
bindEmployeeValues
(
dbc
);
...
...
@@ -358,36 +361,100 @@ public class NonAvailabilityDialog extends TitleAreaDialog {
this
.
employeeViewer
.
getControl
().
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
false
));
// Summary
this
.
summaryText
=
new
Text
(
composite
,
SWT
.
BORDER
);
this
.
summaryText
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
false
));
// Start date To End date
Composite
compDates
=
new
Composite
(
composite
,
SWT
.
NONE
);
layout
=
new
GridLayout
(
5
,
false
);
layout
=
new
GridLayout
(
3
,
false
);
layout
.
marginHeight
=
0
;
layout
.
marginWidth
=
0
;
layout
.
verticalSpacing
=
0
;
compDates
.
setLayout
(
layout
);
this
.
startDate
=
new
DateTime
(
compDates
,
SWT
.
DATE
|
SWT
.
DROP_DOWN
|
SWT
.
BORDER
);
Composite
compDates2
=
new
Composite
(
compDates
,
SWT
.
NONE
);
layout
=
new
GridLayout
(
1
,
false
);
layout
.
marginHeight
=
0
;
layout
.
marginWidth
=
0
;
layout
.
verticalSpacing
=
0
;
compDates2
.
setLayout
(
layout
);
Composite
compDates3
=
new
Composite
(
compDates2
,
SWT
.
NONE
);
layout
=
new
GridLayout
(
3
,
false
);
layout
.
marginHeight
=
0
;
layout
.
marginWidth
=
0
;
layout
.
verticalSpacing
=
0
;
compDates3
.
setLayout
(
layout
);
label
=
new
Label
(
compDates3
,
SWT
.
NONE
);
label
.
setText
(
_
(
"au"
));
this
.
startDate
=
new
DateTime
(
compDates3
,
SWT
.
DATE
|
SWT
.
DROP_DOWN
|
SWT
.
BORDER
);
this
.
startDate
.
setLayoutData
(
new
GridData
(
SWT
.
LEFT
,
SWT
.
CENTER
,
false
,
false
));
this
.
startTime
=
new
Combo
(
compDates
,
SWT
.
BORDER
|
SWT
.
DROP_DOWN
);
this
.
startTime
=
new
Combo
(
compDates
3
,
SWT
.
BORDER
|
SWT
.
DROP_DOWN
);
this
.
startTime
.
setLayoutData
(
new
GridData
(
SWT
.
LEFT
,
SWT
.
CENTER
,
false
,
false
));
label
=
new
Label
(
compDates
,
SWT
.
NONE
);
compDates3
=
new
Composite
(
compDates2
,
SWT
.
NONE
);
layout
=
new
GridLayout
(
1
,
false
);
layout
.
marginHeight
=
0
;
layout
.
marginWidth
=
15
;
layout
.
verticalSpacing
=
0
;
compDates3
.
setLayout
(
layout
);
compDates3
=
new
Composite
(
compDates2
,
SWT
.
NONE
);
layout
=
new
GridLayout
(
3
,
false
);
layout
.
marginHeight
=
0
;
layout
.
marginWidth
=
0
;
layout
.
verticalSpacing
=
0
;
compDates3
.
setLayout
(
layout
);
label
=
new
Label
(
compDates3
,
SWT
.
NONE
);
label
.
setText
(
_
(
"au"
));
this
.
endDate
=
new
DateTime
(
compDates
,
SWT
.
DATE
|
SWT
.
DROP_DOWN
|
SWT
.
BORDER
);
this
.
endDate
=
new
DateTime
(
compDates3
,
SWT
.
DATE
|
SWT
.
DROP_DOWN
|
SWT
.
BORDER
);
this
.
endDate
.
setLayoutData
(
new
GridData
(
SWT
.
LEFT
,
SWT
.
CENTER
,
false
,
false
));
this
.
endTime
=
new
Combo
(
compDates
,
SWT
.
BORDER
|
SWT
.
DROP_DOWN
);
this
.
endTime
=
new
Combo
(
compDates
3
,
SWT
.
BORDER
|
SWT
.
DROP_DOWN
);
this
.
endTime
.
setLayoutData
(
new
GridData
(
SWT
.
LEFT
,
SWT
.
CENTER
,
false
,
false
));
compDates2
=
new
Composite
(
compDates
,
SWT
.
NONE
);
layout
=
new
GridLayout
(
1
,
false
);
layout
.
marginHeight
=
0
;
layout
.
marginWidth
=
25
;
layout
.
verticalSpacing
=
0
;
compDates2
.
setLayout
(
layout
);
Label
separator
=
new
Label
(
compDates2
,
SWT
.
VERTICAL
|
SWT
.
SEPARATOR
);
separator
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_VERTICAL
));
compDates2
=
new
Composite
(
compDates
,
SWT
.
NONE
);
layout
=
new
GridLayout
(
1
,
false
);
layout
.
marginHeight
=
0
;
layout
.
marginWidth
=
0
;
layout
.
verticalSpacing
=
0
;
compDates2
.
setLayout
(
layout
);
compDates3
=
new
Composite
(
compDates2
,
SWT
.
NONE
);
layout
=
new
GridLayout
(
2
,
false
);
layout
.
marginHeight
=
0
;
layout
.
marginWidth
=
0
;
layout
.
verticalSpacing
=
0
;
compDates3
.
setLayout
(
layout
);
label
=
new
Label
(
compDates3
,
SWT
.
NONE
);
label
.
setText
(
"Motif :"
);
//$NON-NLS-1$
motifCombo
=
new
Combo
(
compDates3
,
SWT
.
BORDER
|
SWT
.
DROP_DOWN
);
motifCombo
.
setLayoutData
(
new
GridData
(
SWT
.
LEFT
|
SWT
.
FILL
,
SWT
.
CENTER
|
SWT
.
FILL
,
true
,
false
));
for
(
String
s
:
motifs
.
split
(
","
))
{
//$NON-NLS-1$
motifCombo
.
add
(
s
);
}
separator
=
new
Label
(
comp
,
SWT
.
HORIZONTAL
|
SWT
.
SEPARATOR
);
separator
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
// Visibility
this
.
visibileButton
=
new
Button
(
composite
,
SWT
.
CHECK
);
this
.
visibileButton
.
setText
(
_
(
"Afficher l'absence lors de l'impression des rapports"
));
compDates3
=
new
Composite
(
comp
,
SWT
.
NONE
);
layout
=
new
GridLayout
(
2
,
false
);
layout
.
marginHeight
=
0
;
layout
.
marginWidth
=
0
;
layout
.
verticalSpacing
=
0
;
compDates3
.
setLayout
(
layout
);
this
.
visibileButton
=
new
Button
(
comp
,
SWT
.
CHECK
);
this
.
visibileButton
.
setText
(
_
(
"Afficher l'absence lors de l'impression des rapports"
));
//$NON-NLS-1$
this
.
visibileButton
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
false
));
// Build the separator line
Label
separator
=
new
Label
(
comp
,
SWT
.
HORIZONTAL
|
SWT
.
SEPARATOR
);
separator
=
new
Label
(
comp
,
SWT
.
HORIZONTAL
|
SWT
.
SEPARATOR
);
separator
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
return
comp
;
...
...
@@ -439,7 +506,18 @@ public class NonAvailabilityDialog extends TitleAreaDialog {
}
protected
void
initValues
()
{
this
.
summary
=
new
WritableValue
(
""
,
String
.
class
);
String
motifs
=
""
;
//$NON-NLS-1$
try
{
motifs
=
this
.
managers
.
getApplicationSettingManager
().
getByName
(
MotifPreferencePage
.
NONAVAILABILITY_REASON
);
}
catch
(
ManagerException
e1
)
{
// TODO Auto-generated catch block
e1
.
printStackTrace
();
}
if
(
motifs
==
null
)
{
motifs
=
"Nouveau motif,"
;
}
this
.
summary
=
new
WritableValue
(
motifs
.
substring
(
0
,
motifs
.
indexOf
(
","
)),
String
.
class
);
this
.
motifs
=
motifs
;
this
.
start
=
new
WritableValue
(
new
Date
(),
Date
.
class
);
this
.
end
=
new
WritableValue
(
new
Date
(),
Date
.
class
);
this
.
employee
=
new
WritableValue
(
null
,
Employee
.
class
);
...
...