Byte-Welt Forum

Zurück   Byte-Welt Forum > Projekte > DockingFrames

DockingFrames DockingFrames An extension of Swing, used to flexibly arrange windows. - Ist eine Erweiterung von Swing, mit der flexibel Panels angeordnet werden können.

Antwort
 
Themen-Optionen Thema durchsuchen
Alt 02.02.2009, 10:09   #1
CptBlood starter
 
Benutzerbild von CptBlood
 
Registriert seit: 19.11.2008
Beiträge: 15
CptBlood befindet sich auf einem aufstrebenden Ast
Standard Perspective Eclipse like

Hello,

Is there a way to manage perspective like in Eclipse.
I need two ContentArea displayed in a tabbed pane for switching between it.

Thanks for advance.
CptBlood ist offline   Mit Zitat antworten
Alt 08.02.2009, 18:41   #2
Beni
Moderator
 
Benutzerbild von Beni
 
Registriert seit: 27.08.2006
Beiträge: 571
Beni befindet sich auf einem aufstrebenden Ast
Beni eine Nachricht über Skype™ schicken
Standard AW: Perspective Eclipse like

I'm not sure if I understood you correctly, but I think this can be solved with the layout-mechanism. More precisly, with the method "CControl.save( String )" and "CControl.load( String )".

For a perspecive "x":
1. You would first need to setup the perspective.
2. Then call save( x ).
3. If the user wants perspecive x you'd call "load( x )".

If you store the layout in a file, then the perspectives would be stored as well.
__________________
Beni ist offline   Mit Zitat antworten
Alt 09.02.2009, 08:12   #3
CptBlood starter
 
Benutzerbild von CptBlood
 
Registriert seit: 19.11.2008
Beiträge: 15
CptBlood befindet sich auf einem aufstrebenden Ast
Standard Re: Perspective Eclipse like

Hello,

Ha, Beni comme back !

I speak about perspective like in eclipse, cf picture.
In fact I need to made the same things, with an invert tab (tab round shape to the left instead of right).

Thanks.
Miniaturansicht angehängter Grafiken
Klicken Sie auf die Grafik für eine größere Ansicht

Name:	Perspective.jpg
Hits:	92
Größe:	67,5 KB
ID:	89  

Geändert von CptBlood (09.02.2009 um 10:28 Uhr).
CptBlood ist offline   Mit Zitat antworten
Alt 09.02.2009, 18:34   #4
Beni
Moderator
 
Benutzerbild von Beni
 
Registriert seit: 27.08.2006
Beiträge: 571
Beni befindet sich auf einem aufstrebenden Ast
Beni eine Nachricht über Skype™ schicken
Standard AW: Perspective Eclipse like

I wrote a little application which behaves similar to the Eclipse-perspectives.

Some things I'd like to add:
* To build the initial setup of the perspectives you need real Dockable objects.
* The current layout of a perspective gets stored when another perspective is selected.
* Perspectives are stored in a file
* Given some more buttons the user could easily add his/her own perspectives. If you are interested in that feature: also have a look at CControl.delete and CControl.layouts.
* Everything that is on a working-area is not affected by a change of the perspective. Dockables that belong to a working-area but are minimized, maximized or externalized are put back on their working-area when the perspective changes.

And:
* The ShapedGradientPainter paints these curves that are in Ecilpse. It can't paint the inverse curve, but you could adapt the code...

Java Code:
  1. package dock;
  2.  
  3. import java.awt.GridLayout;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6. import java.awt.event.WindowAdapter;
  7. import java.awt.event.WindowEvent;
  8. import java.io.File;
  9. import java.io.IOException;
  10.  
  11. import javax.swing.JButton;
  12. import javax.swing.JFrame;
  13. import javax.swing.JPanel;
  14.  
  15. import bibliothek.gui.dock.common.CControl;
  16. import bibliothek.gui.dock.common.CLocation;
  17. import bibliothek.gui.dock.common.CWorkingArea;
  18. import bibliothek.gui.dock.common.DefaultMultipleCDockable;
  19. import bibliothek.gui.dock.common.DefaultSingleCDockable;
  20. import bibliothek.gui.dock.common.EmptyMultipleCDockableFactory;
  21. import bibliothek.gui.dock.common.MultipleCDockable;
  22. import bibliothek.gui.dock.common.MultipleCDockableFactory;
  23. import bibliothek.gui.dock.common.MultipleCDockableLayout;
  24. import bibliothek.gui.dock.common.SingleCDockable;
  25. import bibliothek.gui.dock.common.CContentArea.Corner;
  26. import bibliothek.gui.dock.common.intern.CDockable;
  27.  
  28. public class Dock8 extends JFrame{
  29.     public static void main( String[] args ){
  30.         Dock8 dock = new Dock8();
  31.         dock.setBounds( 20, 20, 400, 400 );
  32.         dock.setVisible( true );
  33.     }
  34.    
  35.     private CDockable history;
  36.     private CDockable outline;
  37.     private CDockable fileA;
  38.     private CDockable fileB;
  39.    
  40.     private CWorkingArea area;
  41.    
  42.     private CControl control;
  43.    
  44.     private String perspective = null;
  45.    
  46.     private MultipleCDockableFactory<MultipleCDockable, MultipleCDockableLayout> factory =
  47.         new EmptyMultipleCDockableFactory<MultipleCDockable>(){
  48.         @Override
  49.         public MultipleCDockable createDockable(){
  50.             return new DefaultMultipleCDockable( this, "File" );
  51.         }
  52.     };
  53.    
  54.     public Dock8(){
  55.         setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
  56.         addWindowListener( new WindowAdapter(){
  57.             @Override
  58.             public void windowClosing( WindowEvent e ){
  59.                 try{
  60.                     control.writeXML( new File( "layout.xml" ) );
  61.                 }
  62.                 catch( IOException e1 ){
  63.                     e1.printStackTrace();
  64.                 }
  65.                 dispose();
  66.             }
  67.         });
  68.        
  69.         control = new CControl( this );
  70.        
  71.         // lazy loading, need to add the content area first!
  72.         add( control.getContentArea() );
  73.        
  74.         control.addMultipleDockableFactory( "files", factory );
  75.        
  76.         area = control.createWorkingArea( "area" );
  77.        
  78.         history = createSingle( "Histroy" );
  79.         outline = createSingle( "Outline" );
  80.        
  81.         fileA = createFile();
  82.         fileB = createFile();
  83.        
  84.         try{
  85.             control.readXML( new File( "layout.xml" ) );
  86.         }
  87.         catch( IOException e ){
  88.             // well, then create a default-layout
  89.             buildDebug();
  90.             buildJava();
  91.            
  92.             // The position of children of a Working-Area is not stored in perspectives,
  93.             // make sure they are visible.
  94.             fileA.setLocation( CLocation.working( area ) );
  95.             fileA.setVisible( true );
  96.            
  97.             fileB.setLocation( CLocation.working( area ).south( 0.4 ) );
  98.             fileB.setVisible( true );
  99.            
  100.             control.load( "Java" );
  101.         }
  102.                
  103.         JPanel buttons = new JPanel( new GridLayout( 1, 2 ));
  104.         buttons.add( createPerspectiveButton( "Java" ) );
  105.         buttons.add( createPerspectiveButton( "Debug" ) );
  106.        
  107.         add( control.getContentArea() );
  108.         control.getContentArea().setCornerComponent( buttons, Corner.NORTH_EAST, true );
  109.     }
  110.    
  111.     private void buildDebug(){
  112.         area.setLocation( CLocation.base().normal() );
  113.         area.setVisible( true );
  114.        
  115.         fileA.setLocation( CLocation.working( area ) );
  116.         fileA.setVisible( true );
  117.        
  118.         fileB.setLocation( CLocation.working( area ).stack( 1 ) );
  119.         fileB.setVisible( true );
  120.        
  121.         outline.setLocation( CLocation.base().normalEast( 0.25 ) );
  122.         outline.setVisible( true );
  123.        
  124.         history.setLocation( CLocation.base().normalSouth( 0.25 ) );
  125.         history.setVisible( true );
  126.        
  127.         control.save( "Debug" );
  128.        
  129.         fileA.setVisible( false );
  130.         fileB.setVisible( false );
  131.        
  132.         // BUG: causes an error >:-/
  133.         // area.setVisible( false );
  134.         outline.setVisible( false );
  135.         history.setVisible( false );
  136.     }
  137.    
  138.     private void buildJava(){
  139.         area.setLocation( CLocation.base().normal() );
  140.         area.setVisible( true );
  141.        
  142.         fileA.setLocation( CLocation.working( area ) );
  143.         fileA.setVisible( true );
  144.        
  145.         fileB.setLocation( CLocation.working( area ).south( 0.5 ) );
  146.         fileB.setVisible( true );
  147.        
  148.         outline.setLocation( CLocation.base().normalWest( 0.25 ) );
  149.         outline.setVisible( true );
  150.        
  151.         history.setLocation( CLocation.base().normalWest( 0.25 ).stack() );
  152.         history.setVisible( true );
  153.        
  154.         control.save( "Java" );
  155.        
  156.         fileA.setVisible( false );
  157.         fileB.setVisible( false );
  158.         outline.setVisible( false );
  159.         history.setVisible( false );
  160.     }
  161.    
  162.     private CDockable createSingle( String title ){
  163.         SingleCDockable dockable = new DefaultSingleCDockable( title, title );
  164.         control.add( dockable );
  165.         return dockable;
  166.     }
  167.    
  168.     private CDockable createFile(){
  169.         DefaultMultipleCDockable dockable = new DefaultMultipleCDockable( factory, "File" );
  170.         dockable.setRemoveOnClose( false );
  171.         area.add( dockable );
  172.         return dockable;
  173.     }
  174.    
  175.     private JButton createPerspectiveButton( final String name ){
  176.         JButton button = new JButton( name );
  177.         button.addActionListener( new ActionListener(){
  178.             @Override
  179.             public void actionPerformed( ActionEvent e ){
  180.                 if( perspective != null ){
  181.                     control.save( perspective );
  182.                 }
  183.                 perspective = name;
  184.                 control.load( name );
  185.             }
  186.         });
  187.         return button;
  188.     }
  189. }
__________________
Beni ist offline   Mit Zitat antworten
Alt 10.02.2009, 08:10   #5
CptBlood starter
 
Benutzerbild von CptBlood
 
Registriert seit: 19.11.2008
Beiträge: 15
CptBlood befindet sich auf einem aufstrebenden Ast
Standard Re: Perspective Eclipse like

Who is the Best ?
Thanks Beni !
That's exactly what i want to do.
I just need to make a shape to group the two perspective buttons like in eclipse.
What exactly do the control.save() function ? A file is create physically or only in memory ?
the Debug perspective doesn't keep the state of dockables in it when you come-back from an other perspective as the java perspective. Is it intentionnal ?

Thanks a lot.
With that i'm sure that we use your framework for our project.
The first delivery if for april. Let's go !

Geändert von CptBlood (10.02.2009 um 09:19 Uhr).
CptBlood ist offline   Mit Zitat antworten
Alt 10.02.2009, 15:43   #6
Beni@work
Gast
 
Beiträge: n/a
Standard AW: Perspective Eclipse like

save() stores the layout in memory. The current Dockables are transformed into an intermediate format. If the application stops then this intermediate format gets written into the "layout.xml".

I'll check the other thing with the Debug-Perspective once I'm at home. It should work (if my memory is not totally screwed up...), you are sure you are looking at the history, outline and working-area? The fileA and fileB are intentionally normalized and their location on the working-area does not change. That's because children of a working-area often represent things (like files) that might not be available the next time when the perspective is loaded, hence they are ignored.
  Mit Zitat antworten
Alt 10.02.2009, 18:08   #7
Beni
Moderator
 
Benutzerbild von Beni
 
Registriert seit: 27.08.2006
Beiträge: 571
Beni befindet sich auf einem aufstrebenden Ast
Beni eine Nachricht über Skype™ schicken
Standard Re: Perspective Eclipse like

I can't reproduce the error with the Debug-perspective, maybe we are not talking about the same problem...
__________________
Beni ist offline   Mit Zitat antworten
Alt 11.02.2009, 12:48   #8
CptBlood starter
 
Benutzerbild von CptBlood
 
Registriert seit: 19.11.2008
Beiträge: 15
CptBlood befindet sich auf einem aufstrebenden Ast
Standard Re: Perspective Eclipse like

Oups, I think i'm tired or perhaps at the first launch...
It's work now.
Forget.

Thanks
CptBlood ist offline   Mit Zitat antworten
Alt 15.06.2010, 19:14   #9
ExPörT
Gast
 
Beiträge: n/a
Standard AW: Perspective Eclipse like

Hello,

I copied the sourcecode and tried to compile it. But at compile time i get the following error:

Java Code:
  1. Exception in thread "main" java.lang.IllegalArgumentException: delta too big
  2.     at bibliothek.gui.dock.station.support.PlaceholderList$Entry.move(Unknown Source)
  3.     at bibliothek.gui.dock.station.support.PlaceholderList$SubList.move(Unknown Source)
  4.     at bibliothek.gui.dock.StackDockStation.move(Unknown Source)
  5.     at bibliothek.gui.dock.StackDockStation.move(Unknown Source)
  6.     at bibliothek.gui.dock.SplitDockStation.dropOver(Unknown Source)
  7.     at bibliothek.gui.dock.SplitDockStation.drop(Unknown Source)
  8.     at bibliothek.gui.dock.SplitDockStation.access$900(Unknown Source)
  9.     at bibliothek.gui.dock.SplitDockStation$6.drop(Unknown Source)
  10.     at bibliothek.gui.dock.station.split.Leaf.insert(Unknown Source)
  11.     at bibliothek.gui.dock.station.split.Node.insert(Unknown Source)
  12.     at bibliothek.gui.dock.station.split.Node.insert(Unknown Source)
  13.     at bibliothek.gui.dock.station.split.Node.insert(Unknown Source)
  14.     at bibliothek.gui.dock.station.split.Root.insert(Unknown Source)
  15.     at bibliothek.gui.dock.SplitDockStation.drop(Unknown Source)
  16.     at bibliothek.gui.dock.SplitDockStation.drop(Unknown Source)
  17.     at bibliothek.gui.dock.common.mode.station.CSplitDockStationHandle$Normal.setLocation(Unknown Source)
  18.     at bibliothek.gui.dock.facile.mode.DefaultLocationMode.runApply(Unknown Source)
  19.     at bibliothek.gui.dock.facile.mode.AbstractLocationMode.apply(Unknown Source)
  20.     at bibliothek.gui.dock.facile.mode.AbstractLocationMode.apply(Unknown Source)
  21.     at bibliothek.gui.dock.support.mode.ModeManager$3.run(Unknown Source)
  22.     at bibliothek.gui.dock.support.mode.ModeManager.runTransaction(Unknown Source)
  23.     at bibliothek.gui.dock.support.mode.ModeManager.runTransaction(Unknown Source)
  24.     at bibliothek.gui.dock.support.mode.ModeManager.apply(Unknown Source)
  25.     at bibliothek.gui.dock.support.mode.ModeManager.apply(Unknown Source)
  26.     at bibliothek.gui.dock.support.mode.ModeManager.apply(Unknown Source)
  27.     at bibliothek.gui.dock.common.mode.CLocationModeManager.setLocation(Unknown Source)
  28.     at bibliothek.gui.dock.common.CControl$Access.show(Unknown Source)
  29.     at bibliothek.gui.dock.common.intern.AbstractCDockable.setVisible(Unknown Source)
  30.     at dock.Dock8.buildJava(Dock8.java:152)
  31.     at dock.Dock8.<init>(Dock8.java:90)
  32.     at dock.Dock8.main(Dock8.java:30)

what does it mean?

greetings
ExPörT
  Mit Zitat antworten
Alt 16.06.2010, 07:37   #10
Beni
Moderator
 
Benutzerbild von Beni
 
Registriert seit: 27.08.2006
Beiträge: 571
Beni befindet sich auf einem aufstrebenden Ast
Beni eine Nachricht über Skype™ schicken
Standard AW: Perspective Eclipse like

I'll have to let the program run, but it looks like a bug in the framework.
__________________
Beni ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Stichworte
-


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche

Forumregeln
Es ist Ihnen erlaubt, neue Themen zu verfassen.
Es ist Ihnen erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Eclipse Plugins - Auflistung EagleEye IDEs & Tools 5 10.02.2009 14:24
Regions in Eclipse EagleEye IDEs & Tools 6 20.10.2008 13:34
Qt in Eclipse integriert EagleEye Software 0 25.09.2007 12:37
.NET-PlugIn für Eclipse christoph IDE & Tools 3 27.03.2007 21:12


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:13 Uhr.


Powered by vBulletin® Version 3.8.2 (Deutsch)
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.