Skip to content

Commit

Permalink
Works
Browse files Browse the repository at this point in the history
  • Loading branch information
goga authored and goga committed Jun 18, 2023
1 parent 6b755df commit bfe0086
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 71 deletions.
6 changes: 5 additions & 1 deletion com.hazard157.prisex24/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.toxsoft.core.tslib.coll.impl.*;
import org.toxsoft.core.tslib.utils.errors.*;

import com.hazard157.prisex24.glib.dialogs.*;
import com.hazard157.prisex24.glib.frasel.*;
import com.hazard157.prisex24.glib.frview.*;
import com.hazard157.prisex24.utils.*;
Expand Down Expand Up @@ -80,6 +81,7 @@ public SvinsFramesViewer( Composite aParent, ITsGuiContext aContext ) {
fgViewer = new FramesGridViewer( this, tsContext() );
fgViewer.getControl().setLayoutData( BorderLayout.CENTER );
// setup
toolbar.addListener( this );
toolbar.setActionMenu( ACTID_GIF_CREATE, new AbstractGifManagemntDropDownMenuCreator( tsContext(), this ) {

@Override
Expand All @@ -99,10 +101,12 @@ protected IFrame doGetFrame() {

@Override
public void handleAction( String aActionId ) {
// IFrame sel = selectedItem();
IFrame sel = selectedItem();
switch( aActionId ) {
case ACTID_ABOUT: {
TsDialogUtils.underDevelopment( getShell() );
case ACTID_WORK_WITH_FRAMES: {
if( sel != null ) {
DialogWorkWithFrames.open( tsContext(), sel );
}
break;
}
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.hazard157.prisex24.m5.frames;

import static com.hazard157.prisex24.m5.IPsxM5Constants.*;

import org.toxsoft.core.tsgui.bricks.ctx.*;
import org.toxsoft.core.tsgui.bricks.tstree.tmm.*;
import org.toxsoft.core.tsgui.graphics.*;
import org.toxsoft.core.tsgui.m5.*;
import org.toxsoft.core.tsgui.m5.gui.viewers.*;
import org.toxsoft.core.tsgui.m5.gui.viewers.impl.*;

import com.hazard157.psx.common.stuff.frame.*;

/**
* Left list of frames.
*
* @author hazard157
*/
class CommonFramesM5TreeViewer
extends M5TreeViewer<IFrame> {

private final ITreeModeManager<IFrame> treeModeManager;

public CommonFramesM5TreeViewer( ITsGuiContext aContext, IM5Model<IFrame> aObjModel ) {
super( aContext, aObjModel, false );
// treeModeManager
treeModeManager = new FrameCollectionPanelTmm( tsContext() ) {

@Override
protected void onCurrentModeIdChanged() {
TreeModeInfo<IFrame> info = null;
String mid = currModeId();
if( mid != null ) {
info = treeModeInfoes().findByKey( mid );
}
if( info != null ) {
setTreeMaker( info.treeMaker() );
}
else {
setTreeMaker( null );
}
repackColumns();
}

};
}

void repackColumns() {
IM5Column<IFrame> col;
col = columnManager().columns().getByKey( FID_FRAME_NO );
col.setWidth( 220 );
// isAnimated
col = columnManager().columns().getByKey( FID_IS_ANIMATED );
col.setAlignment( EHorAlignment.CENTER );
col.pack();
// camera ID
col = columnManager().columns().getByKey( FID_CAMERA_ID );
col.pack();
}

@Override
protected void doProcessAfterControlsCreated() {
IM5Column<IFrame> col;
// frameNo
col = columnManager().add( FID_FRAME_NO );
// isAnimated
col = columnManager().add( FID_IS_ANIMATED );
col.setAlignment( EHorAlignment.CENTER );
// camera ID
col = columnManager().add( FID_CAMERA_ID );
repackColumns();
}

// ------------------------------------------------------------------------------------
// API
//

public ITreeModeManager<IFrame> tmm() {
return treeModeManager;
}

}
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
package com.hazard157.prisex24.m5.frames;

import static com.hazard157.common.IHzConstants.*;
import static com.hazard157.prisex24.m5.IPsxM5Constants.*;
import static com.hazard157.prisex24.IPrisex24CoreConstants.*;
import static org.toxsoft.core.tsgui.bricks.actions.ITsStdActionDefs.*;

import java.io.*;

import org.eclipse.swt.*;
import org.eclipse.swt.custom.*;
import org.eclipse.swt.widgets.*;
import org.toxsoft.core.tsgui.bricks.actions.*;
import org.toxsoft.core.tsgui.bricks.ctx.*;
import org.toxsoft.core.tsgui.bricks.tstree.tmm.*;
import org.toxsoft.core.tsgui.bricks.uievents.*;
import org.toxsoft.core.tsgui.dialogs.*;
import org.toxsoft.core.tsgui.graphics.*;
import org.toxsoft.core.tsgui.graphics.icons.*;
import org.toxsoft.core.tsgui.graphics.image.*;
import org.toxsoft.core.tsgui.m5.*;
import org.toxsoft.core.tsgui.m5.gui.panels.*;
import org.toxsoft.core.tsgui.m5.gui.viewers.*;
import org.toxsoft.core.tsgui.m5.gui.viewers.impl.*;
import org.toxsoft.core.tsgui.m5.model.*;
import org.toxsoft.core.tsgui.panels.lazy.*;
import org.toxsoft.core.tsgui.panels.toolbar.*;
Expand All @@ -28,37 +26,31 @@
import org.toxsoft.core.tsgui.utils.rectfit.*;
import org.toxsoft.core.tsgui.widgets.*;
import org.toxsoft.core.tsgui.widgets.pdw.*;
import org.toxsoft.core.tslib.bricks.geometry.*;
import org.toxsoft.core.tslib.bricks.geometry.impl.*;
import org.toxsoft.core.tslib.coll.*;
import org.toxsoft.core.tslib.coll.helpers.*;
import org.toxsoft.core.tslib.utils.errors.*;

import com.hazard157.prisex24.*;
import com.hazard157.prisex24.utils.*;
import com.hazard157.psx.common.stuff.frame.*;

/**
* {@link IM5CollectionViewer} implementation for {@link FrameM5Model}.
* <p>
* TODO add ability to view non-sec frames
*
* @author hazard157
*/
class FrameCollectionPanel
extends AbstractTsStdEventsProducerLazyPanel<IFrame, Control>
implements IM5CollectionPanel<IFrame>, ITsActionHandler, IPsxGuiContextable {

// TODO tree mode management
private final IM5Model<IFrame> model;

// TODO create columns

// TODO selection -> image update

private final IM5Model<IFrame> model;
private final ITreeModeManager<IFrame> treeModeManager;

private final TsToolbar toolbar;
private final IM5TreeViewer<IFrame> framesTree;
private final IPdwWidget imageWidget;
private final TsToolbar toolbar;
private final CommonFramesM5TreeViewer framesTree;
private final IPdwWidget imageWidget;
private final NonsecFramesM5TreeViewer nonsecsList;

private IM5ItemsProvider<IFrame> itemsProvider = IM5ItemsProvider.EMPTY;
private IM5LifecycleManager<IFrame> lifecycleManager = null;
Expand Down Expand Up @@ -86,7 +78,7 @@ public FrameCollectionPanel( ITsGuiContext aContext, IM5Model<IFrame> aModel,
toolbar.setIconSize( EIconSize.IS_24X24 );
toolbar.setVertical( false );
toolbar.setActionDefs( //
// TODO GIF management menu, ACDEF_SEPARATOR, //
ACDEF_GIF_CREATE_MENU, //
// TODO AnumationKind menu, ACDEF_SEPARATOR, //
// TODO Shown cameras menu, ACDEF_SEPARATOR, //
ACDEF_VIEW_AS_TREE_MENU, ACDEF_VIEW_AS_LIST, ACDEF_SEPARATOR, //
Expand All @@ -97,31 +89,15 @@ public FrameCollectionPanel( ITsGuiContext aContext, IM5Model<IFrame> aModel,
);
toolbar.addListener( this );
// framesTree
framesTree = new M5TreeViewer<>( tsContext(), model, false );
framesTree = new CommonFramesM5TreeViewer( tsContext(), model );
// imageWidget
imageWidget = new PdwWidgetSimple( tsContext() );
imageWidget.setFitInfo( RectFitInfo.BEST );
imageWidget.setPreferredSizeFixed( false );
imageWidget.setFulcrum( ETsFulcrum.CENTER );
imageWidget.setAreaPreferredSize( new TsPoint( 720, 576 ) );
// treeModeManager
treeModeManager = new FrameCollectionPanelTmm( tsContext() ) {

@Override
protected void onCurrentModeIdChanged() {
if( !isCurrentTreeMode() ) {
framesTree.setTreeMaker( null );
return;
}
TreeModeInfo<IFrame> info = treeModeInfoes().findByKey( currModeId() );
if( info == null ) {
framesTree.setTreeMaker( null );
return;
}
framesTree.setTreeMaker( info.treeMaker() );
}

};
// nonsecsList
nonsecsList = new NonsecFramesM5TreeViewer( tsContext(), model );
}

// ------------------------------------------------------------------------------------
Expand All @@ -142,15 +118,21 @@ private void updateActionsState() {
boolean isAnim = sel != null && sel.isDefined() && sel.isAnimated();
// enables
toolbar.setActionEnabled( ACTID_PLAY, isSel );
toolbar.setActionEnabled( ACTID_VIEW_AS_LIST, !treeModeManager.isCurrentTreeMode() );
toolbar.setActionEnabled( ACTID_VIEW_AS_LIST, !framesTree.tmm().isCurrentTreeMode() );
toolbar.setActionEnabled( ACTID_GO_PREV, !framesTree.items().isEmpty() && sel != framesTree.items().first() );
toolbar.setActionEnabled( ACTID_GO_NEXT, !framesTree.items().isEmpty() && sel != framesTree.items().last() );
// checks
toolbar.setActionChecked( ACTID_VIEW_AS_LIST, !treeModeManager.isCurrentTreeMode() );
toolbar.setActionChecked( ACTID_VIEW_AS_TREE, treeModeManager.isCurrentTreeMode() );
toolbar.setActionChecked( ACTID_VIEW_AS_LIST, !framesTree.tmm().isCurrentTreeMode() );
toolbar.setActionChecked( ACTID_VIEW_AS_TREE, framesTree.tmm().isCurrentTreeMode() );
}

private void whenFramesTreeSelectionChange( IFrame aSel ) {
nonsecsList.setBaseFrame( aSel );
selectionChangeEventHelper.fireTsSelectionEvent( aSel );
updateActionsState();
}

private void whenNonsecsSelectionChanged( IFrame aSel ) {
TsImage img = null;
if( aSel != null ) {
File file = cofsFrames().findFrameFile( aSel );
Expand All @@ -160,9 +142,16 @@ private void whenFramesTreeSelectionChange( IFrame aSel ) {
}
imageWidget.setTsImage( img );
imageWidget.redraw();
// TODO FrameCollectionPanel.whenFramesTreeSelectionChange()
selectionChangeEventHelper.fireTsSelectionEvent( aSel );
updateActionsState();
}

/**
* Returns the displayed frame which may be non-seconds aligned one.
*
* @return {@link IFrame} - displayed frame or <code>null</code>
*/
private IFrame getDisplayedFrame() {
// TODO FrameCollectionPanel.getSelectedFrame()
return selectedItem();
}

// ------------------------------------------------------------------------------------
Expand All @@ -171,28 +160,21 @@ private void whenFramesTreeSelectionChange( IFrame aSel ) {

@Override
public void handleAction( String aActionId ) {
IFrame sel = framesTree.selectedItem();
switch( aActionId ) {
case "": {
// TODO FrameCollectionPanel.handleAction()
break;
}
case ACTID_VIEW_AS_TREE: {
treeModeManager.setCurrentMode( treeModeManager.lastModeId() );
framesTree.tmm().setNextMode();
break;
}
case ACTID_VIEW_AS_LIST: {
treeModeManager.setCurrentMode( null );
framesTree.tmm().setCurrentMode( null );
break;
}
case ACTID_GO_PREV: {
IFrame frame = ETsCollMove.PREV.findElemAt( sel, framesTree.items(), 10, false );
setSelectedItem( frame );
nonsecsList.moveSelection( ETsCollMove.PREV );
break;
}
case ACTID_GO_NEXT: {
IFrame frame = ETsCollMove.NEXT.findElemAt( sel, framesTree.items(), 10, false );
setSelectedItem( frame );
nonsecsList.moveSelection( ETsCollMove.NEXT );
break;
}
case ACTID_COLLAPSE_ALL: {
Expand All @@ -203,6 +185,10 @@ public void handleAction( String aActionId ) {
framesTree.console().expandAll();
break;
}
// TODO implement actions
case ACTID_GIF_CREATE:
case ACTID_GIF_RECREATE_ALL:
case ACTID_GIF_REMOVE:
default:
TsDialogUtils.warn( getShell(), aActionId );
}
Expand Down Expand Up @@ -231,19 +217,42 @@ protected Control doCreateControl( Composite aParent ) {
// toolbar
toolbar.createControl( board );
toolbar.getControl().setLayoutData( BorderLayout.NORTH );
toolbar.setActionMenu( ACTID_VIEW_AS_TREE, new TreeModeDropDownMenuCreator<>( tsContext(), treeModeManager ) );
// sfMain: framesTree, imageWidget
SashForm sfMain = new SashForm( board, SWT.HORIZONTAL );
sfMain.setLayoutData( BorderLayout.CENTER );
framesTree.createControl( sfMain );
IM5Column<IFrame> col = framesTree.columnManager().add( FID_FRAME_NO );
col.setWidth( 150 );
framesTree.columnManager().add( FID_IS_ANIMATED );
framesTree.columnManager().add( FID_CAMERA_ID );
framesTree.setTreeMaker( null );
imageWidget.createControl( sfMain );
toolbar.setActionMenu( ACTID_VIEW_AS_TREE, new TreeModeDropDownMenuCreator<>( tsContext(), framesTree.tmm() ) );
// mainBoard
TsComposite mainBoard = new TsComposite( board );
mainBoard.setLayoutData( BorderLayout.CENTER );
mainBoard.setLayout( new BorderLayout() );
// frameTree
framesTree.createControl( mainBoard );
framesTree.getControl().setLayoutData( BorderLayout.WEST );
// imageWidget
imageWidget.createControl( mainBoard );
imageWidget.getControl().setLayoutData( BorderLayout.CENTER );
// nonsecsList
nonsecsList.createControl( mainBoard );
nonsecsList.getControl().setLayoutData( BorderLayout.EAST );
nonsecsList.addTsSelectionListener( ( src, sel ) -> whenNonsecsSelectionChanged( sel ) );
// setup
sfMain.setWeights( 4000, 6000 );
toolbar.setActionMenu( ACTID_GIF_CREATE, new AbstractGifManagemntDropDownMenuCreator( tsContext(), this ) {

@Override
protected IFrame doGetFrame() {
return getDisplayedFrame();
}
} );
imageWidget.addTsUserInputListener( new ITsUserInputListener() {

@Override
public boolean onMouseWheel( Object aSource, int aState, ITsPoint aCoors, Control aWidget, int aScrollLines ) {
if( aScrollLines < 0 ) {
nonsecsList.moveSelection( ETsCollMove.NEXT );
}
if( aScrollLines > 0 ) {
nonsecsList.moveSelection( ETsCollMove.PREV );
}
return true;
}
} );
framesTree.addTsSelectionListener( ( src, sel ) -> whenFramesTreeSelectionChange( sel ) );
return board;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public boolean isItemNode( ITsNode aNode ) {

private final ITsGuiContext tsContext;

public FrameCollectionPanelTmm( ITsGuiContext aContext ) {
FrameCollectionPanelTmm( ITsGuiContext aContext ) {
super( true );
tsContext = aContext;
addTreeMode( new TreeModeInfo<>( TMID_BY_MINUTS, STR_TM_BY_MINUTES, STR_TM_BY_MINUTES_D, null, tmByMinutes ) );
Expand Down
Loading

0 comments on commit bfe0086

Please sign in to comment.