Example #1
0
 protected Component createRightComponent() {
   SavePane pane = (SavePane) super.createRightComponent();
   AliasTextRow row = (AliasTextRow) pane.getPropertyPane().getInfo().getRow("name");
   row.setAliasing(
       "Original", AppPrefs.getInstance().getMessages().getString("lblViewNameOriginal"));
   return pane;
 }
Example #2
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
   if (String.valueOf(value).equals("Original")) {
     setText(AppPrefs.getInstance().getMessages().getString("lblViewNameOriginal"));
   }
   // TODO, also remember about adding views, shouldn't allow localized original value
   return this;
 }
Example #3
0
    private boolean doUndefineGraphemeCluster() {
      Messages messages = AppPrefs.getInstance().getMessages();
      TaskDialog dialog =
          new TaskDialog(
              "lblViewsUndefineGraphemeCluster",
              new UndefineGraphemeClusterTask(_view),
              "ViewsUndefineGraphemeCluster");
      dialog.setVisible(true);

      return !dialog.isCancelled();
    }
Example #4
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());
  }