Commit 485372e7 authored by Hélène Ortiz's avatar Hélène Ortiz

Improve vertical alignment in command box (remove top margin of 4px in

gridlayout and rowlayout).
Modify code for proposal change controller.
parent 44c602f5
4.0.48 21/07/2020
------
* Improve vertical alignment in command box (remove top margin of 4px in gridlayout and rowlayout).
* Modify code for proposal change controller.
4.0.47 17/07/2020
------
* Fix bug: staff users have access to all proposals.
......
......@@ -35,6 +35,7 @@ import fr.ill.ics.client.view.error.ServerErrorConsole;
import fr.ill.ics.client.view.error.SimulationResultsWindow;
import fr.ill.ics.client.view.log.LogWindow;
import fr.ill.ics.client.view.logger.LoggerWindow;
import fr.ill.ics.client.view.login.AuthenticationPeer;
import fr.ill.ics.client.view.menu.MenuBuilder;
import fr.ill.ics.client.view.pluginpeer.selection.SelectionPluginPeer;
import fr.ill.ics.client.view.startup.StartupSplashDialog;
......@@ -100,6 +101,9 @@ public abstract class MainWindowPeer {
protected TokenWidget tokenWidget;
protected String title;
protected AuthenticationPeer authenticationPeer;
// Singleton pattern with subclassing: constructor protected for concrete implementations.
protected MainWindowPeer() {
......@@ -337,6 +341,10 @@ public abstract class MainWindowPeer {
public static boolean ready() {
return windowReady;
}
public AuthenticationPeer getAuthenticationPeer() {
return authenticationPeer;
}
public abstract void initDisplay();
public abstract void initFactories();
......
......@@ -204,6 +204,8 @@ public abstract class ImageFactory {
public final static String OK_BUTTON = pushButtonsPath + "okButton.png";
public final static String OK_MOUSE_OVER_BUTTON = pushButtonsPath + "okMouseOverButton.png";
public final static String SELECT_PROPOSAL = pushButtonsPath + "select.png";
public static final String EMPTY_ONE_PIXEL = "emptyOnePixel.png";
/********************************************************************
......
......@@ -381,11 +381,11 @@ public class SWTWidgetFactory extends WidgetFactory {
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = nbColumns;
gridLayout.horizontalSpacing = WidgetFactory.HORIZONTAL_SPACING;
gridLayout.verticalSpacing = 0; // WidgetFactory.VERTICAL_SPACING;
gridLayout.verticalSpacing = 0;
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
gridLayout.marginBottom = 4;
gridLayout.marginTop = 4;
gridLayout.marginTop = 0;
return gridLayout;
}
......@@ -815,7 +815,7 @@ public class SWTWidgetFactory extends WidgetFactory {
rowLayout.justify = justify;
rowLayout.type = orientation; // SWT.VERTICAL or SWT.HORIZONTAL
rowLayout.spacing = 0;
rowLayout.marginTop = 4;
rowLayout.marginTop = 0;
rowLayout.marginWidth = 0;
rowLayout.marginLeft = 0;
rowLayout.marginRight = 0;
......
......@@ -19,6 +19,7 @@ package fr.ill.ics.client.view.login;
import fr.ill.ics.client.control.login.Authentication;
import fr.ill.ics.client.control.login.UserConnection;
import fr.ill.ics.client.control.plugin.command.IProposalChangeControllerCommandPlugin;
import fr.ill.ics.client.view.login.popup.AuthenticationPopup;
import fr.ill.ics.client.view.magnifier.IMagnifyListener;
import fr.ill.ics.client.view.widget.PContainer;
......@@ -43,6 +44,7 @@ public abstract class AuthenticationPeer implements IMagnifyListener {
protected AuthenticationPopup popup;
protected IProposalChangeControllerCommandPlugin proposalChangeControllerCommandPlugin;
public AuthenticationPeer() {
authentication = new Authentication(this);
......@@ -75,7 +77,14 @@ public abstract class AuthenticationPeer implements IMagnifyListener {
setCurrentProposal();
}
public void setProposalChangeControllerCommandPlugin(IProposalChangeControllerCommandPlugin proposalChangeControllerCommandPlugin) {
this.proposalChangeControllerCommandPlugin = proposalChangeControllerCommandPlugin;
}
public IProposalChangeControllerCommandPlugin getProposalChangeControllerCommandPlugin() {
return proposalChangeControllerCommandPlugin;
}
public abstract void setCurrentProposal();
protected abstract void setFocus(int fieldId);
protected abstract void openPopupAt(int x, int y);
......
......@@ -64,6 +64,7 @@ public class SWTProposalPopup extends SWTAuthenticationPopup {
private final static int TABLE_HEIGHT = 200;
private final static String PROPOSAL_ID = "PROPOSAL_ID";
private final static String PROPOSAL_CODE = "PROPOSAL_CODE";
private final static String CYCLE_ID = "CYCLE_ID";
protected final static int COLUMN_CODE = 0;
......@@ -71,6 +72,7 @@ public class SWTProposalPopup extends SWTAuthenticationPopup {
private Table proposalTable;
private String selectedProposalId;
private String selectedProposalCode;
private String selectedProposalCycleId;
private Label selectLabel;
private TableColumn proposalNumberColumn;
......@@ -130,12 +132,14 @@ public class SWTProposalPopup extends SWTAuthenticationPopup {
Proposal proposal = it.next();
items[i] = SWTWidgetFactory.getInstance().createTableItem(proposalTable, SWT.NONE);
items[i].setData(PROPOSAL_ID, proposal.getId()+"");
items[i].setData(PROPOSAL_CODE, proposal.getCode()+"");
items[i].setData(CYCLE_ID, proposal.getCycleId()+"");
items[i].setText(COLUMN_CODE, proposal.getCode());
items[i].setText(COLUMN_TITLE, proposal.getTitle());
i++;
}
selectedProposalId = (String)proposalTable.getItems()[0].getData(PROPOSAL_ID);
selectedProposalCode = (String)proposalTable.getItems()[0].getData(PROPOSAL_CODE);
for (i = 0; i < proposalTable.getItemCount(); i++) {
if (i % 2 == 0) {
......@@ -199,6 +203,7 @@ public class SWTProposalPopup extends SWTAuthenticationPopup {
private void onProposalSelection() {
if (proposals != null && !proposals.isEmpty()) {
selectedProposalId = (String)proposalTable.getSelection()[0].getData(PROPOSAL_ID);
selectedProposalCode = (String)proposalTable.getSelection()[0].getData(PROPOSAL_CODE);
selectedProposalCycleId = (String)proposalTable.getSelection()[0].getData(CYCLE_ID);
}
}
......@@ -212,31 +217,39 @@ public class SWTProposalPopup extends SWTAuthenticationPopup {
protected void onButtonClick(int buttonId) {
switch (buttonId) {
case SELECT_ID:
try {
// Check that user still has the token
if (TokenManager.getInstance().tokenIsOwnedByMe() && ConfigManager.getInstance().isMainClient()) {
// Do something only if selected proposal has changed
if (Long.valueOf(selectedProposalId) != ExperimentData.getInstance().getProposalId()) {
// Once proposal code has been set, trigger all field updates by setting proposal id
UserConnection.getInstance().setSelectedProposalId(Long.valueOf(selectedProposalId), true);
// Cycle id can change if we are in test mode
if (UserConnection.getInstance().getInvestigationsMode() == UserConnection.MODE_INVESTIGATIONS_TEST) {
ExperimentData.getInstance().setCycleId(selectedProposalCycleId);
}
}
if (authenticationPeer.getProposalChangeControllerCommandPlugin() != null) {
authenticationPeer.getProposalChangeControllerCommandPlugin().onSelectProposal(selectedProposalId, selectedProposalCode);
close();
if (followingController != null) {
MainWindow.getInstance().goToNode(SelectionPlugin.SETTINGS_ID, ExperimentData.getInstance().getFollowingController());
}
} else {
DialogManager.getInstance().nomadAboutMessageDialog("cannotChangeProposalWithoutTokenMessage", "changeProposalMessage");
// Check that user still has the token
if (TokenManager.getInstance().tokenIsOwnedByMe() && ConfigManager.getInstance().isMainClient()) {
// Do something only if selected proposal has changed
if (Long.valueOf(selectedProposalId) != ExperimentData.getInstance().getProposalId()) {
// Once proposal code has been set, trigger all field updates by setting proposal id
UserConnection.getInstance().setSelectedProposalId(Long.valueOf(selectedProposalId), true);
// Cycle id can change if we are in test mode
if (UserConnection.getInstance().getInvestigationsMode() == UserConnection.MODE_INVESTIGATIONS_TEST) {
ExperimentData.getInstance().setCycleId(selectedProposalCycleId);
}
}
close();
if (followingController != null) {
MainWindow.getInstance().goToNode(SelectionPlugin.SETTINGS_ID, ExperimentData.getInstance().getFollowingController());
}
} else {
DialogManager.getInstance().nomadAboutMessageDialog("cannotChangeProposalWithoutTokenMessage", "changeProposalMessage");
}
break;
}
break;
} catch (NumberFormatException nfe) {
onCanvasClick(CLOSE_ID+"");
}
}
}
......
......@@ -36,7 +36,6 @@ import java.util.logging.Logger;
import fr.ill.ics.bridge.Controller;
import fr.ill.ics.bridge.ResourceManager;
import fr.ill.ics.bridge.command.CommandZoneWrapper;
import fr.ill.ics.client.control.MainWindow;
import fr.ill.ics.client.control.command.content.CommandBox;
import fr.ill.ics.client.control.parser.ControllerViewParser;
......@@ -74,7 +73,6 @@ import fr.ill.ics.core.command.CommandManager;
import fr.ill.ics.core.property.Property;
import fr.ill.ics.core.property.PropertyManager;
import fr.ill.ics.nscclient.servant.ResourceNotFoundException;
import fr.ill.ics.nscclient.sessionmanagement.SessionManager;
import fr.ill.ics.util.ConfigManager;
import fr.ill.ics.util.GenericParser;
import fr.ill.ics.util.exception.CommandNotFoundException;
......
......@@ -208,8 +208,8 @@ public class ControllerCommandPluginPeer extends ControllerPluginPeer {
}
public final void onExecutionPhaseStateChanged() {
// Not final ! Overrided in some special GUI modules
public void onExecutionPhaseStateChanged() {
if (getAllWidgets() != null) {
Iterator<NomadWidget> itWidgets = getAllWidgets().iterator();
while (itWidgets.hasNext()) {
......
......@@ -277,7 +277,7 @@ public class SWTMainWindowPeer extends MainWindowPeer {
gridLayout.marginRight = 0;//WidgetFactory.HORIZONTAL_SPACING;
parentPluginAreaComposite.setLayout(gridLayout);
SWTAuthenticationPeer loginPeer = new SWTAuthenticationPeer(parentPluginAreaComposite);
authenticationPeer = new SWTAuthenticationPeer(parentPluginAreaComposite);
this.pluginArea = SWTWidgetFactory.getInstance().createComposite(parentPluginAreaComposite, SWT.NONE);
this.pluginArea.setLayoutData(SWTWidgetFactory.getInstance().getGridData());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment