956 ^ v |
956 ^ v |
957 |
957 |
958 ! |
958 ! |
959 |
959 |
960 saveScreenImage:anImage defaultName:defaultName |
960 saveScreenImage:anImage defaultName:defaultName |
961 "save an image into a file |
961 "ask user for filename, then save an image into a file" |
962 - ask user for filename using a fileSelectionBox." |
962 |
963 |
963 Dialog |
964 |fileName| |
964 imageSaveDialog:(resources string:'Save hardcopy image in:') |
965 |
965 image:anImage |
966 fileName := Dialog |
966 default:(defaultName , '.png') |
967 requestFileName:(resources string:'Save hardcopy image in:') |
967 pattern:'*.png;*.tiff;*.bmp;*.gif' |
968 default:(defaultName , '.png') |
968 |
969 ok:(resources string:'Save') |
969 "/ |fileName| |
970 abort:(resources string:'Cancel') |
970 "/ |
971 pattern:'*.png;*.tiff;*.bmp' |
971 "/ fileName := Dialog |
972 fromDirectory:nil |
972 "/ requestFileName:(resources string:'Save hardcopy image in:') |
973 forSave:true |
973 "/ default:(defaultName , '.png') |
974 whenBoxCreatedEvaluate:[:box | |
974 "/ ok:(resources string:'Save') |
975 |editButton paintButton copyButton| |
975 "/ abort:(resources string:'Cancel') |
976 "/ UserPreferences current useNewFileDialog ifFalse:[ |
976 "/ pattern:'*.png;*.tiff;*.bmp' |
977 editButton := Button label:(resources string:'Edit'). |
977 "/ fromDirectory:nil |
978 editButton |
978 "/ forSave:true |
979 action:[ |
979 "/ whenBoxCreatedEvaluate:[:box | |
980 box hide; destroy. |
980 "/ |editButton paintButton copyButton| |
981 ImageEditor openOnImage:anImage. |
981 "/ "/ UserPreferences current useNewFileDialog ifFalse:[ |
982 ]. |
982 "/ editButton := Button label:(resources string:'Edit'). |
983 box addButton:editButton. |
983 "/ editButton |
984 |
984 "/ action:[ |
985 paintButton := Button label:(resources string:'OS Editor'). |
985 "/ box hide; destroy. |
986 paintButton |
986 "/ ImageEditor openOnImage:anImage. |
987 action:[ |
987 "/ ]. |
988 |tempStream| |
988 "/ box addButton:editButton. |
989 |
989 "/ |
990 tempStream := FileStream newTemporaryWithSuffix:'png'. |
990 "/ paintButton := Button label:(resources string:'OS Editor'). |
991 box hide; destroy. |
991 "/ paintButton |
992 PNGReader save:anImage onStream:tempStream. |
992 "/ action:[ |
993 tempStream close. |
993 "/ |tempStream| |
994 OperatingSystem |
994 "/ |
995 openApplicationForDocument:tempStream fileName operation:#edit mimeType:'image/png'. |
995 "/ tempStream := FileStream newTemporaryWithSuffix:'png'. |
996 ]. |
996 "/ box hide; destroy. |
997 box addButton:paintButton. |
997 "/ PNGReader save:anImage onStream:tempStream. |
998 |
998 "/ tempStream close. |
999 copyButton := Button label:(resources string:'Copy to Clipboard'). |
999 "/ OperatingSystem |
1000 copyButton |
1000 "/ openApplicationForDocument:tempStream fileName operation:#edit mimeType:'image/png'. |
1001 action:[ |
1001 "/ ]. |
1002 self window setClipboardObject:anImage. |
1002 "/ box addButton:paintButton. |
1003 box hide; destroy. |
1003 "/ |
1004 ]. |
1004 "/ copyButton := Button label:(resources string:'Copy to Clipboard'). |
1005 box addButton:copyButton. |
1005 "/ copyButton |
1006 "/ ] |
1006 "/ action:[ |
1007 ]. |
1007 "/ self window setClipboardObject:anImage. |
1008 fileName notNil ifTrue:[ |
1008 "/ box hide; destroy. |
1009 anImage saveOn:fileName. |
1009 "/ ]. |
1010 ImageEditView lastSaveDirectory:fileName asFilename directory pathName. |
1010 "/ box addButton:copyButton. |
1011 ]. |
1011 "/ "/ ] |
|
1012 "/ ]. |
|
1013 "/ |
|
1014 "/ fileName notEmptyOrNil ifTrue:[ |
|
1015 "/ anImage saveOn:fileName. |
|
1016 "/ ImageEditView lastSaveDirectory:fileName asFilename directory pathName. |
|
1017 "/ ]. |
1012 |
1018 |
1013 "Created: / 29-01-1998 / 23:20:36 / cg" |
1019 "Created: / 29-01-1998 / 23:20:36 / cg" |
1014 "Modified: / 08-02-2011 / 21:51:11 / cg" |
1020 "Modified: / 08-02-2011 / 21:51:11 / cg" |
1015 ! |
1021 ! |
1016 |
1022 |
7678 ] on:PackageLoadError do:[:ex | |
7684 ] on:PackageLoadError do:[:ex | |
7679 |path| |
7685 |path| |
7680 |
7686 |
7681 path := pathByItem at:someItem ifAbsent:nil. |
7687 path := pathByItem at:someItem ifAbsent:nil. |
7682 path isNil ifTrue:[ |
7688 path isNil ifTrue:[ |
7683 (Dialog information:'package ID inconsistency - cannot load...'). |
7689 Dialog information:('package load failed: %1' bindWith:ex description). |
7684 ] ifFalse:[ |
7690 ] ifFalse:[ |
7685 "/ try to load the file as is (i.e. not via package-id |
7691 "/ try to load the file as is (i.e. not via package-id |
7686 (Dialog information:'package ID inconsistency - loading file directly...'). |
7692 Dialog information:('package load failed: %1\\Loading file directly...' bindWith:ex description). |
7687 Smalltalk fileIn:(packageDirPath asFilename / path). |
7693 Smalltalk fileIn:(packageDirPath asFilename / path). |
7688 ]. |
7694 ]. |
7689 ] |
7695 ] |
7690 ] ensure:[ |
7696 ] ensure:[ |
7691 Smalltalk retractInterestsFor:updateAction. |
7697 Smalltalk retractInterestsFor:updateAction. |
7751 dir notNil ifTrue:[ |
7758 dir notNil ifTrue:[ |
7752 "/ is there a project definition class's source? |
7759 "/ is there a project definition class's source? |
7753 className := ProjectDefinition projectDefinitionClassNameForDefinitionOf:package. |
7760 className := ProjectDefinition projectDefinitionClassNameForDefinitionOf:package. |
7754 fileName := dir / ((Smalltalk fileNameForClass:className),'.st'). |
7761 fileName := dir / ((Smalltalk fileNameForClass:className),'.st'). |
7755 fileName exists ifTrue:[ |
7762 fileName exists ifTrue:[ |
7756 Smalltalk fileIn:fileName. |
7763 ParseError handle:[:ex | |
|
7764 Dialog warn:(resources string:'An error happened while loading the project definition:\ %1\\Maybe the project depends on some other package.\Please check this manually.' with:ex description) |
|
7765 ] do:[ |
|
7766 Smalltalk fileIn:fileName. |
|
7767 ]. |
7757 ] ifFalse:[ |
7768 ] ifFalse:[ |
7758 Dialog warn:(resources string:'Project definition class file not present: "%1"' with:fileName) |
7769 Dialog warn:(resources string:'Project definition class file not present: "%1"' with:fileName) |
7759 ] |
7770 ] |
7760 ] ifFalse:[ |
7771 ] ifFalse:[ |
7761 Dialog warn:(resources string:'Directory not present/readable: "%1"' with:dir) |
7772 Dialog warn:(resources string:'Project directory for "%1" is not present/readable' with:package). |
|
7773 ^ self. |
7762 ] |
7774 ] |
7763 ] ensure:[ |
7775 ] ensure:[ |
7764 Smalltalk retractInterestsFor:updateAction. |
7776 Smalltalk retractInterestsFor:updateAction. |
7765 ]. |
7777 ]. |
7766 ]. |
7778 ]. |
7767 ((defClass := package asPackageId projectDefinitionClass) notNil |
7779 ((defClass := package asPackageId projectDefinitionClass) notNil and:[ defClass isLoaded ]) |
7768 and:[ defClass isLoaded ]) |
|
7769 ifFalse:[ |
7780 ifFalse:[ |
7770 defClass isNil ifTrue:[ |
7781 defClass isNil ifTrue:[ |
7771 Dialog warn:(resources string:'Load failed: definition class for packageID (%1) not present after package load.' with:package) |
7782 Dialog warn:(resources string:'Load failed: definition class for packageID (%1) not present after package load.' with:package) |
7772 ] |
7783 ] |
7773 ] ifTrue:[ |
7784 ] ifTrue:[ |