Exemplo n.º 1
0
 private static void main2(String[] args) {
   Config.cmdline(args);
   try {
     javabughack();
   } catch (InterruptedException e) {
     return;
   }
   setupres();
   MainFrame f = new MainFrame(null);
   if (Utils.getprefb("fullscreen", false)) f.setfs();
   f.mt.start();
   try {
     f.mt.join();
   } catch (InterruptedException e) {
     f.g.interrupt();
     return;
   }
   dumplist(Resource.remote().loadwaited(), Config.loadwaited);
   dumplist(Resource.remote().cached(), Config.allused);
   if (ResCache.global != null) {
     try {
       Writer w = new OutputStreamWriter(ResCache.global.store("tmp/allused"), "UTF-8");
       try {
         Resource.dumplist(Resource.remote().used(), w);
       } finally {
         w.close();
       }
     } catch (IOException e) {
     }
   }
   System.exit(0);
 }
 /** Creates a new instance of ReportElementSheetPanel */
 public ReportObjectSheetPanel() {
   super();
   this.setBackground(Color.BLUE);
   initSheetProperties();
   // We have to register for element changes...
   MainFrame mf = MainFrame.getMainInstance();
   mf.addReportListener(this);
   mf.addReportFrameActivatedListener(this);
   I18n.addOnLanguageChangedListener(this);
 }
Exemplo n.º 3
0
  /**
   * Creates a call to the contact represented by the given string.
   *
   * @param contact the contact to call to
   */
  public void createCall(String contact) {
    CallPanel callPanel = new CallPanel(this, contact);

    mainFrame.addCallPanel(callPanel);

    new CreateCallThread(contact, callPanel).start();
  }
Exemplo n.º 4
0
  /**
   * Creates a call to the given list of contacts.
   *
   * @param contacts the list of contacts to call to
   */
  public void createCall(Vector contacts) {
    CallPanel callPanel = new CallPanel(this, contacts);

    mainFrame.addCallPanel(callPanel);

    new CreateCallThread(contacts, callPanel).start();
  }
Exemplo n.º 5
0
  /**
   * Removes the given call panel tab.
   *
   * @param callPanel the CallPanel to remove
   */
  private void removeCallPanel(CallPanel callPanel) {
    if (callPanel.getCall() != null && activeCalls.contains(callPanel.getCall())) {
      this.activeCalls.remove(callPanel.getCall());
    }

    mainFrame.removeCallPanel(callPanel);
    updateButtonsStateAccordingToSelectedPanel();
  }
Exemplo n.º 6
0
 /** Updates call and hangup buttons' states aa */
 private void updateButtonsStateAccordingToSelectedPanel() {
   Component selectedPanel = mainFrame.getSelectedTab();
   if (selectedPanel != null && selectedPanel instanceof CallPanel) {
     this.hangupButton.setEnabled(true);
   } else {
     this.hangupButton.setEnabled(false);
   }
 }
Exemplo n.º 7
0
  private void update() {
    if (party.memb != om) {
      Collection<Member> old = new HashSet<Member>(avs.keySet());
      for (final Member m : (om = party.memb).values()) {
        if (m.gobid == ign) continue;
        Avaview w = avs.get(m);
        if (w == null) {
          w =
              new Avaview(Coord.z, this, m.gobid, new Coord(27, 27)) {
                private Tex tooltip = null;

                public Object tooltip(Coord c, boolean again) {
                  Gob gob = m.getgob();
                  if (gob == null) return (tooltip);
                  KinInfo ki = gob.getattr(KinInfo.class);
                  if (ki == null) return (null);
                  return (tooltip = ki.rendered());
                }
              };
          avs.put(m, w);
        } else {
          old.remove(m);
        }
      }
      for (Member m : old) {
        ui.destroy(avs.get(m));
        avs.remove(m);
      }
      List<Map.Entry<Member, Avaview>> wl =
          new ArrayList<Map.Entry<Member, Avaview>>(avs.entrySet());
      Collections.sort(
          wl,
          new Comparator<Map.Entry<Member, Avaview>>() {
            public int compare(Entry<Member, Avaview> a, Entry<Member, Avaview> b) {
              return (a.getKey().gobid - b.getKey().gobid);
            }
          });
      int i = 0;
      for (Map.Entry<Member, Avaview> e : wl) {
        e.getValue().c = new Coord((i % 2) * 43, (i / 2) * 43 + 24);
        i++;
      }
    }
    for (Map.Entry<Member, Avaview> e : avs.entrySet()) {
      e.getValue().color = e.getKey().col;
    }
    if ((avs.size() > 0) && (leave == null)) {
      leave = new Button(Coord.z, 84, this, "Leave party");
    }
    if ((avs.size() == 0) && (leave != null)) {
      ui.destroy(leave);
      leave = null;
    }
    sz.y = MainFrame.getScreenSize().y - c.y;
  }
Exemplo n.º 8
0
  /**
   * Implements CallListener.incomingCallReceived. When a call is received creates a call panel and
   * adds it to the main tabbed pane and plays the ring phone sound to the user.
   */
  public void incomingCallReceived(CallEvent event) {
    Call sourceCall = event.getSourceCall();

    CallPanel callPanel = new CallPanel(this, sourceCall, GuiCallParticipantRecord.INCOMING_CALL);

    mainFrame.addCallPanel(callPanel);

    if (mainFrame.getState() == JFrame.ICONIFIED) mainFrame.setState(JFrame.NORMAL);

    if (!mainFrame.isVisible()) mainFrame.setVisible(true);

    mainFrame.toFront();

    this.callButton.setEnabled(true);
    this.hangupButton.setEnabled(true);

    NotificationManager.fireNotification(
        NotificationManager.INCOMING_CALL,
        null,
        "Incoming call recived from: " + sourceCall.getCallParticipants().next());

    activeCalls.put(sourceCall, callPanel);

    this.setCallPanelVisible(true);
  }
Exemplo n.º 9
0
  /**
   * Implements ChangeListener.stateChanged. Enables the hangup button if ones selects a tab in the
   * main tabbed pane that contains a call panel.
   */
  public void stateChanged(ChangeEvent e) {
    this.updateButtonsStateAccordingToSelectedPanel();

    Component selectedPanel = mainFrame.getSelectedTab();
    if (selectedPanel == null || !(selectedPanel instanceof CallPanel)) {
      Iterator callPanels = activeCalls.values().iterator();

      while (callPanels.hasNext()) {
        CallPanel callPanel = (CallPanel) callPanels.next();

        callPanel.removeDialogs();
      }
    }
  }
Exemplo n.º 10
0
  public void disconnected() {
    isConnected = false;

    MainFrame.getInstance().setDisconnected();

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            uploadModel.removeExternalUploads();
            downloadModel.removeExternalDownloads();
          }
        });
    logger.severe("disconnected!");
  }
Exemplo n.º 11
0
  public void actionPerformed(ActionEvent e) {
    // Ask user to confirm exit.
    int reply =
        JOptionPane.showConfirmDialog(
            main,
            bundle.getString("Exit_application_?"),
            bundle.getString("Exit"),
            JOptionPane.YES_NO_OPTION);
    if (reply != JOptionPane.YES_OPTION) return;

    // Save MainFrame's bounds
    Rectangle r = main.getBounds();
    Main.setProperty("window.bounds.width", Integer.toString(r.width));
    Main.setProperty("window.bounds.height", Integer.toString(r.height));
    Main.setProperty("window.bounds.x", Integer.toString(r.x));
    Main.setProperty("window.bounds.y", Integer.toString(r.y));

    // System Exit
    Main.saveProperties();
    Main.exit(0);
  }
Exemplo n.º 12
0
  /** Set view selection to user's choice. */
  public void setSelect() throws DatabaseException {
    JList list = getList();
    View original = null;
    View view = null;
    long id = _collection.getDatabase().getCurrentSetting().getViewID();
    if (id != -1) {
      for (int i = 0; i < list.getModel().getSize(); i++) {
        View vw = (View) list.getModel().getElementAt(i);
        if (id == vw.getID()) {
          view = vw;
          break;
        } else if (vw.getName().equals("Original")) {
          original = view;
        }
      }
    }
    // default Original
    if (view == null) view = original;

    list.setSelectedValue(view, true);
    MainFrame.getInstance().updateStatus();
  }
Exemplo n.º 13
0
  /**
   * Implements ListSelectionListener.valueChanged. Enables or disables call and hangup buttons
   * depending on the selection in the contactlist.
   */
  public void valueChanged(ListSelectionEvent e) {
    Object o = mainFrame.getContactListPanel().getContactList().getSelectedValue();

    if ((e.getFirstIndex() != -1 || e.getLastIndex() != -1) && (o instanceof MetaContact)) {
      setCallMetaContact(true);

      // Switch automatically to the appropriate pps in account selector
      // box and enable callButton if telephony is supported.
      Contact contact = ((MetaContact) o).getDefaultContact(OperationSetBasicTelephony.class);

      if (contact != null) {
        callButton.setEnabled(true);

        if (contact.getProtocolProvider().isRegistered())
          getAccountSelectorBox().setSelected(contact.getProtocolProvider());
      } else {
        callButton.setEnabled(false);
      }
    } else if (phoneNumberCombo.isComboFieldEmpty()) {
      callButton.setEnabled(false);
    }
  }
Exemplo n.º 14
0
  /** Hides the panel containing call and hangup buttons. */
  public void setCallPanelVisible(boolean isVisible) {
    if (isVisible) {
      this.add(comboPanel, BorderLayout.NORTH);
      this.add(buttonsPanel, BorderLayout.CENTER);

      this.minimizeButtonPanel.removeAll();
      this.minimizeButtonPanel.add(minimizeButton);
    } else {
      this.remove(comboPanel);
      this.remove(buttonsPanel);

      this.minimizeButtonPanel.removeAll();
      this.minimizeButtonPanel.add(restoreButton);

      if (mainFrame.isVisible())
        this.mainFrame.getContactListPanel().getContactList().requestFocus();
    }

    if (ConfigurationManager.isCallPanelShown() != isVisible)
      ConfigurationManager.setShowCallPanel(isVisible);

    this.mainFrame.validate();
  }
Exemplo n.º 15
0
 public void connected() {
   isConnected = true;
   MainFrame.getInstance().setConnected();
   logger.severe("now connected");
 }
Exemplo n.º 16
0
  /**
   * Implements the ContactListListener.contactSelected method.
   *
   * @param evt the <tt>ContactListEvent</tt> that notified us
   */
  public void contactClicked(ContactListEvent evt) {
    // We're interested only in two click events.
    if (evt.getClickCount() < 2) return;

    UIContact descriptor = evt.getSourceContact();

    // We're currently only interested in MetaContacts.
    if (descriptor.getDescriptor() instanceof MetaContact) {
      MetaContact metaContact = (MetaContact) descriptor.getDescriptor();

      // Searching for the right proto contact to use as default for the
      // chat conversation.
      Contact defaultContact =
          metaContact.getDefaultContact(OperationSetBasicInstantMessaging.class);

      // do nothing
      if (defaultContact == null) {
        defaultContact = metaContact.getDefaultContact(OperationSetSmsMessaging.class);

        if (defaultContact == null) return;
      }

      ProtocolProviderService defaultProvider = defaultContact.getProtocolProvider();

      OperationSetBasicInstantMessaging defaultIM =
          defaultProvider.getOperationSet(OperationSetBasicInstantMessaging.class);

      ProtocolProviderService protoContactProvider;
      OperationSetBasicInstantMessaging protoContactIM;

      boolean isOfflineMessagingSupported =
          defaultIM != null && !defaultIM.isOfflineMessagingSupported();

      if (defaultContact.getPresenceStatus().getStatus() < 1
          && (!isOfflineMessagingSupported || !defaultProvider.isRegistered())) {
        Iterator<Contact> protoContacts = metaContact.getContacts();

        while (protoContacts.hasNext()) {
          Contact contact = protoContacts.next();

          protoContactProvider = contact.getProtocolProvider();

          protoContactIM =
              protoContactProvider.getOperationSet(OperationSetBasicInstantMessaging.class);

          if (protoContactIM != null
              && protoContactIM.isOfflineMessagingSupported()
              && protoContactProvider.isRegistered()) {
            defaultContact = contact;
          }
        }
      }

      ContactEventHandler contactHandler =
          mainFrame.getContactHandler(defaultContact.getProtocolProvider());

      contactHandler.contactClicked(defaultContact, evt.getClickCount());
    } else if (descriptor.getDescriptor() instanceof SourceContact) {
      SourceContact contact = (SourceContact) descriptor.getDescriptor();

      List<ContactDetail> imDetails =
          contact.getContactDetails(OperationSetBasicInstantMessaging.class);
      List<ContactDetail> mucDetails = contact.getContactDetails(OperationSetMultiUserChat.class);

      if (imDetails != null && imDetails.size() > 0) {
        ProtocolProviderService pps =
            imDetails.get(0).getPreferredProtocolProvider(OperationSetBasicInstantMessaging.class);

        GuiActivator.getUIService()
            .getChatWindowManager()
            .startChat(contact.getContactAddress(), pps);
      } else if (mucDetails != null && mucDetails.size() > 0) {
        ChatRoomWrapper room =
            GuiActivator.getMUCService().findChatRoomWrapperFromSourceContact(contact);

        if (room == null) {
          // lets check by id
          ProtocolProviderService pps =
              mucDetails.get(0).getPreferredProtocolProvider(OperationSetMultiUserChat.class);

          room =
              GuiActivator.getMUCService()
                  .findChatRoomWrapperFromChatRoomID(contact.getContactAddress(), pps);

          if (room == null) {
            GuiActivator.getMUCService()
                .createChatRoom(
                    contact.getContactAddress(),
                    pps,
                    new ArrayList<String>(),
                    "",
                    false,
                    false,
                    false);
          }
        }

        if (room != null) GuiActivator.getMUCService().openChatRoom(room);
      } else {
        List<ContactDetail> smsDetails = contact.getContactDetails(OperationSetSmsMessaging.class);

        if (smsDetails != null && smsDetails.size() > 0) {
          GuiActivator.getUIService()
              .getChatWindowManager()
              .startChat(contact.getContactAddress(), true);
        }
      }
    }
  }
 public void updateSelection() {
   JReportFrame newJrf = MainFrame.getMainInstance().getActiveReportFrame();
   updateSelection(newJrf);
 }
  public void reportFrameActivated(ReportFrameActivatedEvent evt) {

    if (MainFrame.getMainInstance().getActiveReportFrame() == this.getJrf()) return;
    updateSelection(MainFrame.getMainInstance().getActiveReportFrame());
  }
Exemplo n.º 19
0
 public DocumentNameRenderer() {
   super();
   setIcon(MainFrame.getIcon("document"));
 }
Exemplo n.º 20
0
 public OpenDocumentsAction() {
   super("Open documents", MainFrame.getIcon("document"));
   putValue(SHORT_DESCRIPTION, "Opens selected document(s) in a document editor");
 }
Exemplo n.º 21
0
 public MoveDownAction() {
   super("Move down", MainFrame.getIcon("down"));
   putValue(SHORT_DESCRIPTION, "Moves selected document(s) down");
   putValue(MNEMONIC_KEY, KeyEvent.VK_DOWN);
 }
Exemplo n.º 22
0
  /**
   * Handles the <tt>ActionEvent</tt> generated when user presses one of the buttons in this panel.
   */
  public void actionPerformed(ActionEvent evt) {
    JButton button = (JButton) evt.getSource();
    String buttonName = button.getName();

    if (buttonName.equals("call")) {
      Component selectedPanel = mainFrame.getSelectedTab();

      // call button is pressed over an already open call panel
      if (selectedPanel != null
          && selectedPanel instanceof CallPanel
          && ((CallPanel) selectedPanel).getCall().getCallState()
              == CallState.CALL_INITIALIZATION) {

        NotificationManager.stopSound(NotificationManager.BUSY_CALL);
        NotificationManager.stopSound(NotificationManager.INCOMING_CALL);

        CallPanel callPanel = (CallPanel) selectedPanel;

        Iterator participantPanels = callPanel.getParticipantsPanels();

        while (participantPanels.hasNext()) {
          CallParticipantPanel panel = (CallParticipantPanel) participantPanels.next();

          panel.setState("Connecting");
        }

        Call call = callPanel.getCall();

        answerCall(call);
      }
      // call button is pressed over the call list
      else if (selectedPanel != null
          && selectedPanel instanceof CallListPanel
          && ((CallListPanel) selectedPanel).getCallList().getSelectedIndex() != -1) {

        CallListPanel callListPanel = (CallListPanel) selectedPanel;

        GuiCallParticipantRecord callRecord =
            (GuiCallParticipantRecord) callListPanel.getCallList().getSelectedValue();

        String stringContact = callRecord.getParticipantName();

        createCall(stringContact);
      }
      // call button is pressed over the contact list
      else if (selectedPanel != null && selectedPanel instanceof ContactListPanel) {
        // call button is pressed when a meta contact is selected
        if (isCallMetaContact) {
          Object[] selectedContacts =
              mainFrame.getContactListPanel().getContactList().getSelectedValues();

          Vector telephonyContacts = new Vector();

          for (int i = 0; i < selectedContacts.length; i++) {

            Object o = selectedContacts[i];

            if (o instanceof MetaContact) {

              Contact contact =
                  ((MetaContact) o).getDefaultContact(OperationSetBasicTelephony.class);

              if (contact != null) telephonyContacts.add(contact);
              else {
                new ErrorDialog(
                        this.mainFrame,
                        Messages.getI18NString("warning").getText(),
                        Messages.getI18NString(
                                "contactNotSupportingTelephony",
                                new String[] {((MetaContact) o).getDisplayName()})
                            .getText())
                    .showDialog();
              }
            }
          }

          if (telephonyContacts.size() > 0) createCall(telephonyContacts);

        } else if (!phoneNumberCombo.isComboFieldEmpty()) {

          // if no contact is selected checks if the user has chosen
          // or has
          // writen something in the phone combo box

          String stringContact = phoneNumberCombo.getEditor().getItem().toString();

          createCall(stringContact);
        }
      } else if (selectedPanel != null && selectedPanel instanceof DialPanel) {
        String stringContact = phoneNumberCombo.getEditor().getItem().toString();
        createCall(stringContact);
      }
    } else if (buttonName.equalsIgnoreCase("hangup")) {
      Component selectedPanel = this.mainFrame.getSelectedTab();

      if (selectedPanel != null && selectedPanel instanceof CallPanel) {

        NotificationManager.stopSound(NotificationManager.BUSY_CALL);
        NotificationManager.stopSound(NotificationManager.INCOMING_CALL);
        NotificationManager.stopSound(NotificationManager.OUTGOING_CALL);

        CallPanel callPanel = (CallPanel) selectedPanel;

        Call call = callPanel.getCall();

        if (removeCallTimers.containsKey(callPanel)) {
          ((Timer) removeCallTimers.get(callPanel)).stop();
          removeCallTimers.remove(callPanel);
        }

        removeCallPanel(callPanel);

        if (call != null) {
          ProtocolProviderService pps = call.getProtocolProvider();

          OperationSetBasicTelephony telephony = mainFrame.getTelephonyOpSet(pps);

          Iterator participants = call.getCallParticipants();

          while (participants.hasNext()) {
            try {
              // now we hang up the first call participant in the
              // call
              telephony.hangupCallParticipant((CallParticipant) participants.next());
            } catch (OperationFailedException e) {
              logger.error("Hang up was not successful: " + e);
            }
          }
        }
      }
    } else if (buttonName.equalsIgnoreCase("minimize")) {
      JCheckBoxMenuItem hideCallPanelItem =
          mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem();

      if (!hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(true);

      this.setCallPanelVisible(false);
    } else if (buttonName.equalsIgnoreCase("restore")) {

      JCheckBoxMenuItem hideCallPanelItem =
          mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem();

      if (hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(false);

      this.setCallPanelVisible(true);
    }
  }
Exemplo n.º 23
0
 public NewDocumentAction() {
   super("Add document", MainFrame.getIcon("add-document"));
   putValue(SHORT_DESCRIPTION, "Add new document(s) to this corpus");
   putValue(MNEMONIC_KEY, KeyEvent.VK_ENTER);
 }
Exemplo n.º 24
0
  public static void zoomToFit(Viewport2 viewport) {
    ViewDefinition viewdef = viewport.getViewDefinition();
    // if (MainFrame.getInstance().getMeshToolBar().getMode() != MeshToolBar.VIEW_ZOOM) {
    //	MainFrame.getInstance().getJPatchScreen().removeAllMouseListeners();
    //	MainFrame.getInstance().getJPatchScreen().addMouseListeners(new
    // ChangeViewMouseListener(MouseEvent.BUTTON1,ChangeViewMouseListener.ZOOM));
    //	MainFrame.getInstance().getMeshToolBar().setMode(MeshToolBar.VIEW_ZOOM);
    // } else {
    //	MainFrame.getInstance().getMeshToolBar().reset();
    // }
    Selection selection = MainFrame.getInstance().getSelection();
    float left = Float.MAX_VALUE;
    float right = -Float.MAX_VALUE;
    float bottom = Float.MAX_VALUE;
    float top = -Float.MAX_VALUE;
    Point3f p3 = new Point3f();
    Matrix4f m4View = viewdef.getScreenMatrix();
    // Matrix3f m3RotScale = new Matrix3f();
    // m4View.getRotationScale(m3RotScale);
    boolean doit = true;
    if (selection != null && !selection.isSingle()) {
      for (Iterator it = selection.getObjects().iterator(); it.hasNext(); ) {
        Object object = it.next();
        if (object instanceof ControlPoint) {
          p3.set(((ControlPoint) object).getPosition());
          m4View.transform(p3);
          if (p3.x < left) left = p3.x;
          if (p3.x > right) right = p3.x;
          if (p3.y < bottom) bottom = p3.y;
          if (p3.y > top) top = p3.y;
        }
      }
    } else {
      ArrayList heads = MainFrame.getInstance().getModel().allHeads();
      int p = 0;
      for (Iterator it = heads.iterator(); it.hasNext(); ) {
        ControlPoint cp = (ControlPoint) it.next();
        if (!cp.isHidden()) {
          p3.set(cp.getPosition());
          m4View.transform(p3);
          if (p3.x < left) left = p3.x;
          if (p3.x > right) right = p3.x;
          if (p3.y < bottom) bottom = p3.y;
          if (p3.y > top) top = p3.y;
          p++;
        }
      }
      doit = (p >= 2);
    }
    if (doit) {
      // System.out.println(left + " " + right + " " + top + " " + bottom + " " +
      // viewdef.getScale());
      // System.out.println(viewdef.getTranslateX() + " " + viewdef.getTranslateY());
      float centerX = (left + right) / 2f;
      float centerY = (top + bottom) / 2f;
      float dimX = viewdef.getWidth() / 2f;
      float dimY = viewdef.getHeight() / 2f;
      float sizeX = right - centerX;
      float sizeY = top - centerY;
      if (sizeX > 0 || sizeY > 0) {
        // System.out.println(centerX + ":" + centerY);

        float scaleX = dimX / sizeX;
        float scaleY = dimY / sizeY;
        float scale = Math.min(scaleX, scaleY) * 0.9f;
        // viewdef.setScale(viewdef.getScale() * scale);
        viewdef.setLock(null);
        viewdef.moveView(-centerX / dimX + 1, (dimY - centerY) / dimX, false);
        viewdef.scaleView(scale);
        // viewdef.setTranslation(centerX, centerY);
        // viewdef.computeMatrix();
        // viewport.render();
      }
    }
  }
Exemplo n.º 25
0
 /** Shows the "about OLS" dialog on screen. the parent window to use, can be <code>null</code>. */
 public void showAboutBox() {
   MainFrame.showAboutBox(this.host.getVersion());
 }
Exemplo n.º 26
0
  ViewsPane(WordCollection collection) {
    super(null, true, true, false);
    final Messages messages = AppPrefs.getInstance().getMessages();

    // change find label
    setFindButtonLabel(messages.getString("btnFindViews"));

    _collection = collection;
    getList().setModel(new BasicListModel());

    final MainFrame mf = MainFrame.getInstance();
    ListSelectionModel model = getList().getSelectionModel();
    model.addListSelectionListener(
        new ListSelectionListener() {
          public synchronized void valueChanged(ListSelectionEvent evt) {
            try {
              View view = (View) getList().getSelectedValue();
              if (view != null) {
                Setting setting = _collection.getDatabase().getCurrentSetting();
                setting.setViewID(view.getID());
                setting.save();
                mf.updateStatus();
              }
            } catch (DatabaseException e) {
              Dialogs.genericError(e);
            }
          }
        });

    addAddEditDeleteListener(
        new AddEditDeleteListener() {
          public void doAdd(ActionEvent evt) throws DatabaseException {
            final View view = _collection.makeView();
            AddDialog dialog = new AddDialog("lblAddView", view);
            dialog.setVisible(true);
            if (!dialog.isCancelled()) {
              // add default groups and alignments
              AddRunnable task =
                  new AddRunnable() {
                    public void run() {
                      try {
                        ViewDuplicator.makeGroupsAndAlignments(view, view, _collection, false);

                        // update collection view list
                        List views = _collection.getViews();
                        views.add(view);

                        _collection.getDatabase().getCurrentSetting().setViewID(view.getID());
                        refresh();
                      } catch (DatabaseException ex) {
                        exception = ex;
                      }
                    }

                    DatabaseException exception = null;

                    public DatabaseException getException() {
                      return exception;
                    }
                  };
              Messages m = AppPrefs.getInstance().getMessages();
              Dialogs.indeterminateProgressDialog(
                  task,
                  m.getString("pgbWaitString"),
                  m.getString("pgbCurrentTask") + m.getString("lblAddView"));
              if (task.getException()
                  != null) { // so we don't swallow the exception from the other thread.
                throw task.getException();
              }
            }
          }

          public void doCopy(ActionEvent evt) throws DatabaseException {
            ViewDuplicator duplicator =
                new ViewDuplicator((View) getList().getSelectedValue(), _collection);
            TaskDialog dialog = new TaskDialog("lblViewCopy", duplicator);
            dialog.setVisible(true);
            if (!dialog.isCancelled()) {
              // update collection view list
              List views = _collection.getViews();
              View view = duplicator.getDuplicate();
              if (view != null) { // view will be null if attempted duplicate view name.
                views.add(view);
                _collection.getDatabase().getCurrentSetting().setViewID(view.getID());
                refresh();
              }
            }
          }

          public void doDelete(ActionEvent evt) throws DatabaseException {
            View view = (View) getList().getSelectedValue();

            // check for Original view
            View original = _collection.getOriginalView();
            if (view.equals(original)) {
              Dialogs.error(messages.getString("msgErrDeletingOriginalView"));
            } else {
              view.delete();

              // update collection view list
              List views = _collection.getViews();
              views.remove(view);
              changeView(original);

              JSplitPane split = (JSplitPane) getMainComponent();
              int loc = split.getDividerLocation();
              split.setRightComponent(new JLabel(""));
              split.setDividerLocation(loc);
              refresh();
            }
          }

          public void doValidate(ActionEvent evt) {}

          public void doMoveUp(ActionEvent evt) {}

          public void doMoveDown(ActionEvent evt) {}
        });

    getList().setCellRenderer(new ViewNameListCellRenderer());
  }
Exemplo n.º 27
0
 public MoveUpAction() {
   super("Move up", MainFrame.getIcon("up"));
   putValue(SHORT_DESCRIPTION, "Moves selected document(s) up");
   putValue(MNEMONIC_KEY, KeyEvent.VK_UP);
 }
Exemplo n.º 28
0
 public void actionPerformed(ActionEvent actionEvent) {
   zoomToFit(MainFrame.getInstance().getJPatchScreen().getActiveViewport());
 }
Exemplo n.º 29
0
 public RemoveDocumentsAction() {
   super("Remove documents", MainFrame.getIcon("remove-document"));
   putValue(SHORT_DESCRIPTION, "Removes selected document(s) from this corpus");
   putValue(MNEMONIC_KEY, KeyEvent.VK_DELETE);
 }