예제 #1
0
  /**
   * Implements the <tt>ListCellRenderer</tt> method. Returns this panel that has been configured to
   * display bundle name, version and description.
   *
   * @param table the parent table
   * @param value the value of the rendered cell
   * @param isSelected indicates if the rendered cell is selected
   * @param hasFocus indicates if the rendered cell has the focus
   * @param rowIndex the row index of the rendered cell
   * @param vColIndex the column index of the rendered cell
   * @return the rendering component
   */
  public Component getTableCellRendererComponent(
      JTable table,
      Object value,
      boolean isSelected,
      boolean hasFocus,
      int rowIndex,
      int vColIndex) {
    Bundle bundle = (Bundle) value;

    Dictionary<?, ?> headers = bundle.getHeaders();
    Object bundleName = headers.get(Constants.BUNDLE_NAME);
    Object bundleVersion = headers.get(Constants.BUNDLE_VERSION);
    Object bundleDescription = headers.get(Constants.BUNDLE_DESCRIPTION);

    Icon stateIcon = getStateIcon(bundle.getState());

    if (bundleName != null) this.nameLabel.setText(bundleName.toString());
    else this.nameLabel.setText("unknown");

    if (bundleVersion != null) this.versionLabel.setText(bundleVersion.toString());
    else this.versionLabel.setText("");

    if (bundleDescription != null) this.descriptionLabel.setText(bundleDescription.toString());
    else this.descriptionLabel.setText("");

    if (stateIcon != null) this.stateLabel.setIcon(stateIcon);

    this.nameVersionPanel.remove(systemLabel);

    if (PluginManagerActivator.isSystemBundle(bundle)) this.nameVersionPanel.add(systemLabel);

    this.isSelected = isSelected;

    return this;
  }
예제 #2
0
 public void initText() {
   this.setTitle(Bundle.getText("JDialogAlerteTitle"));
   labelDestinataire.setText(Bundle.getText("JDialogAlerteTo"));
   labelObjet.setText(Bundle.getText("JDialogAlerteObject"));
   buttonOK.setText(Bundle.getText("JDialogAlerteSend"));
   buttonCancel.setText(Bundle.getText("JDialogAlerteCancel"));
 }
  /**
   * Removes the selected ext value
   *
   * @param row the row in the table of the ext value to be deleted
   */
  public void remValue(int row) {
    if (row >= 0) {
      int answer =
          JOptionPane.showConfirmDialog(
              null,
              Bundle.getMessage(Bundle.MSG_DELETE_EXT_KEY),
              Bundle.getMessage(Bundle.MSG_DELETE_EXT_KEY_TITLE),
              JOptionPane.YES_NO_OPTION);

      if (answer == 0) {
        xVal.remove(row);
      }
    }
    fireTableDataChanged();
  }
  /**
   * Adds a ext value
   *
   * @return the position in table where the new ext value was added
   */
  public int addValue() {
    String newValue = new String(Bundle.getMessage(Bundle.NEW_VALUE));
    xVal.add(newValue);

    fireTableDataChanged();
    return xVal.size() - 1;
  }
 /**
  * Sets the value in the cell at col and row to value.
  *
  * @param value the new value
  * @param row the row whose value is to be changed
  * @param col the column whose value is to be changed
  */
 public void setValueAt(Object value, int row, int col) {
   String val = (String) value;
   if ((val != null) && (!val.equals(""))) {
     xVal.set(row, val);
   } else {
     JOptionPane.showMessageDialog(null, Bundle.getMessage(Bundle.MSG_VALUE_EMPTY));
   }
 }
 public void setBundle(Bundle b) {
   try {
     MetaTypeInformation mtp = Activator.getMTP(b);
     jcmInfo.setProvider(mtp, b);
   } catch (Exception e) {
     e.printStackTrace();
     Activator.log.error("Failed to get MetaTypeInformation from bundle " + b.getBundleId(), e);
   }
 }
 private ToolAdapterOperatorDescriptor requestSelection() {
   ToolAdapterOperatorDescriptor selected = null;
   int selectedRow = operatorsTable.getSelectedRow();
   if (selectedRow >= 0) {
     selected = ((OperatorsTableModel) operatorsTable.getModel()).getObjectAt(selectedRow);
   } else {
     SnapDialogs.showWarning(Bundle.MessageNoSelection_Text());
   }
   return selected;
 }
예제 #8
0
 /**
  * Invoked when an action occurs.
  *
  * @param e <tt>ActionEvent</tt>.
  */
 public void actionPerformed(ActionEvent e) {
   Object tmp = skinSelector.getSelectedItem();
   if (tmp != null) {
     if (tmp instanceof Bundle) {
       try {
         ((Bundle) tmp).uninstall();
       } catch (BundleException ex) {
       }
     }
   }
 }
 public static void showDialog(AppContext appContext, String helpID) {
   if (instance == null) {
     instance = new ToolAdaptersManagementDialog(appContext, Bundle.Dialog_Title(), helpID);
   }
   instance.show();
 }
  private JTable createPropertiesPanel() {
    DefaultTableModel model =
        new DefaultTableModel(1, 2) {
          @Override
          public boolean isCellEditable(int row, int column) {
            return column == 1;
          }
        };
    model.setValueAt(Bundle.PathLabel_Text(), 0, 0);
    model.setValueAt(ToolAdapterIO.getUserAdapterPath(), 0, 1);
    model.addTableModelListener(
        l -> {
          String newPath = model.getValueAt(0, 1).toString();
          File path = new File(newPath);
          if (!path.exists()
              && SnapDialogs.Answer.YES
                  == SnapDialogs.requestDecision(
                      "Path does not exist",
                      "The path you have entered does not exist.\nDo you want to create it?",
                      true,
                      "Don't ask me in the future")) {
            if (!path.mkdirs()) {
              SnapDialogs.showError("Path could not be created!");
            }
          }
          if (path.exists()) {
            File oldPath = ToolAdapterIO.getUserAdapterPath();
            ToolAdapterOperatorDescriptor[] operatorDescriptors =
                ToolAdapterActionRegistrar.getActionMap()
                    .values()
                    .toArray(
                        new ToolAdapterOperatorDescriptor
                            [ToolAdapterActionRegistrar.getActionMap().values().size()]);
            for (ToolAdapterOperatorDescriptor descriptor : operatorDescriptors) {
              ToolAdapterActionRegistrar.removeOperatorMenu(descriptor);
            }
            ToolAdapterIO.setAdaptersPath(Paths.get(newPath));
            if (!newPath.equals(oldPath.getAbsolutePath())) {
              Collection<ToolAdapterOpSpi> toolAdapterOpSpis =
                  ToolAdapterIO.searchAndRegisterAdapters();
              for (ToolAdapterOpSpi spi : toolAdapterOpSpis) {
                ToolAdapterActionRegistrar.registerOperatorMenu(
                    (ToolAdapterOperatorDescriptor) spi.getOperatorDescriptor());
              }
              refreshContent();
            }
          }
        });
    JTable table = new JTable(model);
    TableColumn labelColumn = table.getColumnModel().getColumn(0);
    labelColumn.setPreferredWidth((CHECK_COLUMN_WIDTH + LABEL_COLUMN_WIDTH) / 2);
    TableColumn pathColumn = table.getColumnModel().getColumn(1);
    pathColumn.setPreferredWidth(COLUMN_WIDTH);
    pathColumn.setCellEditor(new FileChooserCellEditor());
    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    table.setRowHeight(PATH_ROW_HEIGHT);
    table.setBorder(BorderFactory.createLineBorder(Color.black));
    table.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {}

          @Override
          public void focusLost(FocusEvent e) {
            Object source = e.getSource();
            if (!table.equals(source)) {
              table.editingCanceled(new ChangeEvent(source));
              table.clearSelection();
            }
          }
        });
    return table;
  }
  private JPanel createButtonsPanel() {
    JPanel panel = new JPanel(new SpringLayout());

    /** New adapter button */
    panel.add(
        createButton(
            "New",
            TangoIcons.actions_document_new(TangoIcons.Res.R22),
            Bundle.ToolTipNewOperator_Text(),
            e -> {
              ToolAdapterOperatorDescriptor newOperatorSpi =
                  new ToolAdapterOperatorDescriptor(
                      ToolAdapterConstants.OPERATOR_NAMESPACE + "NewOperator",
                      ToolAdapterOp.class,
                      "NewOperator",
                      null,
                      null,
                      null,
                      null,
                      null,
                      null);
              ToolAdapterEditorDialog dialog =
                  new ToolAdapterEditorDialog(appContext, newOperatorSpi, true);
              dialog.show();
              refreshContent();
            }));
    /** Duplicate adapter button */
    panel.add(
        createButton(
            "Copy",
            TangoIcons.actions_edit_copy(TangoIcons.Res.R22),
            Bundle.ToolTipCopyOperator_Text(),
            e -> {
              ToolAdapterOperatorDescriptor operatorDesc = requestSelection();
              if (operatorDesc != null) {
                String opName = operatorDesc.getName();
                int newNameIndex = 0;
                while (GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(opName)
                    != null) {
                  newNameIndex++;
                  opName =
                      operatorDesc.getName()
                          + ToolAdapterConstants.OPERATOR_GENERATED_NAME_SEPARATOR
                          + newNameIndex;
                }
                ToolAdapterEditorDialog dialog =
                    new ToolAdapterEditorDialog(appContext, operatorDesc, newNameIndex);
                dialog.show();
                refreshContent();
              }
            }));
    /** Edit adapter button */
    panel.add(
        createButton(
            "Edit",
            TangoIcons.apps_accessories_text_editor(TangoIcons.Res.R22),
            Bundle.ToolTipEditOperator_Text(),
            e -> {
              ToolAdapterOperatorDescriptor operatorDesc = requestSelection();
              if (operatorDesc != null) {
                ToolAdapterEditorDialog dialog =
                    new ToolAdapterEditorDialog(appContext, operatorDesc, false);
                dialog.show();
                refreshContent();
              }
            }));
    /** Delete adapter button */
    panel.add(
        createButton(
            "Delete",
            TangoIcons.actions_edit_clear(TangoIcons.Res.R22),
            Bundle.ToolTipDeleteOperator_Text(),
            e -> {
              ToolAdapterOperatorDescriptor operatorDescriptor = requestSelection();
              if (operatorDescriptor != null) {
                if (SnapDialogs.Answer.YES
                    == SnapDialogs.requestDecision(
                        Bundle.MessageConfirmRemoval_TitleText(),
                        Bundle.MessageConfirmRemoval_Text(),
                        true,
                        Bundle.MessageConfirmRemovalDontAsk_Text())) {
                  if (operatorDescriptor.isFromPackage()) {
                    SnapDialogs.showWarning(
                        String.format(
                            Bundle.MessagePackageModules_Text(), operatorDescriptor.getName()));
                  } else {
                    ToolAdapterActionRegistrar.removeOperatorMenu(operatorDescriptor);
                    ToolAdapterIO.removeOperator(operatorDescriptor);
                  }
                  refreshContent();
                }
              }
            }));
    /** Execute adapter button */
    panel.add(
        createButton(
            "Run",
            TangoIcons.actions_media_playback_start(TangoIcons.Res.R22),
            Bundle.ToolTipExecuteOperator_Text(),
            e -> {
              ToolAdapterOperatorDescriptor operatorDesc = requestSelection();
              if (operatorDesc != null) {
                // close();
                final ToolAdapterExecutionDialog operatorDialog =
                    new ToolAdapterExecutionDialog(
                        operatorDesc, appContext, operatorDesc.getLabel());
                operatorDialog.show();
              }
            }));

    makeCompactGrid(panel, 1, 5, 0, 0, DEFAULT_PADDING, DEFAULT_PADDING);

    return panel;
  }
예제 #12
0
  private void buttonOKActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_buttonOKActionPerformed

    // verification si les champs sont vides
    if (textIndDestinataire.getText().equals("")
        || textIndObjet.getText().equals("")
        || textMessage.getText().equals("")) {
      JOptionPane.showMessageDialog(
          this,
          Bundle.getText("JDialogAlerteChampsVides"),
          Bundle.getText("JDialogAlerteAttentionMessage"),
          JOptionPane.WARNING_MESSAGE);
      return;
    }

    try {
      // Envoie du login et du password a la servlet "CreerSuperviseurServlet" pour l'ajouter a la
      // BD
      URL url =
          new URL(
              "http://"
                  + P2S.P2S.Preferences.getProperty("host")
                  + ":"
                  + P2S.P2S.Preferences.getProperty("port")
                  + "/p2sserver/CreerUnMessageServlet?login="******"&sujet="
                  + this.textIndObjet.getText()
                  + "&message="
                  + this.textMessage.getText());

      // Buffer qui va recuperer la reponse de la servlet
      BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
      // On recupere la reponse
      String inputLine = in.readLine();
      if (inputLine.equalsIgnoreCase("ok")) { // on a enregistré dans la bd
        this.dispose();
        in.close();
        return;
      } else if (inputLine.equalsIgnoreCase("nok")) {
        JOptionPane.showMessageDialog(
            this,
            Bundle.getText("JDialogAlerteNoSup"),
            Bundle.getText("JDialogAlerteAttentionMessage"),
            JOptionPane.WARNING_MESSAGE);
      }
      in.close();
    } catch (MalformedURLException e1) {
      javax.swing.JOptionPane.showMessageDialog(
          null,
          Bundle.getText("ExceptionErrorURL"),
          Bundle.getText("ExceptionErrorTitle"),
          javax.swing.JOptionPane.ERROR_MESSAGE);
    } catch (IOException e2) {
      javax.swing.JOptionPane.showMessageDialog(
          null,
          Bundle.getText("ExceptionErrorIO"),
          Bundle.getText("ExceptionErrorTitle"),
          javax.swing.JOptionPane.ERROR_MESSAGE);
    } catch (IllegalArgumentException e3) {
      javax.swing.JOptionPane.showMessageDialog(
          null,
          Bundle.getText("ExceptionErrorARGS"),
          Bundle.getText("ExceptionErrorTitle"),
          javax.swing.JOptionPane.ERROR_MESSAGE);
    }
  } // GEN-LAST:event_buttonOKActionPerformed