Save in a class?

Hello all,
we are developing a plug-in for an additional feature (collapsing and expanding graphical elements in a graphical editor).
The user select some elements, click on the collapse button and these elements are deleted. A new node with a label "collapsed" is drawn instead of them in order to represent the deleted elements.
Now when the user click on this new "" element and the Expand button, their "old" elements, of course, should be shown again. So we need to save the information about the deleted (collapsed) elements.
Currently we are saving them in two seperate lists: one for the nodes we deleted and one for the connections we deleted.
We want this feature to be usable in different tabs (editors) and multiple times so the two array we now have are not sufficient (when the user collapses again, the information in the old list will be deleted and overwritten with the information of the newly collapsed elements).
How do we do this properly? Do we write a new class? A class for each "collapse action"? But then, how do we know, which class corresponds to the elements, the user wants to expand?
All help is appreciated
Thanks in advance
jennie

Jennie_ wrote:
Hello Hansbig,
what do you mean with the state of the UI?Though he means well, Hansbig is very much a newbie, and I have to admit that for your problem, so am I. The only thing I can say is that yes, it sounds like you need a class to create instances that hold everything together and allow persistence of this information. Is there an Eclipse developers forum where folks who have encountered this problem before (for surely it is not unique) can share their expertise with you?

Similar Messages

  • Question : Save AWT Image Class to File..

    I Have a Question.. @.@a
    I'm doing AWT transform now..
    Well...
    I have a problem..
    I want to save AWT Image class to file..
    But.. I don't now that..
    Input Image Class same below..
    Image imageContent = (Image)attachment.getContent();
    How does it save imageContent Image class to file..?

    I had the same problem... convert it to a BufferedImage (http://forum.java.sun.com/thread.jspa?threadID=665744&tstart=15), then use javax.imageio.ImageIO.write to save it to a file.

  • Is it save to use class variables in stateful application modules?

    I've a simple question of understanding: Can I savely use class-variables in stateful application modules?
    Consider the following example:
    public class myStateFullAppModuleImpl extends ApplicationModuleImpl
    private int myVar=0;
    public int doMyWork()
    myVar++;
    return myVar;
    Is it save to use "myVar" this way considering AM-pooling? Or should I save "myVar" in the session instead?
    Thanks

    Please see reply at:
    Is it save to use class variables in a stateful application module?

  • Programmatic save of LVOOP class default value

    Hi!
    I've been stuck on this littel issue for some time now, maybe I can't see the wood for trees, maybe my intention is utopic
    Here is what I want to do: retrieve class default value from an existing *.lvclass (no prob so far), modify it in some sort of configuration programme and then save back the default value to this (or another) *.lvclass file.
    The only intended editing is about changing the default value, not more, not less.
    I have tried some VI server magic but failed (LabVIEW crashed)
    Any suggestions?
    Cheers
    Oli
    Programming languages don't create bad code, programmers create bad code....
    Solved!
    Go to Solution.

    Well, I do understand this issues for controls, but I'm sill struggling to transfer this to the LVOOP issue.
    Here's what I used to understand about loading class default values:
    I'm able to load a class default value dynamically from disk as long as inheritance is set right (--> PlugIn Architecture).
    So lets say I have a parent class A which has two children B1 and B2. So using the Get LV class default value.vi I'm able to load classes dynamically and cast it to class A (To More Generic Class). This way I can also load Class_B1.lvclass and Class_B2.lvclass and use dynamic dispatch.
    Now, if B1 and B2 have basically the same class private data (let's say a Boolean) that only differs in default value (true/false) I have a similar case for loading as what I'd like to do for saving.
    Having said that: maybe my intention should be be better described as modifying an existing class default value and save it as a new class.
    I guess there is a reason why NI did not implement the saving part... just need to understand why
    Oli
    Programming languages don't create bad code, programmers create bad code....

  • Save a java class instance in Oracle

    Hi,
    I would like to save a java object into an oracle table in order to use it later.
    Can you tell me if it is possible?
    thanks in advance.
    Michael.

    you have to place the java class in BLOB, and read it in and out as a pure binary file....... buth otherwise it should be possible

  • Is it save to use class variables in a stateful application module?

    I've a simple question of understanding: Can I savely use class-variables in stateful application modules?
    Consider the following example:
    public class myStateFullAppModuleImpl extends ApplicationModuleImpl
    private int myVar=0;
    public int doMyWork()
    myVar++;
    return myVar;
    Is it save to use "myVar" this way considering AM-pooling? Or should I save "myVar" in the session instead?
    Thanks

    Remainder of code:
                for (int i=0; i < length; i++)
                   org.w3c.dom.Node child = nl.item(i);
                   if (child != null && "jbo.counter".equals(child.getNodeName()))
                      getSession().getUserData().put(
                         "jbo.counter", child.getFirstChild().getNodeValue());
                      int counterInt = getCounterValue();
                      counterInt++;
                      getSession().getUserData().put(
                         "jbo.counter", String.valueOf(counterInt));
                      break;
          public void prepareSession(oracle.jbo.Session session)
             super.prepareSession(session);
             try
                int counterInt = getCounterValue();
                counterInt++;
                getSession().getUserData().put("jbo.counter", String.valueOf(counter
    Int));
             catch (Exception e)
                e.printStackTrace();
          public int getCounterValue()
             int counterInt = 0;
             try
                String counter = (String)getSession().getUserData().get("jbo.counter[i][pre]Long postings are being truncated to ~1 kB at this time.

  • How to speed a function to save-retrieve a class?

    The next code is My function to save and restore any class using a byteBuffer
    It works fine in both directions, but I want to speed it.
    For example the lines that make the conversion are too dense:
    if (tipo.equals("double")) {BBuff.putDouble((Double) value);}
    By other side, there is a error handling....
    Any idea ?
    Thanks
    private void object (Object OBJ,boolean read){
         String tipo="";
         Object value = null;
         Field[] fields=OBJ.getClass().getFields();
         for (Field FF:fields){               
         try {
         value = FF.get(OBJ);                    
         } catch (IllegalArgumentException e2) {
         e2.printStackTrace();
         } catch (IllegalAccessException e2) {
         e2.printStackTrace();
         if (FF.getType().getName().contains("."))
         object(value,true);     // call again            
         else
         tipo=FF.getType().getName();
         if (read==true)
         if (tipo.equals("double")) {BBuff.putDouble((Double) value);}
         if (tipo.equals("int")) {BBuff.putInt((Integer) value);}
         if (tipo.equals("float")) {BBuff.putFloat((Float) value);}
         else
          try {
         if (tipo.equals("int"))        FF.setInt(OBJ, BBuff.getInt());
         if (tipo.equals("double")) FF.setDouble(OBJ, BBuff.getDouble());
         if (tipo.equals("float"))  FF.setFloat(OBJ, BBuff.getFloat());
         value = FF.get(OBJ);     
         catch (IllegalArgumentException e) {                         
         e.printStackTrace();
         } catch (IllegalAccessException e) {
          e.printStackTrace();

    Edit: this is all assumming you go ahead with what you're trying to do. I don't personally think it's a very good idea; there's better ways of going about it, as already mentioned.
    Ok. First off, I don;t see the need for the call of "value = FF.get(OBJ);" at the end of the loop. It's going to get called again at the start of the next loop, so that's unnecessary.
    Boxing and unboxing the primitives that you're working with will give you a speed hit, and I think you should be able to avoid it. Before you call FF.get(OBJ), test whether FF.getType().getName(); gives the name of a primitive. If it's an int, declare an int reference and use Field's getInt() method and ByteBuffer's putInt() method, and so on.
    As I said, I'd strongly recommend you separate it into a read() and a write() method. This is not just for neatness or readability, there's unneccesary work being done. The first try block is still executing even if it's a read-from-byte-buffer operation, which is unnecessary. Also, where is BBuff defined? It should probably be passed in as an argument.
    Before you make any changes for speed testing, make a test run that saves & loads say 10,000 objects and time it, then compare this after any changes.

  • SAP Script to save in development class

    Hi All,
    I forgot to save one of the SAP  - Script into development class, saved it into local object.
    How can I save this script agian into development class, I want to make it to craete trasnport for this.
    Plz provide the answer.
    Regards,
    Bala

    Hi,
    with transaction  code SE80. You can reassign to an another development class.
    Lauch Transdaction Se80.
    Select Local Object
    find your sapscript
    right click -> other function -> "change pacxkage"
    Now you select your development class and assign it to a transport order .
    Rgds

  • How to save library symbols' class files in packages that are not the default package?

    Hi,
    I perform the following in Flash CS5 with Flash Builder 4
    1) Create a new library symbol.
    2) Do a RightClick->Properties on the new symbol
    3) Check the options for "Export for ActionScript" and "Export in frame 1".
    4) I write a new name for my class "Class1" and click on the pencil icon "edit class definition" to edit the class.
    At this point my FlashBuilder 4 takes over and opens the "New ActionScript" dialog.
    4) I then click on Package-Browse to select a package e.g. com.mycompany.myfiles as the new class destination.
    The as file is created as com.mycompany.myfiles/Class1.as as everything seems just fine.
    5) I close the ActionScript file and back in Flash CS5 I RightClick on the symbol and select "Edit Class".
    At this time, FB4 suggests again to create the file, ignoring the fact that I already created it before.
    Do you know of a way I can make Flash CS5 remember where I created the file?
    Thanks.

    Hi,
    I didn't remove the project or delete any of the files.
    All I did was create the class file under a package that is not the default package. Then when I clicked on the Flash symbol's "Edit Class" It asked me again to create the same class file.
    Only if I create the class in the default package, it won't ask me to recreate it again.
    Bye,
      RaamEE-IL

  • TextLayout not Serializable AND final class - can't extend and save objects

    As the title reads, I am using a TextLayout object in a class called Foo.
    I want to be able to serialize Foo and save it to the HD. This can't be done because TextLayout does not implement Serializable.
    So I tried to create a new class that extended the TextLayout class. This wasn't possible because TextLayout is defined as:
    public final class TextLayout
    extends Object
    implements Cloneable
    Basically, I have no clue how to be able to save my Foo class to the HD since I can't serialize the TextLayout object inside the Foo class. I would really appreciate help, because it is quite important that this works.
    Thanks.

    Siniz wrote:
    I have never dabbled with with transient variables, but I just read up on it and understand what you are getting at. Is this really the only way?
    The reason why I need to use TextLayout is because I need the bounding box of the text. I see no other way to get a bounding box around text than using TextLayout.That's a question for the swing/awt forums.
    I am also not entirely sure what you mean when you say I should write my own writeObject and readObject methods? You are saying I should entirely ditch the ObjectOutputStream methods?No, you implement those methods on your class in order to customize serialization. Please see the javadocs on the Serializable interface.

  • Class Not Found Exception when saving in Backend?

    Hello all,
    we are using JBOSS, Hibernate, Flex 3 and BlazeDS.
    I have added a class ProjectDocument and it is configured identically to an existing class PartDocument.
    I can successfully load the class in front  end, but the save of the class leads to the following exception.
    The jar is successfully compiled, and includes both PartDocument.class and ProjectDocument.class.
    Does anyone know why BlazeDS cannot find the class?
    regards and thanks
    David
    15:28:49,062 INFO  [STDOUT] [BlazeDS]Cannot create class of type 'ProjectDocumen
    t'.
    flex.messaging.MessageException: Cannot create class of type 'ProjectDocument'.
    Type 'ProjectDocument' not found.
            at flex.messaging.util.ClassUtil.createClass(ClassUtil.java:66)
            at flex.messaging.io.AbstractProxy.getClassFromClassName(AbstractProxy.j
    ava:103)
            at flex.messaging.io.amf.Amf3Input.readScriptObject(Amf3Input.java:430)
            at flex.messaging.io.amf.Amf3Input.readObjectValue(Amf3Input.java:153)
            at flex.messaging.io.amf.Amf3Input.readObject(Amf3Input.java:132)
            at flex.messaging.io.amf.Amf3Input.readArray(Amf3Input.java:371)
            at flex.messaging.io.amf.Amf3Input.readObjectValue(Amf3Input.java:157)
            at flex.messaging.io.amf.Amf3Input.readObject(Amf3Input.java:132)
            at flex.messaging.io.amf.Amf3Input.readScriptObject(Amf3Input.java:473)
            at flex.messaging.io.amf.Amf3Input.readObjectValue(Amf3Input.java:153)
            at flex.messaging.io.amf.Amf3Input.readObject(Amf3Input.java:132)
            at flex.messaging.io.amf.Amf0Input.readObjectValue(Amf0Input.java:135)
            at flex.messaging.io.amf.Amf0Input.readArrayValue(Amf0Input.java:326)
            at flex.messaging.io.amf.Amf0Input.readObjectValue(Amf0Input.java:139)
            at flex.messaging.io.amf.Amf0Input.readObject(Amf0Input.java:95)
            at flex.messaging.io.amf.AmfMessageDeserializer.readObject(AmfMessageDes
    erializer.java:226)
            at flex.messaging.io.amf.AmfMessageDeserializer.readBody(AmfMessageDeser
    ializer.java:205)
            at flex.messaging.io.amf.AmfMessageDeserializer.readMessage(AmfMessageDe
    serializer.java:125)
            at flex.messaging.endpoints.amf.SerializationFilter.invoke(Serialization
    Filter.java:114)
            at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.ja
    va:278)
            at flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java
    :322)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

    Hi all,
    we found the problem.
    To read the class in flex we used:
    registerClassAlias("ProjectDocument", ProjectDocument);
    Then BlazeDS sent as class name just ProjectDocument and not the whole string.
    So do not register classes - if you have a class coming from JAva that Flex does not recognise because it is not used in the mxml, just create a dummy variable.
    Hope this helps someone else!

  • Saving and Restoring a class using Persistence Delegate

    Hi, I have a class that does not comply to the java bean format and thus I have decided to use persistence delegates. All I want to do is be able to save an entire class so I can restore it later.
    So this is what I did:
    XMLEncoder xe = new XMLEncoder(
    new BufferedOutputStream(
    new FileOutputStream(filename)));
    xe.setPersistenceDelegate(Workspace.class,
    new PersistenceDelegate()
    protected Expression instantiate(Object oldInstance, Encoder out)
    return new Expression(oldInstance, oldInstance.getClass(),
    "new", new Object[]
    oldInstance,
    oldInstance,
    oldInstance,
    oldInstance,
    oldInstance,
    oldInstance,
    oldInstance,
    oldInstance
    xe.writeObject(workspace);
    xe.close();
    Where workspace takes in a BufferedImage, int, int, int, int, int, String and String.
    The workspace class Vectors and an array of another class of mine.
    When I run this code I get : java.lang.StackOverflowError
    Can someone point me in the right direction please?
    Thanks in advance,
    Harley.

    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.

  • How to compile .java to .class in .jar file

    Hey. I have code to make a .jar file, read .java files, and save them as .class files in the .jar file. When I open the .jar file, it says that the magic numbers on the classes are wrong. So I figured that Java must compile the .java files to .class files in bytecode.
    Question: What's the code to compile a string from a .java file to a .class file?
    Here's my code:
    try {
                // Name of jar file to write
                String archiveFile = Name + ".jar";
                Manifest jman = new Manifest();
                try {
                    // Create a manifest from a file
                    //InputStream fis = new FileInputStream("manifestfile");
                    //Manifest manifest = new Manifest(fis);
                    // Construct a string version of a manifest
                    StringBuffer sbuf = new StringBuffer();
                    sbuf.append("Manifest-Version: 1.0\n");
                    sbuf.append("Ant-Version: Apache Ant 1.7.1\n");
                    sbuf.append("Created-By: 1.5.0_19-137 (Apple Inc.)\n");
                    sbuf.append("Main-Class: Main\n");
                    sbuf.append("Class-Path: lib/swing-layout-1.0.3.jar\n");
                    sbuf.append("X-COMMENT: Main-Class will be added automatically by build\n");
                    // Convert the string to a input stream
                    InputStream is = new ByteArrayInputStream(sbuf.toString().getBytes("UTF-8"));
                    // Create the manifest
                    jman = new Manifest(is);
                } catch (IOException e) {
                FileOutputStream stream = new FileOutputStream(archiveFile, true);// archive file is jar file name
                JarOutputStream out = new JarOutputStream(stream, jman);
                out.putNextEntry(new JarEntry("Main.class"));
                StringBuffer sbuf = new StringBuffer();
                sbuf.append(readTextFromJar("Main.txt")));
                out.write(sbuf.toString().getBytes("UTF-8"));
                out.closeEntry();
                out.putNextEntry(new JarEntry("MainScreen.class"));
                sbuf = new StringBuffer();
                sbuf.append(readTextFromJar("MainScreen.txt"));
                out.write(sbuf.toString().getBytes("UTF-8"));
                out.closeEntry();
                out.putNextEntry(new JarEntry("GCanvas.class"));
                sbuf = new StringBuffer();
                sbuf.append(readTextFromJar("GCanvas.txt"));
                out.write(sbuf.toString().getBytes("UTF-8"));
                out.closeEntry();
                out.close();
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this, ex.toString(), "BUG!", JOptionPane.INFORMATION_MESSAGE);
                ex.printStackTrace();
            }Thanks,
    -Gandolf

    So I'm guessing that none of you guys have the knowledge on how to compile a java application within a java application. I was thinking that it had something to do with javac... but I'm unsure.
    If no one can answer the question, could someone point me to an expert who would know?
    -Gandolf

  • Save ImageIcon to file

    Hello all,
    Could someone teach me to save and ImageIcon class to an file. I've tried ImageIO.write, but that doesn't accept an ImageIcon class. Tried to use BufferedImage, but that doesn't accept ImageIcon either.
    ImageIcon icon = new ImageIcon(file.getAbsolutePath(), "Test");
    int h = icon.getIconHeight();
    int w = icon.getIconWidth();
    int hnew, wnew;
    if (h > w) {
         hnew = jLabelPict.getHeight();
         wnew = w / (h / jLabelPict.getHeight());
    } else {
         wnew = jLabelPict.getHeight();
         hnew = h / (w / jLabelPict.getHeight());
    Image img = icon.getImage().getScaledInstance(
                                  wnew, hnew, Image.SCALE_FAST);
    icon.setImage(img);
    jLabelPict.setIcon(icon);
    jLabelPict.setText("");
    jTextField.setText(file.getAbsolutePath().toString());
    At this point the file should be saved.
    Many thanks & regards

    hope this can works (not tested):
    ImageIcon icon = ...;
    BufferedImage bimg = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
    bimg.getGraphics().drawImage(icon.getImage(), 0, 0, null);
    ImageIO.write(bimg, "jpeg", file);

  • Ignore some fields while saving a Java class into XML

    Hi!
    I've seen in this forum that there is an easy way of saving Java classes to XML files using Castor. I want to save some Java classes into XML, but not all the fields of the class. For example, I want to ignore all lists. Is there any easy way to do something like this:
    class Java2XML{
              public static void makeXML(Object object)
                        for all fields in object
                                  if field extends List, ignore
                                  else, include field in XML
    }Thanks in advance!

    You can add a managed bean by:
    - manually adding a definition in the faces config source tab.
    - creating a bean in the overview tab of the faces-config editor.
    So yes, you can edit the faces-config manually.
    I hope this answer your question,
    Regards,
    Koen Verhulst

Maybe you are looking for