public MetalworksInBox() {
    super("In Box", true, true, true, true);

    DefaultMutableTreeNode unread;
    DefaultMutableTreeNode personal;
    DefaultMutableTreeNode business;
    DefaultMutableTreeNode spam;

    DefaultMutableTreeNode top = new DefaultMutableTreeNode("Mail Boxes");

    top.add(unread = new DefaultMutableTreeNode("Unread Mail"));
    top.add(personal = new DefaultMutableTreeNode("Personal"));
    top.add(business = new DefaultMutableTreeNode("Business"));
    top.add(spam = new DefaultMutableTreeNode("Spam"));

    unread.add(new DefaultMutableTreeNode("Buy Stuff Now"));
    unread.add(new DefaultMutableTreeNode("Read Me Now"));
    unread.add(new DefaultMutableTreeNode("Hot Offer"));
    unread.add(new DefaultMutableTreeNode("Re: Re: Thank You"));
    unread.add(new DefaultMutableTreeNode("Fwd: Good Joke"));

    personal.add(new DefaultMutableTreeNode("Hi"));
    personal.add(new DefaultMutableTreeNode("Good to hear from you"));
    personal.add(new DefaultMutableTreeNode("Re: Thank You"));

    business.add(new DefaultMutableTreeNode("Thanks for your order"));
    business.add(new DefaultMutableTreeNode("Price Quote"));
    business.add(new DefaultMutableTreeNode("Here is the invoice"));
    business.add(new DefaultMutableTreeNode("Project Metal: delivered on time"));
    business.add(new DefaultMutableTreeNode("Your salary raise approved"));

    spam.add(new DefaultMutableTreeNode("Buy Now"));
    spam.add(new DefaultMutableTreeNode("Make $$$ Now"));
    spam.add(new DefaultMutableTreeNode("HOT HOT HOT"));
    spam.add(new DefaultMutableTreeNode("Buy Now"));
    spam.add(new DefaultMutableTreeNode("Don't Miss This"));
    spam.add(new DefaultMutableTreeNode("Opportunity in Precious Metals"));
    spam.add(new DefaultMutableTreeNode("Buy Now"));
    spam.add(new DefaultMutableTreeNode("Last Chance"));
    spam.add(new DefaultMutableTreeNode("Buy Now"));
    spam.add(new DefaultMutableTreeNode("Make $$$ Now"));
    spam.add(new DefaultMutableTreeNode("To Hot To Handle"));
    spam.add(new DefaultMutableTreeNode("I'm waiting for your call"));

    JTree tree = new JTree(top);
    JScrollPane treeScroller = new JScrollPane(tree);
    treeScroller.setBackground(tree.getBackground());
    setContentPane(treeScroller);
    setSize(325, 200);
    setLocation(75, 75);
  }
  private void createDesignerCard() {
    myLayeredPane = new MyLayeredPane();

    mySurfaceArea =
        new ComponentEditableArea(myLayeredPane) {
          @Override
          protected void fireSelectionChanged() {
            super.fireSelectionChanged();
            myLayeredPane.revalidate();
            myLayeredPane.repaint();
          }

          @Override
          public RadComponent findTarget(int x, int y, @Nullable ComponentTargetFilter filter) {
            if (myRootComponent != null) {
              FindComponentVisitor visitor = new FindComponentVisitor(myLayeredPane, filter, x, y);
              myRootComponent.accept(visitor, false);
              return visitor.getResult();
            }
            return null;
          }

          @Override
          public InputTool findTargetTool(int x, int y) {
            return myDecorationLayer.findTargetTool(x, y);
          }

          @Override
          public void showSelection(boolean value) {
            myDecorationLayer.showSelection(value);
          }

          @Override
          public ComponentDecorator getRootSelectionDecorator() {
            return DesignerEditorPanel.this.getRootSelectionDecorator();
          }

          @Nullable
          public EditOperation processRootOperation(OperationContext context) {
            return DesignerEditorPanel.this.processRootOperation(context);
          }

          @Override
          public FeedbackLayer getFeedbackLayer() {
            return myFeedbackLayer;
          }

          @Override
          public RadComponent getRootComponent() {
            return myRootComponent;
          }
        };

    myPaletteListener =
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            if (DesignerToolWindowManager.getInstance(getProject()).getActiveDesigner()
                == DesignerEditorPanel.this) {
              Item paletteItem = (Item) PaletteManager.getInstance(getProject()).getActiveItem();
              if (paletteItem != null) {
                myToolProvider.setActiveTool(
                    new CreationTool(true, createCreationFactory(paletteItem)));
              } else if (myToolProvider.getActiveTool() instanceof CreationTool) {
                myToolProvider.loadDefaultTool();
              }
            }
          }
        };

    myToolProvider =
        new ToolProvider() {
          @Override
          public void loadDefaultTool() {
            setActiveTool(new SelectionTool());
          }

          @Override
          public void setActiveTool(InputTool tool) {
            if (getActiveTool() instanceof CreationTool && !(tool instanceof CreationTool)) {
              PaletteManager.getInstance(getProject()).clearActiveItem();
            }
            super.setActiveTool(tool);
          }

          @Override
          public boolean execute(
              final ThrowableRunnable<Exception> operation,
              String command,
              final boolean updateProperties) {
            final boolean[] is = {true};
            CommandProcessor.getInstance()
                .executeCommand(
                    getProject(),
                    new Runnable() {
                      public void run() {
                        is[0] = DesignerEditorPanel.this.execute(operation, updateProperties);
                      }
                    },
                    command,
                    null);
            return is[0];
          }

          @Override
          public void execute(final List<EditOperation> operations, String command) {
            CommandProcessor.getInstance()
                .executeCommand(
                    getProject(),
                    new Runnable() {
                      public void run() {
                        DesignerEditorPanel.this.execute(operations);
                      }
                    },
                    command,
                    null);
          }

          @Override
          public void showError(@NonNls String message, Throwable e) {
            DesignerEditorPanel.this.showError(message, e);
          }
        };

    myGlassLayer = new GlassLayer(myToolProvider, mySurfaceArea);
    myLayeredPane.add(myGlassLayer, LAYER_GLASS);

    myDecorationLayer = new DecorationLayer(mySurfaceArea);
    myLayeredPane.add(myDecorationLayer, LAYER_DECORATION);

    myFeedbackLayer = new FeedbackLayer();
    myLayeredPane.add(myFeedbackLayer, LAYER_FEEDBACK);

    JPanel content = new JPanel(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.VERTICAL;

    myVerticalCaption = new CaptionPanel(this, false);
    content.add(myVerticalCaption, gbc);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    myHorizontalCaption = new CaptionPanel(this, true);
    content.add(myHorizontalCaption, gbc);

    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;

    myScrollPane = ScrollPaneFactory.createScrollPane(myLayeredPane);
    myScrollPane.setBackground(Color.WHITE);
    content.add(myScrollPane, gbc);

    myHorizontalCaption.attachToScrollPane(myScrollPane);
    myVerticalCaption.attachToScrollPane(myScrollPane);

    myActionPanel = new DesignerActionPanel(this, myGlassLayer);

    myDesignerCard = new JPanel(new FillLayout());
    myDesignerCard.add(myActionPanel.getToolbarComponent());
    myDesignerCard.add(content);
    add(myDesignerCard, DESIGNER_CARD);

    PaletteManager.getInstance(getProject()).addSelectionListener(myPaletteListener);

    mySourceSelectionListener =
        new ComponentSelectionListener() {
          @Override
          public void selectionChanged(EditableArea area) {
            storeSourceSelectionState();
          }
        };
    mySurfaceArea.addSelectionListener(mySourceSelectionListener);
  }
Пример #3
0
  public void setContent(String cat) {
    cat = cat.trim();
    selectAllCB.setVisible(false);
    selectAllCB.setSelected(false);
    deleteBut.setVisible(false);
    restoreBut.setVisible(false);
    refreshBut.setVisible(true);
    Object columns[] = null;
    int count = 0;
    switch (cat) {
      case "Inbox":
        columns = new Object[] {"", "From", "Date", "Subject", "Content"};
        count = Database.getCount("Inbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc");
        ;
        break;
      case "SentMail":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Sentmail");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc");
        break;
      case "Draft":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Draft");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc");
        break;
      case "Outbox":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Outbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc");
        break;
      case "Trash":
        //                restoreBut.setVisible(true);
        columns = new Object[] {"", "To/From", "Date", "Subject", "Content"};
        count = Database.getCount("Trash");
        workingSet =
            db.getData(
                "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc");
        break;
      default:
        System.out.println("in default case");
    }
    if (count > 0) {
      selectAllCB.setVisible(true);
      rows = new Object[count][];
      msgID = new int[count];
      try {
        workingSet.beforeFirst();
        for (int i = 0; i < count && workingSet.next(); i++) {
          msgID[i] = workingSet.getInt(1);
          rows[i] =
              new Object[] {
                false,
                workingSet.getString(2),
                workingSet.getDate(3),
                workingSet.getString(4),
                workingSet.getString(5)
              };
        }
      } catch (SQLException sqlExc) {
        JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE);
        sqlExc.printStackTrace();
      }

      tableModel = new MyDefaultTableModel(rows, columns);
      table = new JTable(tableModel);
      table.getSelectionModel().addListSelectionListener(this);
      table.addMouseListener(this);
      table.getTableHeader().setOpaque(true);
      table.getTableHeader().setReorderingAllowed(false);
      //            table.getTableHeader().setBackground(Color.blue);
      table.getTableHeader().setForeground(Color.blue);
      //        table.setRowSelectionAllowed(false);
      //            table.setColumnSelectionAllowed(false);
      table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
      table.setRowHeight(20);
      table.setFillsViewportHeight(true);

      TableColumn column = null;
      for (int i = 0; i < 5; i++) {
        column = table.getColumnModel().getColumn(i);
        if (i == 0) {
          column.setPreferredWidth(6);
        } else if (i == 3) {
          column.setPreferredWidth(250);
        } else if (i == 4) {
          column.setPreferredWidth(450);
        } else {
          column.setPreferredWidth(40);
        }
      }
      table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

      remove(contentPan);
      contentPan = new JScrollPane(table);
      contentPan.setBackground(Color.orange);
      contentPan.setOpaque(true);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      Home.home.homeFrame.setVisible(true);
    } else {
      JPanel centPan = new JPanel(new GridBagLayout());
      centPan.setBackground(new Color(52, 86, 70));
      JLabel label = new JLabel("No Messages In This Category");
      label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22));
      label.setForeground(Color.orange);
      centPan.add(label);
      remove(contentPan);
      contentPan = new JScrollPane(centPan);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      contentPan.repaint();
    }
  }