Package de.reuse

Examples of de.reuse.CommonFileFilter


            fileChooser.addChoosableFileFilter(moreFileFilter);
            fileChooser.setFileFilter(gifFileFilter);

            PropertyChangeListener fileFilterChangeListener = new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent e) {
                    CommonFileFilter ff = (CommonFileFilter) e.getNewValue();

                    if (!e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY))
                        return;

                    if (ff.getSuffix().equalsIgnoreCase("more")) {
                        fileChooser.cancelSelection();
                        Action action = (Action) graphicalEditorActionMap.getInterface("exportView");
                        action.putValue(de.grapheditor.ConstantDefinition.IMAGE_TYPE, "more");
                        action.putValue(de.grapheditor.ConstantDefinition.UI_FRAME, uiFrame);
                        action.actionPerformed(null);
                        ((JFileChooser) e.getSource()).removePropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, this);
                    }
                }
            };

            fileChooser.addPropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, fileFilterChangeListener);

            for (; ;) {
                if (fileChooser.showDialog(uiFrame, null) == JFileChooser.APPROVE_OPTION) {
                    imageFile = fileChooser.getSelectedFile();
                    CommonFileFilter currentFilter = (CommonFileFilter) fileChooser.getFileFilter();

                    if (!currentFilter.getSuffix().equalsIgnoreCase(CommonFileFilter.getSuffix(imageFile))) {
                        String path = imageFile.getPath() + "." + currentFilter.getSuffix();
                        imageFile = new File(path);
                    }

                    if (imageFile.exists()) {
                        int result_tmp = JOptionPane.showConfirmDialog(uiFrame, "�ļ� " + imageFile.getPath() + " �Ѿ����ڣ��Ƿ񸲸Ǹ��ļ���", "ȷ�ϴ���", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);

                        if (result_tmp == JOptionPane.YES_OPTION) {
                            break;
                        } else {
                            continue;
                        }
                    }

                    break;
                } else {
                    break;
                }
            }

            fileChooser.removePropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, fileFilterChangeListener);

            CommonFileFilter selectedFilter = (CommonFileFilter) fileChooser.getFileFilter();

            fileChooser.removeChoosableFileFilter(moreFileFilter);
            fileChooser.removeChoosableFileFilter(svgFileFilter);
            fileChooser.removeChoosableFileFilter(gifFileFilter);

            for (int i = 0; i < oldFilter.length; i++) {
                fileChooser.addChoosableFileFilter(oldFilter[i]);
            }
            fileChooser.setSelectedFile(null);
            //end: get the image file's path from user

            //begin:
            if (imageFile == null)
                return;

            if (!imageFile.exists()) {
                try {
                    imageFile.createNewFile();
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(uiFrame, "�������ļ�ʧ��,����洢�豸�Ƿ�������", "���洰��", JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            //end:

            Action action = (Action) graphicalEditorActionMap.getInterface("exportView");
            action.putValue(de.grapheditor.ConstantDefinition.FILE, imageFile);
            action.putValue(de.grapheditor.ConstantDefinition.IMAGE_TYPE, selectedFilter.getSuffix());
            action.putValue(de.grapheditor.ConstantDefinition.UI_FRAME, uiFrame);
            action.actionPerformed(null);
        }
View Full Code Here


      fileChooser.addChoosableFileFilter(moreFileFilter);
      fileChooser.setFileFilter(gifFileFilter);

      PropertyChangeListener fileFilterChangeListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
          CommonFileFilter ff = (CommonFileFilter) e.getNewValue();

          if (!e.getPropertyName().equals(
              JFileChooser.FILE_FILTER_CHANGED_PROPERTY))
            return;

          if (ff.getSuffix().equalsIgnoreCase("more")) {
            fileChooser.cancelSelection();
            Action action = (Action) graphicalEditorActionMap
                .getInterface("exportView");
            action
                .putValue(
                    de.FeatureModellingTool.GraphicalEditor.ConstantDefinition.IMAGE_TYPE,
                    "more");
            action
                .putValue(
                    de.FeatureModellingTool.GraphicalEditor.ConstantDefinition.UI_FRAME,
                    uiJPanel);
            action.actionPerformed(null);
            ((JFileChooser) e.getSource())
                .removePropertyChangeListener(
                    JFileChooser.FILE_FILTER_CHANGED_PROPERTY,
                    this);
          }
        }
      };

      fileChooser.addPropertyChangeListener(
          JFileChooser.FILE_FILTER_CHANGED_PROPERTY,
          fileFilterChangeListener);

      for (;;) {
        if (fileChooser.showDialog(uiJPanel, null) == JFileChooser.APPROVE_OPTION) {
          imageFile = fileChooser.getSelectedFile();
          CommonFileFilter currentFilter = (CommonFileFilter) fileChooser
              .getFileFilter();

          if (!currentFilter.getSuffix().equalsIgnoreCase(
              CommonFileFilter.getSuffix(imageFile))) {
            String path = imageFile.getPath() + "."
                + currentFilter.getSuffix();
            imageFile = new File(path);
          }

          if (imageFile.exists()) {
            int result_tmp = JOptionPane.showConfirmDialog(
                uiJPanel, "�ļ� " + imageFile.getPath()
                    + " �Ѿ����ڣ��Ƿ񸲸Ǹ��ļ���", "ȷ�ϴ���",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.INFORMATION_MESSAGE);

            if (result_tmp == JOptionPane.YES_OPTION) {
              break;
            } else {
              continue;
            }
          }

          break;
        } else {
          break;
        }
      }

      fileChooser.removePropertyChangeListener(
          JFileChooser.FILE_FILTER_CHANGED_PROPERTY,
          fileFilterChangeListener);

      CommonFileFilter selectedFilter = (CommonFileFilter) fileChooser
          .getFileFilter();

      fileChooser.removeChoosableFileFilter(moreFileFilter);
      fileChooser.removeChoosableFileFilter(svgFileFilter);
      fileChooser.removeChoosableFileFilter(gifFileFilter);

      for (int i = 0; i < oldFilter.length; i++) {
        fileChooser.addChoosableFileFilter(oldFilter[i]);
      }
      fileChooser.setSelectedFile(null);
      // end: get the image file's path from user

      // begin:
      if (imageFile == null)
        return;

      if (!imageFile.exists()) {
        try {
          imageFile.createNewFile();
        } catch (IOException ioe) {
          JOptionPane.showMessageDialog(uiJPanel,
              "�������ļ�ʧ��,����洢�豸�Ƿ�������", "���洰��",
              JOptionPane.ERROR_MESSAGE);
          return;
        }
      }
      // end:

      Action action = (Action) graphicalEditorActionMap
          .getInterface("exportView");
      action
          .putValue(
              de.FeatureModellingTool.GraphicalEditor.ConstantDefinition.FILE,
              imageFile);
      action
          .putValue(
              de.FeatureModellingTool.GraphicalEditor.ConstantDefinition.IMAGE_TYPE,
              selectedFilter.getSuffix());
      action
          .putValue(
              de.FeatureModellingTool.GraphicalEditor.ConstantDefinition.UI_FRAME,
              uiJPanel);
      action.actionPerformed(null);
View Full Code Here

            fileChooser.addChoosableFileFilter(moreFileFilter);
            fileChooser.setFileFilter(gifFileFilter);

            PropertyChangeListener fileFilterChangeListener = new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent e) {
                    CommonFileFilter ff = (CommonFileFilter) e.getNewValue();

                    if (!e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY))
                        return;

                    if (ff.getSuffix().equalsIgnoreCase("more")) {
                        fileChooser.cancelSelection();
                        Action action = (Action) graphicalEditorActionMap.getInterface("exportView");
                        action.putValue(de.grapheditor.ConstantDefinition.IMAGE_TYPE, "more");
                        action.putValue(de.grapheditor.ConstantDefinition.UI_FRAME, uiFrame);
                        action.actionPerformed(null);
                        ((JFileChooser) e.getSource()).removePropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, this);
                    }
                }
            };

            fileChooser.addPropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, fileFilterChangeListener);

            for (; ;) {
                if (fileChooser.showDialog(uiFrame, null) == JFileChooser.APPROVE_OPTION) {
                    imageFile = fileChooser.getSelectedFile();
                    CommonFileFilter currentFilter = (CommonFileFilter) fileChooser.getFileFilter();

                    if (!currentFilter.getSuffix().equalsIgnoreCase(CommonFileFilter.getSuffix(imageFile))) {
                        String path = imageFile.getPath() + "." + currentFilter.getSuffix();
                        imageFile = new File(path);
                    }

                    if (imageFile.exists()) {
                        int result_tmp = JOptionPane.showConfirmDialog(uiFrame, "�ļ� " + imageFile.getPath() + " �Ѿ����ڣ��Ƿ񸲸Ǹ��ļ���", "ȷ�ϴ���", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);

                        if (result_tmp == JOptionPane.YES_OPTION) {
                            break;
                        } else {
                            continue;
                        }
                    }

                    break;
                } else {
                    break;
                }
            }

            fileChooser.removePropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, fileFilterChangeListener);

            CommonFileFilter selectedFilter = (CommonFileFilter) fileChooser.getFileFilter();

            fileChooser.removeChoosableFileFilter(moreFileFilter);
            fileChooser.removeChoosableFileFilter(svgFileFilter);
            fileChooser.removeChoosableFileFilter(gifFileFilter);

            for (int i = 0; i < oldFilter.length; i++) {
                fileChooser.addChoosableFileFilter(oldFilter[i]);
            }
            fileChooser.setSelectedFile(null);
            //end: get the image file's path from user

            //begin:
            if (imageFile == null)
                return;

            if (!imageFile.exists()) {
                try {
                    imageFile.createNewFile();
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(uiFrame, "�������ļ�ʧ��,����洢�豸�Ƿ�������", "���洰��", JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            //end:

            Action action = (Action) graphicalEditorActionMap.getInterface("exportView");
            action.putValue(de.grapheditor.ConstantDefinition.FILE, imageFile);
            action.putValue(de.grapheditor.ConstantDefinition.IMAGE_TYPE, selectedFilter.getSuffix());
            action.putValue(de.grapheditor.ConstantDefinition.UI_FRAME, uiFrame);
            action.actionPerformed(null);
        }
View Full Code Here

            fileChooser.addChoosableFileFilter(moreFileFilter);
            fileChooser.setFileFilter(gifFileFilter);

            PropertyChangeListener fileFilterChangeListener = new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent e) {
                    CommonFileFilter ff = (CommonFileFilter) e.getNewValue();

                    if (!e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY))
                        return;

                    if (ff.getSuffix().equalsIgnoreCase("more")) {
                        fileChooser.cancelSelection();
                        Action action = (Action) graphicalEditorActionMap.getInterface("exportView");
                        action.putValue(de.FeatureModellingTool.GraphicalEditor.ConstantDefinition.IMAGE_TYPE, "more");
                        action.putValue(de.FeatureModellingTool.GraphicalEditor.ConstantDefinition.UI_FRAME, uiJPanel);
                        action.actionPerformed(null);
                        ((JFileChooser) e.getSource()).removePropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, this);
                    }
                }
            };

            fileChooser.addPropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, fileFilterChangeListener);

            for (; ;) {
                if (fileChooser.showDialog(uiJPanel, null) == JFileChooser.APPROVE_OPTION) {
                    imageFile = fileChooser.getSelectedFile();
                    CommonFileFilter currentFilter = (CommonFileFilter) fileChooser.getFileFilter();

                    if (!currentFilter.getSuffix().equalsIgnoreCase(CommonFileFilter.getSuffix(imageFile))) {
                        String path = imageFile.getPath() + "." + currentFilter.getSuffix();
                        imageFile = new File(path);
                    }

                    if (imageFile.exists()) {
                        int result_tmp = JOptionPane.showConfirmDialog(uiJPanel, "�ļ� " + imageFile.getPath() + " �Ѿ����ڣ��Ƿ񸲸Ǹ��ļ���", "ȷ�ϴ���", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);

                        if (result_tmp == JOptionPane.YES_OPTION) {
                            break;
                        } else {
                            continue;
                        }
                    }

                    break;
                } else {
                    break;
                }
            }

            fileChooser.removePropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, fileFilterChangeListener);

            CommonFileFilter selectedFilter = (CommonFileFilter) fileChooser.getFileFilter();

            fileChooser.removeChoosableFileFilter(moreFileFilter);
            fileChooser.removeChoosableFileFilter(svgFileFilter);
            fileChooser.removeChoosableFileFilter(gifFileFilter);

            for (int i = 0; i < oldFilter.length; i++) {
                fileChooser.addChoosableFileFilter(oldFilter[i]);
            }
            fileChooser.setSelectedFile(null);
            //end: get the image file's path from user

            //begin:
            if (imageFile == null)
                return;

            if (!imageFile.exists()) {
                try {
                    imageFile.createNewFile();
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(uiJPanel, "�������ļ�ʧ��,����洢�豸�Ƿ�������", "���洰��", JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
            //end:

            Action action = (Action) graphicalEditorActionMap.getInterface("exportView");
            action.putValue(de.FeatureModellingTool.GraphicalEditor.ConstantDefinition.FILE, imageFile);
            action.putValue(de.FeatureModellingTool.GraphicalEditor.ConstantDefinition.IMAGE_TYPE, selectedFilter.getSuffix());
            action.putValue(de.FeatureModellingTool.GraphicalEditor.ConstantDefinition.UI_FRAME, uiJPanel);
            action.actionPerformed(null);
        }
View Full Code Here

TOP

Related Classes of de.reuse.CommonFileFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.