Project

General

Profile

« Previous | Next » 

Revision 36a704bb

Added by Patrick Plitzner over 6 years ago

ref #6672 Migrate authentication bar

View differences:

eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/perspective/SpacerControl.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.perspective;
10

  
11
import javax.annotation.PostConstruct;
12

  
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.layout.FillLayout;
15
import org.eclipse.swt.widgets.Composite;
16

  
17
/**
18
 * @author pplitzner
19
 * @since Nov 16, 2017
20
 *
21
 */
22
public class SpacerControl {
23
    @PostConstruct
24
    public void postConstruct(final Composite parent) {
25
        Composite body = new Composite(parent, SWT.NONE);
26

  
27
        body.setLayout(new FillLayout());
28
    }
29
}
eu.etaxonomy.taxeditor.store/fragment.e4xmi
234 234
    <elements xsi:type="advanced:Placeholder" xmi:id="_9WhpQMuxEeeIUZ_CoTN6NQ" elementId="eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditor" toBeRendered="false" ref="_-bLWkMLREeev9_rmnyo1RA"/>
235 235
    <elements xsi:type="advanced:Placeholder" xmi:id="__ocBgMuxEeeIUZ_CoTN6NQ" elementId="eu.etaxonomy.taxeditor.editor.definedTerm" toBeRendered="false" ref="_FDThIMLSEeev9_rmnyo1RA"/>
236 236
  </fragments>
237
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_3MWDwM3GEeezbuyt8BxlSA" featurename="children" parentElementId="eu.etaxonomy.taxeditor.application.trimbar.bottom" positionInList="last">
238
    <elements xsi:type="menu:ToolControl" xmi:id="_uXvIoM3IEeezbuyt8BxlSA" elementId="eu.etaxonomy.taxeditor.store.toolcontrol.authentication.spacer" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.SpacerControl">
239
      <tags>stretch</tags>
240
    </elements>
241
    <elements xsi:type="menu:ToolBar" xmi:id="_s83GEM3IEeezbuyt8BxlSA" elementId="eu.etaxonomy.taxeditor.store.toolbar.0">
242
      <children xsi:type="menu:ToolControl" xmi:id="_6pk_oM3GEeezbuyt8BxlSA" elementId="eu.etaxonomy.taxeditor.ui.bar.AuthenticatedUserBarE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.ui.bar.AuthenticatedUserBarE4"/>
243
    </elements>
244
  </fragments>
237 245
</fragment:ModelFragments>
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/bar/AuthenticatedUserBarE4.java
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

  
10
package eu.etaxonomy.taxeditor.ui.bar;
11

  
12
import java.util.Observable;
13
import java.util.Observer;
14

  
15
import javax.annotation.PostConstruct;
16
import javax.annotation.PreDestroy;
17
import javax.inject.Inject;
18

  
19
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
23
import org.eclipse.swt.widgets.Label;
24

  
25
import eu.etaxonomy.cdm.model.common.User;
26
import eu.etaxonomy.taxeditor.l10n.Messages;
27
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource;
28
import eu.etaxonomy.taxeditor.store.CdmStore;
29

  
30
/**
31
 * Shows the currently logged in user in status bar
32
 *
33
 * @author n.hoffmann
34
 * @created 01.07.2009
35
 * @version 1.0
36
 */
37
public class AuthenticatedUserBarE4 implements Observer{
38

  
39
    private Label label_authenticatedUser;
40

  
41
    @Inject
42
    private MWindow window;
43

  
44
    public AuthenticatedUserBarE4(){
45
        CdmStore.getLoginManager().addObserver(this);
46
    }
47

  
48
    /** {@inheritDoc} */
49
    @PostConstruct
50
    protected Control createControl(Composite parent) {
51
        parent.getParent().setRedraw(true);
52
        label_authenticatedUser = new Label(parent,  SWT.NULL);
53

  
54
        update(null, null);
55

  
56
        return label_authenticatedUser;
57
    }
58

  
59
    /** {@inheritDoc} */
60
    @Override
61
    public void update(Observable o, Object arg) {
62
        User authenticatedUser = CdmStore.getLoginManager().getAuthenticatedUser();
63
        // TODO find a method to recompute width for parental toolbar item
64
        String text = ""; //$NON-NLS-1$
65
        if(authenticatedUser == null) {
66
            text = Messages.AuthenticatedUserBar_NOT_LOGGED_IN ;
67
        } else {
68
            CdmRemoteSource source = (CdmRemoteSource) CdmStore.getActiveCdmSource();
69
            String loginInfo = String.format("%s@%s:%s",authenticatedUser.getUsername(), source.getName(), source.getContextPath()); //$NON-NLS-1$
70
            window.setLabel(window.getLabel()+" "+loginInfo);
71

  
72
            text = String.format(Messages.AuthenticatedUserBar_LOGGED_IN_AS, authenticatedUser.getUsername());
73
        }
74

  
75
        label_authenticatedUser.setText(text);
76
        label_authenticatedUser.setRedraw(true);
77
    }
78

  
79
    /** {@inheritDoc} */
80
    @PreDestroy
81
    public void dispose() {
82
        CdmStore.getLoginManager().deleteObserver(this);
83
    }
84

  
85
}
eu.etaxonomy.taxeditor.workbench/fragment.e4xmi
117 117
    <elements xsi:type="commands:Handler" xmi:id="_bkScIL4vEeewU62zpvPllA" elementId="eu.etaxonomy.taxeditor.workbench.handler.ExpandHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.handler.ExpandHandler" command="_Z0st0L4vEeewU62zpvPllA"/>
118 118
  </fragments>
119 119
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_lRtmsMLwEee0N85Mii-Chg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.application.trimbar.bottom">
120
    <elements xsi:type="menu:ToolControl" xmi:id="_oKE68MLwEee0N85Mii-Chg" elementId="eu.etaxonomy.taxeditor.workbench.StatusBar" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.StatusBar"/>
120
    <elements xsi:type="menu:ToolBar" xmi:id="_alM80M3JEeezbuyt8BxlSA" elementId="eu.etaxonomy.taxeditor.workbench.toolbar.0">
121
      <children xsi:type="menu:ToolControl" xmi:id="_oKE68MLwEee0N85Mii-Chg" elementId="eu.etaxonomy.taxeditor.workbench.StatusBar" contributionURI="bundleclass://eu.etaxonomy.taxeditor.workbench/eu.etaxonomy.taxeditor.workbench.StatusBar"/>
122
    </elements>
121 123
  </fragments>
122 124
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_2ZfKQMrjEeewfqnfrNoNfg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.application.trimcontribution.perspectiveSwitch" positionInList="first">
123 125
    <elements xsi:type="menu:ToolBar" xmi:id="_KDVngB92EeeIA_2gwq7JKg" elementId="eu.etaxonomy.taxeditor.workbench.menu.toolbar.0">
eu.etaxonomy.taxeditor.workbench/src/main/java/eu/etaxonomy/taxeditor/workbench/SpacerControl.java
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.workbench;
10

  
11
import javax.annotation.PostConstruct;
12

  
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.layout.FillLayout;
15
import org.eclipse.swt.widgets.Composite;
16

  
17
/**
18
 * @author pplitzner
19
 * @since Nov 16, 2017
20
 *
21
 */
22
public class SpacerControl {
23
    @PostConstruct
24
    public void postConstruct(final Composite parent) {
25
        Composite body = new Composite(parent, SWT.NONE);
26

  
27
        body.setLayout(new FillLayout());
28
    }
29
}

Also available in: Unified diff