Commit 0a4bc09c authored by Piotr Różański's avatar Piotr Różański Committed by Marian Dovgialo

#45061 Changes in menu Online

parent 2b02b747
......@@ -32,17 +32,19 @@
private OpenDocumentDescriptor openDocumentDescriptor;
private SignalDocument signalDocument;
private final String selectedSourceTab;
/**
* Constructor.
* @param viewerElementManager ViewerElementManager to be used by
* this action.
* @param viewerElementManager ViewerElementManager to be used by this action.
* @param selectedSourceTab name of the tab to be made active by default (if null, first tab will be active)
*/
public OpenSignalWizardAction(ViewerElementManager viewerElementManager) {
public OpenSignalWizardAction(ViewerElementManager viewerElementManager, String selectedSourceTab) {
super();
this.documentFlowIntegrator = viewerElementManager.getDocumentFlowIntegrator();
this.viewerElementManager = viewerElementManager;
setText(_("Open signal"));
this.selectedSourceTab = selectedSourceTab;
setText(_(selectedSourceTab != null ? selectedSourceTab : "Open signal"));
setIconPath("org/signalml/app/icon/fileopen.png");
setToolTip(_("Open signal and set montage for it"));
setMnemonic(KeyEvent.VK_O);
......@@ -53,7 +55,7 @@ public void actionPerformed(ActionEvent arg0) {
openDocumentDescriptor = new OpenDocumentDescriptor();
OpenSignalWizardDialog openSignalWizardDialog = new OpenSignalWizardDialog(
viewerElementManager, viewerElementManager.getDialogParent(), true
viewerElementManager, selectedSourceTab
);
boolean ok = openSignalWizardDialog.showDialog(openDocumentDescriptor, true);
if (!ok) {
......
......@@ -49,9 +49,12 @@
private OpenSignalWizardStepOnePanel stepOnePanel;
private SignalMontagePanel stepTwoPanel;
public OpenSignalWizardDialog(ViewerElementManager viewerElementManager, Window f, boolean isModal) {
super(f, isModal);
private final String selectedSourceTab;
public OpenSignalWizardDialog(ViewerElementManager viewerElementManager, String selectedSourceTab) {
super(viewerElementManager.getDialogParent(), true);
this.viewerElementManager = viewerElementManager;
this.selectedSourceTab = selectedSourceTab;
this.setTitle(_("Open signal"));
}
......@@ -137,7 +140,7 @@ protected JComponent createInterfaceForStep(int step) {
protected OpenSignalWizardStepOnePanel getStepOnePanel() {
if (stepOnePanel == null) {
stepOnePanel = new OpenSignalWizardStepOnePanel(viewerElementManager);
stepOnePanel = new OpenSignalWizardStepOnePanel(viewerElementManager, selectedSourceTab);
}
return stepOnePanel;
}
......@@ -148,7 +151,7 @@ protected SignalMontagePanel getSignalMontagePanel() {
}
return stepTwoPanel;
}
@Override
public boolean supportsModelClass(Class<?> clazz) {
return OpenDocumentDescriptor.class.isAssignableFrom(clazz);
......
......@@ -41,8 +41,11 @@
private AbstractOpenSignalDescriptor openSignalDescriptor;
public OpenSignalWizardStepOnePanel(ViewerElementManager viewerElementManager) {
private final String selectedSourceTab;
public OpenSignalWizardStepOnePanel(ViewerElementManager viewerElementManager, String selectedSourceTab) {
this.viewerElementManager = viewerElementManager;
this.selectedSourceTab = selectedSourceTab;
this.setLayout(new GridLayout(1, 2));
this.add(createLeftPanel());
......@@ -87,7 +90,7 @@ public OtherSettingsPanel getOtherSettingsPanel() {
protected SignalSourceTabbedPane getSignalSourceTabbedPane() {
if (signalSourceTabbedPane == null) {
signalSourceTabbedPane = new SignalSourceTabbedPane(viewerElementManager);
signalSourceTabbedPane = new SignalSourceTabbedPane(viewerElementManager, selectedSourceTab);
signalSourceTabbedPane.addChangeListener(this);
signalSourceTabbedPane.addPropertyChangeListener(this);
getOtherSettingsPanel().getFileTypeComboBox().addItemListener(signalSourceTabbedPane);
......
......@@ -51,14 +51,26 @@
private Object fileTypeMethod = FileOpenSignalMethod.AUTODETECT;
public SignalSourceTabbedPane(ViewerElementManager viewerElementManager) {
this(viewerElementManager, null);
}
public SignalSourceTabbedPane(ViewerElementManager viewerElementManager, String selectedSourceTab) {
this.viewerElementManager = viewerElementManager;
addTab(_("File"), getFileChooserPanel());
int selectedIndex = 0;
if (ObciServerCapabilities.getSharedInstance().hasOnlineExperiments()) {
if ("Online experiments".equals(selectedSourceTab)) {
selectedIndex = getTabCount();
}
addTab(_("Online experiments"), getChooseExperimentPanel());
}
if (ObciServerCapabilities.getSharedInstance().hasOnlineAmplifiers()) {
if ("Online amplifiers".equals(selectedSourceTab)) {
selectedIndex = getTabCount();
}
addTab(_("Online amplifiers"), getChooseAmplifierPanel());
}
setSelectedIndex(selectedIndex);
}
/**
......
......@@ -650,7 +650,13 @@ public JMenu getMonitorMenu() {
if (monitorMenu == null) {
monitorMenu = new JMenu(_("Online"));
monitorMenu.setMnemonic(KeyEvent.VK_R);
final OpenSignalWizardAction onlineExperimentsAction = new OpenSignalWizardAction(this, "Online experiments");
final OpenSignalWizardAction onlineAmplifiersAction = new OpenSignalWizardAction(this, "Online amplifiers");
monitorMenu.add(onlineExperimentsAction);
monitorMenu.add(onlineAmplifiersAction);
monitorMenu.addSeparator();
monitorMenu.add(getAddCameraAction());
monitorMenu.addSeparator();
monitorMenu.add(getStartMonitorRecordingAction());
......@@ -661,6 +667,12 @@ public JMenu getMonitorMenu() {
monitorMenu.addMenuListener(new MenuListener() {
@Override
public void menuSelected(MenuEvent me) {
onlineExperimentsAction.setEnabled(
ObciServerCapabilities.getSharedInstance().hasOnlineExperiments()
);
onlineAmplifiersAction.setEnabled(
ObciServerCapabilities.getSharedInstance().hasOnlineAmplifiers()
);
getAddCameraAction().setEnabled(
ObciServerCapabilities.getSharedInstance().hasCameraServer()
);
......@@ -1487,7 +1499,7 @@ public EditSignalMontageAction getEditSignalMontageAction() {
public OpenSignalWizardAction getOpenSignalWizardAction() {
if (openSignalWizardAction == null) {
openSignalWizardAction = new OpenSignalWizardAction(this);
openSignalWizardAction = new OpenSignalWizardAction(this, null);
}
return openSignalWizardAction;
}
......
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