IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SWT/JFace Java Discussion :

Utilisation de Browser sous Linux


Sujet :

SWT/JFace Java

  1. #1
    Membre éclairé Avatar de kkt8
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    472
    Détails du profil
    Informations personnelles :
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 472
    Par défaut Utilisation de Browser sous Linux
    Bonjour,

    J'ai un gros clash à l'ouverture du browser (org.eclipse.swt.browser.Browser) que j'instancie dans une dialog afin d'y visualiser un fichier html :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    final Browser browser;
    browser = new Browser(bottom, SWT.BORDER);
    .... 	
    browser.setUrl("file:///" + fAboutHtml.getPath());
    sous Windows pas de problème (pour info firefox 3.6.16).

    Sous linux : clash :
    Unhandled event loop exception
    No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]

    Je ne sais pas trop quoi lui donner comme path, je pensais utiliser une librairie eclipse et non firefox (firefox 3.0.12).

    J'suis nulle en linux et je sais pas trop comment me sortir de ce truc, une idée ?

  2. #2
    Membre éclairé Avatar de kkt8
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    472
    Détails du profil
    Informations personnelles :
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 472
    Par défaut
    alors j'ai ajouté la variable d'env :
    MOZILLA_FIVE_HOME=/usr/lib/mozilla

    Mais j'ai toujours une erreur :

    Unhandled event loop exception
    No more handles [MOZILLA_FIVE_HOME='/usr/lib/mozilla'] (java.lang.UnsatisfiedLinkError: no swt-mozilla-gtk-3557 or swt-mozilla-gtk in swt.library.path, java.library.path or the jar file)


  3. #3
    Expert confirmé
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Par défaut
    XulRunner est bien installé dans ta distrib?

  4. #4
    Membre éclairé Avatar de kkt8
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    472
    Détails du profil
    Informations personnelles :
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 472
    Par défaut
    euh ... je sais même pas comment vérifier qu'il le soit

  5. #5
    Expert confirmé
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Par défaut
    Normalement c'est un package à part, installable via ton gestionnaire de paquets (du moins sous opensuse et ubuntu) c'est le cas.

  6. #6
    Membre éclairé Avatar de kkt8
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    472
    Détails du profil
    Informations personnelles :
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 472
    Par défaut
    le gestionnaire de paquets ???
    c'est quoi ça ?

    tu parles de eclipse ?
    si c'est le cas, je ne l'ai pas effectivement .. mais sous windows non plus ...

    Je peux pas ajouter de truc à installer je peux utiliser un autre browser pour afficher mon html sous linux ?

  7. #7
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Billets dans le blog
    1
    Par défaut
    Le gestionnaire de paquets est assimilable à l'option "Ajouter/Supprimer des programmes" dans Windows, donc, rien à voir avec Eclipse.

    Tu utilises quelle distribution de Linux (Ubuntu, Suse, Fedora, ...) ?

    Tu as l'air d'utiliser swt dans ton application, as-tu la bibliothèque swt pour linux dans ton projet ?
    A mon avis, il aurait été plus simple d'utiliser Swing, portable sans rien faire...
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  8. #8
    Membre éclairé Avatar de kkt8
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    472
    Détails du profil
    Informations personnelles :
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 472
    Par défaut
    en fait, je fais des plugins qui sont ajoutés à un eclipse surchargé par d'autres équipes et les bibliothèques dispo sont limitées en effet, mais j'ai SWT.

    Quel objet tu aurais utilisé en swing ?

  9. #9
    Membre éclairé Avatar de kkt8
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    472
    Détails du profil
    Informations personnelles :
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 472
    Par défaut
    JEditorPane par ex ?
    Mais du coup pour éviter de tout refaire j'ai une classe X extends Dialog :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
     
    protected Control createDialogArea(Composite parent) {
     
    	// brand the about box if there is product info
    	Image aboutImage = null;
    	if (product != null) {
    		ImageDescriptor imageDescriptor = ProductProperties.getAboutImage(product);
    		if (imageDescriptor != null) {
    		  aboutImage = imageDescriptor.createImage();
    		}
     
    		// create a composite which is the parent of the top area and the bottom
    		// button bar, this allows there to be a second child of this composite with 
    		// a banner background on top but not have on the bottom
    		Composite workArea = new Composite(parent, SWT.NONE);
    		GridLayout workLayout = new GridLayout();
    		workLayout.marginHeight = 0;
    		workLayout.marginWidth = 0;
    		workLayout.verticalSpacing = 0;
    		workLayout.horizontalSpacing = 0;
    		workArea.setLayout(workLayout);
    		workArea.setLayoutData(new GridData(GridData.FILL_BOTH));
     
    		// page group
    		Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    		Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    		Composite top = (Composite) super.createDialogArea(workArea);
     
    		// override any layout inherited from createDialogArea 
    		GridLayout layout = new GridLayout();
    		layout.marginHeight = 0;
    		layout.marginWidth = 0;
    		layout.verticalSpacing = 0;
    		layout.horizontalSpacing = 0;
    		top.setLayout(layout);
    		top.setLayoutData(new GridData(GridData.FILL_BOTH));
    		top.setBackground(background);
    		top.setForeground(foreground);
     
    		// the image & text	
    		Composite topContainer = new Composite(top, SWT.NONE);
    		topContainer.setBackground(background);
    		topContainer.setForeground(foreground);
     
    		layout = new GridLayout();
    		layout.numColumns = 2;
    		layout.marginWidth = 0;
    		layout.marginHeight = 0;
    		layout.verticalSpacing = 0;
    		layout.horizontalSpacing = 0;
    		topContainer.setLayout(layout);
    		GridData data = new GridData();
    		data.horizontalAlignment = GridData.FILL;
    		data.grabExcessHorizontalSpace = true;
    		topContainer.setLayoutData(data);
     
    		//image on left side of dialog
    		if (aboutImage != null) {
    		    Label imageLabel = new Label(topContainer, SWT.NONE);
    		    imageLabel.setBackground(background);
    		    imageLabel.setForeground(foreground);
     
    		    data = new GridData();
    		    data.horizontalAlignment = GridData.FILL;
    		    data.verticalAlignment = GridData.BEGINNING;
    		    data.grabExcessHorizontalSpace = false;
    		    imageLabel.setLayoutData(data);
    		    imageLabel.setImage(aboutImage);
    		}
     
    //	if (getItem() != null) {
    		// there is no margins around the image, so insert an extra composite 
    		// here to provide some margins for the text.
    		Composite textContainer = new Composite(topContainer, SWT.NONE);
    		textContainer.setBackground(background);
    		textContainer.setForeground(foreground);
     
    		layout = new GridLayout();
    		layout.numColumns = 1;
    		textContainer.setLayout(layout);
    		data = new GridData();
    		data.horizontalAlignment = GridData.FILL;
    		data.verticalAlignment = GridData.BEGINNING;
    		data.grabExcessHorizontalSpace = true;
    		textContainer.setLayoutData(data);
     
     
    		// text on the right
    		text = new StyledText(textContainer, SWT.MULTI | SWT.READ_ONLY);
    		text.setCaret(null);
    		text.setFont(parent.getFont());
    		data = new GridData();
    		data.horizontalAlignment = GridData.FILL;
    		data.verticalAlignment = GridData.BEGINNING;
    		data.grabExcessHorizontalSpace = true;
    		//data.heightHint = 147;
    		text.setText(item);
    		text.setLayoutData(data);
    		text.setCursor(null);
    		text.setBackground(background);
    		text.setForeground(foreground);
     
     
    		// horizontal bar
    		Label bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR);
    		data = new GridData();
    		data.horizontalAlignment = GridData.FILL;
    		bar.setLayoutData(data);
     
    		// add image buttons for bundle groups that have them
    		Composite bottom = (Composite) super.createDialogArea(workArea);
    		// override any layout inherited from createDialogArea 
    		layout = new GridLayout();
    		bottom.setLayout(layout);
    		bottom.setLayoutData(new GridData(GridData.FILL_BOTH));
     
    		final Browser browser;
    		browser = new Browser(bottom, SWT.BORDER);
    		data = new GridData();
    		data.horizontalAlignment = GridData.FILL;
    		data.verticalAlignment = GridData.BEGINNING;
    		data.grabExcessHorizontalSpace = true;
    		data.heightHint = 250;
    		data.widthHint = 200;
    		browser.setLayoutData(data);
     
    		browser.setUrl("file:///" + fAboutHtml.getPath());
    		// spacer
    	    bar = new Label(bottom, SWT.NONE);
    	    data = new GridData();
    	    data.horizontalAlignment = GridData.FILL;
    	    bar.setLayoutData(data);
     
    	    return workArea;
    	}
    est-ce que je peux remplacer mon browser SWT simplement par un JEditorPane ?

  10. #10
    Expert confirmé
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Par défaut
    Le JEditorPane a un support plus que merdique du HTML et des CSS, a moins de te limiter à du HTML 3...

    En fait pour le composant Browser, SWT s'appuie sur le moteur d'un navigateur existant sous l'OS sur lequel l'application tourne. Sous Windows ce sera IE ou firefox (via XulRunner), sous linux seul Firefox est disponible, sous mac je ne me souviens plus bien.

    Donc il faut absolument que XulRunner soit installé sous linux pour que le browser fonctionne.

    Quelle distribution de linux utilises tu (Ubuntu, OpenSuse, Fedora, Mandriva, Debian, autre?)

  11. #11
    Membre éclairé Avatar de kkt8
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    472
    Détails du profil
    Informations personnelles :
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 472
    Par défaut
    Quelle distribution de linux utilises tu (Ubuntu, OpenSuse, Fedora, Mandriva, Debian, autre?)
    => je sais même pas te répondre : RH4 c'est tout ce que je sais, ça répond à ta question ?

    De toute façon c'est mort, je ne peux pas dépendre d'un truc à installer, je ne peux livrer aux clients finaux que des plugins donc je reformate dans une zone de texte ! tant pis le rendu était sympa en html ...

    Merci de tes réponses en tout cas !

  12. #12
    Membre Expert
    Avatar de Gueritarish
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mai 2007
    Messages
    1 800
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2007
    Messages : 1 800
    Par défaut
    Salut,

    A priori, il faut juste que tu changes l'endroit où pointe MOZILLA_FIVE_HOME. Plutôt que de le faire pointer sur /usr/lib/mozilla, il te faudrait essayer de le faire pointer sur /usr/lib/mozilla/lib/firefoxXXX (XXX étant la version de FF).

    Voilà, à+
    Gueritarish

  13. #13
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Billets dans le blog
    1
    Par défaut
    Tu pourrais regarder ceci avant de tout jeter...
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  14. #14
    Membre éclairé Avatar de kkt8
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    472
    Détails du profil
    Informations personnelles :
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 472
    Par défaut
    Citation Envoyé par Gueritarish Voir le message
    Salut,

    A priori, il faut juste que tu changes l'endroit où pointe MOZILLA_FIVE_HOME. Plutôt que de le faire pointer sur /usr/lib/mozilla, il te faudrait essayer de le faire pointer sur /usr/lib/mozilla/lib/firefoxXXX (XXX étant la version de FF).

    Voilà, à+
    Gueritarish
    nan pas mieux, même message d'erreur que précédemment !

  15. #15
    Membre éclairé Avatar de kkt8
    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    472
    Détails du profil
    Informations personnelles :
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2005
    Messages : 472
    Par défaut
    Citation Envoyé par OButterlin Voir le message
    Tu pourrais regarder ceci avant de tout jeter...
    je jette un oeil dessus merci !
    mais je ne jette pas tout ... je garde le browser sous windows

Discussions similaires

  1. question relative à l'utilisation de msn sous linux
    Par biba13 dans le forum Applications et environnements graphiques
    Réponses: 4
    Dernier message: 20/08/2008, 20h26
  2. Réponses: 4
    Dernier message: 06/11/2007, 20h57
  3. Ne pas utiliser le Terminal sous linux
    Par Titeuf01-87 dans le forum Ubuntu
    Réponses: 9
    Dernier message: 27/10/2007, 12h54
  4. Comment bloquer l'utilisation d'Emule sous linux debian
    Par jojodeparis dans le forum Réseau
    Réponses: 2
    Dernier message: 25/10/2006, 10h31
  5. Utilisation des partitions sous linux
    Par alfa88 dans le forum Administration système
    Réponses: 19
    Dernier message: 18/05/2006, 22h28

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo