⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 statusline.java

📁 jfa2ce 源码帮助开发人员更好的理解运用
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }        };        if (fProgressBar == null) {			return;		}        fProgressBar.getDisplay().timerExec(DELAY_PROGRESS, timer);        if (!animated) {            fProgressBar.beginTask(totalWork);        }        if (name == null) {			fTaskName = "";//$NON-NLS-1$		} else {			fTaskName = name;		}        setMessage(fTaskName);    }    /**     * Notifies that the work is done; that is, either the main task is completed or the     * user cancelled it.     * Done() can be called more than once; an implementation should be prepared to handle     * this case.     */    public void done() {        fStartTime = 0;        if (fProgressBar != null) {            fProgressBar.sendRemainingWork();            fProgressBar.done();        }        setMessage(null);        hideProgress();    }    /**     * Returns the status line's progress monitor     * @return {@link IProgressMonitor} the progress monitor     */    public IProgressMonitor getProgressMonitor() {        return this;    }    /**     * @private     */    protected void handleDispose() {    	if (fStopButtonCursor != null) {    		fStopButtonCursor.dispose();		    		fStopButtonCursor = null;    	}    	if (fProgressBar != null) {    		fProgressBar.dispose();    		fProgressBar = null;    	}    }    /**     * Hides the Cancel button and ProgressIndicator.     * @private     */    protected void hideProgress() {        if (fProgressIsVisible && !isDisposed()) {            fProgressIsVisible = false;            fCancelEnabled = false;            fCancelButtonIsVisible = false;            if (fToolBar != null && !fToolBar.isDisposed()) {				fToolBar.setVisible(false);			}            if (fProgressBarComposite != null                    && !fProgressBarComposite.isDisposed()) {				fProgressBarComposite.setVisible(false);			}            layout();        }    }    /**     * @see IProgressMonitor#internalWorked(double)     */    public void internalWorked(double work) {        if (!fProgressIsVisible) {            if (System.currentTimeMillis() - fStartTime > DELAY_PROGRESS) {				showProgress();			}        }        if (fProgressBar != null) {            fProgressBar.worked(work);        }    }    /**     * Returns true if the user does some UI action to cancel this operation.     * (like hitting the Cancel button on the progress dialog).     * The long running operation typically polls isCanceled().     */    public boolean isCanceled() {        return fIsCanceled;    }    /**     * Returns <code>true</true> if the ProgressIndication provides UI for canceling     * a long running operation.     * @return <code>true</true> if the ProgressIndication provides UI for canceling     */    public boolean isCancelEnabled() {        return fCancelEnabled;    }    /**     * Sets the cancel status. This method is usually called with the      * argument false if a client wants to abort a cancel action.     */    public void setCanceled(boolean b) {        fIsCanceled = b;        if (fCancelButton != null) {			fCancelButton.setEnabled(!b);		}    }    /**     * Controls whether the ProgressIndication provides UI for canceling     * a long running operation.     * If the ProgressIndication is currently visible calling this method may have     * a direct effect on the layout because it will make a cancel button visible.     *       * @param enabled <code>true</true> if cancel should be enabled     */    public void setCancelEnabled(boolean enabled) {        fCancelEnabled = enabled;        if (fProgressIsVisible && !fCancelButtonIsVisible && enabled) {            showButton();            layout();        }        if (fCancelButton != null && !fCancelButton.isDisposed()) {			fCancelButton.setEnabled(enabled);		}    }    /**     * Sets the error message text to be displayed on the status line.     * The image on the status line is cleared.     *      * @param message the error message, or <code>null</code> for no error message     */    public void setErrorMessage(String message) {        setErrorMessage(null, message);    }    /**     * Sets an image and error message text to be displayed on the status line.     *      * @param image the image to use, or <code>null</code> for no image     * @param message the error message, or <code>null</code> for no error message     */    public void setErrorMessage(Image image, String message) {        fErrorText = trim(message);        fErrorImage = image;        updateMessageLabel();    }    /**     * Applies the given font to this status line.     */    public void setFont(Font font) {        super.setFont(font);        Control[] children = getChildren();        for (int i = 0; i < children.length; i++) {            children[i].setFont(font);        }    }    /**     * Sets the message text to be displayed on the status line.     * The image on the status line is cleared.     *      * @param message the error message, or <code>null</code> for no error message     */    public void setMessage(String message) {        setMessage(null, message);    }    /**     * Sets an image and a message text to be displayed on the status line.     *      * @param image the image to use, or <code>null</code> for no image     * @param message the message, or <code>null</code> for no message     */    public void setMessage(Image image, String message) {        fMessageText = trim(message);        fMessageImage = image;        updateMessageLabel();    }    /**     * @see IProgressMonitor#setTaskName(java.lang.String)     */    public void setTaskName(String name) {        fTaskName = name;    }    /**     * Makes the Cancel button visible.     * @private     */    protected void showButton() {        if (fToolBar != null && !fToolBar.isDisposed()) {            fToolBar.setVisible(true);            fToolBar.setEnabled(true);            fToolBar.setCursor(fStopButtonCursor);            fCancelButtonIsVisible = true;        }    }    /**     * Shows the Cancel button and ProgressIndicator.     * @private     */    protected void showProgress() {        if (!fProgressIsVisible && !isDisposed()) {            fProgressIsVisible = true;            if (fCancelEnabled) {				showButton();			}            if (fProgressBarComposite != null                    && !fProgressBarComposite.isDisposed()) {				fProgressBarComposite.setVisible(true);			}            layout();        }    }    /**     * @private     */    void startTask(final long timestamp, final boolean animated) {        if (!fProgressIsVisible && fStartTime == timestamp) {            showProgress();            if (animated) {                if (fProgressBar != null && !fProgressBar.isDisposed()) {                    fProgressBar.beginAnimatedTask();                }            }        }    }    /**     * Notifies that a subtask of the main task is beginning.     * Subtasks are optional; the main task might not have subtasks.     * @param name the name (or description) of the subtask     * @see IProgressMonitor#subTask(String)     */    public void subTask(String name) {        String text;        if (fTaskName.length() == 0) {			text = name;		} else {			text = JFaceResources.format(                    "Set_SubTask", new Object[] { fTaskName, name });//$NON-NLS-1$		}        setMessage(text);    }    /**     * Trims the message to be displayable in the status line.     * This just pulls out the first line of the message.     * Allows null.     */    String trim(String message) {        if (message == null) {			return null;		}        int cr = message.indexOf('\r');        int lf = message.indexOf('\n');        if (cr == -1 && lf == -1) {			return message;		}        int len;        if (cr == -1) {			len = lf;		} else if (lf == -1) {			len = cr;		} else {			len = Math.min(cr, lf);		}        return message.substring(0, len);    }    /**     * Updates the message label widget.     */    protected void updateMessageLabel() {        if (fMessageLabel != null && !fMessageLabel.isDisposed()) {            Display display = fMessageLabel.getDisplay();            if ((fErrorText != null && fErrorText.length() > 0)                    || fErrorImage != null) {                fMessageLabel.setForeground(JFaceColors.getErrorText(display));                fMessageLabel.setText(fErrorText);                fMessageLabel.setImage(fErrorImage);            } else {                fMessageLabel.setForeground(display                        .getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));                fMessageLabel.setText(fMessageText == null ? "" : fMessageText); //$NON-NLS-1$                fMessageLabel.setImage(fMessageImage);            }        }    }    /**     * @see IProgressMonitor#worked(int)     */    public void worked(int work) {        internalWorked(work);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -